2024-07-01 00:55:19 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
2024-07-06 15:30:37 +00:00
|
|
|
|
using RokettoLaunch.Models;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
using RyzStudio.Windows.Forms;
|
|
|
|
|
using RyzStudio.Windows.ThemedForms;
|
2024-07-05 21:43:19 +00:00
|
|
|
|
using RyzStudio.Windows.ThemedForms.ButtonTextBox;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-06 15:30:37 +00:00
|
|
|
|
namespace RokettoLaunch
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-20 16:40:30 +00:00
|
|
|
|
public class EditTileFolderForm : Form
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
private Label label1;
|
|
|
|
|
private ThClearableTextBox textBox1;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
private ThListBox listBox1;
|
2024-07-05 21:43:19 +00:00
|
|
|
|
private Label label2;
|
2024-07-20 16:40:30 +00:00
|
|
|
|
private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1;
|
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
private TileModel result = null;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
public EditTileFolderForm(TileModel model = null)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
InitializeComponent();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-20 16:40:30 +00:00
|
|
|
|
UISetup.Dialog(this);
|
|
|
|
|
|
|
|
|
|
this.Text = (result == null) ? "Add Folder" : "Edit Folder";
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
result = model;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (result != null)
|
2024-07-01 00:55:19 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
textBox1.Text = result?.Title ?? string.Empty;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
foreach (TileModel item in result.Items ?? new List<TileModel>())
|
2024-07-01 00:55:19 +00:00
|
|
|
|
{
|
|
|
|
|
if (item.IsGroup)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
listBox1.ListBox.Items.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeComponent()
|
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
textBox1 = new ThClearableTextBox();
|
2024-07-01 00:55:19 +00:00
|
|
|
|
label1 = new Label();
|
|
|
|
|
listBox1 = new ThListBox();
|
|
|
|
|
label2 = new Label();
|
2024-07-20 16:40:30 +00:00
|
|
|
|
dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter();
|
2024-07-01 00:55:19 +00:00
|
|
|
|
SuspendLayout();
|
2024-07-20 16:40:30 +00:00
|
|
|
|
//
|
2021-07-22 23:45:30 +00:00
|
|
|
|
// textBox1
|
2024-07-20 16:40:30 +00:00
|
|
|
|
//
|
2024-07-01 00:55:19 +00:00
|
|
|
|
textBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
|
|
|
textBox1.BackColor = Color.Transparent;
|
2024-07-20 16:40:30 +00:00
|
|
|
|
textBox1.ClearedValue = "";
|
2024-07-01 00:55:19 +00:00
|
|
|
|
textBox1.EnableReactiveVisual = true;
|
|
|
|
|
textBox1.Font = new Font("Microsoft Sans Serif", 8.25F);
|
2024-07-20 16:40:30 +00:00
|
|
|
|
textBox1.Icon = "O";
|
|
|
|
|
textBox1.IconSize = 13F;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
textBox1.Location = new Point(109, 20);
|
|
|
|
|
textBox1.Name = "textBox1";
|
2024-07-20 16:40:30 +00:00
|
|
|
|
textBox1.Size = new Size(275, 32);
|
2024-07-01 00:55:19 +00:00
|
|
|
|
textBox1.TabIndex = 152;
|
|
|
|
|
textBox1.TabStop = false;
|
|
|
|
|
textBox1.UseSystemPasswordChar = false;
|
2024-07-20 16:40:30 +00:00
|
|
|
|
//
|
2021-07-22 23:45:30 +00:00
|
|
|
|
// label1
|
2024-07-20 16:40:30 +00:00
|
|
|
|
//
|
2024-07-01 00:55:19 +00:00
|
|
|
|
label1.AutoSize = true;
|
|
|
|
|
label1.BackColor = Color.Transparent;
|
|
|
|
|
label1.ForeColor = SystemColors.ControlText;
|
2024-07-20 16:40:30 +00:00
|
|
|
|
label1.Location = new Point(10, 20);
|
2024-07-01 00:55:19 +00:00
|
|
|
|
label1.Margin = new Padding(0);
|
|
|
|
|
label1.Name = "label1";
|
2024-07-20 16:40:30 +00:00
|
|
|
|
label1.Padding = new Padding(0, 9, 0, 0);
|
|
|
|
|
label1.Size = new Size(29, 24);
|
2024-07-01 00:55:19 +00:00
|
|
|
|
label1.TabIndex = 153;
|
|
|
|
|
label1.Text = "Title";
|
|
|
|
|
label1.TextAlign = ContentAlignment.MiddleLeft;
|
2024-07-20 16:40:30 +00:00
|
|
|
|
//
|
2021-07-22 23:45:30 +00:00
|
|
|
|
// listBox1
|
2024-07-20 16:40:30 +00:00
|
|
|
|
//
|
2024-07-01 00:55:19 +00:00
|
|
|
|
listBox1.AllowDrop = true;
|
|
|
|
|
listBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
|
|
|
listBox1.BackColor = Color.Transparent;
|
|
|
|
|
listBox1.EnableReactiveVisual = true;
|
|
|
|
|
listBox1.Font = new Font("Microsoft Sans Serif", 8.25F);
|
2024-07-20 16:40:30 +00:00
|
|
|
|
listBox1.Location = new Point(109, 62);
|
2024-07-01 00:55:19 +00:00
|
|
|
|
listBox1.Name = "listBox1";
|
2024-07-20 16:40:30 +00:00
|
|
|
|
listBox1.Size = new Size(260, 366);
|
2024-07-01 00:55:19 +00:00
|
|
|
|
listBox1.TabIndex = 180;
|
|
|
|
|
listBox1.OnAdd += listBox1_OnAdd;
|
|
|
|
|
listBox1.OnEdit += listBox1_OnEdit;
|
2024-07-20 16:40:30 +00:00
|
|
|
|
listBox1.OnCopy += listBox1_OnCopy;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
listBox1.DragDrop += listBox1_DragDrop;
|
|
|
|
|
listBox1.DragOver += listBox1_DragOver;
|
2024-07-20 16:40:30 +00:00
|
|
|
|
//
|
2021-07-22 23:45:30 +00:00
|
|
|
|
// label2
|
2024-07-20 16:40:30 +00:00
|
|
|
|
//
|
2024-07-01 00:55:19 +00:00
|
|
|
|
label2.AutoSize = true;
|
|
|
|
|
label2.BackColor = Color.Transparent;
|
|
|
|
|
label2.ForeColor = SystemColors.ControlText;
|
2024-07-20 16:40:30 +00:00
|
|
|
|
label2.Location = new Point(10, 62);
|
|
|
|
|
label2.Margin = new Padding(0);
|
2024-07-01 00:55:19 +00:00
|
|
|
|
label2.Name = "label2";
|
2024-07-20 16:40:30 +00:00
|
|
|
|
label2.Padding = new Padding(0, 9, 0, 0);
|
|
|
|
|
label2.Size = new Size(82, 24);
|
2024-07-01 00:55:19 +00:00
|
|
|
|
label2.TabIndex = 181;
|
2024-07-20 16:40:30 +00:00
|
|
|
|
label2.Text = "Tile Collection";
|
2024-07-01 00:55:19 +00:00
|
|
|
|
label2.TextAlign = ContentAlignment.MiddleLeft;
|
2024-07-20 16:40:30 +00:00
|
|
|
|
//
|
|
|
|
|
// dialogFooter1
|
|
|
|
|
//
|
|
|
|
|
dialogFooter1.BackColor = Color.FromArgb(240, 240, 240);
|
|
|
|
|
dialogFooter1.Button1Text = "&Save";
|
|
|
|
|
dialogFooter1.Dialog = this;
|
|
|
|
|
dialogFooter1.Dock = DockStyle.Bottom;
|
|
|
|
|
dialogFooter1.Location = new Point(0, 437);
|
|
|
|
|
dialogFooter1.Name = "dialogFooter1";
|
|
|
|
|
dialogFooter1.Size = new Size(384, 84);
|
|
|
|
|
//
|
2021-08-01 14:25:33 +00:00
|
|
|
|
// EditTileFolderForm
|
2024-07-20 16:40:30 +00:00
|
|
|
|
//
|
|
|
|
|
BackColor = Color.White;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
ClientSize = new Size(384, 521);
|
2024-07-20 16:40:30 +00:00
|
|
|
|
Controls.Add(dialogFooter1);
|
2024-07-01 00:55:19 +00:00
|
|
|
|
Controls.Add(label2);
|
|
|
|
|
Controls.Add(listBox1);
|
|
|
|
|
Controls.Add(label1);
|
|
|
|
|
Controls.Add(textBox1);
|
|
|
|
|
MinimumSize = new Size(400, 560);
|
|
|
|
|
Name = "EditTileFolderForm";
|
|
|
|
|
Text = "Add List Tile";
|
|
|
|
|
ResumeLayout(false);
|
|
|
|
|
PerformLayout();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
public TileModel Result
|
|
|
|
|
{
|
|
|
|
|
get
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (result == null)
|
2024-07-01 00:55:19 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
result = new TileModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Title = textBox1.Text?.Trim() ?? string.Empty;
|
|
|
|
|
result.IsGroup = true;
|
|
|
|
|
result.Items = new List<TileModel>();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
foreach (TileModel item in listBox1.ListBox.Items.OfType<TileModel>())
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
if (item.IsGroup)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
continue;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
result.Items.Add(item);
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
private void listBox1_OnAdd(object sender, EventArgs e)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
var form = new EditTileForm();
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
listBox1.ListBox.Items.Add(form.Result);
|
2021-07-22 23:45:30 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listBox1_OnEdit(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (listBox1.ListBox.Items.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
var n = listBox1.ListBox.SelectedIndex;
|
|
|
|
|
if (n < 0)
|
2021-07-28 19:36:22 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-29 20:07:06 +00:00
|
|
|
|
if (listBox1.ListBox.SelectedItem == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
var form = new EditTileForm((TileModel)listBox1.ListBox.SelectedItem);
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
listBox1.ListBox.Items.RemoveAt(n);
|
|
|
|
|
listBox1.ListBox.Items.Insert(n, form.Result);
|
|
|
|
|
};
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-20 16:40:30 +00:00
|
|
|
|
private void listBox1_OnCopy(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
listBox1.ListBox.CopyItem<TileModel>();
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
private void listBox1_DragOver(object sender, DragEventArgs e)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
|
|
|
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
|
|
|
|
{
|
|
|
|
|
e.Effect = DragDropEffects.Link;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
e.Effect = DragDropEffects.None;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listBox1_DragDrop(object sender, DragEventArgs e)
|
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
var fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
|
2021-07-22 23:45:30 +00:00
|
|
|
|
if (fileList == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fileList.Length <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(fileList[0]))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
var model = new TileModel()
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|