diff --git a/LinearAppLauncher.csproj b/LinearAppLauncher.csproj
index 071451e..0e11b08 100644
--- a/LinearAppLauncher.csproj
+++ b/LinearAppLauncher.csproj
@@ -82,6 +82,7 @@
THorizontalSeparator.cs
+
Component
@@ -154,14 +155,11 @@
UserControl
-
+
UserControl
-
- TileLayoutContainer.cs
-
-
- UserControl
+
+ TilePanelLayout.cs
UserControl
@@ -213,11 +211,8 @@
EditTileForm.cs
-
- TileLayoutContainer.cs
-
-
- TileLayoutPanel.cs
+
+ TilePanelLayout.cs
TilePanel.cs
diff --git a/MainForm.cs b/MainForm.cs
index b994153..172b6a7 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -1,6 +1,7 @@
using AppLauncher.Models;
using AppLauncher.Windows.Forms;
using Newtonsoft.Json;
+using RyzStudio.Windows.Forms;
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -91,12 +92,12 @@ namespace AppLauncher
List rs = new List();
for (int i = 0; i < flowLayoutPanel1.Controls.Count; i++)
{
- if (flowLayoutPanel1.Controls[i].GetType() != typeof(TileLayoutContainer))
+ if (flowLayoutPanel1.Controls[i].GetType() != typeof(TilePanelLayout))
{
continue;
}
- TileLayoutContainer container = flowLayoutPanel1.Controls[i] as TileLayoutContainer;
+ TilePanelLayout container = flowLayoutPanel1.Controls[i] as TilePanelLayout;
rs.Add(container.Model);
}
@@ -131,19 +132,12 @@ namespace AppLauncher
{
while (this.Width > width)
{
- if (this.InvokeRequired)
- {
- this.Invoke(new MethodInvoker(() => {
- this.Width -= increment;
- }));
- }
- else
- {
- this.Width -= increment;
- }
+ ThreadControl.SetWidth(this, (this.Width - increment));
Application.DoEvents();
}
+
+ ThreadControl.SetWidth(this, width);
});
}
@@ -153,21 +147,12 @@ namespace AppLauncher
{
while (this.Width < width)
{
- if (this.InvokeRequired)
- {
- this.Invoke(new MethodInvoker(() => {
- this.Width += increment;
- //this.Invalidate();
- }));
- }
- else
- {
- this.Width += increment;
- //this.Invalidate();
- }
+ ThreadControl.SetWidth(this, (this.Width + increment));
Application.DoEvents();
}
+
+ ThreadControl.SetWidth(this, width);
});
}
@@ -190,7 +175,7 @@ namespace AppLauncher
foreach (TileGroupModel item in rs)
{
- TileLayoutContainer panel = new TileLayoutContainer(item);
+ TilePanelLayout panel = new TilePanelLayout(item);
maxWidth = Math.Max(maxWidth, panel.Width);
flowLayoutPanel1.Controls.Add(panel);
diff --git a/RyzStudio/Windows/Forms/TFlatButton.cs b/RyzStudio/Windows/Forms/TFlatButton.cs
index efce9a1..b50dee0 100644
--- a/RyzStudio/Windows/Forms/TFlatButton.cs
+++ b/RyzStudio/Windows/Forms/TFlatButton.cs
@@ -1,17 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Drawing;
using System.Windows.Forms;
namespace RyzStudio.Windows.Forms
{
public class TFlatButton : Label
{
- public class FlatButtonStyle
+ public class ButtonStyle
{
public Color BackColour { get; set; } = Color.Transparent;
public Color PenColour { get; set; } = Color.Transparent;
@@ -33,17 +27,17 @@ namespace RyzStudio.Windows.Forms
this.TextAlign = ContentAlignment.MiddleCenter;
// customise
- this.StyleOver = new FlatButtonStyle()
+ this.StyleOver = new ButtonStyle()
{
BackColour = Color.FromArgb(51, 51, 51),
PenColour = Color.White
};
- this.StyleDown = new FlatButtonStyle()
+ this.StyleDown = new ButtonStyle()
{
BackColour = Color.FromArgb(179, 179, 179),
PenColour = Color.Black
};
- this.StyleDefault = new FlatButtonStyle()
+ this.StyleDefault = new ButtonStyle()
{
BackColour = Color.White,
PenColour = Color.Black
@@ -91,20 +85,17 @@ namespace RyzStudio.Windows.Forms
}
}
- protected void updateButton(FlatButtonStyle style)
+ protected void updateButton(ButtonStyle style)
{
this.ForeColor = style.PenColour;
this.BackColor = style.BackColour;
}
- [Browsable(false)]
- public FlatButtonStyle StyleOver { get; set; } = new FlatButtonStyle();
+ protected ButtonStyle StyleOver { get; set; } = new ButtonStyle();
- [Browsable(false)]
- public FlatButtonStyle StyleDown { get; set; } = new FlatButtonStyle();
+ protected ButtonStyle StyleDown { get; set; } = new ButtonStyle();
- [Browsable(false)]
- public FlatButtonStyle StyleDefault { get; set; } = new FlatButtonStyle();
+ protected ButtonStyle StyleDefault { get; set; } = new ButtonStyle();
public void PerformClick()
{
diff --git a/RyzStudio/Windows/Forms/ThreadControl.cs b/RyzStudio/Windows/Forms/ThreadControl.cs
new file mode 100644
index 0000000..b7bfd4f
--- /dev/null
+++ b/RyzStudio/Windows/Forms/ThreadControl.cs
@@ -0,0 +1,152 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace RyzStudio.Windows.Forms
+{
+ public class ThreadControl
+ {
+ public static void AddControl(Control control, Control value)
+ {
+ if (control.InvokeRequired)
+ {
+ control.Invoke(new MethodInvoker(() =>
+ {
+ control.Controls.Add(value);
+ }));
+ }
+ else
+ {
+ control.Controls.Add(value);
+ }
+ }
+
+ public static void AddItem(ListBox control, string value)
+ {
+ if (control.InvokeRequired)
+ {
+ control.Invoke(new MethodInvoker(() => {
+ control.Items.Add(value);
+ }));
+ }
+ else
+ {
+ control.Items.Add(value);
+ }
+ }
+
+ public static void Clear(ListBox control)
+ {
+ if (control.InvokeRequired)
+ {
+ control.Invoke(new MethodInvoker(() => {
+ control.Items.Clear();
+ }));
+ }
+ else
+ {
+ control.Items.Clear();
+ }
+ }
+
+ public static string GetText(Control control, bool doTrim = true)
+ {
+ string rv = string.Empty;
+
+ if (control.InvokeRequired)
+ {
+ control.Invoke(new MethodInvoker(() => {
+ rv = (doTrim ? control.Text?.Trim() : control.Text);
+ }));
+ }
+ else
+ {
+ rv = (doTrim ? control.Text?.Trim() : control.Text);
+ }
+
+ return rv;
+ }
+
+ public static int GetValue(NumericUpDown sender)
+ {
+ int rv = 0;
+
+ if (sender.InvokeRequired)
+ {
+ sender.Invoke(new MethodInvoker(() => {
+ rv = (int)sender.Value;
+ }));
+ }
+ else
+ {
+ rv = (int)sender.Value;
+ }
+
+ return rv;
+ }
+
+ public string GetSelectedValue(ListBox sender)
+ {
+ string rv = string.Empty;
+
+ if (sender.InvokeRequired)
+ {
+ sender.Invoke(new MethodInvoker(() => {
+ rv = (sender.SelectedItem == null) ? string.Empty : sender.SelectedItem.ToString();
+ }));
+ }
+ else
+ {
+ rv = (sender.SelectedItem == null) ? string.Empty : sender.SelectedItem.ToString();
+ }
+
+ return rv;
+ }
+
+ public static void SetHeight(Control control, int value)
+ {
+ if (control.InvokeRequired)
+ {
+ control.Invoke(new MethodInvoker(() => {
+ control.Height = value;
+ }));
+ }
+ else
+ {
+ control.Height = value;
+ }
+ }
+
+ public static void SetValue(Control control, string value)
+ {
+ if (control.InvokeRequired)
+ {
+ control.Invoke(new MethodInvoker(() => {
+ control.Text = value;
+ }));
+ }
+ else
+ {
+ control.Text = value;
+ }
+ }
+
+ public static void SetWidth(Control control, int value)
+ {
+ if (control.InvokeRequired)
+ {
+ control.Invoke(new MethodInvoker(() => {
+ control.Width = value;
+ }));
+ }
+ else
+ {
+ control.Width = value;
+ }
+ }
+
+ }
+}
diff --git a/RyzStudio/Windows/ThemedForms/TDialogForm.cs b/RyzStudio/Windows/ThemedForms/TDialogForm.cs
index d46a55c..ada839d 100644
--- a/RyzStudio/Windows/ThemedForms/TDialogForm.cs
+++ b/RyzStudio/Windows/ThemedForms/TDialogForm.cs
@@ -108,117 +108,6 @@
this.Close();
}
- public void SetValue(Label sender, string value)
- {
- if (sender.InvokeRequired)
- {
- sender.Invoke(new MethodInvoker(() => { sender.Text = value; }));
- }
- else
- {
- sender.Text = value;
- }
- }
-
- public void SetValue(GroupBox sender, string value)
- {
- if (sender.InvokeRequired)
- {
- sender.Invoke(new MethodInvoker(() => { sender.Text = value; }));
- }
- else
- {
- sender.Text = value;
- }
- }
-
- public void AddValue(ListBox sender, string value)
- {
- if (sender.InvokeRequired)
- {
- sender.Invoke(new MethodInvoker(() => { sender.Items.Add(value); }));
- }
- else
- {
- sender.Items.Add(value);
- }
- }
-
- public void AddControl(FlowLayoutPanel sender, Control value)
- {
- if (sender.InvokeRequired)
- {
- sender.Invoke(new MethodInvoker(() =>
- {
- sender.Controls.Add(value);
- }));
- }
- else
- {
- sender.Controls.Add(value);
- }
- }
-
- public void ClearValues(ListBox sender)
- {
- if (sender.InvokeRequired)
- {
- sender.Invoke(new MethodInvoker(() => { sender.Items.Clear(); }));
- }
- else
- {
- sender.Items.Clear();
- }
- }
-
- public string GetValue(ListBox sender)
- {
- string rv = string.Empty;
-
- if (sender.InvokeRequired)
- {
- sender.Invoke(new MethodInvoker(() => { rv = (sender.SelectedItem == null) ? string.Empty : sender.SelectedItem.ToString(); }));
- }
- else
- {
- rv = (sender.SelectedItem == null) ? string.Empty : sender.SelectedItem.ToString();
- }
-
- return rv;
- }
-
- public string GetValue(TTextBox sender)
- {
- string rv = string.Empty;
-
- if (sender.InvokeRequired)
- {
- sender.Invoke(new MethodInvoker(() => { rv = sender.Text.Trim(); }));
- }
- else
- {
- rv = sender.Text.Trim();
- }
-
- return rv;
- }
-
- public int GetValue(NumericUpDown sender)
- {
- int rv = 0;
-
- if (sender.InvokeRequired)
- {
- sender.Invoke(new MethodInvoker(() => { rv = (int)sender.Value; }));
- }
- else
- {
- rv = (int)sender.Value;
- }
-
- return rv;
- }
-
private void label1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
diff --git a/RyzStudio/Windows/ThemedForms/TUserControl.cs b/RyzStudio/Windows/ThemedForms/TUserControl.cs
index dad5723..56bea24 100644
--- a/RyzStudio/Windows/ThemedForms/TUserControl.cs
+++ b/RyzStudio/Windows/ThemedForms/TUserControl.cs
@@ -102,17 +102,5 @@ namespace RyzStudio.Windows.ThemedForms
}
}
- public void SetValue(Label sender, string value)
- {
- if (sender.InvokeRequired)
- {
- sender.Invoke(new MethodInvoker(() => { sender.Text = value; }));
- }
- else
- {
- sender.Text = value;
- }
- }
-
}
}
\ No newline at end of file
diff --git a/Windows/Forms/Tile/AddListTileForm.cs b/Windows/Forms/Tile/AddListTileForm.cs
index 7dc42ea..e13c601 100644
--- a/Windows/Forms/Tile/AddListTileForm.cs
+++ b/Windows/Forms/Tile/AddListTileForm.cs
@@ -6,7 +6,7 @@ namespace AppLauncher.Windows.Forms
{
public class AddListTileForm : TDialogForm
{
- public static void ShowDialog(TileLayoutPanel panel)
+ public static void ShowDialog(TilePanelLayout panel)
{
AddListTileForm form = new AddListTileForm(panel);
form.ShowDialog();
@@ -16,14 +16,14 @@ namespace AppLauncher.Windows.Forms
private TButton button1;
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator1;
private TTextBox textBox1;
- protected TileLayoutPanel parentPanel = null;
+ protected TilePanelLayout parentPanel = null;
public AddListTileForm() : base()
{
InitializeComponent();
}
- public AddListTileForm(TileLayoutPanel panel) : base()
+ public AddListTileForm(TilePanelLayout panel) : base()
{
parentPanel = panel;
diff --git a/Windows/Forms/Tile/AddTileForm.cs b/Windows/Forms/Tile/AddTileForm.cs
index 3e7c90f..2970110 100644
--- a/Windows/Forms/Tile/AddTileForm.cs
+++ b/Windows/Forms/Tile/AddTileForm.cs
@@ -11,7 +11,7 @@ namespace AppLauncher.Windows.Forms
{
public class AddTileForm : TDialogForm
{
- public static void ShowDialog(TileLayoutPanel panel)
+ public static void ShowDialog(TilePanelLayout panel)
{
AddTileForm form = new AddTileForm(panel);
form.ShowDialog();
@@ -32,7 +32,7 @@ namespace AppLauncher.Windows.Forms
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator1;
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator2;
private TTextBox textBox1;
- protected TileLayoutPanel parentPanel = null;
+ protected TilePanelLayout parentPanel = null;
public AddTileForm() : base()
{
@@ -40,7 +40,7 @@ namespace AppLauncher.Windows.Forms
initialiseComponents2();
}
- public AddTileForm(TileLayoutPanel panel) : base()
+ public AddTileForm(TilePanelLayout panel) : base()
{
parentPanel = panel;
diff --git a/Windows/Forms/Tile/EditGroupForm.cs b/Windows/Forms/Tile/EditGroupForm.cs
index 6abd291..80f05ef 100644
--- a/Windows/Forms/Tile/EditGroupForm.cs
+++ b/Windows/Forms/Tile/EditGroupForm.cs
@@ -11,7 +11,7 @@ namespace AppLauncher.Windows.Forms
private TButton button1;
private TPickerBox pickerBox1;
private TTextBox textBox1;
- protected TileLayoutContainer parentContainer = null;
+ protected TilePanelLayout parentContainer = null;
public EditGroupForm() : base()
{
@@ -19,7 +19,7 @@ namespace AppLauncher.Windows.Forms
initialiseComponents2();
}
- public EditGroupForm(TileLayoutContainer container) : base()
+ public EditGroupForm(TilePanelLayout container) : base()
{
parentContainer = container;
diff --git a/Windows/Forms/Tile/TilePanel.cs b/Windows/Forms/Tile/TilePanel.cs
index d93995b..55f4086 100644
--- a/Windows/Forms/Tile/TilePanel.cs
+++ b/Windows/Forms/Tile/TilePanel.cs
@@ -41,7 +41,7 @@ namespace AppLauncher.Windows.Forms
[Browsable(false)]
public TileModel ModelInfo => modelInfo;
- public TileLayoutPanel PanelContainer
+ public TilePanelLayout PanelContainer
{
get
{
@@ -50,12 +50,12 @@ namespace AppLauncher.Windows.Forms
return null;
}
- if (this.Parent.GetType() != typeof(TileLayoutPanel))
+ if (this.Parent.GetType() != typeof(TilePanelLayout))
{
return null;
}
- return (TileLayoutPanel)this.Parent;
+ return (TilePanelLayout)this.Parent;
}
}
@@ -96,7 +96,7 @@ namespace AppLauncher.Windows.Forms
private void panel_MouseDown(object sender, MouseEventArgs e)
{
- TileLayoutPanel container = this.PanelContainer;
+ TilePanelLayout container = this.PanelContainer;
if (container == null)
{
return;
@@ -122,7 +122,7 @@ namespace AppLauncher.Windows.Forms
{
if (isDragging)
{
- TileLayoutPanel layoutPanel = this.PanelContainer;
+ TilePanelLayout layoutPanel = this.PanelContainer;
if (layoutPanel == null)
{
return;
diff --git a/Windows/Forms/Tile/TilePanelLayout.Designer.cs b/Windows/Forms/Tile/TilePanelLayout.Designer.cs
new file mode 100644
index 0000000..83b92c0
--- /dev/null
+++ b/Windows/Forms/Tile/TilePanelLayout.Designer.cs
@@ -0,0 +1,193 @@
+namespace AppLauncher.Windows.Forms
+{
+ partial class TilePanelLayout
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.addListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
+ this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
+ this.topToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.upToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.downToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.bottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
+ this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
+ this.contextMenuStrip1.SuspendLayout();
+ this.contextMenuStrip2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // contextMenuStrip1
+ //
+ this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.addToolStripMenuItem,
+ this.addListToolStripMenuItem});
+ this.contextMenuStrip1.Name = "contextMenuStrip1";
+ this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70);
+ //
+ // addToolStripMenuItem
+ //
+ this.addToolStripMenuItem.Name = "addToolStripMenuItem";
+ this.addToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.addToolStripMenuItem.Text = "&Add Tile";
+ this.addToolStripMenuItem.Click += new System.EventHandler(this.addTileMenuItem_Click);
+ //
+ // addListToolStripMenuItem
+ //
+ this.addListToolStripMenuItem.Name = "addListToolStripMenuItem";
+ this.addListToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.addListToolStripMenuItem.Text = "Add &List Tile";
+ this.addListToolStripMenuItem.Click += new System.EventHandler(this.addListTileMenuItem_Click);
+ //
+ // contextMenuStrip2
+ //
+ this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripMenuItem2,
+ this.toolStripMenuItem5,
+ this.toolStripMenuItem1,
+ this.toolStripSeparator2,
+ this.toolStripMenuItem4,
+ this.toolStripSeparator1,
+ this.toolStripMenuItem3});
+ this.contextMenuStrip2.Name = "contextMenuStrip1";
+ this.contextMenuStrip2.Size = new System.Drawing.Size(133, 126);
+ //
+ // toolStripMenuItem2
+ //
+ this.toolStripMenuItem2.Name = "toolStripMenuItem2";
+ this.toolStripMenuItem2.Size = new System.Drawing.Size(132, 22);
+ this.toolStripMenuItem2.Text = "&Add Group";
+ this.toolStripMenuItem2.Click += new System.EventHandler(this.addGroupMenuItem_Click);
+ //
+ // toolStripMenuItem5
+ //
+ this.toolStripMenuItem5.Name = "toolStripMenuItem5";
+ this.toolStripMenuItem5.Size = new System.Drawing.Size(132, 22);
+ this.toolStripMenuItem5.Text = "Add &Row";
+ this.toolStripMenuItem5.Click += new System.EventHandler(this.addRowMenuItem_Click);
+ //
+ // toolStripMenuItem1
+ //
+ this.toolStripMenuItem1.Name = "toolStripMenuItem1";
+ this.toolStripMenuItem1.Size = new System.Drawing.Size(132, 22);
+ this.toolStripMenuItem1.Text = "&Edit";
+ this.toolStripMenuItem1.Click += new System.EventHandler(this.editGroupMenuItem_Click);
+ //
+ // toolStripSeparator2
+ //
+ this.toolStripSeparator2.Name = "toolStripSeparator2";
+ this.toolStripSeparator2.Size = new System.Drawing.Size(129, 6);
+ //
+ // toolStripMenuItem4
+ //
+ this.toolStripMenuItem4.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.topToolStripMenuItem,
+ this.upToolStripMenuItem,
+ this.downToolStripMenuItem,
+ this.bottomToolStripMenuItem});
+ this.toolStripMenuItem4.Name = "toolStripMenuItem4";
+ this.toolStripMenuItem4.Size = new System.Drawing.Size(132, 22);
+ this.toolStripMenuItem4.Text = "&Move";
+ //
+ // topToolStripMenuItem
+ //
+ this.topToolStripMenuItem.Name = "topToolStripMenuItem";
+ this.topToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+ this.topToolStripMenuItem.Text = "&Top";
+ this.topToolStripMenuItem.Click += new System.EventHandler(this.moveTopMenuItem_Click);
+ //
+ // upToolStripMenuItem
+ //
+ this.upToolStripMenuItem.Name = "upToolStripMenuItem";
+ this.upToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+ this.upToolStripMenuItem.Text = "&Up";
+ this.upToolStripMenuItem.Click += new System.EventHandler(this.moveUpMenuItem_Click);
+ //
+ // downToolStripMenuItem
+ //
+ this.downToolStripMenuItem.Name = "downToolStripMenuItem";
+ this.downToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+ this.downToolStripMenuItem.Text = "&Down";
+ this.downToolStripMenuItem.Click += new System.EventHandler(this.moveDownMenuItem_Click);
+ //
+ // bottomToolStripMenuItem
+ //
+ this.bottomToolStripMenuItem.Name = "bottomToolStripMenuItem";
+ this.bottomToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+ this.bottomToolStripMenuItem.Text = "&Bottom";
+ this.bottomToolStripMenuItem.Click += new System.EventHandler(this.moveBottomMenuItem_Click);
+ //
+ // toolStripSeparator1
+ //
+ this.toolStripSeparator1.Name = "toolStripSeparator1";
+ this.toolStripSeparator1.Size = new System.Drawing.Size(129, 6);
+ //
+ // toolStripMenuItem3
+ //
+ this.toolStripMenuItem3.Name = "toolStripMenuItem3";
+ this.toolStripMenuItem3.Size = new System.Drawing.Size(132, 22);
+ this.toolStripMenuItem3.Text = "&Remove";
+ this.toolStripMenuItem3.Click += new System.EventHandler(this.removeGroupMenuItem3_Click);
+ //
+ // TilePanelLayout
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.BackColor = System.Drawing.Color.Transparent;
+ this.Name = "TilePanelLayout";
+ this.Size = new System.Drawing.Size(370, 150);
+ this.contextMenuStrip1.ResumeLayout(false);
+ this.contextMenuStrip2.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
+ private System.Windows.Forms.ToolStripMenuItem addToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem addListToolStripMenuItem;
+ private System.Windows.Forms.ContextMenuStrip contextMenuStrip2;
+ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
+ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5;
+ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
+ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
+ private System.Windows.Forms.ToolStripMenuItem topToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem upToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem downToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem bottomToolStripMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
+ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
+ }
+}
diff --git a/Windows/Forms/Tile/TilePanelLayout.cs b/Windows/Forms/Tile/TilePanelLayout.cs
new file mode 100644
index 0000000..7cb5338
--- /dev/null
+++ b/Windows/Forms/Tile/TilePanelLayout.cs
@@ -0,0 +1,747 @@
+using AppLauncher.Models;
+using RyzStudio.Windows.Forms;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace AppLauncher.Windows.Forms
+{
+ public partial class TilePanelLayout : 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 readonly int labelHeight = 20;
+ protected readonly int collapseIncrement = 6;
+ protected readonly int expandIncrement = 8;
+
+ protected TileGroupModel groupInfo = null;
+ protected List- items = new List
- ();
+
+ protected int collapseHeight = 0;
+ protected int expandedHeight = 0;
+
+ protected bool isAnimating = false;
+ protected bool isChecked = true;
+
+ public TilePanelLayout(TileGroupModel model) : base()
+ {
+ InitializeComponent();
+
+ this.AllowDrop = true;
+ this.BackColor = Color.Transparent;
+
+ this.LoadModel(model);
+
+ //panel1.Resize += panel1_Resize;
+ }
+
+ protected override void OnDragDrop(DragEventArgs e)
+ {
+ string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
+ if (fileList == null)
+ {
+ return;
+ }
+
+ if (fileList.Length <= 0)
+ {
+ return;
+ }
+
+ if (string.IsNullOrWhiteSpace(fileList[0]))
+ {
+ return;
+ }
+
+ TileModel model = new TileModel()
+ {
+ ProcessFilename = fileList[0],
+ Title = Path.GetFileName(fileList[0])
+ };
+
+ // exe
+ if (Path.GetExtension(fileList[0]).Equals(".exe", StringComparison.CurrentCultureIgnoreCase))
+ {
+ if (File.Exists(fileList[0]))
+ {
+ try
+ {
+ FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(fileList[0]);
+ if (fvi != null)
+ {
+ model.Title = fvi.ProductName;
+ }
+ }
+ catch
+ {
+ // do nothing
+ }
+ }
+ }
+
+ this.AddTile(model);
+ }
+
+ protected override void OnDragOver(DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(DataFormats.FileDrop))
+ {
+ e.Effect = DragDropEffects.Link;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+
+ this.Margin = new Padding(0);
+ this.Padding = new Padding(0, 0, 0, 10);
+ //this.MaximumSize = new Size(panel1.Width, ExpandedHeight);
+ //this.MinimumSize = new Size(panel1.Width, label1.Height);
+ //this.Size = this.MaximumSize;
+ //this.Size = new Size(panel1.Width, this.ExpandedHeight);
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ base.OnPaint(e);
+
+ Graphics g = e.Graphics;
+
+ g.DrawImageUnscaled((isChecked ? Properties.Resources.toggle_right_ea_16 : Properties.Resources.toggle_left_ea_16), 2, 2);
+
+ TextRenderer.DrawText(g, groupInfo?.Title, new Font(this.Font.FontFamily, 8.25F), new Point(25, 4), Color.FromArgb(99, 105, 119));
+ }
+
+ protected override async void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+
+ await this.InvalidateContainer();
+ }
+
+ protected override async void OnMouseClick(MouseEventArgs e)
+ {
+ base.OnMouseClick(e);
+
+ bool isLabel = ((e.Location.X >= 0) && (e.Location.X <= this.Width) && (e.Location.Y >= 0) && (e.Location.Y <= 20));
+
+ if (e.Button == MouseButtons.Left)
+ {
+ if (isLabel)
+ {
+ isChecked = !isChecked;
+
+ this.Invalidate();
+ await this.InvalidateContainer();
+ }
+ else
+ {
+
+ }
+ }
+ else if (e.Button == MouseButtons.Right)
+ {
+ if (isLabel)
+ {
+ contextMenuStrip2.Show(this, e.Location);
+ }
+ else
+ {
+ contextMenuStrip1.Show(this, e.Location);
+ }
+ }
+ }
+
+ protected override void OnMouseDoubleClick(MouseEventArgs e) => base.OnMouseClick(e);
+
+ //private async void panel1_Resize(object sender, EventArgs e) => await this.InvalidateContainer();
+
+ public Point GridSize
+ {
+ get
+ {
+ int w = (int)Math.Floor(decimal.Divide(this.Width, this.TileSize));
+ int h = (int)Math.Floor(decimal.Divide(this.Height - labelHeight, this.TileSize));
+
+ return new Point(w, h);
+ }
+ }
+
+ public int CollapseHeight => labelHeight + collapseHeight;
+
+ public int ExpandedHeight => expandedHeight + this.Padding.Bottom;
+
+ //public int CollapseHeight => labelHeight + collapseHeight panel1.CollapseHeight;
+
+ //public int ExpandedHeight => labelHeight + panel1.ExpandedHeight + this.Padding.Top + this.Padding.Bottom;
+
+ public TileGroupModel Model
+ {
+ get
+ {
+ TileGroupModel rs = new TileGroupModel()
+ {
+ Title = groupInfo.Title,
+ //GridSize = new Size(panel1.GridSize.X, panel1.GridSize.Y),
+ GridSize = new Size(this.GridSize.X, this.GridSize.Y),
+ IsExpanded = isChecked,
+ IsExclusive = groupInfo.IsExclusive,
+ Items = this.Tiles
+ //Items = panel1.Tiles
+ };
+
+ return rs;
+ }
+ }
+
+ public FlowLayoutPanel FlowLayoutPanel
+ {
+ get
+ {
+ if (this.Parent == null)
+ {
+ return null;
+ }
+
+ if (this.Parent.GetType() != typeof(FlowLayoutPanel))
+ {
+ return null;
+ }
+
+ return this.Parent as FlowLayoutPanel;
+ }
+ }
+
+ public List Tiles
+ {
+ get
+ {
+ List rs = new List();
+ foreach (Item item in items)
+ {
+ TileModel model = item.Tile.ModelInfo;
+ model.Position = item.Coord;
+
+ rs.Add(model);
+ }
+
+ return rs;
+ }
+ }
+
+ public int TileSize => (tileSize + margin);
+
+ public void AddTile(TileModel tile)
+ {
+ Point gridSize = this.GridSize;
+
+ if (items.Count >= (gridSize.X * gridSize.Y))
+ {
+ this.SetGridSize(gridSize.X, (gridSize.Y + 1));
+ }
+
+ Point? newCoord = findLastFreeCoord();
+ if (newCoord == null)
+ {
+ return;
+ }
+
+ tile.Position = newCoord.Value;
+
+ TilePanel panel = new TilePanel();
+ panel.LoadInfo(tile);
+ panel.Location = convertCoordToLocation(tile.Position);
+
+ items.Add(new Item()
+ {
+ Tile = panel,
+ Coord = tile.Position
+ });
+
+ this.Controls.Add(panel);
+ }
+
+ public void Clear()
+ {
+ this.Controls.Clear();
+ }
+
+ public async Task Collapse()
+ {
+ await Task.Run(() =>
+ {
+ if (isAnimating) return;
+
+ isAnimating = true;
+
+ while (this.Height > this.CollapseHeight)
+ {
+ ThreadControl.SetHeight(this, (this.Height - collapseIncrement));
+
+ Thread.Sleep(10);
+ }
+
+ ThreadControl.SetHeight(this, this.CollapseHeight);
+
+ isAnimating = false;
+ });
+ }
+
+ public async Task CollapseNow()
+ {
+ await Task.Run(() =>
+ {
+ if (isAnimating) return;
+
+ isAnimating = true;
+
+ ThreadControl.SetHeight(this, this.CollapseHeight);
+
+ isAnimating = false;
+ });
+ }
+
+ public async Task Expand()
+ {
+ await Task.Run(() =>
+ {
+ if (isAnimating) return;
+
+ isAnimating = true;
+
+ while (this.Height < this.ExpandedHeight)
+ {
+ ThreadControl.SetHeight(this, (this.Height + expandIncrement));
+ this.Invalidate();
+
+ Thread.Sleep(10);
+ }
+
+ ThreadControl.SetHeight(this, this.ExpandedHeight);
+
+ isAnimating = false;
+ });
+ }
+
+ 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 - labelHeight), this.TileSize));
+
+ if (x < 0) x = 0;
+ if (y < 0) y = 0;
+
+ return new Point((x * this.TileSize), ((y * this.TileSize) + labelHeight));
+ }
+
+ public async Task InvalidateContainer(bool animate = true)
+ {
+ if (isAnimating)
+ {
+ return;
+ }
+
+ if (isChecked)
+ {
+ await this.Expand();
+ }
+ else
+ {
+ if (animate)
+ {
+ await this.Collapse();
+ }
+ else
+ {
+ await this.CollapseNow();
+ }
+ }
+ }
+
+ public void AddGroup()
+ {
+ if (this.FlowLayoutPanel == null)
+ {
+ return;
+ }
+
+ this.FlowLayoutPanel.Controls.Add(new TilePanelLayout(new TileGroupModel()
+ {
+ Title = "New Group",
+ GridSize = new Size(8, 1)
+ }));
+ }
+
+ public void AddRow()
+ {
+ //panel1.SetGridSize(groupInfo.GridSize.Width, (groupInfo.GridSize.Height + 1));
+ this.SetGridSize(groupInfo.GridSize.Width, (groupInfo.GridSize.Height + 1));
+ }
+
+ public void EditGroup()
+ {
+ //EditGroupForm editForm = new EditGroupForm(this);
+ //editForm.ShowDialog();
+ }
+
+ public void LoadModel(TileGroupModel model, bool loadTiles = true)
+ {
+ groupInfo = model;
+
+ this.SetGridSize(groupInfo.GridSize.Width, groupInfo.GridSize.Height);
+ //this.Width = panel1.Width;
+
+ isChecked = groupInfo.IsExpanded;
+
+ if (loadTiles)
+ {
+ this.LoadTiles(model.Items);
+ }
+
+ this.Invalidate();
+ }
+
+ public void LoadTiles(List tiles)
+ {
+ if (tiles == null)
+ {
+ return;
+ }
+
+ if (tiles.Count() <= 0)
+ {
+ return;
+ }
+
+ foreach (TileModel item in tiles)
+ {
+ // resolve final grid position
+ Point? confirmedPosition = resolveCoord(item.Position);
+ if (confirmedPosition == null)
+ {
+ continue;
+
+ }
+
+ // place control
+ TilePanel panel = new TilePanel();
+ panel.LoadInfo(item);
+ panel.Location = convertCoordToLocation(confirmedPosition.Value);
+
+ items.Add(new Item()
+ {
+ Tile = panel,
+ Coord = confirmedPosition.Value
+ });
+
+ this.Controls.Add(panel);
+ }
+ }
+
+ public void MoveTile(TilePanel panel, int posX, int posY)
+ {
+ Item item = items.Where(x => x.Tile.Equals(panel)).FirstOrDefault();
+ if (item == null)
+ {
+ return;
+ }
+
+ Point newPosition = convertLocationToCoord(posX, posY);
+ if (!isTileInBounds(newPosition))
+ {
+ return;
+ }
+
+ if (hasTile(newPosition))
+ {
+ Item swapItem = items.Where(x => x.Coord.Equals(newPosition)).FirstOrDefault();
+ if (swapItem != null)
+ {
+ swapItem.Coord = item.Coord;
+ swapItem.Tile.Location = convertCoordToLocation(item.Coord);
+ }
+
+ item.Coord = newPosition;
+ panel.Location = convertCoordToLocation(newPosition);
+ }
+ else
+ {
+ item.Coord = newPosition;
+ panel.Location = convertCoordToLocation(newPosition);
+ }
+ }
+
+ public void MoveTop()
+ {
+ if (this.FlowLayoutPanel == null)
+ {
+ return;
+ }
+
+ this.FlowLayoutPanel.Controls.SetChildIndex(this, 0);
+ }
+
+ public void MoveUp()
+ {
+ if (this.FlowLayoutPanel == null)
+ {
+ return;
+ }
+
+ int pos = this.FlowLayoutPanel.Controls.GetChildIndex(this);
+ if (pos <= 0)
+ {
+ return;
+ }
+
+ this.FlowLayoutPanel.Controls.SetChildIndex(this, (pos - 1));
+ }
+
+ public void MoveDown()
+ {
+ if (this.FlowLayoutPanel == null)
+ {
+ return;
+ }
+
+ int pos = this.FlowLayoutPanel.Controls.GetChildIndex(this);
+ if (pos >= (this.FlowLayoutPanel.Controls.Count - 1))
+ {
+ return;
+ }
+
+ this.FlowLayoutPanel.Controls.SetChildIndex(this, (pos + 1));
+ }
+
+ public void MoveBottom()
+ {
+ if (this.FlowLayoutPanel == null)
+ {
+ return;
+ }
+
+ this.FlowLayoutPanel.Controls.SetChildIndex(this, (this.FlowLayoutPanel.Controls.Count - 1));
+ }
+
+ public void Remove()
+ {
+ if (this.FlowLayoutPanel == null)
+ {
+ return;
+ }
+
+ this.FlowLayoutPanel.Controls.Remove(this);
+ }
+
+ public void Remove(TilePanel panel)
+ {
+ Item m = items.Where(x => x.Tile.Equals(panel)).FirstOrDefault();
+ if (m != null)
+ {
+ items.Remove(m);
+ }
+
+ this.Controls.Remove(panel);
+ }
+
+ public void SetGridSize(int width, int height)
+ {
+ expandedHeight = (this.TileSize * height) + labelHeight;
+
+ this.Size = new Size((this.TileSize * width), expandedHeight);
+ }
+
+ protected Point convertCoordToLocation(Point position) => new Point((position.X * this.TileSize), ((position.Y * this.TileSize) + labelHeight));
+
+ protected Point convertLocationToCoord(int posX, int posY)
+ {
+ int x = (int)Math.Round(decimal.Divide(posX, this.TileSize));
+ int y = (int)Math.Round(decimal.Divide((posY - labelHeight), this.TileSize));
+
+ if (x < 0) x = 0;
+ if (y < 0) y = 0;
+
+ return new Point(x, y);
+ }
+
+ protected Point? findFirstFreeCoord()
+ {
+ Point gridSize = this.GridSize;
+
+ for (int y = 0; y < gridSize.Y; y++)
+ {
+ for (int x = 0; x < gridSize.X; x++)
+ {
+ if (hasTile(new Point(x, y)))
+ {
+ continue;
+ }
+
+ return new Point(x, y);
+ }
+ }
+
+ return null;
+ }
+
+ protected Point? findLastFreeCoord()
+ {
+ Point gridSize = this.GridSize;
+
+ // none available
+ if (items.Count >= (gridSize.X * gridSize.Y))
+ {
+ return null;
+ }
+
+ if (items.Count <= 0)
+ {
+ return findFirstFreeCoord();
+ }
+
+ // only one available
+ if (items.Count >= ((gridSize.X * gridSize.Y) - 1))
+ {
+ return findFirstFreeCoord();
+ }
+
+ Point? rv = null;
+
+ for (int y = (gridSize.Y - 1); y >= 0; y--)
+ {
+ for (int x = (gridSize.X - 1); x >= 0; x--)
+ {
+ if (hasTile(new Point(x, y)))
+ {
+ if (rv.HasValue)
+ {
+ return rv;
+ }
+ }
+ else
+ {
+ rv = new Point(x, y);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ 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;
+ }
+
+ protected Point? resolveCoord(Point coord)
+ {
+ if (!isTileInBounds(coord))
+ {
+ return null;
+ }
+
+ if (!hasTile(coord))
+ {
+ return coord;
+ }
+
+ return resolveNextCoord(coord);
+ }
+
+ protected Point? resolveNextCoord(Point coord)
+ {
+ Point gridSize = this.GridSize;
+ Point newCoord = coord;
+
+ while (true)
+ {
+ newCoord.X++;
+
+ if (newCoord.X >= gridSize.X)
+ {
+ newCoord.Y++;
+ newCoord.X = 0;
+ }
+
+ if (!isTileInBounds(newCoord))
+ {
+ return null;
+ }
+
+ if (hasTile(newCoord))
+ {
+ continue;
+ }
+
+ return newCoord;
+ }
+ }
+
+ private void addTileMenuItem_Click(object sender, EventArgs e) => AddTileForm.ShowDialog(this);
+
+ private void addListTileMenuItem_Click(object sender, EventArgs e) => AddListTileForm.ShowDialog(this);
+
+ private void addGroupMenuItem_Click(object sender, EventArgs e) => this.AddGroup();
+
+ private void addRowMenuItem_Click(object sender, EventArgs e) => this.AddRow();
+
+ private void editGroupMenuItem_Click(object sender, EventArgs e) => this.EditGroup();
+
+ private void moveTopMenuItem_Click(object sender, EventArgs e) => this.MoveTop();
+
+ private void moveUpMenuItem_Click(object sender, EventArgs e) => this.MoveUp();
+
+ private void moveDownMenuItem_Click(object sender, EventArgs e) => this.MoveDown();
+
+ private void moveBottomMenuItem_Click(object sender, EventArgs e) => this.MoveBottom();
+
+ private void removeGroupMenuItem3_Click(object sender, EventArgs e) => this.Remove();
+
+
+ }
+}
diff --git a/Windows/Forms/Tile/TilePanelLayout.resx b/Windows/Forms/Tile/TilePanelLayout.resx
new file mode 100644
index 0000000..8baf68f
--- /dev/null
+++ b/Windows/Forms/Tile/TilePanelLayout.resx
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 172, 17
+
+
\ No newline at end of file