private void SeedValues() { UCLabel_Preview.SetText(HudCustomizeParams.PreviewText); UcColorPreview_Background.Color = HudCustomizeParams.Background; UcColorPreview_Background.Owner = this; UcColorPreview_Foreground.Color = HudCustomizeParams.Foreground; UcColorPreview_Foreground.Owner = this; foreach (ComboBoxItemFontFamilyFontWeightFontStyle item in ComboBox_FontFamily.Items.Cast <object>().OfType <ComboBoxItemFontFamilyFontWeightFontStyle>().Where(item => item.SystemFontFamily.Equals(HudCustomizeParams.FontFamily))) { ComboBox_FontFamily.SelectedItem = item; break; } foreach (ComboBoxItemFontFamilyFontWeightFontStyle item in ComboBox_FontWeight.Items.Cast <object>().OfType <ComboBoxItemFontFamilyFontWeightFontStyle>().Where(item => item.SystemFontWeight.Equals(HudCustomizeParams.FontWeight))) { ComboBox_FontWeight.SelectedItem = item; break; } foreach (ComboBoxItemFontFamilyFontWeightFontStyle item in ComboBox_FontStyle.Items.Cast <object>().OfType <ComboBoxItemFontFamilyFontWeightFontStyle>().Where(item => item.SystemFontStyle.Equals(HudCustomizeParams.FontStyle))) { ComboBox_FontStyle.SelectedItem = item; break; } TextBox_FontSize.Text = HudCustomizeParams.FontSize.ToString(CultureInfo.InvariantCulture); TextBox_Margin.Text = HudCustomizeParams.Margin.Left + " " + HudCustomizeParams.Margin.Top + " " + HudCustomizeParams.Margin.Right + " " + HudCustomizeParams.Margin.Bottom; UcColorPreview_BorderBrush.Color = HudCustomizeParams.BorderBrush; UcColorPreview_BorderBrush.Owner = this; TextBox_BorderThickness.Text = HudCustomizeParams.BorderThickness.Left + " " + HudCustomizeParams.BorderThickness.Top + " " + HudCustomizeParams.BorderThickness.Right + " " + HudCustomizeParams.BorderThickness.Bottom; TextBox_CornerRadius.Text = HudCustomizeParams.CornerRadius.TopLeft + " " + HudCustomizeParams.CornerRadius.TopRight + " " + HudCustomizeParams.CornerRadius.BottomRight + " " + HudCustomizeParams.CornerRadius.BottomLeft; }
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(); }