Exemplo n.º 1
0
        public SettingsWindow()
        {
            InitializeComponent();

            int   count   = 0;
            int   idx     = -1;
            Color current = Settings.Default.TrayIconForegroundColor;

            colorPicker.ItemsSource = typeof(Colors).GetProperties().Select(propInfo =>
            {
                var c = (Color)propInfo.GetValue(null, null);

                if (c.GetHashCode() == current.GetHashCode())
                {
                    idx = count;
                }

                count++;

                return(new ComboBoxItem()
                {
                    Background = new SolidColorBrush(c),
                    Content = propInfo.Name
                });
            });

            colorPicker.SelectedIndex = idx;

            autorun                = new AutorunEntry(RegistryAutorunValueName);
            autorun.Parameters     = StartInTrayParameter;
            startWithWin.IsChecked = autorun.Exists;

            closeToTray.IsChecked = Settings.Default.CloseToTray;
        }
Exemplo n.º 2
0
 public SettingsViewModel()
 {
     autorun            = new AutorunEntry(RegistryAutorunValueName);
     autorun.Parameters = StartInTrayParameter;
     trayIconColor      = SettingsService.Settings.TrayIconForegroundColor;
     closeToTray        = SettingsService.Settings.CloseToTray;
     autostart          = autorun.Exists;
 }
Exemplo n.º 3
0
        public SettingsWindow()
        {
            InitializeComponent();

            int   count   = 0;
            int   idx     = -1;
            Color current = Settings.Default.TrayIconForegroundColor;

            // Fill ComboBox
            colorPicker.ItemsSource = typeof(Colors).GetProperties().Select(propInfo =>
            {
                var c = (Color)propInfo.GetValue(null, null);

                // Get index of currently selected tray icon color
                if (c.GetHashCode() == current.GetHashCode())
                {
                    idx = count;
                }

                count++;

                // Make sure each color's name is readable
                Brush foreground;
                double lightness = (Math.Max(c.R, Math.Max(c.G, c.B)) + Math.Min(c.R, Math.Min(c.G, c.B))) / 2.0;

                if (lightness > 255 * 0.45)
                {
                    foreground = Black;
                }
                else
                {
                    foreground = White;
                }
                var cb = new ComboBoxItem();
                return(new ComboBoxItem()
                {
                    Background = new SolidColorBrush(c),
                    Foreground = foreground,
                    Content = propInfo.Name
                });
            });

            colorPicker.SelectedIndex = idx;

            autorun                = new AutorunEntry(RegistryAutorunValueName);
            autorun.Parameters     = StartInTrayParameter;
            startWithWin.IsChecked = autorun.Exists;

            closeToTray.IsChecked = Settings.Default.CloseToTray;
        }