Initial commit

This commit is contained in:
Ray committed 2021-09-07 12:32:24 +01:00
commit 1cdcca7267
143 files changed
+18199

No files matched your search

File diff suppressed because it is too large. Load diff
+211
View File
@@ -0,0 +1,211 @@
using bzit.bomg.Models;
using System;
using System.Windows.Forms;
using static RyzStudio.Windows.Forms.BookmarkTreeView;
namespace RyzStudio.Windows.Forms
{
public class BookmarkTreeViewSNode
{
protected BookmarkTreeView parentTreeview = null;
public BookmarkTreeViewSNode(BookmarkTreeView treeview)
{
parentTreeview = treeview;
}
protected TreeNode SelectedNode
{
get => parentTreeview?.SelectedNode;
set
{
if (parentTreeview == null)
{
return;
}
parentTreeview.SelectedNode = value;
}
}
//public TreeNode AddFolder() => parentTreeview.AddFolder(this.SelectedNode);
//public TreeNode AddFolder(string name) => parentTreeview.AddFolder(this.SelectedNode, name);
//public TreeNode AddItem(string name, object tag)
//{
// if (this.SelectedNode == null)
// {
// return null;
// }
// if (this.SelectedNode.Tag != null)
// {
// return null;
// }
// TreeNode tn = new TreeNode(name, (int)BookmarkTreeView.IconSet.Default, (int)BookmarkTreeView.IconSet.Default);
// tn.Tag = tag;
// this.SelectedNode.Nodes.Add(tn);
// return tn;
//}
//public void AddOrUpdateItem(BookmarkItemViewModel viewModel)
//{
// switch (this.GetNodeType())
// {
// case NodeType.Root:
// case NodeType.Folder:
// parentTreeview.AddItem(this.SelectedNode, viewModel);
// break;
// case NodeType.Page:
// parentTreeview.UpdateItem(this.SelectedNode, viewModel);
// break;
// default:
// break;
// }
//}
//public void Delete()
//{
// if (this.SelectedNode == null)
// {
// return;
// }
// if (parentTreeview.Nodes.Count <= 0)
// {
// return;
// }
// if (this.SelectedNode.Equals(parentTreeview.Nodes[0]))
// {
// return;
// }
// this.SelectedNode.Remove();
//}
//public void Edit()
//{
// if (this.SelectedNode == null)
// {
// return;
// }
// if (this.SelectedNode.IsEditing)
// {
// return;
// }
// switch (this.GetNodeType())
// {
// case BookmarkTreeView.NodeType.Root:
// case BookmarkTreeView.NodeType.Folder:
// parentTreeview.AllowBeginEdit = true;
// this.SelectedNode.BeginEdit();
// break;
// case BookmarkTreeView.NodeType.Page:
// parentTreeview.AllowBeginEdit = true;
// this.SelectedNode.BeginEdit();
// break;
// default:
// break;
// }
//}
//public bool FindTextNode(string term) => parentTreeview.FindTextNode(this.SelectedNode, term);
//public BookmarkTreeView.NodeType GetNodeType() => parentTreeview.GetNodeType(this.SelectedNode);
//public BookmarkItemViewModel GetViewModel() => parentTreeview.GetViewModel(this.SelectedNode);
//public void MoveDown()
//{
// if (this.SelectedNode == null)
// {
// return;
// }
// TreeNode tn = this.SelectedNode;
// if (tn.Parent == null)
// {
// return;
// }
// TreeNode tn1 = tn.Parent;
// if (tn.Index >= (tn1.Nodes.Count - 1))
// {
// return;
// }
// int n = tn.Index + 1;
// tn1.Nodes.Remove(tn);
// tn1.Nodes.Insert(n, tn);
// this.SelectedNode = tn;
//}
//public void MoveUp()
//{
// if (this.SelectedNode == null)
// {
// return;
// }
// TreeNode tn = this.SelectedNode;
// if (tn.Parent == null)
// {
// return;
// }
// if (tn.Index <= 0)
// {
// return;
// }
// int n = tn.Index - 1;
// TreeNode tn1 = tn.Parent;
// tn1.Nodes.Remove(tn);
// tn1.Nodes.Insert(n, tn);
// this.SelectedNode = tn;
//}
//public void Sort()
//{
// if (this.SelectedNode == null)
// {
// return;
// }
// string[] tnv = new string[0];
// TreeNode[] tna = new TreeNode[0];
// foreach (TreeNode tn2 in this.SelectedNode.Nodes)
// {
// Array.Resize(ref tna, (tna.Length + 1));
// tna[(tna.Length - 1)] = tn2;
// Array.Resize(ref tnv, (tnv.Length + 1));
// tnv[(tnv.Length - 1)] = tn2.Text;
// }
// Array.Sort(tnv, tna);
// this.SelectedNode.Nodes.Clear();
// foreach (TreeNode tn2 in tna)
// {
// this.SelectedNode.Nodes.Add(tn2);
// }
//}
}
}
+176
View File
@@ -0,0 +1,176 @@
using FizzyLauncher.Models;
using RyzStudio.Windows.ThemedForms;
using System;
namespace FizzyLauncher.Windows.Forms
{
public class EditGroupForm : TDialogForm
{
public static void ShowDialog(TilePanelLayout control)
{
EditGroupForm form = new EditGroupForm();
form.TilePanelLayout = control;
form.ShowDialog();
}
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private TButton button1;
private TPickerBox pickerBox1;
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator2;
private TTextBox textBox1;
public EditGroupForm() : base()
{
InitializeComponent();
pickerBox1.ComboBox.Items.Clear();
pickerBox1.ComboBox.Items.AddRange(new string[] { "No", "Yes" });
if (pickerBox1.ComboBox.Items.Count > 0) pickerBox1.ComboBox.SelectedIndex = 0;
}
private void InitializeComponent()
{
this.textBox1 = new RyzStudio.Windows.ThemedForms.TTextBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new RyzStudio.Windows.ThemedForms.TButton();
this.pickerBox1 = new RyzStudio.Windows.ThemedForms.TPickerBox();
this.horizontalSeparator2 = new RyzStudio.Windows.Forms.THorizontalSeparator();
this.SuspendLayout();
//
// 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, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textBox1.Location = new System.Drawing.Point(192, 20);
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(177, 35);
this.textBox1.SubmitButton = null;
this.textBox1.TabIndex = 152;
this.textBox1.UseSystemPasswordChar = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.ForeColor = System.Drawing.SystemColors.ControlText;
this.label2.Location = new System.Drawing.Point(10, 62);
this.label2.Name = "label2";
this.label2.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label2.Size = new System.Drawing.Size(119, 34);
this.label2.TabIndex = 155;
this.label2.Text = "Show Only Expanded";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.ForeColor = System.Drawing.SystemColors.ControlText;
this.label1.Location = new System.Drawing.Point(10, 21);
this.label1.Margin = new System.Windows.Forms.Padding(0);
this.label1.Name = "label1";
this.label1.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label1.Size = new System.Drawing.Size(29, 34);
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.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.BackColor = System.Drawing.Color.Transparent;
this.button1.DefaultImage = null;
this.button1.DownImage = null;
this.button1.IsSelected = false;
this.button1.LabelText = "&Save";
this.button1.Location = new System.Drawing.Point(241, 469);
this.button1.Margin = new System.Windows.Forms.Padding(10);
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.Right)));
this.pickerBox1.BackColor = System.Drawing.Color.Transparent;
this.pickerBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.pickerBox1.Location = new System.Drawing.Point(285, 62);
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(84, 34);
this.pickerBox1.SubmitButton = null;
this.pickerBox1.TabIndex = 174;
//
// horizontalSeparator2
//
this.horizontalSeparator2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.horizontalSeparator2.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.horizontalSeparator2.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.horizontalSeparator2.BackColor = System.Drawing.Color.Transparent;
this.horizontalSeparator2.Location = new System.Drawing.Point(10, 437);
this.horizontalSeparator2.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0);
this.horizontalSeparator2.MaximumSize = new System.Drawing.Size(4920, 2);
this.horizontalSeparator2.MinimumSize = new System.Drawing.Size(0, 22);
this.horizontalSeparator2.Name = "horizontalSeparator2";
this.horizontalSeparator2.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.horizontalSeparator2.Size = new System.Drawing.Size(364, 22);
this.horizontalSeparator2.TabIndex = 182;
//
// EditGroupForm
//
this.ClientSize = new System.Drawing.Size(384, 521);
this.Controls.Add(this.horizontalSeparator2);
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.MinimumSize = new System.Drawing.Size(400, 560);
this.Name = "EditGroupForm";
this.Text = "Edit Group";
this.ResumeLayout(false);
this.PerformLayout();
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (this.TilePanelLayout != null)
{
textBox1.Text = this.TilePanelLayout.Model.Title;
pickerBox1.ComboBox.SelectedIndex = (this.TilePanelLayout.Model.IsExclusive ? 1 : 0);
}
}
public TilePanelLayout TilePanelLayout { get; set; } = null;
private void button1_Click(object sender, EventArgs e)
{
TileGroupModel model = this.TilePanelLayout.Model;
model.Title = textBox1.Text?.Trim();
model.IsExclusive = (pickerBox1.ComboBox.SelectedIndex == 1);
this.TilePanelLayout.UpdateModel(model);
this.Close();
}
}
}
+60
View File
@@ -0,0 +1,60 @@
<root>
<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>
+394
View File
@@ -0,0 +1,394 @@
using FizzyLauncher.Models;
using RyzStudio.Windows.ThemedForms;
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace FizzyLauncher.Windows.Forms
{
public class EditTileFolderForm : TDialogForm
{
public static void ShowAddDialog(TilePanelLayout control, Point coord)
{
EditTileFolderForm form = new EditTileFolderForm(DialogModeType.Add);
form.TilePanelLayout = control;
form.AimCoord = coord;
form.ShowDialog();
}
public static void ShowEditDialog(TilePanel control)
{
EditTileFolderForm form = new EditTileFolderForm(DialogModeType.Edit);
form.TilePanel = control;
form.ShowDialog();
}
private System.Windows.Forms.Label label1;
private TButton button1;
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator2;
private TTextBox textBox1;
private TListBox listBox1;
private RyzStudio.Windows.Forms.THorizontalSeparator tHorizontalSeparator1;
private System.Windows.Forms.Label label2;
public enum DialogModeType
{
Add = 0,
Edit
}
protected DialogModeType dialogMode = DialogModeType.Add;
public EditTileFolderForm(DialogModeType dialogMode) : base()
{
InitializeComponent();
this.DialogMode = dialogMode;
}
private void InitializeComponent()
{
this.textBox1 = new RyzStudio.Windows.ThemedForms.TTextBox();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new RyzStudio.Windows.ThemedForms.TButton();
this.horizontalSeparator2 = new RyzStudio.Windows.Forms.THorizontalSeparator();
this.listBox1 = new RyzStudio.Windows.ThemedForms.TListBox();
this.label2 = new System.Windows.Forms.Label();
this.tHorizontalSeparator1 = new RyzStudio.Windows.Forms.THorizontalSeparator();
this.SuspendLayout();
//
// 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, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textBox1.Location = new System.Drawing.Point(192, 20);
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(177, 35);
this.textBox1.SubmitButton = null;
this.textBox1.TabIndex = 152;
this.textBox1.UseSystemPasswordChar = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.ForeColor = System.Drawing.SystemColors.ControlText;
this.label1.Location = new System.Drawing.Point(10, 21);
this.label1.Margin = new System.Windows.Forms.Padding(0);
this.label1.Name = "label1";
this.label1.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label1.Size = new System.Drawing.Size(29, 34);
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.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.BackColor = System.Drawing.Color.Transparent;
this.button1.DefaultImage = null;
this.button1.DownImage = null;
this.button1.IsSelected = false;
this.button1.LabelText = "&Save";
this.button1.Location = new System.Drawing.Point(241, 469);
this.button1.Margin = new System.Windows.Forms.Padding(10);
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);
//
// horizontalSeparator2
//
this.horizontalSeparator2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.horizontalSeparator2.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.horizontalSeparator2.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.horizontalSeparator2.BackColor = System.Drawing.Color.Transparent;
this.horizontalSeparator2.Location = new System.Drawing.Point(10, 61);
this.horizontalSeparator2.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0);
this.horizontalSeparator2.MaximumSize = new System.Drawing.Size(4920, 2);
this.horizontalSeparator2.MinimumSize = new System.Drawing.Size(0, 22);
this.horizontalSeparator2.Name = "horizontalSeparator2";
this.horizontalSeparator2.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.horizontalSeparator2.Size = new System.Drawing.Size(364, 22);
this.horizontalSeparator2.TabIndex = 177;
//
// listBox1
//
this.listBox1.AllowDrop = true;
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)));
this.listBox1.BackColor = System.Drawing.Color.Transparent;
this.listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.listBox1.Location = new System.Drawing.Point(109, 87);
this.listBox1.Margin = new System.Windows.Forms.Padding(10, 4, 10, 4);
this.listBox1.Name = "listBox1";
this.listBox1.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5);
this.listBox1.Size = new System.Drawing.Size(260, 346);
this.listBox1.SubmitButton = null;
this.listBox1.TabIndex = 180;
this.listBox1.OnAdd += new System.EventHandler(this.listBox1_OnAdd);
this.listBox1.OnEdit += new System.EventHandler(this.listBox1_OnEdit);
this.listBox1.DragDrop += new System.Windows.Forms.DragEventHandler(this.listBox1_DragDrop);
this.listBox1.DragOver += new System.Windows.Forms.DragEventHandler(this.listBox1_DragOver);
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.ForeColor = System.Drawing.SystemColors.ControlText;
this.label2.Location = new System.Drawing.Point(8, 87);
this.label2.Name = "label2";
this.label2.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label2.Size = new System.Drawing.Size(25, 34);
this.label2.TabIndex = 181;
this.label2.Text = "List";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// tHorizontalSeparator1
//
this.tHorizontalSeparator1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tHorizontalSeparator1.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.tHorizontalSeparator1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.tHorizontalSeparator1.BackColor = System.Drawing.Color.Transparent;
this.tHorizontalSeparator1.Location = new System.Drawing.Point(10, 437);
this.tHorizontalSeparator1.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0);
this.tHorizontalSeparator1.MaximumSize = new System.Drawing.Size(4920, 2);
this.tHorizontalSeparator1.MinimumSize = new System.Drawing.Size(0, 22);
this.tHorizontalSeparator1.Name = "tHorizontalSeparator1";
this.tHorizontalSeparator1.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.tHorizontalSeparator1.Size = new System.Drawing.Size(364, 22);
this.tHorizontalSeparator1.TabIndex = 182;
//
// EditTileFolderForm
//
this.ClientSize = new System.Drawing.Size(384, 521);
this.Controls.Add(this.tHorizontalSeparator1);
this.Controls.Add(this.label2);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.horizontalSeparator2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.MinimumSize = new System.Drawing.Size(400, 560);
this.Name = "EditTileFolderForm";
this.Text = "Add List Tile";
this.ResumeLayout(false);
this.PerformLayout();
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (this.DialogMode == DialogModeType.Edit)
{
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)
{
foreach (TileModel item in this.TilePanel.ModelInfo.Items)
{
if (item.IsGroup)
{
continue;
}
listBox1.ListBox.Items.Add(item);
}
}
}
}
public TilePanelLayout TilePanelLayout { get; set; } = null;
public TilePanel TilePanel { get; set; } = null;
public Point AimCoord { get; set; } = new Point(-1, -1);
public DialogModeType DialogMode
{
get => dialogMode;
set
{
dialogMode = value;
switch (dialogMode)
{
case DialogModeType.Add:
this.Text = "Add Folder";
textBox1.Text = "New Folder";
break;
case DialogModeType.Edit:
this.Text = "Edit Folder";
break;
default: break;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
TileModel model = new TileModel()
{
Title = textBox1.Text?.Trim(),
IsGroup = true
};
switch (this.DialogMode)
{
case DialogModeType.Add:
if (!this.AimCoord.Equals(new Point(-1, -1)))
{
model.Position = this.AimCoord;
}
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.TilePanelLayout.AddTile(model);
break;
case DialogModeType.Edit:
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);
break;
default: break;
}
this.Close();
}
private void listBox1_OnAdd(object sender, EventArgs e) => EditTileForm.ShowAddDialog(listBox1);
private void listBox1_OnEdit(object sender, EventArgs e)
{
if (listBox1.ListBox.Items.Count <= 0)
{
return;
}
if (listBox1.ListBox.SelectedIndex < 0)
{
return;
}
if (listBox1.ListBox.SelectedItem == null)
{
return;
}
EditTileForm.ShowEditDialog(listBox1);
}
private void listBox1_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Link;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void listBox1_DragDrop(object sender, 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
}
}
if (string.IsNullOrWhiteSpace(model.Title))
{
model.Title = Path.GetFileNameWithoutExtension(fileList[0]);
}
}
listBox1.ListBox.Items.Add(model);
}
}
}
+60
View File
@@ -0,0 +1,60 @@
<root>
<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>
+482
View File
@@ -0,0 +1,482 @@
using FizzyLauncher.Models;
using RyzStudio.Windows.ThemedForms;
using System;
using System.Drawing;
namespace FizzyLauncher.Windows.Forms
{
public class EditTileForm : TDialogForm
{
public static void ShowAddDialog(TilePanelLayout control, Point coord)
{
EditTileForm form = new EditTileForm(DialogModeType.Add);
form.TilePanelLayout = control;
form.AimCoord = coord;
form.ShowDialog();
}
public static void ShowAddDialog(TListBox control)
{
EditTileForm form = new EditTileForm(DialogModeType.Add);
form.ListBox = control;
form.ShowDialog();
}
public static void ShowEditDialog(TilePanel control)
{
EditTileForm form = new EditTileForm(DialogModeType.Edit);
form.TilePanel = control;
form.ShowDialog();
}
public static void ShowEditDialog(TListBox control)
{
EditTileForm form = new EditTileForm(DialogModeType.Edit);
form.ListBox = control;
form.ShowDialog();
}
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private TOpenFileTextBox textBox2;
private TTextBox textBox3;
private TFolderTextBox textBox4;
private TButton button1;
private TPickerBox pickerBox1;
private TPickerBox pickerBox2;
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator1;
private RyzStudio.Windows.Forms.THorizontalSeparator horizontalSeparator2;
private TTextBox textBox1;
public enum DialogModeType
{
Add = 0,
Edit
}
protected DialogModeType dialogMode = DialogModeType.Add;
public EditTileForm(DialogModeType dialogMode) : base()
{
InitializeComponent();
this.DialogMode = dialogMode;
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 InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditTileForm));
this.textBox1 = new RyzStudio.Windows.ThemedForms.TTextBox();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.textBox2 = new RyzStudio.Windows.ThemedForms.TOpenFileTextBox();
this.textBox3 = new RyzStudio.Windows.ThemedForms.TTextBox();
this.textBox4 = new RyzStudio.Windows.ThemedForms.TFolderTextBox();
this.button1 = new RyzStudio.Windows.ThemedForms.TButton();
this.pickerBox1 = new RyzStudio.Windows.ThemedForms.TPickerBox();
this.pickerBox2 = new RyzStudio.Windows.ThemedForms.TPickerBox();
this.horizontalSeparator1 = new RyzStudio.Windows.Forms.THorizontalSeparator();
this.horizontalSeparator2 = new RyzStudio.Windows.Forms.THorizontalSeparator();
this.SuspendLayout();
//
// 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("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textBox1.Location = new System.Drawing.Point(192, 20);
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(177, 35);
this.textBox1.SubmitButton = null;
this.textBox1.TabIndex = 152;
this.textBox1.UseSystemPasswordChar = false;
//
// label6
//
this.label6.AutoSize = true;
this.label6.BackColor = System.Drawing.Color.Transparent;
this.label6.ForeColor = System.Drawing.SystemColors.ControlText;
this.label6.Location = new System.Drawing.Point(10, 250);
this.label6.Name = "label6";
this.label6.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label6.Size = new System.Drawing.Size(83, 34);
this.label6.TabIndex = 163;
this.label6.Text = "Run As Admin";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label7
//
this.label7.AutoSize = true;
this.label7.BackColor = System.Drawing.Color.Transparent;
this.label7.ForeColor = System.Drawing.SystemColors.ControlText;
this.label7.Location = new System.Drawing.Point(10, 209);
this.label7.Name = "label7";
this.label7.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label7.Size = new System.Drawing.Size(79, 34);
this.label7.TabIndex = 161;
this.label7.Text = "Window Style";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label4
//
this.label4.AutoSize = true;
this.label4.BackColor = System.Drawing.Color.Transparent;
this.label4.ForeColor = System.Drawing.SystemColors.ControlText;
this.label4.Location = new System.Drawing.Point(10, 144);
this.label4.Name = "label4";
this.label4.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label4.Size = new System.Drawing.Size(103, 34);
this.label4.TabIndex = 159;
this.label4.Text = "Working Directory";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label3
//
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.Color.Transparent;
this.label3.ForeColor = System.Drawing.SystemColors.ControlText;
this.label3.Location = new System.Drawing.Point(10, 103);
this.label3.Name = "label3";
this.label3.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label3.Size = new System.Drawing.Size(61, 34);
this.label3.TabIndex = 157;
this.label3.Text = "Argument";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.ForeColor = System.Drawing.SystemColors.ControlText;
this.label2.Location = new System.Drawing.Point(10, 62);
this.label2.Name = "label2";
this.label2.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label2.Size = new System.Drawing.Size(55, 34);
this.label2.TabIndex = 155;
this.label2.Text = "Filename";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.ForeColor = System.Drawing.SystemColors.ControlText;
this.label1.Location = new System.Drawing.Point(10, 21);
this.label1.Margin = new System.Windows.Forms.Padding(0);
this.label1.Name = "label1";
this.label1.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label1.Size = new System.Drawing.Size(29, 34);
this.label1.TabIndex = 153;
this.label1.Text = "Title";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// textBox2
//
this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox2.BackColor = System.Drawing.Color.Transparent;
this.textBox2.FileDialog = null;
this.textBox2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textBox2.HighlightImage = ((System.Drawing.Image)(resources.GetObject("textBox2.HighlightImage")));
this.textBox2.Location = new System.Drawing.Point(192, 61);
this.textBox2.Margin = new System.Windows.Forms.Padding(10, 3, 3, 3);
this.textBox2.Name = "textBox2";
this.textBox2.NormalImage = ((System.Drawing.Image)(resources.GetObject("textBox2.NormalImage")));
this.textBox2.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9);
this.textBox2.Size = new System.Drawing.Size(177, 35);
this.textBox2.SubmitButton = null;
this.textBox2.TabIndex = 170;
this.textBox2.UseSystemPasswordChar = false;
//
// textBox3
//
this.textBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox3.BackColor = System.Drawing.Color.Transparent;
this.textBox3.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textBox3.Location = new System.Drawing.Point(192, 102);
this.textBox3.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6);
this.textBox3.Name = "textBox3";
this.textBox3.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9);
this.textBox3.Size = new System.Drawing.Size(177, 35);
this.textBox3.SubmitButton = null;
this.textBox3.TabIndex = 171;
this.textBox3.UseSystemPasswordChar = false;
//
// textBox4
//
this.textBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox4.BackColor = System.Drawing.Color.Transparent;
this.textBox4.FolderDialog = null;
this.textBox4.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textBox4.HighlightImage = ((System.Drawing.Image)(resources.GetObject("textBox4.HighlightImage")));
this.textBox4.Location = new System.Drawing.Point(192, 143);
this.textBox4.Margin = new System.Windows.Forms.Padding(10, 3, 3, 3);
this.textBox4.Name = "textBox4";
this.textBox4.NormalImage = ((System.Drawing.Image)(resources.GetObject("textBox4.NormalImage")));
this.textBox4.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9);
this.textBox4.Size = new System.Drawing.Size(177, 35);
this.textBox4.SubmitButton = null;
this.textBox4.TabIndex = 172;
this.textBox4.UseSystemPasswordChar = false;
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.BackColor = System.Drawing.Color.Transparent;
this.button1.DefaultImage = null;
this.button1.DownImage = null;
this.button1.IsSelected = false;
this.button1.LabelText = "&Save";
this.button1.Location = new System.Drawing.Point(241, 469);
this.button1.Margin = new System.Windows.Forms.Padding(10);
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.Right)));
this.pickerBox1.BackColor = System.Drawing.Color.Transparent;
this.pickerBox1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.pickerBox1.Location = new System.Drawing.Point(241, 209);
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(128, 34);
this.pickerBox1.SubmitButton = null;
this.pickerBox1.TabIndex = 174;
//
// pickerBox2
//
this.pickerBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pickerBox2.BackColor = System.Drawing.Color.Transparent;
this.pickerBox2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.pickerBox2.Location = new System.Drawing.Point(285, 250);
this.pickerBox2.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6);
this.pickerBox2.Name = "pickerBox2";
this.pickerBox2.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5);
this.pickerBox2.Size = new System.Drawing.Size(84, 34);
this.pickerBox2.SubmitButton = null;
this.pickerBox2.TabIndex = 175;
//
// horizontalSeparator1
//
this.horizontalSeparator1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.horizontalSeparator1.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.horizontalSeparator1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.horizontalSeparator1.BackColor = System.Drawing.Color.Transparent;
this.horizontalSeparator1.Location = new System.Drawing.Point(10, 181);
this.horizontalSeparator1.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0);
this.horizontalSeparator1.MaximumSize = new System.Drawing.Size(4920, 2);
this.horizontalSeparator1.MinimumSize = new System.Drawing.Size(0, 22);
this.horizontalSeparator1.Name = "horizontalSeparator1";
this.horizontalSeparator1.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.horizontalSeparator1.Size = new System.Drawing.Size(364, 22);
this.horizontalSeparator1.TabIndex = 176;
//
// horizontalSeparator2
//
this.horizontalSeparator2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.horizontalSeparator2.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.horizontalSeparator2.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.horizontalSeparator2.BackColor = System.Drawing.Color.Transparent;
this.horizontalSeparator2.Location = new System.Drawing.Point(10, 437);
this.horizontalSeparator2.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0);
this.horizontalSeparator2.MaximumSize = new System.Drawing.Size(4920, 2);
this.horizontalSeparator2.MinimumSize = new System.Drawing.Size(0, 22);
this.horizontalSeparator2.Name = "horizontalSeparator2";
this.horizontalSeparator2.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.horizontalSeparator2.Size = new System.Drawing.Size(364, 22);
this.horizontalSeparator2.TabIndex = 177;
//
// EditTileForm
//
this.ClientSize = new System.Drawing.Size(384, 521);
this.Controls.Add(this.horizontalSeparator2);
this.Controls.Add(this.horizontalSeparator1);
this.Controls.Add(this.pickerBox2);
this.Controls.Add(this.pickerBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label6);
this.Controls.Add(this.label7);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.MinimumSize = new System.Drawing.Size(400, 560);
this.Name = "EditTileForm";
this.Text = "Add Tile";
this.ResumeLayout(false);
this.PerformLayout();
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (this.DialogMode == DialogModeType.Edit)
{
if (this.TilePanel != null)
{
updateModel(this.TilePanel.ModelInfo);
}
else if (this.ListBox != null)
{
if (this.ListBox.ListBox.SelectedItem != null)
{
TileModel model = (this.ListBox.ListBox.SelectedItem as TileModel);
if (model != null)
{
updateModel(model);
}
}
}
}
}
public TilePanelLayout TilePanelLayout { get; set; } = null;
public TilePanel TilePanel { get; set; } = null;
public TListBox ListBox { get; set; } = null;
public Point AimCoord { get; set; } = new Point(-1, -1);
public DialogModeType DialogMode
{
get => dialogMode;
set
{
dialogMode = value;
switch (dialogMode)
{
case DialogModeType.Add:
this.Text = "Add Tile";
break;
case DialogModeType.Edit:
this.Text = "Edit Tile";
break;
default: break;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
TileModel model = buildModel();
switch (this.DialogMode)
{
case DialogModeType.Add:
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;
}
break;
case DialogModeType.Edit:
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;
}
}
break;
default: break;
}
this.Close();
}
protected TileModel buildModel()
{
TileModel rs = new TileModel()
{
Title = textBox1.Text?.Trim(),
ProcessFilename = textBox2.Text?.Trim(),
ProcessArgument = textBox3.Text?.Trim(),
ProcessWorkingDirectory = textBox4.Text?.Trim(),
ProcessWindowStyle = (System.Diagnostics.ProcessWindowStyle)pickerBox1.ComboBox.SelectedIndex,
ProcessAsAdmin = (pickerBox2.ComboBox.SelectedIndex == 1)
};
if (this.DialogMode == DialogModeType.Add)
{
if (!this.AimCoord.Equals(new Point(-1, -1)))
{
rs.Position = this.AimCoord;
}
}
return rs;
}
protected void updateModel(TileModel model)
{
if (model == null)
{
return;
}
textBox1.Text = model.Title;
textBox2.Text = model.ProcessFilename;
textBox3.Text = model.ProcessArgument;
textBox4.Text = model.ProcessWorkingDirectory;
pickerBox1.ComboBox.SelectedIndex = (int)model.ProcessWindowStyle;
pickerBox2.ComboBox.SelectedIndex = (model.ProcessAsAdmin ? 1 : 0);
}
}
}
+97
View File
@@ -0,0 +1,97 @@
<root>
<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>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="textBox2.HighlightImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAAAK9JREFUOE/t0zsKwkAURuGp1BWJK3EhIrgAV+EOLLWwtRQLwQdiIbbiIkwynj+O
IVwnyhR2XvjyInNIkXHee8f0cEQBPbDOaKEarSvXhsAJO4wirlB4jipiA3phoIvIrLFChhnKiA3o8Ckw
RR93LNBODVwwwRL62kNKYIxNzQ1FSsDOEHk08HrYJMw/8KtA06/cCef6KJDZgDbTFrHNZO3x9idqOyui
m2+07bvPgHcPXOhtG3D6cUIAAAAASUVORK5CYII=
</value>
</data>
<data name="textBox2.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAAAMZJREFUOE/tk7sNwjAQQF3BRohJGAQhMQBTsAElFLSUiAKJTxIXhBZlCILNuyRG
iXEQKeg46fmsO/slhU9Za5XWehiXYcD6JElygZ6qhdwTioVDGo4wDXDjsohXdYkvMDTHVa8R9Hb0tpCz
XzqJL5Df/CRYRFE0Yn8nr9M07XcSwBXmXN6QDfncRTCjt6+Rgfla4Adfn3D+ERS4Yht/wY8FxVN2xTac
gLP5qyYLAhmmA4SGyeeEoPkSq3EWydsoB4gRDEqBVU/p15ajstHKCgAAAABJRU5ErkJggg==
</value>
</data>
<data name="textBox4.HighlightImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wAAADsABataJCQAAAJtJREFUOE/t0zEKwkAQheEpvILHSLySlTeJ6AnEzpPYi0ERPIKWKtZKNv9LNS5x
E6xS+OCDJew8tsgYmeCECsGZo1dKXLBwtnghQ2fe0JDPGHecsW6xwgwjNM8tdIgyxQ0qij2gORV9LejK
Bk8dfi3QjGY/C0IISS7/gkEVtP3KfbKEZm0PLZM++IVK0d0rdrAcR8TrnKK7BzPLa7Wb+WX/Nb8PAAAA
AElFTkSuQmCC
</value>
</data>
<data name="textBox4.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wAAADsABataJCQAAALZJREFUOE/tkzEKwjAYRjt4BY9hvZKTN1HsCYqbJzGzKBGb9gY6qjgrxvdJK7ZS
Gpwc/ODBnzTvg0AT5Xk+hB3cwVc456ZRSIqi2MAeafbGEq5Zlg3KY+1Bvkkql89Ya/vsnUCZN8FJYWyM
6ekKnsWkdF9hb8S3I6ioyRnkpa0FXcFbwOXrAjlyawXe+06q/At+qoDh41cOCU4iV8OaQY8pUVEgOnuA
VcSzjRm2UHvOHeisdc7FDwDnJKIbLgP9AAAAAElFTkSuQmCC
</value>
</data>
</root>
+149
View File
@@ -0,0 +1,149 @@
using FizzyLauncher.Models;
using RyzStudio.Windows.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace FizzyLauncher.Windows.Forms
{
public class TileContainer : Panel
{
protected const int DEFAULT_COLUMN = 6;
protected FlowLayoutPanel flowLayoutPanel1 = null;
public TileContainer()
{
flowLayoutPanel1 = new FlowLayoutPanel();
flowLayoutPanel1.AutoSize = true;
flowLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink;
flowLayoutPanel1.BackColor = Color.Transparent;
flowLayoutPanel1.FlowDirection = FlowDirection.TopDown;
flowLayoutPanel1.Location = new Point(10, 10);
flowLayoutPanel1.Margin = new Padding(0);
flowLayoutPanel1.Padding = new Padding(0, 0, 0, 20);
flowLayoutPanel1.Size = new Size(0, 20);
flowLayoutPanel1.WrapContents = false;
this.AutoScroll = true;
this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
this.BackColor = System.Drawing.Color.Transparent;
this.Margin = new Padding(0);
this.Name = "tileContainer1";
this.Padding = new Padding(10, 10, 10, 20);
this.Controls.Add(flowLayoutPanel1);
}
[Browsable(false)]
public event EventHandler OnColumnSizeChanged;
public int CalcWidth
{
get =>
TilePanelLayout.CalcWidth(this.TileWidthCount) +
this.Left + this.Padding.Horizontal + this.Margin.Horizontal +
flowLayoutPanel1.Padding.Horizontal + flowLayoutPanel1.Margin.Horizontal;
}
public int GroupCount
{
get => flowLayoutPanel1.Controls.Count;
}
public IEnumerable<TilePanelLayout> Groups
{
get
{
for (int i = 0; i < flowLayoutPanel1.Controls.Count; i++)
{
if (flowLayoutPanel1.Controls[i].GetType() != typeof(TilePanelLayout))
{
continue;
}
TilePanelLayout container = flowLayoutPanel1.Controls[i] as TilePanelLayout;
yield return container;
}
}
}
public IEnumerable<TileGroupModel> GroupModels
{
get
{
foreach (TilePanelLayout item in this.Groups)
{
yield return item.Model;
}
}
}
public int TileWidthCount { get; private set; } = DEFAULT_COLUMN;
public void Add()
{
this.Add(new TilePanelLayout(new TileGroupModel()
{
Title = "New Group",
IsExpanded = true,
GridSize = new Size(this.TileWidthCount, 1)
}));
}
public void Add(TilePanelLayout tilePanelLayout)
{
ThreadControl.Add(flowLayoutPanel1, tilePanelLayout);
this.InvalidateColumnSize();
}
public void Add(int columnCount)
{
this.TileWidthCount = ((columnCount <= 0) ? DEFAULT_COLUMN : columnCount);
this.Add();
}
public void Clear()
{
ThreadControl.Clear(flowLayoutPanel1);
this.TileWidthCount = DEFAULT_COLUMN;
InvalidateColumnSize();
}
public void InvalidateColumnSize()
{
this.OnColumnSizeChanged?.Invoke(this, null);
}
public void Load(List<TileGroupModel> groupList)
{
this.Clear();
if (groupList == null)
{
return;
}
foreach (TileGroupModel item in groupList)
{
this.TileWidthCount = Math.Max(this.TileWidthCount, item.GridSize.Width);
TilePanelLayout panel = new TilePanelLayout(item);
this.Add(panel);
}
InvalidateColumnSize();
}
}
}
+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>
+82
View File
@@ -0,0 +1,82 @@
namespace FizzyLauncher.Windows.Forms
{
partial class TilePanel
{
/// <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.components = new System.ComponentModel.Container();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.editToolStripMenuItem,
this.removeToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(118, 48);
//
// editToolStripMenuItem
//
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.editToolStripMenuItem.Text = "&Edit";
this.editToolStripMenuItem.Click += new System.EventHandler(this.editToolStripMenuItem_Click);
//
// removeToolStripMenuItem
//
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
this.removeToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.removeToolStripMenuItem.Text = "&Remove";
this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click);
//
// TilePanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(234)))), ((int)(((byte)(234)))));
this.Margin = new System.Windows.Forms.Padding(4, 3, 0, 0);
this.MaximumSize = new System.Drawing.Size(82, 81);
this.MinimumSize = new System.Drawing.Size(82, 81);
this.Name = "TilePanel";
this.Size = new System.Drawing.Size(82, 81);
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem;
private System.Windows.Forms.ToolTip toolTip1;
}
}
+506
View File
@@ -0,0 +1,506 @@
using FizzyLauncher.Models;
using RyzStudio.Windows.Forms;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using AppResource = BookmarkManager.AppResource;
namespace FizzyLauncher.Windows.Forms
{
public partial class TilePanel : TUserControl
{
protected bool isDragging = false;
protected Point startPosition = new Point();
protected int imageLeft = 0;
protected int imageTop = 11;
protected int labelMargin = 3;
protected int labelTop = 47;
protected Rectangle labelRectangle = new Rectangle();
protected string title = "";
protected Image icon = null;
protected ContextMenuStrip groupContextMenu = null;
protected TileModel modelInfo = new TileModel();
public TilePanel() : base()
{
InitializeComponent();
this.AllowDrop = true;
this.AutoSize = false;
this.BackColor = Color.FromArgb(250, 250, 250);
this.ContextMenuStrip = contextMenuStrip1;
this.DoubleBuffered = true;
this.Font = new Font(this.Font.FontFamily, 8.25F);
this.ForeColor = Color.FromArgb(99, 105, 119);
this.Size = new Size(70, 70);
this.MaximumSize = this.MinimumSize = this.Size;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.AllowDrop = true;
this.AutoSize = false;
this.BackColor = Color.FromArgb(250, 250, 250);
this.ContextMenuStrip = contextMenuStrip1;
this.DoubleBuffered = true;
this.Font = new Font(this.Font.FontFamily, 8.25F);
this.Size = new Size(70, 70);
this.MaximumSize = this.MinimumSize = this.Size;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
if (this.Image != null)
{
g.DrawImage(this.Image, new Point(imageLeft, imageTop));
}
if (!string.IsNullOrWhiteSpace(this.Title))
{
TextRenderer.DrawText(e.Graphics, this.Title, this.Font, labelRectangle, this.ForeColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.NoPadding | TextFormatFlags.EndEllipsis);
}
g.DrawRectangle(new Pen(Color.FromArgb(204, 206, 218), 1), new Rectangle(this.DisplayRectangle.X, this.DisplayRectangle.Y, (this.DisplayRectangle.Width - 1), (this.DisplayRectangle.Height - 1)));
}
[Category("Tile"), Browsable(true)]
public Image Image
{
get => icon;
protected set
{
icon = value;
if (icon == null)
{
imageLeft = 0;
}
else
{
imageLeft = (this.Width - icon.Width) / 2;
}
}
}
[Category("Tile"), Browsable(true)]
public string Title
{
get => title;
protected set
{
title = value;
labelRectangle = new Rectangle(labelMargin, labelTop, (this.Width - (labelMargin * 2)), (this.Height - labelTop - 1));
this.Invalidate();
}
}
[Browsable(false)]
public TileModel ModelInfo => modelInfo;
public TilePanelLayout PanelContainer
{
get
{
if (this.Parent == null)
{
return null;
}
if (this.Parent.GetType() != typeof(TilePanelLayout))
{
return null;
}
return (TilePanelLayout)this.Parent;
}
}
protected override void OnDragDrop(DragEventArgs e)
{
string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
if (this.ModelInfo.IsGroup)
{
this.DropFileList(fileList);
invalidateGroupMenu(this.ModelInfo);
}
else
{
if (this.PanelContainer != null)
{
this.PanelContainer.DropFileList(fileList);
}
}
}
protected override void OnDragOver(DragEventArgs e)
{
base.OnDragDrop(e);
e.Effect = (e.Data.GetDataPresent(DataFormats.FileDrop)) ? DragDropEffects.Link : DragDropEffects.None;
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
isDragging = false;
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
TilePanelLayout container = this.PanelContainer;
if (container == null)
{
return;
}
this.BringToFront();
if (((e.Button == MouseButtons.Left) && (Control.ModifierKeys == Keys.Control)) || (e.Button == MouseButtons.Right))
{
isDragging = true;
startPosition = e.Location;
}
}
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
if (Control.ModifierKeys == Keys.Control) return;
if (this.ModelInfo == null) return;
if (e.Button == MouseButtons.Left)
{
if (this.ModelInfo.IsGroup)
{
if (groupContextMenu != null)
{
invalidateGroupMenuSize();
groupContextMenu.Show(this, e.Location);
}
}
else
{
OnMouseDoubleClick(e);
}
}
}
protected override void OnMouseDoubleClick(MouseEventArgs e)
{
base.OnMouseDoubleClick(e);
if (Control.ModifierKeys == Keys.Control) return;
if (e.Button == MouseButtons.Left)
{
execute(this.ModelInfo);
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (isDragging)
{
TilePanelLayout 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));
layoutPanel.MoveTile(this, x, y);
}
}
public void DropFileList(string[] fileList)
{
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
}
}
if (string.IsNullOrWhiteSpace(model.Title))
{
model.Title = Path.GetFileNameWithoutExtension(fileList[0]);
}
}
this.ModelInfo.Items.Add(model);
}
public void LoadInfo(TileModel model)
{
this.modelInfo = model;
this.Image = null;
this.Title = model.Title;
if (this.modelInfo.IsGroup)
{
this.Image = AppResource.folder_32;
invalidateGroupMenu(this.modelInfo);
}
else
{
this.Image = getIcon(model);
}
toolTip1.SetToolTip(this, this.Title);
}
private void editToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.ModelInfo.IsGroup)
{
EditTileFolderForm.ShowEditDialog(this);
}
else
{
EditTileForm.ShowEditDialog(this);
}
}
private void removeToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.PanelContainer == null)
{
return;
}
this.PanelContainer.Remove(this);
}
protected void execute(TileModel model)
{
if (model == null)
{
return;
}
if (model.IsGroup)
{
return;
}
if (string.IsNullOrWhiteSpace(model.CleanProcessFilename))
{
return;
}
if (!File.Exists(model.CleanProcessFilename))
{
return;
}
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = model.CleanProcessFilename;
p.WindowStyle = model.ProcessWindowStyle;
if (!string.IsNullOrWhiteSpace(model.CleanProcessArgument))
{
p.Arguments = model.CleanProcessArgument;
}
if (!string.IsNullOrWhiteSpace(model.CleanProcessWorkingDirectory))
{
p.WorkingDirectory = model.CleanProcessWorkingDirectory;
}
if (model.ProcessAsAdmin)
{
p.UseShellExecute = true;
p.Verb = "runas";
}
MainForm parentForm = findMainForm();
if (parentForm != null)
{
if (parentForm.CurrentSession != null)
{
if (parentForm.CurrentSession.HideOnClick)
{
parentForm.Visible = false;
}
}
}
try
{
Process.Start(p);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}
protected Image getIcon(TileModel model)
{
if (!File.Exists(model.CleanProcessFilename))
{
return null;
}
try
{
return Icon.ExtractAssociatedIcon(model.CleanProcessFilename)?.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;
}
}
protected void invalidateGroupMenuSize()
{
if (this.PanelContainer != null)
{
if (this.PanelContainer.MainForm != null)
{
if (this.PanelContainer.MainForm.CurrentSession != null)
{
if (this.PanelContainer.MainForm.CurrentSession.EnableBigIconInFolder)
{
groupContextMenu.ImageScalingSize = new Size(24, 24);
return;
}
}
}
}
groupContextMenu.ImageScalingSize = new Size(16, 16);
}
protected MainForm findMainForm()
{
Control item = this;
while (true)
{
item = item.Parent;
if (item == null)
{
return null;
}
if (item.GetType() == typeof(MainForm))
{
return (item as MainForm);
}
}
}
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);
}
}
}
+66
View File
@@ -0,0 +1,66 @@
<root>
<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>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>172, 17</value>
</metadata>
</root>
+259
View File
@@ -0,0 +1,259 @@
namespace FizzyLauncher.Windows.Forms
{
partial class TilePanelLayout
{
/// <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.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.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator();
this.removeRowToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem2 = 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.label1 = new System.Windows.Forms.Label();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
this.removeRowToolStripMenuItem = 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.toolStripMenuItem6,
this.removeRowToolStripMenuItem1});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(144, 76);
//
// addToolStripMenuItem
//
this.addToolStripMenuItem.Name = "addToolStripMenuItem";
this.addToolStripMenuItem.Size = new System.Drawing.Size(143, 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(143, 22);
this.addListToolStripMenuItem.Text = "Add &Folder";
this.addListToolStripMenuItem.Click += new System.EventHandler(this.addListTileMenuItem_Click);
//
// toolStripMenuItem6
//
this.toolStripMenuItem6.Name = "toolStripMenuItem6";
this.toolStripMenuItem6.Size = new System.Drawing.Size(140, 6);
//
// removeRowToolStripMenuItem1
//
this.removeRowToolStripMenuItem1.Name = "removeRowToolStripMenuItem1";
this.removeRowToolStripMenuItem1.Size = new System.Drawing.Size(143, 22);
this.removeRowToolStripMenuItem1.Text = "&Remove Row";
this.removeRowToolStripMenuItem1.Click += new System.EventHandler(this.removeRowToolStripMenuItem_Click_1);
//
// contextMenuStrip2
//
this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem2,
this.toolStripMenuItem1,
this.toolStripSeparator3,
this.toolStripMenuItem7,
this.toolStripSeparator2,
this.toolStripMenuItem4,
this.toolStripSeparator1,
this.toolStripMenuItem3});
this.contextMenuStrip2.Name = "contextMenuStrip1";
this.contextMenuStrip2.Size = new System.Drawing.Size(181, 154);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem2.Text = "&Add Group";
this.toolStripMenuItem2.Click += new System.EventHandler(this.addGroupMenuItem_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(180, 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(177, 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(180, 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(177, 6);
//
// toolStripMenuItem3
//
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem3.Text = "&Remove";
this.toolStripMenuItem3.Click += new System.EventHandler(this.removeGroupMenuItem3_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(99)))), ((int)(((byte)(105)))), ((int)(((byte)(119)))));
this.label1.Image = global::BookmarkManager.AppResource.toggle_left_ea_16;
this.label1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.label1.Location = new System.Drawing.Point(265, 83);
this.label1.Margin = new System.Windows.Forms.Padding(0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(0, 15);
this.label1.TabIndex = 2;
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.label1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.label1_MouseClick);
this.label1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.label1_MouseClick);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(177, 6);
//
// toolStripMenuItem7
//
this.toolStripMenuItem7.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem5,
this.removeRowToolStripMenuItem});
this.toolStripMenuItem7.Name = "toolStripMenuItem7";
this.toolStripMenuItem7.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem7.Text = "Ro&w";
//
// toolStripMenuItem5
//
this.toolStripMenuItem5.Name = "toolStripMenuItem5";
this.toolStripMenuItem5.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem5.Text = "Add &Row";
this.toolStripMenuItem5.Click += new System.EventHandler(this.toolStripMenuItem5_Click);
//
// removeRowToolStripMenuItem
//
this.removeRowToolStripMenuItem.Name = "removeRowToolStripMenuItem";
this.removeRowToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.removeRowToolStripMenuItem.Text = "Remo&ve Row";
this.removeRowToolStripMenuItem.Click += new System.EventHandler(this.removeRowToolStripMenuItem_Click_1);
//
// TilePanelLayout
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Transparent;
this.Controls.Add(this.label1);
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "TilePanelLayout";
this.Size = new System.Drawing.Size(432, 173);
this.contextMenuStrip1.ResumeLayout(false);
this.contextMenuStrip2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#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 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;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem6;
private System.Windows.Forms.ToolStripMenuItem removeRowToolStripMenuItem1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem7;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5;
private System.Windows.Forms.ToolStripMenuItem removeRowToolStripMenuItem;
}
}
+943
View File
@@ -0,0 +1,943 @@
using FizzyLauncher.Models;
using RyzStudio.Windows.Forms;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using AppResource = BookmarkManager.AppResource;
namespace FizzyLauncher.Windows.Forms
{
public partial class TilePanelLayout : TUserControl
{
public static int CalcWidth(int tileCount) => (tileCount * tileSize) + ((tileCount - 1) * margin);
public class Item
{
public TilePanel Tile { get; set; }
public Point Coord { get; set; } = new Point(0, 0);
}
protected const int tileSize = 70;
protected const int margin = 3;
protected const int labelHeight = 20;
protected const int collapseIncrement = 6;
protected const int expandIncrement = 8;
protected TileGroupModel groupModel = null;
protected List<Item> items = new List<Item>();
protected int collapseHeight = 0;
protected int expandedHeight = 0;
protected bool isAnimating = false;
protected bool isChecked = true;
protected Point lastMousePosition = new Point();
protected Point gridSize = new Point();
public TilePanelLayout(TileGroupModel model) : base()
{
InitializeComponent();
this.AllowDrop = true;
this.BackColor = Color.Transparent;
this.LoadModel(model);
label1.Location = new Point(0, 4);
label1.Margin = new Padding(0);
label1.Padding = new Padding(0);
}
protected override void OnDragDrop(DragEventArgs e)
{
string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
this.DropFileList(fileList);
}
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);
}
protected override async void OnResize(EventArgs e)
{
base.OnResize(e);
await this.InvalidateContainer();
}
protected override void OnMouseClick(MouseEventArgs 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));
if (e.Button == MouseButtons.Left)
{
// do nothing
}
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);
public Point GridSize
{
get => gridSize;
}
public bool EnableAnimation
{
get
{
MainForm mainForm = this.MainForm;
if (mainForm == null)
{
return false;
}
if (mainForm.CurrentSession == null)
{
return false;
}
return mainForm.CurrentSession.EnableAnimation;
}
}
public int CollapseHeight => labelHeight + collapseHeight;
public int ExpandedHeight => expandedHeight + this.Padding.Bottom;
public void DropFileList(string[] fileList)
{
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
}
}
if (string.IsNullOrWhiteSpace(model.Title))
{
model.Title = Path.GetFileNameWithoutExtension(fileList[0]);
}
}
this.AddTile(model);
}
public TileGroupModel Model
{
get
{
TileGroupModel rs = new TileGroupModel()
{
Title = groupModel.Title,
GridSize = new Size(this.GridSize.X, this.GridSize.Y),
IsExpanded = isChecked,
IsExclusive = groupModel.IsExclusive,
Items = this.Tiles
};
return rs;
}
}
public FlowLayoutPanel FlowLayoutPanel
{
get
{
Control parentControl = this.Parent;
while (true)
{
if (parentControl == null)
{
return null;
}
if (parentControl.GetType() == typeof(FlowLayoutPanel))
{
return parentControl as FlowLayoutPanel;
}
parentControl = parentControl.Parent;
}
}
}
public MainForm MainForm
{
get
{
Control parentControl = this.FlowLayoutPanel;
while (true)
{
if (parentControl == null)
{
return null;
}
if (parentControl.GetType() == typeof(MainForm))
{
return parentControl as MainForm;
}
parentControl = parentControl.Parent;
}
}
}
public List<TileModel> Tiles
{
get
{
List<TileModel> rs = new List<TileModel>();
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 = tile.Position;
if ((newCoord == null) || hasTile(tile.Position))
{
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;
isChecked = false;
if (this.EnableAnimation)
{
while (this.Height > this.CollapseHeight)
{
ThreadControl.SetHeight(this, (this.Height - collapseIncrement));
Thread.Sleep(10);
}
}
ThreadControl.SetHeight(this, this.CollapseHeight);
isAnimating = false;
this.Invalidate(this.DisplayRectangle, false);
});
}
public async Task Expand()
{
await Task.Run(() =>
{
if (isAnimating) return;
isAnimating = true;
isChecked = true;
if (this.EnableAnimation)
{
while (this.Height < this.ExpandedHeight)
{
ThreadControl.SetHeight(this, (this.Height + expandIncrement));
Thread.Sleep(10);
}
}
ThreadControl.SetHeight(this, this.ExpandedHeight);
isAnimating = false;
this.Invalidate(this.DisplayRectangle, 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()
{
if (isAnimating)
{
return;
}
if (isChecked)
{
await this.Expand();
}
else
{
await this.Collapse();
}
}
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() => this.SetGridSize(gridSize.X, (gridSize.Y + 1));
public void EditGroup() => EditGroupForm.ShowDialog(this);
public void LoadModel(TileGroupModel model)
{
groupModel = model;
isChecked = groupModel.IsExpanded;
label1.Text = " " + groupModel?.Title;
label1.Image = (isChecked ? AppResource.toggle_right_ea_16 : AppResource.toggle_left_ea_16);
this.SetGridSize(groupModel.GridSize.Width, groupModel.GridSize.Height);
this.LoadTiles(model.Items);
this.SetGridSize(groupModel.GridSize.Width, groupModel.GridSize.Height);
this.Invalidate();
}
public void UpdateModel(TileGroupModel model)
{
groupModel = model;
isChecked = groupModel.IsExpanded;
label1.Text = " " + groupModel?.Title;
this.Invalidate();
}
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 = 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_Nearest(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)
{
gridSize = new Point(width, height);
groupModel.GridSize = new Size(groupModel.GridSize.Width, height);
expandedHeight = (this.TileSize * height) + labelHeight;
int w = CalcWidth(gridSize.X);
this.Size = new Size(w, (isChecked ? this.ExpandedHeight : this.CollapseHeight));
}
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.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 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 async void label1_MouseClick(object sender, MouseEventArgs e)
{
if (isAnimating) return;
if (e.Button == MouseButtons.Left)
{
isChecked = !isChecked;
label1.Image = (isChecked ? AppResource.toggle_right_ea_16 : AppResource.toggle_left_ea_16);
this.Invalidate();
await this.InvalidateContainer();
// exclusivity
if (isChecked)
{
if (this.Model.IsExclusive)
{
if (this.FlowLayoutPanel != null)
{
foreach (TilePanelLayout item in this.FlowLayoutPanel.Controls.OfType<TilePanelLayout>())
{
if (item.Equals(this))
{
continue;
}
await item.Collapse();
}
}
}
}
label1.Image = (isChecked ? AppResource.toggle_right_ea_16 : AppResource.toggle_left_ea_16);
}
else if (e.Button == MouseButtons.Right)
{
contextMenuStrip2.Show(this, e.Location);
}
}
#region tile context menu
/// <summary>
/// Add tile
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void addTileMenuItem_Click(object sender, EventArgs e)
{
Point coord = convertLocationToCoord(lastMousePosition.X, lastMousePosition.Y);
EditTileForm.ShowAddDialog(this, coord);
}
/// <summary>
/// Add folder
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void addListTileMenuItem_Click(object sender, EventArgs e)
{
Point coord = convertLocationToCoord(lastMousePosition.X, lastMousePosition.Y);
EditTileFolderForm.ShowAddDialog(this, coord);
}
#endregion
#region group context menu
/// <summary>
/// Add group
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void addGroupMenuItem_Click(object sender, EventArgs e)
{
this.AddGroup();
}
/// <summary>
/// Edit group
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void editGroupMenuItem_Click(object sender, EventArgs e)
{
this.EditGroup();
}
/// <summary>
/// Add row
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem5_Click(object sender, EventArgs e)
{
this.AddRow();
}
/// <summary>
/// Remove row
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void removeRowToolStripMenuItem_Click_1(object sender, EventArgs e)
{
if (gridSize.Y <= 1)
{
return;
}
bool rs = items.Exists(x => x.Coord.Y.Equals(gridSize.Y - 1));
if (rs)
{
return;
}
this.SetGridSize(gridSize.X, (gridSize.Y - 1));
}
/// <summary>
/// Move to top
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void moveTopMenuItem_Click(object sender, EventArgs e)
{
this.MoveTop();
}
/// <summary>
/// Move up
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void moveUpMenuItem_Click(object sender, EventArgs e)
{
this.MoveUp();
}
/// <summary>
/// Move down
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void moveDownMenuItem_Click(object sender, EventArgs e)
{
this.MoveDown();
}
/// <summary>
/// Move to bottom
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void moveBottomMenuItem_Click(object sender, EventArgs e)
{
this.MoveBottom();
}
/// <summary>
/// Remove group
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void removeGroupMenuItem3_Click(object sender, EventArgs e)
{
this.Remove();
}
#endregion
}
}
+66
View File
@@ -0,0 +1,66 @@
<root>
<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>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="contextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>172, 17</value>
</metadata>
</root>