public void ShowSettingsWindow()
        {
            var window = new Window();

            window.Width  = 600.0;
            window.Height = 700.0;
            window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            var settings      = new string[] { "Hardware", "Window Background Color", "Bar Background Color", "Bar Foreground Color", "Border Color", "Font", "Position", "Reset" };
            var settingsPanel = new SettingsPanel(settings);
            var handler       = new SettingsHandler(settingsPanel);

            window.Closed   += (object sender, EventArgs e) => { handler.Dispose(); };
            handler.Delegate = this;
            Uri iconUri = new Uri("pack://application:,,,/heart.ico", UriKind.RelativeOrAbsolute);

            window.Title   = "PC Hardware Monitor Settings";
            window.Icon    = System.Windows.Media.Imaging.BitmapFrame.Create(iconUri);
            window.Content = settingsPanel;
            window.Show();
        }
示例#2
0
        public SettingsHandler(SettingsPanel settingsPanel)
        {
            CheckForSettingsFile();
            this.settingsPanel = settingsPanel;
            settingsPanel.didClickButtonAtIndex = (j) => { CurrentSettingDidChange(j); };
            hardwareMenu.Width               = 290.0;
            hardwareMenu.Height              = 380.0;
            hardwareMenu.Background          = new SolidColorBrush(Color.FromArgb((byte)0, (byte)70, (byte)85, (byte)90));
            hardwareMenu.Margin              = new Thickness(0, 0, 30, 130);
            hardwareMenu.HorizontalAlignment = HorizontalAlignment.Right;
            hardwareMenu.VerticalAlignment   = VerticalAlignment.Center;
            positionMenu                     = new StackPanel();
            positionMenu.Width               = 290.0;
            positionMenu.Height              = 380.0;
            positionMenu.Visibility          = Visibility.Hidden;
            positionMenu.HorizontalAlignment = HorizontalAlignment.Right;
            positionMenu.VerticalAlignment   = VerticalAlignment.Center;
            positionMenu.Margin              = new Thickness(100, 0, 0, 50);
            for (int i = 0; i < positionTitles.Length; i++)
            {
                var radioButton = new RadioButton();
                var index       = i;
                radioButton.Width               = 100.0;
                radioButton.Height              = 30.0;
                radioButton.Content             = positionTitles[i];
                radioButton.HorizontalAlignment = HorizontalAlignment.Center;
                radioButton.VerticalAlignment   = VerticalAlignment.Center;
                radioButton.Margin              = new Thickness(0, 0, 30, 0);
                radioButton.LayoutTransform     = new ScaleTransform(1.6, 1.6);
                radioButton.Click              += (object sender, RoutedEventArgs e) => { NewPositionWasSelected((LayoutPosition)index, rowsCheckBox.IsChecked ?? false); };
                radioButtons.Add(radioButton);
                positionMenu.Children.Add(radioButton);
            }
            rowsCheckBox.Content             = "Layout in rows";
            rowsCheckBox.Width               = 180.0;
            rowsCheckBox.Height              = 30.0;
            rowsCheckBox.LayoutTransform     = new ScaleTransform(1.4, 1.4);
            rowsCheckBox.HorizontalAlignment = HorizontalAlignment.Right;
            rowsCheckBox.Foreground          = new SolidColorBrush(Color.FromRgb((byte)200, (byte)200, (byte)200));
            rowsCheckBox.Click              += (object sender, RoutedEventArgs e) => { NewPositionWasSelected(settings.startupPosition, rowsCheckBox.IsChecked ?? false); };
            rowsCheckBox.IsChecked           = settings.layoutIsInRows;
            positionMenu.Children.Add(rowsCheckBox);
            settingsPanel.Children.Add(positionMenu);
            switch (settings.startupPosition)
            {
            case (LayoutPosition)0: radioButtons[0].IsChecked = true; break;

            case (LayoutPosition)1: radioButtons[1].IsChecked = true; break;

            case (LayoutPosition)2: radioButtons[2].IsChecked = true; break;

            case (LayoutPosition)3: radioButtons[3].IsChecked = true; break;

            case (LayoutPosition)4: radioButtons[4].IsChecked = true; break;
            }
            settingsPanel.rightPanel.Children.Add(hardwareMenu);
            settingsPanel.colorCanvas.Visibility = Visibility.Hidden;
            settingsPanel.SetButtonSelected(0, true);
            settingsPanel.didSelectedNewColor = (color) => { NewColorWasSelected(color); };
            foreach (Vital vital in settings.startupVitals)
            {
                vitalsToMonitor.Add(vital);
            }
            bool hasReachedSegoe = false;

            foreach (var font in Fonts.SystemFontFamilies)
            {
                fontFamilies.Add(font.ToString());
                if (font.ToString().Contains("Segoe") && hasReachedSegoe == false)
                {
                    fontFamilies.Add("Segoe UI Black");
                    fontFamilies.Add("Segoe UI Light");
                    fontFamilies.Add("Segoe UI Semibold");
                    fontFamilies.Add("Segoe UI Semilight");
                    hasReachedSegoe = true;
                }
            }

            fontbox.Width                = 120.0;
            fontbox.Height               = 22.0;
            fontbox.ItemsSource          = fontFamilies;
            fontbox.SelectedIndex        = fontFamilies.IndexOf(settings.font.fontFamily);
            fontbox.Visibility           = Visibility.Hidden;
            fontbox.HorizontalAlignment  = HorizontalAlignment.Center;
            fontbox.VerticalAlignment    = VerticalAlignment.Center;
            fontbox.Margin               = new Thickness(250, 120, 0, 0);
            fontbox.SelectionChanged    += (object sender, SelectionChangedEventArgs e) => { settings.font.fontFamily = (string)fontbox.SelectedItem; this.Delegate.DidSelectNewFont(settings.font); };
            fontSizeSlider.Width         = 200.0;
            fontSizeSlider.Height        = 20.0;
            fontSizeSlider.Maximum       = 40.0;
            fontSizeSlider.Value         = settings.font.size;
            fontSizeSlider.ValueChanged += (object sender, RoutedPropertyChangedEventArgs <double> e) => {
                fontSizeLabel.Content = $"Font Size: {(int)e.NewValue}";
                settings.font.size    = (int)e.NewValue;
                this.Delegate.DidSelectNewFont(settings.font);
            };
            fontSizeSlider.Margin             = new Thickness(340, 50, 0, 0);
            fontSizeSlider.Visibility         = Visibility.Hidden;
            fontSizeLabel.Width               = 80.0;
            fontSizeLabel.Height              = 35.0;
            fontSizeLabel.Content             = "Font Size: 20";
            fontSizeLabel.VerticalAlignment   = VerticalAlignment.Center;
            fontSizeLabel.HorizontalAlignment = HorizontalAlignment.Center;
            fontSizeLabel.Margin              = new Thickness(60, 60, 0, 0);
            fontSizeLabel.Visibility          = Visibility.Hidden;
            settingsPanel.Children.Add(fontSizeLabel);
            settingsPanel.Children.Add(fontSizeSlider);
            settingsPanel.Children.Add(fontbox);

            for (int i = 0; i < hardwareVitalTitles.Length; i++)
            {
                var vital    = (Vital)i;
                var checkbox = new CheckBox();
                checkbox.Content             = hardwareVitalTitles[i];
                checkbox.Width               = 180.0;
                checkbox.Height              = 30.0;
                checkbox.LayoutTransform     = new ScaleTransform(1.4, 1.4);
                checkbox.HorizontalAlignment = HorizontalAlignment.Right;
                checkbox.Foreground          = new SolidColorBrush(Color.FromRgb((byte)200, (byte)200, (byte)200));
                checkboxes.Add(checkbox);
                checkbox.Click += (object sender, RoutedEventArgs e) => {
                    if (checkbox.IsChecked ?? false)
                    {
                        vitalsToMonitor.Add(vital); this.Delegate.DidSelectNewVital(vital, true);
                    }
                    else
                    {
                        if (vitalsToMonitor.Contains(vital))
                        {
                            vitalsToMonitor.Remove(vital); this.Delegate.DidSelectNewVital(vital, false);
                        }
                    }
                    settings.startupVitals = vitalsToMonitor.ToArray();
                };
                hardwareMenu.Children.Add(checkbox);
            }
            ShowCheckMenu();
        }