From 3b4f19ae408ba9d44ed5db0ffff1313d77912e16 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 3 May 2020 22:58:49 +0100 Subject: [PATCH] Changed: manage tile groups --- LinearAppLauncher.csproj | 6 + Windows/Forms/Tile/EditGroupForm.cs | 181 ++++++++++++++++++++++++++ Windows/Forms/Tile/EditGroupForm.resx | 131 +++++++++++++++++++ Windows/Forms/Tile/TileContainer.cs | 28 ++-- Windows/Forms/Tile/TileLayoutPanel.cs | 10 +- 5 files changed, 345 insertions(+), 11 deletions(-) create mode 100644 Windows/Forms/Tile/EditGroupForm.cs create mode 100644 Windows/Forms/Tile/EditGroupForm.resx diff --git a/LinearAppLauncher.csproj b/LinearAppLauncher.csproj index a701533..9acbc22 100644 --- a/LinearAppLauncher.csproj +++ b/LinearAppLauncher.csproj @@ -131,6 +131,9 @@ Form + + Form + Form @@ -198,6 +201,9 @@ AddTileForm.cs + + EditGroupForm.cs + EditTileForm.cs diff --git a/Windows/Forms/Tile/EditGroupForm.cs b/Windows/Forms/Tile/EditGroupForm.cs new file mode 100644 index 0000000..b3386d6 --- /dev/null +++ b/Windows/Forms/Tile/EditGroupForm.cs @@ -0,0 +1,181 @@ +using AppLauncher.Models; +using RyzStudio.Windows.ThemedForms; +using System; + +namespace AppLauncher.Windows.Forms +{ + public class EditGroupForm : DialogForm + { + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private Button button1; + private PickerBox pickerBox1; + private TextBox textBox1; + protected TileContainer parentContainer = null; + + public EditGroupForm() : base() + { + InitializeComponent(); + initialiseComponents2(); + } + + public EditGroupForm(TileContainer container) : base() + { + parentContainer = container; + + InitializeComponent(); + initialiseComponents2(); + } + + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditGroupForm)); + this.textBox1 = new RyzStudio.Windows.ThemedForms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.button1 = new RyzStudio.Windows.ThemedForms.Button(); + this.pickerBox1 = new RyzStudio.Windows.ThemedForms.PickerBox(); + ((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).BeginInit(); + this.SuspendLayout(); + // + // imgbxClose + // + this.imgbxClose.Image = ((System.Drawing.Image)(resources.GetObject("imgbxClose.Image"))); + this.imgbxClose.Location = new System.Drawing.Point(367, 5); + // + // lblDescription + // + this.lblDescription.Size = new System.Drawing.Size(359, 30); + this.lblDescription.Text = "Edit Group"; + // + // panel1 + // + this.panel1.Location = new System.Drawing.Point(394, 474); + // + // area1 + // + this.area1.Location = new System.Drawing.Point(1, 474); + this.area1.Size = new System.Drawing.Size(392, 5); + // + // textBox1 + // + this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBox1.BackColor = System.Drawing.Color.Transparent; + this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.textBox1.Location = new System.Drawing.Point(159, 50); + this.textBox1.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6); + this.textBox1.Name = "textBox1"; + this.textBox1.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9); + this.textBox1.Size = new System.Drawing.Size(220, 32); + this.textBox1.SubmitButton = null; + this.textBox1.TabIndex = 152; + this.textBox1.UseSystemPasswordChar = false; + // + // label2 + // + this.label2.BackColor = System.Drawing.Color.Transparent; + this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(95)))), ((int)(((byte)(99)))), ((int)(((byte)(104))))); + this.label2.Location = new System.Drawing.Point(18, 91); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(131, 32); + this.label2.TabIndex = 155; + this.label2.Text = "Show Only Expanded"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label1 + // + this.label1.BackColor = System.Drawing.Color.Transparent; + this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(95)))), ((int)(((byte)(99)))), ((int)(((byte)(104))))); + this.label1.Location = new System.Drawing.Point(18, 50); + this.label1.Margin = new System.Windows.Forms.Padding(0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(131, 32); + this.label1.TabIndex = 153; + this.label1.Text = "Title"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button1.BackColor = System.Drawing.Color.Transparent; + this.button1.DefaultImage = null; + this.button1.DownImage = null; + this.button1.LabelText = "&Save"; + this.button1.Location = new System.Drawing.Point(251, 427); + this.button1.Name = "button1"; + this.button1.OverImage = null; + this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); + this.button1.Size = new System.Drawing.Size(128, 32); + this.button1.TabIndex = 173; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // pickerBox1 + // + this.pickerBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pickerBox1.BackColor = System.Drawing.Color.Transparent; + this.pickerBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.pickerBox1.Location = new System.Drawing.Point(239, 91); + this.pickerBox1.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6); + this.pickerBox1.Name = "pickerBox1"; + this.pickerBox1.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5); + this.pickerBox1.Size = new System.Drawing.Size(140, 32); + this.pickerBox1.SubmitButton = null; + this.pickerBox1.TabIndex = 174; + // + // EditGroupForm + // + this.ClientSize = new System.Drawing.Size(400, 480); + this.Controls.Add(this.pickerBox1); + this.Controls.Add(this.button1); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.textBox1); + this.Description = "Edit Group"; + this.Name = "EditGroupForm"; + this.Controls.SetChildIndex(this.imgbxClose, 0); + this.Controls.SetChildIndex(this.lblDescription, 0); + this.Controls.SetChildIndex(this.panel1, 0); + this.Controls.SetChildIndex(this.area1, 0); + this.Controls.SetChildIndex(this.textBox1, 0); + this.Controls.SetChildIndex(this.label1, 0); + this.Controls.SetChildIndex(this.label2, 0); + this.Controls.SetChildIndex(this.button1, 0); + this.Controls.SetChildIndex(this.pickerBox1, 0); + ((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).EndInit(); + this.ResumeLayout(false); + + } + + private void initialiseComponents2() + { + pickerBox1.ComboBox.Items.Clear(); + pickerBox1.ComboBox.Items.AddRange(new string[] { "No", "Yes" }); + if (pickerBox1.ComboBox.Items.Count > 0) pickerBox1.ComboBox.SelectedIndex = 0; + } + + protected override void OnShown(EventArgs e) + { + base.OnShown(e); + + if (parentContainer != null) + { + textBox1.Text = parentContainer.Model.Title; + pickerBox1.ComboBox.SelectedIndex = (parentContainer.Model.IsExpanded ? 1 : 0); + } + } + + private void button1_Click(object sender, EventArgs e) + { + TileGroupModel model = parentContainer.Model; + model.Title = textBox1.Text?.Trim(); + model.IsExclusive = (pickerBox1.ComboBox.SelectedIndex == 1); + + parentContainer.LoadModel(model, false); + + this.Close(); + } + + } +} diff --git a/Windows/Forms/Tile/EditGroupForm.resx b/Windows/Forms/Tile/EditGroupForm.resx new file mode 100644 index 0000000..3747e00 --- /dev/null +++ b/Windows/Forms/Tile/EditGroupForm.resx @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + wwAADsMBx2+oZAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMS4xYyqcSwAAANlJREFUOE+lU1sO + gjAQrHgRY6KemQ+VT9NrgAfgfRA+SawzdTAk2lhkkgm7s7vTAq0py/LUNM0dHEEXSfYWfd8fDQIOD23b + nvFMY6jeAcxpMFIwC1HX9YWzNOCWUunR4AxnvxpUVbV3zm2UGsbUlHoEDfBhdsgf4BWDCcmYGmtqCxtw + NeQcoJ6JjGn43hXy8CvIxDeIGbREZY+pHjLgtqeVHf7SzVq7VdmDM6x9GGj1/19h9UckVv3GWMwNRh5L + 6dGYH+UCHCTQ9SfV+7pMvJIIaLL0Oudd1x2eUQ8MyeAeq0cAAAAASUVORK5CYII= + + + \ No newline at end of file diff --git a/Windows/Forms/Tile/TileContainer.cs b/Windows/Forms/Tile/TileContainer.cs index 2347f62..e3285c5 100644 --- a/Windows/Forms/Tile/TileContainer.cs +++ b/Windows/Forms/Tile/TileContainer.cs @@ -20,17 +20,11 @@ namespace AppLauncher.Windows.Forms InitializeComponent(); this.ContextMenuStrip = contextMenuStrip1; - //this.BackColor = Color.MistyRose; label1.TileGroupPanel = this; - groupInfo = model; + this.LoadModel(model); - label1.TitleText = groupInfo.Title; - panel1.SetGridSize(groupInfo.GridSize.Width, groupInfo.GridSize.Height); - this.Width = panel1.Width; - label1.Checked = groupInfo.IsExpanded; - panel1.LoadTiles(model.Items); panel1.Resize += panel1_Resize; } @@ -41,7 +35,7 @@ namespace AppLauncher.Windows.Forms label1.Width = panel1.Width; this.Margin = new Padding(0, 0, 0, 0); - this.Padding = new Padding(0, 0, 0, 20); + 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; @@ -215,7 +209,23 @@ namespace AppLauncher.Windows.Forms public void EditGroup() { + EditGroupForm editForm = new EditGroupForm(this); + editForm.ShowDialog(); + } + public void LoadModel(TileGroupModel model, bool loadTiles = true) + { + groupInfo = model; + + label1.TitleText = groupInfo.Title; + panel1.SetGridSize(groupInfo.GridSize.Width, groupInfo.GridSize.Height); + this.Width = panel1.Width; + label1.Checked = groupInfo.IsExpanded; + + if (loadTiles) + { + panel1.LoadTiles(model.Items); + } } public void MoveTop() @@ -280,8 +290,6 @@ namespace AppLauncher.Windows.Forms this.FlowLayoutPanel.Controls.Remove(this); } - - private void addToolStripMenuItem_Click(object sender, EventArgs e) { AddTileForm addForm = new AddTileForm(panel1); diff --git a/Windows/Forms/Tile/TileLayoutPanel.cs b/Windows/Forms/Tile/TileLayoutPanel.cs index 3783e62..73f99e8 100644 --- a/Windows/Forms/Tile/TileLayoutPanel.cs +++ b/Windows/Forms/Tile/TileLayoutPanel.cs @@ -94,7 +94,10 @@ namespace AppLauncher.Windows.Forms List rs = new List(); foreach (Item item in items) { - rs.Add(item.Tile.ModelInfo); + TileModel model = item.Tile.ModelInfo; + model.Position = item.Coord; + + rs.Add(model); } return rs; @@ -258,6 +261,11 @@ namespace AppLauncher.Windows.Forms return null; } + if (items.Count <= 0) + { + return findFirstFreeCoord(); + } + // only one available if (items.Count >= ((gridSize.X * gridSize.Y) - 1)) {