Added: support for add tile at coord

This commit is contained in:
Ray 2020-05-17 02:17:30 +01:00
parent c90d846f2e
commit d4258b39eb
9 changed files with 408 additions and 371 deletions

View File

@ -7,7 +7,6 @@ namespace AppLauncher.Models
public class TileModel public class TileModel
{ {
public string Title { get; set; } public string Title { get; set; }
public Image Icon { get; set; }
public string ProcessFilename { get; set; } public string ProcessFilename { get; set; }
public string ProcessArgument { get; set; } public string ProcessArgument { get; set; }
public string ProcessWorkingDirectory { get; set; } public string ProcessWorkingDirectory { get; set; }
@ -16,7 +15,22 @@ namespace AppLauncher.Models
public Point Position { get; set; } public Point Position { get; set; }
public bool IsGroup { get; set; } = false; public bool IsGroup { get; set; } = false;
protected List<TileModel> Items { get; set; } = new List<TileModel>(); public List<TileModel> Items { get; set; } = new List<TileModel>();
public override string ToString() => this.Title ?? string.Empty;
//public void Update(TileModel model)
//{
// this.Title = model.Title;
// this.ProcessFilename = model.ProcessFilename;
// this.ProcessArgument = model.ProcessArgument;
// this.ProcessWorkingDirectory = model.ProcessWorkingDirectory;
// this.ProcessWindowStyle = model.ProcessWindowStyle;
// this.ProcessAsAdmin = model.ProcessAsAdmin;
// this.Position = model.Position;
// this.IsGroup = model.IsGroup;
// this.Items = model.Items;
//}
} }
} }

View File

@ -26,9 +26,9 @@
inkscape:document-rotation="0" inkscape:document-rotation="0"
inkscape:current-layer="layer1" inkscape:current-layer="layer1"
inkscape:document-units="mm" inkscape:document-units="mm"
inkscape:cy="362.07537" inkscape:cy="407.3011"
inkscape:cx="331.14896" inkscape:cx="356.66747"
inkscape:zoom="5.6" inkscape:zoom="11.2"
inkscape:pageshadow="2" inkscape:pageshadow="2"
inkscape:pageopacity="0.0" inkscape:pageopacity="0.0"
borderopacity="1.0" borderopacity="1.0"
@ -523,7 +523,10 @@
inkscape:export-ydpi="120" /> inkscape:export-ydpi="120" />
</g> </g>
<g <g
transform="matrix(0.26458333,0,0,0.26458333,90.279613,100.24874)" inkscape:export-ydpi="96"
inkscape:export-xdpi="96"
inkscape:export-filename="L:\gitlab-hiimray\linear-app-launcher\Resources\folder_32.png"
transform="matrix(0.34189664,0,0,0.34189664,90.202299,100.09411)"
id="g1832" id="g1832"
style="fill:none;stroke:#636977;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"> style="fill:none;stroke:#636977;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1">
<path <path

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -6,9 +6,10 @@ namespace AppLauncher.Windows.Forms
{ {
public class AddListTileForm : TDialogForm public class AddListTileForm : TDialogForm
{ {
public static void ShowDialog(TTilePanelLayout panel) public static void ShowDialog(TTilePanelLayout control)
{ {
AddListTileForm form = new AddListTileForm(panel); AddListTileForm form = new AddListTileForm();
form.TilePanelLayout = control;
form.ShowDialog(); form.ShowDialog();
} }
@ -16,20 +17,14 @@ namespace AppLauncher.Windows.Forms
private TButton button1; private TButton button1;
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator1; private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator1;
private TTextBox textBox1; private TTextBox textBox1;
protected TTilePanelLayout parentPanel = null;
public TTilePanelLayout TilePanelLayout { get; set; } = null;
public AddListTileForm() : base() public AddListTileForm() : base()
{ {
InitializeComponent(); InitializeComponent();
} }
public AddListTileForm(TTilePanelLayout panel) : base()
{
parentPanel = panel;
InitializeComponent();
}
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddListTileForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddListTileForm));
@ -156,7 +151,7 @@ namespace AppLauncher.Windows.Forms
IsGroup = true IsGroup = true
}; };
parentPanel.AddTile(model); this.TilePanelLayout.AddTile(model);
this.Close(); this.Close();
} }

View File

