WIP: refactoring + tile layout

This commit is contained in:
Ray committed 2020-04-11 18:43:20 +01:00
1 parent 06f570122c
commit c9edc93e40
23 files changed
+1078 -491

No files matched your search

+78
View File
@@ -0,0 +1,78 @@
namespace AppLauncher.Windows.Forms
{
partial class TileContainer
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new AppLauncher.Windows.Forms.TileGroupLabel();
this.panel1 = new AppLauncher.Windows.Forms.TileLayoutPanel();
this.SuspendLayout();
//
// label1
//
this.label1.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.label1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.label1.Checked = false;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Margin = new System.Windows.Forms.Padding(0, 0, 0, 3);
this.label1.MinimumSize = new System.Drawing.Size(100, 20);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(223, 20);
this.label1.TabIndex = 11;
this.label1.TileGroupPanel = null;
this.label1.TitleText = "Featured";
//
// panel1
//
this.panel1.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.panel1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.panel1.BackColor = System.Drawing.Color.Transparent;
this.panel1.Location = new System.Drawing.Point(0, 23);
this.panel1.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(223, 127);
this.panel1.TabIndex = 27;
//
// TileContainer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Transparent;
this.Controls.Add(this.panel1);
this.Controls.Add(this.label1);
this.Name = "TileContainer";
this.Size = new System.Drawing.Size(370, 150);
this.ResumeLayout(false);
}
#endregion
private TileGroupLabel label1;
private TileLayoutPanel panel1;
}
}
+124
View File
@@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using AppLauncher.Models;
namespace AppLauncher.Windows.Forms
{
public partial class TileContainer : AUserControl
{
protected int collapseIncrement = 6;
protected int expandIncrement = 8;
protected TileGroupModel groupInfo = null;
public TileContainer(TileGroupModel model) : base()
{
InitializeComponent();
label1.TileGroupPanel = this;
groupInfo = model;
label1.TitleText = groupInfo.Title;
panel1.SetGridSize(groupInfo.GridSize.Width, groupInfo.GridSize.Height);
label1.Checked = groupInfo.IsExpanded;
//label1.Width = panel1.Width;
//label1.PanelHeight = panel1.Height;
//this.Margin = new Padding(0);
//this.Size = new Size(panel1.Width, (label1.Height + panel1.Height));
//this.MaximumSize = this.Size;
//this.MinimumSize = this.Size;
panel1.LoadTiles(model.Items);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
label1.Width = panel1.Width;
this.Margin = new Padding(0);
this.MaximumSize = new Size(panel1.Width, (label1.Height + panel1.ExpandedHeight));
this.MinimumSize = new Size(panel1.Width, label1.Height);
this.Size = this.MaximumSize;
}
protected int collapseHeight => label1.Height + panel1.CollapseHeight;
protected int expandedHeight => label1.Height + panel1.ExpandedHeight;
public async Task Collapse()
{
await Task.Run(() =>
{
while (this.Height > collapseHeight)
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(() => {
this.Height -= collapseIncrement;
}));
}
else
{
this.Height -= collapseIncrement;
}
Thread.Sleep(10);
}
});
}
public async Task CollapseNow()
{
await Task.Run(() =>
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(() => {
this.Height = collapseHeight;
}));
}
else
{
this.Height = collapseHeight;
}
});
}
public async Task Expand()
{
await Task.Run(() =>
{
while (this.Height < expandedHeight)
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(() => {
this.Height += expandIncrement;
this.Invalidate();
}));
}
else
{
this.Height += expandIncrement;
this.Invalidate();
}
Thread.Sleep(10);
}
});
}
}
}
File renamed without changes.
@@ -1,6 +1,6 @@
namespace AppLauncher.Windows.Forms
{
partial class HeadingPanel
partial class TileGroupLabel
{
/// <summary>
/// Required designer variable.
@@ -48,8 +48,8 @@
this.label1.Size = new System.Drawing.Size(575, 20);
this.label1.TabIndex = 8;
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.label1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HeadingPanel_MouseClick);
this.label1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.HeadingPanel_MouseClick);
this.label1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick);
this.label1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick);
//
// pictureBox1
//
@@ -67,8 +67,8 @@
this.pictureBox1.Size = new System.Drawing.Size(20, 20);
this.pictureBox1.TabIndex = 7;
this.pictureBox1.TabStop = false;
this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HeadingPanel_MouseClick);
this.pictureBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.HeadingPanel_MouseClick);
this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick);
this.pictureBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick);
//
// HeadingPanel
//
@@ -79,7 +79,7 @@
this.MinimumSize = new System.Drawing.Size(100, 20);
this.Name = "HeadingPanel";
this.Size = new System.Drawing.Size(600, 20);
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HeadingPanel_MouseClick);
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
@@ -5,11 +5,11 @@ using System.Windows.Forms;
namespace AppLauncher.Windows.Forms
{
public partial class HeadingPanel : AUserControl
public partial class TileGroupLabel : AUserControl
{
protected bool isChecked = false;
public HeadingPanel() : base()
public TileGroupLabel() : base()
{
InitializeComponent();
@@ -32,26 +32,17 @@ namespace AppLauncher.Windows.Forms
}
}
public TilePanelContainer TilePanelContainer { get; set; } = null;
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public TileContainer TileGroupPanel { get; set; } = null;
protected async override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (this.TilePanelContainer != null)
{
if (this.Checked)
{
await this.TilePanelContainer.Expand(120);
}
else
{
await this.TilePanelContainer.Collapse(0);
}
}
await invalidateToggle(false);
}
private async void HeadingPanel_MouseClick(object sender, MouseEventArgs e)
protected async void panel_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
{
@@ -60,18 +51,32 @@ namespace AppLauncher.Windows.Forms
this.Checked = !this.Checked;
if (this.TilePanelContainer != null)
await invalidateToggle();
}
protected async Task invalidateToggle(bool animate = true)
{
if (this.TileGroupPanel == null)
{
if (this.Checked)
return;
}
if (this.Checked)
{
await this.TileGroupPanel.Expand();
}
else
{
if (animate)
{
await this.TilePanelContainer.Expand(120);
await this.TileGroupPanel.Collapse();
}
else
{
await this.TilePanelContainer.Collapse(0);
await this.TileGroupPanel.CollapseNow();
}
}
}
}
}
}
File renamed without changes.
+220
View File
@@ -0,0 +1,220 @@
using AppLauncher.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AppLauncher.Windows.Forms
{
public class TileLayoutPanel : AUserControl
{
public class Item
{
public TilePanel Tile { get; set; }
public Point Coord { get; set; } = new Point(0, 0);
}
protected readonly int tileSize = 70;
protected readonly int margin = 3;
protected int collapseHeight = 0;
protected int expandedHeight = 0;
protected List<Item> items = new List<Item>();
public TileLayoutPanel() : base()
{
this.BackColor = System.Drawing.Color.Transparent;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
OnResize(e);
}
public Point GridSize
{
get
{
int w = (int)Math.Floor(decimal.Divide(this.Width, this.TileSize));
int h = (int)Math.Floor(decimal.Divide(this.Height, this.TileSize));
return new Point(w, h);
}
}
public int TileSize => (tileSize + margin);
public int CollapseHeight => collapseHeight;
public int ExpandedHeight => expandedHeight;
public void Clear()
{
this.Controls.Clear();
}
//public Point GetTileCoord(Point location) => this.GetTileCoord(location.X, location.Y);
//public Point GetTileCoord(int posX, int posY)
//{
// int x = (int)Math.Round(decimal.Divide(posX, this.TileSize));
// int y = (int)Math.Round(decimal.Divide(posY, this.TileSize));
// if (x < 0) x = 0;
// if (y < 0) y = 0;
// return new Point(x, y);
//}
//public Point GetTilePosition(Point location) => this.GetTilePosition(location.X, location.Y);
public Point GetTilePosition(int posX, int posY)
{
int x = (int)Math.Round(decimal.Divide(posX, this.TileSize));
int y = (int)Math.Round(decimal.Divide(posY, this.TileSize));
if (x < 0) x = 0;
if (y < 0) y = 0;
return new Point((x * this.TileSize), (y * this.TileSize));
}
public void SetGridSize(int width, int height)
{
expandedHeight = (this.TileSize * height);
this.Size = new Size((this.TileSize * width), expandedHeight);
}
public void LoadTiles(List<TileModel> tiles)
{
if (tiles == null)
{
return;
}
if (tiles.Count() <= 0)
{
return;
}
foreach (TileModel item in tiles)
{
// resolve final grid position
Point? confirmedPosition = resolvePosition(item.Position);
if (confirmedPosition == null)
{
continue;
}
// place control
TilePanel panel = new TilePanel();
panel.LoadInfo(item);
panel.Location = convertPositionToLocation(confirmedPosition.Value);
items.Add(new Item()
{
Tile = panel,
Coord = confirmedPosition.Value
});
this.Controls.Add(panel);
}
}
public void MoveTile(TilePanel panel, int posX, int posY)
{
}
protected Point convertPositionToLocation(Point position) => new Point((position.X * this.TileSize), (position.Y * this.TileSize));
protected Point? resolvePosition(Point position)
{
if (!isTileInBounds(position))
{
return null;
}
if (!hasTile(position))
{
return position;
}
return resolveNextPosition(position);
}
protected Point? resolveNextPosition(Point position)
{
Point gridSize = this.GridSize;
Point newPosition = position;
while (true)
{
newPosition.X++;
if (newPosition.X >= gridSize.X)
{
newPosition.Y++;
newPosition.X = 0;
}
if (!isTileInBounds(newPosition))
{
return null;
}
if (hasTile(newPosition))
{
continue;
}
return newPosition;
}
}
protected bool hasTile(Point position)
{
if (items == null)
{
return false;
}
if (items.Count <= 0)
{
return false;
}
return (items.Count(x => x.Coord.Equals(position)) > 0);
}
protected bool isTileInBounds(Point position)
{
Point gridSize = this.GridSize;
if (position.X > gridSize.X)
{
return false;
}
if (position.Y > gridSize.Y)
{
return false;
}
return true;
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -44,6 +44,8 @@
this.label1.Size = new System.Drawing.Size(70, 13);
this.label1.TabIndex = 24;
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label1.Click += new System.EventHandler(this.TilePanel_Click);
this.label1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TilePanel_MouseDoubleClick);
//
// pictureBox1
//
@@ -57,6 +59,8 @@
this.pictureBox1.Size = new System.Drawing.Size(70, 38);
this.pictureBox1.TabIndex = 25;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.TilePanel_Click);
this.pictureBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TilePanel_MouseDoubleClick);
//
// TilePanel
//
@@ -71,6 +75,8 @@
this.MinimumSize = new System.Drawing.Size(70, 70);
this.Name = "TilePanel";
this.Size = new System.Drawing.Size(70, 70);
this.Click += new System.EventHandler(this.TilePanel_Click);
this.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TilePanel_MouseDoubleClick);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
+174
View File
@@ -0,0 +1,174 @@
using AppLauncher.Models;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace AppLauncher.Windows.Forms
{
public partial class TilePanel : AUserControl
{
protected bool isDragging = false;
protected Point startPosition = new Point();
protected TileModel model = new TileModel();
public TilePanel() : base()
{
InitializeComponent();
this.MouseDown += panel_MouseDown;
this.MouseUp += panel_MouseUp;
this.MouseMove += panel_MouseMove;
pictureBox1.MouseDown += panel_MouseDown;
pictureBox1.MouseUp += panel_MouseUp;
pictureBox1.MouseMove += panel_MouseMove;
label1.MouseDown += panel_MouseDown;
label1.MouseUp += panel_MouseUp;
label1.MouseMove += panel_MouseMove;
}
[Category("Appearance"), Browsable(true)]
public string Title { get => label1.Text; protected set => label1.Text = value; }
[Category("Appearance"), Browsable(true)]
public Image Image { get => pictureBox1.BackgroundImage; protected set => pictureBox1.BackgroundImage = value; }
[Browsable(false)]
public TileModel Info => model;
//[Browsable(false)]
//public string ProcessArgument { get; set; }
//[Browsable(false)]
//public string ProcessWorkingDirectory { get; set; }
//[Browsable(false)]
//public ProcessWindowStyle ProcessWindowStyle { get; set; } = ProcessWindowStyle.Normal;
public TileLayoutPanel PanelContainer
{
get
{
if (this.Parent == null)
{
return null;
}
if (this.Parent.GetType() != typeof(TileLayoutPanel))
{
return null;
}
return (TileLayoutPanel)this.Parent;
}
}
public void LoadInfo(TileModel model)
{
this.model = model;
this.Title = model.Title;
this.Image = model.Icon;
if (this.Image == null)
{
if (File.Exists(model.ProcessFilename))
{
try
{
this.Image = Icon.ExtractAssociatedIcon(model.ProcessFilename)?.ToBitmap();
}
catch
{
}
}
}
}
private void panel_MouseDown(object sender, MouseEventArgs e)
{
TileLayoutPanel container = this.PanelContainer;
if (container == null)
{
return;
}
if (e.Button != MouseButtons.Left)
{
return;
}
this.BringToFront();
isDragging = true;
startPosition = e.Location;
}
private void panel_MouseUp(object sender, MouseEventArgs e)
{
isDragging = false;
}
private void panel_MouseMove(object sender, MouseEventArgs e)
{
if (isDragging)
{
TileLayoutPanel layoutPanel = this.PanelContainer;
if (layoutPanel == null)
{
return;
}
int x = (this.Location.X + (e.Location.X - startPosition.X));
int y = (this.Location.Y + (e.Location.Y - startPosition.Y));
//this.Location = layoutPanel.GetTilePosition(x, y);
layoutPanel.MoveTile(this, x, y);
}
}
private void TilePanel_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (this.Info == null)
{
return;
}
if (string.IsNullOrWhiteSpace(this.Info.ProcessFilename))
{
return;
}
if (!File.Exists(this.Info.ProcessFilename))
{
return;
}
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = this.Info.ProcessFilename;
p.WindowStyle = this.Info.ProcessWindowStyle;
if (!string.IsNullOrWhiteSpace(this.Info.ProcessArgument)) p.Arguments = this.Info.ProcessArgument;
if (!string.IsNullOrWhiteSpace(this.Info.ProcessWorkingDirectory)) p.WorkingDirectory = this.Info.ProcessWorkingDirectory;
if (this.Info.ProcessAsAdmin) p.Verb = "runas";
try
{
Process.Start(p);
}
catch
{
// do nothing
}
}
private void TilePanel_Click(object sender, EventArgs e)
{
// do nothing yet
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
-150
View File
@@ -1,150 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace AppLauncher.Windows.Forms
{
public partial class TilePanel : AUserControl
{
protected bool isDragging = false;
protected Point startPosition = new Point();
public TilePanel() : base()
{
InitializeComponent();
this.MouseDown += panel_MouseDown;
this.MouseUp += panel_MouseUp;
this.MouseMove += panel_MouseMove;
pictureBox1.MouseDown += panel_MouseDown;
pictureBox1.MouseUp += panel_MouseUp;
pictureBox1.MouseMove += panel_MouseMove;
label1.MouseDown += panel_MouseDown;
label1.MouseUp += panel_MouseUp;
label1.MouseMove += panel_MouseMove;
}
protected override void OnLocationChanged(EventArgs e)
{
base.OnLocationChanged(e);
if (this.Parent != null)
{
if (this.Parent.GetType() == typeof(TilePanelContainer))
{
TilePanelContainer container = (TilePanelContainer)this.Parent;
Point p = container.GetTilePosition(this.Location);
//label1.Text = p.X.ToString() + ", " + p.Y.ToString();
}
}
}
[Category("Appearance"), Browsable(true)]
public string TitleText { get => label1.Text; set => label1.Text = value; }
[Category("Appearance"), Browsable(true)]
public Image IconImage { get => pictureBox1.BackgroundImage; set => pictureBox1.BackgroundImage = value; }
[Browsable(false)]
public string ProcessFilename { get; set; }
[Browsable(false)]
public string ProcessArgument { get; set; }
[Browsable(false)]
public string ProcessWorkingDirectory { get; set; }
[Browsable(false)]
public ProcessWindowStyle ProcessWindowStyle { get; set; } = ProcessWindowStyle.Normal;
public TilePanelContainer PanelContainer
{
get
{
if (this.Parent == null)
{
return null;
}
if (this.Parent.GetType() != typeof(TilePanelContainer))
{
return null;
}
return (TilePanelContainer)this.Parent;
}
}
private void panel_MouseDown(object sender, MouseEventArgs e)
{
TilePanelContainer container = this.PanelContainer;
if (container == null)
{
return;
}
if (e.Button != MouseButtons.Left)
{
return;
}
isDragging = true;
startPosition = e.Location;
}
private void panel_MouseUp(object sender, MouseEventArgs e)
{
isDragging = false;
}
private void panel_MouseMove(object sender, MouseEventArgs e)
{
if (isDragging)
{
TilePanelContainer container = this.PanelContainer;
if (container == null)
{
return;
}
//label1.Text = e.Location.ToString();
//this.Location = new Point(e.Location.X - windowOffset.X, e.Location.Y - windowOffset.Y);
//int x = parentPosition.X + (e.Location.X - positionOffset.X);
//int y = parentPosition.Y + (e.Location.Y - positionOffset.Y);
//this.Location = new Point(x, y);
//int x = (tilePosition.X + e.Location.X);
//int y = (tilePosition.Y + e.Location.Y);
int x = (this.Location.X + (e.Location.X - startPosition.X));
int y = (this.Location.Y + (e.Location.Y - startPosition.Y));
this.Location = container.GetTilePosition(x, y);
//label1.Text = x.ToString() + ", " + y.ToString();
//label1.Text = e.X.ToString() + ", " + e.Y.ToString();
//Point pos = this.PointToScreen(e.Location);
//int y = Math.Max((pos.Y - windowOffset.Y), Screen.PrimaryScreen.WorkingArea.Y);
//y = Math.Min(y, (Screen.PrimaryScreen.WorkingArea.Y + Screen.PrimaryScreen.WorkingArea.Height) - this.Height);
//this.Parent.Location = new Point(Screen.PrimaryScreen.WorkingArea.X, y);
}
}
}
}
-121
View File
@@ -1,121 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AppLauncher.Windows.Forms
{
public class TilePanelContainer : AUserControl
{
protected readonly int tileSize = 70;
protected readonly int margin = 3;
public TilePanelContainer() : base()
{
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
OnResize(e);
}
public Point GridSize
{
get
{
int w = (int)Math.Floor(decimal.Divide(this.Width, this.TileSize));
int h = (int)Math.Floor(decimal.Divide(this.Height, this.TileSize));
return new Point(w, h);
}
}
public int TileSize => (tileSize + margin);
public async Task Collapse(int height, int increment = 6)
{
await Task.Run(() =>
{
while (this.Height > height)
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(() => {
this.Height -= increment;
}));
}
else
{
this.Height -= increment;
}
Thread.Sleep(10);
}
});
}
public async Task Expand(int height, int increment = 8)
{
await Task.Run(() =>
{
while (this.Height < height)
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(() => {
this.Height += increment;
this.Invalidate();
}));
}
else
{
this.Height += increment;
this.Invalidate();
}
Thread.Sleep(10);
}
});
}
public Point GetTileCoord(Point location) => this.GetTileCoord(location.X, location.Y);
public Point GetTileCoord(int posX, int posY)
{
int x = (int)Math.Round(decimal.Divide(posX, this.TileSize));
int y = (int)Math.Round(decimal.Divide(posY, this.TileSize));
if (x < 0) x = 0;
if (y < 0) y = 0;
return new Point(x, y);
}
public Point GetTilePosition(Point location) => this.GetTilePosition(location.X, location.Y);
public Point GetTilePosition(int posX, int posY)
{
int x = (int)Math.Round(decimal.Divide(posX, this.TileSize));
int y = (int)Math.Round(decimal.Divide(posY, this.TileSize));
if (x < 0) x = 0;
if (y < 0) y = 0;
return new Point((x * this.TileSize), (y * this.TileSize));
}
public void SetGridSize(int width, int height)
{
this.Size = new Size((this.TileSize * width), (this.TileSize * height));
}
}
}
+1
View File
@@ -48,6 +48,7 @@
this.pictureBox1.Size = new System.Drawing.Size(40, 40);
this.pictureBox1.TabIndex = 5;
this.pictureBox1.TabStop = false;
this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp);
//
// label1
//
+13
View File
@@ -42,6 +42,8 @@ namespace AppLauncher.Windows.Forms
set => label1.Text = value;
}
public ContextMenuStrip MainMenu { get; set; } = null;
protected void parentForm_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
@@ -71,5 +73,16 @@ namespace AppLauncher.Windows.Forms
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
if (this.MainMenu != null)
{
this.MainMenu.Show(this.PointToScreen(e.Location));
}
}
}
}
}