diff --git a/.gitignore b/.gitignore index 3a8542d..9b38ae2 100644 --- a/.gitignore +++ b/.gitignore @@ -359,4 +359,5 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd +/main/Resources/Taskbar Groups Background.exe diff --git a/README.md b/README.md index 671358e..af1b144 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,21 @@

- Logo + Logo

Taskbar Groups

-Issues open -Last commit -Latest version -Latest version +Issues open +Last commit +Latest version +Latest version

Taskbar groups is a lightweight utility for Windows that lets the users create groups of shortcuts in the taskbar.

- Download & Release Notes + Download & Release Notes


@@ -25,102 +25,26 @@ * [➤ Installation](#-how-to-download-taskbar-groups) * [➤ Creating your first group](#%EF%B8%8F-creating-your-first-group) -* [➤ Screen/Window Documentation](#%EF%B8%8F-screenwindow-documentation) - * [Main Screen](#main-screen-) - * [Group Creation Screen](#group-creation-screen-) - * [Extra Notes](#extra-notes-) -* [➤ Image/Icon Caching](#-imageicon-caching) -* [➤ Program Shortcuts](#%EF%B8%8F-program-shortcuts) -* [➤ File/Folder Structure](#-folder-structure-documentation) -* [➤ License](#-License) +* [➤ License](#-license) [![-----------------------------------------------------](https://user-images.githubusercontent.com/56088716/103312593-8a37ff80-49eb-11eb-91d3-75488e21a0a9.png)](#how-to-download-taskbar-groups) ## 🔽 How to download Taskbar groups: - 1. Download the .zip-file from the latest release (link above) - 2. Unpack the .zip-file at a desired location - 3. Run the TaskbarGroups.exe file in the extracted folder +1. Download the TaskbarGroups.exe from [releases](https://github.com/PikeNote/taskbar-groups-pike-beta/releases) +2. Place in any location and run [ ![-----------------------------------------------------](https://user-images.githubusercontent.com/56088716/103312593-8a37ff80-49eb-11eb-91d3-75488e21a0a9.png)](#creating-your-first-group) -## 🛠️ Creating your first group - 1. Press on the "Add taskbar group" - 2. Give the group a name and an icon - 3. Click on the "Add new shortcut" and select an .exe or .lnk (repeat until you got all your desired shortcuts) - a. You can select multiple .exe or .lnk files at once - b. You can drag and drop .exe, .lnk, or folders into the add new shortcut field - 4. Save the group - enter image description here5. Left click on the group - 6. In the folder that opens up, right click on the highlighted shortcut - 7. Select "Pin to taskbar" - [![-----------------------------------------------------](https://user-images.githubusercontent.com/56088716/103312593-8a37ff80-49eb-11eb-91d3-75488e21a0a9.png)](#screenwindow-documentation) -## 🖥️ Screen/Window Documentation - Below will be some documentation for each of the screens with explaining the functionality of each of the components. -#### Main screen [](#main-screen) -![Group overview screen](https://user-images.githubusercontent.com/56088716/103317856-81025f00-49fa-11eb-907b-99623babf315.PNG)Here is the main group configuration screen. You get here by executing the TaskbarGroups.exe file. Here you can add groups and see what groups you have created. - -#### Group Creation Screen [](#group-creation) -![Group creation screen](https://user-images.githubusercontent.com/56088716/103452967-36efd680-4ca3-11eb-8244-2aed6fc5af97.PNG) -Here is the group creation screen. Here you can start customizing and configuring your group. Here is the quick rundown of the features of this window. - -**Name the new group** - You can insert any group name (no special characters) that you would like with a maximum character limit of 49 characters in total. - -**Width** - You can set the limit for how many shortcuts will appear on each line. For example I have 12 shortcuts and I have a width of 6. It will display 6 shortcuts per row/line. - -**Change Group Icon** - You can click the (+) icon and it will bring up a file dialogue. You can select any type of image files (.png, .jpg, etc.), icon files (.ico), and any sort of executable or shortcut files (.exe, .lnk). On top of this you can drag and drop any of the mentioned file types above to use the icons from those files. - -**Add new shortcuts** - You can click the (+) icon and it will bring up a file dialogue like the change group icon section. You can select any type of executable or extension files (.exe, .lnk) to add to your group. You can also add **shortcuts** leading to the windows store apps along with steam games/software. **Do note however that if the shortcuts are moved, the application can no longer launch those applications and you will have to re-edit your group.** - -**Allow open-all shortcuts** - When you launch the group to try to launch an app, you have the option to launch all the executables inside the group. To enable this feature, this checkbox has to be checked and the group has to be saved. All shortcuts can be launched through the usage of the Ctrl + Enter keybinds. - -**Shortcut Item Selection** - Once you have added shortcuts/applications, you can click on the **sides of the individual entries** of those shortcuts/applications or anywhere that a text or image aren't blocking the background area. Clicking on them will "select" them and they would have a permanent background that is darker than the rest of the entries. This will be the same color as when you hover over applications/shortcuts. This will be needed to set **Working Directories** and **Arguments**. - -**Working Directory** - Once you have selected an item, this textbox and the choose folder beside it will be enabled. Here you can change what working directory the application starts with. This may be required for some applications. By default for older groups, the working directory is the directory of the taskbar groups application. For new added shortcuts/applications, the working directory will be set as the location of the application or the directory of the target file for shortcuts. You can also manually set a loation through the **Select Directory** button. Any directory that is changed manually will be checked to be valid and if the working directory is invalid, the target path will be set with the same process as if you added a new application/shortcut. - -**Arguments** - Once you have selected an item, this textbox is enabled and you can type any launch arguments that you would like to include with the application on launch. - -**Dark color/Light color/Custom color** - Here you can select what color you want the background of your group to be. - -**Opacity** - Here you can select how transparent you want the background of your application to be. The scale work from 0% (Solid color, no opacity) to 100% (Fully transparent). - -**Entry Name** - Whenever you add an application, the entry will have the text assumed from the name of the application without the extension at the end (.exe, .txt, etc.). This can be changed if you select the text directly and you can type into field. The textbox that you type in expands/shrinks based on the length of the text to make room to select the entry. The character limit here is 27 characters. - -#### Extra Notes [](#extra-notes) -With fetching the icons of executables, the application will directly take the icon of the executable. With extensions, it works a little bit different. The application will try to fix the icon location for the extension to see if that exists anywhere on the system and use that if possible. If not, then the application would try to use the icon of the target file of that extension. - -On top of this, this works a bit differently for Microsoft App Store extensions. These extensions don't contain any sort of target path nor icon location. Here the application will try to fetch the image from the system folder where these icons are stored using the ID of the application grabbed from the extension. -[ -![-----------------------------------------------------](https://user-images.githubusercontent.com/56088716/103312593-8a37ff80-49eb-11eb-91d3-75488e21a0a9.png)](#image-caching) -## 📦 Image/Icon Caching -Image/icon caching is done through recreating the icon and placing it locally in the icons folder of the group in the config folder. Here it is loaded up locally as to not waste resources to recreate the icon every time. When icons are deleted/not found, the application will display an x. The icon cache can be regenerated by simply saving the group again through the main application. - -[ -![-----------------------------------------------------](https://user-images.githubusercontent.com/56088716/103312593-8a37ff80-49eb-11eb-91d3-75488e21a0a9.png)](#program-shortcuts) -## ⌨️ Program Shortcuts -When you open a group once its created through the shortcut provided, there are a list of hotkeys to make the program more easily usable. - -**Top row numbers 1,2,3,4,5,6,7,8,9,0** - Opens the shortcuts at those positions respective from 1-10. - -**Ctrl + Enter** - Opens all applications/shortcut within the group at once -(Feature must be enabled through the settings when editing/creating the group for this to work) - -[ -![-----------------------------------------------------](https://user-images.githubusercontent.com/56088716/103312593-8a37ff80-49eb-11eb-91d3-75488e21a0a9.png)](#folder-structure) - -## 📁 Folder Structure Documentation - -#### /config -In the config folder, you will have the data regarding each group that you have created. -#### /config//Icons -This is the icon cache that comes with the folder. All icons of the shortcuts that you added are added into that cache. This cache will be read from when using your group to not have to fetch each individual icon every time. -#### /config//GroupIcon.ico / GroupImage.png -Created image from the group icon you selected. This will be your application icon and read from when you start up the group. -#### /config//ObjectData.xml -Crucial information about the shortcuts and the group itself stored inside of here. It saves your settings for the group and is important in determining what goes into the group when you open it and any other visual settings you may have configured. -#### /JITComp -In here stores the individual profiles for each form. Essentially these profiles are per-compiled code that the application can read from to improve loading times and responsiveness in the system. -#### /Shortcuts -Here is where all of your shortcuts to activate your group will go. All groups created will have their shortcut created here and after creation, you can feel free to move the shortcut or pin it to any desired locations. -![-----------------------------------------------------](https://user-images.githubusercontent.com/56088716/103312593-8a37ff80-49eb-11eb-91d3-75488e21a0a9.png) +## 🛠️ Creating and pinning your first group +1. Press on the "Add taskbar group" +2. Give the group a name and an icon +3. Click on the "Add new shortcut" and select an .exe or .lnk (repeat until you got all your desired shortcuts) + a. You can select multiple .exe or .lnk files at once + b. You can drag and drop .exe, .lnk, or folders into the add new shortcut field +4. Save the group +5. Left click on the group in an empty space +6. In the folder that opens up, right click on the highlighted shortcut with the same name as your group +7. Select "Pin to taskbar" + [ ![-----------------------------------------------------](https://user-images.githubusercontent.com/56088716/103312593-8a37ff80-49eb-11eb-91d3-75488e21a0a9.png)](#-License) ## 📜 License This project is licensed under the [MIT License](https://github.com/tjackenpacken/taskbar-groups/blob/master/LICENSE). diff --git a/TaskbarGroups.sln b/TaskbarGroups.sln index b764273..da4ab26 100644 --- a/TaskbarGroups.sln +++ b/TaskbarGroups.sln @@ -1,20 +1,39 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30523.141 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32922.545 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "client", "main\client.csproj", "{B6E63AE7-4433-44EC-BCDE-031CD779E8CC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "editorClient", "main\editorClient.csproj", "{B6E63AE7-4433-44EC-BCDE-031CD779E8CC}" + ProjectSection(ProjectDependencies) = postProject + {880E67DC-610D-4661-878B-14C0A76223B5} = {880E67DC-610D-4661-878B-14C0A76223B5} + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "backgroundClient", "backgroundClient\backgroundClient.csproj", "{880E67DC-610D-4661-878B-14C0A76223B5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {B6E63AE7-4433-44EC-BCDE-031CD779E8CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B6E63AE7-4433-44EC-BCDE-031CD779E8CC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B6E63AE7-4433-44EC-BCDE-031CD779E8CC}.Debug|x86.ActiveCfg = Debug|Any CPU + {B6E63AE7-4433-44EC-BCDE-031CD779E8CC}.Debug|x86.Build.0 = Debug|Any CPU {B6E63AE7-4433-44EC-BCDE-031CD779E8CC}.Release|Any CPU.ActiveCfg = Release|Any CPU {B6E63AE7-4433-44EC-BCDE-031CD779E8CC}.Release|Any CPU.Build.0 = Release|Any CPU + {B6E63AE7-4433-44EC-BCDE-031CD779E8CC}.Release|x86.ActiveCfg = Release|Any CPU + {B6E63AE7-4433-44EC-BCDE-031CD779E8CC}.Release|x86.Build.0 = Release|Any CPU + {880E67DC-610D-4661-878B-14C0A76223B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {880E67DC-610D-4661-878B-14C0A76223B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {880E67DC-610D-4661-878B-14C0A76223B5}.Debug|x86.ActiveCfg = Debug|Any CPU + {880E67DC-610D-4661-878B-14C0A76223B5}.Debug|x86.Build.0 = Debug|Any CPU + {880E67DC-610D-4661-878B-14C0A76223B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {880E67DC-610D-4661-878B-14C0A76223B5}.Release|Any CPU.Build.0 = Release|Any CPU + {880E67DC-610D-4661-878B-14C0A76223B5}.Release|x86.ActiveCfg = Release|Any CPU + {880E67DC-610D-4661-878B-14C0A76223B5}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/backgroundClient/Classes/Category.cs b/backgroundClient/Classes/Category.cs new file mode 100644 index 0000000..f7436d0 --- /dev/null +++ b/backgroundClient/Classes/Category.cs @@ -0,0 +1,170 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Runtime.Serialization; +using System.Diagnostics; + +namespace backgroundClient.Classes +{ + public class Category + { + public List programImages = new List(); + + public string Name = ""; + public string ColorString = System.Drawing.ColorTranslator.ToHtml(Color.FromArgb(31, 31, 31)); + public bool allowOpenAll = false; + public List ShortcutList; + public int Width; // not used aon + public double Opacity = 10; + public String HoverColor; + public int IconSize = 30; + public int Separation = 8; + + public Icon groupIco; + + public Category() + { + + } + + public Category(string loadCat) + { + String fullPath = Path.GetFullPath(Path.Combine(loadCat, "ObjectData.xml")); + + System.Xml.Serialization.XmlSerializer reader = + new System.Xml.Serialization.XmlSerializer(typeof(Category)); + using (StreamReader file = new StreamReader(fullPath)) + { + Category category = (Category)reader.Deserialize(file); + this.Name = category.Name; + this.ShortcutList = category.ShortcutList; + this.Width = category.Width; + this.ColorString = category.ColorString; + this.Opacity = category.Opacity; + this.allowOpenAll = category.allowOpenAll; + this.HoverColor = category.HoverColor; + this.IconSize = category.IconSize; + this.Separation = category.Separation; + } + + + + foreach (ProgramShortcut psc in ShortcutList) + { + programImages.Add(loadImageCache(psc)); + } + + using (MemoryStream ms = new MemoryStream(System.IO.File.ReadAllBytes(Path.Combine(loadCat, "GroupIcon.ico")))) + groupIco = new Icon(ms); + + Color sysColor = bkgProcess.SystemColors; + if (ColorString == "sys") + { + ColorString = "#" + sysColor.R.ToString("X2") + sysColor.G.ToString("X2") + sysColor.B.ToString("X2"); + } + } + + + + public Color calculateHoverColor() + { + Color BackColor = FromString(ColorString); + if (BackColor.R * 0.2126 + BackColor.G * 0.7152 + BackColor.B * 0.0722 > 255 / 2) + { + // Do prior calculations on darker colors to prevent color values going negative + int backColorR = BackColor.R - 50 >= 0 ? BackColor.R - 50 : 0; + int backColorG = BackColor.G - 50 >= 0 ? BackColor.G - 50 : 0; + int backColorB = BackColor.B - 50 >= 0 ? BackColor.B - 50 : 0; + + //if backcolor is light, set hover color as darker + return Color.FromArgb(BackColor.A, backColorR, backColorG, backColorB); + } + else + { + // Do prior calculations on darker colors to prevent color values going over 255 + int backColorR = BackColor.R + 50 <= 255 ? BackColor.R + 50 : 255; + int backColorG = BackColor.G + 50 <= 255 ? BackColor.G + 50 : 255; + int backColorB = BackColor.B + 50 <= 255 ? BackColor.B + 50 : 255; + + //light backcolor is light, set hover color as darker + return Color.FromArgb(BackColor.A, (BackColor.R + 50), (BackColor.G + 50), (BackColor.B + 50)); + } + } + + public static Color FromString(string name) + { + if (String.IsNullOrWhiteSpace(name)) + { + throw new ArgumentException("name"); + } + + KnownColor knownColor; + + if (Enum.TryParse(name, out knownColor)) + { + return Color.FromKnownColor(knownColor); + } + + return ColorTranslator.FromHtml(name); + } + + public Image loadImageCache(ProgramShortcut shortcutObject) + { + + String programPath = shortcutObject.FilePath; + + if (System.IO.File.Exists(programPath) || Directory.Exists(programPath) || shortcutObject.isWindowsApp) + { + try + { + // Try to construct the path like if it existed + // If it does, directly load it into memory and return it + // If not then it would throw an exception in which the below code would catch it + String cacheImagePath = generateCachePath(shortcutObject); + + using (MemoryStream ms = new MemoryStream(System.IO.File.ReadAllBytes(cacheImagePath))) + { + return Image.FromStream(ms); + + } + + } + catch (Exception) + { + return global::backgroundClient.Properties.Resources.Error; + } + } + else + { + return global::backgroundClient.Properties.Resources.Error; + } + } + + public String generateCachePath(ProgramShortcut shortcutObject) + { + return Path.Combine(Paths.ConfigPath, this.Name, "Icons", + generateMD5Hash(shortcutObject.FilePath + shortcutObject.Arguments) + ".png"); + } + + private String generateMD5Hash(String s) + { + using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create()) + { + byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(s); + byte[] hashBytes = md5.ComputeHash(inputBytes); + + + StringBuilder sb = new System.Text.StringBuilder(); + for (int i = 0; i < hashBytes.Length; i++) + { + sb.Append(hashBytes[i].ToString("X2")); + } + return sb.ToString(); + } + } + } +} diff --git a/backgroundClient/Classes/Jumplist.cs b/backgroundClient/Classes/Jumplist.cs new file mode 100644 index 0000000..44a59d0 --- /dev/null +++ b/backgroundClient/Classes/Jumplist.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.WindowsAPICodePack.Taskbar; +using System.IO; +using System.Reflection; +using Microsoft.WindowsAPICodePack.Shell; +using IWshRuntimeLibrary; + +namespace backgroundClient.Classes +{ + public class Jumplist + { + private JumpList list; + public Jumplist(IntPtr windowHandle) + { + list = JumpList.CreateJumpListForIndividualWindow(TaskbarManager.Instance.ApplicationId, windowHandle); + list.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent; + } + + public void buildJumplist(bool allowOpenAll, string Name) + { + + string categoryPath = Path.Combine(Paths.ConfigPath, Name); + + JumpListCustomCategory userTaskbarCategory = new JumpListCustomCategory("Taskbar Groups"); + + JumpListLink openEdit = new JumpListLink(Paths.exeString, "Edit Group"); + openEdit.Arguments = "editingGroupMode " + Name; + openEdit.IconReference = new IconReference(Path.Combine(categoryPath, "GroupIcon.ico"), 0); + userTaskbarCategory.AddJumpListItems(openEdit); + + if (allowOpenAll) + { + JumpListLink openAllShortcuts = new JumpListLink(Paths.exeString, "Open all shortcuts"); + openAllShortcuts.Arguments = Name + " tskBaropen_allGroup"; + openAllShortcuts.IconReference = new IconReference(Path.Combine(categoryPath, "GroupIcon.ico"), 0); + userTaskbarCategory.AddJumpListItems(openAllShortcuts); + } + + try + { + list.AddCustomCategories(userTaskbarCategory); + + list.Refresh(); + } + catch { } + } + } +} diff --git a/backgroundClient/Classes/Paths.cs b/backgroundClient/Classes/Paths.cs new file mode 100644 index 0000000..8cf33f6 --- /dev/null +++ b/backgroundClient/Classes/Paths.cs @@ -0,0 +1,84 @@ +using backgroundClient.Properties; +using IWshRuntimeLibrary; +using System; +using System.IO; + +namespace backgroundClient.Classes +{ + // Function that is accessed by all forms to get the starting absolute path of the .exe + // Added as to not keep generating the path in each form + static class Paths + { + /// + /// The folder in which the main executable resides. + /// + public static String path = System.IO.Path.GetDirectoryName(exeString); + + /// + /// The full path to the application's main executable. + /// + public static String exeString = System.Reflection.Assembly.GetExecutingAssembly().Location; + + public static String exeFolder = AppDomain.CurrentDomain.BaseDirectory; + + public static String defaultConfigPath; + + static Paths() + { + + } + + private static string AppDataRelativePath + { + get + { + return System.IO.Path.Combine("Jack Schierbeck", "taskbar-groups"); + } + } + + public static string ConfigPath = setupConfigPath(); + + private static string setupConfigPath() + { + string directoryPath; + defaultConfigPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataRelativePath, "config"); + if (!Settings.settingInfo.portableMode) + { + directoryPath = defaultConfigPath; + } + else + { + directoryPath = Path.Combine(exeFolder, "config"); + } + + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + + return directoryPath; + } + + public static string OptimizationProfilePath + { + get + { + string directoryPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataRelativePath, "JITComp"); + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + return directoryPath; + } + } + + public static string MainClientShortcut + { + get + { + string filePath = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataRelativePath, "Taskbar Group Editor.lnk"); + return filePath; + } + } + } +} diff --git a/backgroundClient/Classes/ProgramShortcut.cs b/backgroundClient/Classes/ProgramShortcut.cs new file mode 100644 index 0000000..d39ef2d --- /dev/null +++ b/backgroundClient/Classes/ProgramShortcut.cs @@ -0,0 +1,19 @@ +namespace backgroundClient.Classes +{ + public class ProgramShortcut + { + public string FilePath { get; set; } + public bool isWindowsApp { get; set; } + + public string name { get; set; } = ""; + public string Arguments = ""; + public string WorkingDirectory = Paths.exeString; + + + public ProgramShortcut() // needed for XML serialization + { + + } + + } +} diff --git a/backgroundClient/Classes/ScreenExtensions.cs b/backgroundClient/Classes/ScreenExtensions.cs new file mode 100644 index 0000000..b9dc82a --- /dev/null +++ b/backgroundClient/Classes/ScreenExtensions.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace backgroundClient.Classes +{ + // Get DPI function below + public static class ScreenExtensions + { + public static void GetDpi(this System.Windows.Forms.Screen screen, DpiType dpiType, out uint dpiX, out uint dpiY) + { + var pnt = new System.Drawing.Point(screen.Bounds.Left + 1, screen.Bounds.Top + 1); + var mon = MonitorFromPoint(pnt, 2/*MONITOR_DEFAULTTONEAREST*/); + GetDpiForMonitor(mon, dpiType, out dpiX, out dpiY); + } + + //https://msdn.microsoft.com/en-us/library/windows/desktop/dd145062(v=vs.85).aspx + [DllImport("User32.dll")] + private static extern IntPtr MonitorFromPoint([In] System.Drawing.Point pt, [In] uint dwFlags); + + //https://msdn.microsoft.com/en-us/library/windows/desktop/dn280510(v=vs.85).aspx + [DllImport("Shcore.dll")] + private static extern IntPtr GetDpiForMonitor([In] IntPtr hmonitor, [In] DpiType dpiType, [Out] out uint dpiX, [Out] out uint dpiY); + } + + //https://msdn.microsoft.com/en-us/library/windows/desktop/dn280511(v=vs.85).aspx + public enum DpiType + { + Effective = 0, + Angular = 1, + Raw = 2, + } +} diff --git a/backgroundClient/Classes/Settings.cs b/backgroundClient/Classes/Settings.cs new file mode 100644 index 0000000..eb21885 --- /dev/null +++ b/backgroundClient/Classes/Settings.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Serialization; + +namespace backgroundClient.Classes +{ + static class Settings + { + private static string appDataRelative = System.IO.Path.Combine("Jack Schierbeck", "taskbar-groups"); + public static string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), appDataRelative, "Settings.xml"); + public static string defaultSettingsPath; + public static Setting settingInfo; + + static Settings() + { + defaultSettingsPath = settingsPath; + if (File.Exists(settingsPath)) + { + + } + else if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.xml"))) + { + settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.xml"); + } + else + { + Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), appDataRelative)); + settingInfo = new Setting(); + writeXML(); + return; + } + + System.Xml.Serialization.XmlSerializer reader = + new System.Xml.Serialization.XmlSerializer(typeof(Setting)); + using (StreamReader file = new StreamReader(settingsPath)) + { + settingInfo = (Setting)reader.Deserialize(file); + file.Close(); + } + + if (settingInfo.portableMode == true && !File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.xml"))) + { + settingInfo.portableMode = false; + writeXML(); + } + + } + + public static void writeXML() + { + try + { + System.Xml.Serialization.XmlSerializer writer = + new System.Xml.Serialization.XmlSerializer(typeof(Setting)); + + using (FileStream file = System.IO.File.Create(settingsPath)) + { + writer.Serialize(file, settingInfo); + file.Close(); + } + }catch(IOException) + { + DialogResult result = MessageBox.Show("Settings.xml may be open in another file.", "Exit", MessageBoxButtons.OK); + Environment.Exit(4); + } + } + } + + [Serializable()] + public class Setting + { + [XmlElement] + public bool portableMode { get; set; } = false; + } +} diff --git a/backgroundClient/Classes/ShellLink.cs b/backgroundClient/Classes/ShellLink.cs new file mode 100644 index 0000000..b777e7b --- /dev/null +++ b/backgroundClient/Classes/ShellLink.cs @@ -0,0 +1,126 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace backgroundClient.Classes +{ + static class ShellLink + { + public static void InstallShortcut(string exePath, string appId, string desc, string wkDirec, string iconLocation, string saveLocation, string arguments) + { + // Use passed parameters as to construct the shortcut + IShellLinkW newShortcut = (IShellLinkW)new CShellLink(); + newShortcut.SetPath(exePath); + newShortcut.SetDescription(desc); + newShortcut.SetWorkingDirectory(wkDirec); + newShortcut.SetArguments(arguments); + newShortcut.SetIconLocation(iconLocation, 0); + + + // Set the classID of the shortcut that is created + // Crucial to avoid program stacking + IPropertyStore newShortcutProperties = (IPropertyStore)newShortcut; + + PropVariantHelper varAppId = new PropVariantHelper(); + varAppId.SetValue(appId); + newShortcutProperties.SetValue(PROPERTYKEY.AppUserModel_ID, varAppId.Propvariant); + + // Save the shortcut as per passed save location + IPersistFile newShortcutSave = (IPersistFile)newShortcut; + newShortcutSave.Save(saveLocation, true); + } + + #region COM APIs + [ComImport, Guid("000214F9-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + internal interface IShellLinkW + { + void GetPath([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, IntPtr pfd, uint fFlags); + void GetIDList(out IntPtr ppidl); + void SetIDList(IntPtr pidl); + void GetDescription([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, 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 wHotKey); + void SetHotKey(short wHotKey); + void GetShowCmd(out uint iShowCmd); + void SetShowCmd(uint iShowCmd); + void GetIconLocation([Out(), MarshalAs(UnmanagedType.LPWStr)] out StringBuilder pszIconPath, int cchIconPath, out int iIcon); + void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon); + void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, uint dwReserved); + void Resolve(IntPtr hwnd, uint fFlags); + void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile); + } + + [ComImport, Guid("0000010b-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + internal interface IPersistFile + { + void GetCurFile([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile); + void IsDirty(); + void Load([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, [MarshalAs(UnmanagedType.U4)] long dwMode); + void Save([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, bool fRemember); + void SaveCompleted([MarshalAs(UnmanagedType.LPWStr)] string pszFileName); + } + + [StructLayout(LayoutKind.Explicit)] + public struct PROPVARIANT + { + [FieldOffset(0)] + public ushort vt; + [FieldOffset(8)] + public IntPtr unionmember; + [FieldOffset(8)] + public UInt64 forceStructToLargeEnoughSize; + } + + [ComImport, Guid("886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + interface IPropertyStore + { + void GetCount([Out] out uint propertyCount); + void GetAt([In] uint propertyIndex, [Out, MarshalAs(UnmanagedType.Struct)] out PROPERTYKEY key); + void GetValue([In, MarshalAs(UnmanagedType.Struct)] ref PROPERTYKEY key, [Out, MarshalAs(UnmanagedType.Struct)] out PROPVARIANT pv); + void SetValue([In, MarshalAs(UnmanagedType.Struct)] ref PROPERTYKEY key, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT pv); + void Commit(); + } + + [ComImport, Guid("00021401-0000-0000-C000-000000000046"), ClassInterface(ClassInterfaceType.None)] + internal class CShellLink { } + + [StructLayout(LayoutKind.Sequential, Pack = 4)] + public struct PROPERTYKEY + { + public Guid fmtid; + public uint pid; + + public PROPERTYKEY(Guid guid, uint id) + { + fmtid = guid; + pid = id; + } + + public static readonly PROPERTYKEY AppUserModel_ID = new PROPERTYKEY(new Guid("9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3"), 5); + } + #endregion + + internal class PropVariantHelper + { + private static class NativeMethods + { + [DllImport("Ole32.dll", PreserveSig = false)] + internal static extern void PropVariantClear(ref PROPVARIANT pvar); + } + + private PROPVARIANT variant; + public PROPVARIANT Propvariant => variant; + + public void SetValue(string val) + { + NativeMethods.PropVariantClear(ref variant); + variant.vt = (ushort)VarEnum.VT_LPWSTR; + variant.unionmember = Marshal.StringToCoTaskMemUni(val); + } + } + } +} \ No newline at end of file diff --git a/backgroundClient/Forms/bkgProcess.Designer.cs b/backgroundClient/Forms/bkgProcess.Designer.cs new file mode 100644 index 0000000..096f140 --- /dev/null +++ b/backgroundClient/Forms/bkgProcess.Designer.cs @@ -0,0 +1,59 @@ + +namespace backgroundClient +{ + partial class bkgProcess + { + /// + /// 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.components = new System.ComponentModel.Container(); + this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); + this.SuspendLayout(); + // + // notifyIcon1 + // + this.notifyIcon1.Text = "Taskbar Groups Background"; + this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click); + // + // bkgProcess + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(0, 0); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "bkgProcess"; + this.ShowInTaskbar = false; + this.Text = "Form1"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.NotifyIcon notifyIcon1; + } +} + diff --git a/backgroundClient/Forms/bkgProcess.cs b/backgroundClient/Forms/bkgProcess.cs new file mode 100644 index 0000000..d3b2672 --- /dev/null +++ b/backgroundClient/Forms/bkgProcess.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows.Forms; +using backgroundClient.Classes; +using IWshRuntimeLibrary; +using static backgroundClient.bkgProcess; + +namespace backgroundClient +{ + public partial class bkgProcess : Form + { + public static Dictionary loadedCategories = new Dictionary(); + + [DllImport("user32.dll")] + public static extern bool ShowWindow(IntPtr handle, int flags); + [DllImport("dwmapi.dll", EntryPoint = "#127")] + public static extern void DwmGetColorizationParameters(out DWMCOLORIZATIONPARAMS parameters); + + public static Color SystemColors = Color.FromArgb(31, 31, 31); + + public struct DWMCOLORIZATIONPARAMS + { + public uint ColorizationColor, + ColorizationAfterglow, + ColorizationColorBalance, + ColorizationAfterglowBalance, + ColorizationBlurBalance, + ColorizationGlassReflectionIntensity, + ColorizationOpaqueBlend; + } + + protected override CreateParams CreateParams + { + get + { + var Params = base.CreateParams; + Params.ExStyle |= 0x80; + Params.ExStyle |= 0x08000000; + return Params; + } + } + + + public bkgProcess() + { + //Make background transparent + this.BackColor = Color.LimeGreen; + this.TransparencyKey = Color.LimeGreen; + this.ShowInTaskbar = false; + this.Opacity = 0; + + AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => + { + string resourceName = new AssemblyName(args.Name).Name + ".dll"; + string resource = Array.Find(this.GetType().Assembly.GetManifestResourceNames(), element => element.EndsWith(resourceName)); + + using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)) + { + Byte[] assemblyData = new Byte[stream.Length]; + stream.Read(assemblyData, 0, assemblyData.Length); + return Assembly.Load(assemblyData); + } + }; + + InitializeComponent(); + updateColor(); + this.Hide(); + + string[] folders = Directory.GetDirectories(Paths.ConfigPath); + foreach (string folderName in folders) + { + if (System.IO.File.Exists(Path.Combine(folderName, "ObjectData.xml"))) + { + loadedCategories.Add(new DirectoryInfo(folderName).Name, new Category(folderName)); + } + } + + + + notifyIcon1.Visible = true; + notifyIcon1.Icon = backgroundClient.Properties.Resources.Icon; + + ContextMenu trayContext = new ContextMenu(); + + trayContext.MenuItems.Add("Exit", (s,e) => { + Application.Exit(); + }); + notifyIcon1.ContextMenu = trayContext; + } + + private void updateColor() + { + DWMCOLORIZATIONPARAMS windowsColors = new DWMCOLORIZATIONPARAMS(); + DwmGetColorizationParameters(out windowsColors); + + SystemColors = Color.FromArgb( + (byte)(255), + (byte)(windowsColors.ColorizationColor >> 16), + (byte)(windowsColors.ColorizationColor >> 8), + (byte)windowsColors.ColorizationColor); + } + + + public static void showFormCat( string category, string arguments) + { + try + { + new frmMain(loadedCategories[category], arguments.Split(' ')).Show(); + } + catch { } + } + + private void notifyIcon1_Click(object sender, EventArgs e) + { + openEditor(); + } + + public static void openEditor(string arguments="") + { + if (System.IO.File.Exists(Paths.MainClientShortcut) && Paths.MainClientShortcut != Paths.exeString) + { + WshShell shell = new WshShell(); //Create a new WshShell Interface + IWshShortcut mainClientShortcut = (IWshShortcut)shell.CreateShortcut(Paths.MainClientShortcut); //Link the interface to our shortcut + + // Chcek if the editor actually exists + if (System.IO.File.Exists(mainClientShortcut.TargetPath)) + { + Process p = new Process(); + p.StartInfo.FileName = mainClientShortcut.TargetPath; + + p.StartInfo.Arguments = arguments; + p.Start(); + } + else + { + MessageBox.Show("The editor has moved since the last time you've used it. Reopen it for it to relink the shortcut needed to use this feature!"); + } + } + else + { + MessageBox.Show("Please reopen your Taskbar Groups editor to set the location of itself so you can use this feature!"); + } + } + + // Get system color window changes + const int WM_DWMCOLORIZATIONCOLORCHANGED = 0x320; + protected override void WndProc(ref Message m) + { + // Cancel any maximize message sent to the window + if (m.Msg == 0x320) + { + updateColor(); + } + base.WndProc(ref m); + } + } +} diff --git a/backgroundClient/Forms/bkgProcess.resx b/backgroundClient/Forms/bkgProcess.resx new file mode 100644 index 0000000..84ceda3 --- /dev/null +++ b/backgroundClient/Forms/bkgProcess.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file diff --git a/main/Forms/frmMain.Designer.cs b/backgroundClient/Forms/frmMain.Designer.cs similarity index 94% rename from main/Forms/frmMain.Designer.cs rename to backgroundClient/Forms/frmMain.Designer.cs index a8c4812..139d164 100644 --- a/main/Forms/frmMain.Designer.cs +++ b/backgroundClient/Forms/frmMain.Designer.cs @@ -1,4 +1,4 @@ -namespace client +namespace backgroundClient { partial class frmMain { @@ -40,7 +40,6 @@ private void InitializeComponent() this.KeyPreview = true; this.Name = "frmMain"; this.Text = "Group"; - this.Deactivate += new System.EventHandler(this.frmMain_Deactivate); this.Load += new System.EventHandler(this.frmMain_Load); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.frmMain_KeyDown); this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.frmMain_KeyUp); diff --git a/main/Forms/frmMain.cs b/backgroundClient/Forms/frmMain.cs similarity index 64% rename from main/Forms/frmMain.cs rename to backgroundClient/Forms/frmMain.cs index 19d67ba..8e67896 100644 --- a/main/Forms/frmMain.cs +++ b/backgroundClient/Forms/frmMain.cs @@ -1,21 +1,30 @@ -using client.Classes; -using client.User_controls; +using backgroundClient.Classes; +using backgroundClient.User_controls; using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; -using System.IO; -using System.Threading.Tasks; +using System.Drawing.Drawing2D; +using System.Linq; +using System.Runtime.InteropServices; +using System.Timers; using System.Windows.Forms; -namespace client +namespace backgroundClient { public partial class frmMain : Form { + [DllImport("User32.dll")] + internal static extern IntPtr SetForegroundWindow(IntPtr hWnd); + + [DllImport("user32.dll", SetLastError = true)] + static extern void SwitchToThisWindow(IntPtr hWnd, bool turnOn); + // Allow doubleBuffering drawing each frame to memory and then onto screen // Solves flickering issues mostly as the entire rendering of the screen is done in 1 operation after being first loaded to memory + /* protected override CreateParams CreateParams { @@ -26,65 +35,181 @@ protected override CreateParams CreateParams return cp; } } + */ - public Category ThisCategory; public List ControlList; + Keys[] keyList = new Keys[] {Keys.D1, Keys.D2,Keys.D3, Keys.D4,Keys.D5, Keys.D6,Keys.D7, Keys.D8,Keys.D9, Keys.D0}; public Color HoverColor; + public static uint eDpi { get; set; } // Effective DPI + public static decimal xDpi { get; set; } // eDpi ratio for HDPi conversions - private string passedDirec; + //private string passedDirec; public Point mouseClick; + private string[] argumentList; + + private Category loadedCat; + + private Jumplist jumpList; + + public int ucShortcutSize; + public int ucShortcutIconSize; + public int ucShortcutIconLocation; + //------------------------------------------------------------------------------------ // CTOR AND LOAD // - public frmMain(string passedDirectory, int cursorPosX, int cursorPosY) + public frmMain(Category category, string[] arguments) { + /* + AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => + { + string resourceName = new AssemblyName(args.Name).Name + ".dll"; + string resource = Array.Find(this.GetType().Assembly.GetManifestResourceNames(), element => element.EndsWith(resourceName)); + + using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)) + { + Byte[] assemblyData = new Byte[stream.Length]; + stream.Read(assemblyData, 0, assemblyData.Length); + return Assembly.Load(assemblyData); + } + }; + */ + + + InitializeComponent(); + loadedCat = category; + System.Runtime.ProfileOptimization.StartProfile("frmMain.Profile"); - mouseClick = new Point(cursorPosX, cursorPosY); // Consstruct point p based on passed x y mouse values - passedDirec = passedDirectory; + mouseClick = new Point(Cursor.Position.X, Cursor.Position.Y); // Consstruct point p based on passed x y mouse values + eDpi = Display(DpiType.Effective); // Get Dpi from clicked screen + xDpi = eDpi / 96; // Get eDpi conversion ratio FormBorderStyle = FormBorderStyle.None; + argumentList = arguments; - using (MemoryStream ms = new MemoryStream(System.IO.File.ReadAllBytes(MainPath.path + "\\config\\" + passedDirec + "\\GroupIcon.ico"))) - this.Icon = new Icon(ms); + this.Icon = category.groupIco; - if (Directory.Exists(@MainPath.path + @"\config\" + passedDirec)) - { - ControlList = new List(); + ControlList = new List(); - this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); - ThisCategory = new Category($"config\\{passedDirec}"); - this.BackColor = ImageFunctions.FromString(ThisCategory.ColorString); - Opacity = (1 - (ThisCategory.Opacity / 100)); + this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); + this.BackColor = Category.FromString(category.ColorString); + Opacity = (1 - (category.Opacity / 100)); - if (BackColor.R * 0.2126 + BackColor.G * 0.7152 + BackColor.B * 0.0722 > 255 / 2) - //if backcolor is light, set hover color as darker - HoverColor = Color.FromArgb(BackColor.A, (BackColor.R - 50), (BackColor.G - 50), (BackColor.B - 50)); - else - //light backcolor is light, set hover color as darker - HoverColor = Color.FromArgb(BackColor.A, (BackColor.R + 50), (BackColor.G + 50), (BackColor.B + 50)); + this.TopLevel = true; + this.TopMost = true; + + /* + if (BackColor.R * 0.2126 + BackColor.G * 0.7152 + BackColor.B * 0.0722 > 255 / 2) + { + // Do prior calculations on darker colors to prevent color values going negative + int backColorR = BackColor.R - 50 >= 0 ? BackColor.R - 50 : 0; + int backColorG = BackColor.G - 50 >= 0 ? BackColor.G - 50 : 0; + int backColorB = BackColor.B - 50 >= 0 ? BackColor.B - 50 : 0; + + //if backcolor is light, set hover color as darker + HoverColor = Color.FromArgb(BackColor.A, backColorR, backColorG, backColorB); } else { - Application.Exit(); + // Do prior calculations on darker colors to prevent color values going over 255 + int backColorR = BackColor.R + 50 <= 255 ? BackColor.R + 50 : 255; + int backColorG = BackColor.G + 50 <= 255 ? BackColor.G + 50 : 255; + int backColorB = BackColor.B + 50 <= 255 ? BackColor.B + 50 : 255; + + //light backcolor is light, set hover color as darker + HoverColor = Color.FromArgb(BackColor.A, (BackColor.R + 50), (BackColor.G + 50), (BackColor.B + 50)); + }*/ + + if (category.HoverColor == null) + { + HoverColor = category.calculateHoverColor(); + } else + { + HoverColor = ColorTranslator.FromHtml(category.HoverColor); + } + + jumpList = new Jumplist(this.Handle); + jumpList.buildJumplist(category.allowOpenAll, category.Name); + + if (arguments[0] == "setGroupContextMenu") + { + this.Close(); } } + // eDpi Calculations Below ----------------- + public uint Display(DpiType type) + { + foreach (var screen in System.Windows.Forms.Screen.AllScreens) + { + if (screen.Bounds.Contains(mouseClick)) // Get what screen to target eDpi + { + screen.GetDpi(DpiType.Effective, out uint x, out _); + eDpi = x; + return (x); + } + } + return (eDpi); + } + private void frmMain_Load(object sender, EventArgs e) { LoadCategory(); + + /* + if (argumentList.Length >= 2) + { + string jointArgument = String.Join(" ", argumentList).Trim(); + ucShortcut[] argumentMatch = ControlList.Where(prmShortcut => prmShortcut.Psc.name == jointArgument).ToArray(); + + if (jointArgument == "tskBaropen_allGroup") + { + foreach (ucShortcut usc in this.ControlList) + usc.ucShortcut_Click(usc, new EventArgs()); + } + this.Close(); + }*/ + + + if (argumentList[0] == "tskBaropen_allGroup") + { + foreach (ucShortcut usc in this.ControlList) + usc.ucShortcut_Click(usc, new EventArgs()); + this.Close(); + } SetLocation(); + + //this.TopMost = false; + + SetForegroundWindow(this.Handle); + SwitchToThisWindow(this.Handle, true); + + System.Timers.Timer t = new System.Timers.Timer(); + t.Interval = 50; + t.AutoReset = false; + t.Elapsed += new ElapsedEventHandler(TimerElapsed); + t.Start(); + } + + private void TimerElapsed(object sender, ElapsedEventArgs e) + { + this.Deactivate += frmMain_Deactivate; + this.LostFocus += frmMain_Deactivate; } + [DllImport("user32.dll")] + private static extern IntPtr GetForegroundWindow(); + + // Sets location of form private void SetLocation() { - List taskbarList = FindDockedTaskBars(); + Dictionary taskbarList = FindDockedTaskBars(); Rectangle taskbar = new Rectangle(); Rectangle screen = new Rectangle(); - int i = 0; int locationy; int locationx; if (taskbarList.Count != 0) @@ -97,9 +222,9 @@ private void SetLocation() screen.Y = scr.Bounds.Y; screen.Width = scr.Bounds.Width; screen.Height = scr.Bounds.Height; - taskbar = taskbarList[i]; + taskbarList.TryGetValue(scr.DeviceName, out taskbar); + break; } - i++; } if (taskbar.Contains(mouseClick)) // Click on taskbar @@ -168,7 +293,6 @@ private void SetLocation() screen.Width = scr.Bounds.Width; screen.Height = scr.Bounds.Height; } - i++; } if (mouseClick.Y > Screen.PrimaryScreen.Bounds.Height - 35) @@ -197,9 +321,10 @@ private void SetLocation() } } // Search for active taskbars on screen - public static List FindDockedTaskBars() + public static Dictionary FindDockedTaskBars() { - List dockedRects = new List(); + var dockedRects = new Dictionary(); + foreach (var tmpScrn in Screen.AllScreens) { if (!tmpScrn.Bounds.Equals(tmpScrn.WorkingArea)) @@ -243,7 +368,7 @@ public static List FindDockedTaskBars() // Nothing found! } - dockedRects.Add(rect); + dockedRects.Add(tmpScrn.DeviceName, rect); } } @@ -261,45 +386,51 @@ public static List FindDockedTaskBars() // Loading category and building shortcuts private void LoadCategory() { - //System.Diagnostics.Debugger.Launch(); - this.Width = 0; - this.Height = 45; + this.Height = (int)((loadedCat.IconSize + loadedCat.Separation * 2) * xDpi); + ucShortcutSize = this.Height; + ucShortcutIconSize = (int)(loadedCat.IconSize * xDpi); + ucShortcutIconLocation = (int)(loadedCat.Separation * xDpi); int x = 0; int y = 0; - int width = ThisCategory.Width; + int width = loadedCat.Width; int columns = 1; // Check if icon caches exist for the category being loaded // If not then rebuild the icon cache - if (!Directory.Exists(@MainPath.path + @"\config\" + ThisCategory.Name + @"\Icons\")) + + /* + if (!Directory.Exists(Path.Combine(Paths.ConfigPath, loadedCat.Name, "Icons"))) { ThisCategory.cacheIcons(); } + */ - foreach (ProgramShortcut psc in ThisCategory.ShortcutList) + for (int i=0; i width) // creating new row if there are more psc than max width { x = 0; - y += 45; - this.Height += 45; + y += (int)((loadedCat.IconSize + loadedCat.Separation * 2) * xDpi); + this.Height += (int)((loadedCat.IconSize + loadedCat.Separation * 2) * xDpi); columns = 1; } - if (this.Width < ((width * 55))) - this.Width += (55); + if (this.Width < ((width * (int)((loadedCat.IconSize + loadedCat.Separation * 2) * xDpi)))) + this.Width += ((int)((loadedCat.IconSize + loadedCat.Separation * 2) * (xDpi))); // OLD //BuildShortcutPanel(x, y, psc); - + // Building shortcut controls - ucShortcut pscPanel = new ucShortcut() + ucShortcut pscPanel = new ucShortcut() { - Psc = psc, - MotherForm = this, - ThisCategory = ThisCategory + Psc = psc, + MotherForm = this, + bkgImage = loadedCat.programImages[i], + loadedCategory = loadedCat }; pscPanel.Location = new System.Drawing.Point(x, y); this.Controls.Add(pscPanel); @@ -308,14 +439,16 @@ private void LoadCategory() pscPanel.BringToFront(); // Reset values - x += 55; + x += (int)((loadedCat.IconSize + loadedCat.Separation * 2) * xDpi); columns++; } - this.Width -= 2; // For some reason the width is 2 pixels larger than the shortcuts. Temporary fix + // this.Width -= 2; // For some reason the width is 2 pixels larger than the shortcuts. Temporary fix + // Fixed by setting the width of the ucPanel to the real value up here } // OLD (Having some issues with the uc build, so keeping the old code below) + /* private void BuildShortcutPanel(int x, int y, ProgramShortcut psc) { this.shortcutPic = new System.Windows.Forms.PictureBox(); @@ -333,6 +466,7 @@ private void BuildShortcutPanel(int x, int y, ProgramShortcut psc) this.shortcutPic.MouseEnter += new System.EventHandler((sender, e) => this.shortcutPanel.BackColor = Color.Black); this.shortcutPic.MouseLeave += new System.EventHandler((sender, e) => this.shortcutPanel.BackColor = System.Drawing.Color.Transparent); } + */ // Click handler for shortcuts public void OpenFile(string arguments, string path, string workingDirec) @@ -358,11 +492,16 @@ public void OpenFile(string arguments, string path, string workingDirec) } } + // Closes application upon deactivation private void frmMain_Deactivate(object sender, EventArgs e) { - // closes program if user clicks outside form - this.Close(); + + if (GetForegroundWindow() != this.Handle) + { + // closes program if user clicks outside form + this.Close(); + } } // Keyboard shortcut handlers @@ -371,6 +510,11 @@ private void frmMain_KeyDown(object sender, KeyEventArgs e) try { + + if (keyList.Contains(e.KeyCode)) { + ControlList[Array.IndexOf(keyList, e.KeyCode)].ucShortcut_MouseEnter(sender, e); + } + /* switch (e.KeyCode) { @@ -405,17 +549,18 @@ private void frmMain_KeyDown(object sender, KeyEventArgs e) ControlList[9].ucShortcut_MouseEnter(sender, e); break; } + */ } catch { } + } private void frmMain_KeyUp(object sender, KeyEventArgs e) { - //System.Diagnostics.Debugger.Launch(); - if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Enter && ThisCategory.allowOpenAll) + if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Enter && loadedCat.allowOpenAll) { foreach (ucShortcut usc in this.ControlList) usc.ucShortcut_Click(sender, e); @@ -423,6 +568,13 @@ private void frmMain_KeyUp(object sender, KeyEventArgs e) try { + if (keyList.Contains(e.KeyCode)) + { + ControlList[Array.IndexOf(keyList, e.KeyCode)].ucShortcut_MouseEnter(sender, e); + ControlList[Array.IndexOf(keyList, e.KeyCode)].ucShortcut_Click(sender, e); + } + + /* switch (e.KeyCode) { case Keys.D1: @@ -444,7 +596,7 @@ private void frmMain_KeyUp(object sender, KeyEventArgs e) break; case Keys.D5: ControlList[4].ucShortcut_MouseLeave(sender, e); - ControlList[4].ucShortcut_Click(sender, e); + ControlList[4].ucShortcut_Click(sender, e);f break; case Keys.D6: ControlList[5].ucShortcut_MouseLeave(sender, e); @@ -467,6 +619,7 @@ private void frmMain_KeyUp(object sender, KeyEventArgs e) ControlList[9].ucShortcut_Click(sender, e); break; } + */ } catch { @@ -474,11 +627,30 @@ private void frmMain_KeyUp(object sender, KeyEventArgs e) } } + private const int WM_SYSCOMMAND = 0x0112; + private const int SC_MAXIMIZE = 0xf030; + + protected override void WndProc(ref Message m) + { + // Cancel any maximize message sent to the window + if (m.Msg == WM_SYSCOMMAND) + { + if (m.WParam.ToInt32() == SC_MAXIMIZE) + { + m.Result = IntPtr.Zero; + return; + } + } + base.WndProc(ref m); + } // // endregion // public System.Windows.Forms.PictureBox shortcutPic; public System.Windows.Forms.Panel shortcutPanel; + + + // // END OF CLASS // diff --git a/main/Forms/frmMain.resx b/backgroundClient/Forms/frmMain.resx similarity index 100% rename from main/Forms/frmMain.resx rename to backgroundClient/Forms/frmMain.resx diff --git a/backgroundClient/Icon.ico b/backgroundClient/Icon.ico new file mode 100644 index 0000000..80a5706 Binary files /dev/null and b/backgroundClient/Icon.ico differ diff --git a/backgroundClient/Program.cs b/backgroundClient/Program.cs new file mode 100644 index 0000000..dbfcea7 --- /dev/null +++ b/backgroundClient/Program.cs @@ -0,0 +1,118 @@ +using backgroundClient.Classes; +using IWshRuntimeLibrary; +using Microsoft.VisualBasic.ApplicationServices; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace backgroundClient +{ + + class SingleInstanceApp : WindowsFormsApplicationBase + { + // Define functions to set AppUserModelID + [DllImport("shell32.dll", SetLastError = true)] + static extern void SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID); + + public SingleInstanceApp() + : base() + { + this.IsSingleInstance = true; + } + + protected override void OnStartupNextInstance( + StartupNextInstanceEventArgs e) + { + base.OnStartupNextInstance(e); + + string[] secondInstanceArgumens = e.CommandLine.ToArray(); + + if (secondInstanceArgumens.Length > 1) // Checks for additional arguments; opens either main application or taskbar drawer application + { + if (bkgProcess.loadedCategories.ContainsKey(secondInstanceArgumens[1])) + { + String group = secondInstanceArgumens[1]; + String argument = ""; + + if (secondInstanceArgumens.Length > 2) + { + for (int i = 2; i < secondInstanceArgumens.Length; i++) + { + argument += secondInstanceArgumens[i].Trim(); + } + } + SetCurrentProcessExplicitAppUserModelID("tjackenpacken.taskbarGroup.menu." + secondInstanceArgumens[1]); + + bkgProcess.showFormCat(group, argument); + } + else if (secondInstanceArgumens[1] == "editingGroupMode") + { + if (bkgProcess.loadedCategories.ContainsKey(secondInstanceArgumens[2])) + { + bkgProcess.openEditor("editingGroupMode" + " " + secondInstanceArgumens[2]); + } + } else if (secondInstanceArgumens[1] == "exitApplicationModeReserved") + { + Application.Exit(); + } + } + } + + protected override void OnCreateMainForm() + { + string[] arguments = Environment.GetCommandLineArgs(); + + base.OnCreateMainForm(); + + this.MainForm = new bkgProcess(); + + Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); + + if (arguments.Length > 1) // Checks for additional arguments; opens either main application or taskbar drawer application + { + if (bkgProcess.loadedCategories.ContainsKey(arguments[1]) || arguments[1] == "editingGroupMode") + { + Process p = new Process(); + p.StartInfo.FileName = Paths.exeString; + + String argument = ""; + + if (arguments.Length > 2) + { + for (int i = 2; i < arguments.Length; i++) + { + argument += arguments[i].Trim(); + } + } + + p.StartInfo.Arguments = arguments[1] + " " + argument; + p.Start(); + } + } + } + } + + static class Program + { + /// + /// The main entry point for the application. + /// + /// + + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + + new SingleInstanceApp().Run(Environment.GetCommandLineArgs()); + } + } +} diff --git a/backgroundClient/Properties/AssemblyInfo.cs b/backgroundClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b75e72c --- /dev/null +++ b/backgroundClient/Properties/AssemblyInfo.cs @@ -0,0 +1,38 @@ +using System.Resources; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Taskbar Groups Background Client")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Taskbar Group")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("880e67dc-610d-4661-878b-14c0a76223b5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("0.2.2.0")] +[assembly: AssemblyFileVersion("0.2.2.0")] +[assembly: NeutralResourcesLanguage("en")] diff --git a/backgroundClient/Properties/Resources.Designer.cs b/backgroundClient/Properties/Resources.Designer.cs new file mode 100644 index 0000000..843bff1 --- /dev/null +++ b/backgroundClient/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace backgroundClient.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("backgroundClient.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Error { + get { + object obj = ResourceManager.GetObject("Error", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon Icon { + get { + object obj = ResourceManager.GetObject("Icon", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Microsoft_WindowsAPICodePack { + get { + object obj = ResourceManager.GetObject("Microsoft_WindowsAPICodePack", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Microsoft_WindowsAPICodePack_Shell { + get { + object obj = ResourceManager.GetObject("Microsoft_WindowsAPICodePack_Shell", resourceCulture); + return ((byte[])(obj)); + } + } + } +} diff --git a/backgroundClient/Properties/Resources.resx b/backgroundClient/Properties/Resources.resx new file mode 100644 index 0000000..512d123 --- /dev/null +++ b/backgroundClient/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\Resources\Error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\lib\Microsoft.WindowsAPICodePack.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\lib\Microsoft.WindowsAPICodePack.Shell.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/backgroundClient/Properties/Settings.Designer.cs b/backgroundClient/Properties/Settings.Designer.cs new file mode 100644 index 0000000..8c1e124 --- /dev/null +++ b/backgroundClient/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace backgroundClient.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/backgroundClient/Properties/Settings.settings b/backgroundClient/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/backgroundClient/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/backgroundClient/Resources/Error.png b/backgroundClient/Resources/Error.png new file mode 100644 index 0000000..b96dfe4 Binary files /dev/null and b/backgroundClient/Resources/Error.png differ diff --git a/backgroundClient/Resources/Icon.ico b/backgroundClient/Resources/Icon.ico new file mode 100644 index 0000000..80a5706 Binary files /dev/null and b/backgroundClient/Resources/Icon.ico differ diff --git a/main/User controls/ucShortcut.Designer.cs b/backgroundClient/User Controls/ucShortcut.Designer.cs similarity index 81% rename from main/User controls/ucShortcut.Designer.cs rename to backgroundClient/User Controls/ucShortcut.Designer.cs index 2e2abba..02a4135 100644 --- a/main/User controls/ucShortcut.Designer.cs +++ b/backgroundClient/User Controls/ucShortcut.Designer.cs @@ -1,4 +1,4 @@ -namespace client.User_controls +namespace backgroundClient.User_controls { partial class ucShortcut { @@ -28,16 +28,22 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.picIcon = new System.Windows.Forms.PictureBox(); ((System.ComponentModel.ISupportInitialize)(this.picIcon)).BeginInit(); this.SuspendLayout(); // // picIcon // + this.picIcon.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.picIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; this.picIcon.Location = new System.Drawing.Point(16, 11); this.picIcon.Name = "picIcon"; this.picIcon.Size = new System.Drawing.Size(23, 23); + this.picIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.picIcon.TabIndex = 0; this.picIcon.TabStop = false; this.picIcon.Click += new System.EventHandler(this.ucShortcut_Click); @@ -64,5 +70,6 @@ private void InitializeComponent() #endregion private System.Windows.Forms.PictureBox picIcon; + private System.Windows.Forms.ToolTip toolTip1; } } diff --git a/main/User controls/ucShortcut.cs b/backgroundClient/User Controls/ucShortcut.cs similarity index 68% rename from main/User controls/ucShortcut.cs rename to backgroundClient/User Controls/ucShortcut.cs index d3273b4..b3a486e 100644 --- a/main/User controls/ucShortcut.cs +++ b/backgroundClient/User Controls/ucShortcut.cs @@ -2,23 +2,19 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; -using client.Classes; using System.Diagnostics; using System.IO; -using IWshRuntimeLibrary; +using backgroundClient.Classes; -namespace client.User_controls +namespace backgroundClient.User_controls { public partial class ucShortcut : UserControl { public ProgramShortcut Psc { get; set; } public frmMain MotherForm { get; set; } - public Category ThisCategory { get; set; } + public Image bkgImage { get; set; } + public Category loadedCategory { get; set; } public ucShortcut() { InitializeComponent(); @@ -26,10 +22,15 @@ public ucShortcut() private void ucShortcut_Load(object sender, EventArgs e) { + this.Size = new Size(MotherForm.ucShortcutSize, MotherForm.ucShortcutSize); this.Show(); this.BringToFront(); this.BackColor = MotherForm.BackColor; - picIcon.BackgroundImage = ThisCategory.loadImageCache(Psc); // Use the local icon cache for the file specified as the icon image + picIcon.BackgroundImage = bkgImage; + toolTip1.SetToolTip(picIcon, Psc.name); + toolTip1.SetToolTip(this, Psc.name); + picIcon.Location = new System.Drawing.Point(MotherForm.ucShortcutIconLocation, MotherForm.ucShortcutIconLocation); + picIcon.Size = new System.Drawing.Size(MotherForm.ucShortcutIconSize, MotherForm.ucShortcutIconSize); } public void ucShortcut_Click(object sender, EventArgs e) @@ -40,10 +41,10 @@ public void ucShortcut_Click(object sender, EventArgs e) p.Start(); } else { - if(Path.GetExtension(Psc.FilePath).ToLower() == ".lnk" && Psc.FilePath == MainPath.exeString) + if(Path.GetExtension(Psc.FilePath).ToLower() == ".lnk" && Psc.FilePath == Paths.exeString) { - MotherForm.OpenFile(Psc.Arguments, Psc.FilePath, MainPath.path); + MotherForm.OpenFile(Psc.Arguments, Psc.FilePath, Paths.path); } else { MotherForm.OpenFile(Psc.Arguments, Psc.FilePath, Psc.WorkingDirectory); diff --git a/main/User controls/ucShortcut.resx b/backgroundClient/User Controls/ucShortcut.resx similarity index 96% rename from main/User controls/ucShortcut.resx rename to backgroundClient/User Controls/ucShortcut.resx index 1af7de1..df8339b 100644 --- a/main/User controls/ucShortcut.resx +++ b/backgroundClient/User Controls/ucShortcut.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/backgroundClient/backgroundClient.csproj b/backgroundClient/backgroundClient.csproj new file mode 100644 index 0000000..404b5c8 --- /dev/null +++ b/backgroundClient/backgroundClient.csproj @@ -0,0 +1,162 @@ + + + + + Debug + AnyCPU + {880E67DC-610D-4661-878B-14C0A76223B5} + WinExe + backgroundClient + Taskbar Groups Background + v4.7.2 + 512 + false + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + + AnyCPU + true + full + false + ..\main\Resources\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + none + true + ..\main\Resources\ + TRACE + prompt + 4 + false + + + Icon.ico + + + + ..\main\obj\Debug\Interop.IWshRuntimeLibrary.dll + True + + + + lib\Microsoft.WindowsAPICodePack.dll + False + + + lib\Microsoft.WindowsAPICodePack.Shell.dll + False + + + + + + + + + + + + + + + + + + + + Form + + + bkgProcess.cs + + + + + + + Form + + + frmMain.cs + + + + + UserControl + + + ucShortcut.cs + + + bkgProcess.cs + Designer + + + frmMain.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + ucShortcut.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + False + Microsoft .NET Framework 4.7.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + \ No newline at end of file diff --git a/backgroundClient/lib/Microsoft.WindowsAPICodePack.Shell.dll b/backgroundClient/lib/Microsoft.WindowsAPICodePack.Shell.dll new file mode 100644 index 0000000..4d4324d Binary files /dev/null and b/backgroundClient/lib/Microsoft.WindowsAPICodePack.Shell.dll differ diff --git a/backgroundClient/lib/Microsoft.WindowsAPICodePack.dll b/backgroundClient/lib/Microsoft.WindowsAPICodePack.dll new file mode 100644 index 0000000..a8f431b Binary files /dev/null and b/backgroundClient/lib/Microsoft.WindowsAPICodePack.dll differ diff --git a/main/App.config b/main/App.config deleted file mode 100644 index 56efbc7..0000000 --- a/main/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/main/Classes/Category.cs b/main/Classes/Category.cs index 4dc92b9..f3be803 100644 --- a/main/Classes/Category.cs +++ b/main/Classes/Category.cs @@ -1,29 +1,38 @@ using client.User_controls; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; +using System.Text; using System.Text.RegularExpressions; using System.Windows.Forms; +using System.Xml.Serialization; namespace client.Classes { public class Category { - public string Name; + public string Name = ""; public string ColorString = System.Drawing.ColorTranslator.ToHtml(Color.FromArgb(31, 31, 31)); public bool allowOpenAll = false; public List ShortcutList; public int Width; // not used aon public double Opacity = 10; + public String HoverColor; + public int IconSize = 30; + public int Separation = 8; + Regex specialCharRegex = new Regex("[*'\",_&#^@]"); private static int[] iconSizes = new int[] {16,32,64,128,256,512}; + private string path; - public Category(string path) + public Category(string inputPath) { + path = inputPath; // Use application's absolute path; (grabs the .exe) // Gets the parent folder of the exe and concats the rest of the path string fullPath; @@ -31,14 +40,20 @@ public Category(string path) // Check if path is a full directory or part of a file name // Passed from the main shortcut client and the config client - if (System.IO.File.Exists(@MainPath.path + @"\" + path + @"\ObjectData.xml")) + + // This if won't ever be true, because the path passed in is a full path to a folder. + /* + if (System.IO.File.Exists(@Paths.path + @"\" + path + @"\ObjectData.xml")) { - fullPath = @MainPath.path + @"\" + path + @"\ObjectData.xml"; + fullPath = @Paths.path + @"\" + path + @"\ObjectData.xml"; } else { - fullPath = Path.GetFullPath(path + "\\ObjectData.xml"); + */ + fullPath = Path.GetFullPath(Path.Combine(inputPath, "ObjectData.xml")); + /* } + */ System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(Category)); @@ -51,7 +66,16 @@ public Category(string path) this.ColorString = category.ColorString; this.Opacity = category.Opacity; this.allowOpenAll = category.allowOpenAll; + this.HoverColor = category.HoverColor; + this.IconSize = category.IconSize; + this.Separation = category.Separation; } + + } + + public String getPath() + { + return path; } public Category() // needed for XML serialization @@ -61,65 +85,95 @@ public Category(string path) public void CreateConfig(Image groupImage) { + try + { + //string filePath = path + @"\" + this.Name + "Group.exe"; + // + // Directory and .exe + // + path = Path.Combine(Paths.ConfigPath, this.Name); + System.IO.Directory.CreateDirectory(@path); - string path = @"config\" + this.Name; - //string filePath = path + @"\" + this.Name + "Group.exe"; - // - // Directory and .exe - // - System.IO.Directory.CreateDirectory(@path); + //System.IO.File.Copy(@"config\config.exe", @filePath); - //System.IO.File.Copy(@"config\config.exe", @filePath); - // - // XML config - // - System.Xml.Serialization.XmlSerializer writer = - new System.Xml.Serialization.XmlSerializer(typeof(Category)); - using (FileStream file = System.IO.File.Create(@path + @"\ObjectData.xml")) - { - writer.Serialize(file, this); - file.Close(); - } - // - // Create .ico - // + writeXML(); - Image img = ImageFunctions.ResizeImage(groupImage, 256, 256); // Resize img if too big - img.Save(path + @"\GroupImage.png"); + // + // Create .ico + // - if (GetMimeType(groupImage).ToString() == "*.PNG") - { - createMultiIcon(groupImage, path + @"\GroupIcon.ico"); - } - else { - using (FileStream fs = new FileStream(path + @"\GroupIcon.ico", FileMode.Create)) + Image img = ImageFunctions.ResizeImage(groupImage, 256, 256); // Resize img if too big + img.Save(Path.Combine(path, "GroupImage.png")); + + if (GetMimeType(groupImage).ToString() == "*.PNG") { - ImageFunctions.IconFromImage(img).Save(fs); - fs.Close(); + createMultiIcon(groupImage, Path.Combine(path, "GroupIcon.ico")); } + else + { + using (FileStream fs = new FileStream(Path.Combine(path, "GroupIcon.ico"), FileMode.Create)) + { + ImageFunctions.IconFromImage(img).Save(fs); + fs.Close(); + } + } + + + // Through shellLink.cs class, pass through into the function information on how to construct the icon + // Needed due to needing to set a unique AppUserModelID so the shortcut applications don't stack on the taskbar with the main application + // Tricks Windows to think they are from different applications even though they are from the same .exe + ShellLink.InstallShortcut( + Paths.BackgroundApplication, + "tjackenpacken.taskbarGroup.menu." + this.Name, + path + " shortcut", + path, + Path.Combine(path, "GroupIcon.ico"), + Path.Combine(path, this.Name + ".lnk"), + this.Name + ); + + + // Build the icon cache + cacheIcons(); + + System.IO.File.Move(Path.Combine(path, this.Name + ".lnk"), + Path.Combine(Paths.ShortcutsPath, Regex.Replace(this.Name, @"(_)+", " ") + ".lnk")); // Move .lnk to correct directory } + catch { } + finally + { + closeBackgroundApp(); - // Through shellLink.cs class, pass through into the function information on how to construct the icon - // Needed due to needing to set a unique AppUserModelID so the shortcut applications don't stack on the taskbar with the main application - // Tricks Windows to think they are from different applications even though they are from the same .exe - ShellLink.InstallShortcut( - Path.GetFullPath(@System.AppDomain.CurrentDomain.FriendlyName), - "tjackenpacken.taskbarGroup.menu." + this.Name, - path + " shortcut", - Path.GetFullPath(@path), - Path.GetFullPath(path + @"\GroupIcon.ico"), - path + "\\" + this.Name + ".lnk", - this.Name - ); + Process backgroundProcess = new Process(); + backgroundProcess.StartInfo.FileName = Paths.BackgroundApplication; + backgroundProcess.Start(); + - // Build the icon cache - cacheIcons(); + Process p = new Process(); + p.StartInfo.FileName = Paths.BackgroundApplication; + p.StartInfo.Arguments = this.Name + " setGroupContextMenu"; + p.Start(); + + } + } - System.IO.File.Move(@path + "\\" + this.Name + ".lnk", - Path.GetFullPath(@"Shortcuts\" + Regex.Replace(this.Name, @"(_)+", " ") + ".lnk")); // Move .lnk to correct directory + + private void writeXML() + { + // + // XML config + // + System.Xml.Serialization.XmlSerializer writer = + new System.Xml.Serialization.XmlSerializer(typeof(Category)); + + using (FileStream file = System.IO.File.Create(Path.Combine(@path, "ObjectData.xml"))) + { + writer.Serialize(file, this); + file.Close(); + } } private static void createMultiIcon(Image iconImage, string filePath) @@ -152,7 +206,7 @@ orderby diffItem.difference public Bitmap LoadIconImage() // Needed to access img without occupying read/write { - string path = @"config\" + Name + @"\GroupImage.png"; + string path = Path.Combine(Paths.ConfigPath, Name, "GroupImage.png"); using (MemoryStream ms = new MemoryStream(System.IO.File.ReadAllBytes(path))) return new Bitmap(ms); @@ -164,8 +218,8 @@ public void cacheIcons() { // Defines the paths for the icons folder - string path = @MainPath.path + @"\config\" + this.Name; - string iconPath = path + "\\Icons\\"; + string path = Path.Combine(Paths.ConfigPath, this.Name); + string iconPath = Path.Combine(path, "Icons"); // Check and delete current icons folder to completely rebuild the icon cache // Only done on re-edits of the group and isn't done usually @@ -177,32 +231,18 @@ public void cacheIcons() // Creates the icons folder inside of existing config folder for the group Directory.CreateDirectory(iconPath); - iconPath = @path + @"\Icons\"; - // Loops through each shortcut added by the user and gets the icon // Writes the icon to the new folder in a .jpg format // Namign scheme for the files are done through Path.GetFileNameWithoutExtension() - for (int i = ShortcutList.Count; i < 0; i--) + + for(int i=0; i< ShortcutList.Count; i++) { String filePath = ShortcutList[i].FilePath; ucProgramShortcut programShortcutControl = Application.OpenForms["frmGroup"].Controls["pnlShortcuts"].Controls[i] as ucProgramShortcut; - string savePath; - - if (ShortcutList[i].isWindowsApp) - { - savePath = iconPath + "\\" + specialCharRegex.Replace(filePath, string.Empty) + ".png"; - } else if (Directory.Exists(filePath)) - { - savePath = iconPath + "\\" + Path.GetFileNameWithoutExtension(filePath) + "_FolderObjTSKGRoup.png"; - } else - { - savePath = iconPath + "\\" + Path.GetFileNameWithoutExtension(filePath) + ".png"; - } - + string savePath = Path.Combine(iconPath, generateMD5Hash(filePath + ShortcutList[i].Arguments) + ".png"); programShortcutControl.logo.Save(savePath); - - } + } } // Try to load an iamge from the cache @@ -219,9 +259,7 @@ public Image loadImageCache(ProgramShortcut shortcutObject) // Try to construct the path like if it existed // If it does, directly load it into memory and return it // If not then it would throw an exception in which the below code would catch it - String cacheImagePath = @Path.GetDirectoryName(Application.ExecutablePath) + - @"\config\" + this.Name + @"\Icons\" + ((shortcutObject.isWindowsApp) ? specialCharRegex.Replace(programPath, string.Empty) : - @Path.GetFileNameWithoutExtension(programPath)) + (Directory.Exists(programPath)? "_FolderObjTSKGRoup.jpg" : ".png"); + String cacheImagePath = generateCachePath(shortcutObject); using (MemoryStream ms = new MemoryStream(System.IO.File.ReadAllBytes(cacheImagePath))) return Image.FromStream(ms); @@ -234,7 +272,7 @@ public Image loadImageCache(ProgramShortcut shortcutObject) // Checks if the original file even exists to make sure to not do any extra operations // Same processing as above in cacheIcons() - String path = MainPath.path + @"\config\" + this.Name + @"\Icons\" + Path.GetFileNameWithoutExtension(programPath) + (Directory.Exists(programPath) ? "_FolderObjTSKGRoup.png" : ".png"); + String path = Path.Combine(Paths.ConfigPath, this.Name, "Icons", generateMD5Hash(programPath + shortcutObject.Arguments) +".png"); Image finalImage; @@ -265,6 +303,18 @@ public Image loadImageCache(ProgramShortcut shortcutObject) } } + public String generateCachePath(ProgramShortcut ps) + { + /* + return @Path.GetDirectoryName(Application.ExecutablePath) + + @"\config\" + this.Name + @"\Icons\" + ((shortcutObject.isWindowsApp) ? specialCharRegex.Replace(programPath, string.Empty) : + @Path.GetFileNameWithoutExtension(programPath)) + (Directory.Exists(programPath) ? "_FolderObjTSKGRoup.png" : ".png"); + */ + + return Path.Combine(Paths.ConfigPath, this.Name, "Icons", + generateMD5Hash(ps.FilePath + ps.Arguments) + ".png"); + } + public static string GetMimeType(Image i) { var imgguid = i.RawFormat.Guid; @@ -275,8 +325,75 @@ public static string GetMimeType(Image i) } return "image/unknown"; } + + public Color calculateHoverColor() + { + Color BackColor = ImageFunctions.FromString(ColorString); + if (BackColor.R * 0.2126 + BackColor.G * 0.7152 + BackColor.B * 0.0722 > 255 / 2) + { + // Do prior calculations on darker colors to prevent color values going negative + int backColorR = BackColor.R - 50 >= 0 ? BackColor.R - 50 : 0; + int backColorG = BackColor.G - 50 >= 0 ? BackColor.G - 50 : 0; + int backColorB = BackColor.B - 50 >= 0 ? BackColor.B - 50 : 0; + + //if backcolor is light, set hover color as darker + return Color.FromArgb(BackColor.A, backColorR, backColorG, backColorB); + } + else + { + // Do prior calculations on darker colors to prevent color values going over 255 + int backColorR = BackColor.R + 50 <= 255 ? BackColor.R + 50 : 255; + int backColorG = BackColor.G + 50 <= 255 ? BackColor.G + 50 : 255; + int backColorB = BackColor.B + 50 <= 255 ? BackColor.B + 50 : 255; + + //light backcolor is light, set hover color as darker + return Color.FromArgb(BackColor.A, (BackColor.R + 50), (BackColor.G + 50), (BackColor.B + 50)); + } + } + + private String generateMD5Hash(String s) + { + using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create()) + { + byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(s); + byte[] hashBytes = md5.ComputeHash(inputBytes); + + + StringBuilder sb = new System.Text.StringBuilder(); + for (int i = 0; i < hashBytes.Length; i++) + { + sb.Append(hashBytes[i].ToString("X2")); + } + return sb.ToString(); + } + } + // // END OF CLASS // + + public static void closeBackgroundApp(string path = "") + { + Process[] pname = Process.GetProcessesByName(Path.GetFileNameWithoutExtension("Taskbar Groups Background")); + if (pname.Length != 0) + { + Process bkg = pname[0]; + + Process p = new Process(); + if (path == "") + { + path = Paths.BackgroundApplication; + } + p.StartInfo.FileName = path; + p.StartInfo.Arguments = "exitApplicationModeReserved"; + p.Start(); + + if(!bkg.WaitForExit(2000)) + { + bkg.Kill(); + } + } + + } } } diff --git a/main/Classes/MainPath.cs b/main/Classes/MainPath.cs deleted file mode 100644 index 8f60c2e..0000000 --- a/main/Classes/MainPath.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace client.Classes -{ - // Function that is accessed by all forms to get the starting absolute path of the .exe - // Added as to not keep generating the path in each form - static class MainPath - { - public static String path; - public static String exeString; - } -} diff --git a/main/Classes/Paths.cs b/main/Classes/Paths.cs new file mode 100644 index 0000000..28f06f7 --- /dev/null +++ b/main/Classes/Paths.cs @@ -0,0 +1,175 @@ +using client.Properties; +using IWshRuntimeLibrary; +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Security.Cryptography; + +namespace client.Classes +{ + // Function that is accessed by all forms to get the starting absolute path of the .exe + // Added as to not keep generating the path in each form + static class Paths + { + /// + /// The full path to the application's main executable. + /// + public static String exeString = System.Reflection.Assembly.GetExecutingAssembly().Location; + + public static String exeFolder = AppDomain.CurrentDomain.BaseDirectory; + + /// + /// The folder in which the main executable resides. + /// + public static String path = System.IO.Path.GetDirectoryName(exeString); + + public static String defaultConfigPath; + public static String defaultShortcutsPath; + public static String defaultBackgroundPath; + + public static bool justWritten = false; + + static Paths() + { + + } + + private static string AppDataRelativePath + { + get + { + return System.IO.Path.Combine("Jack Schierbeck", "taskbar-groups"); + } + } + + public static string ConfigPath = setupConfigPath(); + public static string BackgroundApplication = setupBackgroundApplication(); + public static string ShortcutsPath = setupShortcutsPath(); + + private static string setupConfigPath() + { + string directoryPath; + defaultConfigPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataRelativePath, "config"); + if (!Settings.settingInfo.portableMode) + { + directoryPath = defaultConfigPath; + } + else + { + directoryPath = Path.Combine(exeFolder, "config"); + } + + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + + return directoryPath; + } + + private static string setupShortcutsPath() + { + string directoryPath; + defaultShortcutsPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataRelativePath, "Shortcuts"); + if (!Settings.settingInfo.portableMode) + { + directoryPath = defaultShortcutsPath; + } + else + { + directoryPath = Path.Combine(exeFolder, "Shortcuts"); + } + + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + + return directoryPath; + } + + public static string OptimizationProfilePath + { + get + { + string directoryPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataRelativePath, "JITComp"); + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + return directoryPath; + } + } + + private static string setupBackgroundApplication() + { + Directory.CreateDirectory(Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataRelativePath)); + + string filePath; + defaultBackgroundPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataRelativePath, "Taskbar Groups Background.exe"); + + if (!Settings.settingInfo.portableMode) + { + filePath = defaultBackgroundPath; + } + else + { + filePath = Path.Combine(exeFolder, "Taskbar Groups Background.exe"); + } + + if (!System.IO.File.Exists(filePath)) + { + System.IO.File.WriteAllBytes(filePath, Resources.Taskbar_Groups_Background); + + justWritten = true; + } else + { + byte[] fileHash; + byte[] localHash; + using (var md5 = MD5.Create()) + { + using (MemoryStream memStream = new MemoryStream(Resources.Taskbar_Groups_Background)) + { + using (var stream = System.IO.File.OpenRead(filePath)) + { + fileHash = md5.ComputeHash(stream); + } + + localHash = md5.ComputeHash(memStream); + } + + + } + + if (fileHash.SequenceEqual(localHash) == false) + { + Category.closeBackgroundApp(filePath); + System.IO.File.WriteAllBytes(filePath, Resources.Taskbar_Groups_Background); + + justWritten = true; + } + } + + return filePath; + } + + private static string setupMainClientShortcut() + { + string filePath = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataRelativePath, "Taskbar Group Editor.lnk"); + // Regenerate .lnk every time (doing the entire process to check it is just more tedious and most likely more computationally expensive. + string shortcutLocation = System.IO.Path.Combine(filePath); + WshShell shell = new WshShell(); + IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation); + + shortcut.Description = "Shortcut for Edit Group context menu feature"; // The description of the shortcut + shortcut.TargetPath = Paths.exeString; // The path of the file that will launch when the shortcut is run + shortcut.Save(); + return filePath; + } + + + public static string MainClientShortcut = setupMainClientShortcut(); + } +} diff --git a/main/Classes/ProgramShortcut.cs b/main/Classes/ProgramShortcut.cs index 8df8ccb..f26c37d 100644 --- a/main/Classes/ProgramShortcut.cs +++ b/main/Classes/ProgramShortcut.cs @@ -7,7 +7,7 @@ public class ProgramShortcut public string name { get; set; } = ""; public string Arguments = ""; - public string WorkingDirectory = MainPath.exeString; + public string WorkingDirectory = Paths.exeString; public ProgramShortcut() // needed for XML serialization diff --git a/main/Classes/ScreenExtensions.cs b/main/Classes/ScreenExtensions.cs new file mode 100644 index 0000000..c5e0713 --- /dev/null +++ b/main/Classes/ScreenExtensions.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace client.Classes +{ + // Get DPI function below + public static class ScreenExtensions + { + public static void GetDpi(this System.Windows.Forms.Screen screen, DpiType dpiType, out uint dpiX, out uint dpiY) + { + var pnt = new System.Drawing.Point(screen.Bounds.Left + 1, screen.Bounds.Top + 1); + var mon = MonitorFromPoint(pnt, 2/*MONITOR_DEFAULTTONEAREST*/); + GetDpiForMonitor(mon, dpiType, out dpiX, out dpiY); + } + + //https://msdn.microsoft.com/en-us/library/windows/desktop/dd145062(v=vs.85).aspx + [DllImport("User32.dll")] + private static extern IntPtr MonitorFromPoint([In] System.Drawing.Point pt, [In] uint dwFlags); + + //https://msdn.microsoft.com/en-us/library/windows/desktop/dn280510(v=vs.85).aspx + [DllImport("Shcore.dll")] + private static extern IntPtr GetDpiForMonitor([In] IntPtr hmonitor, [In] DpiType dpiType, [Out] out uint dpiX, [Out] out uint dpiY); + } + + //https://msdn.microsoft.com/en-us/library/windows/desktop/dn280511(v=vs.85).aspx + public enum DpiType + { + Effective = 0, + Angular = 1, + Raw = 2, + } +} diff --git a/main/Classes/Settings.cs b/main/Classes/Settings.cs new file mode 100644 index 0000000..f5f3c19 --- /dev/null +++ b/main/Classes/Settings.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Serialization; + +namespace client.Classes +{ + static class Settings + { + private static string appDataRelative = System.IO.Path.Combine("Jack Schierbeck", "taskbar-groups"); + public static string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), appDataRelative, "Settings.xml"); + public static string defaultSettingsPath; + public static Setting settingInfo; + + static Settings() + { + defaultSettingsPath = settingsPath; + if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.xml"))) + { + settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.xml"); + } + else if (!File.Exists(settingsPath)) + { + Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), appDataRelative)); + settingInfo = new Setting(); + writeXML(); + return; + } + + System.Xml.Serialization.XmlSerializer reader = + new System.Xml.Serialization.XmlSerializer(typeof(Setting)); + using (StreamReader file = new StreamReader(settingsPath)) + { + settingInfo = (Setting)reader.Deserialize(file); + file.Close(); + } + + if (settingInfo.portableMode == true && !File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.xml"))) + { + settingInfo.portableMode = false; + writeXML(); + } + + } + + public static void writeXML() + { + try + { + System.Xml.Serialization.XmlSerializer writer = + new System.Xml.Serialization.XmlSerializer(typeof(Setting)); + + using (FileStream file = System.IO.File.Create(settingsPath)) + { + writer.Serialize(file, settingInfo); + file.Close(); + } + }catch(IOException e) + { + DialogResult result = MessageBox.Show("Settings.xml may be open in another file.\r\n\r\nError: " + e.Message, "Exit", MessageBoxButtons.OK); + Environment.Exit(4); + } + } + } + + [Serializable()] + public class Setting + { + [XmlElement] + public bool portableMode { get; set; } = false; + } +} diff --git a/main/Classes/WindowsLnkFile.cs b/main/Classes/WindowsLnkFile.cs new file mode 100644 index 0000000..ed70c53 --- /dev/null +++ b/main/Classes/WindowsLnkFile.cs @@ -0,0 +1,658 @@ +// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild +// Generated/taken from https://formats.kaitai.io/windows_lnk_file/csharp.html (cc0-1.0) + + +namespace Kaitai +{ + + /// + /// Windows .lnk files (AKA "shell link" file) are most frequently used + /// in Windows shell to create "shortcuts" to another files, usually for + /// purposes of running a program from some other directory, sometimes + /// with certain preconfigured arguments and some other options. + /// + /// + /// Reference: Source + /// + public partial class WindowsLnkFile : KaitaiStruct + { + public static WindowsLnkFile FromFile(string fileName) + { + using (var k = new KaitaiStream(fileName)) + { + return new WindowsLnkFile(k); + } + } + + + public enum WindowState + { + Normal = 1, + Maximized = 3, + MinNoActive = 7, + } + + public enum DriveTypes + { + Unknown = 0, + NoRootDir = 1, + Removable = 2, + Fixed = 3, + Remote = 4, + Cdrom = 5, + Ramdisk = 6, + } + public WindowsLnkFile(KaitaiStream p__io, KaitaiStruct p__parent = null, WindowsLnkFile p__root = null) : base(p__io) + { + m_parent = p__parent; + m_root = p__root ?? this; + _read(); + } + private void _read() + { + _header = new FileHeader(m_io, this, m_root); + if (Header.Flags.HasLinkTargetIdList) { + _targetIdList = new LinkTargetIdList(m_io, this, m_root); + } + if (Header.Flags.HasLinkInfo) { + _info = new LinkInfo(m_io, this, m_root); + } + if (Header.Flags.HasName) { + _name = new StringData(m_io, this, m_root); + } + if (Header.Flags.HasRelPath) { + _relPath = new StringData(m_io, this, m_root); + } + if (Header.Flags.HasWorkDir) { + _workDir = new StringData(m_io, this, m_root); + } + if (Header.Flags.HasArguments) { + _arguments = new StringData(m_io, this, m_root); + } + if (Header.Flags.HasIconLocation) { + _iconLocation = new StringData(m_io, this, m_root); + } + } + + /// + /// Reference: Section 2.2 + /// + public partial class LinkTargetIdList : KaitaiStruct + { + public static LinkTargetIdList FromFile(string fileName) + { + using (var k = new KaitaiStream(fileName)) + { + return new LinkTargetIdList(k); + } + } + + public LinkTargetIdList(KaitaiStream p__io, WindowsLnkFile p__parent = null, WindowsLnkFile p__root = null) : base(p__io) + { + m_parent = p__parent; + m_root = p__root; + _read(); + } + private void _read() + { + _lenIdList = m_io.ReadU2le(); + __raw_idList = m_io.ReadBytes(LenIdList); + } + private ushort _lenIdList; + private WindowsLnkFile m_root; + private WindowsLnkFile m_parent; + private byte[] __raw_idList; + public ushort LenIdList { get { return _lenIdList; } } + public WindowsLnkFile M_Root { get { return m_root; } } + public WindowsLnkFile M_Parent { get { return m_parent; } } + public byte[] M_RawIdList { get { return __raw_idList; } } + } + public partial class StringData : KaitaiStruct + { + public static StringData FromFile(string fileName) + { + using (var k = new KaitaiStream(fileName)) + { + return new StringData(k); + } + + } + + public StringData(KaitaiStream p__io, WindowsLnkFile p__parent = null, WindowsLnkFile p__root = null) : base(p__io) + { + m_parent = p__parent; + m_root = p__root; + _read(); + } + private void _read() + { + _charsStr = m_io.ReadU2le(); + _str = System.Text.Encoding.GetEncoding("UTF-16LE").GetString(m_io.ReadBytes((CharsStr * 2))); + } + private ushort _charsStr; + private string _str; + private WindowsLnkFile m_root; + private WindowsLnkFile m_parent; + public ushort CharsStr { get { return _charsStr; } } + public string Str { get { return _str; } } + public WindowsLnkFile M_Root { get { return m_root; } } + public WindowsLnkFile M_Parent { get { return m_parent; } } + } + + /// + /// Reference: Section 2.3 + /// + public partial class LinkInfo : KaitaiStruct + { + public static LinkInfo FromFile(string fileName) + { + using (var k = new KaitaiStream(fileName)) + { + return new LinkInfo(k); + } + } + + public LinkInfo(KaitaiStream p__io, WindowsLnkFile p__parent = null, WindowsLnkFile p__root = null) : base(p__io) + { + m_parent = p__parent; + m_root = p__root; + _read(); + } + private void _read() + { + _lenAll = m_io.ReadU4le(); + __raw_all = m_io.ReadBytes((LenAll - 4)); + using (var io___raw_all = new KaitaiStream(__raw_all)) + { + _all = new All(io___raw_all, this, m_root); + } + } + + /// + /// Reference: Section 2.3.1 + /// + public partial class VolumeIdBody : KaitaiStruct + { + public static VolumeIdBody FromFile(string fileName) + { + using (var k = new KaitaiStream(fileName)) + { + return new VolumeIdBody(k); + } + } + + public VolumeIdBody(KaitaiStream p__io, WindowsLnkFile.LinkInfo.VolumeIdSpec p__parent = null, WindowsLnkFile p__root = null) : base(p__io) + { + m_parent = p__parent; + m_root = p__root; + f_isUnicode = false; + f_volumeLabelAnsi = false; + _read(); + } + private void _read() + { + _driveType = ((WindowsLnkFile.DriveTypes) m_io.ReadU4le()); + _driveSerialNumber = m_io.ReadU4le(); + _ofsVolumeLabel = m_io.ReadU4le(); + if (IsUnicode) { + _ofsVolumeLabelUnicode = m_io.ReadU4le(); + } + } + private bool f_isUnicode; + private bool _isUnicode; + public bool IsUnicode + { + get + { + if (f_isUnicode) + return _isUnicode; + _isUnicode = (bool) (OfsVolumeLabel == 20); + f_isUnicode = true; + return _isUnicode; + } + } + private bool f_volumeLabelAnsi; + private string _volumeLabelAnsi; + public string VolumeLabelAnsi + { + get + { + if (f_volumeLabelAnsi) + return _volumeLabelAnsi; + if (!(IsUnicode)) { + long _pos = m_io.Pos; + m_io.Seek((OfsVolumeLabel - 4)); + _volumeLabelAnsi = System.Text.Encoding.GetEncoding("cp437").GetString(m_io.ReadBytesTerm(0, false, true, true)); + m_io.Seek(_pos); + f_volumeLabelAnsi = true; + } + return _volumeLabelAnsi; + } + } + private DriveTypes _driveType; + private uint _driveSerialNumber; + private uint _ofsVolumeLabel; + private uint? _ofsVolumeLabelUnicode; + private WindowsLnkFile m_root; + private WindowsLnkFile.LinkInfo.VolumeIdSpec m_parent; + public DriveTypes DriveType { get { return _driveType; } } + public uint DriveSerialNumber { get { return _driveSerialNumber; } } + public uint OfsVolumeLabel { get { return _ofsVolumeLabel; } } + public uint? OfsVolumeLabelUnicode { get { return _ofsVolumeLabelUnicode; } } + public WindowsLnkFile M_Root { get { return m_root; } } + public WindowsLnkFile.LinkInfo.VolumeIdSpec M_Parent { get { return m_parent; } } + } + + /// + /// Reference: Section 2.3 + /// + public partial class All : KaitaiStruct + { + public static All FromFile(string fileName) + { + using (var k = new KaitaiStream(fileName)) + { + return new All(k); + } + } + + public All(KaitaiStream p__io, WindowsLnkFile.LinkInfo p__parent = null, WindowsLnkFile p__root = null) : base(p__io) + { + m_parent = p__parent; + m_root = p__root; + f_volumeId = false; + f_localBasePath = false; + _read(); + } + private void _read() + { + _lenHeader = m_io.ReadU4le(); + __raw_header = m_io.ReadBytes((LenHeader - 8)); + using (var io___raw_header = new KaitaiStream(__raw_header)) + { + _header = new Header(io___raw_header, this, m_root); + } + } + private bool f_volumeId; + private VolumeIdSpec _volumeId; + public VolumeIdSpec VolumeId + { + get + { + if (f_volumeId) + return _volumeId; + if (Header.Flags.HasVolumeIdAndLocalBasePath) { + long _pos = m_io.Pos; + m_io.Seek((Header.OfsVolumeId - 4)); + _volumeId = new VolumeIdSpec(m_io, this, m_root); + m_io.Seek(_pos); + f_volumeId = true; + } + return _volumeId; + } + } + private bool f_localBasePath; + private byte[] _localBasePath; + public byte[] LocalBasePath + { + get + { + if (f_localBasePath) + return _localBasePath; + if (Header.Flags.HasVolumeIdAndLocalBasePath) { + long _pos = m_io.Pos; + m_io.Seek((Header.OfsLocalBasePath - 4)); + _localBasePath = m_io.ReadBytesTerm(0, false, true, true); + m_io.Seek(_pos); + f_localBasePath = true; + } + return _localBasePath; + } + } + private uint _lenHeader; + private Header _header; + private WindowsLnkFile m_root; + private WindowsLnkFile.LinkInfo m_parent; + private byte[] __raw_header; + public uint LenHeader { get { return _lenHeader; } } + public Header Header { get { return _header; } } + public WindowsLnkFile M_Root { get { return m_root; } } + public WindowsLnkFile.LinkInfo M_Parent { get { return m_parent; } } + public byte[] M_RawHeader { get { return __raw_header; } } + } + + /// + /// Reference: Section 2.3.1 + /// + public partial class VolumeIdSpec : KaitaiStruct + { + public static VolumeIdSpec FromFile(string fileName) + { + + using (var k = new KaitaiStream(fileName)) + { + return new VolumeIdSpec(k); + } + } + + public VolumeIdSpec(KaitaiStream p__io, WindowsLnkFile.LinkInfo.All p__parent = null, WindowsLnkFile p__root = null) : base(p__io) + { + m_parent = p__parent; + m_root = p__root; + _read(); + } + private void _read() + { + _lenAll = m_io.ReadU4le(); + __raw_body = m_io.ReadBytes((LenAll - 4)); + using (var io___raw_body = new KaitaiStream(__raw_body)) + { + + _body = new VolumeIdBody(io___raw_body, this, m_root); + } + } + private uint _lenAll; + private VolumeIdBody _body; + private WindowsLnkFile m_root; + private WindowsLnkFile.LinkInfo.All m_parent; + private byte[] __raw_body; + public uint LenAll { get { return _lenAll; } } + public VolumeIdBody Body { get { return _body; } } + public WindowsLnkFile M_Root { get { return m_root; } } + public WindowsLnkFile.LinkInfo.All M_Parent { get { return m_parent; } } + public byte[] M_RawBody { get { return __raw_body; } } + } + + /// + /// Reference: Section 2.3 + /// + public partial class LinkInfoFlags : KaitaiStruct + { + public static LinkInfoFlags FromFile(string fileName) + { + using (var k = new KaitaiStream(fileName)) + { + return new LinkInfoFlags(k); + } + } + + public LinkInfoFlags(KaitaiStream p__io, WindowsLnkFile.LinkInfo.Header p__parent = null, WindowsLnkFile p__root = null) : base(p__io) + { + m_parent = p__parent; + m_root = p__root; + _read(); + } + private void _read() + { + _reserved1 = m_io.ReadBitsIntBe(6); + _hasCommonNetRelLink = m_io.ReadBitsIntBe(1) != 0; + _hasVolumeIdAndLocalBasePath = m_io.ReadBitsIntBe(1) != 0; + _reserved2 = m_io.ReadBitsIntBe(24); + } + private ulong _reserved1; + private bool _hasCommonNetRelLink; + private bool _hasVolumeIdAndLocalBasePath; + private ulong _reserved2; + private WindowsLnkFile m_root; + private WindowsLnkFile.LinkInfo.Header m_parent; + public ulong Reserved1 { get { return _reserved1; } } + public bool HasCommonNetRelLink { get { return _hasCommonNetRelLink; } } + public bool HasVolumeIdAndLocalBasePath { get { return _hasVolumeIdAndLocalBasePath; } } + public ulong Reserved2 { get { return _reserved2; } } + public WindowsLnkFile M_Root { get { return m_root; } } + public WindowsLnkFile.LinkInfo.Header M_Parent { get { return m_parent; } } + } + + /// + /// Reference: Section 2.3 + /// + public partial class Header : KaitaiStruct + { + public static Header FromFile(string fileName) + { + using (var k = new KaitaiStream(fileName)) + { + return new Header(k); + } + } + + public Header(KaitaiStream p__io, WindowsLnkFile.LinkInfo.All p__parent = null, WindowsLnkFile p__root = null) : base(p__io) + { + m_parent = p__parent; + m_root = p__root; + _read(); + } + private void _read() + { + _flags = new LinkInfoFlags(m_io, this, m_root); + _ofsVolumeId = m_io.ReadU4le(); + _ofsLocalBasePath = m_io.ReadU4le(); + _ofsCommonNetRelLink = m_io.ReadU4le(); + _ofsCommonPathSuffix = m_io.ReadU4le(); + if (!(M_Io.IsEof)) { + _ofsLocalBasePathUnicode = m_io.ReadU4le(); + } + if (!(M_Io.IsEof)) { + _ofsCommonPathSuffixUnicode = m_io.ReadU4le(); + } + } + private LinkInfoFlags _flags; + private uint _ofsVolumeId; + private uint _ofsLocalBasePath; + private uint _ofsCommonNetRelLink; + private uint _ofsCommonPathSuffix; + private uint? _ofsLocalBasePathUnicode; + private uint? _ofsCommonPathSuffixUnicode; + private WindowsLnkFile m_root; + private WindowsLnkFile.LinkInfo.All m_parent; + public LinkInfoFlags Flags { get { return _flags; } } + public uint OfsVolumeId { get { return _ofsVolumeId; } } + public uint OfsLocalBasePath { get { return _ofsLocalBasePath; } } + public uint OfsCommonNetRelLink { get { return _ofsCommonNetRelLink; } } + public uint OfsCommonPathSuffix { get { return _ofsCommonPathSuffix; } } + public uint? OfsLocalBasePathUnicode { get { return _ofsLocalBasePathUnicode; } } + public uint? OfsCommonPathSuffixUnicode { get { return _ofsCommonPathSuffixUnicode; } } + public WindowsLnkFile M_Root { get { return m_root; } } + public WindowsLnkFile.LinkInfo.All M_Parent { get { return m_parent; } } + } + private uint _lenAll; + private All _all; + private WindowsLnkFile m_root; + private WindowsLnkFile m_parent; + private byte[] __raw_all; + public uint LenAll { get { return _lenAll; } } + public WindowsLnkFile M_Root { get { return m_root; } } + public WindowsLnkFile M_Parent { get { return m_parent; } } + public byte[] M_RawAll { get { return __raw_all; } } + } + + /// + /// Reference: Section 2.1.1 + /// + public partial class LinkFlags : KaitaiStruct + { + public static LinkFlags FromFile(string fileName) + { + using (var k = new KaitaiStream(fileName)) + { + return new LinkFlags(k); + } + + } + + public LinkFlags(KaitaiStream p__io, WindowsLnkFile.FileHeader p__parent = null, WindowsLnkFile p__root = null) : base(p__io) + { + m_parent = p__parent; + m_root = p__root; + _read(); + } + private void _read() + { + _isUnicode = m_io.ReadBitsIntBe(1) != 0; + _hasIconLocation = m_io.ReadBitsIntBe(1) != 0; + _hasArguments = m_io.ReadBitsIntBe(1) != 0; + _hasWorkDir = m_io.ReadBitsIntBe(1) != 0; + _hasRelPath = m_io.ReadBitsIntBe(1) != 0; + _hasName = m_io.ReadBitsIntBe(1) != 0; + _hasLinkInfo = m_io.ReadBitsIntBe(1) != 0; + _hasLinkTargetIdList = m_io.ReadBitsIntBe(1) != 0; + __unnamed8 = m_io.ReadBitsIntBe(16); + _reserved = m_io.ReadBitsIntBe(5); + _keepLocalIdListForUncTarget = m_io.ReadBitsIntBe(1) != 0; + __unnamed11 = m_io.ReadBitsIntBe(2); + } + private bool _isUnicode; + private bool _hasIconLocation; + private bool _hasArguments; + private bool _hasWorkDir; + private bool _hasRelPath; + private bool _hasName; + private bool _hasLinkInfo; + private bool _hasLinkTargetIdList; + private ulong __unnamed8; + private ulong _reserved; + private bool _keepLocalIdListForUncTarget; + private ulong __unnamed11; + private WindowsLnkFile m_root; + private WindowsLnkFile.FileHeader m_parent; + public bool IsUnicode { get { return _isUnicode; } } + public bool HasIconLocation { get { return _hasIconLocation; } } + public bool HasArguments { get { return _hasArguments; } } + public bool HasWorkDir { get { return _hasWorkDir; } } + public bool HasRelPath { get { return _hasRelPath; } } + public bool HasName { get { return _hasName; } } + public bool HasLinkInfo { get { return _hasLinkInfo; } } + public bool HasLinkTargetIdList { get { return _hasLinkTargetIdList; } } + public ulong Unnamed_8 { get { return __unnamed8; } } + public ulong Reserved { get { return _reserved; } } + public bool KeepLocalIdListForUncTarget { get { return _keepLocalIdListForUncTarget; } } + public ulong Unnamed_11 { get { return __unnamed11; } } + public WindowsLnkFile M_Root { get { return m_root; } } + public WindowsLnkFile.FileHeader M_Parent { get { return m_parent; } } + } + + /// + /// Reference: Section 2.1 + /// + public partial class FileHeader : KaitaiStruct + { + public static FileHeader FromFile(string fileName) + { + using (var k = new KaitaiStream(fileName)) + { + return new FileHeader(k); + } + } + + public FileHeader(KaitaiStream p__io, WindowsLnkFile p__parent = null, WindowsLnkFile p__root = null) : base(p__io) + { + m_parent = p__parent; + m_root = p__root; + _read(); + } + private void _read() + { + _lenHeader = m_io.ReadBytes(4); + if (!((KaitaiStream.ByteArrayCompare(LenHeader, new byte[] { 76, 0, 0, 0 }) == 0))) + { + throw new ValidationNotEqualError(new byte[] { 76, 0, 0, 0 }, LenHeader, M_Io, "/types/file_header/seq/0"); + } + _linkClsid = m_io.ReadBytes(16); + if (!((KaitaiStream.ByteArrayCompare(LinkClsid, new byte[] { 1, 20, 2, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70 }) == 0))) + { + throw new ValidationNotEqualError(new byte[] { 1, 20, 2, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70 }, LinkClsid, M_Io, "/types/file_header/seq/1"); + } + __raw_flags = m_io.ReadBytes(4); + using (var io___raw_flags = new KaitaiStream(__raw_flags)) + { + _flags = new LinkFlags(io___raw_flags, this, m_root); + _fileAttrs = m_io.ReadU4le(); + _timeCreation = m_io.ReadU8le(); + _timeAccess = m_io.ReadU8le(); + _timeWrite = m_io.ReadU8le(); + _targetFileSize = m_io.ReadU4le(); + _iconIndex = m_io.ReadS4le(); + _showCommand = ((WindowsLnkFile.WindowState)m_io.ReadU4le()); + _hotkey = m_io.ReadU2le(); + _reserved = m_io.ReadBytes(10); + if (!((KaitaiStream.ByteArrayCompare(Reserved, new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }) == 0))) + { + throw new ValidationNotEqualError(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Reserved, M_Io, "/types/file_header/seq/11"); + } + } + } + private byte[] _lenHeader; + private byte[] _linkClsid; + private LinkFlags _flags; + private uint _fileAttrs; + private ulong _timeCreation; + private ulong _timeAccess; + private ulong _timeWrite; + private uint _targetFileSize; + private int _iconIndex; + private WindowState _showCommand; + private ushort _hotkey; + private byte[] _reserved; + private WindowsLnkFile m_root; + private WindowsLnkFile m_parent; + private byte[] __raw_flags; + + /// + /// Technically, a size of the header, but in reality, it's + /// fixed by standard. + /// + public byte[] LenHeader { get { return _lenHeader; } } + + /// + /// 16-byte class identified (CLSID), reserved for Windows shell + /// link files. + /// + public byte[] LinkClsid { get { return _linkClsid; } } + public LinkFlags Flags { get { return _flags; } } + public uint FileAttrs { get { return _fileAttrs; } } + public ulong TimeCreation { get { return _timeCreation; } } + public ulong TimeAccess { get { return _timeAccess; } } + public ulong TimeWrite { get { return _timeWrite; } } + + /// + /// Lower 32 bits of the size of the file that this link targets + /// + public uint TargetFileSize { get { return _targetFileSize; } } + + /// + /// Index of an icon to use from target file + /// + public int IconIndex { get { return _iconIndex; } } + + /// + /// Window state to set after the launch of target executable + /// + public WindowState ShowCommand { get { return _showCommand; } } + public ushort Hotkey { get { return _hotkey; } } + public byte[] Reserved { get { return _reserved; } } + public WindowsLnkFile M_Root { get { return m_root; } } + public WindowsLnkFile M_Parent { get { return m_parent; } } + public byte[] M_RawFlags { get { return __raw_flags; } } + } + private FileHeader _header; + private LinkTargetIdList _targetIdList; + private LinkInfo _info; + private StringData _name; + private StringData _relPath; + private StringData _workDir; + private StringData _arguments; + private StringData _iconLocation; + private WindowsLnkFile m_root; + private KaitaiStruct m_parent; + public FileHeader Header { get { return _header; } } + public LinkTargetIdList TargetIdList { get { return _targetIdList; } } + public LinkInfo Info { get { return _info; } } + public StringData Name { get { return _name; } } + public StringData RelPath { get { return _relPath; } } + public StringData WorkDir { get { return _workDir; } } + public StringData Arguments { get { return _arguments; } } + public StringData IconLocation { get { return _iconLocation; } } + public WindowsLnkFile M_Root { get { return m_root; } } + public KaitaiStruct M_Parent { get { return m_parent; } } + } +} diff --git a/main/Classes/handleWindowsApp.cs b/main/Classes/handleWindowsApp.cs index 2d9eafa..26dd8ef 100644 --- a/main/Classes/handleWindowsApp.cs +++ b/main/Classes/handleWindowsApp.cs @@ -5,18 +5,21 @@ using System.Xml; using System.Collections.Generic; using Windows.Management.Deployment; +using System.Text.RegularExpressions; +using System.Runtime.InteropServices; namespace client.Classes { class handleWindowsApp { + public static Dictionary fileDirectoryCache = new Dictionary(); private static PackageManager pkgManger = new PackageManager(); public static Bitmap getWindowsAppIcon(String file, bool alreadyAppID = false) { // Get the app's ID from its shortcut target file (Ex. 4DF9E0F8.Netflix_mcm4njqhnhss8!Netflix.app) - String microsoftAppName = (!alreadyAppID) ? GetLnkTarget(file) : file; + String microsoftAppName = (!alreadyAppID) ? GetLnkTarget(file)[0] : file; // Split the string to get the app name from the beginning (Ex. 4DF9E0F8.Netflix) String subAppName = microsoftAppName.Split('!')[0]; @@ -26,43 +29,50 @@ public static Bitmap getWindowsAppIcon(String file, bool alreadyAppID = false) // Load and read manifest to get the logo path XmlDocument appManifest = new XmlDocument(); - appManifest.Load(appPath + "\\AppxManifest.xml"); + appManifest.Load(Path.Combine(appPath, "AppxManifest.xml")); XmlNamespaceManager appManifestNamespace = new XmlNamespaceManager(new NameTable()); appManifestNamespace.AddNamespace("sm", "http://schemas.microsoft.com/appx/manifest/foundation/windows10"); String logoLocation = (appManifest.SelectSingleNode("/sm:Package/sm:Properties/sm:Logo", appManifestNamespace).InnerText).Replace("\\", @"\"); + String logoPNG = ""; - - - if (logoLocation != null) + if (logoLocation != null && logoLocation != "") { // Get the last instance or usage of \ to cut out the path of the logo just to have the path leading to the general logo folder - logoLocation = logoLocation.Substring(0, logoLocation.LastIndexOf(@"\")); - String logoLocationFullPath = Path.GetFullPath(appPath + "\\" + logoLocation); + int lastIndexOf = logoLocation.LastIndexOf(@"\"); + String logoLocationFullPath; + + if (lastIndexOf != -1) + { + logoPNG = logoLocation.Substring(lastIndexOf + 1, logoLocation.LastIndexOf(@".") - lastIndexOf - 1); + logoLocation = logoLocation.Substring(0, lastIndexOf); + logoLocationFullPath = Path.GetFullPath(Path.Combine(appPath, logoLocation)); + } else + { + logoPNG = logoLocation; + logoLocationFullPath = Path.GetFullPath(appPath + "\\"); + } + // Search for all files with 150x150 in its name and use the first result DirectoryInfo logoDirectory = new DirectoryInfo(logoLocationFullPath); - FileInfo[] filesInDir = getLogoFolder("StoreLogo", logoDirectory); + + + String[] keysToTest = { logoPNG, "scale-200","StoreLogo"}; - if (filesInDir.Length != 0) - { - return getLogo(filesInDir.Last().FullName, file); - } - else - { - filesInDir = getLogoFolder("scale-200", logoDirectory); + for (int i=0; i packages = pkgManger.FindPackagesForUser("", subAppName); - - String finalPath = Environment.ExpandEnvironmentVariables("%ProgramW6432%") + $@"\WindowsApps\" + packages.First().InstalledLocation.DisplayName + @"\"; + // TODO: This should probably use Path.Combine(). + var test = packages.First(); + //String finalPath = Environment.ExpandEnvironmentVariables("%ProgramW6432%") + $@"\WindowsApps\" + packages.First().InstalledLocation.DisplayName + @"\"; + String finalPath = packages.First().InstalledLocation.Path; fileDirectoryCache[subAppName] = finalPath; return finalPath; } @@ -131,7 +145,7 @@ public static string findWindowsAppsName(string AppName) // Load and read manifest to get the logo path XmlDocument appManifest = new XmlDocument(); - appManifest.Load(appPath + "\\AppxManifest.xml"); + appManifest.Load(Path.Combine(appPath, "AppxManifest.xml")); XmlNamespaceManager appManifestNamespace = new XmlNamespaceManager(new NameTable()); appManifestNamespace.AddNamespace("sm", "http://schemas.microsoft.com/appx/manifest/foundation/windows10"); @@ -139,10 +153,10 @@ public static string findWindowsAppsName(string AppName) try { - return appManifest.SelectSingleNode("/sm:Package/sm:Applications/sm:Application/uap:VisualElements", appManifestNamespace).Attributes.GetNamedItem("DisplayName").InnerText; + return appManifest.SelectSingleNode("/sm:Package/sm:Properties/sm:DisplayName", appManifestNamespace).InnerText; } catch (Exception) { - return appManifest.SelectSingleNode("/sm:Package/sm:Properties/sm:DisplayName", appManifestNamespace).InnerText; + return appManifest.SelectSingleNode("/sm:Package/sm:Applications/sm:Application/uap:VisualElements", appManifestNamespace).Attributes.GetNamedItem("DisplayName").InnerText; } } } diff --git a/main/Forms/frmClient.Designer.cs b/main/Forms/frmClient.Designer.cs index db058e4..99386a1 100644 --- a/main/Forms/frmClient.Designer.cs +++ b/main/Forms/frmClient.Designer.cs @@ -30,71 +30,121 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmClient)); this.pnlLeftColumn = new System.Windows.Forms.Panel(); + this.lblHelpTitle = new System.Windows.Forms.Label(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.pnlVersionInfo = new System.Windows.Forms.Panel(); + this.githubLink = new System.Windows.Forms.LinkLabel(); this.label6 = new System.Windows.Forms.Label(); this.currentVersion = new System.Windows.Forms.Label(); this.githubVersion = new System.Windows.Forms.Label(); - this.githubLink = new System.Windows.Forms.LinkLabel(); this.githubLabel = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); + this.panel2 = new System.Windows.Forms.Panel(); + this.portabilityButton = new System.Windows.Forms.Button(); + this.label8 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label11 = new System.Windows.Forms.Label(); this.pnlHelp = new System.Windows.Forms.Panel(); + this.label5 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.lblHelp1 = new System.Windows.Forms.Label(); this.lblHelp3 = new System.Windows.Forms.Label(); this.lblHelp2 = new System.Windows.Forms.Label(); - this.lblHelpTitle = new System.Windows.Forms.Label(); - this.pnlAddGroup = new System.Windows.Forms.Panel(); - this.lblAddGroup = new System.Windows.Forms.Label(); - this.cmdAddGroup = new System.Windows.Forms.PictureBox(); this.label1 = new System.Windows.Forms.Label(); this.panel1 = new System.Windows.Forms.Panel(); this.label2 = new System.Windows.Forms.Label(); - this.pnlExistingGroups = new System.Windows.Forms.Panel(); - this.pnlBottomMain = new System.Windows.Forms.Panel(); + this.pnlExistingShortcuts = new System.Windows.Forms.TableLayoutPanel(); + this.pnlAddGroup = new System.Windows.Forms.Panel(); + this.lblAddGroup = new System.Windows.Forms.Label(); + this.cmdAddGroup = new System.Windows.Forms.PictureBox(); this.pnlLeftColumn.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); this.pnlVersionInfo.SuspendLayout(); + this.panel2.SuspendLayout(); this.pnlHelp.SuspendLayout(); + this.panel1.SuspendLayout(); this.pnlAddGroup.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.cmdAddGroup)).BeginInit(); - this.panel1.SuspendLayout(); - this.pnlBottomMain.SuspendLayout(); this.SuspendLayout(); // // pnlLeftColumn // + this.pnlLeftColumn.AutoSize = true; this.pnlLeftColumn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); - this.pnlLeftColumn.Controls.Add(this.pnlVersionInfo); - this.pnlLeftColumn.Controls.Add(this.pnlHelp); this.pnlLeftColumn.Controls.Add(this.lblHelpTitle); + this.pnlLeftColumn.Controls.Add(this.tableLayoutPanel2); + this.pnlLeftColumn.Dock = System.Windows.Forms.DockStyle.Left; this.pnlLeftColumn.ImeMode = System.Windows.Forms.ImeMode.On; this.pnlLeftColumn.Location = new System.Drawing.Point(0, 0); this.pnlLeftColumn.Name = "pnlLeftColumn"; - this.pnlLeftColumn.Size = new System.Drawing.Size(320, 820); + this.pnlLeftColumn.Size = new System.Drawing.Size(312, 821); this.pnlLeftColumn.TabIndex = 0; // + // lblHelpTitle + // + this.lblHelpTitle.BackColor = System.Drawing.Color.Transparent; + this.lblHelpTitle.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblHelpTitle.ForeColor = System.Drawing.Color.Transparent; + this.lblHelpTitle.Location = new System.Drawing.Point(41, 44); + this.lblHelpTitle.Name = "lblHelpTitle"; + this.lblHelpTitle.Size = new System.Drawing.Size(240, 56); + this.lblHelpTitle.TabIndex = 13; + this.lblHelpTitle.Text = "Press on \"Add Taskbar group\" to get started"; + this.lblHelpTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.AutoSize = true; + this.tableLayoutPanel2.ColumnCount = 1; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.Controls.Add(this.pnlVersionInfo, 0, 2); + this.tableLayoutPanel2.Controls.Add(this.panel2, 0, 1); + this.tableLayoutPanel2.Controls.Add(this.pnlHelp, 0, 0); + this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 126); + 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, 248F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 153F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(306, 683); + this.tableLayoutPanel2.TabIndex = 18; + // // pnlVersionInfo // - this.pnlVersionInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.pnlVersionInfo.Controls.Add(this.githubLink); this.pnlVersionInfo.Controls.Add(this.label6); this.pnlVersionInfo.Controls.Add(this.currentVersion); this.pnlVersionInfo.Controls.Add(this.githubVersion); - this.pnlVersionInfo.Controls.Add(this.githubLink); this.pnlVersionInfo.Controls.Add(this.githubLabel); this.pnlVersionInfo.Controls.Add(this.label4); - this.pnlVersionInfo.Controls.Add(this.label5); - this.pnlVersionInfo.Location = new System.Drawing.Point(12, 615); + this.pnlVersionInfo.Location = new System.Drawing.Point(3, 533); this.pnlVersionInfo.Name = "pnlVersionInfo"; - this.pnlVersionInfo.Size = new System.Drawing.Size(292, 178); + this.pnlVersionInfo.Size = new System.Drawing.Size(300, 116); this.pnlVersionInfo.TabIndex = 18; // + // githubLink + // + this.githubLink.ActiveLinkColor = System.Drawing.Color.White; + this.githubLink.AutoSize = true; + this.githubLink.Font = new System.Drawing.Font("Segoe UI", 9.75F); + this.githubLink.LinkColor = System.Drawing.Color.White; + this.githubLink.Location = new System.Drawing.Point(44, 28); + this.githubLink.Name = "githubLink"; + this.githubLink.Size = new System.Drawing.Size(201, 17); + this.githubLink.TabIndex = 20; + this.githubLink.TabStop = true; + this.githubLink.Text = "Please report them to the GitHub"; + this.githubLink.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.githubLink.VisitedLinkColor = System.Drawing.Color.White; + this.githubLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.githubLink_LinkClicked); + // // label6 // this.label6.AutoSize = true; this.label6.BackColor = System.Drawing.Color.Transparent; this.label6.Font = new System.Drawing.Font("Segoe UI", 10F); this.label6.ForeColor = System.Drawing.Color.Transparent; - this.label6.Location = new System.Drawing.Point(66, 101); + this.label6.Location = new System.Drawing.Point(60, 54); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(108, 19); this.label6.TabIndex = 19; @@ -106,7 +156,7 @@ private void InitializeComponent() this.currentVersion.BackColor = System.Drawing.Color.Transparent; this.currentVersion.Font = new System.Drawing.Font("Segoe UI", 10F); this.currentVersion.ForeColor = System.Drawing.Color.Transparent; - this.currentVersion.Location = new System.Drawing.Point(173, 101); + this.currentVersion.Location = new System.Drawing.Point(170, 54); this.currentVersion.Name = "currentVersion"; this.currentVersion.Size = new System.Drawing.Size(17, 19); this.currentVersion.TabIndex = 15; @@ -118,32 +168,19 @@ private void InitializeComponent() this.githubVersion.BackColor = System.Drawing.Color.Transparent; this.githubVersion.Font = new System.Drawing.Font("Segoe UI", 10F); this.githubVersion.ForeColor = System.Drawing.Color.Transparent; - this.githubVersion.Location = new System.Drawing.Point(173, 130); + this.githubVersion.Location = new System.Drawing.Point(163, 83); this.githubVersion.Name = "githubVersion"; this.githubVersion.Size = new System.Drawing.Size(17, 19); this.githubVersion.TabIndex = 14; this.githubVersion.Text = "0"; // - // githubLink - // - this.githubLink.AutoSize = true; - this.githubLink.Font = new System.Drawing.Font("Segoe UI", 9.75F); - this.githubLink.LinkColor = System.Drawing.Color.White; - this.githubLink.Location = new System.Drawing.Point(218, 34); - this.githubLink.Name = "githubLink"; - this.githubLink.Size = new System.Drawing.Size(34, 17); - this.githubLink.TabIndex = 18; - this.githubLink.TabStop = true; - this.githubLink.Text = "here"; - this.githubLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.githubLink_LinkClicked); - // // githubLabel // this.githubLabel.AutoSize = true; this.githubLabel.BackColor = System.Drawing.Color.Transparent; this.githubLabel.Font = new System.Drawing.Font("Segoe UI", 10F); this.githubLabel.ForeColor = System.Drawing.Color.Transparent; - this.githubLabel.Location = new System.Drawing.Point(75, 130); + this.githubLabel.Location = new System.Drawing.Point(61, 83); this.githubLabel.Name = "githubLabel"; this.githubLabel.Size = new System.Drawing.Size(98, 19); this.githubLabel.TabIndex = 13; @@ -154,35 +191,102 @@ private void InitializeComponent() this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.ForeColor = System.Drawing.Color.Transparent; - this.label4.Location = new System.Drawing.Point(22, 1); + this.label4.Location = new System.Drawing.Point(-3, 1); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(243, 27); + this.label4.Size = new System.Drawing.Size(295, 27); this.label4.TabIndex = 17; this.label4.Text = "Have issues/bugs?"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // label5 - // - this.label5.BackColor = System.Drawing.Color.Transparent; - this.label5.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label5.ForeColor = System.Drawing.Color.Transparent; - this.label5.Location = new System.Drawing.Point(22, 34); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(243, 24); - this.label5.TabIndex = 14; - this.label5.Text = "Please report them to the Github"; + // panel2 + // + this.panel2.Controls.Add(this.portabilityButton); + this.panel2.Controls.Add(this.label8); + this.panel2.Controls.Add(this.label7); + this.panel2.Controls.Add(this.label11); + this.panel2.Location = new System.Drawing.Point(3, 285); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(300, 179); + this.panel2.TabIndex = 20; + // + // portabilityButton + // + this.portabilityButton.BackColor = System.Drawing.Color.Transparent; + this.portabilityButton.BackgroundImage = global::client.Properties.Resources.toggleOff; + this.portabilityButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.portabilityButton.Cursor = System.Windows.Forms.Cursors.Hand; + this.portabilityButton.FlatAppearance.BorderSize = 0; + this.portabilityButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.portabilityButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.portabilityButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.portabilityButton.ForeColor = System.Drawing.Color.Transparent; + this.portabilityButton.Location = new System.Drawing.Point(111, 53); + this.portabilityButton.Name = "portabilityButton"; + this.portabilityButton.Size = new System.Drawing.Size(66, 31); + this.portabilityButton.TabIndex = 21; + this.portabilityButton.TabStop = false; + this.portabilityButton.Tag = "n"; + this.portabilityButton.UseVisualStyleBackColor = false; + this.portabilityButton.Click += new System.EventHandler(this.button1_Click); + // + // label8 + // + this.label8.BackColor = System.Drawing.Color.Transparent; + this.label8.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label8.ForeColor = System.Drawing.Color.Transparent; + this.label8.Location = new System.Drawing.Point(3, 87); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(283, 90); + this.label8.TabIndex = 20; + this.label8.Text = resources.GetString("label8.Text"); + this.label8.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // label7 + // + this.label7.BackColor = System.Drawing.Color.Transparent; + this.label7.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label7.ForeColor = System.Drawing.Color.Transparent; + this.label7.Location = new System.Drawing.Point(35, 38); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(218, 23); + this.label7.TabIndex = 18; + this.label7.Text = "Portability Mode\r\n\r\n\r\n"; + this.label7.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // label11 + // + this.label11.BackColor = System.Drawing.Color.Transparent; + this.label11.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label11.ForeColor = System.Drawing.Color.Transparent; + this.label11.Location = new System.Drawing.Point(23, 1); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(243, 27); + this.label11.TabIndex = 17; + this.label11.Text = "Want portability?"; + this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // pnlHelp // + this.pnlHelp.Controls.Add(this.label5); this.pnlHelp.Controls.Add(this.label3); this.pnlHelp.Controls.Add(this.lblHelp1); this.pnlHelp.Controls.Add(this.lblHelp3); this.pnlHelp.Controls.Add(this.lblHelp2); - this.pnlHelp.Location = new System.Drawing.Point(12, 126); + this.pnlHelp.Location = new System.Drawing.Point(3, 3); this.pnlHelp.Name = "pnlHelp"; - this.pnlHelp.Size = new System.Drawing.Size(292, 202); + this.pnlHelp.Size = new System.Drawing.Size(300, 224); this.pnlHelp.TabIndex = 17; - this.pnlHelp.Visible = false; + // + // label5 + // + this.label5.BackColor = System.Drawing.Color.Transparent; + this.label5.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.ForeColor = System.Drawing.Color.Transparent; + this.label5.Location = new System.Drawing.Point(25, 48); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(243, 40); + this.label5.TabIndex = 18; + this.label5.Text = "1. Click on the group you want to pin to open the shortcuts folder"; // // label3 // @@ -193,7 +297,7 @@ private void InitializeComponent() this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(243, 26); this.label3.TabIndex = 17; - this.label3.Text = "When the folder opens:"; + this.label3.Text = "Pin your first shortcut:"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // lblHelp1 @@ -201,53 +305,89 @@ private void InitializeComponent() this.lblHelp1.BackColor = System.Drawing.Color.Transparent; this.lblHelp1.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblHelp1.ForeColor = System.Drawing.Color.Transparent; - this.lblHelp1.Location = new System.Drawing.Point(26, 59); + this.lblHelp1.Location = new System.Drawing.Point(26, 92); this.lblHelp1.Name = "lblHelp1"; this.lblHelp1.Size = new System.Drawing.Size(243, 40); this.lblHelp1.TabIndex = 14; - this.lblHelp1.Text = "1. Right click on the shortcut named as your new group"; + this.lblHelp1.Text = "2. Right click on the shortcut named as your new group"; // // lblHelp3 // this.lblHelp3.BackColor = System.Drawing.Color.Transparent; this.lblHelp3.Font = new System.Drawing.Font("Segoe UI", 9.75F); this.lblHelp3.ForeColor = System.Drawing.Color.Transparent; - this.lblHelp3.Location = new System.Drawing.Point(26, 155); + this.lblHelp3.Location = new System.Drawing.Point(26, 168); this.lblHelp3.Name = "lblHelp3"; this.lblHelp3.Size = new System.Drawing.Size(243, 22); this.lblHelp3.TabIndex = 16; - this.lblHelp3.Text = "3. Enjoy your new Taskbar group"; + this.lblHelp3.Text = "4. Enjoy your new Taskbar group"; // // lblHelp2 // this.lblHelp2.BackColor = System.Drawing.Color.Transparent; this.lblHelp2.Font = new System.Drawing.Font("Segoe UI", 9.75F); this.lblHelp2.ForeColor = System.Drawing.Color.Transparent; - this.lblHelp2.Location = new System.Drawing.Point(26, 115); + this.lblHelp2.Location = new System.Drawing.Point(26, 138); this.lblHelp2.Name = "lblHelp2"; this.lblHelp2.Size = new System.Drawing.Size(243, 22); this.lblHelp2.TabIndex = 15; - this.lblHelp2.Text = "2. Click on \"Pin to taskbar\""; + this.lblHelp2.Text = "3. Click on \"Pin to taskbar\""; // - // lblHelpTitle + // label1 // - this.lblHelpTitle.BackColor = System.Drawing.Color.Transparent; - this.lblHelpTitle.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblHelpTitle.ForeColor = System.Drawing.Color.Transparent; - this.lblHelpTitle.Location = new System.Drawing.Point(41, 44); - this.lblHelpTitle.Name = "lblHelpTitle"; - this.lblHelpTitle.Size = new System.Drawing.Size(240, 56); - this.lblHelpTitle.TabIndex = 13; - this.lblHelpTitle.Text = "Press on \"Add Taskbar group\" to get started"; - this.lblHelpTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.label1.AutoSize = true; + this.label1.BackColor = System.Drawing.Color.Transparent; + this.label1.Font = new System.Drawing.Font("Segoe UI", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.ForeColor = System.Drawing.Color.Transparent; + this.label1.Location = new System.Drawing.Point(31, 42); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(212, 40); + this.label1.TabIndex = 11; + this.label1.Text = "Taskbar Groups"; + // + // panel1 + // + this.panel1.Controls.Add(this.label2); + this.panel1.Controls.Add(this.label1); + this.panel1.Location = new System.Drawing.Point(320, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(677, 133); + this.panel1.TabIndex = 2; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.BackColor = System.Drawing.Color.Transparent; + this.label2.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(143)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); + this.label2.Location = new System.Drawing.Point(36, 88); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(503, 20); + this.label2.TabIndex = 12; + this.label2.Text = "Group your favourite programs and pin them to the taskbar for easy access"; + // + // pnlExistingShortcuts + // + this.pnlExistingShortcuts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlExistingShortcuts.ColumnCount = 1; + this.pnlExistingShortcuts.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.pnlExistingShortcuts.Location = new System.Drawing.Point(320, 148); + this.pnlExistingShortcuts.Name = "pnlExistingShortcuts"; + this.pnlExistingShortcuts.RowCount = 1; + this.pnlExistingShortcuts.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.pnlExistingShortcuts.Size = new System.Drawing.Size(674, 36); + this.pnlExistingShortcuts.TabIndex = 5; // // pnlAddGroup // + this.pnlAddGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.pnlAddGroup.Controls.Add(this.lblAddGroup); this.pnlAddGroup.Controls.Add(this.cmdAddGroup); - this.pnlAddGroup.Location = new System.Drawing.Point(164, 4); + this.pnlAddGroup.Location = new System.Drawing.Point(502, 193); this.pnlAddGroup.Name = "pnlAddGroup"; - this.pnlAddGroup.Size = new System.Drawing.Size(340, 70); + this.pnlAddGroup.Size = new System.Drawing.Size(318, 68); this.pnlAddGroup.TabIndex = 1; this.pnlAddGroup.Click += new System.EventHandler(this.cmdAddGroup_Click); this.pnlAddGroup.MouseEnter += new System.EventHandler(this.pnlAddGroup_MouseEnter); @@ -255,11 +395,12 @@ private void InitializeComponent() // // lblAddGroup // + this.lblAddGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); this.lblAddGroup.AutoSize = true; this.lblAddGroup.BackColor = System.Drawing.Color.Transparent; this.lblAddGroup.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblAddGroup.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(143)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); - this.lblAddGroup.Location = new System.Drawing.Point(140, 24); + this.lblAddGroup.Location = new System.Drawing.Point(129, 24); this.lblAddGroup.Name = "lblAddGroup"; this.lblAddGroup.Size = new System.Drawing.Size(119, 17); this.lblAddGroup.TabIndex = 8; @@ -270,121 +411,82 @@ private void InitializeComponent() // // cmdAddGroup // - this.cmdAddGroup.BackgroundImage = global::client.Properties.Resources.AddGray; + this.cmdAddGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); + this.cmdAddGroup.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("cmdAddGroup.BackgroundImage"))); this.cmdAddGroup.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.cmdAddGroup.Location = new System.Drawing.Point(88, 14); + this.cmdAddGroup.Location = new System.Drawing.Point(77, 14); this.cmdAddGroup.Margin = new System.Windows.Forms.Padding(30, 30, 10, 30); this.cmdAddGroup.Name = "cmdAddGroup"; - this.cmdAddGroup.Size = new System.Drawing.Size(40, 40); + this.cmdAddGroup.Size = new System.Drawing.Size(40, 38); this.cmdAddGroup.TabIndex = 7; this.cmdAddGroup.TabStop = false; this.cmdAddGroup.Click += new System.EventHandler(this.cmdAddGroup_Click); this.cmdAddGroup.MouseEnter += new System.EventHandler(this.pnlAddGroup_MouseEnter); this.cmdAddGroup.MouseLeave += new System.EventHandler(this.pnlAddGroup_MouseLeave); // - // label1 - // - this.label1.AutoSize = true; - this.label1.BackColor = System.Drawing.Color.Transparent; - this.label1.Font = new System.Drawing.Font("Segoe UI", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.ForeColor = System.Drawing.Color.Transparent; - this.label1.Location = new System.Drawing.Point(31, 42); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(212, 40); - this.label1.TabIndex = 11; - this.label1.Text = "Taskbar Groups"; - // - // panel1 - // - this.panel1.Controls.Add(this.label2); - this.panel1.Controls.Add(this.label1); - this.panel1.Location = new System.Drawing.Point(320, 0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(680, 133); - this.panel1.TabIndex = 2; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.BackColor = System.Drawing.Color.Transparent; - this.label2.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(143)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); - this.label2.Location = new System.Drawing.Point(36, 88); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(503, 20); - this.label2.TabIndex = 12; - this.label2.Text = "Group your favourite programs and pin them to the taskbar for easy access"; - // - // pnlExistingGroups - // - this.pnlExistingGroups.Location = new System.Drawing.Point(320, 133); - this.pnlExistingGroups.Margin = new System.Windows.Forms.Padding(0); - this.pnlExistingGroups.Name = "pnlExistingGroups"; - this.pnlExistingGroups.Size = new System.Drawing.Size(680, 0); - this.pnlExistingGroups.TabIndex = 3; - // - // pnlBottomMain - // - this.pnlBottomMain.Controls.Add(this.pnlAddGroup); - this.pnlBottomMain.Location = new System.Drawing.Point(326, 162); - this.pnlBottomMain.Name = "pnlBottomMain"; - this.pnlBottomMain.Size = new System.Drawing.Size(662, 101); - this.pnlBottomMain.TabIndex = 4; - // // frmClient // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.AutoScroll = true; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(3)))), ((int)(((byte)(3))))); - this.ClientSize = new System.Drawing.Size(1000, 821); - this.Controls.Add(this.pnlBottomMain); - this.Controls.Add(this.pnlExistingGroups); + this.ClientSize = new System.Drawing.Size(1014, 821); + this.Controls.Add(this.pnlAddGroup); + this.Controls.Add(this.pnlExistingShortcuts); this.Controls.Add(this.panel1); this.Controls.Add(this.pnlLeftColumn); + this.DoubleBuffered = true; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "frmClient"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "TaskbarGroups"; - this.Resize += new System.EventHandler(this.frmClient_Resize); + this.Text = "Taskbar Groups"; + this.SizeChanged += new System.EventHandler(this.frmClient_SizeChanged); this.pnlLeftColumn.ResumeLayout(false); + this.pnlLeftColumn.PerformLayout(); + this.tableLayoutPanel2.ResumeLayout(false); this.pnlVersionInfo.ResumeLayout(false); this.pnlVersionInfo.PerformLayout(); + this.panel2.ResumeLayout(false); this.pnlHelp.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); this.pnlAddGroup.ResumeLayout(false); this.pnlAddGroup.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.cmdAddGroup)).EndInit(); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); - this.pnlBottomMain.ResumeLayout(false); this.ResumeLayout(false); + this.PerformLayout(); } #endregion private System.Windows.Forms.Panel pnlLeftColumn; - private System.Windows.Forms.Panel pnlAddGroup; private System.Windows.Forms.Label label1; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label lblAddGroup; - private System.Windows.Forms.PictureBox cmdAddGroup; - private System.Windows.Forms.Panel pnlExistingGroups; private System.Windows.Forms.Label lblHelpTitle; private System.Windows.Forms.Panel pnlHelp; private System.Windows.Forms.Label lblHelp1; private System.Windows.Forms.Label lblHelp3; private System.Windows.Forms.Label lblHelp2; private System.Windows.Forms.Label label3; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Button portabilityButton; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TableLayoutPanel pnlExistingShortcuts; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private System.Windows.Forms.Panel pnlVersionInfo; + private System.Windows.Forms.LinkLabel githubLink; + private System.Windows.Forms.Label label6; private System.Windows.Forms.Label currentVersion; private System.Windows.Forms.Label githubVersion; private System.Windows.Forms.Label githubLabel; - private System.Windows.Forms.Panel pnlVersionInfo; private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.LinkLabel githubLink; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.Panel pnlBottomMain; + private System.Windows.Forms.Panel pnlAddGroup; + private System.Windows.Forms.Label lblAddGroup; + private System.Windows.Forms.PictureBox cmdAddGroup; } } \ No newline at end of file diff --git a/main/Forms/frmClient.cs b/main/Forms/frmClient.cs index bbf9d67..8d94294 100644 --- a/main/Forms/frmClient.cs +++ b/main/Forms/frmClient.cs @@ -1,49 +1,145 @@ -using client.Classes; +using ChinhDo.Transactions; +using client.Classes; using client.User_controls; +using IWshRuntimeLibrary; using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.IO; +using System.Linq; +using System.Net.Http; +using System.Reflection; using System.Threading.Tasks; +using System.Transactions; using System.Windows.Forms; using Windows.Data.Json; -using System.Net.Http; +using System.Runtime.InteropServices; +using Kaitai; +using System.Security.Cryptography.X509Certificates; namespace client.Forms { public partial class frmClient : Form { private static readonly HttpClient client = new HttpClient(); - public frmClient() + private List categoryList = new List(); + public bool editOpened = false; + + public frmClient(List arguments) { System.Runtime.ProfileOptimization.StartProfile("frmClient.Profile"); InitializeComponent(); + eDpi = Display(DpiType.Effective); this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); + this.MinimumSize = new Size(Size.Width + 1, Size.Height); // +1 seems to fix the bottomscroll bar randomly appearing. Reload(); currentVersion.Text = "v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(); githubVersion.Text = Task.Run(() => getVersionData()).Result; + + if (arguments.Count > 2 && arguments[1] == "editingGroupMode" && Directory.Exists(Path.Combine(Paths.ConfigPath, arguments[2]))) + { + + try + { + frmGroup editGroup = new frmGroup(this, categoryList.Where(cat => cat.Name == arguments[2]).First()); + editGroup.TopMost = true; + editGroup.Show(); + } + catch { } + } + + if (Settings.settingInfo.portableMode) + { + portabilityButton.Tag = "y"; + portabilityButton.Image = Properties.Resources.toggleOn; + + string[] files = + Directory.GetFiles(Paths.ShortcutsPath, "*.lnk"); + + foreach (string lnkPath in files) + { + WindowsLnkFile lk = WindowsLnkFile.FromFile(lnkPath); + if (lk.RelPath == null || string.IsNullOrEmpty(lk.RelPath.Str) || lk.RelPath.Str != "..\\Taskbar Groups Background.exe") + { + changeAllShortcuts(); + break; + } + + } + } + else + { + portabilityButton.Tag = "n"; + portabilityButton.Image = Properties.Resources.toggleOff; + } + + if (Paths.justWritten) + { + changeAllShortcuts(); + } + //pnlExistingGroups.AutoScroll = true; + //pnlExistingGroups.AutoSize = true; + //flowLayoutPanel1.AutoScroll = true; + pnlExistingShortcuts.AutoSize = true; + Reset(); + } + + public static uint eDpi { get; set; } // Effective DPI + + public uint Display(DpiType type) + { + foreach (var screen in System.Windows.Forms.Screen.AllScreens) + { + screen.GetDpi(DpiType.Effective, out uint x, out _); + eDpi = x; + return (x); + } + return (eDpi); } public void Reload() { // flush and reload existing groups - pnlExistingGroups.Controls.Clear(); - pnlExistingGroups.Height = 0; + pnlExistingShortcuts.Controls.Clear(); + + List subDirectories = new List(); - string configPath = @MainPath.path + @"\config"; - string[] subDirectories = Directory.GetDirectories(configPath); + using(IEnumerator enumeratorDrectories = Directory.EnumerateDirectories(Paths.ConfigPath).GetEnumerator()) + { + while (true) + { + try + { + if (!enumeratorDrectories.MoveNext()) + break; + subDirectories.Add(enumeratorDrectories.Current); + // processing + } + catch (Exception e) + { + } + } + } + + + //string[] subDirectories = Directory.GetDirectories(Paths.ConfigPath); + pnlExistingShortcuts.SuspendLayout(); foreach (string dir in subDirectories) { try { - LoadCategory(dir); + LoadCategory(Path.Combine(Paths.ConfigPath, dir)); } catch (IOException ex) { MessageBox.Show(ex.Message); } } + pnlExistingShortcuts.ResumeLayout(true); + /* if (pnlExistingGroups.HasChildren) // helper if no group is created { lblHelpTitle.Text = "Click on a group to add a taskbar shortcut"; @@ -54,7 +150,8 @@ public void Reload() lblHelpTitle.Text = "Press on \"Add Taskbar group\" to get started"; pnlHelp.Visible = false; } - pnlBottomMain.Top = pnlExistingGroups.Bottom + 20; // spacing between existing groups and add new group btn + */ + //pnlBottomMain.Location = new Point(pnlBottomMain.Location.X, tableLayoutPanel1.Bottom + (int)(20 * eDpi / 96)); // spacing between existing groups and add new group btn Reset(); } @@ -62,10 +159,14 @@ public void Reload() public void LoadCategory(string dir) { Category category = new Category(dir); + categoryList.Add(category); + ucCategoryPanel newCategory = new ucCategoryPanel(this, category); - pnlExistingGroups.Height += newCategory.Height; - pnlExistingGroups.Controls.Add(newCategory); - newCategory.Top = pnlExistingGroups.Height - newCategory.Height; + pnlExistingShortcuts.RowCount += 1; + pnlExistingShortcuts.Controls.Add(newCategory,0, pnlExistingShortcuts.RowCount - 1); + newCategory.Anchor = AnchorStyles.Left | AnchorStyles.Right; + //newCategory.Top = pnlExistingGroups.Height - newCategory.Height; + //newCategory.Dock = DockStyle.Top; newCategory.Show(); newCategory.BringToFront(); newCategory.MouseEnter += new System.EventHandler((sender, e) => EnterControl(sender, e, newCategory)); @@ -74,10 +175,12 @@ public void LoadCategory(string dir) public void Reset() { - if (pnlBottomMain.Bottom > this.Bottom) - pnlLeftColumn.Height = pnlBottomMain.Bottom; - else - pnlLeftColumn.Height = this.RectangleToScreen(this.ClientRectangle).Height; // making left column pnl dynamic + if(eDpi == 0) + { + eDpi = Display(DpiType.Effective); + } + pnlAddGroup.Top = pnlExistingShortcuts.Bottom + (int)(20 * eDpi / 96); + pnlAddGroup.Left = ((this.ClientSize.Width+pnlLeftColumn.Width) - pnlAddGroup.Width) / 2 ; } private void cmdAddGroup_Click(object sender, EventArgs e) @@ -112,7 +215,7 @@ private static async Task getVersionData() { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("User-Agent", "taskbar-groups"); - var res = await client.GetAsync("https://api.github.com/repos/tjackenpacken/taskbar-groups/releases"); + var res = await client.GetAsync("https://api.github.com/repos/PikeNote/taskbar-groups-pike-beta/releases"); res.EnsureSuccessStatusCode(); string responseBody = await res.Content.ReadAsStringAsync(); @@ -120,17 +223,160 @@ private static async Task getVersionData() JsonObject jsonObjectData = responseJSON[0].GetObject(); return jsonObjectData["tag_name"].GetString(); - } catch {return "Not found";} + } + catch { return "Not found"; } } private void githubLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - System.Diagnostics.Process.Start("https://github.com/tjackenpacken/taskbar-groups/releases"); + System.Diagnostics.Process.Start("https://github.com/PikeNote/taskbar-groups-pike-beta"); } - private void frmClient_Resize(object sender, EventArgs e) + private void button1_Click(object sender, EventArgs e) + { + if ((string)portabilityButton.Tag != "n") + { + + DialogResult res = MessageBox.Show("NOTE: Pressing OK will move the following folders back to the AppData folder (config, Shortcuts) and will move Taskbar Groups Background exe back to AppData.\r\n\r\nWARNING: PLASE DO NOT CLOSE THIS APPLICATION UNTIL A COMPLETION POPUP APPEARS.", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); + if (res == DialogResult.OK) + { + portibleModeToggle(0); + } + } + else + { + DialogResult res = MessageBox.Show("NOTE: Pressing OK will move the following folders to the CURRENT folder (config, Shortcuts) and will move Taskbar Groups Background exe to the CURENT folder.\r\n\r\nWARNING: PLASE DO NOT CLOSE THIS APPLICATION UNTIL A COMPLETION POPUP APPEARS.", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); + + if (res == DialogResult.OK) + { + portibleModeToggle(1); + } + } + } + + public static void changeAllShortcuts() + { + string[] files = System.IO.Directory.GetFiles(Paths.ShortcutsPath, "*.lnk"); + WshShell wshShell = new WshShell(); + foreach (string filePath in files) + { + IWshRuntimeLibrary.IWshShortcut newShortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(filePath); + newShortcut.TargetPath = Paths.BackgroundApplication; + newShortcut.IconLocation = Path.Combine(Paths.ConfigPath, newShortcut.Arguments.Trim(), "GroupIcon.ico"); + newShortcut.WorkingDirectory = Path.Combine(Paths.ConfigPath, newShortcut.Arguments.Trim()); + newShortcut.Save(); + } + } + + // Moves files from AppData to current folder and vice versa + // This is based off of the array below + // Index 0 = Current Path + // Index 1 = Default Path + + // Mode 0 = Current path -> Default Path (Turning off) + // Mode 1 = Default path -> Current Path (Turning on) + private void portibleModeToggle(int mode) + { + String[,] folderArray = new string[,] { { Path.Combine(Paths.exeFolder, "config"), Paths.defaultConfigPath }, { Path.Combine(Paths.exeFolder, "Shortcuts"), Paths.defaultShortcutsPath }}; + String[,] fileArray = new string[,] { { Path.Combine(Paths.exeFolder, "Taskbar Groups Background.exe"), Paths.defaultBackgroundPath }, { Path.Combine(Paths.exeFolder, "Settings.xml"), Settings.defaultSettingsPath } }; + + int int1; + int int2; + if (mode == 0) + { + int1 = 0; + int2 = 1; + } else + { + int1 = 1; + int2 = 0; + } + + try + { + // Kill off the background process + Category.closeBackgroundApp(); + + IFileManager fm = new TxFileManager(); + using (TransactionScope scope1 = new TransactionScope()) + { + + Settings.settingInfo.portableMode = true; + Settings.writeXML(); + + for (int i = 0; i < folderArray.Length/2; i++) + { + if (fm.DirectoryExists(folderArray[i, int1])) + { + // Need to use another method to move from one partition to another + Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(folderArray[i, int1], folderArray[i, int2]); + + // Folders may still reside after being moved + if (fm.DirectoryExists(folderArray[i, int1]) && !Directory.EnumerateFileSystemEntries(folderArray[i, int1]).Any()) + { + fm.DeleteDirectory(folderArray[i, int1]); + } + } + else + { + fm.CreateDirectory(folderArray[i, int2]); + } + } + + for (int i = 0; i < fileArray.Length/2; i++) + { + if (fm.FileExists(fileArray[i, int1])) + { + // Delete if a file is already there (edge cases where the background or another group is created) + if(fm.FileExists(fileArray[i, int2])) + { + fm.Delete(fileArray[i, int2]); + } + fm.Move(fileArray[i, int1], fileArray[i, int2]); + } + } + + if (mode == 0) + { + Paths.ConfigPath = Paths.defaultConfigPath; + Paths.ShortcutsPath = Paths.defaultShortcutsPath; + Paths.BackgroundApplication = Paths.defaultBackgroundPath; + Settings.settingsPath = Settings.defaultSettingsPath; + + portabilityButton.Tag = "n"; + portabilityButton.Image = Properties.Resources.toggleOff; + + } else + { + Paths.ConfigPath = folderArray[0, 0]; + Paths.ShortcutsPath = folderArray[1, 0]; + + Paths.BackgroundApplication = fileArray[0, 0]; + Settings.settingsPath = fileArray[1, 0]; + + portabilityButton.Tag = "y"; + portabilityButton.Image = Properties.Resources.toggleOn; + + } + + changeAllShortcuts(); + + + scope1.Complete(); + + MessageBox.Show("File moving done!"); + } + } + catch(IOException e) { + MessageBox.Show("The application does not have access to this directory!\r\n\r\nError: " + e.Message); + } + } + + private void frmClient_SizeChanged(object sender, EventArgs e) { Reset(); } } + + } diff --git a/main/Forms/frmClient.resx b/main/Forms/frmClient.resx index 6f26b96..eaf20c9 100644 --- a/main/Forms/frmClient.resx +++ b/main/Forms/frmClient.resx @@ -117,7 +117,23 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Note: Enabling this feature will move all your folders (config + shortcut folders). The background exe will be replicated here and a new settings file will be created. All shortcuts in the shortcuts folder will be pointed there. + + + + + + iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAYAAABxLuKEAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL + DAAACwwBP0AiyAAAAS1JREFUeF7t1UEKwlAQBNEczRvGI3mzOGDPpjJ/oRAULKE2Ir+Ht3G77/th54RZ + JMwiYRadYOqz/WN0ECbRQZhEB2ESHYRJdBAm0UGYRAdhEh2ESXQQJtFBmEQHYRIdhEl0ECbRQZhEB2ES + HYRJdPg6TG3ecMNj+t3V4QZhOtwgTIcbhOlwgzAdbhCmww3CdLhBmA43CNPhBmE63CBMhxuE6XDDNTB8 + 8+q4/0l8U5jEN4VJfFOYxDcvgXmn2vRfaao2hZmqTWGmalOYqdoUZqo2hZmqTWGmalOYqdoUZqo2hZmq + TWGmalOYX44OwiQ6CJPoIEyigzCJDsIkOgiT6CBMooMwiQ7CJDoIk+ggTKKDMIkOwiQ6CJPoIEyigzCJ + Dqcv7JUwi4RZJMzYfjwBe16LftbZqC4AAAAASUVORK5CYII= + + AAABAAYAAAAAAAEAIAB1JQAAZgAAAICAAAABACAAKAgBANslAABAQAAAAQAgAChCAAADLgEAMDAAAAEA diff --git a/main/Forms/frmGroup.Designer.cs b/main/Forms/frmGroup.Designer.cs index ad82445..4792d91 100644 --- a/main/Forms/frmGroup.Designer.cs +++ b/main/Forms/frmGroup.Designer.cs @@ -1,4 +1,6 @@ -namespace client.Forms +using client.User_controls; + +namespace client.Forms { partial class frmGroup { @@ -28,6 +30,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmGroup)); this.lblWith = new System.Windows.Forms.Label(); this.lblErrorNum = new System.Windows.Forms.Label(); @@ -36,36 +39,54 @@ private void InitializeComponent() this.lblErrorTitle = new System.Windows.Forms.Label(); this.cmdSave = new System.Windows.Forms.Button(); this.cmdExit = new System.Windows.Forms.Button(); - this.pnlShortcuts = new System.Windows.Forms.Panel(); this.pnlGroupIcon = new System.Windows.Forms.Panel(); this.cmdAddGroupIcon = new System.Windows.Forms.PictureBox(); this.lblAddGroupIcon = new System.Windows.Forms.Label(); this.lblAddGroupIconDesc = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); this.txtGroupName = new System.Windows.Forms.TextBox(); this.pnlAddShortcut = new System.Windows.Forms.Panel(); this.cmdAddShortcut = new System.Windows.Forms.PictureBox(); this.lblErrorShortcut = new System.Windows.Forms.Label(); this.lblAddShortcut = new System.Windows.Forms.Label(); this.pnlColor = new System.Windows.Forms.Panel(); - this.numOpacDown = new System.Windows.Forms.Button(); - this.numOpacUp = new System.Windows.Forms.Button(); - this.lblPercent = new System.Windows.Forms.Label(); + this.cmdRightSettings = new System.Windows.Forms.Button(); + this.cmdLeftSettings = new System.Windows.Forms.Button(); + this.groupSettingsTabControl = new client.User_controls.ucTabControl(); + this.generalConfigPage = new System.Windows.Forms.TabPage(); + this.label1 = new System.Windows.Forms.Label(); + this.IconSeparationBottomButton = new System.Windows.Forms.Button(); this.pnlAllowOpenAll = new System.Windows.Forms.CheckBox(); - this.lblOpacityTooltip = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.lblPercent = new System.Windows.Forms.Label(); + this.lblIconSeparation = new System.Windows.Forms.Label(); this.lblOpacity = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.pnlCustomColor = new System.Windows.Forms.Panel(); - this.radioCustom = new System.Windows.Forms.RadioButton(); + this.IconSeparationText = new System.Windows.Forms.Label(); + this.numOpacUp = new System.Windows.Forms.Button(); + this.IconSeparationTopButton = new System.Windows.Forms.Button(); + this.numOpacDown = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.IconSizeText = new System.Windows.Forms.Label(); + this.lblOpacityTooltip = new System.Windows.Forms.Label(); + this.IconSizeBottomButton = new System.Windows.Forms.Button(); + this.lblIconSize = new System.Windows.Forms.Label(); + this.IconSizeTopButton = new System.Windows.Forms.Button(); + this.colorConfigPage = new System.Windows.Forms.TabPage(); + this.radioSystem = new System.Windows.Forms.RadioButton(); this.radioDark = new System.Windows.Forms.RadioButton(); + this.radioCustom = new System.Windows.Forms.RadioButton(); + this.pnlCustomColor = new System.Windows.Forms.Panel(); + this.panel1 = new System.Windows.Forms.Panel(); this.radioLight = new System.Windows.Forms.RadioButton(); + this.pnlCustomColor1 = new System.Windows.Forms.Panel(); + this.panel3 = new System.Windows.Forms.Panel(); this.cmdDelete = new System.Windows.Forms.Button(); this.pnlEnd = new System.Windows.Forms.Panel(); this.colorDialog = new System.Windows.Forms.ColorDialog(); - this.cmdWidthDown = new System.Windows.Forms.Button(); - this.cmdWidthUp = new System.Windows.Forms.Button(); this.pnlArguments = new System.Windows.Forms.Panel(); + this.label9 = new System.Windows.Forms.Label(); + this.cmdSelectProgramPath = new System.Windows.Forms.Button(); + this.label10 = new System.Windows.Forms.Label(); + this.pnlProgramPath = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.cmdSelectDirectory = new System.Windows.Forms.Button(); @@ -73,22 +94,41 @@ private void InitializeComponent() this.pnlWorkingDirectory = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.pnlArgumentTextbox = new System.Windows.Forms.TextBox(); + this.pnlDeleteConfo = new System.Windows.Forms.Panel(); + this.confirmDelete = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.pnlShortcuts = new System.Windows.Forms.FlowLayoutPanel(); + this.pictureBox2 = new System.Windows.Forms.PictureBox(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.cmdWidthDown = new System.Windows.Forms.Button(); + this.cmdWidthUp = new System.Windows.Forms.Button(); + this.validationTimerPrgm = new System.Windows.Forms.Timer(this.components); + this.validaitonTimerDirec = new System.Windows.Forms.Timer(this.components); this.pnlGroupIcon.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.cmdAddGroupIcon)).BeginInit(); this.pnlAddShortcut.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.cmdAddShortcut)).BeginInit(); this.pnlColor.SuspendLayout(); + this.groupSettingsTabControl.SuspendLayout(); + this.generalConfigPage.SuspendLayout(); + this.colorConfigPage.SuspendLayout(); + this.pnlCustomColor.SuspendLayout(); + this.pnlCustomColor1.SuspendLayout(); this.pnlEnd.SuspendLayout(); this.pnlArguments.SuspendLayout(); + this.pnlDeleteConfo.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // lblWith // + this.lblWith.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblWith.AutoSize = true; this.lblWith.BackColor = System.Drawing.Color.Transparent; this.lblWith.Font = new System.Drawing.Font("Segoe UI", 13F); this.lblWith.ForeColor = System.Drawing.Color.White; - this.lblWith.Location = new System.Drawing.Point(447, 23); + this.lblWith.Location = new System.Drawing.Point(416, 23); this.lblWith.Name = "lblWith"; this.lblWith.Size = new System.Drawing.Size(64, 25); this.lblWith.TabIndex = 40; @@ -96,9 +136,10 @@ private void InitializeComponent() // // lblErrorNum // + this.lblErrorNum.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblErrorNum.Font = new System.Drawing.Font("Segoe UI Semibold", 10F, System.Drawing.FontStyle.Bold); this.lblErrorNum.ForeColor = System.Drawing.Color.Red; - this.lblErrorNum.Location = new System.Drawing.Point(268, 3); + this.lblErrorNum.Location = new System.Drawing.Point(237, 3); this.lblErrorNum.Name = "lblErrorNum"; this.lblErrorNum.Size = new System.Drawing.Size(241, 19); this.lblErrorNum.TabIndex = 44; @@ -108,10 +149,11 @@ private void InitializeComponent() // // lblNum // + this.lblNum.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblNum.BackColor = System.Drawing.Color.Transparent; this.lblNum.Font = new System.Drawing.Font("Segoe UI", 13F, System.Drawing.FontStyle.Bold); this.lblNum.ForeColor = System.Drawing.Color.White; - this.lblNum.Location = new System.Drawing.Point(505, 23); + this.lblNum.Location = new System.Drawing.Point(474, 23); this.lblNum.Name = "lblNum"; this.lblNum.Size = new System.Drawing.Size(35, 25); this.lblNum.TabIndex = 41; @@ -123,7 +165,7 @@ private void InitializeComponent() this.lblErrorIcon.AutoSize = true; this.lblErrorIcon.Font = new System.Drawing.Font("Segoe UI Semibold", 10F, System.Drawing.FontStyle.Bold); this.lblErrorIcon.ForeColor = System.Drawing.Color.Red; - this.lblErrorIcon.Location = new System.Drawing.Point(147, 76); + this.lblErrorIcon.Location = new System.Drawing.Point(155, 76); this.lblErrorIcon.Name = "lblErrorIcon"; this.lblErrorIcon.Size = new System.Drawing.Size(96, 19); this.lblErrorIcon.TabIndex = 38; @@ -135,7 +177,7 @@ private void InitializeComponent() this.lblErrorTitle.AutoSize = true; this.lblErrorTitle.Font = new System.Drawing.Font("Segoe UI Semibold", 10F, System.Drawing.FontStyle.Bold); this.lblErrorTitle.ForeColor = System.Drawing.Color.Red; - this.lblErrorTitle.Location = new System.Drawing.Point(44, 9); + this.lblErrorTitle.Location = new System.Drawing.Point(52, 9); this.lblErrorTitle.Name = "lblErrorTitle"; this.lblErrorTitle.Size = new System.Drawing.Size(96, 19); this.lblErrorTitle.TabIndex = 37; @@ -150,7 +192,7 @@ private void InitializeComponent() this.cmdSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.cmdSave.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cmdSave.ForeColor = System.Drawing.Color.White; - this.cmdSave.Location = new System.Drawing.Point(28, 7); + this.cmdSave.Location = new System.Drawing.Point(36, 7); this.cmdSave.Name = "cmdSave"; this.cmdSave.Size = new System.Drawing.Size(129, 30); this.cmdSave.TabIndex = 36; @@ -166,7 +208,7 @@ private void InitializeComponent() this.cmdExit.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.cmdExit.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cmdExit.ForeColor = System.Drawing.Color.White; - this.cmdExit.Location = new System.Drawing.Point(171, 7); + this.cmdExit.Location = new System.Drawing.Point(179, 7); this.cmdExit.Name = "cmdExit"; this.cmdExit.Size = new System.Drawing.Size(129, 30); this.cmdExit.TabIndex = 35; @@ -174,25 +216,18 @@ private void InitializeComponent() this.cmdExit.UseVisualStyleBackColor = false; this.cmdExit.Click += new System.EventHandler(this.cmdExit_Click); // - // pnlShortcuts - // - this.pnlShortcuts.AutoScroll = true; - this.pnlShortcuts.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); - this.pnlShortcuts.ForeColor = System.Drawing.SystemColors.ControlText; - this.pnlShortcuts.Location = new System.Drawing.Point(45, 194); - this.pnlShortcuts.Name = "pnlShortcuts"; - this.pnlShortcuts.Size = new System.Drawing.Size(500, 5); - this.pnlShortcuts.TabIndex = 34; - // // pnlGroupIcon // this.pnlGroupIcon.AllowDrop = true; + this.pnlGroupIcon.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlGroupIcon.AutoSize = true; this.pnlGroupIcon.Controls.Add(this.cmdAddGroupIcon); this.pnlGroupIcon.Controls.Add(this.lblAddGroupIcon); this.pnlGroupIcon.Controls.Add(this.lblAddGroupIconDesc); - this.pnlGroupIcon.Location = new System.Drawing.Point(49, 83); + this.pnlGroupIcon.Location = new System.Drawing.Point(57, 83); this.pnlGroupIcon.Name = "pnlGroupIcon"; - this.pnlGroupIcon.Size = new System.Drawing.Size(495, 86); + this.pnlGroupIcon.Size = new System.Drawing.Size(466, 102); this.pnlGroupIcon.TabIndex = 33; this.pnlGroupIcon.Click += new System.EventHandler(this.cmdAddGroupIcon_Click); this.pnlGroupIcon.DragDrop += new System.Windows.Forms.DragEventHandler(this.pnlDragDropImg); @@ -205,12 +240,15 @@ private void InitializeComponent() // this.cmdAddGroupIcon.BackgroundImage = global::client.Properties.Resources.AddWhite; this.cmdAddGroupIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.cmdAddGroupIcon.Location = new System.Drawing.Point(23, 12); + this.cmdAddGroupIcon.ErrorImage = global::client.Properties.Resources.Error; + this.cmdAddGroupIcon.Location = new System.Drawing.Point(31, 12); this.cmdAddGroupIcon.Margin = new System.Windows.Forms.Padding(30, 30, 10, 30); this.cmdAddGroupIcon.Name = "cmdAddGroupIcon"; this.cmdAddGroupIcon.Size = new System.Drawing.Size(60, 60); this.cmdAddGroupIcon.TabIndex = 10; this.cmdAddGroupIcon.TabStop = false; + this.cmdAddGroupIcon.Tag = "Unchanged"; + this.cmdAddGroupIcon.BackgroundImageChanged += new System.EventHandler(this.cmdAddGroupIcon_BackgroundImageChanged); this.cmdAddGroupIcon.Click += new System.EventHandler(this.cmdAddGroupIcon_Click); this.cmdAddGroupIcon.MouseEnter += new System.EventHandler(this.pnlGroupIcon_MouseEnter); this.cmdAddGroupIcon.MouseLeave += new System.EventHandler(this.pnlGroupIcon_MouseLeave); @@ -221,7 +259,7 @@ private void InitializeComponent() this.lblAddGroupIcon.BackColor = System.Drawing.Color.Transparent; this.lblAddGroupIcon.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblAddGroupIcon.ForeColor = System.Drawing.Color.White; - this.lblAddGroupIcon.Location = new System.Drawing.Point(96, 15); + this.lblAddGroupIcon.Location = new System.Drawing.Point(104, 15); this.lblAddGroupIcon.Name = "lblAddGroupIcon"; this.lblAddGroupIcon.Size = new System.Drawing.Size(190, 30); this.lblAddGroupIcon.TabIndex = 11; @@ -236,7 +274,7 @@ private void InitializeComponent() this.lblAddGroupIconDesc.BackColor = System.Drawing.Color.Transparent; this.lblAddGroupIconDesc.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblAddGroupIconDesc.ForeColor = System.Drawing.Color.White; - this.lblAddGroupIconDesc.Location = new System.Drawing.Point(99, 46); + this.lblAddGroupIconDesc.Location = new System.Drawing.Point(107, 46); this.lblAddGroupIconDesc.Name = "lblAddGroupIconDesc"; this.lblAddGroupIconDesc.Size = new System.Drawing.Size(245, 17); this.lblAddGroupIconDesc.TabIndex = 12; @@ -245,33 +283,13 @@ private void InitializeComponent() this.lblAddGroupIconDesc.MouseEnter += new System.EventHandler(this.pnlGroupIcon_MouseEnter); this.lblAddGroupIconDesc.MouseLeave += new System.EventHandler(this.pnlGroupIcon_MouseLeave); // - // label4 - // - this.label4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); - this.label4.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); - this.label4.Location = new System.Drawing.Point(45, 182); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(500, 1); - this.label4.TabIndex = 32; - // - // label2 - // - this.label2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); - this.label2.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); - this.label2.Location = new System.Drawing.Point(45, 69); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(500, 1); - this.label2.TabIndex = 31; - // // txtGroupName // this.txtGroupName.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); this.txtGroupName.BorderStyle = System.Windows.Forms.BorderStyle.None; this.txtGroupName.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.txtGroupName.ForeColor = System.Drawing.Color.White; - this.txtGroupName.Location = new System.Drawing.Point(48, 29); + this.txtGroupName.Location = new System.Drawing.Point(56, 29); this.txtGroupName.Name = "txtGroupName"; this.txtGroupName.Size = new System.Drawing.Size(395, 32); this.txtGroupName.TabIndex = 30; @@ -284,12 +302,14 @@ private void InitializeComponent() // pnlAddShortcut // this.pnlAddShortcut.AllowDrop = true; + this.pnlAddShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.pnlAddShortcut.AutoSize = true; this.pnlAddShortcut.Controls.Add(this.cmdAddShortcut); this.pnlAddShortcut.Controls.Add(this.lblErrorShortcut); this.pnlAddShortcut.Controls.Add(this.lblAddShortcut); - this.pnlAddShortcut.Location = new System.Drawing.Point(94, 203); + this.pnlAddShortcut.Location = new System.Drawing.Point(57, 240); this.pnlAddShortcut.Name = "pnlAddShortcut"; - this.pnlAddShortcut.Size = new System.Drawing.Size(415, 80); + this.pnlAddShortcut.Size = new System.Drawing.Size(466, 81); this.pnlAddShortcut.TabIndex = 45; this.pnlAddShortcut.Click += new System.EventHandler(this.pnlAddShortcut_Click); this.pnlAddShortcut.DragDrop += new System.Windows.Forms.DragEventHandler(this.pnlDragDropExt); @@ -300,9 +320,11 @@ private void InitializeComponent() // // cmdAddShortcut // + this.cmdAddShortcut.Anchor = System.Windows.Forms.AnchorStyles.None; this.cmdAddShortcut.BackgroundImage = global::client.Properties.Resources.AddGray; this.cmdAddShortcut.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.cmdAddShortcut.Location = new System.Drawing.Point(191, 16); + this.cmdAddShortcut.ErrorImage = global::client.Properties.Resources.Error; + this.cmdAddShortcut.Location = new System.Drawing.Point(214, 16); this.cmdAddShortcut.Margin = new System.Windows.Forms.Padding(30, 30, 10, 30); this.cmdAddShortcut.Name = "cmdAddShortcut"; this.cmdAddShortcut.Size = new System.Drawing.Size(35, 35); @@ -314,11 +336,13 @@ private void InitializeComponent() // // lblErrorShortcut // + this.lblErrorShortcut.Anchor = System.Windows.Forms.AnchorStyles.None; + this.lblErrorShortcut.AutoSize = true; this.lblErrorShortcut.Font = new System.Drawing.Font("Segoe UI Semibold", 10F, System.Drawing.FontStyle.Bold); this.lblErrorShortcut.ForeColor = System.Drawing.Color.Red; - this.lblErrorShortcut.Location = new System.Drawing.Point(0, 54); + this.lblErrorShortcut.Location = new System.Drawing.Point(186, 51); this.lblErrorShortcut.Name = "lblErrorShortcut"; - this.lblErrorShortcut.Size = new System.Drawing.Size(414, 19); + this.lblErrorShortcut.Size = new System.Drawing.Size(96, 19); this.lblErrorShortcut.TabIndex = 23; this.lblErrorShortcut.Text = "Error message"; this.lblErrorShortcut.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -326,11 +350,12 @@ private void InitializeComponent() // // lblAddShortcut // + this.lblAddShortcut.Anchor = System.Windows.Forms.AnchorStyles.None; this.lblAddShortcut.AutoSize = true; this.lblAddShortcut.BackColor = System.Drawing.Color.Transparent; this.lblAddShortcut.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblAddShortcut.ForeColor = System.Drawing.Color.White; - this.lblAddShortcut.Location = new System.Drawing.Point(159, 51); + this.lblAddShortcut.Location = new System.Drawing.Point(182, 51); this.lblAddShortcut.Name = "lblAddShortcut"; this.lblAddShortcut.Size = new System.Drawing.Size(110, 17); this.lblAddShortcut.TabIndex = 14; @@ -341,67 +366,119 @@ private void InitializeComponent() // // pnlColor // - this.pnlColor.Controls.Add(this.numOpacDown); - this.pnlColor.Controls.Add(this.numOpacUp); - this.pnlColor.Controls.Add(this.lblPercent); - this.pnlColor.Controls.Add(this.pnlAllowOpenAll); - this.pnlColor.Controls.Add(this.lblOpacityTooltip); - this.pnlColor.Controls.Add(this.lblOpacity); - this.pnlColor.Controls.Add(this.label1); - this.pnlColor.Controls.Add(this.pnlCustomColor); - this.pnlColor.Controls.Add(this.radioCustom); - this.pnlColor.Controls.Add(this.radioDark); - this.pnlColor.Controls.Add(this.radioLight); - this.pnlColor.Location = new System.Drawing.Point(110, 544); + this.pnlColor.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.pnlColor.AutoSize = true; + this.pnlColor.Controls.Add(this.cmdRightSettings); + this.pnlColor.Controls.Add(this.cmdLeftSettings); + this.pnlColor.Controls.Add(this.groupSettingsTabControl); + this.pnlColor.Location = new System.Drawing.Point(100, 642); this.pnlColor.Name = "pnlColor"; - this.pnlColor.Size = new System.Drawing.Size(368, 164); + this.pnlColor.Size = new System.Drawing.Size(378, 175); this.pnlColor.TabIndex = 48; // - // numOpacDown - // - this.numOpacDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); - this.numOpacDown.BackgroundImage = global::client.Properties.Resources.NumDownWhite; - this.numOpacDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.numOpacDown.FlatAppearance.BorderSize = 0; - this.numOpacDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.numOpacDown.Location = new System.Drawing.Point(250, 115); - this.numOpacDown.Name = "numOpacDown"; - this.numOpacDown.Size = new System.Drawing.Size(16, 8); - this.numOpacDown.TabIndex = 49; - this.numOpacDown.UseVisualStyleBackColor = false; - this.numOpacDown.Click += new System.EventHandler(this.numOpacDown_Click); - // - // numOpacUp + // cmdRightSettings + // + this.cmdRightSettings.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.cmdRightSettings.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.cmdRightSettings.BackgroundImage = global::client.Properties.Resources.RightArrow; + this.cmdRightSettings.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.cmdRightSettings.FlatAppearance.BorderSize = 0; + this.cmdRightSettings.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.cmdRightSettings.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.cmdRightSettings.Location = new System.Drawing.Point(343, 72); + this.cmdRightSettings.Name = "cmdRightSettings"; + this.cmdRightSettings.Size = new System.Drawing.Size(26, 45); + this.cmdRightSettings.TabIndex = 55; + this.cmdRightSettings.UseVisualStyleBackColor = false; + this.cmdRightSettings.Click += new System.EventHandler(this.cmdRightSettings_Click); + // + // cmdLeftSettings + // + this.cmdLeftSettings.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.cmdLeftSettings.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.cmdLeftSettings.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("cmdLeftSettings.BackgroundImage"))); + this.cmdLeftSettings.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.cmdLeftSettings.Enabled = false; + this.cmdLeftSettings.FlatAppearance.BorderSize = 0; + this.cmdLeftSettings.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.cmdLeftSettings.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.cmdLeftSettings.Location = new System.Drawing.Point(7, 73); + this.cmdLeftSettings.Name = "cmdLeftSettings"; + this.cmdLeftSettings.Size = new System.Drawing.Size(26, 45); + this.cmdLeftSettings.TabIndex = 54; + this.cmdLeftSettings.UseVisualStyleBackColor = false; + this.cmdLeftSettings.Click += new System.EventHandler(this.cmdLeftSettings_Click); + // + // groupSettingsTabControl + // + this.groupSettingsTabControl.Controls.Add(this.generalConfigPage); + this.groupSettingsTabControl.Controls.Add(this.colorConfigPage); + this.groupSettingsTabControl.Location = new System.Drawing.Point(36, 8); + this.groupSettingsTabControl.Name = "groupSettingsTabControl"; + this.groupSettingsTabControl.SelectedIndex = 0; + this.groupSettingsTabControl.Size = new System.Drawing.Size(305, 153); + this.groupSettingsTabControl.TabIndex = 53; + // + // generalConfigPage + // + this.generalConfigPage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.generalConfigPage.Controls.Add(this.label1); + this.generalConfigPage.Controls.Add(this.IconSeparationBottomButton); + this.generalConfigPage.Controls.Add(this.pnlAllowOpenAll); + this.generalConfigPage.Controls.Add(this.label8); + this.generalConfigPage.Controls.Add(this.lblPercent); + this.generalConfigPage.Controls.Add(this.lblIconSeparation); + this.generalConfigPage.Controls.Add(this.lblOpacity); + this.generalConfigPage.Controls.Add(this.IconSeparationText); + this.generalConfigPage.Controls.Add(this.numOpacUp); + this.generalConfigPage.Controls.Add(this.IconSeparationTopButton); + this.generalConfigPage.Controls.Add(this.numOpacDown); + this.generalConfigPage.Controls.Add(this.label4); + this.generalConfigPage.Controls.Add(this.IconSizeText); + this.generalConfigPage.Controls.Add(this.lblOpacityTooltip); + this.generalConfigPage.Controls.Add(this.IconSizeBottomButton); + this.generalConfigPage.Controls.Add(this.lblIconSize); + this.generalConfigPage.Controls.Add(this.IconSizeTopButton); + this.generalConfigPage.Location = new System.Drawing.Point(4, 22); + this.generalConfigPage.Name = "generalConfigPage"; + this.generalConfigPage.Padding = new System.Windows.Forms.Padding(3); + this.generalConfigPage.Size = new System.Drawing.Size(297, 127); + this.generalConfigPage.TabIndex = 0; + this.generalConfigPage.Text = "Genneral Config"; // - this.numOpacUp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); - this.numOpacUp.BackgroundImage = global::client.Properties.Resources.NumUpWhite; - this.numOpacUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.numOpacUp.FlatAppearance.BorderSize = 0; - this.numOpacUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.numOpacUp.Location = new System.Drawing.Point(250, 101); - this.numOpacUp.Name = "numOpacUp"; - this.numOpacUp.Size = new System.Drawing.Size(16, 8); - this.numOpacUp.TabIndex = 50; - this.numOpacUp.UseVisualStyleBackColor = false; - this.numOpacUp.Click += new System.EventHandler(this.numOpacUp_Click); + // label1 // - // lblPercent + this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); + this.label1.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); + this.label1.Location = new System.Drawing.Point(149, 32); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(45, 1); + this.label1.TabIndex = 49; // - this.lblPercent.AutoSize = true; - this.lblPercent.Font = new System.Drawing.Font("Segoe UI", 11.25F); - this.lblPercent.ForeColor = System.Drawing.Color.White; - this.lblPercent.Location = new System.Drawing.Point(216, 102); - this.lblPercent.Name = "lblPercent"; - this.lblPercent.Size = new System.Drawing.Size(21, 20); - this.lblPercent.TabIndex = 5; - this.lblPercent.Text = "%"; + // IconSeparationBottomButton + // + this.IconSeparationBottomButton.Anchor = System.Windows.Forms.AnchorStyles.None; + this.IconSeparationBottomButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.IconSeparationBottomButton.BackgroundImage = global::client.Properties.Resources.NumDownWhite; + this.IconSeparationBottomButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.IconSeparationBottomButton.FlatAppearance.BorderSize = 0; + this.IconSeparationBottomButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.IconSeparationBottomButton.Location = new System.Drawing.Point(211, 110); + this.IconSeparationBottomButton.Name = "IconSeparationBottomButton"; + this.IconSeparationBottomButton.Size = new System.Drawing.Size(16, 8); + this.IconSeparationBottomButton.TabIndex = 59; + this.IconSeparationBottomButton.UseVisualStyleBackColor = false; + this.IconSeparationBottomButton.Click += new System.EventHandler(this.IconSeparationBottomButton_Click); // // pnlAllowOpenAll // + this.pnlAllowOpenAll.Anchor = System.Windows.Forms.AnchorStyles.None; this.pnlAllowOpenAll.AutoSize = true; this.pnlAllowOpenAll.Font = new System.Drawing.Font("Segoe UI", 11.25F); this.pnlAllowOpenAll.ForeColor = System.Drawing.Color.White; - this.pnlAllowOpenAll.Location = new System.Drawing.Point(64, 131); + this.pnlAllowOpenAll.Location = new System.Drawing.Point(15, 39); this.pnlAllowOpenAll.Name = "pnlAllowOpenAll"; this.pnlAllowOpenAll.Size = new System.Drawing.Size(278, 24); this.pnlAllowOpenAll.TabIndex = 49; @@ -409,79 +486,270 @@ private void InitializeComponent() this.pnlAllowOpenAll.UseVisualStyleBackColor = true; this.pnlAllowOpenAll.CheckedChanged += new System.EventHandler(this.pnlAllowOpenAll_CheckedChanged); // - // lblOpacityTooltip + // label8 // - this.lblOpacityTooltip.AutoSize = true; - this.lblOpacityTooltip.Font = new System.Drawing.Font("Segoe UI", 11.25F); - this.lblOpacityTooltip.ForeColor = System.Drawing.Color.White; - this.lblOpacityTooltip.Location = new System.Drawing.Point(127, 101); - this.lblOpacityTooltip.Name = "lblOpacityTooltip"; - this.lblOpacityTooltip.Size = new System.Drawing.Size(63, 20); - this.lblOpacityTooltip.TabIndex = 4; - this.lblOpacityTooltip.Text = "Opacity:"; + this.label8.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); + this.label8.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); + this.label8.Location = new System.Drawing.Point(183, 115); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(25, 1); + this.label8.TabIndex = 58; + // + // lblPercent + // + this.lblPercent.Anchor = System.Windows.Forms.AnchorStyles.None; + this.lblPercent.AutoSize = true; + this.lblPercent.Font = new System.Drawing.Font("Segoe UI", 11.25F); + this.lblPercent.ForeColor = System.Drawing.Color.White; + this.lblPercent.Location = new System.Drawing.Point(172, 12); + this.lblPercent.Name = "lblPercent"; + this.lblPercent.Size = new System.Drawing.Size(21, 20); + this.lblPercent.TabIndex = 5; + this.lblPercent.Text = "%"; + // + // lblIconSeparation + // + this.lblIconSeparation.Anchor = System.Windows.Forms.AnchorStyles.None; + this.lblIconSeparation.BackColor = System.Drawing.Color.Transparent; + this.lblIconSeparation.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblIconSeparation.ForeColor = System.Drawing.Color.White; + this.lblIconSeparation.Location = new System.Drawing.Point(184, 94); + this.lblIconSeparation.Name = "lblIconSeparation"; + this.lblIconSeparation.Size = new System.Drawing.Size(27, 25); + this.lblIconSeparation.TabIndex = 58; + this.lblIconSeparation.Text = "6"; + this.lblIconSeparation.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // lblOpacity // + this.lblOpacity.Anchor = System.Windows.Forms.AnchorStyles.None; this.lblOpacity.Font = new System.Drawing.Font("Segoe UI", 11.25F); this.lblOpacity.ForeColor = System.Drawing.Color.White; - this.lblOpacity.Location = new System.Drawing.Point(185, 102); + this.lblOpacity.Location = new System.Drawing.Point(149, 13); this.lblOpacity.Name = "lblOpacity"; - this.lblOpacity.Size = new System.Drawing.Size(35, 20); + this.lblOpacity.Size = new System.Drawing.Size(27, 20); this.lblOpacity.TabIndex = 50; this.lblOpacity.Text = "10"; this.lblOpacity.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // - // label1 + // IconSeparationText // - this.label1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); - this.label1.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); - this.label1.Location = new System.Drawing.Point(189, 122); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(45, 1); - this.label1.TabIndex = 49; + this.IconSeparationText.Anchor = System.Windows.Forms.AnchorStyles.None; + this.IconSeparationText.AutoSize = true; + this.IconSeparationText.BackColor = System.Drawing.Color.Transparent; + this.IconSeparationText.Font = new System.Drawing.Font("Segoe UI", 11.25F); + this.IconSeparationText.ForeColor = System.Drawing.Color.White; + this.IconSeparationText.Location = new System.Drawing.Point(72, 96); + this.IconSeparationText.Name = "IconSeparationText"; + this.IconSeparationText.Size = new System.Drawing.Size(114, 20); + this.IconSeparationText.TabIndex = 57; + this.IconSeparationText.Text = "Icon separation:"; // - // pnlCustomColor + // numOpacUp // - this.pnlCustomColor.Location = new System.Drawing.Point(256, 75); - this.pnlCustomColor.Name = "pnlCustomColor"; - this.pnlCustomColor.Size = new System.Drawing.Size(15, 15); - this.pnlCustomColor.TabIndex = 3; + this.numOpacUp.Anchor = System.Windows.Forms.AnchorStyles.None; + this.numOpacUp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.numOpacUp.BackgroundImage = global::client.Properties.Resources.NumUpWhite; + this.numOpacUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.numOpacUp.FlatAppearance.BorderSize = 0; + this.numOpacUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.numOpacUp.Location = new System.Drawing.Point(199, 11); + this.numOpacUp.Name = "numOpacUp"; + this.numOpacUp.Size = new System.Drawing.Size(16, 8); + this.numOpacUp.TabIndex = 50; + this.numOpacUp.UseVisualStyleBackColor = false; + this.numOpacUp.Click += new System.EventHandler(this.numOpacUp_Click); // - // radioCustom + // IconSeparationTopButton + // + this.IconSeparationTopButton.Anchor = System.Windows.Forms.AnchorStyles.None; + this.IconSeparationTopButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.IconSeparationTopButton.BackgroundImage = global::client.Properties.Resources.NumUpWhite; + this.IconSeparationTopButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.IconSeparationTopButton.FlatAppearance.BorderSize = 0; + this.IconSeparationTopButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.IconSeparationTopButton.Location = new System.Drawing.Point(211, 96); + this.IconSeparationTopButton.Name = "IconSeparationTopButton"; + this.IconSeparationTopButton.Size = new System.Drawing.Size(16, 8); + this.IconSeparationTopButton.TabIndex = 60; + this.IconSeparationTopButton.UseVisualStyleBackColor = false; + this.IconSeparationTopButton.Click += new System.EventHandler(this.IconSeparationTopButton_Click); // - this.radioCustom.AutoSize = true; - this.radioCustom.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.radioCustom.ForeColor = System.Drawing.Color.White; - this.radioCustom.Location = new System.Drawing.Point(135, 69); - this.radioCustom.Name = "radioCustom"; - this.radioCustom.Size = new System.Drawing.Size(115, 24); - this.radioCustom.TabIndex = 2; - this.radioCustom.TabStop = true; - this.radioCustom.Text = "Custom color"; - this.radioCustom.UseVisualStyleBackColor = true; - this.radioCustom.Click += new System.EventHandler(this.radioCustom_Click); + // numOpacDown + // + this.numOpacDown.Anchor = System.Windows.Forms.AnchorStyles.None; + this.numOpacDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.numOpacDown.BackgroundImage = global::client.Properties.Resources.NumDownWhite; + this.numOpacDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.numOpacDown.FlatAppearance.BorderSize = 0; + this.numOpacDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.numOpacDown.Location = new System.Drawing.Point(199, 25); + this.numOpacDown.Name = "numOpacDown"; + this.numOpacDown.Size = new System.Drawing.Size(16, 8); + this.numOpacDown.TabIndex = 49; + this.numOpacDown.UseVisualStyleBackColor = false; + this.numOpacDown.Click += new System.EventHandler(this.numOpacDown_Click); + // + // label4 + // + this.label4.Anchor = System.Windows.Forms.AnchorStyles.None; + this.label4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); + this.label4.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); + this.label4.Location = new System.Drawing.Point(161, 85); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(25, 1); + this.label4.TabIndex = 51; + // + // IconSizeText + // + this.IconSizeText.Anchor = System.Windows.Forms.AnchorStyles.None; + this.IconSizeText.AutoSize = true; + this.IconSizeText.BackColor = System.Drawing.Color.Transparent; + this.IconSizeText.Font = new System.Drawing.Font("Segoe UI", 11.25F); + this.IconSizeText.ForeColor = System.Drawing.Color.White; + this.IconSizeText.Location = new System.Drawing.Point(90, 65); + this.IconSizeText.Name = "IconSizeText"; + this.IconSizeText.Size = new System.Drawing.Size(69, 20); + this.IconSizeText.TabIndex = 53; + this.IconSizeText.Text = "Icon size:"; + // + // lblOpacityTooltip + // + this.lblOpacityTooltip.Anchor = System.Windows.Forms.AnchorStyles.None; + this.lblOpacityTooltip.AutoSize = true; + this.lblOpacityTooltip.Font = new System.Drawing.Font("Segoe UI", 11.25F); + this.lblOpacityTooltip.ForeColor = System.Drawing.Color.White; + this.lblOpacityTooltip.Location = new System.Drawing.Point(83, 11); + this.lblOpacityTooltip.Name = "lblOpacityTooltip"; + this.lblOpacityTooltip.Size = new System.Drawing.Size(63, 20); + this.lblOpacityTooltip.TabIndex = 4; + this.lblOpacityTooltip.Text = "Opacity:"; + // + // IconSizeBottomButton + // + this.IconSizeBottomButton.Anchor = System.Windows.Forms.AnchorStyles.None; + this.IconSizeBottomButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.IconSizeBottomButton.BackgroundImage = global::client.Properties.Resources.NumDownWhite; + this.IconSizeBottomButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.IconSizeBottomButton.FlatAppearance.BorderSize = 0; + this.IconSizeBottomButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.IconSizeBottomButton.Location = new System.Drawing.Point(193, 78); + this.IconSizeBottomButton.Name = "IconSizeBottomButton"; + this.IconSizeBottomButton.Size = new System.Drawing.Size(16, 8); + this.IconSizeBottomButton.TabIndex = 55; + this.IconSizeBottomButton.UseVisualStyleBackColor = false; + this.IconSizeBottomButton.Click += new System.EventHandler(this.IconSizeBottomButton_Click); + // + // lblIconSize + // + this.lblIconSize.Anchor = System.Windows.Forms.AnchorStyles.None; + this.lblIconSize.BackColor = System.Drawing.Color.Transparent; + this.lblIconSize.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblIconSize.ForeColor = System.Drawing.Color.White; + this.lblIconSize.Location = new System.Drawing.Point(161, 63); + this.lblIconSize.Name = "lblIconSize"; + this.lblIconSize.Size = new System.Drawing.Size(27, 25); + this.lblIconSize.TabIndex = 54; + this.lblIconSize.Text = "6"; + this.lblIconSize.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // IconSizeTopButton + // + this.IconSizeTopButton.Anchor = System.Windows.Forms.AnchorStyles.None; + this.IconSizeTopButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.IconSizeTopButton.BackgroundImage = global::client.Properties.Resources.NumUpWhite; + this.IconSizeTopButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.IconSizeTopButton.FlatAppearance.BorderSize = 0; + this.IconSizeTopButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.IconSizeTopButton.Location = new System.Drawing.Point(193, 63); + this.IconSizeTopButton.Name = "IconSizeTopButton"; + this.IconSizeTopButton.Size = new System.Drawing.Size(16, 8); + this.IconSizeTopButton.TabIndex = 56; + this.IconSizeTopButton.UseVisualStyleBackColor = false; + this.IconSizeTopButton.Click += new System.EventHandler(this.IconSizeTopButton_Click); + // + // colorConfigPage + // + this.colorConfigPage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.colorConfigPage.Controls.Add(this.radioSystem); + this.colorConfigPage.Controls.Add(this.radioDark); + this.colorConfigPage.Controls.Add(this.radioCustom); + this.colorConfigPage.Controls.Add(this.pnlCustomColor); + this.colorConfigPage.Controls.Add(this.radioLight); + this.colorConfigPage.Controls.Add(this.pnlCustomColor1); + this.colorConfigPage.Location = new System.Drawing.Point(4, 22); + this.colorConfigPage.Name = "colorConfigPage"; + this.colorConfigPage.Padding = new System.Windows.Forms.Padding(3); + this.colorConfigPage.Size = new System.Drawing.Size(297, 127); + this.colorConfigPage.TabIndex = 1; + this.colorConfigPage.Text = "Color Config"; + // + // radioSystem + // + this.radioSystem.AutoSize = true; + this.radioSystem.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.radioSystem.ForeColor = System.Drawing.Color.White; + this.radioSystem.Location = new System.Drawing.Point(102, 63); + this.radioSystem.Name = "radioSystem"; + this.radioSystem.Size = new System.Drawing.Size(114, 24); + this.radioSystem.TabIndex = 6; + this.radioSystem.Text = "System Color"; + this.radioSystem.UseVisualStyleBackColor = true; + this.radioSystem.Click += new System.EventHandler(this.radioSystem_Click); // // radioDark // this.radioDark.AutoSize = true; this.radioDark.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.radioDark.ForeColor = System.Drawing.Color.White; - this.radioDark.Location = new System.Drawing.Point(135, 9); + this.radioDark.Location = new System.Drawing.Point(104, 4); this.radioDark.Name = "radioDark"; this.radioDark.Size = new System.Drawing.Size(96, 24); this.radioDark.TabIndex = 1; - this.radioDark.TabStop = true; this.radioDark.Text = "Dark color"; this.radioDark.UseVisualStyleBackColor = true; this.radioDark.Click += new System.EventHandler(this.radioDark_Click); // + // radioCustom + // + this.radioCustom.AutoSize = true; + this.radioCustom.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.radioCustom.ForeColor = System.Drawing.Color.White; + this.radioCustom.Location = new System.Drawing.Point(67, 89); + this.radioCustom.Name = "radioCustom"; + this.radioCustom.Size = new System.Drawing.Size(115, 24); + this.radioCustom.TabIndex = 2; + this.radioCustom.Text = "Custom color"; + this.radioCustom.UseVisualStyleBackColor = true; + this.radioCustom.MouseClick += new System.Windows.Forms.MouseEventHandler(this.radioCustom_Click); + // + // pnlCustomColor + // + this.pnlCustomColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnlCustomColor.Controls.Add(this.panel1); + this.pnlCustomColor.Location = new System.Drawing.Point(186, 95); + this.pnlCustomColor.Name = "pnlCustomColor"; + this.pnlCustomColor.Size = new System.Drawing.Size(15, 15); + this.pnlCustomColor.TabIndex = 3; + this.pnlCustomColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.radioCustom_Click); + // + // panel1 + // + this.panel1.Location = new System.Drawing.Point(34, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(15, 15); + this.panel1.TabIndex = 4; + // // radioLight // this.radioLight.AutoSize = true; + this.radioLight.Checked = true; this.radioLight.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.radioLight.ForeColor = System.Drawing.Color.White; - this.radioLight.Location = new System.Drawing.Point(135, 39); + this.radioLight.Location = new System.Drawing.Point(104, 34); this.radioLight.Name = "radioLight"; this.radioLight.Size = new System.Drawing.Size(98, 24); this.radioLight.TabIndex = 0; @@ -490,6 +758,23 @@ private void InitializeComponent() this.radioLight.UseVisualStyleBackColor = true; this.radioLight.Click += new System.EventHandler(this.radioLight_Click); // + // pnlCustomColor1 + // + this.pnlCustomColor1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnlCustomColor1.Controls.Add(this.panel3); + this.pnlCustomColor1.Location = new System.Drawing.Point(209, 95); + this.pnlCustomColor1.Name = "pnlCustomColor1"; + this.pnlCustomColor1.Size = new System.Drawing.Size(15, 15); + this.pnlCustomColor1.TabIndex = 5; + this.pnlCustomColor1.Click += new System.EventHandler(this.pnlCustomColor1_Click); + // + // panel3 + // + this.panel3.Location = new System.Drawing.Point(34, 0); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(15, 15); + this.panel3.TabIndex = 4; + // // cmdDelete // this.cmdDelete.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(76)))), ((int)(((byte)(76))))); @@ -498,54 +783,34 @@ private void InitializeComponent() this.cmdDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.cmdDelete.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cmdDelete.ForeColor = System.Drawing.Color.White; - this.cmdDelete.Location = new System.Drawing.Point(313, 7); + this.cmdDelete.Location = new System.Drawing.Point(321, 7); this.cmdDelete.Name = "cmdDelete"; this.cmdDelete.Size = new System.Drawing.Size(129, 30); this.cmdDelete.TabIndex = 46; this.cmdDelete.Text = "Delete"; this.cmdDelete.UseVisualStyleBackColor = false; - this.cmdDelete.Click += new System.EventHandler(this.cmdDelete_Click); + this.cmdDelete.Click += new System.EventHandler(this.openDeleteConformation); // // pnlEnd // + this.pnlEnd.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.pnlEnd.AutoSize = true; this.pnlEnd.Controls.Add(this.cmdDelete); this.pnlEnd.Controls.Add(this.cmdSave); this.pnlEnd.Controls.Add(this.cmdExit); - this.pnlEnd.Location = new System.Drawing.Point(52, 722); + this.pnlEnd.Location = new System.Drawing.Point(41, 881); this.pnlEnd.Name = "pnlEnd"; this.pnlEnd.Size = new System.Drawing.Size(482, 44); this.pnlEnd.TabIndex = 47; // - // cmdWidthDown - // - this.cmdWidthDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); - this.cmdWidthDown.BackgroundImage = global::client.Properties.Resources.NumDownWhite; - this.cmdWidthDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.cmdWidthDown.FlatAppearance.BorderSize = 0; - this.cmdWidthDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.cmdWidthDown.Location = new System.Drawing.Point(514, 51); - this.cmdWidthDown.Name = "cmdWidthDown"; - this.cmdWidthDown.Size = new System.Drawing.Size(16, 8); - this.cmdWidthDown.TabIndex = 42; - this.cmdWidthDown.UseVisualStyleBackColor = false; - this.cmdWidthDown.Click += new System.EventHandler(this.cmdWidthDown_Click); - // - // cmdWidthUp - // - this.cmdWidthUp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); - this.cmdWidthUp.BackgroundImage = global::client.Properties.Resources.NumUpWhite; - this.cmdWidthUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.cmdWidthUp.FlatAppearance.BorderSize = 0; - this.cmdWidthUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.cmdWidthUp.Location = new System.Drawing.Point(514, 13); - this.cmdWidthUp.Name = "cmdWidthUp"; - this.cmdWidthUp.Size = new System.Drawing.Size(16, 8); - this.cmdWidthUp.TabIndex = 43; - this.cmdWidthUp.UseVisualStyleBackColor = false; - this.cmdWidthUp.Click += new System.EventHandler(this.cmdWidthUp_Click); - // // pnlArguments // + this.pnlArguments.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.pnlArguments.AutoSize = true; + this.pnlArguments.Controls.Add(this.label9); + this.pnlArguments.Controls.Add(this.cmdSelectProgramPath); + this.pnlArguments.Controls.Add(this.label10); + this.pnlArguments.Controls.Add(this.pnlProgramPath); this.pnlArguments.Controls.Add(this.label7); this.pnlArguments.Controls.Add(this.label6); this.pnlArguments.Controls.Add(this.cmdSelectDirectory); @@ -553,18 +818,67 @@ private void InitializeComponent() this.pnlArguments.Controls.Add(this.pnlWorkingDirectory); this.pnlArguments.Controls.Add(this.label3); this.pnlArguments.Controls.Add(this.pnlArgumentTextbox); - this.pnlArguments.Location = new System.Drawing.Point(45, 547); + this.pnlArguments.Location = new System.Drawing.Point(41, 627); this.pnlArguments.Name = "pnlArguments"; - this.pnlArguments.Size = new System.Drawing.Size(482, 131); + this.pnlArguments.Size = new System.Drawing.Size(489, 151); this.pnlArguments.TabIndex = 48; this.pnlArguments.Visible = false; // + // label9 + // + this.label9.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); + this.label9.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label9.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); + this.label9.Location = new System.Drawing.Point(35, 44); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(335, 1); + this.label9.TabIndex = 54; + // + // cmdSelectProgramPath + // + this.cmdSelectProgramPath.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(76)))), ((int)(((byte)(76))))); + this.cmdSelectProgramPath.FlatAppearance.BorderSize = 0; + this.cmdSelectProgramPath.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.cmdSelectProgramPath.Font = new System.Drawing.Font("Segoe UI", 8F); + this.cmdSelectProgramPath.ForeColor = System.Drawing.Color.White; + this.cmdSelectProgramPath.Location = new System.Drawing.Point(376, 20); + this.cmdSelectProgramPath.Name = "cmdSelectProgramPath"; + this.cmdSelectProgramPath.Size = new System.Drawing.Size(97, 27); + this.cmdSelectProgramPath.TabIndex = 57; + this.cmdSelectProgramPath.Text = "Select Program"; + this.cmdSelectProgramPath.UseVisualStyleBackColor = false; + this.cmdSelectProgramPath.Click += new System.EventHandler(this.cmdSelectProgramPath_Click); + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("Segoe UI", 11.25F); + this.label10.ForeColor = System.Drawing.Color.White; + this.label10.Location = new System.Drawing.Point(32, 4); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(101, 20); + this.label10.TabIndex = 56; + this.label10.Text = "Program Path:"; + // + // pnlProgramPath + // + this.pnlProgramPath.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.pnlProgramPath.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.pnlProgramPath.Enabled = false; + this.pnlProgramPath.Font = new System.Drawing.Font("Segoe UI", 9F); + this.pnlProgramPath.ForeColor = System.Drawing.Color.White; + this.pnlProgramPath.Location = new System.Drawing.Point(36, 26); + this.pnlProgramPath.Name = "pnlProgramPath"; + this.pnlProgramPath.Size = new System.Drawing.Size(330, 16); + this.pnlProgramPath.TabIndex = 55; + this.pnlProgramPath.TextChanged += new System.EventHandler(this.pnlProgramPath_TextChanged); + // // label7 // this.label7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); this.label7.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); - this.label7.Location = new System.Drawing.Point(26, 51); + this.label7.Location = new System.Drawing.Point(35, 93); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(440, 1); this.label7.TabIndex = 53; @@ -574,7 +888,7 @@ private void InitializeComponent() this.label6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); this.label6.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(143)))), ((int)(((byte)(143))))); - this.label6.Location = new System.Drawing.Point(26, 103); + this.label6.Location = new System.Drawing.Point(35, 145); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(335, 1); this.label6.TabIndex = 50; @@ -586,7 +900,7 @@ private void InitializeComponent() this.cmdSelectDirectory.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.cmdSelectDirectory.Font = new System.Drawing.Font("Segoe UI", 8F); this.cmdSelectDirectory.ForeColor = System.Drawing.Color.White; - this.cmdSelectDirectory.Location = new System.Drawing.Point(367, 79); + this.cmdSelectDirectory.Location = new System.Drawing.Point(376, 121); this.cmdSelectDirectory.Name = "cmdSelectDirectory"; this.cmdSelectDirectory.Size = new System.Drawing.Size(97, 27); this.cmdSelectDirectory.TabIndex = 52; @@ -599,7 +913,7 @@ private void InitializeComponent() this.label5.AutoSize = true; this.label5.Font = new System.Drawing.Font("Segoe UI", 11.25F); this.label5.ForeColor = System.Drawing.Color.White; - this.label5.Location = new System.Drawing.Point(23, 63); + this.label5.Location = new System.Drawing.Point(32, 105); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(132, 20); this.label5.TabIndex = 51; @@ -612,7 +926,7 @@ private void InitializeComponent() this.pnlWorkingDirectory.Enabled = false; this.pnlWorkingDirectory.Font = new System.Drawing.Font("Segoe UI", 9F); this.pnlWorkingDirectory.ForeColor = System.Drawing.Color.White; - this.pnlWorkingDirectory.Location = new System.Drawing.Point(27, 85); + this.pnlWorkingDirectory.Location = new System.Drawing.Point(36, 127); this.pnlWorkingDirectory.Name = "pnlWorkingDirectory"; this.pnlWorkingDirectory.Size = new System.Drawing.Size(330, 16); this.pnlWorkingDirectory.TabIndex = 50; @@ -623,7 +937,7 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Font = new System.Drawing.Font("Segoe UI", 11.25F); this.label3.ForeColor = System.Drawing.Color.White; - this.label3.Location = new System.Drawing.Point(23, 11); + this.label3.Location = new System.Drawing.Point(32, 53); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(84, 20); this.label3.TabIndex = 1; @@ -636,41 +950,161 @@ private void InitializeComponent() this.pnlArgumentTextbox.Enabled = false; this.pnlArgumentTextbox.Font = new System.Drawing.Font("Segoe UI", 9F); this.pnlArgumentTextbox.ForeColor = System.Drawing.Color.White; - this.pnlArgumentTextbox.Location = new System.Drawing.Point(26, 33); + this.pnlArgumentTextbox.Location = new System.Drawing.Point(35, 75); this.pnlArgumentTextbox.Name = "pnlArgumentTextbox"; this.pnlArgumentTextbox.Size = new System.Drawing.Size(425, 16); this.pnlArgumentTextbox.TabIndex = 0; this.pnlArgumentTextbox.TextChanged += new System.EventHandler(this.pnlArgumentTextbox_TextChanged); this.pnlArgumentTextbox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pnlArgumentTextbox_KeyDown); // + // pnlDeleteConfo + // + this.pnlDeleteConfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); + this.pnlDeleteConfo.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.pnlDeleteConfo.Controls.Add(this.confirmDelete); + this.pnlDeleteConfo.Controls.Add(this.label2); + this.pnlDeleteConfo.Location = new System.Drawing.Point(162, 347); + this.pnlDeleteConfo.Name = "pnlDeleteConfo"; + this.pnlDeleteConfo.Padding = new System.Windows.Forms.Padding(0, 0, 0, 10); + this.pnlDeleteConfo.Size = new System.Drawing.Size(253, 98); + this.pnlDeleteConfo.TabIndex = 51; + this.pnlDeleteConfo.Visible = false; + // + // confirmDelete + // + this.confirmDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); + this.confirmDelete.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(76)))), ((int)(((byte)(76))))); + this.confirmDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(148)))), ((int)(((byte)(148)))), ((int)(((byte)(148))))); + this.confirmDelete.FlatAppearance.BorderSize = 0; + this.confirmDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.confirmDelete.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.confirmDelete.ForeColor = System.Drawing.Color.White; + this.confirmDelete.Location = new System.Drawing.Point(76, 49); + this.confirmDelete.Name = "confirmDelete"; + this.confirmDelete.Size = new System.Drawing.Size(99, 26); + this.confirmDelete.TabIndex = 47; + this.confirmDelete.Text = "Yes"; + this.confirmDelete.UseVisualStyleBackColor = false; + this.confirmDelete.Click += new System.EventHandler(this.cmdDelete_Click); + // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); + this.label2.Font = new System.Drawing.Font("Segoe UI", 10F); + this.label2.ForeColor = System.Drawing.Color.White; + this.label2.Location = new System.Drawing.Point(-1, 1); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(252, 39); + this.label2.TabIndex = 0; + this.label2.Text = "Are you sure you want to delete this group?"; + this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // pnlShortcuts + // + this.pnlShortcuts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlShortcuts.AutoScroll = true; + this.pnlShortcuts.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.pnlShortcuts.Location = new System.Drawing.Point(57, 191); + this.pnlShortcuts.Name = "pnlShortcuts"; + this.pnlShortcuts.Size = new System.Drawing.Size(473, 40); + this.pnlShortcuts.TabIndex = 52; + this.pnlShortcuts.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.pnlShortcuts_ControlAdded); + // + // pictureBox2 + // + this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBox2.Location = new System.Drawing.Point(56, 180); + this.pictureBox2.Name = "pictureBox2"; + this.pictureBox2.Size = new System.Drawing.Size(467, 5); + this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox2.TabIndex = 50; + this.pictureBox2.TabStop = false; + // + // pictureBox1 + // + this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBox1.Location = new System.Drawing.Point(56, 74); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(467, 5); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox1.TabIndex = 49; + this.pictureBox1.TabStop = false; + // + // cmdWidthDown + // + this.cmdWidthDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.cmdWidthDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.cmdWidthDown.BackgroundImage = global::client.Properties.Resources.NumDownWhite; + this.cmdWidthDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.cmdWidthDown.FlatAppearance.BorderSize = 0; + this.cmdWidthDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.cmdWidthDown.Location = new System.Drawing.Point(483, 51); + this.cmdWidthDown.Name = "cmdWidthDown"; + this.cmdWidthDown.Size = new System.Drawing.Size(16, 8); + this.cmdWidthDown.TabIndex = 42; + this.cmdWidthDown.UseVisualStyleBackColor = false; + this.cmdWidthDown.Click += new System.EventHandler(this.cmdWidthDown_Click); + // + // cmdWidthUp + // + this.cmdWidthUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.cmdWidthUp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.cmdWidthUp.BackgroundImage = global::client.Properties.Resources.NumUpWhite; + this.cmdWidthUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.cmdWidthUp.FlatAppearance.BorderSize = 0; + this.cmdWidthUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.cmdWidthUp.Location = new System.Drawing.Point(483, 13); + this.cmdWidthUp.Name = "cmdWidthUp"; + this.cmdWidthUp.Size = new System.Drawing.Size(16, 8); + this.cmdWidthUp.TabIndex = 43; + this.cmdWidthUp.UseVisualStyleBackColor = false; + this.cmdWidthUp.Click += new System.EventHandler(this.cmdWidthUp_Click); + // + // validationTimerPrgm + // + this.validationTimerPrgm.Interval = 1000; + this.validationTimerPrgm.Tick += new System.EventHandler(this.validationTimer_Tick); + // + // validaitonTimerDirec + // + this.validaitonTimerDirec.Interval = 1000; + this.validaitonTimerDirec.Tick += new System.EventHandler(this.validaitonTimerDirec_Tick); + // // frmGroup // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.AutoScroll = true; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); - this.ClientSize = new System.Drawing.Size(589, 821); + this.ClientSize = new System.Drawing.Size(574, 946); + this.Controls.Add(this.pnlDeleteConfo); this.Controls.Add(this.pnlArguments); + this.Controls.Add(this.pnlColor); + this.Controls.Add(this.pnlShortcuts); + this.Controls.Add(this.pictureBox2); + this.Controls.Add(this.pictureBox1); this.Controls.Add(this.pnlEnd); this.Controls.Add(this.pnlAddShortcut); - this.Controls.Add(this.pnlColor); this.Controls.Add(this.lblWith); this.Controls.Add(this.lblErrorNum); this.Controls.Add(this.cmdWidthDown); this.Controls.Add(this.lblNum); this.Controls.Add(this.lblErrorIcon); this.Controls.Add(this.lblErrorTitle); - this.Controls.Add(this.pnlShortcuts); this.Controls.Add(this.pnlGroupIcon); - this.Controls.Add(this.label4); this.Controls.Add(this.cmdWidthUp); - this.Controls.Add(this.label2); this.Controls.Add(this.txtGroupName); + this.DoubleBuffered = true; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MinimumSize = new System.Drawing.Size(590, 39); this.Name = "frmGroup"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "New group"; this.Load += new System.EventHandler(this.frmGroup_Load); + this.SizeChanged += new System.EventHandler(this.frmGroup_SizeChanged); this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.frmGroup_MouseClick); this.pnlGroupIcon.ResumeLayout(false); this.pnlGroupIcon.PerformLayout(); @@ -679,10 +1113,19 @@ private void InitializeComponent() this.pnlAddShortcut.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.cmdAddShortcut)).EndInit(); this.pnlColor.ResumeLayout(false); - this.pnlColor.PerformLayout(); + this.groupSettingsTabControl.ResumeLayout(false); + this.generalConfigPage.ResumeLayout(false); + this.generalConfigPage.PerformLayout(); + this.colorConfigPage.ResumeLayout(false); + this.colorConfigPage.PerformLayout(); + this.pnlCustomColor.ResumeLayout(false); + this.pnlCustomColor1.ResumeLayout(false); this.pnlEnd.ResumeLayout(false); this.pnlArguments.ResumeLayout(false); this.pnlArguments.PerformLayout(); + this.pnlDeleteConfo.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -698,14 +1141,11 @@ private void InitializeComponent() private System.Windows.Forms.Label lblErrorTitle; private System.Windows.Forms.Button cmdSave; private System.Windows.Forms.Button cmdExit; - private System.Windows.Forms.Panel pnlShortcuts; private System.Windows.Forms.Panel pnlGroupIcon; private System.Windows.Forms.PictureBox cmdAddGroupIcon; private System.Windows.Forms.Label lblAddGroupIcon; private System.Windows.Forms.Label lblAddGroupIconDesc; - private System.Windows.Forms.Label label4; private System.Windows.Forms.Button cmdWidthUp; - private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox txtGroupName; private System.Windows.Forms.Panel pnlAddShortcut; private System.Windows.Forms.Label lblErrorShortcut; @@ -714,11 +1154,7 @@ private void InitializeComponent() private System.Windows.Forms.Button cmdDelete; private System.Windows.Forms.Panel pnlEnd; private System.Windows.Forms.Panel pnlColor; - private System.Windows.Forms.RadioButton radioCustom; - private System.Windows.Forms.RadioButton radioDark; - private System.Windows.Forms.RadioButton radioLight; private System.Windows.Forms.ColorDialog colorDialog; - private System.Windows.Forms.Panel pnlCustomColor; private System.Windows.Forms.Label lblOpacityTooltip; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label lblPercent; @@ -734,5 +1170,40 @@ private void InitializeComponent() private System.Windows.Forms.Button cmdSelectDirectory; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label7; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.PictureBox pictureBox2; + private System.Windows.Forms.Panel pnlDeleteConfo; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button confirmDelete; + private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.FlowLayoutPanel pnlShortcuts; + private System.Windows.Forms.Label IconSeparationText; + private System.Windows.Forms.Button IconSeparationBottomButton; + private System.Windows.Forms.Label lblIconSeparation; + private System.Windows.Forms.Button IconSeparationTopButton; + private System.Windows.Forms.Label IconSizeText; + private System.Windows.Forms.Button IconSizeBottomButton; + private System.Windows.Forms.Label lblIconSize; + private System.Windows.Forms.Button IconSizeTopButton; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label4; + private ucTabControl groupSettingsTabControl; + private System.Windows.Forms.TabPage generalConfigPage; + private System.Windows.Forms.TabPage colorConfigPage; + private System.Windows.Forms.Button cmdLeftSettings; + private System.Windows.Forms.Button cmdRightSettings; + public System.Windows.Forms.RadioButton radioCustom; + public System.Windows.Forms.RadioButton radioDark; + public System.Windows.Forms.RadioButton radioLight; + public System.Windows.Forms.Panel pnlCustomColor; + public System.Windows.Forms.Panel pnlCustomColor1; + public System.Windows.Forms.RadioButton radioSystem; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Button cmdSelectProgramPath; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.TextBox pnlProgramPath; + private System.Windows.Forms.Timer validationTimerPrgm; + private System.Windows.Forms.Timer validaitonTimerDirec; } } \ No newline at end of file diff --git a/main/Forms/frmGroup.cs b/main/Forms/frmGroup.cs index be43763..f43907e 100644 --- a/main/Forms/frmGroup.cs +++ b/main/Forms/frmGroup.cs @@ -1,5 +1,4 @@ -using ChinhDo.Transactions; -using client.Classes; +using client.Classes; using client.User_controls; using IWshRuntimeLibrary; using System; @@ -10,27 +9,37 @@ using System.Text.RegularExpressions; using System.Transactions; using System.Windows.Forms; +using System.Reflection; using Microsoft.WindowsAPICodePack.Shell; -using Microsoft.WindowsAPICodePack.Dialogs; +using Microsoft.WindowsAPICodePack.Dialogs; +using ChinhDo.Transactions; +using System.Drawing.Imaging; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using client.Properties; namespace client.Forms { + public partial class frmGroup : Form { + [DllImport("shell32.dll")] + static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr ppszPath); + public Category Category; public frmClient Client; public bool IsNew; private String[] imageExt = new String[] { ".png", ".jpg", ".jpe", ".jfif", ".jpeg", }; private String[] extensionExt = new String[] { ".exe", ".lnk", ".url" }; private String[] specialImageExt = new String[] { ".ico", ".exe", ".lnk" }; - private String[] newExt; + public String[] newExt; public ucProgramShortcut selectedShortcut; public static Shell32.Shell shell = new Shell32.Shell(); - private List shortcutChanged = new List(); - + private Regex fileRegex = new Regex(@"^(?:[\w]\:|\\)(?:\\[A-Za-z_\-\s0-9\.]+)+(?:\.[a-zA-Z].*$)"); + private Regex directoryRegex = new Regex(@"^[a-zA-Z]:\\(?:(?:(?![<>:""\/\\|?*]).)+(?:(?() }; Client = client; IsNew = true; @@ -77,23 +86,43 @@ public frmGroup(frmClient client, Category category) cmdAddGroupIcon.BackgroundImage = Category.LoadIconImage(); lblNum.Text = Category.Width.ToString(); lblOpacity.Text = Category.Opacity.ToString(); - + lblIconSize.Text = Category.IconSize.ToString(); + lblIconSeparation.Text = Category.Separation.ToString(); + if (Category.ColorString == null) // Handles if groups is created from earlier releas w/o ColorString property - Category.ColorString = System.Drawing.ColorTranslator.ToHtml(Color.FromArgb(31, 31, 31)); + Category.ColorString = ColorTranslator.ToHtml(Color.FromArgb(31, 31, 31)); - Color categoryColor = ImageFunctions.FromString(Category.ColorString); - - if (categoryColor == Color.FromArgb(31, 31, 31)) - radioDark.Checked = true; - else if (categoryColor == Color.FromArgb(230, 230, 230)) - radioLight.Checked = true; - else + if (Category.ColorString == "sys") + { + radioSystem.Checked = true; + } else { - radioCustom.Checked = true; - pnlCustomColor.Visible = true; - pnlCustomColor.BackColor = categoryColor; + Color categoryColor = ImageFunctions.FromString(Category.ColorString); + if (categoryColor == Color.FromArgb(31, 31, 31)) + radioDark.Checked = true; + else if (categoryColor == Color.FromArgb(230, 230, 230)) + radioLight.Checked = true; + else + { + radioCustom.Checked = true; + //pnlCustomColor.Visible = true; + pnlCustomColor.BackColor = categoryColor; + + if (category.HoverColor != null) + { + pnlCustomColor1.BackColor = ImageFunctions.FromString(category.HoverColor); + } + else + { + pnlCustomColor1.BackColor = category.calculateHoverColor(); + } + + } } + colorConfigPage.Update(); + colorConfigPage.Refresh(); + // Loading existing shortcutpanels int position = 0; foreach (ProgramShortcut psc in category.ShortcutList) @@ -101,13 +130,23 @@ public frmGroup(frmClient client, Category category) LoadShortcut(psc, position); position++; } + + + + pnlShortcuts_ControlAdded(this, new ControlEventArgs(this)); + } // Handle scaling etc(?) (WORK IN PROGRESS) private void frmGroup_Load(object sender, EventArgs e) { // Scaling form (WORK IN PROGRESS) - this.MaximumSize = new Size(605, Screen.PrimaryScreen.WorkingArea.Height); + this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); + + typeof(Control).GetProperty("ResizeRedraw", BindingFlags.NonPublic | BindingFlags.Instance) + .SetValue(pnlDeleteConfo, true, null); + + newExt = imageExt.Concat(specialImageExt).ToArray(); } //-------------------------------------- @@ -123,17 +162,24 @@ public void LoadShortcut(ProgramShortcut psc, int position) MotherForm = this, Shortcut = psc, Position = position, - }; + Width = pnlAddShortcut.Width - (3 * (int)(frmClient.eDpi / 96)) + }; pnlShortcuts.Controls.Add(ucPsc); + ucPsc.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; ucPsc.Show(); - ucPsc.BringToFront(); + ucPsc.SendToBack(); + + if (pnlShortcuts.Controls.Count < 6) { - pnlShortcuts.Height += 50; - pnlAddShortcut.Top += 50; + pnlShortcuts.Height += 50 * (int)(frmClient.eDpi / 96); + pnlAddShortcut.Top += 50 * (int)(frmClient.eDpi / 96); } - ucPsc.Location = new Point(25, (pnlShortcuts.Controls.Count * 50)-50); + + + //ucPsc.Location = new Point(25 * (int)(frmClient.eDpi / 96), (pnlShortcuts.Controls.Count * 50 * (int)(frmClient.eDpi / 96)) - 50 * (int)(frmClient.eDpi / 96)); + pnlShortcuts.AutoScroll = true; } @@ -145,9 +191,9 @@ private void pnlAddShortcut_Click(object sender, EventArgs e) lblErrorShortcut.Visible = false; // resetting error msg - if (Category.ShortcutList.Count >= 20) + if (Category.ShortcutList.Count >= 50) { - lblErrorShortcut.Text = "Max 20 shortcuts in one group"; + lblErrorShortcut.Text = "Max 50 shortcuts in one group"; lblErrorShortcut.BringToFront(); lblErrorShortcut.Visible = true; } @@ -155,17 +201,17 @@ private void pnlAddShortcut_Click(object sender, EventArgs e) OpenFileDialog openFileDialog = new OpenFileDialog // ask user to select exe file { - InitialDirectory = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs", + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms), Title = "Create New Shortcut", CheckFileExists = true, CheckPathExists = true, Multiselect = true, DefaultExt = "exe", - Filter = "Exe or Shortcut (.exe, .lnk)|*.exe;*.lnk;*.url", + Filter = "Executable or Shortcut|*.exe;*.lnk;*.url;*.bat|All files (*.*)|*.*", RestoreDirectory = true, ReadOnlyChecked = true, DereferenceLinks = false - }; + }; if (openFileDialog.ShowDialog() == DialogResult.OK) { @@ -195,7 +241,8 @@ private void pnlDragDropExt(object sender, DragEventArgs e) { addShortcut(item.ParsingName, true); } - } else + } + else { // Loops through each file to make sure they exist and to add them directly to the shortcut list foreach (var file in files) @@ -211,7 +258,7 @@ private void pnlDragDropExt(object sender, DragEventArgs e) { pnlShortcuts.ScrollControlIntoView(pnlShortcuts.Controls[0]); } - + resetSelection(); } @@ -219,10 +266,36 @@ private void pnlDragDropExt(object sender, DragEventArgs e) private void addShortcut(String file, bool isExtension = false) { String workingDirec = getProperDirectory(file); + String appName = ""; + String appFilePath = expandEnvironment(file); + + appName = getShortcutName(appName, isExtension, appFilePath); + - ProgramShortcut psc = new ProgramShortcut() { FilePath = Environment.ExpandEnvironmentVariables(file), isWindowsApp = isExtension, WorkingDirectory = workingDirec }; //Create new shortcut obj + ProgramShortcut psc = new ProgramShortcut() { FilePath = appFilePath, isWindowsApp = isExtension, WorkingDirectory = workingDirec, name = appName }; //Create new shortcut obj Category.ShortcutList.Add(psc); // Add to panel shortcut list - LoadShortcut(psc, Category.ShortcutList.Count - 1); + LoadShortcut(psc, Category.ShortcutList.Count-1); + } + + // Handle setting/getting shortcut name + public static String getShortcutName(String appName, bool isExtension, String appFilePath) + { + // Grab the file name without the extension to be used later as the naming scheme for the icon .jpg image + if (isExtension) + { + return handleWindowsApp.findWindowsAppsName(appFilePath); + } + else + { + if (System.IO.File.Exists(appFilePath) && Path.GetExtension(appFilePath).ToLower() == ".lnk") + { + return handleExtName(appFilePath); + } + else + { + return Path.GetFileNameWithoutExtension(appFilePath); + } + } } // Delete shortcut @@ -232,30 +305,32 @@ public void DeleteShortcut(ProgramShortcut psc) Category.ShortcutList.Remove(psc); resetSelection(); - bool before = true; + bool after = false; + int controlIndex=0; //int i = 0; foreach (ucProgramShortcut ucPsc in pnlShortcuts.Controls) { - if (before) + if (after) { - ucPsc.Top -= 50; + //ucPsc.Top -= 50 * (int)(frmClient.eDpi / 96); ucPsc.Position -= 1; } if (ucPsc.Shortcut == psc) { //i = pnlShortcuts.Controls.IndexOf(ucPsc); - int controlIndex = pnlShortcuts.Controls.IndexOf(ucPsc); + controlIndex = pnlShortcuts.Controls.IndexOf(ucPsc); - pnlShortcuts.Controls.Remove(ucPsc); + if (controlIndex + 1 != pnlShortcuts.Controls.Count) { try { - pnlShortcuts.ScrollControlIntoView(pnlShortcuts.Controls[controlIndex]); - } catch + pnlShortcuts.ScrollControlIntoView(pnlShortcuts.Controls[controlIndex+1]); + } + catch { if (pnlShortcuts.Controls.Count != 0) { @@ -264,38 +339,44 @@ public void DeleteShortcut(ProgramShortcut psc) } } - before = false; + after = true; } } + pnlShortcuts.Controls.Remove(pnlShortcuts.Controls[controlIndex]); + + /* if (pnlShortcuts.Controls.Count < 5) { - pnlShortcuts.Height -= 50; - pnlAddShortcut.Top -= 50; + pnlShortcuts.Height -= 50 * (int)(frmClient.eDpi / 96); + pnlAddShortcut.Top -= 50 * (int)(frmClient.eDpi / 96); } + */ + pnlShortcuts_ControlAdded(this, new ControlEventArgs(this)); } // Change positions of shortcut panels public void Swap(IList list, int indexA, int indexB) { - resetSelection(); - T tmp = list[indexA]; - list[indexA] = list[indexB]; - list[indexB] = tmp; - - // Clears and reloads all shortcuts with new positions - pnlShortcuts.Controls.Clear(); - pnlShortcuts.Height = 0; - pnlAddShortcut.Top = 220; - - selectedShortcut = null; + // Get move amount via eDPI calculation + int moveAmount = 50 * (int)(frmClient.eDpi / 96); + (list[indexA], list[indexB]) = (list[indexB], list[indexA]); // Swap items + resetSelection(); // Reset item selection + + if (indexA>indexB) + { + //pnlShortcuts.Controls[indexA].Top -= moveAmount; + //pnlShortcuts.Controls[indexB].Top += moveAmount; - int position = 0; - foreach (ProgramShortcut psc in Category.ShortcutList) + pnlShortcuts.Controls.SetChildIndex(pnlShortcuts.Controls[indexB], indexA); + } else { - LoadShortcut(psc, position); - position++; + //pnlShortcuts.Controls[indexA].Top += moveAmount; + //pnlShortcuts.Controls[indexB].Top -= moveAmount; + pnlShortcuts.Controls.SetChildIndex(pnlShortcuts.Controls[indexA], indexB); } + + pnlShortcuts_ControlAdded(this, new ControlEventArgs(this)); } @@ -323,14 +404,15 @@ private void cmdAddGroupIcon_Click(object sender, EventArgs e) RestoreDirectory = true, ReadOnlyChecked = true, DereferenceLinks = false, - }; + }; if (openFileDialog.ShowDialog() == DialogResult.OK) { String imageExtension = Path.GetExtension(openFileDialog.FileName).ToLower(); - handleIcon(openFileDialog.FileName, imageExtension); + + cmdAddGroupIcon.BackgroundImage = handleIcon(openFileDialog.FileName, imageExtension); } } @@ -346,49 +428,173 @@ private void pnlDragDropImg(object sender, DragEventArgs e) if (files.Length == 1 && newExt.Contains(imageExtension) && System.IO.File.Exists(files[0])) { // Checks if the files being added/dropped are an .exe or .lnk in which tye icons need to be extracted/processed - handleIcon(files[0], imageExtension); + cmdAddGroupIcon.BackgroundImage = handleIcon(files[0], imageExtension); } } - private void handleIcon(String file, String imageExtension) + public Bitmap handleIcon(String file, String imageExtension) { // Checks if the files being added/dropped are an .exe or .lnk in which tye icons need to be extracted/processed if (specialImageExt.Contains(imageExtension)) { if (imageExtension == ".lnk") { - cmdAddGroupIcon.BackgroundImage = handleLnkExt(file); + return handleLnkExt(file); } else { - cmdAddGroupIcon.BackgroundImage = Icon.ExtractAssociatedIcon(file).ToBitmap(); + return Icon.ExtractAssociatedIcon(file).ToBitmap(); } } else { - cmdAddGroupIcon.BackgroundImage = Image.FromFile(file); + return BitmapFromFile(file); } - lblAddGroupIcon.Text = "Change group icon"; + } + // Handle returning images of icon files (.lnk) public static Bitmap handleLnkExt(String file) { - IWshShortcut lnkIcon = (IWshShortcut)new WshShell().CreateShortcut(file); - String[] icLocation = lnkIcon.IconLocation.Split(','); - // Check if iconLocation exists to get an .ico from; if not then take the image from the .exe it is referring to - // Checks for link iconLocations as those are used by some applications - if (icLocation[0] != "" && !lnkIcon.IconLocation.Contains("http")) + + /* + Shell shell = new Shell(); + string path = Path.GetDirectoryName(file); // Get individual path/directory strings + string file_name = Path.GetFileName(file); + Shell32.Folder folder = shell.NameSpace(path); // Pass into Shell32 to get link for the shortcut + FolderItem folderItem = folder.ParseName(file_name); + + + ShellLinkObject link = (ShellLinkObject)folderItem.GetLink; + */ + var ShellData = Kaitai.WindowsLnkFile.FromFile(file); + + + var targetPath = ""; + var iconLC = ""; + + // Pass #1 using Kaitai reading + //LnkFile linkFile = Lnk.Lnk.LoadFile(file); + + + if (ShellData.RelPath != null) { - return Icon.ExtractAssociatedIcon(Path.GetFullPath(Environment.ExpandEnvironmentVariables(icLocation[0]))).ToBitmap(); + var test = Path.GetDirectoryName(file); + targetPath = Path.GetFullPath(Path.GetDirectoryName(file) + "\\" + ShellData.RelPath.Str); } - else if (icLocation[0] == "" && lnkIcon.TargetPath == "") + if(ShellData.IconLocation != null && ShellData.IconLocation.Str != null) { - return handleWindowsApp.getWindowsAppIcon(file); - } else + targetPath = ShellData.IconLocation.Str; + } + + /* + + // Pass #2 using Lnk library + if(string.IsNullOrEmpty(targetPath)) + { + LnkFile linkFile = Lnk.Lnk.LoadFile(file); + linkFile.TargetIDs.ForEach(s => + { + var sType = s.GetType().Name.ToUpper(); + if (sType == "SHELLBAG0X2F") + { + targetPath += ((ShellBag0X2F)s).Value + "\\"; + } + else if (sType == "SHELLBAG0X31") + { + targetPath += ((ShellBag0X31)s).ShortName + "\\"; + } + else if (sType == "SHELLBAG0X32") + { + targetPath += ((ShellBag0X32)s).ShortName; + } + else if (sType == "SHELLBAG0X00") + { + ShellBag0X00 castedShellBag = ((ShellBag0X00)s); + //targetPath += ((ShellBag0X00)s).PropertyStore.Sheets.First().PropertyNames.First().Value; // Super super hacky + for (int i = 0; i < castedShellBag.PropertyStore.Sheets.Count; i++) + { + var testPath = ""; + if (castedShellBag.PropertyStore.Sheets[i].PropertyNames.TryGetValue("2", out testPath)) + { + if (System.IO.File.Exists(testPath)) + { + targetPath = testPath; + } + } + } + + //((ShellBag0X00)s).PropertyStore.Sheets.First().PropertyNames.TryGetValue(2, out testPath); // Super super hacky + } + }); + + + if (string.IsNullOrEmpty(iconLC)) + { + iconLC = linkFile.IconLocation; + } + } + + */ + + + //var iconLC = linkFile.IconLocation; + + + // Pass #3 using IWshShortcut (native) + if (string.IsNullOrEmpty(targetPath)) + { + try + { + //string[] testPath = handleWindowsApp.GetLnkTarget(file); // Try using old method to get path + IWshShortcut lnkIcon = (IWshShortcut)new WshShell().CreateShortcut(file); + String[] icLocation = lnkIcon.IconLocation.Split(','); + String testPath = lnkIcon.TargetPath; + + if (string.IsNullOrEmpty(targetPath) && (System.IO.File.Exists(testPath) || Directory.Exists(testPath))) + { + targetPath = testPath; + } + + if (string.IsNullOrEmpty(iconLC)) + { + iconLC = icLocation[0]; + } + + } + catch (Exception e) + { } + } + + + + //String[] icLocation = iconLC.Split(','); + // Check if iconLocation exists to get an .ico from; if not then take the image from the .exe it is referring to + // Checks for link iconLocations as those are used by some applications + + // Return the icon + try { - return Icon.ExtractAssociatedIcon(Path.GetFullPath(Environment.ExpandEnvironmentVariables(lnkIcon.TargetPath))).ToBitmap(); + if (!string.IsNullOrEmpty(iconLC) && !iconLC.Contains("http")) + { + + return Icon.ExtractAssociatedIcon(Path.GetFullPath(expandEnvironment(iconLC))).ToBitmap(); + } + else if (string.IsNullOrEmpty(iconLC) && (targetPath == "" || !System.IO.File.Exists(targetPath))) + { + return handleWindowsApp.getWindowsAppIcon(file); + + } else + { + return Icon.ExtractAssociatedIcon(Path.GetFullPath(expandEnvironment(targetPath))).ToBitmap(); + } + } catch (Exception e) + { + return Icon.ExtractAssociatedIcon(Path.GetFullPath(expandEnvironment(file))).ToBitmap(); } + + } @@ -419,14 +625,14 @@ private void pnlDragDropEnterImg(object sender, DragEventArgs e) { resetSelection(); - if (checkExtensions(e, imageExt.Concat(specialImageExt).ToArray())) + if (checkExtensions(e, newExt)) { pnlGroupIcon.BackColor = Color.FromArgb(23, 23, 23); } } // Series of checks to make sure it can be dropped - private Boolean checkExtensions(DragEventArgs e, String[] exts) + public Boolean checkExtensions(DragEventArgs e, String[] exts) { // Make sure the file can be dragged dropped @@ -468,9 +674,9 @@ private Boolean checkExtensions(DragEventArgs e, String[] exts) // Exit editor private void cmdExit_Click(object sender, EventArgs e) { - this.Hide(); - this.Dispose(); - Client.Reload(); //flush and reload category panels + this.Close(); + Client.Reload(); //flush and reload category panel + Client.Reset(); } // Save group @@ -485,8 +691,8 @@ private void cmdSave_Click(object sender, EventArgs e) lblErrorTitle.Text = "Must select a name"; lblErrorTitle.Visible = true; } - else if (IsNew && Directory.Exists(@MainPath.path + @"\config\" + txtGroupName.Text) || - !IsNew && Category.Name != txtGroupName.Text && Directory.Exists(@MainPath.path + @"\config\" + txtGroupName.Text)) + else if (IsNew && Directory.Exists(Path.Combine(Paths.ConfigPath, txtGroupName.Text)) || + !IsNew && Category.Name != txtGroupName.Text && Directory.Exists(Path.Combine(Paths.ConfigPath, txtGroupName.Text))) { lblErrorTitle.Text = "There is already a group with that name"; lblErrorTitle.Visible = true; @@ -496,12 +702,6 @@ private void cmdSave_Click(object sender, EventArgs e) lblErrorTitle.Text = "Name must not have any special characters"; lblErrorTitle.Visible = true; } - else if (cmdAddGroupIcon.BackgroundImage == - global::client.Properties.Resources.AddWhite) // Verify icon - { - lblErrorIcon.Text = "Must select group icon"; - lblErrorIcon.Visible = true; - } else if (Category.ShortcutList.Count == 0) // Verify shortcuts { lblErrorShortcut.Text = "Must select at least one shortcut"; @@ -509,25 +709,21 @@ private void cmdSave_Click(object sender, EventArgs e) } else { + if ((string)cmdAddGroupIcon.Tag == "Unchanged") // Verify icon + { + cmdAddGroupIcon.BackgroundImage = constructIcons(); + //lblErrorIcon.Text = "Must select group icon"; + //lblErrorIcon.Visible = true; + } try { - - foreach(ProgramShortcut shortcutModifiedItem in shortcutChanged) - { - if (!Directory.Exists(shortcutModifiedItem.WorkingDirectory)) - { - shortcutModifiedItem.WorkingDirectory = getProperDirectory(shortcutModifiedItem.FilePath); - } - } - - if (!IsNew) { // // Delete old config // - string configPath = @MainPath.path + @"\config\" + Category.Name; - string shortcutPath = @MainPath.path + @"\Shortcuts\" + Regex.Replace(Category.Name, @"(_)+", " ") + ".lnk"; + string configPath = Path.Combine(Paths.ConfigPath, Category.Name); + string shortcutPath = Path.Combine(Paths.ShortcutsPath, Regex.Replace(Category.Name, @"(_)+", " ") + ".lnk"); try { @@ -538,7 +734,8 @@ private void cmdSave_Click(object sender, EventArgs e) fm.Delete(shortcutPath); scope1.Complete(); } - } catch (Exception) + } + catch (Exception ex) { MessageBox.Show("Please close all programs used within the taskbar group in order to save!"); return; @@ -557,9 +754,9 @@ private void cmdSave_Click(object sender, EventArgs e) Category.Name = Regex.Replace(txtGroupName.Text, @"\s+", "_"); Category.CreateConfig(cmdAddGroupIcon.BackgroundImage); // Creating group config files - Client.LoadCategory(Path.GetFullPath(@"config\" + Category.Name)); // Loading visuals - - this.Dispose(); + Client.LoadCategory(Path.Combine(Paths.ConfigPath, Category.Name)); // Loading visuals + + this.Close(); Client.Reload(); } catch (IOException ex) @@ -579,8 +776,8 @@ private void cmdDelete_Click(object sender, EventArgs e) try { - string configPath = @MainPath.path + @"\config\" + Category.Name; - string shortcutPath = @MainPath.path + @"\Shortcuts\" + Regex.Replace(Category.Name, @"(_)+", " ") + ".lnk"; + string configPath = Path.Combine(Paths.ConfigPath, Category.Name); + string shortcutPath = Path.Combine(Paths.ShortcutsPath, Regex.Replace(Category.Name, @"(_)+", " ") + ".lnk"); var dir = new DirectoryInfo(configPath); @@ -591,8 +788,10 @@ private void cmdDelete_Click(object sender, EventArgs e) { fm.DeleteDirectory(configPath); fm.Delete(shortcutPath); - this.Hide(); - this.Dispose(); + //this.Hide(); + //this.Dispose(); + this.Close(); + Client.Reload(); //flush and reload category panels scope1.Complete(); } @@ -652,27 +851,44 @@ private void cmdWidthDown_Click(object sender, EventArgs e) } } - // Color radio buttons - private void radioCustom_Click(object sender, EventArgs e) + // Custom colors + private void radioCustom_Click(object sender, MouseEventArgs e) { if (colorDialog.ShowDialog() == DialogResult.OK) { - Category.ColorString = System.Drawing.ColorTranslator.ToHtml(colorDialog.Color); - pnlCustomColor.Visible = true; + Category.ColorString = ColorTranslator.ToHtml(colorDialog.Color); + //pnlCustomColor.Visible = true; pnlCustomColor.BackColor = colorDialog.Color; + + pnlCustomColor1.BackColor = Category.calculateHoverColor(); + Category.HoverColor = ColorTranslator.ToHtml(pnlCustomColor1.BackColor); + } + } + + private void pnlCustomColor1_Click(object sender, EventArgs e) + { + if (colorDialog.ShowDialog() == DialogResult.OK) + { + Category.HoverColor = ColorTranslator.ToHtml(colorDialog.Color); + pnlCustomColor1.BackColor = colorDialog.Color; } } private void radioDark_Click(object sender, EventArgs e) { Category.ColorString = System.Drawing.ColorTranslator.ToHtml(Color.FromArgb(31, 31, 31)); - pnlCustomColor.Visible = false; + //pnlCustomColor.Visible = false; } private void radioLight_Click(object sender, EventArgs e) { Category.ColorString = System.Drawing.ColorTranslator.ToHtml(Color.FromArgb(230, 230, 230)); - pnlCustomColor.Visible = false; + //pnlCustomColor.Visible = false; + } + + private void radioSystem_Click(object sender, EventArgs e) + { + Category.ColorString = "sys"; } // Opacity buttons @@ -753,14 +969,28 @@ private void txtGroupName_TextChanged(object sender, EventArgs e) } //-------------------------------------- - // SHORTCUT/PRGORAM SELECTION + // SHORTCUT/PROGRAM SELECTION //-------------------------------------- // Deselect selected program/shortcut public void resetSelection() { + // If either timer has pending checks, do them before selected shortcut gets nulled + if(validaitonTimerDirec.Enabled) + { + validaitonTimerDirec.Stop(); + validaitonTimerDirec_Tick(this, new EventArgs()); + } + if(validationTimerPrgm.Enabled) + { + validationTimerPrgm.Stop(); + validationTimer_Tick(this, new EventArgs()); + } + pnlArgumentTextbox.Enabled = false; cmdSelectDirectory.Enabled = false; + pnlProgramPath.Enabled = false; + cmdSelectProgramPath.Enabled = false; if (selectedShortcut != null) { pnlColor.Visible = true; @@ -781,6 +1011,10 @@ public void enableSelection(ucProgramShortcut passedShortcut) pnlArgumentTextbox.Text = Category.ShortcutList[selectedShortcut.Position].Arguments; pnlArgumentTextbox.Enabled = true; + pnlProgramPath.Text = Category.ShortcutList[selectedShortcut.Position].FilePath; + pnlProgramPath.Enabled = true; + cmdSelectProgramPath.Enabled = true; + pnlWorkingDirectory.Text = Category.ShortcutList[selectedShortcut.Position].WorkingDirectory; pnlWorkingDirectory.Enabled = true; cmdSelectDirectory.Enabled = true; @@ -825,24 +1059,73 @@ private void cmdSelectDirectory_Click(object sender, EventArgs e) if (openFileDialog.ShowDialog() == CommonFileDialogResult.Ok) { - this.Focus(); Category.ShortcutList[selectedShortcut.Position].WorkingDirectory = openFileDialog.FileName; + pnlWorkingDirectory.Text = openFileDialog.FileName; + } + this.Focus(); + } + + private void cmdSelectProgramPath_Click(object sender, EventArgs e) + { + CommonOpenFileDialog openFileDialog = new CommonOpenFileDialog() + { + EnsurePathExists = true, + IsFolderPicker = false, + InitialDirectory = Category.ShortcutList[selectedShortcut.Position].WorkingDirectory + }; + + if (openFileDialog.ShowDialog() == CommonFileDialogResult.Ok) + { + Category.ShortcutList[selectedShortcut.Position].FilePath = openFileDialog.FileName; + pnlProgramPath.Text = openFileDialog.FileName; } + this.Focus(); } + + // Wait 1 second for user to "finish typing" + // Reset the timer everytime the text is changed private void pnlWorkingDirectory_TextChanged(object sender, EventArgs e) { - Category.ShortcutList[selectedShortcut.Position].WorkingDirectory = pnlWorkingDirectory.Text; + validaitonTimerDirec.Stop(); + validaitonTimerDirec.Start(); + } + + private void pnlProgramPath_TextChanged(object sender, EventArgs e) + { + validationTimerPrgm.Stop(); + validationTimerPrgm.Start(); + } - if (!shortcutChanged.Contains(Category.ShortcutList[selectedShortcut.Position])) + // Both timers actively validate the path after a certain amount of time + private void validationTimer_Tick(object sender, EventArgs e) + { + validationTimerPrgm.Stop(); + if (fileRegex.IsMatch(pnlProgramPath.Text)) { - shortcutChanged.Add(Category.ShortcutList[selectedShortcut.Position]); + if (System.IO.File.Exists(pnlProgramPath.Text)) + { + Category.ShortcutList[selectedShortcut.Position].FilePath = pnlProgramPath.Text; + } + } + } + + private void validaitonTimerDirec_Tick(object sender, EventArgs e) + { + validaitonTimerDirec.Stop(); + if (directoryRegex.IsMatch(pnlWorkingDirectory.Text)) + { + if (System.IO.Directory.Exists(pnlWorkingDirectory.Text)) + { + Category.ShortcutList[selectedShortcut.Position].WorkingDirectory = pnlWorkingDirectory.Text; + } } } private String getProperDirectory(String file) { - try { + try + { if (Path.GetExtension(file).ToLower() == ".lnk") { IWshShortcut extension = (IWshShortcut)new WshShell().CreateShortcut(file); @@ -853,15 +1136,222 @@ private String getProperDirectory(String file) { return Path.GetDirectoryName(file); } - } catch (Exception) + } + catch (Exception) { - return MainPath.exeString; + return Paths.exeString; } } private void frmGroup_MouseClick(object sender, MouseEventArgs e) { + if (pnlDeleteConfo.Visible) + { + pnlDeleteConfo.Visible = false; + } + resetSelection(); } + + public static String expandEnvironment(string path) + { + if (path.Contains("%ProgramFiles%")) + { + path = path.Replace("%ProgramFiles%", "%ProgramW6432%"); + } + + return Environment.ExpandEnvironmentVariables(path); + } + + private void frmGroup_SizeChanged(object sender, EventArgs e) + { + if (pnlAddShortcut.Bounds.IntersectsWith(pnlShortcuts.Bounds) || pnlColor.Bounds.IntersectsWith(pnlAddShortcut.Bounds)) + { + this.MinimumSize = new Size(this.MinimumSize.Width, this.Height); + } + + if (pnlDeleteConfo.Visible) + { + Point deleteButton = cmdDelete.FindForm().PointToClient(cmdDelete.Parent.PointToScreen(cmdDelete.Location)); + pnlDeleteConfo.Location = new Point(deleteButton.X - 63, deleteButton.Y - 100); + } + + pnlAddShortcut.Location = new Point(pnlAddShortcut.Location.X, pnlShortcuts.Bottom + (int)(20 * frmClient.eDpi / 96)); + pnlAddShortcut.Left = (this.ClientSize.Width - pnlAddShortcut.Width) / 2; + } + + private void openDeleteConformation(object sender, EventArgs e) + { + Point deleteButton = cmdDelete.FindForm().PointToClient(cmdDelete.Parent.PointToScreen(cmdDelete.Location)); + pnlDeleteConfo.Location = new Point(deleteButton.X - 63, deleteButton.Y - 100); + pnlDeleteConfo.Visible = true; + } + + private Image constructIcons() + { + List iconImages = new List(); + if (pnlShortcuts.Controls.Count >= 4) + { + for (int i = 0; i < 4; i++) + { + iconImages.Insert(0, ((ucProgramShortcut)pnlShortcuts.Controls[i]).logo); + } + } + else + { + foreach (ucProgramShortcut controlItem in pnlShortcuts.Controls) + { + iconImages.Insert(0, controlItem.logo); + } + } + + var image = new Bitmap(256, 256, PixelFormat.Format32bppArgb); + using (var g = Graphics.FromImage(image)) + { + g.Clear(Color.Transparent); + + PointF drawLocation = new PointF(0, 0); + int counter = 0; + + foreach (Image iconImage in iconImages) + { + if (counter == 2) + { + counter = 0; + drawLocation.Y += 128; + drawLocation.X = 0; + } + + g.DrawImage(ImageFunctions.ResizeImage(iconImage, 128, 128), drawLocation); + + drawLocation.X += 128; + counter += 1; + + + } + g.Dispose(); + } + return image; + } + + private void cmdAddGroupIcon_BackgroundImageChanged(object sender, EventArgs e) + { + cmdAddGroupIcon.Tag = "Changed"; + } + + public static Bitmap BitmapFromFile(string path) + { + var bytes = System.IO.File.ReadAllBytes(path); + var ms = new MemoryStream(bytes); + var bp = (Bitmap)Image.FromStream(ms); + return bp; + } + + private void pnlShortcuts_ControlAdded(object sender, ControlEventArgs e) + { + for(int i=0; i< pnlShortcuts.Controls.Count; i++) + { + ((ucProgramShortcut)pnlShortcuts.Controls[i]).ucProgramShortcut_ReadjustArrows(i); + } + } + + // Icon size + private void IconSizeTopButton_Click(object sender, EventArgs e) + { + int iconSize = int.Parse(lblIconSize.Text); + iconSize += 1; + Category.IconSize = iconSize; + lblIconSize.Text = iconSize.ToString(); + IconSizeBottomButton.Enabled = true; + IconSizeBottomButton.BackgroundImage = global::client.Properties.Resources.NumDownWhite; + + if (iconSize > 255) + { + IconSizeTopButton.Enabled = false; + IconSizeTopButton.BackgroundImage = global::client.Properties.Resources.NumUpGray; + } + } + + private void IconSizeBottomButton_Click(object sender, EventArgs e) + { + int iconSize = int.Parse(lblIconSize.Text); + iconSize -= 1; + Category.IconSize = iconSize; + lblIconSize.Text = iconSize.ToString(); + IconSizeTopButton.Enabled = true; + IconSizeTopButton.BackgroundImage = global::client.Properties.Resources.NumUpWhite; + + if (iconSize < 11) + { + IconSizeBottomButton.Enabled = false; + IconSizeBottomButton.BackgroundImage = global::client.Properties.Resources.NumDownGray; + } + } + + // Icon separation + private void IconSeparationTopButton_Click(object sender, EventArgs e) + { + int separation = int.Parse(lblIconSeparation.Text); + separation += 1; + Category.Separation = separation; + lblIconSeparation.Text = separation.ToString(); + IconSeparationBottomButton.Enabled = true; + IconSeparationBottomButton.BackgroundImage = global::client.Properties.Resources.NumDownWhite; + + if (separation > 49) + { + IconSeparationTopButton.Enabled = false; + IconSeparationTopButton.BackgroundImage = global::client.Properties.Resources.NumUpGray; + } + } + + private void IconSeparationBottomButton_Click(object sender, EventArgs e) + { + int separation = int.Parse(lblIconSeparation.Text); + separation -= 1; + Category.Separation = separation; + lblIconSeparation.Text = separation.ToString(); + IconSeparationTopButton.Enabled = true; + IconSeparationTopButton.BackgroundImage = global::client.Properties.Resources.NumUpWhite; + + if (separation < 2) + { + IconSeparationBottomButton.Enabled = false; + IconSeparationBottomButton.BackgroundImage = global::client.Properties.Resources.NumDownGray; + } + } + + private void cmdRightSettings_Click(object sender, EventArgs e) + { + if(groupSettingsTabControl.SelectedIndex 0) + { + groupSettingsTabControl.SelectedIndex -= 1; + cmdRightSettings.Enabled = true; + cmdRightSettings.BackgroundImage = Resources.RightArrow; + + if (groupSettingsTabControl.SelectedIndex == 0) + { + cmdLeftSettings.BackgroundImage = Resources.LeftArrowGrey; + cmdLeftSettings.Enabled = false; + } + } + } } } diff --git a/main/Forms/frmGroup.resx b/main/Forms/frmGroup.resx index d325534..0d615e1 100644 --- a/main/Forms/frmGroup.resx +++ b/main/Forms/frmGroup.resx @@ -117,10 +117,40 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vAAADrwBlbxySQAABChJREFUeF7tnT1rFUEUhvM78gf8G6kCCSHfX4WFlbewsUh+hZWFlY3YWAkWlhYR + BAsLQVALG0EQQcRCEDt9nzALS9yQnJm5ySneB172okmK59zd2TMz9+6CMcYYY4wx+VhaWlrc2tq6M5vN + Tnhd/tlcNchX9sVHHf+Sw8PDly7KNYD0g4ODp0MhxlleXr5ZfszMGwlf3N3dvbuysvLnbCGG6P+/6Oiz + ZJ4gmHe+ZH8eyz8vOnuOyq+ankju6TihseHFWPhFKWeQz5KeIHR7e/v+WHQkZYxxUVpBot7ht3Qr+20s + uDL75c+aKJJ3ennSO/v1SGh1VldXfx8fH98of95EkEDunh6elVob9SaPdfTlKgrS1tfXb29sbPwcC62N + zq63Ou4rLkYEhCFOvENkazY3N39QWL12IaIgTYV4MhbaknKpcyGiII1JQAbbsdDalHkrX56iIIwue29v + 79MgsyVMjfD39NqFiIAwhS77+SCzNRor7unoQkRBWkuXfTa6e3qmoy9PURDG5UTF+DrIbElZ63AhoiAM + cWWgnZQbydra2i9uAPTahYiCtJ5dtgb/Rzq6EFGQRjNGUzYWWhuNE2909OUpCsIQV6YpJuVGwqwus7t6 + 7UJEQVqZuJuUG83Ozs4DHV2IKEjr3GWzAujLUxSEde6yP7vLrgBhSrcumzVujTlHeu1CREFamaKYlBtN + 6bJdiChI427HXfY1gzDE6fL0CpGtcZfdANLcZScAabyLO65lu8uuAWGIk8D3iGyNivrdXXYlSFMhJneM + 18RddiVIowegFxgLrY277EoQRlfMGvQgsyXusitBmBLeMX5e3GU3gLSet7FlzHEhoiCNu51ei0VlR6HH + iSgIQ5zeyR8Q2Rr6Em/JrARpPReLyqXOhYiCtM6LRd6S2UKZuJuUGwmzur6N7YAE8m6elHzZeEtmRySy + uiAa/L0lszdF6KTwi+KCzIEidFL4ZeNLVkc8qCcDgb7tTQgC3RgmA4GKp06ygUBPLiYEgZ5+TwYCFS9Q + ZQOBXsJNCAJ5h3uTQzIQWMaESdHReBtQBxCoeKNcNhBIt++tpMlAYM/bZG+27gACFX8cIRsIZDzwB3aS + gUB/pC0ZCFT8oc9sIJDu3B+LTgYCOy+KudvvAQJ7Loq52+8AAhV/+Uw2EOivZ0oIAt3tJwOBCrfJ/oq/ + TCCQ21p3+8lAoIrir4nNBPKQ2KvbJ94C2wEEdu72/VXjPUBg527fW2B7gEAN1n5cRSYQqKgufqBLKhCI + SD/yKBkI7NntlwlQF6UFBCpMWvqxeZmQTD9YMiOS6UevZgOhSngnP2v4OroY8wK5dOesyY/FnxedHUfl + V808kWzuxvyA+2wgvIwR/xWEM6n8mLlKJH/o9lkzOS1Gmd/y2XGdUAAmLWez2YmLYYwxxhiTk4WFf7l5 + hhZ7VJBTAAAAAElFTkSuQmCC + + - 17, 17 + 25, 17 + + + 139, 17 + + + 304, 17 - AAABAAYAAAAAAAEAIAB1JQAAZgAAAICAAAABACAAKAgBANslAABAQAAAAQAgAChCAAADLgEAMDAAAAEA diff --git a/main/Properties/AssemblyInfo.cs b/main/Properties/AssemblyInfo.cs index 26b671a..2c3a648 100644 --- a/main/Properties/AssemblyInfo.cs +++ b/main/Properties/AssemblyInfo.cs @@ -6,12 +6,12 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("TaskbarGroups")] +[assembly: AssemblyTitle("Taskbar Groups")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Jack Schierbeck")] -[assembly: AssemblyProduct("TaskbarGroups")] -[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyProduct("Taskbar Groups")] +[assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -33,6 +33,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.2.0.0")] -[assembly: AssemblyFileVersion("0.2.0.0")] +[assembly: AssemblyVersion("0.2.2.1")] +[assembly: AssemblyFileVersion("0.2.2.1")] [assembly: NeutralResourcesLanguage("en")] diff --git a/main/Properties/Resources.Designer.cs b/main/Properties/Resources.Designer.cs index d4bfcc4..f7137f1 100644 --- a/main/Properties/Resources.Designer.cs +++ b/main/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace client.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -100,6 +100,16 @@ internal static System.Drawing.Bitmap AddWhite { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] ChinhDo_Transactions_FileManager { + get { + object obj = ResourceManager.GetObject("ChinhDo_Transactions_FileManager", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -110,6 +120,66 @@ internal static System.Drawing.Bitmap Error { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap grayline { + get { + object obj = ResourceManager.GetObject("grayline", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Kaitai_Struct_Runtime { + get { + object obj = ResourceManager.GetObject("Kaitai_Struct_Runtime", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap LeftArrow { + get { + object obj = ResourceManager.GetObject("LeftArrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap LeftArrowGrey { + get { + object obj = ResourceManager.GetObject("LeftArrowGrey", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Microsoft_WindowsAPICodePack { + get { + object obj = ResourceManager.GetObject("Microsoft_WindowsAPICodePack", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Microsoft_WindowsAPICodePack_Shell { + get { + object obj = ResourceManager.GetObject("Microsoft_WindowsAPICodePack_Shell", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -170,6 +240,36 @@ internal static System.Drawing.Bitmap NumUpWhite { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap pencil { + get { + object obj = ResourceManager.GetObject("pencil", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap RightArrow { + get { + object obj = ResourceManager.GetObject("RightArrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap RightArrowGrey { + get { + object obj = ResourceManager.GetObject("RightArrowGrey", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -179,5 +279,35 @@ internal static System.Drawing.Bitmap Subtract { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Taskbar_Groups_Background { + get { + object obj = ResourceManager.GetObject("Taskbar_Groups_Background", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap toggleOff { + get { + object obj = ResourceManager.GetObject("toggleOff", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap toggleOn { + get { + object obj = ResourceManager.GetObject("toggleOn", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/main/Properties/Resources.resx b/main/Properties/Resources.resx index c368015..5e30b5b 100644 --- a/main/Properties/Resources.resx +++ b/main/Properties/Resources.resx @@ -130,9 +130,30 @@ ..\Resources\AddIconWhite.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\lib\ChinhDo.Transactions.FileManager.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\Error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\grayline.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\lib\kaitai.struct.runtime.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\resources\leftarrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\resources\leftarrowgrey.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\lib\Microsoft.WindowsAPICodePack.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\lib\Microsoft.WindowsAPICodePack.Shell.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\NumDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -151,7 +172,25 @@ ..\Resources\NumUpWhite.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\pencil.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\resources\rightarrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\resources\rightarrowgrey.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\Subtract.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Taskbar Groups Background.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\toggleOff.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\toggleOn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/main/Resources/LeftArrow.png b/main/Resources/LeftArrow.png new file mode 100644 index 0000000..6ff399e Binary files /dev/null and b/main/Resources/LeftArrow.png differ diff --git a/main/Resources/LeftArrowGrey.png b/main/Resources/LeftArrowGrey.png new file mode 100644 index 0000000..a520045 Binary files /dev/null and b/main/Resources/LeftArrowGrey.png differ diff --git a/main/Resources/RightArrow.png b/main/Resources/RightArrow.png new file mode 100644 index 0000000..ce0dc21 Binary files /dev/null and b/main/Resources/RightArrow.png differ diff --git a/main/Resources/RightArrowGrey.png b/main/Resources/RightArrowGrey.png new file mode 100644 index 0000000..7c5bfcd Binary files /dev/null and b/main/Resources/RightArrowGrey.png differ diff --git a/main/Resources/grayline.png b/main/Resources/grayline.png new file mode 100644 index 0000000..aed1828 Binary files /dev/null and b/main/Resources/grayline.png differ diff --git a/main/Resources/pencil.png b/main/Resources/pencil.png new file mode 100644 index 0000000..26eaa4d Binary files /dev/null and b/main/Resources/pencil.png differ diff --git a/main/Resources/toggleOff.png b/main/Resources/toggleOff.png new file mode 100644 index 0000000..7ae561d Binary files /dev/null and b/main/Resources/toggleOff.png differ diff --git a/main/Resources/toggleOn.png b/main/Resources/toggleOn.png new file mode 100644 index 0000000..cba8509 Binary files /dev/null and b/main/Resources/toggleOn.png differ diff --git a/main/User controls/ucCategoryPanel.Designer.cs b/main/User controls/ucCategoryPanel.Designer.cs index 3541d35..47ea3de 100644 --- a/main/User controls/ucCategoryPanel.Designer.cs +++ b/main/User controls/ucCategoryPanel.Designer.cs @@ -31,6 +31,7 @@ private void InitializeComponent() this.lblTitle = new System.Windows.Forms.Label(); this.cmdDelete = new System.Windows.Forms.Button(); this.picGroupIcon = new System.Windows.Forms.PictureBox(); + this.pnlShortcuts = new System.Windows.Forms.FlowLayoutPanel(); ((System.ComponentModel.ISupportInitialize)(this.picGroupIcon)).BeginInit(); this.SuspendLayout(); // @@ -50,6 +51,7 @@ private void InitializeComponent() // // cmdDelete // + this.cmdDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.cmdDelete.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(76)))), ((int)(((byte)(76))))); this.cmdDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(148)))), ((int)(((byte)(148)))), ((int)(((byte)(148))))); this.cmdDelete.FlatAppearance.BorderSize = 0; @@ -76,16 +78,33 @@ private void InitializeComponent() this.picGroupIcon.MouseEnter += new System.EventHandler(this.lblTitle_MouseEnter); this.picGroupIcon.MouseLeave += new System.EventHandler(this.lblTitle_MouseLeave); // + // pnlShortcuts + // + this.pnlShortcuts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlShortcuts.AutoSize = true; + this.pnlShortcuts.Location = new System.Drawing.Point(88, 44); + this.pnlShortcuts.Name = "pnlShortcuts"; + this.pnlShortcuts.Size = new System.Drawing.Size(400, 21); + this.pnlShortcuts.TabIndex = 22; + this.pnlShortcuts.Click += new System.EventHandler(this.OpenFolder); + this.pnlShortcuts.MouseEnter += new System.EventHandler(this.lblTitle_MouseEnter); + this.pnlShortcuts.MouseLeave += new System.EventHandler(this.lblTitle_MouseLeave); + // // ucCategoryPanel // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(3)))), ((int)(((byte)(3))))); + this.Controls.Add(this.pnlShortcuts); this.Controls.Add(this.picGroupIcon); this.Controls.Add(this.cmdDelete); this.Controls.Add(this.lblTitle); + this.DoubleBuffered = true; this.Name = "ucCategoryPanel"; - this.Size = new System.Drawing.Size(680, 100); + this.Size = new System.Drawing.Size(668, 68); this.Load += new System.EventHandler(this.ucNewCategory_Load); this.Click += new System.EventHandler(this.OpenFolder); ((System.ComponentModel.ISupportInitialize)(this.picGroupIcon)).EndInit(); @@ -98,5 +117,6 @@ private void InitializeComponent() private System.Windows.Forms.Label lblTitle; private System.Windows.Forms.Button cmdDelete; private System.Windows.Forms.PictureBox picGroupIcon; + private System.Windows.Forms.FlowLayoutPanel pnlShortcuts; } } \ No newline at end of file diff --git a/main/User controls/ucCategoryPanel.cs b/main/User controls/ucCategoryPanel.cs index 177aea2..b0a1752 100644 --- a/main/User controls/ucCategoryPanel.cs +++ b/main/User controls/ucCategoryPanel.cs @@ -21,11 +21,11 @@ public ucCategoryPanel(frmClient client, Category category) picGroupIcon.BackgroundImage = Category.LoadIconImage(); // starting values for position of shortcuts - int x = 90; - int y = 55; + int x = (int)(90 * frmClient.eDpi / 96); + int y = (int)(56 * frmClient.eDpi / 96); int columns = 1; - if (!Directory.Exists((@"config\" + category.Name) + "\\Icons\\")) + if (!Directory.Exists(Path.Combine(Paths.ConfigPath, category.Name, "Icons"))) { category.cacheIcons(); } @@ -34,13 +34,13 @@ public ucCategoryPanel(frmClient client, Category category) { if (columns == 8) { - x = 90; // resetting x - y += 40; // adding new row - this.Height += 40; + x = (int)(90 * frmClient.eDpi / 96); // resetting x + y += (int)(40 * frmClient.eDpi / 96); // adding new row + //this.Height += (int)(40 * frmClient.eDpi / 96); columns = 1; } CreateShortcut(x, y, psc); - x += 50; + x += (int)(50 * frmClient.eDpi / 96); columns++; } } @@ -52,7 +52,7 @@ private void CreateShortcut(int x, int y, ProgramShortcut programShortcut) { BackColor = System.Drawing.Color.Transparent, Location = new System.Drawing.Point(x, y), - Size = new System.Drawing.Size(30, 30), + Size = new System.Drawing.Size((int)(30 * frmClient.eDpi / 96), (int)(30 * frmClient.eDpi / 96)), BackgroundImageLayout = ImageLayout.Stretch, TabStop = false }; @@ -63,7 +63,7 @@ private void CreateShortcut(int x, int y, ProgramShortcut programShortcut) // Check if file is stil existing and if so render it if (File.Exists(programShortcut.FilePath) || Directory.Exists(programShortcut.FilePath) || programShortcut.isWindowsApp) { - this.shortcutPanel.BackgroundImage = Category.loadImageCache(programShortcut); + this.shortcutPanel.BackgroundImage = ImageFunctions.ResizeImage(Category.loadImageCache(programShortcut), shortcutPanel.Width, shortcutPanel.Height); } else // if file does not exist { @@ -76,7 +76,7 @@ private void CreateShortcut(int x, int y, ProgramShortcut programShortcut) tt.SetToolTip(this.shortcutPanel, "Program does not exist"); } - this.Controls.Add(this.shortcutPanel); + this.pnlShortcuts.Controls.Add(this.shortcutPanel); this.shortcutPanel.Show(); this.shortcutPanel.BringToFront(); } @@ -92,7 +92,7 @@ public void OpenFolder(object sender, EventArgs e) // Open the shortcut folder for the group when click on category panel // Build path based on the directory of the main .exe file - string filePath = Path.GetFullPath(new Uri($"{MainPath.path}\\Shortcuts").LocalPath + "\\" + Category.Name + ".lnk"); + string filePath = Path.Combine(Paths.ShortcutsPath, Regex.Replace(Category.Name, @"_+", " ") + ".lnk"); // Open directory in explorer and highlighting file System.Diagnostics.Process.Start("explorer.exe", string.Format("/select,\"{0}\"", @filePath)); @@ -100,9 +100,14 @@ public void OpenFolder(object sender, EventArgs e) private void cmdDelete_Click(object sender, EventArgs e) { - frmGroup editGroup = new frmGroup(Client, Category); - editGroup.Show(); - editGroup.BringToFront(); + if (!Client.editOpened) + { + frmGroup editGroup = new frmGroup(Client, Category); + editGroup.Show(); + editGroup.BringToFront(); + editGroup.FormClosed += new FormClosedEventHandler(frmGroup_Closed); + Client.editOpened = true; + } } public static Bitmap LoadBitmap(string path) // needed to access img without occupying read/write @@ -133,5 +138,10 @@ private void lblTitle_MouseLeave(object sender, EventArgs e) // public System.Windows.Forms.PictureBox shortcutPanel; + private void frmGroup_Closed(object sender, FormClosedEventArgs e) + { + Client.editOpened = false; + } + } } diff --git a/main/User controls/ucProgramShortcut.Designer.cs b/main/User controls/ucProgramShortcut.Designer.cs index a330c48..2279e4a 100644 --- a/main/User controls/ucProgramShortcut.Designer.cs +++ b/main/User controls/ucProgramShortcut.Designer.cs @@ -33,18 +33,21 @@ private void InitializeComponent() this.cmdNumDown = new System.Windows.Forms.Button(); this.picShortcut = new System.Windows.Forms.PictureBox(); this.txtShortcutName = new System.Windows.Forms.TextBox(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); ((System.ComponentModel.ISupportInitialize)(this.picShortcut)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // cmdDelete // + this.cmdDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.cmdDelete.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(76)))), ((int)(((byte)(76))))); this.cmdDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(148)))), ((int)(((byte)(148)))), ((int)(((byte)(148))))); this.cmdDelete.FlatAppearance.BorderSize = 0; this.cmdDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.cmdDelete.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cmdDelete.ForeColor = System.Drawing.Color.White; - this.cmdDelete.Location = new System.Drawing.Point(345, 11); + this.cmdDelete.Location = new System.Drawing.Point(362, 11); this.cmdDelete.Name = "cmdDelete"; this.cmdDelete.Size = new System.Drawing.Size(83, 27); this.cmdDelete.TabIndex = 21; @@ -89,57 +92,78 @@ private void InitializeComponent() // picShortcut // this.picShortcut.BackgroundImage = global::client.Properties.Resources.AddWhite; - this.picShortcut.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.picShortcut.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.picShortcut.Cursor = System.Windows.Forms.Cursors.Hand; this.picShortcut.Location = new System.Drawing.Point(69, 9); this.picShortcut.Margin = new System.Windows.Forms.Padding(30, 30, 10, 30); this.picShortcut.Name = "picShortcut"; this.picShortcut.Size = new System.Drawing.Size(30, 30); + this.picShortcut.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.picShortcut.TabIndex = 17; this.picShortcut.TabStop = false; - this.picShortcut.MouseEnter += new System.EventHandler(this.ucProgramShortcut_MouseEnter); - this.picShortcut.MouseLeave += new System.EventHandler(this.ucProgramShortcut_MouseLeave); + this.picShortcut.BackgroundImageChanged += new System.EventHandler(this.picShortcut_BackgroundImageChanged); + this.picShortcut.Click += new System.EventHandler(this.picShortcut_Click); + this.picShortcut.DragDrop += new System.Windows.Forms.DragEventHandler(this.picShortcut_DragDrop); + this.picShortcut.DragEnter += new System.Windows.Forms.DragEventHandler(this.picShortcut_DragEnter); // // txtShortcutName // + this.txtShortcutName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); this.txtShortcutName.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); this.txtShortcutName.BorderStyle = System.Windows.Forms.BorderStyle.None; this.txtShortcutName.Cursor = System.Windows.Forms.Cursors.Arrow; this.txtShortcutName.Font = new System.Drawing.Font("Segoe UI", 12F); this.txtShortcutName.ForeColor = System.Drawing.Color.White; this.txtShortcutName.Location = new System.Drawing.Point(112, 13); - this.txtShortcutName.MaxLength = 27; this.txtShortcutName.Name = "txtShortcutName"; - this.txtShortcutName.Size = new System.Drawing.Size(214, 22); + this.txtShortcutName.Size = new System.Drawing.Size(205, 22); this.txtShortcutName.TabIndex = 31; this.txtShortcutName.TabStop = false; this.txtShortcutName.Text = "Program Name"; this.txtShortcutName.Click += new System.EventHandler(this.txtShortcutName_Click); this.txtShortcutName.TextChanged += new System.EventHandler(this.lbTextbox_TextChanged); - this.txtShortcutName.Enter += new System.EventHandler(this.ucProgramShortcut_Enter); this.txtShortcutName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ucProgramShortcut_KeyDown); - this.txtShortcutName.Leave += new System.EventHandler(this.ucProgramShortcut_Leave); this.txtShortcutName.MouseEnter += new System.EventHandler(this.ucProgramShortcut_MouseEnter); this.txtShortcutName.MouseLeave += new System.EventHandler(this.ucProgramShortcut_MouseLeave); // + // pictureBox1 + // + this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBox1.BackColor = System.Drawing.Color.Transparent; + this.pictureBox1.Image = global::client.Properties.Resources.pencil; + this.pictureBox1.Location = new System.Drawing.Point(338, 14); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(20, 20); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox1.TabIndex = 32; + this.pictureBox1.TabStop = false; + this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); + this.pictureBox1.MouseEnter += new System.EventHandler(this.ucProgramShortcut_MouseEnter); + this.pictureBox1.MouseLeave += new System.EventHandler(this.ucProgramShortcut_MouseLeave); + // // ucProgramShortcut // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))); + this.Controls.Add(this.picShortcut); + this.Controls.Add(this.pictureBox1); this.Controls.Add(this.txtShortcutName); this.Controls.Add(this.cmdNumUp); this.Controls.Add(this.cmdNumDown); this.Controls.Add(this.cmdDelete); - this.Controls.Add(this.picShortcut); + this.DoubleBuffered = true; this.Name = "ucProgramShortcut"; - this.Size = new System.Drawing.Size(450, 50); + this.Size = new System.Drawing.Size(467, 50); this.Load += new System.EventHandler(this.ucProgramShortcut_Load); + this.SizeChanged += new System.EventHandler(this.ucProgramShortcut_SizeChanged); this.Click += new System.EventHandler(this.ucProgramShortcut_Click); - this.Enter += new System.EventHandler(this.ucProgramShortcut_Enter); - this.Leave += new System.EventHandler(this.ucProgramShortcut_Leave); this.MouseEnter += new System.EventHandler(this.ucProgramShortcut_MouseEnter); this.MouseLeave += new System.EventHandler(this.ucProgramShortcut_MouseLeave); ((System.ComponentModel.ISupportInitialize)(this.picShortcut)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -151,5 +175,6 @@ private void InitializeComponent() private System.Windows.Forms.Button cmdNumUp; private System.Windows.Forms.Button cmdNumDown; private System.Windows.Forms.TextBox txtShortcutName; + private System.Windows.Forms.PictureBox pictureBox1; } } diff --git a/main/User controls/ucProgramShortcut.cs b/main/User controls/ucProgramShortcut.cs index 13bf4a1..bd43307 100644 --- a/main/User controls/ucProgramShortcut.cs +++ b/main/User controls/ucProgramShortcut.cs @@ -5,6 +5,7 @@ using client.Forms; using System.IO; using System.Windows.Input; +using System.Linq; namespace client.User_controls { @@ -17,15 +18,25 @@ public partial class ucProgramShortcut : UserControl public int Position { get; set; } public Bitmap logo; + + private float characterWidth = 8f; + public ucProgramShortcut() { InitializeComponent(); + picShortcut.AllowDrop = true; } private void ucProgramShortcut_Load(object sender, EventArgs e) { + // Ensure the shortcut name cannot be empty + if (Shortcut.name == "") + { + Shortcut.name = frmGroup.getShortcutName(Shortcut.name, Shortcut.isWindowsApp, Shortcut.FilePath); + } + txtShortcutName.Text = Shortcut.name; + /* // Grab the file name without the extension to be used later as the naming scheme for the icon .jpg image - if (Shortcut.isWindowsApp) { txtShortcutName.Text = handleWindowsApp.findWindowsAppsName(Shortcut.FilePath); @@ -43,58 +54,89 @@ private void ucProgramShortcut_Load(object sender, EventArgs e) { txtShortcutName.Text = Shortcut.name; } + */ + txtShortcutName.Width = this.Width - (txtShortcutName.Bounds.Left) - (this.Width - pictureBox1.Bounds.Left); - Size size = TextRenderer.MeasureText(txtShortcutName.Text, txtShortcutName.Font); - txtShortcutName.Width = size.Width; - txtShortcutName.Height = size.Height; + String cacheIconPath = MotherForm.Category.generateCachePath(Shortcut); + Image bkgImg = (Image)(new Bitmap(1, 1)); + - if (Shortcut.isWindowsApp) + if (File.Exists(cacheIconPath)) { - picShortcut.BackgroundImage = handleWindowsApp.getWindowsAppIcon(Shortcut.FilePath, true); - } - else if (File.Exists(Shortcut.FilePath)) // Checks if the shortcut actually exists; if not then display an error image + bkgImg = frmGroup.BitmapFromFile(cacheIconPath); + } else { - String imageExtension = Path.GetExtension(Shortcut.FilePath).ToLower(); - - // Start checking if the extension is an lnk (shortcut) file - // Depending on the extension, the icon can be directly extracted or it has to be gotten through other methods as to not get the shortcut arrow - if (imageExtension == ".lnk") + if (Shortcut.isWindowsApp) { - picShortcut.BackgroundImage = logo = frmGroup.handleLnkExt(Shortcut.FilePath); + bkgImg = handleWindowsApp.getWindowsAppIcon(Shortcut.FilePath, true); } - else + else if (File.Exists(Shortcut.FilePath)) // Checks if the shortcut actually exists; if not then display an error image { - picShortcut.BackgroundImage = logo = Icon.ExtractAssociatedIcon(Shortcut.FilePath).ToBitmap(); - } + String imageExtension = Path.GetExtension(Shortcut.FilePath).ToLower(); + + // Start checking if the extension is an lnk (shortcut) file + // Depending on the extension, the icon can be directly extracted or it has to be gotten through other methods as to not get the shortcut arrow + if (imageExtension == ".lnk") + { + bkgImg = frmGroup.handleLnkExt(Shortcut.FilePath); + } + else + { + bkgImg = Icon.ExtractAssociatedIcon(Shortcut.FilePath).ToBitmap(); + } - } else if (Directory.Exists(Shortcut.FilePath)) - { - try + } + else if (Directory.Exists(Shortcut.FilePath)) { - picShortcut.BackgroundImage = logo = handleFolder.GetFolderIcon(Shortcut.FilePath).ToBitmap(); + try + { + bkgImg = handleFolder.GetFolderIcon(Shortcut.FilePath).ToBitmap(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } } - catch (Exception ex) + else { - MessageBox.Show(ex.Message); + bkgImg = global::client.Properties.Resources.Error; } - } else - { - picShortcut.BackgroundImage = logo = global::client.Properties.Resources.Error; } + picShortcut.BackgroundImage = bkgImg; + + this.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + txtShortcutName.GotFocus += txtShortcutName_GotFocus; + + txtShortcutName.Text = Truncate(Shortcut.name, (int)Math.Floor(txtShortcutName.Width / characterWidth)); + } + + public void ucProgramShortcut_ReadjustArrows(int pos) + { + Position = pos; + // Reset to default + // Rerun checks if (Position == 0) { cmdNumUp.Enabled = false; cmdNumUp.BackgroundImage = global::client.Properties.Resources.NumUpGray; + } else + { + cmdNumUp.Enabled = true; + cmdNumUp.BackgroundImage = global::client.Properties.Resources.NumUp; } + if (Position == MotherForm.Category.ShortcutList.Count - 1) { cmdNumDown.Enabled = false; cmdNumDown.BackgroundImage = global::client.Properties.Resources.NumDownGray; + } else + { + cmdNumDown.Enabled = true; + cmdNumDown.BackgroundImage = global::client.Properties.Resources.NumDown; } - } private void ucProgramShortcut_MouseEnter(object sender, EventArgs e) @@ -119,7 +161,6 @@ private void cmdNumUp_Click(object sender, EventArgs e) private void cmdNumDown_Click(object sender, EventArgs e) { MotherForm.Swap(MotherForm.Category.ShortcutList, Position, Position + 1); - } private void cmdDelete_Click(object sender, EventArgs e) @@ -174,10 +215,10 @@ public void ucSelected() private void lbTextbox_TextChanged(object sender, EventArgs e) { - Size size = TextRenderer.MeasureText(txtShortcutName.Text, txtShortcutName.Font); - txtShortcutName.Width = size.Width; - txtShortcutName.Height = size.Height; - Shortcut.name = txtShortcutName.Text; + if (txtShortcutName.Focused) + { + Shortcut.name = txtShortcutName.Text; + } } private void ucProgramShortcut_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) @@ -199,15 +240,94 @@ private void txtShortcutName_Click(object sender, EventArgs e) ucProgramShortcut_Click(sender, e); } - private void ucProgramShortcut_Enter(object sender, EventArgs e) + private void ucProgramShortcut_SizeChanged(object sender, EventArgs e) + { + try + { + txtShortcutName.Width = this.Width - (txtShortcutName.Bounds.Left) - (this.Width - pictureBox1.Bounds.Left); + + if (!txtShortcutName.Focused) + { + txtShortcutName.Text = Truncate(Shortcut.name, (int)Math.Floor(txtShortcutName.Width / characterWidth)); + } + } catch (Exception) + { + + } + + } + + public static string Truncate(string value, int maxChars) + { + return value.Length <= maxChars ? value : value.Substring(0, maxChars) + "..."; + } + + private void txtShortcutName_GotFocus(object sender, EventArgs e) + { + if (txtShortcutName.Text != Shortcut.name) + { + txtShortcutName.Text = Shortcut.name; + } + } + + private void pictureBox1_Click(object sender, EventArgs e) + { + if (!IsSelected) + ucProgramShortcut_Click(sender, e); + if (!txtShortcutName.Focused) + { + txtShortcutName.Focus(); + txtShortcutName.Select(txtShortcutName.TextLength, txtShortcutName.TextLength); + } + } + + private void picShortcut_Click(object sender, EventArgs e) + { + OpenFileDialog openFileDialog = new OpenFileDialog // ask user to select img as group icon + { + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), + Title = "Select Group Icon", + CheckFileExists = true, + CheckPathExists = true, + DefaultExt = "img", + Filter = "Image files and exec (*.jpg, *.jpeg, *.jpe, *.jfif, *.png, *.exe, *.ico) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png; *.ico; *.exe", + FilterIndex = 2, + RestoreDirectory = true, + ReadOnlyChecked = true, + DereferenceLinks = false, + }; + + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + + String imageExtension = Path.GetExtension(openFileDialog.FileName).ToLower(); + + picShortcut.BackgroundImage = MotherForm.handleIcon(openFileDialog.FileName, imageExtension); + } + } + + private void picShortcut_DragEnter(object sender, DragEventArgs e) { - //IsSelected = true; + MotherForm.checkExtensions(e, MotherForm.newExt); } - private void ucProgramShortcut_Leave(object sender, EventArgs e) + private void picShortcut_DragDrop(object sender, DragEventArgs e) { - //IsSelected = false; + var files = (String[])e.Data.GetData(DataFormats.FileDrop); + + String imageExtension = Path.GetExtension(files[0]).ToLower(); + + if (files.Length == 1 && MotherForm.newExt.Contains(imageExtension) && System.IO.File.Exists(files[0])) + { + // Checks if the files being added/dropped are an .exe or .lnk in which tye icons need to be extracted/processed + picShortcut.BackgroundImage = MotherForm.handleIcon(files[0], imageExtension); + } } + // Bind this so that any changes to the logos automatically bind to changing the logo variable + private void picShortcut_BackgroundImageChanged(object sender, EventArgs e) + { + logo = new Bitmap(picShortcut.BackgroundImage); + } } } diff --git a/main/User controls/ucTabControl.cs b/main/User controls/ucTabControl.cs new file mode 100644 index 0000000..7841d95 --- /dev/null +++ b/main/User controls/ucTabControl.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Forms; +using Windows.ApplicationModel; +using TabControl = System.Windows.Forms.TabControl; + +namespace client.User_controls +{ + public class ucTabControl : TabControl + { + protected override void WndProc(ref Message m) + { + // Hide tabs by trapping the TCM_ADJUSTRECT message + if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1; + else base.WndProc(ref m); + } + } +} diff --git a/main/app.manifest b/main/app.manifest new file mode 100644 index 0000000..2c88c95 --- /dev/null +++ b/main/app.manifest @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/main/client.cs b/main/client.cs deleted file mode 100644 index 36903ce..0000000 --- a/main/client.cs +++ /dev/null @@ -1,84 +0,0 @@ -using client.Forms; -using System; -using System.IO; -using System.Runtime.InteropServices; -using System.Windows.Forms; -using client.Classes; -using System.Diagnostics; - -namespace client -{ - static class client - { - /// - /// The main entry point for the application. - /// - - public static string[] arguments = Environment.GetCommandLineArgs(); - - // Define functions to set AppUserModelID - [DllImport("shell32.dll", SetLastError = true)] - static extern void SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID); - - [STAThread] - - static void Main() - { - // Use existing methods to obtain cursor already imported as to not import any extra functions - // Pass as two variables instead of Point due to Point requiring System.Drawing - int cursorX = Cursor.Position.X; - int cursorY = Cursor.Position.Y; - - // Set the MainPath to the absolute path where the exe is located - MainPath.path = Path.GetFullPath(new Uri(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)).LocalPath); - MainPath.exeString = Path.GetFullPath(new Uri(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath); - - // Creats folder for JIT compilation - Directory.CreateDirectory($"{MainPath.path}\\JITComp"); - - // Creates directory in case it does not exist for config files - Directory.CreateDirectory($"{MainPath.path}\\config"); - Directory.CreateDirectory($"{MainPath.path}\\Shortcuts"); - - System.Runtime.ProfileOptimization.SetProfileRoot(MainPath.path + "\\JITComp"); - - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - - try - { - System.IO.File.Create(MainPath.path + "\\directoryTestingDocument.txt").Close(); - System.IO.File.Delete(MainPath.path + "\\directoryTestingDocument.txt"); - } - catch - { - using (Process configTool = new Process()) - { - configTool.StartInfo.FileName = MainPath.exeString; - configTool.StartInfo.Verb = "runas"; - try - { - configTool.Start(); - } catch - { - Process.GetCurrentProcess().Kill(); - } - } - } - - if (arguments.Length > 1) // Checks for additional arguments; opens either main application or taskbar drawer application - { - // Sets the AppUserModelID to tjackenpacken.taskbarGroup.menu.groupName - // Distinguishes each shortcut process from one another to prevent them from stacking with the main application - SetCurrentProcessExplicitAppUserModelID("tjackenpacken.taskbarGroup.menu."+ arguments[1]); - - Application.Run(new frmMain(arguments[1], cursorX, cursorY)); - } else - { - // See comment above - SetCurrentProcessExplicitAppUserModelID("tjackenpacken.taskbarGroup.main"); - Application.Run(new frmClient()); - } - } - } -} diff --git a/main/editorClient.cs b/main/editorClient.cs new file mode 100644 index 0000000..ba307ab --- /dev/null +++ b/main/editorClient.cs @@ -0,0 +1,157 @@ +using client.Forms; +using System; +using System.IO; +using System.Runtime.InteropServices; +using System.Windows.Forms; +using client.Classes; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Reflection; + +namespace client +{ + static class editorClient + { + /// + /// The main entry point for the application. + /// + + public static string[] arguments = Environment.GetCommandLineArgs(); + + // Define functions to set AppUserModelID + [DllImport("shell32.dll", SetLastError = true)] + static extern void SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID); + + [DllImport("user32.dll", SetLastError = true)] + internal static extern bool SetProcessDpiAwarenessContext(int dpiFlag); + + [DllImport("SHCore.dll", SetLastError = true)] + internal static extern bool SetProcessDpiAwareness(PROCESS_DPI_AWARENESS awareness); + + [DllImport("user32.dll")] + internal static extern bool SetProcessDPIAware(); + + internal enum PROCESS_DPI_AWARENESS + { + Process_DPI_Unaware = 0, + Process_System_DPI_Aware = 1, + Process_Per_Monitor_DPI_Aware = 2 + } + + internal enum DPI_AWARENESS_CONTEXT + { + DPI_AWARENESS_CONTEXT_UNAWARE = 16, + DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = 17, + DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = 18, + DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = 34 + } + + [STAThread] + + static void Main() + { + AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => + { + string resourceName = new AssemblyName(args.Name).Name + ".dll"; + string resource = Array.Find(Assembly.GetExecutingAssembly().GetManifestResourceNames(), element => element.EndsWith(resourceName)); + + using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)) + { + Byte[] assemblyData = new Byte[stream.Length]; + stream.Read(assemblyData, 0, assemblyData.Length); + return Assembly.Load(assemblyData); + } + }; + if (Environment.OSVersion.Version >= new Version(6, 3, 0)) // win 8.1 added support for per monitor dpi + { + if (Environment.OSVersion.Version >= new Version(10, 0, 15063)) // win 10 creators update added support for per monitor v2 + { + SetProcessDpiAwarenessContext((int)DPI_AWARENESS_CONTEXT.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + } + else SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.Process_Per_Monitor_DPI_Aware); + } + else SetProcessDPIAware(); + // Use existing methods to obtain cursor already imported as to not import any extra functions + // Pass as two variables instead of Point due to Point requiring System.Drawing + + // OLD - No longer handled here + //int cursorX = Cursor.Position.X; + //int cursorY = Cursor.Position.Y; + + // Creates folder for JIT compilation. + try + {System.Runtime.ProfileOptimization.SetProfileRoot(Paths.OptimizationProfilePath);} catch (Exception ex){} + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + + + try + { + System.IO.File.Create(Paths.path + "\\directoryTestingDocument.txt").Close(); + System.IO.File.Delete(Paths.path + "\\directoryTestingDocument.txt"); + } + catch + { + /* + using (Process configTool = new Process()) + { + configTool.StartInfo.FileName = Paths.exeString; + configTool.StartInfo.Verb = "runas"; + try + { + configTool.Start(); + } catch + { + Process.GetCurrentProcess().Kill(); + } + } + */ + MessageBox.Show("This program does not have access to this directory!"); + Process.GetCurrentProcess().Close(); + } + + /* + if (arguments.Length > 1) // Checks for additional arguments; opens either main application or taskbar drawer application + { + if (Directory.Exists(Path.Combine(Paths.ConfigPath, arguments[1]))) + { + // Sets the AppUserModelID to tjackenpacken.taskbarGroup.menu.groupName + // Distinguishes each shortcut process from one another to prevent them from stacking with the main application + SetCurrentProcessExplicitAppUserModelID("tjackenpacken.taskbarGroup.menu." + arguments[1]); + + System.Threading.Mutex mutexThread = new Mutex(true, "tjackenpacken.taskbarGroup.menu." + arguments[1]); + + try + { + if (!mutexThread.WaitOne(TimeSpan.Zero, false)) + { + Application.Exit(); + } + } + catch { } + //Application.Run(new frmMain(arguments[1], cursorX, cursorY, arguments.ToList(), mutexThread)); + } else if (arguments[1] == "editingGroupMode") + { + // See comment above + SetCurrentProcessExplicitAppUserModelID("tjackenpacken.taskbarGroup.main"); + Application.Run(new frmClient(arguments.ToList())); + } else + { + Application.Exit(); + } + } else + { + // See comment above + SetCurrentProcessExplicitAppUserModelID("tjackenpacken.taskbarGroup.main"); + Application.Run(new frmClient(arguments.ToList())); + } + */ + + SetCurrentProcessExplicitAppUserModelID("tjackenpacken.taskbarGroup.main"); + Application.Run(new frmClient(arguments.ToList())); + } + } +} diff --git a/main/client.csproj b/main/editorClient.csproj similarity index 79% rename from main/client.csproj rename to main/editorClient.csproj index 137d4c9..2ad1726 100644 --- a/main/client.csproj +++ b/main/editorClient.csproj @@ -7,12 +7,14 @@ {B6E63AE7-4433-44EC-BCDE-031CD779E8CC} WinExe client - TaskbarGroups + Taskbar Groups v4.7.2 512 - true + false true false + + publish\ true Disk @@ -27,8 +29,6 @@ 1.0.0.%2a false true - - AnyCPU @@ -43,32 +43,46 @@ AnyCPU - pdbonly + none true bin\Release\ TRACE prompt 4 + false Icon.ico + + app.manifest + - - ..\packages\TxFileManager.1.4.0\lib\netstandard2.0\ChinhDo.Transactions.FileManager.dll + + ..\packages\TxFileManager.1.5.0.1\lib\netstandard2.0\ChinhDo.Transactions.FileManager.dll + False + + + ..\packages\KaitaiStruct.Runtime.CSharp.0.10.0\lib\net45\Kaitai.Struct.Runtime.dll + False - + + ..\packages\Microsoft-WindowsAPICodePack-Core.1.1.4\lib\net472\Microsoft.WindowsAPICodePack.dll + False - + ..\packages\Microsoft-WindowsAPICodePack-Shell.1.1.4\lib\net472\Microsoft.WindowsAPICodePack.Shell.dll + False + + @@ -81,6 +95,7 @@ .\Windows.winmd + False @@ -91,8 +106,10 @@ - + + + Form @@ -106,14 +123,17 @@ frmGroup.cs - - - Form + + + + + True + True + Resources.resx - - frmMain.cs + + Component - UserControl @@ -126,40 +146,26 @@ ucProgramShortcut.cs - - UserControl - - - ucShortcut.cs - frmClient.cs + Designer frmGroup.cs - - - frmMain.cs + Designer ResXFileCodeGenerator - Resources.Designer.cs Designer + Resources.Designer.cs - - True - Resources.resx - True - ucCategoryPanel.cs ucProgramShortcut.cs - - ucShortcut.cs - + SettingsSingleFileGenerator @@ -171,9 +177,6 @@ True - - - @@ -199,7 +202,19 @@ - + + + + + + + + + + + + + @@ -249,6 +264,7 @@ false + Microsoft.WindowsAPICodePack.xml diff --git a/main/lib/ChinhDo.Transactions.FileManager.dll b/main/lib/ChinhDo.Transactions.FileManager.dll new file mode 100644 index 0000000..577d750 Binary files /dev/null and b/main/lib/ChinhDo.Transactions.FileManager.dll differ diff --git a/main/lib/Kaitai.Struct.Runtime.dll b/main/lib/Kaitai.Struct.Runtime.dll new file mode 100644 index 0000000..535ed8a Binary files /dev/null and b/main/lib/Kaitai.Struct.Runtime.dll differ diff --git a/main/lib/Microsoft.WindowsAPICodePack.Shell.dll b/main/lib/Microsoft.WindowsAPICodePack.Shell.dll new file mode 100644 index 0000000..4d4324d Binary files /dev/null and b/main/lib/Microsoft.WindowsAPICodePack.Shell.dll differ diff --git a/main/lib/Microsoft.WindowsAPICodePack.dll b/main/lib/Microsoft.WindowsAPICodePack.dll new file mode 100644 index 0000000..a8f431b Binary files /dev/null and b/main/lib/Microsoft.WindowsAPICodePack.dll differ diff --git a/main/packages.config b/main/packages.config index dbf6403..c61251b 100644 --- a/main/packages.config +++ b/main/packages.config @@ -1,6 +1,7 @@  + - + \ No newline at end of file