@ -1,19 +1,24 @@
using AppLauncher.Models; using AppLauncher.Models;
using RyzStudio.Windows.ThemedForms; using RyzStudio.Windows.ThemedForms;
using System; using System;
using System.Collections.Generic; using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AppLauncher.Windows.Forms namespace AppLauncher.Windows.Forms
{ {
public class AddTileForm : TDialogForm public class AddTileForm : TDialogForm
{ {
public static void ShowDialog(TTilePanelLayout panel) public static void ShowDialog(TTilePanelLayout control, Point coord)
{ {
AddTileForm form = new AddTileForm(panel); AddTileForm form = new AddTileForm();
form.TilePanelLayout = control;
form.AimCoord = coord;
form.ShowDialog();
}
public static void ShowDialog(TListBox control)
{
AddTileForm form = new AddTileForm();
form.ListBox = control;
form.ShowDialog(); form.ShowDialog();
} }
@ -32,20 +37,22 @@ namespace AppLauncher.Windows.Forms
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator1; private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator1;
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator2; private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator2;
private TTextBox textBox1; private TTextBox textBox1;
protected TTilePanelLayout parentPanel = null;
public TTilePanelLayout TilePanelLayout { get; set; } = null;
public Point AimCoord { get; set; } = new Point(-1, -1);
public TListBox ListBox { get; set; } = null;
public AddTileForm() : base() public AddTileForm() : base()
{ {
InitializeComponent(); InitializeComponent();
initialiseComponents2();
}
public AddTileForm(TTilePanelLayout panel) : base() pickerBox1.ComboBox.Items.Clear();
{ pickerBox1.ComboBox.Items.AddRange(new string[] { "Normal", "Hidden", "Minimized", "Maximized" });
parentPanel = panel; if (pickerBox1.ComboBox.Items.Count > 0) pickerBox1.ComboBox.SelectedIndex = 0;
InitializeComponent(); pickerBox2.ComboBox.Items.Clear();
initialiseComponents2(); pickerBox2.ComboBox.Items.AddRange(new string[] { "No", "Yes" });
if (pickerBox2.ComboBox.Items.Count > 0) pickerBox2.ComboBox.SelectedIndex = 0;
} }
private void InitializeComponent() private void InitializeComponent()
@ -343,20 +350,26 @@ namespace AppLauncher.Windows.Forms
} }
private void initialiseComponents2()
{
pickerBox1.ComboBox.Items.Clear();
pickerBox1.ComboBox.Items.AddRange(new string[] { "Normal", "Hidden", "Minimized", "Maximized" });
if (pickerBox1.ComboBox.Items.Count > 0) pickerBox1.ComboBox.SelectedIndex = 0;
pickerBox2.ComboBox.Items.Clear();
pickerBox2.ComboBox.Items.AddRange(new string[] { "No", "Yes" });
if (pickerBox2.ComboBox.Items.Count > 0) pickerBox2.ComboBox.SelectedIndex = 0;
}
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
TileModel model = new TileModel() TileModel model = buildModel();
if (this.TilePanelLayout != null)
{
this.TilePanelLayout.AddTile(model);
}
else if (this.ListBox != null)
{
int n = this.ListBox.ListBox.Items.Add(model);
this.ListBox.ListBox.SelectedIndex = n;
}
this.Close();
}
protected TileModel buildModel()
{
TileModel rs = new TileModel()
{ {
Title = textBox1.Text?.Trim(), Title = textBox1.Text?.Trim(),
ProcessFilename = textBox2.Text?.Trim(), ProcessFilename = textBox2.Text?.Trim(),
@ -366,9 +379,12 @@ namespace AppLauncher.Windows.Forms
ProcessAsAdmin = (pickerBox2.ComboBox.SelectedIndex == 1) ProcessAsAdmin = (pickerBox2.ComboBox.SelectedIndex == 1)
}; };
parentPanel.AddTile(model); if (!this.AimCoord.Equals(new Point(-1, -1)))
{
rs.Position = this.AimCoord;
}
this.Close(); return rs;
} }
} }

View File

@ -6,25 +6,28 @@ namespace AppLauncher.Windows.Forms
{ {
public class EditGroupForm : TDialogForm public class EditGroupForm : TDialogForm
{ {
public static void ShowDialog(TTilePanelLayout control)
{
EditGroupForm form = new EditGroupForm();
form.TilePanelLayout = control;
form.ShowDialog();
}
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private TButton button1; private TButton button1;
private TPickerBox pickerBox1; private TPickerBox pickerBox1;
private TTextBox textBox1; private TTextBox textBox1;
protected TTilePanelLayout parentContainer = null;
public TTilePanelLayout TilePanelLayout { get; set; } = null;
public EditGroupForm() : base() public EditGroupForm() : base()
{ {
InitializeComponent(); InitializeComponent();
initialiseComponents2();
}
public EditGroupForm(TTilePanelLayout container) : base() pickerBox1.ComboBox.Items.Clear();
{ pickerBox1.ComboBox.Items.AddRange(new string[] { "No", "Yes" });
parentContainer = container; if (pickerBox1.ComboBox.Items.Count > 0) pickerBox1.ComboBox.SelectedIndex = 0;
InitializeComponent();
initialiseComponents2();
} }
private void InitializeComponent() private void InitializeComponent()
@ -148,31 +151,24 @@ namespace AppLauncher.Windows.Forms
} }
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) protected override void OnShown(EventArgs e)
{ {
base.OnShown(e); base.OnShown(e);
if (parentContainer != null) if (this.TilePanelLayout != null)
{ {
textBox1.Text = parentContainer.Model.Title; textBox1.Text = this.TilePanelLayout.Model.Title;
pickerBox1.ComboBox.SelectedIndex = (parentContainer.Model.IsExclusive ? 1 : 0); pickerBox1.ComboBox.SelectedIndex = (this.TilePanelLayout.Model.IsExclusive ? 1 : 0);
} }
} }
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
TileGroupModel model = parentContainer.Model; TileGroupModel model = this.TilePanelLayout.Model;
model.Title = textBox1.Text?.Trim(); model.Title = textBox1.Text?.Trim();
model.IsExclusive = (pickerBox1.ComboBox.SelectedIndex == 1); model.IsExclusive = (pickerBox1.ComboBox.SelectedIndex == 1);
parentContainer.UpdateModel(model); this.TilePanelLayout.UpdateModel(model);
this.Close(); this.Close();
} }

