diff --git a/AppxPackage/ManifestReader.cs b/AppxPackage/ManifestReader.cs index e649481..e42ac83 100644 --- a/AppxPackage/ManifestReader.cs +++ b/AppxPackage/ManifestReader.cs @@ -857,6 +857,7 @@ namespace AppxPackage private bool m_usePRI = false; private bool m_enablePRI = false; private PriReader m_pri = null; + public PriReader PriFile => m_pri; public IntPtr Instance => m_hReader; public string FileRoot{ get { return Path.GetDirectoryName (m_filePath); } } private void InitPri () diff --git a/AppxPackage/PriFileNative.cs b/AppxPackage/PriFileNative.cs index 6f25d1a..09fe3b3 100644 --- a/AppxPackage/PriFileNative.cs +++ b/AppxPackage/PriFileNative.cs @@ -66,6 +66,108 @@ namespace AppxPackage PriFormatFreeString (ptr); // 如果 DLL 返回的内存要求 free return s; } + [StructLayout (LayoutKind.Sequential)] + internal struct DWORDWSTRPAIR + { + public uint dwKey; + public IntPtr lpValue; // LPWSTR + } + [StructLayout (LayoutKind.Sequential)] + internal struct DWSPAIRLIST + { + public uint dwLength; + public DWORDWSTRPAIR lpArray; // 第一个元素(柔性数组起点) + } + [StructLayout (LayoutKind.Sequential)] + internal struct WSDSPAIR + { + public IntPtr lpKey; // LPWSTR + public IntPtr lpValue; // HDWSPAIRLIST + } + [StructLayout (LayoutKind.Sequential)] + internal struct WSDSPAIRLIST + { + public uint dwLength; + public WSDSPAIR lpArray; // 第一个元素 + } + [DllImport (DLL, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr GetPriResourceAllValueList (PCSPRIFILE pFilePri, [MarshalAs (UnmanagedType.LPWStr)] string resName); + [DllImport (DLL, CallingConvention = CallingConvention.Cdecl)] + public static extern void DestroyPriResourceAllValueList (IntPtr list); + [DllImport (DLL, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr GetPriResourcesAllValuesList (PCSPRIFILE pFilePri, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string [] lpResNames, uint dwCount); + [DllImport (DLL, CallingConvention = CallingConvention.Cdecl)] + public static extern void DestroyResourcesAllValuesList (IntPtr list); + public static Dictionary ParseDWSPAIRLIST (IntPtr ptr) + { + if (ptr == IntPtr.Zero) + return null; + + var result = new Dictionary (); + + // 读取数量 + uint count = (uint)Marshal.ReadInt32 (ptr); + + // 跳过 dwLength + IntPtr pFirst = IntPtr.Add (ptr, sizeof (uint)); + + int elementSize = Marshal.SizeOf (typeof (DWORDWSTRPAIR)); + + for (int i = 0; i < count; i++) + { + IntPtr pItem = IntPtr.Add (pFirst, i * elementSize); + + object boxed = + Marshal.PtrToStructure (pItem, typeof (DWORDWSTRPAIR)); + + DWORDWSTRPAIR item = (DWORDWSTRPAIR)boxed; + + string value = null; + + if (item.lpValue != IntPtr.Zero) + value = Marshal.PtrToStringUni (item.lpValue); + + result [item.dwKey] = value; + } + + return result; + } + public static Dictionary> ParseWSDSPAIRLIST (IntPtr ptr) + { + if (ptr == IntPtr.Zero) + return null; + + var result = + new Dictionary> (); + + uint count = (uint)Marshal.ReadInt32 (ptr); + + IntPtr pFirst = IntPtr.Add (ptr, sizeof (uint)); + + int elementSize = Marshal.SizeOf (typeof (WSDSPAIR)); + + for (int i = 0; i < count; i++) + { + IntPtr pItem = IntPtr.Add (pFirst, i * elementSize); + + object boxed = + Marshal.PtrToStructure (pItem, typeof (WSDSPAIR)); + + WSDSPAIR item = (WSDSPAIR)boxed; + + string key = null; + + if (item.lpKey != IntPtr.Zero) + key = Marshal.PtrToStringUni (item.lpKey); + + Dictionary valueDict = + ParseDWSPAIRLIST (item.lpValue); + + result [key] = valueDict; + } + + return result; + } } public static class LpcwstrListHelper { diff --git a/AppxPackage/PriReader.cs b/AppxPackage/PriReader.cs index 640b8df..6bb09f2 100644 --- a/AppxPackage/PriReader.cs +++ b/AppxPackage/PriReader.cs @@ -9,6 +9,51 @@ using System.Threading.Tasks; namespace AppxPackage { + public struct PriResourceKey + { + public enum PriResourceType: byte + { + Scale = 0, + TargetSize = 1, + String = 2 + } + public enum PriContrast: byte + { + None = 0, + White = 1, + Black = 2, + High = 3, + Low = 4 + } + public readonly PriResourceType Type; + public readonly PriContrast Contrast; + public readonly ushort Value; + public uint Raw { get; } + public PriResourceKey (uint raw) + { + Raw = raw; + Type = (PriResourceType)((raw >> 28) & 0xF); + Contrast = (PriContrast)((raw >> 24) & 0xF); + Value = (ushort)(raw & 0xFFFF); + } + public bool IsScale => Type == PriResourceType.Scale; + public bool IsTargetSize => Type == PriResourceType.TargetSize; + public bool IsString => Type == PriResourceType.String; + public override string ToString () + { + switch (Type) + { + case PriResourceType.Scale: + return $"Scale={Value}, Contrast={Contrast}"; + case PriResourceType.TargetSize: + return $"TargetSize={Value}, Contrast={Contrast}"; + case PriResourceType.String: + return $"LCID=0x{Value:X4}"; + default: + return $"Unknown(0x{Raw:X8})"; + } + } + } public class PriReader: IDisposable { private IntPtr m_hPriFile = IntPtr.Zero; @@ -60,7 +105,7 @@ namespace AppxPackage public PriReader (IntPtr pStream) { Create (pStream); } public PriReader ([MarshalAs (UnmanagedType.LPWStr)] string fileName) { Create (fileName); } public PriReader () { } - public void AddSearch (IEnumerable arr) + public void AddSearch (IEnumerable arr) { IntPtr buf = IntPtr.Zero; try @@ -102,9 +147,98 @@ namespace AppxPackage } public static string LastError { get { return PriFileHelper.PriFileGetLastError (); } } public string Path (string resName) { return Resource (resName); } - public Dictionary Paths (IEnumerable resNames) { return Resources (resNames); } + public Dictionary Paths (IEnumerable resNames) { return Resources (resNames); } public string String (string resName) { return Resource (resName); } - public Dictionary Strings (IEnumerable resNames) { return Resources (resNames); } + public Dictionary Strings (IEnumerable resNames) { return Resources (resNames); } + public Dictionary ResourceAllValues (string resName) + { + var task = Task.Factory.StartNew (() => { + IntPtr ptr = IntPtr.Zero; + + try + { + ptr = PriFileHelper.GetPriResourceAllValueList ( + m_hPriFile, resName); + + if (ptr == IntPtr.Zero) + return new Dictionary (); + + var raw = + PriFileHelper.ParseDWSPAIRLIST (ptr); + + var result = + new Dictionary (); + + foreach (var kv in raw) + { + var key = new PriResourceKey (kv.Key); + result [key] = kv.Value; + } + return result; + } + finally + { + if (ptr != IntPtr.Zero) PriFileHelper.DestroyPriResourceAllValueList (ptr); + } + }); + return task.Result; + } + public Dictionary> ResourcesAllValues (IEnumerable resNames) + { + var task = Task.Factory.StartNew (() => { + IntPtr ptr = IntPtr.Zero; + + try + { + var list = resNames?.ToList (); + + if (list == null || list.Count == 0) + return new Dictionary> (); + + ptr = PriFileHelper.GetPriResourcesAllValuesList ( + m_hPriFile, + list.ToArray (), + (uint)list.Count); + + if (ptr == IntPtr.Zero) + return new Dictionary> (); + + var raw = + PriFileHelper.ParseWSDSPAIRLIST (ptr); + + var result = + new Dictionary> (); + + foreach (var outer in raw) + { + var innerDict = + new Dictionary (); + + foreach (var inner in outer.Value) + { + var key = + new PriResourceKey (inner.Key); + + innerDict [key] = inner.Value; + } + + result [outer.Key] = innerDict; + } + + return result; + } + finally + { + if (ptr != IntPtr.Zero) + PriFileHelper.DestroyResourcesAllValuesList (ptr); + } + }); + + return task.Result; + } } public class PriReaderBundle: IDisposable { @@ -246,6 +380,7 @@ namespace AppxPackage { return Resources (resNames); } + public void Dispose () { foreach (PriInst it in _priFiles) it.Reader.Dispose (); diff --git a/Bridge/SysInit.cs b/Bridge/SysInit.cs index 2e94518..311816a 100644 --- a/Bridge/SysInit.cs +++ b/Bridge/SysInit.cs @@ -1,14 +1,10 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using Win32; using DataUtils; using System.IO; using System.Runtime.InteropServices; using System.Reflection; using System.Windows.Forms; -using System.Drawing; using Newtonsoft.Json; using AppxPackage; using ModernNotice; @@ -898,6 +894,7 @@ namespace Bridge public _I_Taskbar Taskbar { get; private set; } = null; public _I_System System => system; public _I_Notice Notice => new _I_Notice (); + public _I_Process Process => proc; public string CmdArgs { get diff --git a/DataUtils/ResourceXml.cs b/DataUtils/ResourceXml.cs index d8e140a..ac307f8 100644 --- a/DataUtils/ResourceXml.cs +++ b/DataUtils/ResourceXml.cs @@ -230,6 +230,7 @@ namespace DataUtils return string.Empty; } + public string GetString (string id) => Get (id); public string this [string id] { diff --git a/DataUtils/Storage.cs b/DataUtils/Storage.cs index 0cf6696..d6d4583 100644 --- a/DataUtils/Storage.cs +++ b/DataUtils/Storage.cs @@ -1,9 +1,14 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; using System.Runtime.InteropServices; using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; namespace DataUtils { @@ -257,6 +262,28 @@ namespace DataUtils string b = Utilities.NormalizeFullPath (r); return string.Equals (a, b, StringComparison.OrdinalIgnoreCase); } + public bool Open (string path) + { + if (string.IsNullOrEmpty (path)) return false; + try + { + if (File.Exists (path)) + { + Process.Start (path); + return true; + } + + if (Directory.Exists (path)) + { + Process.Start ("explorer.exe", path); + return true; + } + } + catch + { + } + return false; + } } // Basic entry object [ComVisible (true)] @@ -476,13 +503,183 @@ namespace DataUtils } [ComVisible (true)] [ClassInterface (ClassInterfaceType.AutoDual)] + public class _I_Explorer + { + [DllImport ("user32.dll")] + private static extern IntPtr GetForegroundWindow (); + class WindowWrapper: IWin32Window + { + private IntPtr _hwnd; + public WindowWrapper (IntPtr handle) { _hwnd = handle; } + public IntPtr Handle { get { return _hwnd; } } + } + private static IWin32Window GetActiveWindowOwner () + { + IntPtr hWnd = GetForegroundWindow (); + return hWnd != IntPtr.Zero ? new WindowWrapper (hWnd) : null; + } + private static void CallJS (object jsFunc, params object [] args) + { + if (jsFunc == null) return; + try + { + object [] realArgs = new object [args.Length + 1]; + realArgs [0] = jsFunc; // thisArg + Array.Copy (args, 0, realArgs, 1, args.Length); + jsFunc.GetType ().InvokeMember ( + "call", + System.Reflection.BindingFlags.InvokeMethod, + null, + jsFunc, + realArgs + ); + } + catch { } + } + public void File (string filter, string initDir, object jsCallback) + { + IWin32Window owner = GetActiveWindowOwner (); + Thread t = new Thread (() => + { + string result = string.Empty; + try + { + using (OpenFileDialog dlg = new OpenFileDialog ()) + { + dlg.Filter = filter; + dlg.InitialDirectory = string.IsNullOrEmpty (initDir) + ? Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments) + : initDir; + dlg.Multiselect = false; + if (dlg.ShowDialog (owner) == DialogResult.OK) + result = dlg.FileName; + } + } + catch { } + CallJS (jsCallback, result); + }); + t.IsBackground = true; + t.SetApartmentState (ApartmentState.STA); + t.Start (); + } + public void Files (string filter, string initDir, object jsCallback) + { + IWin32Window owner = GetActiveWindowOwner (); + Thread t = new Thread (() => + { + string result = "[]"; + try + { + using (OpenFileDialog dlg = new OpenFileDialog ()) + { + dlg.Filter = filter; + dlg.InitialDirectory = string.IsNullOrEmpty (initDir) + ? Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments) + : initDir; + dlg.Multiselect = true; + if (dlg.ShowDialog (owner) == DialogResult.OK) + result = Newtonsoft.Json.JsonConvert.SerializeObject (dlg.FileNames); + } + } + catch { } + CallJS (jsCallback, result); + }); + t.IsBackground = true; + t.SetApartmentState (ApartmentState.STA); + t.Start (); + } + public void Dir (string initDir, object jsCallback) + { + IWin32Window owner = GetActiveWindowOwner (); + Thread t = new Thread (() => + { + string result = string.Empty; + try + { + using (FolderBrowserDialog dlg = new FolderBrowserDialog ()) + { + dlg.SelectedPath = string.IsNullOrEmpty (initDir) + ? Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments) + : initDir; + if (dlg.ShowDialog (owner) == DialogResult.OK) + result = dlg.SelectedPath; + } + } + catch { } + + CallJS (jsCallback, result); + }); + t.IsBackground = true; + t.SetApartmentState (ApartmentState.STA); + t.Start (); + } + public void Dirs (string initDir, object jsCallback) + { + IWin32Window owner = GetActiveWindowOwner (); + Thread t = new Thread (() => + { + string result = "[]"; + try + { + using (var dlg = new OpenFileDialog ()) + { + // trick: 多选文件夹 + dlg.ValidateNames = false; + dlg.CheckFileExists = false; + dlg.CheckPathExists = true; + dlg.FileName = "SelectFolder"; + dlg.InitialDirectory = string.IsNullOrEmpty (initDir) + ? Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments) + : initDir; + dlg.Multiselect = true; + if (dlg.ShowDialog (owner) == DialogResult.OK) + { + var dirs = dlg.FileNames.Select (f => Path.GetDirectoryName (f)).Distinct ().ToArray (); + result = Newtonsoft.Json.JsonConvert.SerializeObject (dirs); + } + } + } + catch { } + CallJS (jsCallback, result); + }); + t.IsBackground = true; + t.SetApartmentState (ApartmentState.STA); + t.Start (); + } + } + [ComVisible (true)] + [ClassInterface (ClassInterfaceType.AutoDual)] public class _I_Storage { + private static void CallJS (object jsFunc, params object [] args) + { + if (jsFunc == null) return; + try + { + // 这里固定第一个参数为 thisArg(比如 1) + object [] realArgs = new object [args.Length + 1]; + realArgs [0] = jsFunc; // thisArg + Array.Copy (args, 0, realArgs, 1, args.Length); + + jsFunc.GetType ().InvokeMember ( + "call", + BindingFlags.InvokeMethod, + null, + jsFunc, + realArgs + ); + } + catch + { + // ignore errors in callback invocation + } + } protected _I_Path path = new _I_Path (); public _I_Path Path { get { return path; } } public _I_File GetFile (string path) { return new _I_File (path); } public _I_Directory GetDirectory (string path) { return new _I_Directory (path); } public _I_Directory GetDir (string path) { return GetDirectory (path); } + public _I_Explorer Explorer => new _I_Explorer (); } // Small shell helpers that P/Invoke for folder retrieval using CSIDL or Known Folder GUIDs internal static class ShellHelpers diff --git a/Generated/InstallerSetup.exe b/Generated/InstallerSetup.exe index 1253ec8..4f4eb5f 100644 Binary files a/Generated/InstallerSetup.exe and b/Generated/InstallerSetup.exe differ diff --git a/Launch/Launch.csproj b/Launch/Launch.csproj index bd8ba08..b9be413 100644 --- a/Launch/Launch.csproj +++ b/Launch/Launch.csproj @@ -23,7 +23,7 @@ 4 - AnyCPU + x86 pdbonly true ..\Release\ diff --git a/Manager/BridgeExt.cs b/Manager/BridgeExt.cs new file mode 100644 index 0000000..0762224 --- /dev/null +++ b/Manager/BridgeExt.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using DataUtils; +using Newtonsoft.Json; + +namespace Manager +{ + [ComVisible (true)] + [ClassInterface (ClassInterfaceType.AutoDual)] + public class BridgeExt: Bridge._I_BridgeBase + { + Form currentWnd = null; + public BridgeExt (Form wnd, IScriptBridge isc, IWebBrowserPageScale iwbps, ITaskbarProgress itp) : base (wnd, isc, iwbps, itp) + { + currentWnd = wnd; + } + private static void CallJS (object jsFunc, params object [] args) + { + if (jsFunc == null) return; + try + { + // 这里固定第一个参数为 thisArg(比如 1) + object [] realArgs = new object [args.Length + 1]; + realArgs [0] = jsFunc; // thisArg + Array.Copy (args, 0, realArgs, 1, args.Length); + + jsFunc.GetType ().InvokeMember ( + "call", + BindingFlags.InvokeMethod, + null, + jsFunc, + realArgs + ); + } + catch + { + // ignore errors in callback invocation + } + } + public Task CreateAppShortcut (string installLocation, string appUserModelId, object successCallback, object failedCallback) + { + var tcs = new TaskCompletionSource (); + var scf = new ShortcutCreateForm (); + scf.Owner = currentWnd; + scf.FormClosed += (s, e) => + { + bool success = scf.IsSuccess; + tcs.TrySetResult (success); + var data = new + { + succeeded = scf.IsSuccess, + message = scf.Message + }; + string json = JsonConvert.SerializeObject (data); + if (currentWnd.InvokeRequired) + { + currentWnd.BeginInvoke (new Action (() => + { + if (success) + CallJS (successCallback, json); + else + CallJS (failedCallback, json); + })); + } + else + { + if (success) + CallJS (successCallback, json); + else + CallJS (failedCallback, json); + } + scf.Dispose (); + }; + scf.Show (currentWnd); + scf.InitCreater (installLocation, appUserModelId); + return tcs.Task; + } + } +} diff --git a/Manager/ClassDiagram1.cd b/Manager/ClassDiagram1.cd new file mode 100644 index 0000000..7b89419 --- /dev/null +++ b/Manager/ClassDiagram1.cd @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Manager/ImageDisplay.Designer.cs b/Manager/ImageDisplay.Designer.cs new file mode 100644 index 0000000..231308f --- /dev/null +++ b/Manager/ImageDisplay.Designer.cs @@ -0,0 +1,126 @@ +namespace Manager +{ + partial class ImageDisplay + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose (bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose (); + } + base.Dispose (disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent () + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageDisplay)); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.sizeDisplay = new System.Windows.Forms.Label(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.backgroundPanel = new System.Windows.Forms.Panel(); + this.foregroundPicture = new System.Windows.Forms.PictureBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.flowLayoutPanel1.SuspendLayout(); + this.backgroundPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.foregroundPicture)).BeginInit(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 1; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.sizeDisplay, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 2; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(30, 60); + this.tableLayoutPanel1.TabIndex = 0; + // + // sizeDisplay + // + this.sizeDisplay.AutoSize = true; + this.sizeDisplay.Dock = System.Windows.Forms.DockStyle.Fill; + this.sizeDisplay.Location = new System.Drawing.Point(3, 0); + this.sizeDisplay.Name = "sizeDisplay"; + this.sizeDisplay.Size = new System.Drawing.Size(24, 15); + this.sizeDisplay.TabIndex = 0; + this.sizeDisplay.Text = "16"; + this.sizeDisplay.TextAlign = System.Drawing.ContentAlignment.BottomLeft; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("flowLayoutPanel1.BackgroundImage"))); + this.flowLayoutPanel1.Controls.Add(this.backgroundPanel); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 15); + this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(30, 45); + this.flowLayoutPanel1.TabIndex = 1; + // + // backgroundPanel + // + this.backgroundPanel.BackColor = System.Drawing.Color.Transparent; + this.backgroundPanel.Controls.Add(this.foregroundPicture); + this.backgroundPanel.Location = new System.Drawing.Point(0, 0); + this.backgroundPanel.Margin = new System.Windows.Forms.Padding(0); + this.backgroundPanel.Name = "backgroundPanel"; + this.backgroundPanel.Size = new System.Drawing.Size(24, 24); + this.backgroundPanel.TabIndex = 0; + // + // foregroundPicture + // + this.foregroundPicture.BackColor = System.Drawing.Color.Transparent; + this.foregroundPicture.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.foregroundPicture.Location = new System.Drawing.Point(3, 4); + this.foregroundPicture.Name = "foregroundPicture"; + this.foregroundPicture.Size = new System.Drawing.Size(16, 16); + this.foregroundPicture.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.foregroundPicture.TabIndex = 0; + this.foregroundPicture.TabStop = false; + // + // ImageDisplay + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.tableLayoutPanel1); + this.MinimumSize = new System.Drawing.Size(30, 0); + this.Name = "ImageDisplay"; + this.Size = new System.Drawing.Size(30, 60); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.flowLayoutPanel1.ResumeLayout(false); + this.backgroundPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.foregroundPicture)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label sizeDisplay; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.Panel backgroundPanel; + private System.Windows.Forms.PictureBox foregroundPicture; + } +} diff --git a/Manager/ImageDisplay.cs b/Manager/ImageDisplay.cs new file mode 100644 index 0000000..6c3957d --- /dev/null +++ b/Manager/ImageDisplay.cs @@ -0,0 +1,69 @@ +using System.Drawing; +using System.Windows.Forms; + +namespace Manager +{ + public partial class ImageDisplay: UserControl + { + public ImageDisplay () + { + InitializeComponent (); + IconSize = 16; + Ratio = (decimal)(8.0 / 7.0); + } + private Size iconSize = new Size (16, 16); + private decimal ratio = (decimal)(8.0 / 7.0); + private bool originImgSize = false; + public void RefreshPictureDisplay () + { + if (originImgSize) + { + var backSizeWidth = (foregroundPicture.Image?.Size.Width ?? 0) * ratio; + var backSizeHeight = (foregroundPicture.Image?.Size.Width ?? 0) * ratio; + foregroundPicture.Size = ForegroundImage.Size; + backgroundPanel.Size = new Size ((int)backSizeWidth, (int)backSizeHeight); + sizeDisplay.Text = backgroundPanel.Size.ToString (); + } + else + { + foregroundPicture.Size = new Size ( + (int)(iconSize.Width / ratio), + (int)(iconSize.Height / ratio) + ); + backgroundPanel.Size = iconSize; + } + foregroundPicture.Left = (int)((backgroundPanel.Width - foregroundPicture.Width) * 0.5); + foregroundPicture.Top = (int)((backgroundPanel.Height - foregroundPicture.Height) * 0.5); + this.Size = new Size ( + (int)(iconSize.Width * 1), + (int)((iconSize.Height + sizeDisplay.Height) * 1) + ); + } + public decimal Ratio + { + get { return ratio; } + set + { + ratio = value; + RefreshPictureDisplay (); + } + } + public int IconSize + { + get { return iconSize.Width; } + set + { + sizeDisplay.Text = value.ToString (); + iconSize = new Size (value, value); + RefreshPictureDisplay (); + } + } + public bool IsOriginPicSize + { + get { return originImgSize; } + set { originImgSize = true; RefreshPictureDisplay (); } + } + public Color BackgroundColor { get { return backgroundPanel.BackColor; } set { backgroundPanel.BackColor = value; } } + public Image ForegroundImage { get { return foregroundPicture.Image; } set { foregroundPicture.Image = value; } } + } +} diff --git a/Manager/ImageDisplay.resx b/Manager/ImageDisplay.resx new file mode 100644 index 0000000..5d765b4 --- /dev/null +++ b/Manager/ImageDisplay.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAS + dAAAEnQB3mYfeAAAAGdJREFUWEftzrENgFAQw9C//1qscv2tQBMGsEiBkF+TLvLZnqvHLMIswizCLMIs + wizCLMIswizCLOK/WfPIZYNZxMk2pG4mvS+YRTSzctlgFmEWYRZhFmEWYRZhFmEWYRZhFvHJrN0bfh7U + g5LtRRcAAAAASUVORK5CYII= + + + \ No newline at end of file diff --git a/Manager/ImageSetForm.Designer.cs b/Manager/ImageSetForm.Designer.cs new file mode 100644 index 0000000..e1cdb27 --- /dev/null +++ b/Manager/ImageSetForm.Designer.cs @@ -0,0 +1,323 @@ +namespace Manager +{ + partial class ImageSetForm + { + /// + /// 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 Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageSetForm)); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.radioButton1 = new System.Windows.Forms.RadioButton(); + this.panel1 = new System.Windows.Forms.Panel(); + this.initImgsSizeList = new System.Windows.Forms.FlowLayoutPanel(); + this.radioButton2 = new System.Windows.Forms.RadioButton(); + this.label2 = new System.Windows.Forms.Label(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.tableLayoutPanel1.SuspendLayout(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.tableLayoutPanel2.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 5; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 109F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.textBox1, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.radioButton1, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.radioButton2, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 5); + this.tableLayoutPanel1.Controls.Add(this.textBox2, 2, 5); + this.tableLayoutPanel1.Controls.Add(this.label3, 1, 6); + this.tableLayoutPanel1.Controls.Add(this.button1, 3, 5); + this.tableLayoutPanel1.Controls.Add(this.pictureBox1, 1, 7); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 1, 9); + this.tableLayoutPanel1.Controls.Add(this.label4, 3, 6); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 11; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 60F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 36F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(454, 439); + this.tableLayoutPanel1.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Fill; + this.label1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.label1.Location = new System.Drawing.Point(23, 20); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(97, 32); + this.label1.TabIndex = 0; + this.label1.Text = "Current Size"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // textBox1 + // + this.tableLayoutPanel1.SetColumnSpan(this.textBox1, 2); + this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox1.Location = new System.Drawing.Point(126, 24); + this.textBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.textBox1.Name = "textBox1"; + this.textBox1.ReadOnly = true; + this.textBox1.Size = new System.Drawing.Size(305, 27); + this.textBox1.TabIndex = 1; + // + // radioButton1 + // + this.radioButton1.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.radioButton1, 3); + this.radioButton1.Dock = System.Windows.Forms.DockStyle.Fill; + this.radioButton1.Location = new System.Drawing.Point(23, 56); + this.radioButton1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.radioButton1.Name = "radioButton1"; + this.radioButton1.Size = new System.Drawing.Size(408, 24); + this.radioButton1.TabIndex = 2; + this.radioButton1.TabStop = true; + this.radioButton1.Text = "Use Default Resources"; + this.radioButton1.UseVisualStyleBackColor = true; + this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); + // + // panel1 + // + this.tableLayoutPanel1.SetColumnSpan(this.panel1, 3); + this.panel1.Controls.Add(this.initImgsSizeList); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(23, 88); + this.panel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(408, 52); + this.panel1.TabIndex = 3; + // + // initImgsSizeList + // + this.initImgsSizeList.AutoScroll = true; + this.initImgsSizeList.Dock = System.Windows.Forms.DockStyle.Fill; + this.initImgsSizeList.Location = new System.Drawing.Point(0, 0); + this.initImgsSizeList.Margin = new System.Windows.Forms.Padding(0); + this.initImgsSizeList.Name = "initImgsSizeList"; + this.initImgsSizeList.Size = new System.Drawing.Size(408, 52); + this.initImgsSizeList.TabIndex = 0; + // + // radioButton2 + // + this.radioButton2.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.radioButton2, 3); + this.radioButton2.Dock = System.Windows.Forms.DockStyle.Fill; + this.radioButton2.Location = new System.Drawing.Point(23, 148); + this.radioButton2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.radioButton2.Name = "radioButton2"; + this.radioButton2.Size = new System.Drawing.Size(408, 24); + this.radioButton2.TabIndex = 4; + this.radioButton2.TabStop = true; + this.radioButton2.Text = "Use File"; + this.radioButton2.UseVisualStyleBackColor = true; + this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Dock = System.Windows.Forms.DockStyle.Fill; + this.label2.Location = new System.Drawing.Point(23, 176); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(97, 36); + this.label2.TabIndex = 5; + this.label2.Text = "File Path"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // textBox2 + // + this.textBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox2.Location = new System.Drawing.Point(126, 180); + this.textBox2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(196, 27); + this.textBox2.TabIndex = 6; + this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged); + // + // label3 + // + this.label3.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.label3, 2); + this.label3.Dock = System.Windows.Forms.DockStyle.Fill; + this.label3.Location = new System.Drawing.Point(23, 212); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(299, 20); + this.label3.TabIndex = 7; + this.label3.Text = "Preview"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // button1 + // + this.button1.Dock = System.Windows.Forms.DockStyle.Fill; + this.button1.Location = new System.Drawing.Point(325, 176); + this.button1.Margin = new System.Windows.Forms.Padding(0); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(109, 36); + this.button1.TabIndex = 8; + this.button1.Text = "Browse..."; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // pictureBox1 + // + this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage"))); + this.tableLayoutPanel1.SetColumnSpan(this.pictureBox1, 3); + this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBox1.Location = new System.Drawing.Point(23, 236); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(408, 129); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox1.TabIndex = 9; + this.pictureBox1.TabStop = false; + this.pictureBox1.LoadCompleted += new System.ComponentModel.AsyncCompletedEventHandler(this.pictureBox1_LoadCompleted); + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.ColumnCount = 5; + this.tableLayoutPanel1.SetColumnSpan(this.tableLayoutPanel2, 3); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 80F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 80F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel2.Controls.Add(this.button2, 1, 1); + this.tableLayoutPanel2.Controls.Add(this.button3, 3, 1); + this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel2.Location = new System.Drawing.Point(20, 379); + this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(0); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 3; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 36F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(414, 40); + this.tableLayoutPanel2.TabIndex = 10; + // + // button2 + // + this.button2.Dock = System.Windows.Forms.DockStyle.Fill; + this.button2.Location = new System.Drawing.Point(84, 2); + this.button2.Margin = new System.Windows.Forms.Padding(0); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(80, 36); + this.button2.TabIndex = 0; + this.button2.Text = "Set"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button3 + // + this.button3.Dock = System.Windows.Forms.DockStyle.Fill; + this.button3.Location = new System.Drawing.Point(248, 2); + this.button3.Margin = new System.Windows.Forms.Padding(0); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(80, 36); + this.button3.TabIndex = 1; + this.button3.Text = "Cancel"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Dock = System.Windows.Forms.DockStyle.Fill; + this.label4.Location = new System.Drawing.Point(328, 212); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(103, 20); + this.label4.TabIndex = 11; + this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // ImageSetForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(454, 439); + this.Controls.Add(this.tableLayoutPanel1); + this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.Name = "ImageSetForm"; + this.Text = "Setting Current Image"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ImageSetForm_FormClosing); + this.Load += new System.EventHandler(this.ImageSetForm_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.tableLayoutPanel2.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.RadioButton radioButton1; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.FlowLayoutPanel initImgsSizeList; + private System.Windows.Forms.RadioButton radioButton2; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Label label4; + } +} \ No newline at end of file diff --git a/Manager/ImageSetForm.cs b/Manager/ImageSetForm.cs new file mode 100644 index 0000000..697fd49 --- /dev/null +++ b/Manager/ImageSetForm.cs @@ -0,0 +1,178 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; +using Bridge; + +namespace Manager +{ + public partial class ImageSetForm: Form + { + public ImageSetForm () + { + InitializeComponent (); + Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_SETIMG_TITLE"); + label1.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_SETIMG_CURRSIZE"); + radioButton1.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_SETIMG_USEDEF"); + radioButton2.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_SETIMG_USEFILE"); + label2.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_SETIMG_FILEPATH"); + button1.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_BROWSE"); + label3.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_PREVIEW"); + button2.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_SETIMG_SET"); + button3.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_CANCEL"); + } + private Dictionary defimages = new Dictionary (); + private void RefreshDefaultImagesSettings () + { + try + { + initImgsSizeList.Controls.Clear (); + foreach (var kv in defimages) + { + RadioButton rb = new RadioButton (); + rb.Text = kv.Key.ToString (); + rb.CheckedChanged += DefaultImgsRadio_CheckedChanged; + initImgsSizeList.Controls.Add (rb); + } + } + catch { } + } + public Dictionary DefaultImages + { + get { return defimages; } + set { defimages = value; RefreshDefaultImagesSettings (); } + } + public int CurrentSize { set { textBox1.Text = value.ToString (); } } + private void RefreshImagesType () + { + initImgsSizeList.Enabled = radioButton1.Checked; + textBox2.Enabled = button1.Enabled = radioButton2.Checked; + } + private Image finalUse = null; + private void RefreshImagesPreview () + { + pictureBox1.Image = null; + try + { + if (radioButton1.Checked) + { + foreach (RadioButton ctrl in initImgsSizeList.Controls) + { + if (ctrl.Checked) + { + int value = int.Parse (ctrl.Text); + pictureBox1.Image = defimages [value]; + } + } + } + else + { + try + { + pictureBox1.Image = Image.FromFile (textBox2.Text); + } + catch { } + } + } + catch { pictureBox1.Image = null; } + finally + { + try + { + label4.Text = $"{pictureBox1.Image.Width} x {pictureBox1.Image.Height}"; + } + catch { label4.Text = ""; } + } + } + private void DefaultImgsRadio_CheckedChanged (object sender, EventArgs e) + { + RefreshImagesPreview (); + } + private void ImageSetForm_Load (object sender, EventArgs e) + { + RefreshImagesType (); + //RefreshImagesPreview (); + } + private void textBox2_TextChanged (object sender, EventArgs e) + { + RefreshImagesPreview (); + } + private void radioButton1_CheckedChanged (object sender, EventArgs e) + { + RefreshImagesType (); + RefreshImagesPreview (); + } + private void radioButton2_CheckedChanged (object sender, EventArgs e) + { + RefreshImagesType (); + RefreshImagesPreview (); + } + public Image FinalImage + { + set + { + pictureBox1.Image = value; + try + { + label4.Text = $"{pictureBox1.Image.Width} x {pictureBox1.Image.Height}"; + } + catch { label4.Text = ""; } + } + get { return finalUse; } + } + private void button3_Click (object sender, EventArgs e) + { + this.Close (); + } + private void button2_Click (object sender, EventArgs e) + { + try + { + if (radioButton1.Checked) + { + foreach (RadioButton ctrl in initImgsSizeList.Controls) + { + if (ctrl.Checked) + { + int value = int.Parse (ctrl.Text); + finalUse = defimages [value]; + } + } + } + else + { + finalUse = Image.FromFile (textBox2.Text); + } + if (finalUse == null) throw new Exception ("Error: none valid image."); + this.Close (); + } + catch (Exception ex) + { + MessageBox.Show (ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ImageSetForm_FormClosing (object sender, FormClosingEventArgs e) + { + } + private void pictureBox1_LoadCompleted (object sender, System.ComponentModel.AsyncCompletedEventArgs e) + { + label4.Text = $"{pictureBox1.Image.Width} x {pictureBox1.Image.Height}"; + } + private void button1_Click (object sender, EventArgs e) + { + using (OpenFileDialog ofd = new OpenFileDialog ()) + { + ofd.Title = "Please select the image file: "; + ofd.Filter = "Image Files (*.png;*.bmp;*.jpg;*.jpeg)|*.png;*.bmp;*.jpg;*.jpeg"; + ofd.Multiselect = false; + ofd.CheckFileExists = true; + ofd.CheckPathExists = true; + if (ofd.ShowDialog (this) == DialogResult.OK) + { + textBox2.Text = ofd.FileName; + radioButton2.Checked = true; + } + } + } + } +} diff --git a/Manager/ImageSetForm.resx b/Manager/ImageSetForm.resx new file mode 100644 index 0000000..c6e16e9 --- /dev/null +++ b/Manager/ImageSetForm.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAS + dAAAEnQB3mYfeAAAAGlJREFUWEftzrENACEQA0H6r4SG6OAKAfHXwOodEOwkzqwdlTNzzCLMIswizCLM + IswizCLMIswizCLMIjJZ6+rLhFezehO+uKNjfzCLSGb1ZYJZhFmEWYRZhFmEWYRZhFmEWYRZxJNZVRvc + pafKc4vMkgAAAABJRU5ErkJggg== + + + \ No newline at end of file diff --git a/Manager/LoadingStatusForm.Designer.cs b/Manager/LoadingStatusForm.Designer.cs new file mode 100644 index 0000000..3a96232 --- /dev/null +++ b/Manager/LoadingStatusForm.Designer.cs @@ -0,0 +1,89 @@ +namespace Manager +{ + partial class LoadingStatusForm + { + /// + /// 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 Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(241, 123); + this.tableLayoutPanel1.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Fill; + this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(55, 48); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(131, 27); + this.label1.TabIndex = 1; + this.label1.Text = "Please wait..."; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // LoadingStatusForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.ClientSize = new System.Drawing.Size(241, 123); + this.ControlBox = false; + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.MaximizeBox = false; + this.Name = "LoadingStatusForm"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Please wait..."; + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/Manager/LoadingStatusForm.cs b/Manager/LoadingStatusForm.cs new file mode 100644 index 0000000..f3a8c2a --- /dev/null +++ b/Manager/LoadingStatusForm.cs @@ -0,0 +1,19 @@ +using System.Windows.Forms; +using Bridge; + +namespace Manager +{ + public partial class LoadingStatusForm: Form + { + public LoadingStatusForm () + { + InitializeComponent (); + label1.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_LOADING"); + } + public string TipText + { + get { return label1.Text; } + set { label1.Text = value; } + } + } +} diff --git a/Manager/LoadingStatusForm.resx b/Manager/LoadingStatusForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Manager/LoadingStatusForm.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/Manager/Manager.csproj b/Manager/Manager.csproj index ee33b0c..bc90f9c 100644 --- a/Manager/Manager.csproj +++ b/Manager/Manager.csproj @@ -53,8 +53,13 @@ MinimumRecommendedRules.ruleset + + ..\packages\Newtonsoft.Json.13.0.4\lib\net40\Newtonsoft.Json.dll + True + + @@ -65,6 +70,25 @@ + + + UserControl + + + ImageDisplay.cs + + + Form + + + ImageSetForm.cs + + + Form + + + LoadingStatusForm.cs + Form @@ -74,7 +98,22 @@ - + + Form + + + ShortcutCreateForm.cs + + + + ImageDisplay.cs + + + ImageSetForm.cs + + + LoadingStatusForm.cs + ManagerShell.cs @@ -88,7 +127,12 @@ Resources.resx True + + ShortcutCreateForm.cs + + + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/Manager/ManagerShell.cs b/Manager/ManagerShell.cs index 16cef76..661db55 100644 --- a/Manager/ManagerShell.cs +++ b/Manager/ManagerShell.cs @@ -9,6 +9,7 @@ namespace Manager public ManagerShell () { InitializeComponent (); + this.PublicObjectForScripting = new BridgeExt (this, this, this, this); try { var relativePath = DataUtils.VisualElementsStore.Vemanifest.SplashScreenImage (Program.g_appId); @@ -23,6 +24,7 @@ namespace Manager } catch { } InitSize (); + Text = Bridge.ResXmlStore.StringRes.Get ("MANAGER_APPTITLE"); } private void InitSize () { diff --git a/Manager/Program.cs b/Manager/Program.cs index 2f47838..663309e 100644 --- a/Manager/Program.cs +++ b/Manager/Program.cs @@ -1,6 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; +using System.IO; using System.Windows.Forms; namespace Manager @@ -15,7 +14,13 @@ namespace Manager [STAThread] static void Main () { + Directory.SetCurrentDirectory (AppDomain.CurrentDomain.BaseDirectory); + //System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo ("en-US"); + //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo ("en-US"); AppxPackage.PackageReader.AddApplicationItem ("SmallLogo"); + AppxPackage.PackageReader.AddApplicationItem ("Square30x30Logo"); + AppxPackage.PackageReader.AddApplicationItem ("Logo"); + AppxPackage.PackageReader.AddApplicationItem ("Square44x44Logo"); DataUtils.BrowserEmulation.SetWebBrowserEmulation (); Application.EnableVisualStyles (); Application.SetCompatibleTextRenderingDefault (false); diff --git a/Manager/ShortcutCreateForm.Designer.cs b/Manager/ShortcutCreateForm.Designer.cs new file mode 100644 index 0000000..2c05a50 --- /dev/null +++ b/Manager/ShortcutCreateForm.Designer.cs @@ -0,0 +1,662 @@ +namespace Manager +{ + partial class ShortcutCreateForm + { + /// + /// 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 Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShortcutCreateForm)); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.label3 = new System.Windows.Forms.Label(); + this.iconSetGen = new System.Windows.Forms.RadioButton(); + this.iconSetFromFile = new System.Windows.Forms.RadioButton(); + this.label4 = new System.Windows.Forms.Label(); + this.iconFileInput = new System.Windows.Forms.TextBox(); + this.iconFileBrowser = new System.Windows.Forms.Button(); + this.label7 = new System.Windows.Forms.Label(); + this.customIconDisplay = new System.Windows.Forms.PictureBox(); + this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); + this.label5 = new System.Windows.Forms.Label(); + this.colorPickerButton = new System.Windows.Forms.Button(); + this.colorInputAndPreview = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.ratio8_7 = new System.Windows.Forms.RadioButton(); + this.ratio3_2 = new System.Windows.Forms.RadioButton(); + this.ratio1_1 = new System.Windows.Forms.RadioButton(); + this.ratioCustom = new System.Windows.Forms.RadioButton(); + this.label10 = new System.Windows.Forms.Label(); + this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel(); + this.ratioCustomBack = new System.Windows.Forms.TextBox(); + this.ratioCustomFore = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.shortcutNameInput = new System.Windows.Forms.TextBox(); + this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.imageSizeList = new System.Windows.Forms.DataGridView(); + this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column2 = new System.Windows.Forms.DataGridViewImageColumn(); + this.imagesPreview = new System.Windows.Forms.FlowLayoutPanel(); + this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel(); + this.buttonGen = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.tableLayoutPanel1.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.customIconDisplay)).BeginInit(); + this.tableLayoutPanel3.SuspendLayout(); + this.tableLayoutPanel6.SuspendLayout(); + this.tableLayoutPanel4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.imageSizeList)).BeginInit(); + this.tableLayoutPanel5.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 7; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 24F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 5F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 5F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 25F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.label2, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 1, 5); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 3, 5); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel4, 5, 5); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel5, 1, 7); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 9; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 24F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 10F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 24F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(782, 553); + this.tableLayoutPanel1.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.label1, 5); + this.label1.Dock = System.Windows.Forms.DockStyle.Fill; + this.label1.Font = new System.Drawing.Font("微软雅黑 Light", 20F); + this.label1.Location = new System.Drawing.Point(27, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(727, 45); + this.label1.TabIndex = 0; + this.label1.Text = "Create Desktop Shortcut"; + // + // label2 + // + this.label2.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.label2, 5); + this.label2.Dock = System.Windows.Forms.DockStyle.Fill; + this.label2.Location = new System.Drawing.Point(27, 79); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(727, 60); + this.label2.TabIndex = 1; + this.label2.Text = resources.GetString("label2.Text"); + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.ColumnCount = 2; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 103F)); + this.tableLayoutPanel2.Controls.Add(this.label3, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.iconSetGen, 0, 2); + this.tableLayoutPanel2.Controls.Add(this.iconSetFromFile, 0, 3); + this.tableLayoutPanel2.Controls.Add(this.label4, 0, 5); + this.tableLayoutPanel2.Controls.Add(this.iconFileInput, 0, 6); + this.tableLayoutPanel2.Controls.Add(this.iconFileBrowser, 1, 7); + this.tableLayoutPanel2.Controls.Add(this.label7, 0, 8); + this.tableLayoutPanel2.Controls.Add(this.customIconDisplay, 0, 9); + this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel2.Location = new System.Drawing.Point(27, 152); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 10; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 8F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 8F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 34F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 39F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 18F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 13F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(235, 324); + this.tableLayoutPanel2.TabIndex = 2; + // + // label3 + // + this.label3.AutoSize = true; + this.tableLayoutPanel2.SetColumnSpan(this.label3, 2); + this.label3.Dock = System.Windows.Forms.DockStyle.Fill; + this.label3.Location = new System.Drawing.Point(3, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(229, 40); + this.label3.TabIndex = 0; + this.label3.Text = "Please select the method for setting the icon."; + // + // iconSetGen + // + this.iconSetGen.AutoSize = true; + this.iconSetGen.Checked = true; + this.tableLayoutPanel2.SetColumnSpan(this.iconSetGen, 2); + this.iconSetGen.Dock = System.Windows.Forms.DockStyle.Fill; + this.iconSetGen.Location = new System.Drawing.Point(3, 51); + this.iconSetGen.Name = "iconSetGen"; + this.iconSetGen.Size = new System.Drawing.Size(229, 24); + this.iconSetGen.TabIndex = 1; + this.iconSetGen.TabStop = true; + this.iconSetGen.Text = "Generate an icon"; + this.iconSetGen.UseVisualStyleBackColor = true; + this.iconSetGen.CheckedChanged += new System.EventHandler(this.iconSetGen_CheckedChanged); + // + // iconSetFromFile + // + this.iconSetFromFile.AutoSize = true; + this.tableLayoutPanel2.SetColumnSpan(this.iconSetFromFile, 2); + this.iconSetFromFile.Dock = System.Windows.Forms.DockStyle.Fill; + this.iconSetFromFile.Location = new System.Drawing.Point(3, 81); + this.iconSetFromFile.Name = "iconSetFromFile"; + this.iconSetFromFile.Size = new System.Drawing.Size(229, 24); + this.iconSetFromFile.TabIndex = 2; + this.iconSetFromFile.Text = "Use existing icons"; + this.iconSetFromFile.UseVisualStyleBackColor = true; + this.iconSetFromFile.CheckedChanged += new System.EventHandler(this.iconSetFromFile_CheckedChanged); + // + // label4 + // + this.label4.AutoSize = true; + this.tableLayoutPanel2.SetColumnSpan(this.label4, 2); + this.label4.Dock = System.Windows.Forms.DockStyle.Fill; + this.label4.Location = new System.Drawing.Point(3, 116); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(229, 20); + this.label4.TabIndex = 3; + this.label4.Text = "Custom icon file path:"; + // + // iconFileInput + // + this.tableLayoutPanel2.SetColumnSpan(this.iconFileInput, 2); + this.iconFileInput.Dock = System.Windows.Forms.DockStyle.Fill; + this.iconFileInput.Location = new System.Drawing.Point(3, 139); + this.iconFileInput.Name = "iconFileInput"; + this.iconFileInput.Size = new System.Drawing.Size(229, 27); + this.iconFileInput.TabIndex = 4; + this.iconFileInput.TextChanged += new System.EventHandler(this.iconFileInput_TextChanged); + // + // iconFileBrowser + // + this.iconFileBrowser.Dock = System.Windows.Forms.DockStyle.Fill; + this.iconFileBrowser.Location = new System.Drawing.Point(135, 173); + this.iconFileBrowser.Name = "iconFileBrowser"; + this.iconFileBrowser.Size = new System.Drawing.Size(97, 33); + this.iconFileBrowser.TabIndex = 5; + this.iconFileBrowser.Text = "Browser..."; + this.iconFileBrowser.UseVisualStyleBackColor = true; + this.iconFileBrowser.Click += new System.EventHandler(this.iconFileBrowser_Click); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Dock = System.Windows.Forms.DockStyle.Fill; + this.label7.Location = new System.Drawing.Point(3, 209); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(126, 18); + this.label7.TabIndex = 6; + this.label7.Text = "Preview:"; + // + // customIconDisplay + // + this.customIconDisplay.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.tableLayoutPanel2.SetColumnSpan(this.customIconDisplay, 2); + this.customIconDisplay.Dock = System.Windows.Forms.DockStyle.Fill; + this.customIconDisplay.Location = new System.Drawing.Point(3, 230); + this.customIconDisplay.Name = "customIconDisplay"; + this.customIconDisplay.Size = new System.Drawing.Size(229, 91); + this.customIconDisplay.TabIndex = 7; + this.customIconDisplay.TabStop = false; + // + // tableLayoutPanel3 + // + this.tableLayoutPanel3.ColumnCount = 2; + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 97F)); + this.tableLayoutPanel3.Controls.Add(this.label5, 0, 0); + this.tableLayoutPanel3.Controls.Add(this.colorPickerButton, 1, 1); + this.tableLayoutPanel3.Controls.Add(this.colorInputAndPreview, 0, 1); + this.tableLayoutPanel3.Controls.Add(this.label6, 0, 2); + this.tableLayoutPanel3.Controls.Add(this.ratio8_7, 0, 3); + this.tableLayoutPanel3.Controls.Add(this.ratio3_2, 0, 4); + this.tableLayoutPanel3.Controls.Add(this.ratio1_1, 0, 5); + this.tableLayoutPanel3.Controls.Add(this.ratioCustom, 0, 6); + this.tableLayoutPanel3.Controls.Add(this.label10, 0, 7); + this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel6, 0, 8); + this.tableLayoutPanel3.Controls.Add(this.label12, 0, 9); + this.tableLayoutPanel3.Controls.Add(this.shortcutNameInput, 0, 10); + this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel3.Location = new System.Drawing.Point(273, 152); + this.tableLayoutPanel3.Name = "tableLayoutPanel3"; + this.tableLayoutPanel3.RowCount = 11; + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F)); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F)); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 18F)); + this.tableLayoutPanel3.Size = new System.Drawing.Size(235, 324); + this.tableLayoutPanel3.TabIndex = 3; + // + // label5 + // + this.label5.AutoSize = true; + this.tableLayoutPanel3.SetColumnSpan(this.label5, 2); + this.label5.Dock = System.Windows.Forms.DockStyle.Fill; + this.label5.Location = new System.Drawing.Point(3, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(229, 20); + this.label5.TabIndex = 0; + this.label5.Text = "Background Color:"; + // + // colorPickerButton + // + this.colorPickerButton.Dock = System.Windows.Forms.DockStyle.Fill; + this.colorPickerButton.Location = new System.Drawing.Point(141, 23); + this.colorPickerButton.Name = "colorPickerButton"; + this.colorPickerButton.Size = new System.Drawing.Size(91, 29); + this.colorPickerButton.TabIndex = 1; + this.colorPickerButton.Text = "Select"; + this.colorPickerButton.UseVisualStyleBackColor = true; + this.colorPickerButton.Click += new System.EventHandler(this.colorPickerButton_Click); + // + // colorInputAndPreview + // + this.colorInputAndPreview.Dock = System.Windows.Forms.DockStyle.Fill; + this.colorInputAndPreview.Location = new System.Drawing.Point(3, 23); + this.colorInputAndPreview.Name = "colorInputAndPreview"; + this.colorInputAndPreview.Size = new System.Drawing.Size(132, 27); + this.colorInputAndPreview.TabIndex = 2; + this.colorInputAndPreview.TextChanged += new System.EventHandler(this.colorInputAndPreview_TextChanged); + // + // label6 + // + this.label6.AutoSize = true; + this.tableLayoutPanel3.SetColumnSpan(this.label6, 2); + this.label6.Dock = System.Windows.Forms.DockStyle.Fill; + this.label6.Location = new System.Drawing.Point(3, 55); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(229, 40); + this.label6.TabIndex = 3; + this.label6.Text = "Background-to-foreground edge ratio"; + // + // ratio8_7 + // + this.ratio8_7.AutoSize = true; + this.ratio8_7.Checked = true; + this.tableLayoutPanel3.SetColumnSpan(this.ratio8_7, 2); + this.ratio8_7.Dock = System.Windows.Forms.DockStyle.Fill; + this.ratio8_7.Location = new System.Drawing.Point(3, 98); + this.ratio8_7.Name = "ratio8_7"; + this.ratio8_7.Size = new System.Drawing.Size(229, 24); + this.ratio8_7.TabIndex = 4; + this.ratio8_7.TabStop = true; + this.ratio8_7.Text = "8:7"; + this.ratio8_7.UseVisualStyleBackColor = true; + this.ratio8_7.CheckedChanged += new System.EventHandler(this.ratio8_7_CheckedChanged); + // + // ratio3_2 + // + this.ratio3_2.AutoSize = true; + this.tableLayoutPanel3.SetColumnSpan(this.ratio3_2, 2); + this.ratio3_2.Dock = System.Windows.Forms.DockStyle.Fill; + this.ratio3_2.Location = new System.Drawing.Point(3, 128); + this.ratio3_2.Name = "ratio3_2"; + this.ratio3_2.Size = new System.Drawing.Size(229, 24); + this.ratio3_2.TabIndex = 5; + this.ratio3_2.Text = "3:2"; + this.ratio3_2.UseVisualStyleBackColor = true; + this.ratio3_2.CheckedChanged += new System.EventHandler(this.ratio3_2_CheckedChanged); + // + // ratio1_1 + // + this.ratio1_1.AutoSize = true; + this.tableLayoutPanel3.SetColumnSpan(this.ratio1_1, 2); + this.ratio1_1.Dock = System.Windows.Forms.DockStyle.Fill; + this.ratio1_1.Location = new System.Drawing.Point(3, 158); + this.ratio1_1.Name = "ratio1_1"; + this.ratio1_1.Size = new System.Drawing.Size(229, 24); + this.ratio1_1.TabIndex = 6; + this.ratio1_1.Text = "1:1"; + this.ratio1_1.UseVisualStyleBackColor = true; + this.ratio1_1.CheckedChanged += new System.EventHandler(this.ratio1_1_CheckedChanged); + // + // ratioCustom + // + this.ratioCustom.AutoSize = true; + this.tableLayoutPanel3.SetColumnSpan(this.ratioCustom, 2); + this.ratioCustom.Dock = System.Windows.Forms.DockStyle.Fill; + this.ratioCustom.Location = new System.Drawing.Point(3, 188); + this.ratioCustom.Name = "ratioCustom"; + this.ratioCustom.Size = new System.Drawing.Size(229, 24); + this.ratioCustom.TabIndex = 7; + this.ratioCustom.Text = "Custom"; + this.ratioCustom.UseVisualStyleBackColor = true; + this.ratioCustom.CheckedChanged += new System.EventHandler(this.ratioCustom_CheckedChanged); + // + // label10 + // + this.label10.AutoSize = true; + this.tableLayoutPanel3.SetColumnSpan(this.label10, 2); + this.label10.Dock = System.Windows.Forms.DockStyle.Fill; + this.label10.Location = new System.Drawing.Point(3, 215); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(229, 20); + this.label10.TabIndex = 8; + this.label10.Text = "Custom Ratio:"; + // + // tableLayoutPanel6 + // + this.tableLayoutPanel6.ColumnCount = 3; + this.tableLayoutPanel3.SetColumnSpan(this.tableLayoutPanel6, 2); + this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel6.Controls.Add(this.ratioCustomBack, 0, 0); + this.tableLayoutPanel6.Controls.Add(this.ratioCustomFore, 2, 0); + this.tableLayoutPanel6.Controls.Add(this.label11, 1, 0); + this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel6.Location = new System.Drawing.Point(0, 235); + this.tableLayoutPanel6.Margin = new System.Windows.Forms.Padding(0); + this.tableLayoutPanel6.Name = "tableLayoutPanel6"; + this.tableLayoutPanel6.RowCount = 1; + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel6.Size = new System.Drawing.Size(235, 32); + this.tableLayoutPanel6.TabIndex = 9; + // + // ratioCustomBack + // + this.ratioCustomBack.Dock = System.Windows.Forms.DockStyle.Fill; + this.ratioCustomBack.Location = new System.Drawing.Point(3, 3); + this.ratioCustomBack.Name = "ratioCustomBack"; + this.ratioCustomBack.Size = new System.Drawing.Size(101, 27); + this.ratioCustomBack.TabIndex = 0; + this.ratioCustomBack.Text = "8"; + this.ratioCustomBack.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // ratioCustomFore + // + this.ratioCustomFore.Dock = System.Windows.Forms.DockStyle.Fill; + this.ratioCustomFore.Location = new System.Drawing.Point(130, 3); + this.ratioCustomFore.Name = "ratioCustomFore"; + this.ratioCustomFore.Size = new System.Drawing.Size(102, 27); + this.ratioCustomFore.TabIndex = 1; + this.ratioCustomFore.Text = "7"; + this.ratioCustomFore.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Dock = System.Windows.Forms.DockStyle.Fill; + this.label11.Location = new System.Drawing.Point(110, 0); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(14, 32); + this.label11.TabIndex = 2; + this.label11.Text = ":"; + this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label12 + // + this.label12.AutoSize = true; + this.tableLayoutPanel3.SetColumnSpan(this.label12, 2); + this.label12.Dock = System.Windows.Forms.DockStyle.Fill; + this.label12.Location = new System.Drawing.Point(3, 267); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(229, 20); + this.label12.TabIndex = 10; + this.label12.Text = "Shortcut Display Name"; + // + // shortcutNameInput + // + this.tableLayoutPanel3.SetColumnSpan(this.shortcutNameInput, 2); + this.shortcutNameInput.Dock = System.Windows.Forms.DockStyle.Fill; + this.shortcutNameInput.Location = new System.Drawing.Point(3, 290); + this.shortcutNameInput.Name = "shortcutNameInput"; + this.shortcutNameInput.Size = new System.Drawing.Size(229, 27); + this.shortcutNameInput.TabIndex = 11; + // + // tableLayoutPanel4 + // + this.tableLayoutPanel4.ColumnCount = 1; + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel4.Controls.Add(this.label8, 0, 0); + this.tableLayoutPanel4.Controls.Add(this.label9, 0, 2); + this.tableLayoutPanel4.Controls.Add(this.imageSizeList, 0, 1); + this.tableLayoutPanel4.Controls.Add(this.imagesPreview, 0, 3); + this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel4.Location = new System.Drawing.Point(519, 152); + this.tableLayoutPanel4.Name = "tableLayoutPanel4"; + this.tableLayoutPanel4.RowCount = 4; + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel4.Size = new System.Drawing.Size(235, 324); + this.tableLayoutPanel4.TabIndex = 4; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Dock = System.Windows.Forms.DockStyle.Fill; + this.label8.Location = new System.Drawing.Point(3, 0); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(229, 20); + this.label8.TabIndex = 0; + this.label8.Text = "Image List:"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Dock = System.Windows.Forms.DockStyle.Fill; + this.label9.Location = new System.Drawing.Point(3, 162); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(229, 20); + this.label9.TabIndex = 1; + this.label9.Text = "Preview:"; + // + // imageSizeList + // + this.imageSizeList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.imageSizeList.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Column1, + this.Column2}); + this.imageSizeList.Dock = System.Windows.Forms.DockStyle.Fill; + this.imageSizeList.Location = new System.Drawing.Point(3, 23); + this.imageSizeList.Name = "imageSizeList"; + this.imageSizeList.RowTemplate.Height = 27; + this.imageSizeList.Size = new System.Drawing.Size(229, 136); + this.imageSizeList.TabIndex = 2; + this.imageSizeList.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.imageSizeList_CellDoubleClick); + // + // Column1 + // + this.Column1.HeaderText = "Size"; + this.Column1.Name = "Column1"; + this.Column1.Width = 50; + // + // Column2 + // + this.Column2.HeaderText = "Image"; + this.Column2.Name = "Column2"; + // + // imagesPreview + // + this.imagesPreview.AutoScroll = true; + this.imagesPreview.Dock = System.Windows.Forms.DockStyle.Fill; + this.imagesPreview.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.imagesPreview.Location = new System.Drawing.Point(3, 185); + this.imagesPreview.Name = "imagesPreview"; + this.imagesPreview.Size = new System.Drawing.Size(229, 136); + this.imagesPreview.TabIndex = 3; + // + // tableLayoutPanel5 + // + this.tableLayoutPanel5.ColumnCount = 5; + this.tableLayoutPanel1.SetColumnSpan(this.tableLayoutPanel5, 5); + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 172F)); + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel5.Controls.Add(this.buttonGen, 1, 1); + this.tableLayoutPanel5.Controls.Add(this.buttonCancel, 3, 1); + this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel5.Location = new System.Drawing.Point(24, 489); + this.tableLayoutPanel5.Margin = new System.Windows.Forms.Padding(0); + this.tableLayoutPanel5.Name = "tableLayoutPanel5"; + this.tableLayoutPanel5.RowCount = 3; + this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F)); + this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel5.Size = new System.Drawing.Size(733, 40); + this.tableLayoutPanel5.TabIndex = 5; + // + // buttonGen + // + this.buttonGen.Dock = System.Windows.Forms.DockStyle.Fill; + this.buttonGen.Location = new System.Drawing.Point(180, 4); + this.buttonGen.Margin = new System.Windows.Forms.Padding(0); + this.buttonGen.Name = "buttonGen"; + this.buttonGen.Size = new System.Drawing.Size(100, 32); + this.buttonGen.TabIndex = 0; + this.buttonGen.Text = "Generate"; + this.buttonGen.UseVisualStyleBackColor = true; + this.buttonGen.Click += new System.EventHandler(this.buttonGen_Click); + // + // buttonCancel + // + this.buttonCancel.Dock = System.Windows.Forms.DockStyle.Fill; + this.buttonCancel.Location = new System.Drawing.Point(452, 4); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(0); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(100, 32); + this.buttonCancel.TabIndex = 1; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // ShortcutCreateForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(782, 553); + this.Controls.Add(this.tableLayoutPanel1); + this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.Name = "ShortcutCreateForm"; + this.Text = "ShortcutCreateForm"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ShortcutCreateForm_FormClosing); + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ShortcutCreateForm_FormClosed); + this.Load += new System.EventHandler(this.ShortcutCreateForm_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.tableLayoutPanel2.ResumeLayout(false); + this.tableLayoutPanel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.customIconDisplay)).EndInit(); + this.tableLayoutPanel3.ResumeLayout(false); + this.tableLayoutPanel3.PerformLayout(); + this.tableLayoutPanel6.ResumeLayout(false); + this.tableLayoutPanel6.PerformLayout(); + this.tableLayoutPanel4.ResumeLayout(false); + this.tableLayoutPanel4.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.imageSizeList)).EndInit(); + this.tableLayoutPanel5.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.RadioButton iconSetGen; + private System.Windows.Forms.RadioButton iconSetFromFile; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox iconFileInput; + private System.Windows.Forms.Button iconFileBrowser; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.PictureBox customIconDisplay; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Button colorPickerButton; + private System.Windows.Forms.TextBox colorInputAndPreview; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.RadioButton ratio8_7; + private System.Windows.Forms.RadioButton ratio3_2; + private System.Windows.Forms.RadioButton ratio1_1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.RadioButton ratioCustom; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel6; + private System.Windows.Forms.TextBox ratioCustomBack; + private System.Windows.Forms.TextBox ratioCustomFore; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.DataGridView imageSizeList; + private System.Windows.Forms.DataGridViewTextBoxColumn Column1; + private System.Windows.Forms.DataGridViewImageColumn Column2; + private System.Windows.Forms.FlowLayoutPanel imagesPreview; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel5; + private System.Windows.Forms.Button buttonGen; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.TextBox shortcutNameInput; + } +} \ No newline at end of file diff --git a/Manager/ShortcutCreateForm.cs b/Manager/ShortcutCreateForm.cs index 3cf2412..6131794 100644 --- a/Manager/ShortcutCreateForm.cs +++ b/Manager/ShortcutCreateForm.cs @@ -1,11 +1,571 @@ using System; using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.IO; using System.Linq; -using System.Text; - +using System.Threading.Tasks; +using System.Windows.Forms; +using Bridge; namespace Manager { - class ShortcutCreateForm + public partial class ShortcutCreateForm: Form { + public ShortcutCreateForm () + { + InitializeComponent (); + Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_TITLE"); + label1.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_TITLE"); + label2.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_DESC"); + label3.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_ICONTYPE"); + iconSetGen.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_ICONTYPE_GEN"); + iconSetFromFile.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_ICONTYPE_SEL"); + label4.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_ICONTYPE_SEL_ICONPATH"); + iconFileBrowser.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_BROWSE"); + label7.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_PREVIEW"); + label5.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_BACKGROUNDCOLOR"); + colorPickerButton.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_SELECT"); + label6.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_RATIO"); + ratioCustom.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_RATIO_CUSTOM"); + label10.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_RATIO_CUSTOMRATIO"); + label12.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_DISPLAYNAME"); + label8.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_IMAGELIST"); + label9.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_PREVIEW"); + buttonGen.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_GENERATE"); + buttonCancel.Text = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_CANCEL"); + Column1.HeaderText = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_SIZE"); + Column2.HeaderText = ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_IMAGE"); + _imageItems.ListChanged += ImageItems_ListChanged; + RefreshCustomRatioStatus (); + RefreshIconSourceMode (); + } + private void ImageItems_ListChanged (object sender, ListChangedEventArgs e) { RefreshImagePreview (); } + void RefreshImagePreview () + { + imagesPreview.SuspendLayout (); + imagesPreview.Controls.Clear (); + foreach (var item in _imageItems.OrderBy (i => i.Size)) + { + var display = new ImageDisplay + { + IconSize = item.Size, + ForegroundImage = item.Image, + BackgroundColor = GetCurrentBackgroundColor (), + Ratio = GetCurrentRatio () + }; + imagesPreview.Controls.Add (display); + } + imagesPreview.ResumeLayout (); + } + void UpdateRatio (decimal ratio) + { + foreach (ImageDisplay d in imagesPreview.Controls) d.Ratio = ratio; + } + void UpdateBackgroundColor (Color color) + { + foreach (ImageDisplay d in imagesPreview.Controls) d.BackgroundColor = color; + } + public Color GetCurrentBackgroundColor () => DataUtils.UITheme.StringToColor (colorInputAndPreview.Text); + public decimal GetCurrentRatio () + { + if (ratio8_7.Checked) return (decimal)(8m / 7m); + if (ratio3_2.Checked) return 1.5m; + if (ratio1_1.Checked) return 1m; + try + { + if (ratioCustom.Checked) + { + decimal l = 0m, r = 0m; + decimal.TryParse (ratioCustomBack.Text, out l); + decimal.TryParse (ratioCustomFore.Text, out r); + return l / r; + } + } catch { } + return 0m; + } + class ImageItem + { + public int Size { get; set; } + public Image Image { get; set; } + } + private BindingList _imageItems = new BindingList(); + Dictionary ExtractBest (Dictionary source, int baseSize) + { + if (source == null || source.Count == 0) return null; + var result = new Dictionary (); + foreach (var kv in source) + { + if (kv.Key.IsTargetSize && + kv.Key.Contrast == AppxPackage.PriResourceKey.PriContrast.None) + { + result [kv.Key.Value] = kv.Value; + } + } + if (result.Count > 0) return result; + foreach (var kv in source) + { + if (kv.Key.IsTargetSize) + { + result [kv.Key.Value] = kv.Value; + } + } + if (result.Count > 0) return result; + foreach (var kv in source) + { + if (kv.Key.IsScale && + kv.Key.Contrast == AppxPackage.PriResourceKey.PriContrast.None) + { + int size = (int)(kv.Key.Value * 0.01 * baseSize); + result [size] = kv.Value; + } + } + if (result.Count > 0) + return result; + foreach (var kv in source) + { + if (kv.Key.IsScale) + { + int size = (int)(kv.Key.Value * 0.01 * baseSize); + result [size] = kv.Value; + } + } + return result.Count > 0 ? result : null; + } + void InitImageList (Dictionary images) + { + _imageItems = new BindingList ( + images.Select (kv => new ImageItem + { + Size = kv.Key, + Image = kv.Value + }).ToList () + ); + imageSizeList.AutoGenerateColumns = false; + Column1.DataPropertyName = nameof (ImageItem.Size); + Column2.DataPropertyName = nameof (ImageItem.Image); + imageSizeList.DataSource = _imageItems; + + } + private string installLocation = ""; + private string genAppUserId = ""; + private Dictionary _initList = new Dictionary (); + private void InitInfos () + { + try + { + _initList?.Clear (); + _initList = null; + using (var m = new AppxPackage.ManifestReader (Path.Combine (installLocation, "AppxManifest.xml"))) + { + m.EnablePri = false; + m.UsePri = true; + AppxPackage.MRApplication app = null; + string logo_30 = "", + smallLogo = "", + logo = "", + logo_44 = ""; + foreach (var i in m.Applications) + { + if (i.UserModelID?.Trim ()?.ToLowerInvariant () == genAppUserId?.Trim ()?.ToLowerInvariant ()) + { + app = i; + logo_44 = app ["Square44x44Logo"]; + logo_30 = app ["Square30x30Logo"]; + logo = app ["Logo"]; + smallLogo = app ["SmallLogo"]; + break; + } + } + m.EnablePri = true; + foreach (var i in m.Applications) + { + if (i.UserModelID?.Trim ()?.ToLowerInvariant () == genAppUserId?.Trim ()?.ToLowerInvariant ()) + { + app = i; + break; + } + } + this.Invoke ((Action)(() => + { + colorInputAndPreview.Text = app ["BackgroundColor"]; + shortcutNameInput.Text = app ["DisplayName"]; + if (string.IsNullOrWhiteSpace (shortcutNameInput.Text)) + shortcutNameInput.Text = app ["SmallLogo"]; + })); + Dictionary logo_30list = m.PriFile.ResourceAllValues (logo_30), + logo_smalllist = m.PriFile.ResourceAllValues (smallLogo), + logo_list = m.PriFile.ResourceAllValues (logo), + logo_44list = m.PriFile.ResourceAllValues (logo_44); + Dictionary filteredlist = null; + filteredlist = + ExtractBest (logo_44list, 44) + ?? ExtractBest (logo_30list, 30) + ?? ExtractBest (logo_smalllist, 30) + ?? ExtractBest (logo_list, 150); + Dictionary imageList = new Dictionary (); + foreach (var kv in filteredlist) + { + try + { + var imgPath = Path.Combine (installLocation, kv.Value); + var img = Image.FromFile (imgPath); + if (img == null) continue; + imageList [kv.Key] = img; + } + catch { } + } + _initList = imageList; + this.Invoke ((Action)(() => + { + InitImageList (imageList); + RefreshImagePreview (); + RefreshCustomRatioStatus (); + RefreshIconSourceMode (); + })); + } + } + catch (Exception e) + { + this.Invoke ((Action)(() => _imageItems.Clear ())); + } + } + private void InitAsync () + { + var loading = new LoadingStatusForm (); + { + loading.Show (this); + loading.Refresh (); + this.Invoke ((Action)(() => { Enabled = false; })); + + Task.Factory.StartNew (() => + { + try + { + InitInfos (); + } + catch (Exception ex) + { + Invoke ((Action)(() => + { + MessageBox.Show ($"Initialization failed: {ex.Message}"); + })); + } + finally + { + this.Invoke ((Action)(() => + { + loading.Close (); + Enabled = true; + })); + } + }); + } + } + public string InstallLocation + { + get { return installLocation; } + set { installLocation = value; InitAsync (); } + } + public string AppUserModelID + { + get { return genAppUserId; } + set { genAppUserId = value; InitAsync (); } + } + public void InitCreater (string inslocation, string appUserId) + { + installLocation = inslocation; + genAppUserId = appUserId; + InitAsync (); + } + private void ShortcutCreateForm_Load (object sender, EventArgs e) + { + + } + private void ratio8_7_CheckedChanged (object sender, EventArgs e) { RefreshCustomRatioStatus (); } + private void ratio3_2_CheckedChanged (object sender, EventArgs e) { RefreshCustomRatioStatus (); } + private void ratio1_1_CheckedChanged (object sender, EventArgs e) { RefreshCustomRatioStatus (); } + private void ratioCustom_CheckedChanged (object sender, EventArgs e) { RefreshCustomRatioStatus (); } + private void RefreshCustomRatioStatus () + { + ratioCustomBack.Enabled = ratioCustomFore.Enabled = ratioCustom.Checked; + UpdateRatio (GetCurrentRatio ()); + } + private void iconSetGen_CheckedChanged (object sender, EventArgs e) { RefreshIconSourceMode (); } + private void iconSetFromFile_CheckedChanged (object sender, EventArgs e) { RefreshIconSourceMode (); } + private void RefreshIconSourceMode () + { + iconFileInput.Enabled = iconFileBrowser.Enabled = iconSetFromFile.Checked; + colorInputAndPreview.Enabled = colorPickerButton.Enabled = + ratio8_7.Enabled = ratio3_2.Enabled = ratio1_1.Enabled = + ratioCustom.Enabled = ratioCustomBack.Enabled = ratioCustomFore.Enabled = + iconSetGen.Checked; + if (iconSetGen.Checked) + { + RefreshCustomRatioStatus (); + } + if (iconSetFromFile.Checked) + { + try + { + customIconDisplay.Image = new Icon (iconFileInput.Text)?.ToBitmap (); + } + catch + { + customIconDisplay.Image = null; + } + } + else customIconDisplay.Image = null; + } + private void colorInputAndPreview_TextChanged (object sender, EventArgs e) + { + try + { + Color nowColor = DataUtils.UITheme.StringToColor (colorInputAndPreview.Text); + double luminance = nowColor.R * 0.299 + nowColor.G * 0.587 + nowColor.B * 0.114; + Color foreground = luminance < 128 ? Color.White : Color.Black; + colorInputAndPreview.BackColor = nowColor; + colorInputAndPreview.ForeColor = foreground; + UpdateBackgroundColor (nowColor); + } + catch { } + } + private Bitmap GenerateIconBitmap (int size, Image foreground, Color background, decimal ratio) + { + var bmp = new Bitmap (size, size); + using (var g = Graphics.FromImage (bmp)) + { + g.Clear (background); + g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; + g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; + g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; + float foreSize = (float)(size / ratio); + float x = (size - foreSize) / 2f; + float y = (size - foreSize) / 2f; + var destRect = new RectangleF (x, y, foreSize, foreSize); + g.DrawImage (foreground, destRect); + } + return bmp; + } + Dictionary GenerateAllIconImages () + { + var result = new Dictionary (); + Color bg = GetCurrentBackgroundColor (); + decimal ratio = GetCurrentRatio (); + foreach (var item in _imageItems) + { + var bmp = GenerateIconBitmap (item.Size, item.Image, bg, ratio); + result [item.Size] = bmp; + } + return result; + } + public static void SaveAsIcon (Dictionary images, string filePath) + { + using (var fs = new FileStream (filePath, FileMode.Create)) + using (var bw = new BinaryWriter (fs)) + { + bw.Write ((short)0); // reserved + bw.Write ((short)1); // type = icon + bw.Write ((short)images.Count); + int offset = 6 + (16 * images.Count); + var imageData = new List (); + foreach (var kv in images.OrderBy (i => i.Key)) + { + using (var ms = new MemoryStream ()) + { + kv.Value.Save (ms, System.Drawing.Imaging.ImageFormat.Png); + byte [] data = ms.ToArray (); + imageData.Add (data); + bw.Write ((byte)(kv.Key >= 256 ? 0 : kv.Key)); // width + bw.Write ((byte)(kv.Key >= 256 ? 0 : kv.Key)); // height + bw.Write ((byte)0); // color count + bw.Write ((byte)0); // reserved + bw.Write ((short)1); // planes + bw.Write ((short)32); // bit count + bw.Write (data.Length); + bw.Write (offset); + offset += data.Length; + } + } + foreach (var data in imageData) bw.Write (data); + } + } + private void iconFileInput_TextChanged (object sender, EventArgs e) + { + try + { + customIconDisplay.Image = new Icon (iconFileInput.Text)?.ToBitmap (); + } + catch + { + customIconDisplay.Image = null; + } + } + private void imageSizeList_CellDoubleClick (object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex < 0) return; + if (imageSizeList.Columns [e.ColumnIndex] != Column2) return; + var item = _imageItems [e.RowIndex]; + var isf = new ImageSetForm (); + isf.CurrentSize = item.Size; + isf.DefaultImages = _initList; + isf.FinalImage = item.Image; + isf.ShowDialog (this); + var newimg = isf.FinalImage; + if (newimg != null) + { + item.Image = newimg; + RefreshImagePreview (); + } + } + public bool IsSuccess { get; private set; } = false; + public string Message { get; private set; } = ""; + private void buttonCancel_Click (object sender, EventArgs e) + { + IsSuccess = false; + Message = "User canceled."; + this.Close (); + } + private void ShortcutCreateForm_FormClosed (object sender, FormClosedEventArgs e) + { + _imageItems?.Clear (); + _imageItems = null; + _initList?.Clear (); + _initList = null; + } + public static bool IsValidFileName (string fileName, bool requireExtension = true) + { + if (string.IsNullOrWhiteSpace (fileName)) return false; + if (fileName.IndexOfAny (Path.GetInvalidFileNameChars ()) >= 0) return false; + if (fileName.EndsWith (" ") || fileName.EndsWith (".")) return false; + if (requireExtension) + { + if (!Path.HasExtension (fileName)) return false; + string ext = Path.GetExtension (fileName); + if (string.IsNullOrWhiteSpace (ext) || ext == ".") return false; + } + string nameWithoutExtension = Path.GetFileNameWithoutExtension (fileName); + string [] reservedNames = + { + "CON", "PRN", "AUX", "NUL", + "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", + "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" + }; + if (reservedNames.Contains (nameWithoutExtension.ToUpper ())) return false; + if (fileName.Length > 255) return false; + return true; + } + private void buttonGen_Click (object sender, EventArgs e) + { + try + { + if (!IsValidFileName (shortcutNameInput.Text, false)) + { + MessageBox.Show (this, "Invalid shortcut name.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + var iconfilename = ""; + var iconfilepath = ""; + if (iconSetGen.Checked) + { + iconfilename = genAppUserId.Replace ('!', '-') + ".ico"; + iconfilepath = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "icons", iconfilename); + if (File.Exists (iconfilepath)) + { + #region gen twice; + var dlgres = MessageBox.Show ( + this, + ResXmlStore.StringRes.Get ("MANAGER_APP_SHORTCUTCREATE_ASK_ICONEXISTS"), + "Ask", + MessageBoxButtons.YesNo, + MessageBoxIcon.Question + ); + if (dlgres == DialogResult.Yes) + { + try + { + iconfilename = genAppUserId.Replace ('!', '-') + "-" + DateTime.Now.GetHashCode () + ".ico"; + iconfilepath = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "icons", iconfilename); + var icons = GenerateAllIconImages (); + SaveAsIcon (icons, iconfilepath); + } + catch (Exception ex) + { + MessageBox.Show (this, "Cannot create icon, we will fallback. Message: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + iconfilename = genAppUserId.Replace ('!', '-') + ".ico"; + iconfilepath = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "icons", iconfilename); + } + } + #endregion + } + else + { + var icons = GenerateAllIconImages (); + SaveAsIcon (icons, iconfilepath); + } + } + else + { + iconfilepath = iconFileInput.Text; + } + var shortcutname = shortcutNameInput.Text + ".lnk"; + var shortcutpath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Desktop), shortcutname); + ShortcutHelper.CreateShortcut ( + shortcutpath, + Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "Launch.exe"), + genAppUserId, + null, + iconfilepath, + shortcutNameInput.Text, + genAppUserId + ); + IsSuccess = true; + Message = ""; + this.Close (); + } + catch (Exception ex) + { + IsSuccess = false; + Message = ex.Message; + this.Close (); + } + } + private void ShortcutCreateForm_FormClosing (object sender, FormClosingEventArgs e) + { + if (!IsSuccess && string.IsNullOrWhiteSpace (Message)) + { + IsSuccess = false; + Message = "User canceled."; + } + } + + private void colorPickerButton_Click (object sender, EventArgs e) + { + using (var colorpicker = new ColorDialog ()) + { + colorpicker.Color = GetCurrentBackgroundColor (); + var dlgres = colorpicker.ShowDialog (this); + if (dlgres == DialogResult.OK) + { + colorInputAndPreview.Text = DataUtils.UITheme.ColorToHtml (colorpicker.Color); + } + } + } + + private void iconFileBrowser_Click (object sender, EventArgs e) + { + using (OpenFileDialog dlg = new OpenFileDialog ()) + { + dlg.Title = "Please select the icon file:"; + dlg.Filter = "Icon File (*.ico)|*.ico"; + dlg.CheckFileExists = true; + dlg.CheckPathExists = true; + dlg.Multiselect = false; + dlg.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory; + if (dlg.ShowDialog () == DialogResult.OK) + { + iconFileInput.Text = dlg.FileName; + } + } + } } } diff --git a/Manager/ShortcutCreateForm.resx b/Manager/ShortcutCreateForm.resx new file mode 100644 index 0000000..bd85112 --- /dev/null +++ b/Manager/ShortcutCreateForm.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + A shortcut to the Windows Store app will be created on the desktop as the entry point for launching the app. Due to limitations in Windows 8.x, this will be achieved through launching the program (using parameters); please do not pin it to the Start Menu. + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/Manager/ShortcutHelper.cs b/Manager/ShortcutHelper.cs new file mode 100644 index 0000000..7741ff7 --- /dev/null +++ b/Manager/ShortcutHelper.cs @@ -0,0 +1,155 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace Manager +{ + public static class ShortcutHelper + { + public static void CreateShortcut ( + string shortcutPath, + string targetPath, + string arguments, + string workingDirectory, + string iconPath, + string description, + string appUserModelID) + { + IShellLinkW link = (IShellLinkW)new CShellLink (); + + link.SetPath (targetPath); + + if (!string.IsNullOrEmpty (arguments)) + link.SetArguments (arguments); + + if (!string.IsNullOrEmpty (workingDirectory)) + link.SetWorkingDirectory (workingDirectory); + + if (!string.IsNullOrEmpty (description)) + link.SetDescription (description); + + if (!string.IsNullOrEmpty (iconPath)) + link.SetIconLocation (iconPath, 0); + + if (!string.IsNullOrEmpty (appUserModelID)) + { + IPropertyStore propertyStore = (IPropertyStore)link; + + PROPERTYKEY key = PROPERTYKEY.AppUserModel_ID; + + using (PropVariant pv = new PropVariant (appUserModelID)) + { + propertyStore.SetValue (ref key, pv); + propertyStore.Commit (); + } + } + + IPersistFile file = (IPersistFile)link; + file.Save (shortcutPath, false); + + Marshal.ReleaseComObject (link); + } + + #region COM 定义(全部放进类内部) + + [ComImport] + [Guid ("00021401-0000-0000-C000-000000000046")] + internal class CShellLink + { + } + + [ComImport] + [InterfaceType (ComInterfaceType.InterfaceIsIUnknown)] + [Guid ("000214F9-0000-0000-C000-000000000046")] + internal interface IShellLinkW + { + void GetPath ([Out, MarshalAs (UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, IntPtr pfd, int fFlags); + void GetIDList (out IntPtr ppidl); + void SetIDList (IntPtr pidl); + void GetDescription ([Out, MarshalAs (UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName); + void SetDescription ([MarshalAs (UnmanagedType.LPWStr)] string pszName); + void GetWorkingDirectory ([Out, MarshalAs (UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath); + void SetWorkingDirectory ([MarshalAs (UnmanagedType.LPWStr)] string pszDir); + void GetArguments ([Out, MarshalAs (UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath); + void SetArguments ([MarshalAs (UnmanagedType.LPWStr)] string pszArgs); + void GetHotkey (out short pwHotkey); + void SetHotkey (short wHotkey); + void GetShowCmd (out int piShowCmd); + void SetShowCmd (int iShowCmd); + void GetIconLocation ([Out, MarshalAs (UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath, out int piIcon); + void SetIconLocation ([MarshalAs (UnmanagedType.LPWStr)] string pszIconPath, int iIcon); + void SetRelativePath ([MarshalAs (UnmanagedType.LPWStr)] string pszPathRel, int dwReserved); + void Resolve (IntPtr hwnd, int fFlags); + void SetPath ([MarshalAs (UnmanagedType.LPWStr)] string pszFile); + } + + [ComImport] + [InterfaceType (ComInterfaceType.InterfaceIsIUnknown)] + [Guid ("0000010b-0000-0000-C000-000000000046")] + internal interface IPersistFile + { + void GetClassID (out Guid pClassID); + void IsDirty (); + void Load ([MarshalAs (UnmanagedType.LPWStr)] string pszFileName, uint dwMode); + void Save ([MarshalAs (UnmanagedType.LPWStr)] string pszFileName, bool fRemember); + void SaveCompleted ([MarshalAs (UnmanagedType.LPWStr)] string pszFileName); + void GetCurFile ([MarshalAs (UnmanagedType.LPWStr)] out string ppszFileName); + } + + [ComImport] + [InterfaceType (ComInterfaceType.InterfaceIsIUnknown)] + [Guid ("886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99")] + internal interface IPropertyStore + { + uint GetCount (out uint cProps); + uint GetAt (uint iProp, out PROPERTYKEY pkey); + uint GetValue (ref PROPERTYKEY key, out PropVariant pv); + uint SetValue (ref PROPERTYKEY key, PropVariant pv); + uint Commit (); + } + + [StructLayout (LayoutKind.Sequential, Pack = 4)] + internal struct PROPERTYKEY + { + public Guid fmtid; + public uint pid; + + public static PROPERTYKEY AppUserModel_ID = + new PROPERTYKEY + { + fmtid = new Guid ("9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3"), + pid = 5 + }; + } + + [StructLayout (LayoutKind.Sequential)] + internal sealed class PropVariant: IDisposable + { + short vt; + short wReserved1; + short wReserved2; + short wReserved3; + IntPtr ptr; + int int32; + + private const short VT_LPWSTR = 31; + + public PropVariant (string value) + { + vt = VT_LPWSTR; + ptr = Marshal.StringToCoTaskMemUni (value); + } + + public void Dispose () + { + if (ptr != IntPtr.Zero) + { + Marshal.FreeCoTaskMem (ptr); + ptr = IntPtr.Zero; + } + } + } + + #endregion + } +} diff --git a/Manager/packages.config b/Manager/packages.config new file mode 100644 index 0000000..649c3f8 --- /dev/null +++ b/Manager/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Update/Update.csproj b/Update/Update.csproj index 65ccf88..312ce70 100644 --- a/Update/Update.csproj +++ b/Update/Update.csproj @@ -73,12 +73,6 @@ - - - {ad25497f-a15f-4dff-ac7a-b8abf5f411d6} - settings - -