Added duplicate tile

Added drag-n-drop files on til
Added add tile on middle-click
This commit is contained in:
Ray committed 2024-07-11 22:12:56 +01:00
1 parent 39f54d5bba
commit 1c291c1b91
7 files changed
+320 -141

No files matched your search

+5 -36
View File
@@ -28,48 +28,17 @@
/// </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);
components = new System.ComponentModel.Container();
toolTip1 = new System.Windows.Forms.ToolTip(components);
SuspendLayout();
//
// TilePanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.Name = "TilePanel";
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
Name = "TilePanel";
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;
}
}
+66 -96
View File
@@ -1,4 +1,5 @@
using System;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
@@ -19,7 +20,6 @@ namespace RokettoLaunch.Windows.Forms
InitializeComponent();
this.AllowDrop = true;
this.ContextMenuStrip = contextMenuStrip1;
this.Font = new Font(this.Font.FontFamily, 8.25F);
this.Size = new Size(70, 70);
this.AutoScaleMode = AutoScaleMode.None;
@@ -49,10 +49,30 @@ namespace RokettoLaunch.Windows.Forms
if (this.ModelInfo.IsGroup)
{
this.DropFileList(fileList);
foreach (var item in fileList ?? new string[0])
{
var model = GetTileModel(item);
if (model == null)
{
continue;
}
this.ModelInfo.Items.Add(model);
}
InvalidateGroupMenu(this.ModelInfo);
}
else
{
if ((fileList?.Length ?? 0) > 0)
{
var model = GetTileModel(fileList[0]);
if (model != null)
{
LoadInfo(model);
}
}
}
}
protected override void OnMouseClick(MouseEventArgs e)
@@ -96,97 +116,6 @@ namespace RokettoLaunch.Windows.Forms
}
#region Context Menu
/// <summary>
/// Edit
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void editToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.ModelInfo.IsGroup)
{
var form = new EditTileFolderForm(this.ModelInfo);
if (form.ShowDialog() == DialogResult.OK)
{
this.LoadInfo(form.Result);
};
}
else
{
var form = new EditTileForm(this.ModelInfo);
if (form.ShowDialog() == DialogResult.OK)
{
this.LoadInfo(form.Result);
};
}
}
/// <summary>
/// Remove
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void removeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.TileContainer?.Controls?.Remove(this);
}
#endregion
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;
@@ -208,7 +137,7 @@ namespace RokettoLaunch.Windows.Forms
toolTip1.SetToolTip(this, this.Title);
}
protected void Execute(TileModel model)
private void Execute(TileModel model)
{
if (model == null)
{
@@ -231,7 +160,7 @@ namespace RokettoLaunch.Windows.Forms
RyzStudio.Diagnostics.Process.Execute(model.CleanProcessFilename, model.CleanProcessWorkingDirectory, model.CleanProcessArgument, model.ProcessWindowStyle, model.ProcessAsAdmin);
}
protected void InvalidateGroupMenu(TileModel model)
private void InvalidateGroupMenu(TileModel model)
{
var iconSize = ((this.MainForm?.CurrentSession?.ShowBigIcons ?? true) ? 24 : 16);
@@ -267,5 +196,46 @@ namespace RokettoLaunch.Windows.Forms
}
}
private TileModel GetTileModel(string filename)
{
if (string.IsNullOrWhiteSpace(filename))
{
return null;
}
TileModel model = new TileModel()
{
ProcessFilename = filename,
Title = Path.GetFileName(filename)
};
// exe
if (Path.GetExtension(filename).Equals(".exe", StringComparison.CurrentCultureIgnoreCase))
{
if (File.Exists(filename))
{
try
{
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(filename);
if (fvi != null)
{
model.Title = fvi.ProductName;
}
}
catch
{
// do nothing
}
}
if (string.IsNullOrWhiteSpace(model.Title))
{
model.Title = Path.GetFileNameWithoutExtension(filename);
}
}
return model;
}
}
}
+61 -4
View File
@@ -1,4 +1,64 @@
<root>
<?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">
@@ -57,9 +117,6 @@
<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>