View File

@ -1,14 +1,16 @@
using AppLauncher.Models; using AppLauncher.Models;
using RyzStudio.Windows.ThemedForms; using RyzStudio.Windows.ThemedForms;
using System; using System;
using System.Linq;
namespace AppLauncher.Windows.Forms namespace AppLauncher.Windows.Forms
{ {
public class EditListTileForm : TDialogForm public class EditListTileForm : TDialogForm
{ {
public static void ShowDialog(TTilePanel panel) public static void ShowDialog(TTilePanel control)
{ {
EditListTileForm form = new EditListTileForm(panel); EditListTileForm form = new EditListTileForm();
form.TilePanel = control;
form.ShowDialog(); form.ShowDialog();
} }
@ -16,54 +18,28 @@ namespace AppLauncher.Windows.Forms
private TButton button1; private TButton button1;
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator2; private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator2;
private TTextBox textBox1; private TTextBox textBox1;
private TListBox tListBox1; private TListBox listBox1;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private TButton tButton1;
private TButton tButton2; public TTilePanel TilePanel { get; set; } = null;
private TButton tButton3;
private TButton tButton4;
protected TTilePanel parentPanel = null;
public EditListTileForm() : base() public EditListTileForm() : base()
{ {
InitializeComponent(); InitializeComponent();
} }
public EditListTileForm(TTilePanel panel) : base()
{
parentPanel = panel;
InitializeComponent();
}
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditListTileForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditListTileForm));
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle1 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle(); RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle1 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle2 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle(); RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle2 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle3 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle(); RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle3 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle4 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle5 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle6 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle7 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle8 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle9 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle10 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle11 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle12 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle13 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle14 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
RyzStudio.Windows.ThemedForms.TButton.ButtonStyle buttonStyle15 = new RyzStudio.Windows.ThemedForms.TButton.ButtonStyle();
this.textBox1 = new RyzStudio.Windows.ThemedForms.TTextBox(); this.textBox1 = new RyzStudio.Windows.ThemedForms.TTextBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.button1 = new RyzStudio.Windows.ThemedForms.TButton(); this.button1 = new RyzStudio.Windows.ThemedForms.TButton();
this.horizontalSeparator2 = new RyzStudio.Windows.Forms.THorizontalSeparator(); this.horizontalSeparator2 = new RyzStudio.Windows.Forms.THorizontalSeparator();
this.tListBox1 = new RyzStudio.Windows.ThemedForms.TListBox(); this.listBox1 = new RyzStudio.Windows.ThemedForms.TListBox();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.tButton1 = new RyzStudio.Windows.ThemedForms.TButton();
this.tButton2 = new RyzStudio.Windows.ThemedForms.TButton();
this.tButton3 = new RyzStudio.Windows.ThemedForms.TButton();
this.tButton4 = new RyzStudio.Windows.ThemedForms.TButton();
((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -150,19 +126,22 @@ namespace AppLauncher.Windows.Forms
this.horizontalSeparator2.Size = new System.Drawing.Size(380, 2); this.horizontalSeparator2.Size = new System.Drawing.Size(380, 2);
this.horizontalSeparator2.TabIndex = 177; this.horizontalSeparator2.TabIndex = 177;
// //
// tListBox1 // listBox1
// //
this.tListBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.tListBox1.BackColor = System.Drawing.Color.Transparent; this.listBox1.BackColor = System.Drawing.Color.Transparent;
this.tListBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); this.listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.tListBox1.Location = new System.Drawing.Point(159, 101); this.listBox1.Location = new System.Drawing.Point(159, 101);
this.tListBox1.Margin = new System.Windows.Forms.Padding(10, 4, 10, 4); this.listBox1.Margin = new System.Windows.Forms.Padding(10, 4, 10, 4);
this.tListBox1.Name = "tListBox1"; this.listBox1.Name = "listBox1";
this.tListBox1.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5); this.listBox1.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5);
this.tListBox1.Size = new System.Drawing.Size(220, 180); this.listBox1.Size = new System.Drawing.Size(220, 280);
this.tListBox1.SubmitButton = null; this.listBox1.SubmitButton = null;
this.tListBox1.TabIndex = 180; this.listBox1.TabIndex = 180;
this.listBox1.OnAdd += new System.EventHandler(this.listBox1_OnAdd);
this.listBox1.OnEdit += new System.EventHandler(this.listBox1_OnEdit);
// //
// label2 // label2
// //
@ -175,115 +154,11 @@ namespace AppLauncher.Windows.Forms
this.label2.Text = "List"; this.label2.Text = "List";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
// //
// tButton1
//
this.tButton1.BackColor = System.Drawing.Color.Transparent;
this.tButton1.DefaultImage = global::AppLauncher.Resource1.plus;
this.tButton1.DownImage = global::AppLauncher.Resource1.plus2;
this.tButton1.LabelText = "";
this.tButton1.Location = new System.Drawing.Point(159, 288);
this.tButton1.Name = "tButton1";
this.tButton1.OverImage = global::AppLauncher.Resource1.plus2;
this.tButton1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
this.tButton1.Size = new System.Drawing.Size(32, 32);
buttonStyle4.BackColour = System.Drawing.Color.White;
buttonStyle4.ForeImage = null;
buttonStyle4.PenColour = System.Drawing.Color.Black;
this.tButton1.StyleDefault = buttonStyle4;
buttonStyle5.BackColour = System.Drawing.Color.FromArgb(((int)(((byte)(179)))), ((int)(((byte)(179)))), ((int)(((byte)(179)))));
buttonStyle5.ForeImage = null;
buttonStyle5.PenColour = System.Drawing.Color.Black;
this.tButton1.StyleDown = buttonStyle5;
buttonStyle6.BackColour = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51)))));
buttonStyle6.ForeImage = null;
buttonStyle6.PenColour = System.Drawing.Color.White;
this.tButton1.StyleOver = buttonStyle6;
this.tButton1.TabIndex = 182;
//
// tButton2
//
this.tButton2.BackColor = System.Drawing.Color.Transparent;
this.tButton2.DefaultImage = null;
this.tButton2.DownImage = null;
this.tButton2.LabelText = "";
this.tButton2.Location = new System.Drawing.Point(197, 288);
this.tButton2.Name = "tButton2";
this.tButton2.OverImage = null;
this.tButton2.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
this.tButton2.Size = new System.Drawing.Size(32, 32);
buttonStyle7.BackColour = System.Drawing.Color.White;
buttonStyle7.ForeImage = null;
buttonStyle7.PenColour = System.Drawing.Color.Black;
this.tButton2.StyleDefault = buttonStyle7;
buttonStyle8.BackColour = System.Drawing.Color.FromArgb(((int)(((byte)(179)))), ((int)(((byte)(179)))), ((int)(((byte)(179)))));
buttonStyle8.ForeImage = null;
buttonStyle8.PenColour = System.Drawing.Color.Black;
this.tButton2.StyleDown = buttonStyle8;
buttonStyle9.BackColour = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51)))));
buttonStyle9.ForeImage = null;
buttonStyle9.PenColour = System.Drawing.Color.White;
this.tButton2.StyleOver = buttonStyle9;
this.tButton2.TabIndex = 183;
//
// tButton3
//
this.tButton3.BackColor = System.Drawing.Color.Transparent;
this.tButton3.DefaultImage = null;
this.tButton3.DownImage = null;
this.tButton3.LabelText = "";
this.tButton3.Location = new System.Drawing.Point(235, 288);
this.tButton3.Name = "tButton3";
this.tButton3.OverImage = null;
this.tButton3.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
this.tButton3.Size = new System.Drawing.Size(32, 32);
buttonStyle10.BackColour = System.Drawing.Color.White;
buttonStyle10.ForeImage = null;
buttonStyle10.PenColour = System.Drawing.Color.Black;
this.tButton3.StyleDefault = buttonStyle10;
buttonStyle11.BackColour = System.Drawing.Color.FromArgb(((int)(((byte)(179)))), ((int)(((byte)(179)))), ((int)(((byte)(179)))));
buttonStyle11.ForeImage = null;
buttonStyle11.PenColour = System.Drawing.Color.Black;
this.tButton3.StyleDown = buttonStyle11;
buttonStyle12.BackColour = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51)))));
buttonStyle12.ForeImage = null;
buttonStyle12.PenColour = System.Drawing.Color.White;
this.tButton3.StyleOver = buttonStyle12;
this.tButton3.TabIndex = 184;
//
// tButton4
//
this.tButton4.BackColor = System.Drawing.Color.Transparent;
this.tButton4.DefaultImage = null;
this.tButton4.DownImage = null;
this.tButton4.LabelText = "";
this.tButton4.Location = new System.Drawing.Point(273, 288);
this.tButton4.Name = "tButton4";
this.tButton4.OverImage = null;
this.tButton4.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
this.tButton4.Size = new System.Drawing.Size(32, 32);
buttonStyle13.BackColour = System.Drawing.Color.White;
buttonStyle13.ForeImage = null;
buttonStyle13.PenColour = System.Drawing.Color.Black;
this.tButton4.StyleDefault = buttonStyle13;
buttonStyle14.BackColour = System.Drawing.Color.FromArgb(((int)(((byte)(179)))), ((int)(((byte)(179)))), ((int)(((byte)(179)))));
buttonStyle14.ForeImage = null;
buttonStyle14.PenColour = System.Drawing.Color.Black;
this.tButton4.StyleDown = buttonStyle14;
buttonStyle15.BackColour = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51)))));
buttonStyle15.ForeImage = null;
buttonStyle15.PenColour = System.Drawing.Color.White;
this.tButton4.StyleOver = buttonStyle15;
this.tButton4.TabIndex = 185;
//
// EditListTileForm // EditListTileForm
// //
this.ClientSize = new System.Drawing.Size(400, 480); this.ClientSize = new System.Drawing.Size(400, 480);
this.Controls.Add(this.tButton4);
this.Controls.Add(this.tButton3);
this.Controls.Add(this.tButton2);
this.Controls.Add(this.tButton1);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.tListBox1); this.Controls.Add(this.listBox1);
this.Controls.Add(this.horizontalSeparator2); this.Controls.Add(this.horizontalSeparator2);
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
@ -298,12 +173,8 @@ namespace AppLauncher.Windows.Forms
this.Controls.SetChildIndex(this.label1, 0); this.Controls.SetChildIndex(this.label1, 0);
this.Controls.SetChildIndex(this.button1, 0); this.Controls.SetChildIndex(this.button1, 0);
this.Controls.SetChildIndex(this.horizontalSeparator2, 0); this.Controls.SetChildIndex(this.horizontalSeparator2, 0);
this.Controls.SetChildIndex(this.tListBox1, 0); this.Controls.SetChildIndex(this.listBox1, 0);
this.Controls.SetChildIndex(this.label2, 0); this.Controls.SetChildIndex(this.label2, 0);
this.Controls.SetChildIndex(this.tButton1, 0);
this.Controls.SetChildIndex(this.tButton2, 0);
this.Controls.SetChildIndex(this.tButton3, 0);
this.Controls.SetChildIndex(this.tButton4, 0);
((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
@ -313,9 +184,24 @@ namespace AppLauncher.Windows.Forms
{ {
base.OnShown(e); base.OnShown(e);
if (parentPanel != null) listBox1.ListBox.Items.Clear();
if (this.TilePanel == null) return;
if (this.TilePanel.ModelInfo == null) return;
textBox1.Text = this.TilePanel.ModelInfo.Title;
if (this.TilePanel.ModelInfo.Items != null)
{ {
textBox1.Text = parentPanel.ModelInfo.Title; foreach (TileModel item in this.TilePanel.ModelInfo.Items)
{
if (item.IsGroup)
{
continue;
}
listBox1.ListBox.Items.Add(item);
}
} }
} }
@ -327,10 +213,34 @@ namespace AppLauncher.Windows.Forms
IsGroup = true IsGroup = true
}; };
parentPanel.LoadInfo(model); model.Items = new System.Collections.Generic.List<TileModel>();
foreach (TileModel item in listBox1.ListBox.Items.OfType<TileModel>())
{
if (item.IsGroup)
{
continue;
}
model.Items.Add(item);
}
this.TilePanel.LoadInfo(model);
this.Close(); this.Close();
} }
private void listBox1_OnAdd(object sender, EventArgs e) => AddTileForm.ShowDialog(listBox1);
private void listBox1_OnEdit(object sender, EventArgs e)
{
if (listBox1.ListBox.Items.Count <= 0)
{
return;
}
EditTileForm.ShowDialog(listBox1);
}
} }
} }

