Example #1
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     if (Settings.Default["Color1"] == null)
     {
         string colorizationValue = string.Format("{0:x}", Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColor", "00000000"));
         Color  color             = (Color)ColorConverter.ConvertFromString("#" + colorizationValue);
         color.A = 100;
         Settings.Default["Color1"] = new SolidColorBrush(color);
         color.A = 255;
         Settings.Default["Color2"] = new SolidColorBrush(color);
         Settings.Default.Save();
         float r = color.R, g = color.G, b = color.B;
         float s, v;
         Singlton.RGBtoHSV(r, g, b, out _, out s, out v);
         if (s >= 195 || v >= 195)
         {
             Settings.Default.ColorF = new SolidColorBrush(Colors.Black);
         }
         else
         {
             Settings.Default.ColorF = new SolidColorBrush(Colors.White);
         }
     }
 }
        private void MainColorGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            switch (((MainColorCB.SelectedItem as ComboBoxItem).Tag as string))
            {
            case "blue":
                Singlton.Color2 = new SolidColorBrush(new Color {
                    R = 38, G = 0, B = 230, A = 255
                });
                Singlton.Color1 = new SolidColorBrush(new Color {
                    R = 96, G = 69, B = 230, A = 255
                });
                Singlton.ColorF = new SolidColorBrush(Colors.White);
                break;

            case "red":
                Singlton.Color2 = new SolidColorBrush(new Color {
                    R = 255, G = 33, B = 36, A = 255
                });
                Singlton.Color1 = new SolidColorBrush(new Color {
                    R = 255, G = 90, B = 90, A = 255
                });
                Singlton.ColorF = new SolidColorBrush(Colors.White);
                break;

            case "green":
                Singlton.Color2 = new SolidColorBrush(new Color {
                    R = 0, G = 255, B = 50, A = 255
                });
                Singlton.Color1 = new SolidColorBrush(new Color {
                    R = 40, G = 255, B = 90, A = 255
                });
                Singlton.ColorF = new SolidColorBrush(Colors.Black);
                break;

            case "yellow":
                Singlton.Color2 = new SolidColorBrush(new Color {
                    R = 232, G = 255, B = 0, A = 255
                });
                Singlton.Color1 = new SolidColorBrush(new Color {
                    R = 240, G = 255, B = 77, A = 255
                });
                Singlton.ColorF = new SolidColorBrush(Colors.Black);
                break;

            default:
                string colorizationValue = string.Format("{0:x}", Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColor", "00000000"));
                Color  color             = (Color)ColorConverter.ConvertFromString("#" + colorizationValue);
                color.A         = 100;
                Singlton.Color1 = new SolidColorBrush(color);
                color.A         = 255;
                Singlton.Color2 = new SolidColorBrush(color);
                float r = color.R, g = color.G, b = color.B;
                float s, v;
                Singlton.RGBtoHSV(r, g, b, out _, out s, out v);
                if (s >= 195 || v >= 195)
                {
                    Singlton.ColorF = new SolidColorBrush(Colors.Black);
                }
                else
                {
                    Singlton.ColorF = new SolidColorBrush(Colors.White);
                }
                break;
            }
        }