//-------------------------------------- // SHORTCUT/PROGRAM SELECTION //-------------------------------------- // Deselect selected program/shortcut public void resetSelection() { pnlArgumentTextbox.Enabled = false; cmdSelectDirectory.Enabled = false; if (selectedShortcut != null) { pnlColor.Visible = true; pnlArguments.Visible = false; selectedShortcut.ucDeselected(); selectedShortcut.IsSelected = false; selectedShortcut = null; } }
// Enable the argument textbox once a shortcut/program has been selected public void enableSelection(ucProgramShortcut passedShortcut) { selectedShortcut = passedShortcut; passedShortcut.ucSelected(); passedShortcut.IsSelected = true; pnlArgumentTextbox.Text = Category.ShortcutList[selectedShortcut.Position].Arguments; pnlArgumentTextbox.Enabled = true; pnlWorkingDirectory.Text = Category.ShortcutList[selectedShortcut.Position].WorkingDirectory; pnlWorkingDirectory.Enabled = true; cmdSelectDirectory.Enabled = true; pnlColor.Visible = false; pnlArguments.Visible = true; }
//-------------------------------------- // SHORTCUT PANEL HANLDERS //-------------------------------------- // Load up shortcut panel public void LoadShortcut(ProgramShortcut psc, int position) { pnlShortcuts.AutoScroll = false; ucProgramShortcut ucPsc = new ucProgramShortcut(this, psc, position); pnlShortcuts.Controls.Add(ucPsc); ucPsc.Show(); ucPsc.BringToFront(); if (pnlShortcuts.Controls.Count < 6) { pnlShortcuts.Height += 50; pnlAddShortcut.Top += 50; } ucPsc.Location = new Point(25, (pnlShortcuts.Controls.Count * 50) - 50); pnlShortcuts.AutoScroll = true; }
// Goal is to create a folder with icons of the programs pre-cached and ready to be read // Avoids having the icons need to be rebuilt everytime which takes time and resources public void cacheIcons() { // Defines the paths for the icons folder 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 if (Directory.Exists(iconPath)) { Directory.Delete(iconPath, true); } // Creates the icons folder inside of existing config folder for the group Directory.CreateDirectory(iconPath); // 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() int ind = ShortcutList.Count - 1; foreach (ProgramShortcut shrtcutList in ShortcutList) { String filePath = shrtcutList.FilePath; ucProgramShortcut programShortcutControl = Application.OpenForms["frmGroup"].Controls["pnlShortcuts"].Controls[ind] as ucProgramShortcut; ind--; string savePath; if (shrtcutList.isWindowsApp) { savePath = Path.Combine(iconPath, specialCharRegex.Replace(filePath, string.Empty) + ".png"); } else if (Directory.Exists(filePath)) { savePath = Path.Combine(iconPath, Path.GetFileNameWithoutExtension(filePath) + "_FolderObjTSKGRoup.png"); } else { savePath = Path.Combine(iconPath, Path.GetFileNameWithoutExtension(filePath) + ".png"); } programShortcutControl.logo.Save(savePath); } }
public void LoadShortcuts() { pnlShortcuts.Height = 0; pnlShortcuts.Controls.Clear(); int y = 0; int position = 0; foreach (ProgramShortcut psc in Category.ShortcutList) { ucProgramShortcut ucPsc = new ucProgramShortcut(this, psc, position); pnlShortcuts.Controls.Add(ucPsc); ucPsc.Location = new Point(0, y); ucShortcutList.Add(ucPsc); ucPsc.Show(); ucPsc.BringToFront(); position++; if (pnlShortcuts.Height < 350) { y += 50; pnlShortcuts.Height += 50; } else { pnlShortcuts.ScrollControlIntoView(ucPsc); } } if (pnlShortcuts.Height >= 350) { if (!pnlShortcuts.AutoScroll) { pnlShortcuts.AutoScroll = true; pnlShortcuts.Width += 40; } } pnlAdd.Top = pnlShortcuts.Bottom; //if (pnlAdd.Bottom > pnlEnd.Top) //{ // this.Height += 50; // pnlEnd.Top += 50; //} //this.Height = pnlAdd.Bottom + 75; }
// Goal is to create a folder with icons of the programs pre-cached and ready to be read // Avoids having the icons need to be rebuilt everytime which takes time and resources public void cacheIcons() { // Defines the paths for the icons folder string path = @MainPath.path + @"\config\" + this.Name; string iconPath = 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 if (Directory.Exists(iconPath)) { Directory.Delete(iconPath, true); } // 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--) { 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"; } programShortcutControl.logo.Save(savePath); } }
// Change positions of shortcut panels public void Swap <T>(IList <T> 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; int position = 0; foreach (ProgramShortcut psc in Category.ShortcutList) { LoadShortcut(psc, position); position++; } }