View File

@ -1,15 +1,22 @@
using AppLauncher.Models; using AppLauncher.Models;
using RyzStudio.Windows.ThemedForms; using RyzStudio.Windows.ThemedForms;
using System; using System;
using System.IO;
namespace AppLauncher.Windows.Forms namespace AppLauncher.Windows.Forms
{ {
public class EditTileForm : TDialogForm public class EditTileForm : TDialogForm
{ {
public static void ShowDialog(TTilePanel panel) public static void ShowDialog(TTilePanel control)
{ {
EditTileForm form = new EditTileForm(panel); EditTileForm form = new EditTileForm();
form.TilePanel = control;
form.ShowDialog();
}
public static void ShowDialog(TListBox control)
{
EditTileForm form = new EditTileForm();
form.ListBox = control;
form.ShowDialog(); form.ShowDialog();
} }
@ -28,20 +35,21 @@ namespace AppLauncher.Windows.Forms
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator1; private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator1;
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator2; private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator2;
private TTextBox textBox1; private TTextBox textBox1;
protected TTilePanel parentPanel = null;
public TTilePanel TilePanel { get; set; } = null;
public TListBox ListBox { get; set; } = null;
public EditTileForm() : base() public EditTileForm() : base()
{ {
InitializeComponent(); InitializeComponent();
initialiseComponents2();
}
public EditTileForm(TTilePanel panel) : base() pickerBox1.ComboBox.Items.Clear();
{ pickerBox1.ComboBox.Items.AddRange(new string[] { "Normal", "Hidden", "Minimized", "Maximized" });
parentPanel = panel; if (pickerBox1.ComboBox.Items.Count > 0) pickerBox1.ComboBox.SelectedIndex = 0;
InitializeComponent(); pickerBox2.ComboBox.Items.Clear();
initialiseComponents2(); pickerBox2.ComboBox.Items.AddRange(new string[] { "No", "Yes" });
if (pickerBox2.ComboBox.Items.Count > 0) pickerBox2.ComboBox.SelectedIndex = 0;
} }
private void InitializeComponent() private void InitializeComponent()
@ -339,36 +347,52 @@ namespace AppLauncher.Windows.Forms
} }
private void initialiseComponents2()
{
pickerBox1.ComboBox.Items.Clear();
pickerBox1.ComboBox.Items.AddRange(new string[] { "Normal", "Hidden", "Minimized", "Maximized" });
if (pickerBox1.ComboBox.Items.Count > 0) pickerBox1.ComboBox.SelectedIndex = 0;
pickerBox2.ComboBox.Items.Clear();
pickerBox2.ComboBox.Items.AddRange(new string[] { "No", "Yes" });
if (pickerBox2.ComboBox.Items.Count > 0) pickerBox2.ComboBox.SelectedIndex = 0;
}
protected override void OnShown(EventArgs e) protected override void OnShown(EventArgs e)
{ {
base.OnShown(e); base.OnShown(e);
if (parentPanel != null) if (this.TilePanel != null)
{ {
textBox1.Text = parentPanel.ModelInfo.Title; updateModel(this.TilePanel.ModelInfo);
textBox2.Text = parentPanel.ModelInfo.ProcessFilename; }
textBox3.Text = parentPanel.ModelInfo.ProcessArgument; else if (this.ListBox != null)
textBox4.Text = parentPanel.ModelInfo.ProcessWorkingDirectory; {
pickerBox1.ComboBox.SelectedIndex = (int)parentPanel.ModelInfo.ProcessWindowStyle; if (this.ListBox.ListBox.SelectedItem != null)
pickerBox2.ComboBox.SelectedIndex = (parentPanel.ModelInfo.ProcessAsAdmin ? 1 : 0); {
TileModel model = (this.ListBox.ListBox.SelectedItem as TileModel);
if (model != null)
{
updateModel(model);
}
}
} }
} }
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
TileModel model = new TileModel() TileModel model = buildModel();
if (this.TilePanel != null)
{
this.TilePanel.LoadInfo(model);
}
else if (this.ListBox != null)
{
int n = this.ListBox.ListBox.SelectedIndex;
if (n >= 0)
{
this.ListBox.ListBox.Items.RemoveAt(n);
this.ListBox.ListBox.Items.Insert(n, model);
this.ListBox.ListBox.SelectedIndex = n;
}
}
this.Close();
}
protected TileModel buildModel()
{
return new TileModel()
{ {
Title = textBox1.Text?.Trim(), Title = textBox1.Text?.Trim(),
ProcessFilename = textBox2.Text?.Trim(), ProcessFilename = textBox2.Text?.Trim(),
@ -377,17 +401,21 @@ namespace AppLauncher.Windows.Forms
ProcessWindowStyle = (System.Diagnostics.ProcessWindowStyle)pickerBox1.ComboBox.SelectedIndex, ProcessWindowStyle = (System.Diagnostics.ProcessWindowStyle)pickerBox1.ComboBox.SelectedIndex,
ProcessAsAdmin = (pickerBox2.ComboBox.SelectedIndex == 1) ProcessAsAdmin = (pickerBox2.ComboBox.SelectedIndex == 1)
}; };
}
parentPanel.LoadInfo(model); protected void updateModel(TileModel model)
{
if (model == null)
{
return;
}
//parentPanel.Info.Title = textBox1.Text?.Trim(); textBox1.Text = model.Title;
//parentPanel.Info.ProcessFilename = textBox2.Text?.Trim(); textBox2.Text = model.ProcessFilename;
//parentPanel.Info.ProcessArgument = textBox3.Text?.Trim(); textBox3.Text = model.ProcessArgument;
//parentPanel.Info.ProcessWorkingDirectory = textBox4.Text?.Trim(); textBox4.Text = model.ProcessWorkingDirectory;
//parentPanel.Info.ProcessWindowStyle = (System.Diagnostics.ProcessWindowStyle) pickerBox1.ComboBox.SelectedIndex; pickerBox1.ComboBox.SelectedIndex = (int)model.ProcessWindowStyle;
//parentPanel.Info.ProcessAsAdmin = (pickerBox2.ComboBox.SelectedIndex == 1); pickerBox2.ComboBox.SelectedIndex = (model.ProcessAsAdmin ? 1 : 0);
this.Close();
} }
} }

