private void frmMain_Load(object sender, EventArgs e) { //System.Diagnostics.Debugger.Launch(); if (Directory.Exists(@MainPath.path + @"\config\" + passedDirec)) { ControlList = new List <ucShortcut>(); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); ThisCategory = new Category($"config\\{passedDirec}"); this.BackColor = ImageFunctions.FromString(ThisCategory.ColorString); Opacity = (1 - (ThisCategory.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)); } LoadCategory(); SetLocation(); } else { Application.Exit(); } }
// CTOR for editing an existing group public frmGroup(frmClient client, Category category) { // Setting form profile System.Runtime.ProfileOptimization.StartProfile("frmGroup.Profile"); InitializeComponent(); // Setting properties Category = category; Client = client; IsNew = false; // Setting control values from loaded group this.Text = "Edit group"; txtGroupName.Text = Regex.Replace(Category.Name, @"(_)+", " "); pnlAllowOpenAll.Checked = category.allowOpenAll; cmdAddGroupIcon.BackgroundImage = Category.LoadIconImage(); lblNum.Text = Category.Width.ToString(); lblOpacity.Text = Category.Opacity.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)); } 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; } // Loading existing shortcutpanels int position = 0; foreach (ProgramShortcut psc in category.ShortcutList) { LoadShortcut(psc, position); position++; } }
// editing an existing group public GroupEditor(GroupOverview groupOverview, Border tab, Group group) { // Setting from profile ProfileOptimization.StartProfile("GroupEditor.Profile"); InitializeComponent(); // Setting properties GroupOverview = groupOverview; Tab = tab; Group = group; IsNew = false; // DropHandler DataContext = new ViewModel(this); // Setting control values from loaded group InpGroupName.Text = Group.Name; ImgGroupIcon.Source = Group.LoadGroupImage(); LblWidth.Content = Group.Width.ToString(); Color groupBackgroundColor = ImageFunctions.FromString(Group.BackgroundColor); ClrCustomColor.SelectedColor = groupBackgroundColor; SldOpacity.Value = Group.Opacity; if (Group.SelectedBackgroundOption == BackgroundOption.Dark) { RadDark.IsChecked = true; } else if (Group.SelectedBackgroundOption == BackgroundOption.WindowsTheme) { RadWindowsTheme.IsChecked = true; } else if (Group.SelectedBackgroundOption == BackgroundOption.WindowsAccentColor) { RadWindowsAccentColor.IsChecked = true; } else if (Group.SelectedBackgroundOption == BackgroundOption.Custom) { RadCustom.IsChecked = true; ClrCustomColor.IsEnabled = true; } LoadShortcuts(); }
public CtlGroup(GroupOverview groupOverview, Group group, MainWindow mainWindow) { InitializeComponent(); GroupOverview = groupOverview; Group = group; MainWindow = mainWindow; LblBackgroundColor.Background = new SolidColorBrush(ImageFunctions.FromString(Group.BackgroundColor)); ImgGroupIcon.Source = Group.LoadGroupImage(); LblGroupname.Text = Group.Name; if (!Directory.Exists($@"{Paths.GroupsPath}\{Group.Name}\Icons\")) { Group.CacheImages(); } foreach (Shortcut shortcut in Group.ShortcutList) { CreateShortcut(shortcut); } }
//------------------------------------------------------------------------------------ // CTOR AND LOAD // public frmMain(string passedDirectory, int cursorPosX, int cursorPosY) { InitializeComponent(); System.Runtime.ProfileOptimization.StartProfile("frmMain.Profile"); mouseClick = new Point(cursorPosX, cursorPosY); // Consstruct point p based on passed x y mouse values passedDirec = passedDirectory; FormBorderStyle = FormBorderStyle.None; using (MemoryStream ms = new MemoryStream(System.IO.File.ReadAllBytes(MainPath.path + "\\config\\" + passedDirec + "\\GroupIcon.ico"))) this.Icon = new Icon(ms); if (Directory.Exists(@MainPath.path + @"\config\" + passedDirec)) { ControlList = new List <ucShortcut>(); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); ThisCategory = new Category($"config\\{passedDirec}"); this.BackColor = ImageFunctions.FromString(ThisCategory.ColorString); Opacity = (1 - (ThisCategory.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)); } } else { Application.Exit(); } }