diff --git a/ShortcutUtil/EntryListItem.Designer.cs b/ShortcutUtil/EntryListItem.Designer.cs
new file mode 100644
index 0000000..613d017
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.Designer.cs
@@ -0,0 +1,59 @@
+namespace ShortcutUtil
+{
+ partial class EntryListItem
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.testButton = new ShortcutUtil.ListBoxButton();
+ this.SuspendLayout();
+ //
+ // testButton
+ //
+ this.testButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
+ this.testButton.Location = new System.Drawing.Point(550, 47);
+ this.testButton.Name = "testButton";
+ this.testButton.Size = new System.Drawing.Size(120, 55);
+ this.testButton.TabIndex = 0;
+ this.testButton.Text = "Test";
+ this.testButton.UseVisualStyleBackColor = true;
+ //
+ // EntryListItem
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.testButton);
+ this.Name = "EntryListItem";
+ this.Size = new System.Drawing.Size(700, 150);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private ListBoxButton testButton;
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.Designer.cs b/ShortcutUtil/EntryListItem.Designer.cs
new file mode 100644
index 0000000..613d017
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.Designer.cs
@@ -0,0 +1,59 @@
+namespace ShortcutUtil
+{
+ partial class EntryListItem
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.testButton = new ShortcutUtil.ListBoxButton();
+ this.SuspendLayout();
+ //
+ // testButton
+ //
+ this.testButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
+ this.testButton.Location = new System.Drawing.Point(550, 47);
+ this.testButton.Name = "testButton";
+ this.testButton.Size = new System.Drawing.Size(120, 55);
+ this.testButton.TabIndex = 0;
+ this.testButton.Text = "Test";
+ this.testButton.UseVisualStyleBackColor = true;
+ //
+ // EntryListItem
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.testButton);
+ this.Name = "EntryListItem";
+ this.Size = new System.Drawing.Size(700, 150);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private ListBoxButton testButton;
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.cs b/ShortcutUtil/EntryListItem.cs
new file mode 100644
index 0000000..6787497
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ShortcutUtil
+{
+ public partial class EntryListItem : UserControl
+ {
+ public ListBoxControl TestButton { get; private set; }
+
+ private ListBox listBox;
+ public EntryListItem(ListBox listBox)
+ {
+ InitializeComponent();
+
+ this.listBox = listBox;
+
+ TestButton = new ListBoxControl(testButton, listBox);
+ }
+
+ public void LayoutFromList()
+ {
+ if (listBox.Items.Count > 0)
+ {
+ Size = listBox.GetItemRectangle(0).Size;
+ PerformLayout();
+ }
+ }
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.Designer.cs b/ShortcutUtil/EntryListItem.Designer.cs
new file mode 100644
index 0000000..613d017
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.Designer.cs
@@ -0,0 +1,59 @@
+namespace ShortcutUtil
+{
+ partial class EntryListItem
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.testButton = new ShortcutUtil.ListBoxButton();
+ this.SuspendLayout();
+ //
+ // testButton
+ //
+ this.testButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
+ this.testButton.Location = new System.Drawing.Point(550, 47);
+ this.testButton.Name = "testButton";
+ this.testButton.Size = new System.Drawing.Size(120, 55);
+ this.testButton.TabIndex = 0;
+ this.testButton.Text = "Test";
+ this.testButton.UseVisualStyleBackColor = true;
+ //
+ // EntryListItem
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.testButton);
+ this.Name = "EntryListItem";
+ this.Size = new System.Drawing.Size(700, 150);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private ListBoxButton testButton;
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.cs b/ShortcutUtil/EntryListItem.cs
new file mode 100644
index 0000000..6787497
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ShortcutUtil
+{
+ public partial class EntryListItem : UserControl
+ {
+ public ListBoxControl TestButton { get; private set; }
+
+ private ListBox listBox;
+ public EntryListItem(ListBox listBox)
+ {
+ InitializeComponent();
+
+ this.listBox = listBox;
+
+ TestButton = new ListBoxControl(testButton, listBox);
+ }
+
+ public void LayoutFromList()
+ {
+ if (listBox.Items.Count > 0)
+ {
+ Size = listBox.GetItemRectangle(0).Size;
+ PerformLayout();
+ }
+ }
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.resx b/ShortcutUtil/EntryListItem.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ShortcutUtil/EntryListItem.Designer.cs b/ShortcutUtil/EntryListItem.Designer.cs
new file mode 100644
index 0000000..613d017
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.Designer.cs
@@ -0,0 +1,59 @@
+namespace ShortcutUtil
+{
+ partial class EntryListItem
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.testButton = new ShortcutUtil.ListBoxButton();
+ this.SuspendLayout();
+ //
+ // testButton
+ //
+ this.testButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
+ this.testButton.Location = new System.Drawing.Point(550, 47);
+ this.testButton.Name = "testButton";
+ this.testButton.Size = new System.Drawing.Size(120, 55);
+ this.testButton.TabIndex = 0;
+ this.testButton.Text = "Test";
+ this.testButton.UseVisualStyleBackColor = true;
+ //
+ // EntryListItem
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.testButton);
+ this.Name = "EntryListItem";
+ this.Size = new System.Drawing.Size(700, 150);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private ListBoxButton testButton;
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.cs b/ShortcutUtil/EntryListItem.cs
new file mode 100644
index 0000000..6787497
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ShortcutUtil
+{
+ public partial class EntryListItem : UserControl
+ {
+ public ListBoxControl TestButton { get; private set; }
+
+ private ListBox listBox;
+ public EntryListItem(ListBox listBox)
+ {
+ InitializeComponent();
+
+ this.listBox = listBox;
+
+ TestButton = new ListBoxControl(testButton, listBox);
+ }
+
+ public void LayoutFromList()
+ {
+ if (listBox.Items.Count > 0)
+ {
+ Size = listBox.GetItemRectangle(0).Size;
+ PerformLayout();
+ }
+ }
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.resx b/ShortcutUtil/EntryListItem.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ShortcutUtil/ListBoxButton.cs b/ShortcutUtil/ListBoxButton.cs
new file mode 100644
index 0000000..46518cd
--- /dev/null
+++ b/ShortcutUtil/ListBoxButton.cs
@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ShortcutUtil
+{
+ public interface IListBoxControl
+ {
+ void Hover();
+ void Unhover();
+ }
+
+ public class ListBoxButton : Button, IListBoxControl
+ {
+ public void Hover()
+ {
+ OnMouseDown(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0));
+ }
+ public void Unhover()
+ {
+ OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0));
+ }
+ }
+
+ public class ListBoxControl where T : Control, IListBoxControl, new()
+ {
+ public T Control { get; private set; }
+ private ListBox listBox;
+
+ public int? IndexOver { get; private set; }
+
+ private MethodInfo refreshItem;
+ public ListBoxControl(T control, ListBox listBox)
+ {
+ Control = control;
+ this.listBox = listBox;
+ listBox.MouseMove += ListBoxMouseMove;
+
+ refreshItem = listBox.GetType().GetMethod("RefreshItem", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(int) }, null);
+ }
+
+ private void RefreshItem(int index)
+ {
+ listBox.BeginUpdate();
+ object item = listBox.Items[index];
+ listBox.Items.RemoveAt(index);
+ listBox.Items.Insert(index, item);
+ listBox.EndUpdate();
+ //listBox.Items[index] = item;
+ //listBox.Items[index] =
+ //if (refreshItem != null) refreshItem.Invoke(listBox, new object[] { index });
+ }
+
+ public Rectangle BoundsInList(int index)
+ {
+ Point offsetLoc = listBox.GetItemRectangle(index).Location;
+ offsetLoc.Offset(Control.Location);
+ return new Rectangle(offsetLoc, Control.Size);
+ }
+
+ private void ListBoxMouseMove(object sender, MouseEventArgs e)
+ {
+ int? nowIndexOver = null;
+ for (int i = 0; i < listBox.Items.Count; i++)
+ {
+ if (BoundsInList(i).Contains(e.X, e.Y))
+ {
+ nowIndexOver = i;
+ break;
+ }
+ }
+
+ if (nowIndexOver != IndexOver)
+ {
+ if (IndexOver.HasValue) RefreshItem(IndexOver.Value);
+ IndexOver = nowIndexOver;
+ if (IndexOver.HasValue) RefreshItem(IndexOver.Value);
+ }
+ }
+
+ public void RenderToItem(DrawItemEventArgs e)
+ {
+ using (Bitmap b = new Bitmap(Control.Size.Width, Control.Size.Height))
+ {
+ if (e.Index == IndexOver)
+ {
+ Control.Hover();
+ }
+ Control.DrawToBitmap(b, new Rectangle(new Point(), Control.Size));
+ Point offsetLoc = e.Bounds.Location;
+ offsetLoc.Offset(Control.Location);
+ e.Graphics.DrawImage(b, offsetLoc.X, offsetLoc.Y);
+ if (e.Index == IndexOver)
+ {
+ Control.Unhover();
+ }
+ }
+ }
+
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.Designer.cs b/ShortcutUtil/EntryListItem.Designer.cs
new file mode 100644
index 0000000..613d017
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.Designer.cs
@@ -0,0 +1,59 @@
+namespace ShortcutUtil
+{
+ partial class EntryListItem
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.testButton = new ShortcutUtil.ListBoxButton();
+ this.SuspendLayout();
+ //
+ // testButton
+ //
+ this.testButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
+ this.testButton.Location = new System.Drawing.Point(550, 47);
+ this.testButton.Name = "testButton";
+ this.testButton.Size = new System.Drawing.Size(120, 55);
+ this.testButton.TabIndex = 0;
+ this.testButton.Text = "Test";
+ this.testButton.UseVisualStyleBackColor = true;
+ //
+ // EntryListItem
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.testButton);
+ this.Name = "EntryListItem";
+ this.Size = new System.Drawing.Size(700, 150);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private ListBoxButton testButton;
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.cs b/ShortcutUtil/EntryListItem.cs
new file mode 100644
index 0000000..6787497
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ShortcutUtil
+{
+ public partial class EntryListItem : UserControl
+ {
+ public ListBoxControl TestButton { get; private set; }
+
+ private ListBox listBox;
+ public EntryListItem(ListBox listBox)
+ {
+ InitializeComponent();
+
+ this.listBox = listBox;
+
+ TestButton = new ListBoxControl(testButton, listBox);
+ }
+
+ public void LayoutFromList()
+ {
+ if (listBox.Items.Count > 0)
+ {
+ Size = listBox.GetItemRectangle(0).Size;
+ PerformLayout();
+ }
+ }
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.resx b/ShortcutUtil/EntryListItem.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ShortcutUtil/ListBoxButton.cs b/ShortcutUtil/ListBoxButton.cs
new file mode 100644
index 0000000..46518cd
--- /dev/null
+++ b/ShortcutUtil/ListBoxButton.cs
@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ShortcutUtil
+{
+ public interface IListBoxControl
+ {
+ void Hover();
+ void Unhover();
+ }
+
+ public class ListBoxButton : Button, IListBoxControl
+ {
+ public void Hover()
+ {
+ OnMouseDown(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0));
+ }
+ public void Unhover()
+ {
+ OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0));
+ }
+ }
+
+ public class ListBoxControl where T : Control, IListBoxControl, new()
+ {
+ public T Control { get; private set; }
+ private ListBox listBox;
+
+ public int? IndexOver { get; private set; }
+
+ private MethodInfo refreshItem;
+ public ListBoxControl(T control, ListBox listBox)
+ {
+ Control = control;
+ this.listBox = listBox;
+ listBox.MouseMove += ListBoxMouseMove;
+
+ refreshItem = listBox.GetType().GetMethod("RefreshItem", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(int) }, null);
+ }
+
+ private void RefreshItem(int index)
+ {
+ listBox.BeginUpdate();
+ object item = listBox.Items[index];
+ listBox.Items.RemoveAt(index);
+ listBox.Items.Insert(index, item);
+ listBox.EndUpdate();
+ //listBox.Items[index] = item;
+ //listBox.Items[index] =
+ //if (refreshItem != null) refreshItem.Invoke(listBox, new object[] { index });
+ }
+
+ public Rectangle BoundsInList(int index)
+ {
+ Point offsetLoc = listBox.GetItemRectangle(index).Location;
+ offsetLoc.Offset(Control.Location);
+ return new Rectangle(offsetLoc, Control.Size);
+ }
+
+ private void ListBoxMouseMove(object sender, MouseEventArgs e)
+ {
+ int? nowIndexOver = null;
+ for (int i = 0; i < listBox.Items.Count; i++)
+ {
+ if (BoundsInList(i).Contains(e.X, e.Y))
+ {
+ nowIndexOver = i;
+ break;
+ }
+ }
+
+ if (nowIndexOver != IndexOver)
+ {
+ if (IndexOver.HasValue) RefreshItem(IndexOver.Value);
+ IndexOver = nowIndexOver;
+ if (IndexOver.HasValue) RefreshItem(IndexOver.Value);
+ }
+ }
+
+ public void RenderToItem(DrawItemEventArgs e)
+ {
+ using (Bitmap b = new Bitmap(Control.Size.Width, Control.Size.Height))
+ {
+ if (e.Index == IndexOver)
+ {
+ Control.Hover();
+ }
+ Control.DrawToBitmap(b, new Rectangle(new Point(), Control.Size));
+ Point offsetLoc = e.Bounds.Location;
+ offsetLoc.Offset(Control.Location);
+ e.Graphics.DrawImage(b, offsetLoc.X, offsetLoc.Y);
+ if (e.Index == IndexOver)
+ {
+ Control.Unhover();
+ }
+ }
+ }
+
+ }
+}
diff --git a/ShortcutUtil/MainForm.Designer.cs b/ShortcutUtil/MainForm.Designer.cs
index 8af74c7..d6d2006 100755
--- a/ShortcutUtil/MainForm.Designer.cs
+++ b/ShortcutUtil/MainForm.Designer.cs
@@ -40,9 +40,10 @@
// defaultShortcutLabel
//
this.defaultShortcutLabel.AutoSize = true;
- this.defaultShortcutLabel.Location = new System.Drawing.Point(14, 75);
+ this.defaultShortcutLabel.Location = new System.Drawing.Point(19, 94);
+ this.defaultShortcutLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.defaultShortcutLabel.Name = "defaultShortcutLabel";
- this.defaultShortcutLabel.Size = new System.Drawing.Size(169, 20);
+ this.defaultShortcutLabel.Size = new System.Drawing.Size(226, 25);
this.defaultShortcutLabel.TabIndex = 0;
this.defaultShortcutLabel.Text = "Select default shortcut";
//
@@ -53,9 +54,10 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.entryListBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
this.entryListBox.FormattingEnabled = true;
- this.entryListBox.Location = new System.Drawing.Point(16, 98);
+ this.entryListBox.Location = new System.Drawing.Point(21, 122);
+ this.entryListBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.entryListBox.Name = "entryListBox";
- this.entryListBox.Size = new System.Drawing.Size(770, 355);
+ this.entryListBox.Size = new System.Drawing.Size(1025, 443);
this.entryListBox.TabIndex = 1;
this.entryListBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.entryListBox_DrawItem);
this.entryListBox.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(this.entryListBox_MeasureItem);
@@ -63,9 +65,10 @@
// createButton
//
this.createButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.createButton.Location = new System.Drawing.Point(644, 458);
+ this.createButton.Location = new System.Drawing.Point(859, 572);
+ this.createButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.createButton.Name = "createButton";
- this.createButton.Size = new System.Drawing.Size(144, 40);
+ this.createButton.Size = new System.Drawing.Size(192, 50);
this.createButton.TabIndex = 2;
this.createButton.Text = "Create Shortcut";
this.createButton.UseVisualStyleBackColor = true;
@@ -73,9 +76,10 @@
// appUserModelIdLabel
//
this.appUserModelIdLabel.AutoSize = true;
- this.appUserModelIdLabel.Location = new System.Drawing.Point(14, 12);
+ this.appUserModelIdLabel.Location = new System.Drawing.Point(19, 15);
+ this.appUserModelIdLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.appUserModelIdLabel.Name = "appUserModelIdLabel";
- this.appUserModelIdLabel.Size = new System.Drawing.Size(213, 20);
+ this.appUserModelIdLabel.Size = new System.Drawing.Size(284, 25);
this.appUserModelIdLabel.TabIndex = 3;
this.appUserModelIdLabel.Text = "Shortcut App User Model ID:";
//
@@ -83,9 +87,10 @@
//
this.appUserModelIdBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.appUserModelIdBox.Location = new System.Drawing.Point(16, 35);
+ this.appUserModelIdBox.Location = new System.Drawing.Point(21, 44);
+ this.appUserModelIdBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.appUserModelIdBox.Name = "appUserModelIdBox";
- this.appUserModelIdBox.Size = new System.Drawing.Size(608, 26);
+ this.appUserModelIdBox.Size = new System.Drawing.Size(809, 31);
this.appUserModelIdBox.TabIndex = 4;
this.appUserModelIdBox.WaterMarkColor = System.Drawing.Color.Gray;
this.appUserModelIdBox.WaterMarkText = "Enter a manual ID, or select on from a UWP App or open Window";
@@ -93,9 +98,10 @@
// appButton
//
this.appButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.appButton.Location = new System.Drawing.Point(633, 35);
+ this.appButton.Location = new System.Drawing.Point(844, 44);
+ this.appButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.appButton.Name = "appButton";
- this.appButton.Size = new System.Drawing.Size(74, 31);
+ this.appButton.Size = new System.Drawing.Size(99, 39);
this.appButton.TabIndex = 5;
this.appButton.Text = "APP";
this.appButton.UseVisualStyleBackColor = true;
@@ -104,10 +110,11 @@
// hwndButton
//
this.hwndButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.hwndButton.Location = new System.Drawing.Point(712, 35);
- this.hwndButton.MinimumSize = new System.Drawing.Size(76, 26);
+ this.hwndButton.Location = new System.Drawing.Point(949, 44);
+ this.hwndButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+ this.hwndButton.MinimumSize = new System.Drawing.Size(101, 32);
this.hwndButton.Name = "hwndButton";
- this.hwndButton.Size = new System.Drawing.Size(76, 31);
+ this.hwndButton.Size = new System.Drawing.Size(101, 39);
this.hwndButton.TabIndex = 6;
this.hwndButton.Text = "HWND";
this.hwndButton.UseVisualStyleBackColor = true;
@@ -116,9 +123,9 @@
// MainForm
//
this.AcceptButton = this.createButton;
- this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 508);
+ this.ClientSize = new System.Drawing.Size(1067, 635);
this.Controls.Add(this.hwndButton);
this.Controls.Add(this.appButton);
this.Controls.Add(this.appUserModelIdBox);
@@ -126,6 +133,7 @@
this.Controls.Add(this.createButton);
this.Controls.Add(this.entryListBox);
this.Controls.Add(this.defaultShortcutLabel);
+ this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "MainForm";
this.Text = "Form1";
this.ResumeLayout(false);
diff --git a/ShortcutUtil/EntryListItem.Designer.cs b/ShortcutUtil/EntryListItem.Designer.cs
new file mode 100644
index 0000000..613d017
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.Designer.cs
@@ -0,0 +1,59 @@
+namespace ShortcutUtil
+{
+ partial class EntryListItem
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.testButton = new ShortcutUtil.ListBoxButton();
+ this.SuspendLayout();
+ //
+ // testButton
+ //
+ this.testButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
+ this.testButton.Location = new System.Drawing.Point(550, 47);
+ this.testButton.Name = "testButton";
+ this.testButton.Size = new System.Drawing.Size(120, 55);
+ this.testButton.TabIndex = 0;
+ this.testButton.Text = "Test";
+ this.testButton.UseVisualStyleBackColor = true;
+ //
+ // EntryListItem
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.testButton);
+ this.Name = "EntryListItem";
+ this.Size = new System.Drawing.Size(700, 150);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private ListBoxButton testButton;
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.cs b/ShortcutUtil/EntryListItem.cs
new file mode 100644
index 0000000..6787497
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ShortcutUtil
+{
+ public partial class EntryListItem : UserControl
+ {
+ public ListBoxControl TestButton { get; private set; }
+
+ private ListBox listBox;
+ public EntryListItem(ListBox listBox)
+ {
+ InitializeComponent();
+
+ this.listBox = listBox;
+
+ TestButton = new ListBoxControl(testButton, listBox);
+ }
+
+ public void LayoutFromList()
+ {
+ if (listBox.Items.Count > 0)
+ {
+ Size = listBox.GetItemRectangle(0).Size;
+ PerformLayout();
+ }
+ }
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.resx b/ShortcutUtil/EntryListItem.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ShortcutUtil/ListBoxButton.cs b/ShortcutUtil/ListBoxButton.cs
new file mode 100644
index 0000000..46518cd
--- /dev/null
+++ b/ShortcutUtil/ListBoxButton.cs
@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ShortcutUtil
+{
+ public interface IListBoxControl
+ {
+ void Hover();
+ void Unhover();
+ }
+
+ public class ListBoxButton : Button, IListBoxControl
+ {
+ public void Hover()
+ {
+ OnMouseDown(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0));
+ }
+ public void Unhover()
+ {
+ OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0));
+ }
+ }
+
+ public class ListBoxControl where T : Control, IListBoxControl, new()
+ {
+ public T Control { get; private set; }
+ private ListBox listBox;
+
+ public int? IndexOver { get; private set; }
+
+ private MethodInfo refreshItem;
+ public ListBoxControl(T control, ListBox listBox)
+ {
+ Control = control;
+ this.listBox = listBox;
+ listBox.MouseMove += ListBoxMouseMove;
+
+ refreshItem = listBox.GetType().GetMethod("RefreshItem", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(int) }, null);
+ }
+
+ private void RefreshItem(int index)
+ {
+ listBox.BeginUpdate();
+ object item = listBox.Items[index];
+ listBox.Items.RemoveAt(index);
+ listBox.Items.Insert(index, item);
+ listBox.EndUpdate();
+ //listBox.Items[index] = item;
+ //listBox.Items[index] =
+ //if (refreshItem != null) refreshItem.Invoke(listBox, new object[] { index });
+ }
+
+ public Rectangle BoundsInList(int index)
+ {
+ Point offsetLoc = listBox.GetItemRectangle(index).Location;
+ offsetLoc.Offset(Control.Location);
+ return new Rectangle(offsetLoc, Control.Size);
+ }
+
+ private void ListBoxMouseMove(object sender, MouseEventArgs e)
+ {
+ int? nowIndexOver = null;
+ for (int i = 0; i < listBox.Items.Count; i++)
+ {
+ if (BoundsInList(i).Contains(e.X, e.Y))
+ {
+ nowIndexOver = i;
+ break;
+ }
+ }
+
+ if (nowIndexOver != IndexOver)
+ {
+ if (IndexOver.HasValue) RefreshItem(IndexOver.Value);
+ IndexOver = nowIndexOver;
+ if (IndexOver.HasValue) RefreshItem(IndexOver.Value);
+ }
+ }
+
+ public void RenderToItem(DrawItemEventArgs e)
+ {
+ using (Bitmap b = new Bitmap(Control.Size.Width, Control.Size.Height))
+ {
+ if (e.Index == IndexOver)
+ {
+ Control.Hover();
+ }
+ Control.DrawToBitmap(b, new Rectangle(new Point(), Control.Size));
+ Point offsetLoc = e.Bounds.Location;
+ offsetLoc.Offset(Control.Location);
+ e.Graphics.DrawImage(b, offsetLoc.X, offsetLoc.Y);
+ if (e.Index == IndexOver)
+ {
+ Control.Unhover();
+ }
+ }
+ }
+
+ }
+}
diff --git a/ShortcutUtil/MainForm.Designer.cs b/ShortcutUtil/MainForm.Designer.cs
index 8af74c7..d6d2006 100755
--- a/ShortcutUtil/MainForm.Designer.cs
+++ b/ShortcutUtil/MainForm.Designer.cs
@@ -40,9 +40,10 @@
// defaultShortcutLabel
//
this.defaultShortcutLabel.AutoSize = true;
- this.defaultShortcutLabel.Location = new System.Drawing.Point(14, 75);
+ this.defaultShortcutLabel.Location = new System.Drawing.Point(19, 94);
+ this.defaultShortcutLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.defaultShortcutLabel.Name = "defaultShortcutLabel";
- this.defaultShortcutLabel.Size = new System.Drawing.Size(169, 20);
+ this.defaultShortcutLabel.Size = new System.Drawing.Size(226, 25);
this.defaultShortcutLabel.TabIndex = 0;
this.defaultShortcutLabel.Text = "Select default shortcut";
//
@@ -53,9 +54,10 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.entryListBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
this.entryListBox.FormattingEnabled = true;
- this.entryListBox.Location = new System.Drawing.Point(16, 98);
+ this.entryListBox.Location = new System.Drawing.Point(21, 122);
+ this.entryListBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.entryListBox.Name = "entryListBox";
- this.entryListBox.Size = new System.Drawing.Size(770, 355);
+ this.entryListBox.Size = new System.Drawing.Size(1025, 443);
this.entryListBox.TabIndex = 1;
this.entryListBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.entryListBox_DrawItem);
this.entryListBox.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(this.entryListBox_MeasureItem);
@@ -63,9 +65,10 @@
// createButton
//
this.createButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.createButton.Location = new System.Drawing.Point(644, 458);
+ this.createButton.Location = new System.Drawing.Point(859, 572);
+ this.createButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.createButton.Name = "createButton";
- this.createButton.Size = new System.Drawing.Size(144, 40);
+ this.createButton.Size = new System.Drawing.Size(192, 50);
this.createButton.TabIndex = 2;
this.createButton.Text = "Create Shortcut";
this.createButton.UseVisualStyleBackColor = true;
@@ -73,9 +76,10 @@
// appUserModelIdLabel
//
this.appUserModelIdLabel.AutoSize = true;
- this.appUserModelIdLabel.Location = new System.Drawing.Point(14, 12);
+ this.appUserModelIdLabel.Location = new System.Drawing.Point(19, 15);
+ this.appUserModelIdLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.appUserModelIdLabel.Name = "appUserModelIdLabel";
- this.appUserModelIdLabel.Size = new System.Drawing.Size(213, 20);
+ this.appUserModelIdLabel.Size = new System.Drawing.Size(284, 25);
this.appUserModelIdLabel.TabIndex = 3;
this.appUserModelIdLabel.Text = "Shortcut App User Model ID:";
//
@@ -83,9 +87,10 @@
//
this.appUserModelIdBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.appUserModelIdBox.Location = new System.Drawing.Point(16, 35);
+ this.appUserModelIdBox.Location = new System.Drawing.Point(21, 44);
+ this.appUserModelIdBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.appUserModelIdBox.Name = "appUserModelIdBox";
- this.appUserModelIdBox.Size = new System.Drawing.Size(608, 26);
+ this.appUserModelIdBox.Size = new System.Drawing.Size(809, 31);
this.appUserModelIdBox.TabIndex = 4;
this.appUserModelIdBox.WaterMarkColor = System.Drawing.Color.Gray;
this.appUserModelIdBox.WaterMarkText = "Enter a manual ID, or select on from a UWP App or open Window";
@@ -93,9 +98,10 @@
// appButton
//
this.appButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.appButton.Location = new System.Drawing.Point(633, 35);
+ this.appButton.Location = new System.Drawing.Point(844, 44);
+ this.appButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.appButton.Name = "appButton";
- this.appButton.Size = new System.Drawing.Size(74, 31);
+ this.appButton.Size = new System.Drawing.Size(99, 39);
this.appButton.TabIndex = 5;
this.appButton.Text = "APP";
this.appButton.UseVisualStyleBackColor = true;
@@ -104,10 +110,11 @@
// hwndButton
//
this.hwndButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.hwndButton.Location = new System.Drawing.Point(712, 35);
- this.hwndButton.MinimumSize = new System.Drawing.Size(76, 26);
+ this.hwndButton.Location = new System.Drawing.Point(949, 44);
+ this.hwndButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+ this.hwndButton.MinimumSize = new System.Drawing.Size(101, 32);
this.hwndButton.Name = "hwndButton";
- this.hwndButton.Size = new System.Drawing.Size(76, 31);
+ this.hwndButton.Size = new System.Drawing.Size(101, 39);
this.hwndButton.TabIndex = 6;
this.hwndButton.Text = "HWND";
this.hwndButton.UseVisualStyleBackColor = true;
@@ -116,9 +123,9 @@
// MainForm
//
this.AcceptButton = this.createButton;
- this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 508);
+ this.ClientSize = new System.Drawing.Size(1067, 635);
this.Controls.Add(this.hwndButton);
this.Controls.Add(this.appButton);
this.Controls.Add(this.appUserModelIdBox);
@@ -126,6 +133,7 @@
this.Controls.Add(this.createButton);
this.Controls.Add(this.entryListBox);
this.Controls.Add(this.defaultShortcutLabel);
+ this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "MainForm";
this.Text = "Form1";
this.ResumeLayout(false);
diff --git a/ShortcutUtil/MainForm.cs b/ShortcutUtil/MainForm.cs
index c654b19..ccd2997 100755
--- a/ShortcutUtil/MainForm.cs
+++ b/ShortcutUtil/MainForm.cs
@@ -7,6 +7,7 @@
using System.Data;
using System.Drawing;
using System.Linq;
+using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@@ -27,10 +28,18 @@
private AppResolver appResolver;
+ private EntryListItem listLayout;
+
public MainForm(EntryList entryList, AppResolver appResolver)
{
InitializeComponent();
+ typeof(ListBox).InvokeMember("DoubleBuffered",
+ BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
+ null, entryListBox, new object[] { true });
+
+ DoubleBuffered = true;
+
Text = entryList.FilePath == null ? "New shortcut file" : entryList.FilePath;
defaultFont = defaultShortcutLabel.Font;
@@ -46,6 +55,10 @@
{
entryListBox.SelectedIndex = 0;
}
+
+
+
+ listLayout = new EntryListItem(entryListBox);
}
private Dictionary, Icon> iconsByFileIndex = new Dictionary, Icon>();
@@ -62,27 +75,31 @@
try
{
icon = new Icon(file, preferred);
-
- if (icon != null)
- {
- iconsByFileIndex.Add(key, icon);
- return icon;
- }
- } catch (Exception) { }
-
- try
+ }
+ catch (Exception)
{
- icon = IconExtractor.Extract(file, index, true);
- if (icon != null)
+ icon = null;
+ }
+ if (icon == null)
+ {
+ try
{
- iconsByFileIndex.Add(key, icon);
- return icon;
+ icon = IconExtractor.Extract(file, index, true);
+ }
+ catch (Exception)
+ {
+ icon = null;
}
}
- catch (Exception) { }
- MessageBox.Show("Couldn't load icon " + index + " from " + file);
- return null;
+ iconsByFileIndex.Add(key, icon);
+
+ /*
+ if (icon == null)
+ {
+ MessageBox.Show("Couldn't load icon " + index + " from " + file);
+ }
+ */
}
return iconsByFileIndex[key];
@@ -96,6 +113,8 @@
e.DrawBackground();
e.DrawFocusRectangle();
+ listLayout.LayoutFromList();
+
if (e.Index >= 0 && e.Index < entryList.Entries.Count)
{
Rectangle iconBounds = new Rectangle(Point.Add(e.Bounds.Location, ItemPadding), IconSize);
@@ -103,7 +122,12 @@
Size textSize = new Size(0, nameFont.Height + 2);
Entry entry = entryList.Entries[e.Index];
- e.Graphics.DrawIcon(GetIcon(entry.Icon, entry.IconIndex, IconSize), iconBounds);
+
+ Icon icon = GetIcon(entry.Icon, entry.IconIndex, IconSize);
+ if (icon != null)
+ {
+ e.Graphics.DrawIcon(icon, iconBounds);
+ }
PointF textLocation = PointF.Add(e.Bounds.Location, new Size(IconSize.Width + ItemPadding.Width * 2, ItemPadding.Width));
@@ -115,12 +139,19 @@
e.Graphics.DrawString(entry.Description, defaultFont, fontBrush, textLocation);
textLocation = PointF.Add(textLocation, textSize);
+
+ listLayout.TestButton.RenderToItem(e);
}
}
private void entryListBox_MeasureItem(object sender, MeasureItemEventArgs e)
{
- e.ItemHeight = Size.Add(IconSize, new Size(0, ItemPadding.Height * 2)).Height;
+ e.ItemHeight = GetItemSize().Height;
+ }
+
+ public Size GetItemSize()
+ {
+ return Size.Add(IconSize, new Size(0, ItemPadding.Height * 2));
}
private SearchForm search = new SearchForm();
diff --git a/ShortcutUtil/EntryListItem.Designer.cs b/ShortcutUtil/EntryListItem.Designer.cs
new file mode 100644
index 0000000..613d017
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.Designer.cs
@@ -0,0 +1,59 @@
+namespace ShortcutUtil
+{
+ partial class EntryListItem
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.testButton = new ShortcutUtil.ListBoxButton();
+ this.SuspendLayout();
+ //
+ // testButton
+ //
+ this.testButton.Anchor = System.Windows.Forms.AnchorStyles.Right;
+ this.testButton.Location = new System.Drawing.Point(550, 47);
+ this.testButton.Name = "testButton";
+ this.testButton.Size = new System.Drawing.Size(120, 55);
+ this.testButton.TabIndex = 0;
+ this.testButton.Text = "Test";
+ this.testButton.UseVisualStyleBackColor = true;
+ //
+ // EntryListItem
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.testButton);
+ this.Name = "EntryListItem";
+ this.Size = new System.Drawing.Size(700, 150);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private ListBoxButton testButton;
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.cs b/ShortcutUtil/EntryListItem.cs
new file mode 100644
index 0000000..6787497
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ShortcutUtil
+{
+ public partial class EntryListItem : UserControl
+ {
+ public ListBoxControl TestButton { get; private set; }
+
+ private ListBox listBox;
+ public EntryListItem(ListBox listBox)
+ {
+ InitializeComponent();
+
+ this.listBox = listBox;
+
+ TestButton = new ListBoxControl(testButton, listBox);
+ }
+
+ public void LayoutFromList()
+ {
+ if (listBox.Items.Count > 0)
+ {
+ Size = listBox.GetItemRectangle(0).Size;
+ PerformLayout();
+ }
+ }
+ }
+}
diff --git a/ShortcutUtil/EntryListItem.resx b/ShortcutUtil/EntryListItem.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/ShortcutUtil/EntryListItem.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ShortcutUtil/ListBoxButton.cs b/ShortcutUtil/ListBoxButton.cs
new file mode 100644
index 0000000..46518cd
--- /dev/null
+++ b/ShortcutUtil/ListBoxButton.cs
@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ShortcutUtil
+{
+ public interface IListBoxControl
+ {
+ void Hover();
+ void Unhover();
+ }
+
+ public class ListBoxButton : Button, IListBoxControl
+ {
+ public void Hover()
+ {
+ OnMouseDown(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0));
+ }
+ public void Unhover()
+ {
+ OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0));
+ }
+ }
+
+ public class ListBoxControl where T : Control, IListBoxControl, new()
+ {
+ public T Control { get; private set; }
+ private ListBox listBox;
+
+ public int? IndexOver { get; private set; }
+
+ private MethodInfo refreshItem;
+ public ListBoxControl(T control, ListBox listBox)
+ {
+ Control = control;
+ this.listBox = listBox;
+ listBox.MouseMove += ListBoxMouseMove;
+
+ refreshItem = listBox.GetType().GetMethod("RefreshItem", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(int) }, null);
+ }
+
+ private void RefreshItem(int index)
+ {
+ listBox.BeginUpdate();
+ object item = listBox.Items[index];
+ listBox.Items.RemoveAt(index);
+ listBox.Items.Insert(index, item);
+ listBox.EndUpdate();
+ //listBox.Items[index] = item;
+ //listBox.Items[index] =
+ //if (refreshItem != null) refreshItem.Invoke(listBox, new object[] { index });
+ }
+
+ public Rectangle BoundsInList(int index)
+ {
+ Point offsetLoc = listBox.GetItemRectangle(index).Location;
+ offsetLoc.Offset(Control.Location);
+ return new Rectangle(offsetLoc, Control.Size);
+ }
+
+ private void ListBoxMouseMove(object sender, MouseEventArgs e)
+ {
+ int? nowIndexOver = null;
+ for (int i = 0; i < listBox.Items.Count; i++)
+ {
+ if (BoundsInList(i).Contains(e.X, e.Y))
+ {
+ nowIndexOver = i;
+ break;
+ }
+ }
+
+ if (nowIndexOver != IndexOver)
+ {
+ if (IndexOver.HasValue) RefreshItem(IndexOver.Value);
+ IndexOver = nowIndexOver;
+ if (IndexOver.HasValue) RefreshItem(IndexOver.Value);
+ }
+ }
+
+ public void RenderToItem(DrawItemEventArgs e)
+ {
+ using (Bitmap b = new Bitmap(Control.Size.Width, Control.Size.Height))
+ {
+ if (e.Index == IndexOver)
+ {
+ Control.Hover();
+ }
+ Control.DrawToBitmap(b, new Rectangle(new Point(), Control.Size));
+ Point offsetLoc = e.Bounds.Location;
+ offsetLoc.Offset(Control.Location);
+ e.Graphics.DrawImage(b, offsetLoc.X, offsetLoc.Y);
+ if (e.Index == IndexOver)
+ {
+ Control.Unhover();
+ }
+ }
+ }
+
+ }
+}
diff --git a/ShortcutUtil/MainForm.Designer.cs b/ShortcutUtil/MainForm.Designer.cs
index 8af74c7..d6d2006 100755
--- a/ShortcutUtil/MainForm.Designer.cs
+++ b/ShortcutUtil/MainForm.Designer.cs
@@ -40,9 +40,10 @@
// defaultShortcutLabel
//
this.defaultShortcutLabel.AutoSize = true;
- this.defaultShortcutLabel.Location = new System.Drawing.Point(14, 75);
+ this.defaultShortcutLabel.Location = new System.Drawing.Point(19, 94);
+ this.defaultShortcutLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.defaultShortcutLabel.Name = "defaultShortcutLabel";
- this.defaultShortcutLabel.Size = new System.Drawing.Size(169, 20);
+ this.defaultShortcutLabel.Size = new System.Drawing.Size(226, 25);
this.defaultShortcutLabel.TabIndex = 0;
this.defaultShortcutLabel.Text = "Select default shortcut";
//
@@ -53,9 +54,10 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.entryListBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
this.entryListBox.FormattingEnabled = true;
- this.entryListBox.Location = new System.Drawing.Point(16, 98);
+ this.entryListBox.Location = new System.Drawing.Point(21, 122);
+ this.entryListBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.entryListBox.Name = "entryListBox";
- this.entryListBox.Size = new System.Drawing.Size(770, 355);
+ this.entryListBox.Size = new System.Drawing.Size(1025, 443);
this.entryListBox.TabIndex = 1;
this.entryListBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.entryListBox_DrawItem);
this.entryListBox.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(this.entryListBox_MeasureItem);
@@ -63,9 +65,10 @@
// createButton
//
this.createButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.createButton.Location = new System.Drawing.Point(644, 458);
+ this.createButton.Location = new System.Drawing.Point(859, 572);
+ this.createButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.createButton.Name = "createButton";
- this.createButton.Size = new System.Drawing.Size(144, 40);
+ this.createButton.Size = new System.Drawing.Size(192, 50);
this.createButton.TabIndex = 2;
this.createButton.Text = "Create Shortcut";
this.createButton.UseVisualStyleBackColor = true;
@@ -73,9 +76,10 @@
// appUserModelIdLabel
//
this.appUserModelIdLabel.AutoSize = true;
- this.appUserModelIdLabel.Location = new System.Drawing.Point(14, 12);
+ this.appUserModelIdLabel.Location = new System.Drawing.Point(19, 15);
+ this.appUserModelIdLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.appUserModelIdLabel.Name = "appUserModelIdLabel";
- this.appUserModelIdLabel.Size = new System.Drawing.Size(213, 20);
+ this.appUserModelIdLabel.Size = new System.Drawing.Size(284, 25);
this.appUserModelIdLabel.TabIndex = 3;
this.appUserModelIdLabel.Text = "Shortcut App User Model ID:";
//
@@ -83,9 +87,10 @@
//
this.appUserModelIdBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.appUserModelIdBox.Location = new System.Drawing.Point(16, 35);
+ this.appUserModelIdBox.Location = new System.Drawing.Point(21, 44);
+ this.appUserModelIdBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.appUserModelIdBox.Name = "appUserModelIdBox";
- this.appUserModelIdBox.Size = new System.Drawing.Size(608, 26);
+ this.appUserModelIdBox.Size = new System.Drawing.Size(809, 31);
this.appUserModelIdBox.TabIndex = 4;
this.appUserModelIdBox.WaterMarkColor = System.Drawing.Color.Gray;
this.appUserModelIdBox.WaterMarkText = "Enter a manual ID, or select on from a UWP App or open Window";
@@ -93,9 +98,10 @@
// appButton
//
this.appButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.appButton.Location = new System.Drawing.Point(633, 35);
+ this.appButton.Location = new System.Drawing.Point(844, 44);
+ this.appButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.appButton.Name = "appButton";
- this.appButton.Size = new System.Drawing.Size(74, 31);
+ this.appButton.Size = new System.Drawing.Size(99, 39);
this.appButton.TabIndex = 5;
this.appButton.Text = "APP";
this.appButton.UseVisualStyleBackColor = true;
@@ -104,10 +110,11 @@
// hwndButton
//
this.hwndButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.hwndButton.Location = new System.Drawing.Point(712, 35);
- this.hwndButton.MinimumSize = new System.Drawing.Size(76, 26);
+ this.hwndButton.Location = new System.Drawing.Point(949, 44);
+ this.hwndButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+ this.hwndButton.MinimumSize = new System.Drawing.Size(101, 32);
this.hwndButton.Name = "hwndButton";
- this.hwndButton.Size = new System.Drawing.Size(76, 31);
+ this.hwndButton.Size = new System.Drawing.Size(101, 39);
this.hwndButton.TabIndex = 6;
this.hwndButton.Text = "HWND";
this.hwndButton.UseVisualStyleBackColor = true;
@@ -116,9 +123,9 @@
// MainForm
//
this.AcceptButton = this.createButton;
- this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 508);
+ this.ClientSize = new System.Drawing.Size(1067, 635);
this.Controls.Add(this.hwndButton);
this.Controls.Add(this.appButton);
this.Controls.Add(this.appUserModelIdBox);
@@ -126,6 +133,7 @@
this.Controls.Add(this.createButton);
this.Controls.Add(this.entryListBox);
this.Controls.Add(this.defaultShortcutLabel);
+ this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "MainForm";
this.Text = "Form1";
this.ResumeLayout(false);
diff --git a/ShortcutUtil/MainForm.cs b/ShortcutUtil/MainForm.cs
index c654b19..ccd2997 100755
--- a/ShortcutUtil/MainForm.cs
+++ b/ShortcutUtil/MainForm.cs
@@ -7,6 +7,7 @@
using System.Data;
using System.Drawing;
using System.Linq;
+using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@@ -27,10 +28,18 @@
private AppResolver appResolver;
+ private EntryListItem listLayout;
+
public MainForm(EntryList entryList, AppResolver appResolver)
{
InitializeComponent();
+ typeof(ListBox).InvokeMember("DoubleBuffered",
+ BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
+ null, entryListBox, new object[] { true });
+
+ DoubleBuffered = true;
+
Text = entryList.FilePath == null ? "New shortcut file" : entryList.FilePath;
defaultFont = defaultShortcutLabel.Font;
@@ -46,6 +55,10 @@
{
entryListBox.SelectedIndex = 0;
}
+
+
+
+ listLayout = new EntryListItem(entryListBox);
}
private Dictionary, Icon> iconsByFileIndex = new Dictionary, Icon>();
@@ -62,27 +75,31 @@
try
{
icon = new Icon(file, preferred);
-
- if (icon != null)
- {
- iconsByFileIndex.Add(key, icon);
- return icon;
- }
- } catch (Exception) { }
-
- try
+ }
+ catch (Exception)
{
- icon = IconExtractor.Extract(file, index, true);
- if (icon != null)
+ icon = null;
+ }
+ if (icon == null)
+ {
+ try
{
- iconsByFileIndex.Add(key, icon);
- return icon;
+ icon = IconExtractor.Extract(file, index, true);
+ }
+ catch (Exception)
+ {
+ icon = null;
}
}
- catch (Exception) { }
- MessageBox.Show("Couldn't load icon " + index + " from " + file);
- return null;
+ iconsByFileIndex.Add(key, icon);
+
+ /*
+ if (icon == null)
+ {
+ MessageBox.Show("Couldn't load icon " + index + " from " + file);
+ }
+ */
}
return iconsByFileIndex[key];
@@ -96,6 +113,8 @@
e.DrawBackground();
e.DrawFocusRectangle();
+ listLayout.LayoutFromList();
+
if (e.Index >= 0 && e.Index < entryList.Entries.Count)
{
Rectangle iconBounds = new Rectangle(Point.Add(e.Bounds.Location, ItemPadding), IconSize);
@@ -103,7 +122,12 @@
Size textSize = new Size(0, nameFont.Height + 2);
Entry entry = entryList.Entries[e.Index];
- e.Graphics.DrawIcon(GetIcon(entry.Icon, entry.IconIndex, IconSize), iconBounds);
+
+ Icon icon = GetIcon(entry.Icon, entry.IconIndex, IconSize);
+ if (icon != null)
+ {
+ e.Graphics.DrawIcon(icon, iconBounds);
+ }
PointF textLocation = PointF.Add(e.Bounds.Location, new Size(IconSize.Width + ItemPadding.Width * 2, ItemPadding.Width));
@@ -115,12 +139,19 @@
e.Graphics.DrawString(entry.Description, defaultFont, fontBrush, textLocation);
textLocation = PointF.Add(textLocation, textSize);
+
+ listLayout.TestButton.RenderToItem(e);
}
}
private void entryListBox_MeasureItem(object sender, MeasureItemEventArgs e)
{
- e.ItemHeight = Size.Add(IconSize, new Size(0, ItemPadding.Height * 2)).Height;
+ e.ItemHeight = GetItemSize().Height;
+ }
+
+ public Size GetItemSize()
+ {
+ return Size.Add(IconSize, new Size(0, ItemPadding.Height * 2));
}
private SearchForm search = new SearchForm();
diff --git a/ShortcutUtil/ShortcutUtil.csproj b/ShortcutUtil/ShortcutUtil.csproj
index 3428eaa..4dcb31a 100755
--- a/ShortcutUtil/ShortcutUtil.csproj
+++ b/ShortcutUtil/ShortcutUtil.csproj
@@ -116,7 +116,16 @@
NativeHelpers.cs
+
+ UserControl
+
+
+ EntryListItem.cs
+
+
+ Component
+
Form
@@ -135,6 +144,9 @@
Component
+
+ EntryListItem.cs
+
MainForm.cs