View File

@ -13,6 +13,7 @@ namespace AppLauncher.Windows.Forms
protected bool isDragging = false; protected bool isDragging = false;
protected Point startPosition = new Point(); protected Point startPosition = new Point();
protected ContextMenuStrip groupContextMenu = null;
protected TileModel modelInfo = new TileModel(); protected TileModel modelInfo = new TileModel();
public TTilePanel() : base() public TTilePanel() : base()
@ -77,30 +78,18 @@ namespace AppLauncher.Windows.Forms
{ {
this.modelInfo = model; this.modelInfo = model;
this.Image = null;
this.Title = model.Title; this.Title = model.Title;
if (this.modelInfo.IsGroup) if (this.modelInfo.IsGroup)
{ {
this.Image = Properties.Resources.folder_32; this.Image = Properties.Resources.folder_32;
invalidateGroupMenu(this.modelInfo);
} }
else else
{ {
this.Image = model.Icon; this.Image = getIcon(model);
if (this.Image == null)
{
if (File.Exists(model.ProcessFilename))
{
try
{
this.Image = Icon.ExtractAssociatedIcon(model.ProcessFilename)?.ToBitmap();
}
catch
{
}
}
}
} }
toolTip1.SetToolTip(this, this.Title); toolTip1.SetToolTip(this, this.Title);
@ -116,16 +105,14 @@ namespace AppLauncher.Windows.Forms
return; return;
} }
if (e.Button != MouseButtons.Right)
{
return;
}
this.BringToFront(); this.BringToFront();
if (((e.Button == MouseButtons.Left) && (Control.ModifierKeys == Keys.Control)) || (e.Button == MouseButtons.Right))
{
isDragging = true; isDragging = true;
startPosition = e.Location; startPosition = e.Location;
} }
}
private void panel_MouseUp(object sender, MouseEventArgs e) private void panel_MouseUp(object sender, MouseEventArgs e)
{ {
@ -151,67 +138,32 @@ namespace AppLauncher.Windows.Forms
private void panel_MouseClick(object sender, MouseEventArgs e) private void panel_MouseClick(object sender, MouseEventArgs e)
{ {
if (e.Button != MouseButtons.Left) if (Control.ModifierKeys == Keys.Control) return;
{ if (this.ModelInfo == null) return;
return;
}
if (this.ModelInfo == null) if (e.Button == MouseButtons.Left)
{ {
return;
}
if (this.ModelInfo.IsGroup) if (this.ModelInfo.IsGroup)
{ {
if (groupContextMenu != null)
{
groupContextMenu.Show(this, e.Location);
}
} }
else else
{ {
panel_MouseDoubleClick(sender, e); panel_MouseDoubleClick(sender, e);
} }
} }
}
private void panel_MouseDoubleClick(object sender, MouseEventArgs e) private void panel_MouseDoubleClick(object sender, MouseEventArgs e)
{ {
if (e.Button != MouseButtons.Left) if (Control.ModifierKeys == Keys.Control) return;
{
return;
}
if (this.ModelInfo == null) if (e.Button == MouseButtons.Left)
{ {
return; execute(this.ModelInfo);
}
if (this.ModelInfo.IsGroup)
{
return;
}
if (string.IsNullOrWhiteSpace(this.ModelInfo.ProcessFilename))
{
return;
}
if (!File.Exists(this.ModelInfo.ProcessFilename))
{
return;
}
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = this.ModelInfo.ProcessFilename;
p.WindowStyle = this.ModelInfo.ProcessWindowStyle;
if (!string.IsNullOrWhiteSpace(this.ModelInfo.ProcessArgument)) p.Arguments = this.ModelInfo.ProcessArgument;
if (!string.IsNullOrWhiteSpace(this.ModelInfo.ProcessWorkingDirectory)) p.WorkingDirectory = this.ModelInfo.ProcessWorkingDirectory;
if (this.ModelInfo.ProcessAsAdmin) p.Verb = "runas";
try
{
Process.Start(p);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
} }
} }
@ -237,5 +189,105 @@ namespace AppLauncher.Windows.Forms
this.PanelContainer.Remove(this); this.PanelContainer.Remove(this);
} }
protected void execute(TileModel model)
{
if (model == null)
{
return;
}
if (model.IsGroup)
{
return;
}
if (string.IsNullOrWhiteSpace(model.ProcessFilename))
{
return;
}
if (!File.Exists(model.ProcessFilename))
{
return;
}
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = model.ProcessFilename;
p.WindowStyle = model.ProcessWindowStyle;
if (!string.IsNullOrWhiteSpace(model.ProcessArgument)) p.Arguments = model.ProcessArgument;
if (!string.IsNullOrWhiteSpace(model.ProcessWorkingDirectory)) p.WorkingDirectory = model.ProcessWorkingDirectory;
if (model.ProcessAsAdmin) p.Verb = "runas";
try
{
Process.Start(p);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}
protected Image getIcon(TileModel model)
{
if (!File.Exists(model.ProcessFilename))
{
return null;
}
try
{
return Icon.ExtractAssociatedIcon(model.ProcessFilename)?.ToBitmap();
}
catch
{
// do nothing
}
return null;
}
protected void invalidateGroupMenu(TileModel model)
{
if (groupContextMenu == null) groupContextMenu = new ContextMenuStrip();
groupContextMenu.Items.Clear();
if (model.Items == null)
{
return;
}
foreach (TileModel item in model.Items)
{
ToolStripItem toolItem = groupContextMenu.Items.Add(item.Title);
toolItem.Image = getIcon(item);
toolItem.Tag = item;
toolItem.Click += toolItem_Click;
}
}
private void toolItem_Click(object sender, EventArgs e)
{
if (sender.GetType() != typeof(ToolStripMenuItem))
{
return;
}
ToolStripMenuItem item = (sender as ToolStripMenuItem);
if (item.Tag == null)
{
return;
}
if (item.Tag.GetType() != typeof(TileModel))
{
return;
}
TileModel model = (item.Tag as TileModel);
execute(model);
}
} }
} }

