コード例 #1
0
        public WindowHudDesign(Window owner, HudCustomizeParams.HudCustomizeType hudCustomizeType)
        {
            InitializeComponent();
            Owner = owner;
            WindowStartupLocation = WindowStartupLocation.CenterOwner;

            HudCustomizeParams = new HudCustomizeParams(hudCustomizeType);

            // init values

            foreach (var item in Fonts.SystemFontFamilies)
            {
                ComboBox_FontFamily.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(item));
            }

            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Black));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Bold));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.DemiBold));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.ExtraBlack));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.ExtraBold));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.ExtraLight));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Heavy));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Light));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Medium));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Normal));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Regular));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.SemiBold));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Thin));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.UltraBlack));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.UltraBold));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.UltraLight));

            ComboBox_FontStyle.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontStyles.Italic));
            ComboBox_FontStyle.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontStyles.Normal));
            ComboBox_FontStyle.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontStyles.Oblique));

            // hook
            UcColorPreview_Background.ColorChanged += (sender, args) => UCLabel_Preview.SetBackground(UcColorPreview_Background.Color);
            UcColorPreview_Foreground.ColorChanged += (sender, args) => UCLabel_Preview.SetForeground(UcColorPreview_Foreground.Color);
            ComboBox_FontFamily.SelectionChanged += (o, args) => UCLabel_Preview.SetFontFamily(((ComboBoxItemFontFamilyFontWeightFontStyle)ComboBox_FontFamily.SelectedItem).SystemFontFamily);
            ComboBox_FontWeight.SelectionChanged += (o, args) => UCLabel_Preview.SetFontWeight(((ComboBoxItemFontFamilyFontWeightFontStyle)ComboBox_FontWeight.SelectedItem).SystemFontWeight);
            ComboBox_FontStyle.SelectionChanged += (o, args) => UCLabel_Preview.SetFontStyle(((ComboBoxItemFontFamilyFontWeightFontStyle)ComboBox_FontStyle.SelectedItem).SystemFontStyle);
            TextBox_FontSize.TextChanged += (sender, args) => { double value; if (double.TryParse(TextBox_FontSize.Text, out value)) UCLabel_Preview.SetFontSize(value); };
            TextBox_Margin.TextChanged += (sender, args) =>
            {
                try
                {
                    string[] split = TextBox_Margin.Text.Split(new[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries);
                    UCLabel_Preview.SetMargin(new Thickness(double.Parse(split[0]), double.Parse(split[1]), double.Parse(split[2]), double.Parse(split[3])));
                    TextBox_Margin.Background = Brushes.White;
                }
                catch
                {
                    TextBox_Margin.Background = Brushes.MistyRose;
                }
            };
            UcColorPreview_BorderBrush.ColorChanged += (sender, args) => UCLabel_Preview.SetBorderBrush(UcColorPreview_BorderBrush.Color);
            TextBox_BorderThickness.TextChanged += (sender, args) =>
            {
                try
                {
                    string[] split = TextBox_BorderThickness.Text.Split(new[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries);
                    UCLabel_Preview.SetBorderThickness(new Thickness(double.Parse(split[0]), double.Parse(split[1]), double.Parse(split[2]), double.Parse(split[3])));
                    TextBox_BorderThickness.Background = Brushes.White;
                }
                catch
                {
                    TextBox_BorderThickness.Background = Brushes.MistyRose;
                }
            };
            TextBox_CornerRadius.TextChanged += (sender, args) =>
            {
                try
                {
                    string[] split = TextBox_CornerRadius.Text.Split(new[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries);
                    UCLabel_Preview.SetCornerRadius(new CornerRadius(double.Parse(split[0]), double.Parse(split[1]), double.Parse(split[2]), double.Parse(split[3])));
                    TextBox_CornerRadius.Background = Brushes.White;
                }
                catch
                {
                    TextBox_CornerRadius.Background = Brushes.MistyRose;
                }
            };

            // seed values

            SeedValues();
        }
コード例 #2
0
        public WindowHudDesign(Window owner, HudCustomizeParams.HudCustomizeType hudCustomizeType)
        {
            InitializeComponent();
            Owner = owner;
            WindowStartupLocation = WindowStartupLocation.CenterOwner;

            HudCustomizeParams = new HudCustomizeParams(hudCustomizeType);

            // init values

            foreach (var item in Fonts.SystemFontFamilies)
            {
                ComboBox_FontFamily.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(item));
            }

            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Black));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Bold));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.DemiBold));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.ExtraBlack));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.ExtraBold));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.ExtraLight));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Heavy));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Light));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Medium));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Normal));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Regular));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.SemiBold));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.Thin));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.UltraBlack));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.UltraBold));
            ComboBox_FontWeight.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontWeights.UltraLight));

            ComboBox_FontStyle.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontStyles.Italic));
            ComboBox_FontStyle.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontStyles.Normal));
            ComboBox_FontStyle.Items.Add(new ComboBoxItemFontFamilyFontWeightFontStyle(FontStyles.Oblique));

            // hook
            UcColorPreview_Background.ColorChanged += (sender, args) => UCLabel_Preview.SetBackground(UcColorPreview_Background.Color);
            UcColorPreview_Foreground.ColorChanged += (sender, args) => UCLabel_Preview.SetForeground(UcColorPreview_Foreground.Color);
            ComboBox_FontFamily.SelectionChanged   += (o, args) => UCLabel_Preview.SetFontFamily(((ComboBoxItemFontFamilyFontWeightFontStyle)ComboBox_FontFamily.SelectedItem).SystemFontFamily);
            ComboBox_FontWeight.SelectionChanged   += (o, args) => UCLabel_Preview.SetFontWeight(((ComboBoxItemFontFamilyFontWeightFontStyle)ComboBox_FontWeight.SelectedItem).SystemFontWeight);
            ComboBox_FontStyle.SelectionChanged    += (o, args) => UCLabel_Preview.SetFontStyle(((ComboBoxItemFontFamilyFontWeightFontStyle)ComboBox_FontStyle.SelectedItem).SystemFontStyle);
            TextBox_FontSize.TextChanged           += (sender, args) => { double value; if (double.TryParse(TextBox_FontSize.Text, out value))
                                                                          {
                                                                              UCLabel_Preview.SetFontSize(value);
                                                                          }
            };
            TextBox_Margin.TextChanged += (sender, args) =>
            {
                try
                {
                    string[] split = TextBox_Margin.Text.Split(new[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries);
                    UCLabel_Preview.SetMargin(new Thickness(double.Parse(split[0]), double.Parse(split[1]), double.Parse(split[2]), double.Parse(split[3])));
                    TextBox_Margin.Background = Brushes.White;
                }
                catch
                {
                    TextBox_Margin.Background = Brushes.MistyRose;
                }
            };
            UcColorPreview_BorderBrush.ColorChanged += (sender, args) => UCLabel_Preview.SetBorderBrush(UcColorPreview_BorderBrush.Color);
            TextBox_BorderThickness.TextChanged     += (sender, args) =>
            {
                try
                {
                    string[] split = TextBox_BorderThickness.Text.Split(new[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries);
                    UCLabel_Preview.SetBorderThickness(new Thickness(double.Parse(split[0]), double.Parse(split[1]), double.Parse(split[2]), double.Parse(split[3])));
                    TextBox_BorderThickness.Background = Brushes.White;
                }
                catch
                {
                    TextBox_BorderThickness.Background = Brushes.MistyRose;
                }
            };
            TextBox_CornerRadius.TextChanged += (sender, args) =>
            {
                try
                {
                    string[] split = TextBox_CornerRadius.Text.Split(new[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries);
                    UCLabel_Preview.SetCornerRadius(new CornerRadius(double.Parse(split[0]), double.Parse(split[1]), double.Parse(split[2]), double.Parse(split[3])));
                    TextBox_CornerRadius.Background = Brushes.White;
                }
                catch
                {
                    TextBox_CornerRadius.Background = Brushes.MistyRose;
                }
            };

            // seed values

            SeedValues();
        }