View File

@ -35,6 +35,7 @@ namespace AppLauncher.Windows.Forms
protected bool isAnimating = false; protected bool isAnimating = false;
protected bool isChecked = true; protected bool isChecked = true;
protected Point lastMousePosition = new Point();
public TTilePanelLayout(TileGroupModel model) : base() public TTilePanelLayout(TileGroupModel model) : base()
{ {
@ -139,6 +140,8 @@ namespace AppLauncher.Windows.Forms
{ {
base.OnMouseClick(e); base.OnMouseClick(e);
lastMousePosition = e.Location;
bool isLabel = ((e.Location.X >= 0) && (e.Location.X <= this.Width) && (e.Location.Y >= 0) && (e.Location.Y <= 20)); 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 (e.Button == MouseButtons.Left)
@ -248,7 +251,12 @@ namespace AppLauncher.Windows.Forms
this.SetGridSize(gridSize.X, (gridSize.Y + 1)); this.SetGridSize(gridSize.X, (gridSize.Y + 1));
} }
Point? newCoord = findLastFreeCoord(); Point? newCoord = tile.Position;
if ((newCoord == null) || hasTile(tile.Position))
{
newCoord = findLastFreeCoord();
}
if (newCoord == null) if (newCoord == null)
{ {
return; return;
@ -385,11 +393,7 @@ namespace AppLauncher.Windows.Forms
this.SetGridSize(groupInfo.GridSize.Width, (groupInfo.GridSize.Height + 1)); this.SetGridSize(groupInfo.GridSize.Width, (groupInfo.GridSize.Height + 1));
} }
public void EditGroup() public void EditGroup() => EditGroupForm.ShowDialog(this);
{
EditGroupForm editForm = new EditGroupForm(this);
editForm.ShowDialog();
}
public void LoadModel(TileGroupModel model) public void LoadModel(TileGroupModel model)
{ {
@ -457,7 +461,7 @@ namespace AppLauncher.Windows.Forms
return; return;
} }
Point newPosition = convertLocationToCoord(posX, posY); Point newPosition = convertLocationToCoord_Nearest(posX, posY);
if (!isTileInBounds(newPosition)) if (!isTileInBounds(newPosition))
{ {
return; return;
@ -565,6 +569,20 @@ namespace AppLauncher.Windows.Forms
protected Point convertCoordToLocation(Point position) => new Point((position.X * this.TileSize), ((position.Y * this.TileSize) + labelHeight)); protected Point convertCoordToLocation(Point position) => new Point((position.X * this.TileSize), ((position.Y * this.TileSize) + labelHeight));
protected Point convertLocationToCoord(int posX, int posY) protected Point convertLocationToCoord(int posX, int posY)
{
int x = (int)Math.Ceiling(decimal.Divide(posX, this.TileSize));
int y = (int)Math.Ceiling(decimal.Divide((posY - labelHeight), this.TileSize));
x--;
y--;
if (x < 0) x = 0;
if (y < 0) y = 0;
return new Point(x, y);
}
protected Point convertLocationToCoord_Nearest(int posX, int posY)
{ {
int x = (int)Math.Round(decimal.Divide(posX, this.TileSize)); int x = (int)Math.Round(decimal.Divide(posX, this.TileSize));
int y = (int)Math.Round(decimal.Divide((posY - labelHeight), this.TileSize)); int y = (int)Math.Round(decimal.Divide((posY - labelHeight), this.TileSize));
@ -715,7 +733,12 @@ namespace AppLauncher.Windows.Forms
} }
} }
private void addTileMenuItem_Click(object sender, EventArgs e) => AddTileForm.ShowDialog(this); private void addTileMenuItem_Click(object sender, EventArgs e)
{
Point coord = convertLocationToCoord(lastMousePosition.X, lastMousePosition.Y);
AddTileForm.ShowDialog(this, coord);
}
private void addListTileMenuItem_Click(object sender, EventArgs e) => AddListTileForm.ShowDialog(this); private void addListTileMenuItem_Click(object sender, EventArgs e) => AddListTileForm.ShowDialog(this);