private void Button_Click(object sender, RoutedEventArgs e) { try { FontChooserDialog dialog = new FontChooserDialog(); dialog.SelectedFamily = TextFormat.FontFamily; dialog.SelectedTypeface = new Typeface(TextFormat.FontFamily, TextFormat.FontStyle, TextFormat.FontWeight, FontStretches.Normal); dialog.SelectedSize = TextFormat.FontSize; if (TextFormat.Decorations.HasFlag(TextDecorations.Underline)) { dialog.IsUnderline = true; } if (TextFormat.Decorations.HasFlag(TextDecorations.Strikethrough)) { dialog.IsStrikethrough = true; } if (TextFormat.Decorations.HasFlag(TextDecorations.Baseline)) { dialog.IsBaseline = true; } if (TextFormat.Decorations.HasFlag(TextDecorations.OverLine)) { dialog.IsOverLine = true; } dialog.Owner = Window.GetWindow(this); Nullable<bool> results = dialog.ShowDialog(); if (results != null && results == true) { ConfigManager.UndoManager.StartBatch(); TextFormat.FontFamily = dialog.SelectedTypeface.FontFamily; TextFormat.FontStyle = dialog.SelectedTypeface.Style; TextFormat.FontWeight = dialog.SelectedTypeface.Weight; TextFormat.FontSize = dialog.SelectedSize; TextDecorations newDecorations = 0; if (dialog.IsUnderline) { newDecorations |= TextDecorations.Underline; } if (dialog.IsStrikethrough) { newDecorations |= TextDecorations.Strikethrough; } if (dialog.IsBaseline) { newDecorations |= TextDecorations.Baseline; } if (dialog.IsOverLine) { newDecorations |= TextDecorations.OverLine; } TextFormat.Decorations = newDecorations; ConfigManager.UndoManager.CloseBatch(); } } catch (Exception re) { ConfigManager.LogManager.LogError("Error opening text format editor.", re); } }
private void Button_Click(object sender, RoutedEventArgs e) { try { FontChooserDialog dialog = new FontChooserDialog(); dialog.SelectedFamily = TextFormat.FontFamily; dialog.SelectedTypeface = new Typeface(TextFormat.FontFamily, TextFormat.FontStyle, TextFormat.FontWeight, FontStretches.Normal); dialog.SelectedSize = TextFormat.FontSize; if (TextFormat.Decorations.HasFlag(TextDecorations.Underline)) { dialog.IsUnderline = true; } if (TextFormat.Decorations.HasFlag(TextDecorations.Strikethrough)) { dialog.IsStrikethrough = true; } if (TextFormat.Decorations.HasFlag(TextDecorations.Baseline)) { dialog.IsBaseline = true; } if (TextFormat.Decorations.HasFlag(TextDecorations.OverLine)) { dialog.IsOverLine = true; } dialog.Owner = Window.GetWindow(this); bool?results = dialog.ShowDialog(); if (results != null && results == true) { ConfigManager.UndoManager.StartBatch(); TextFormat.FontFamily = dialog.SelectedTypeface.FontFamily; TextFormat.FontStyle = dialog.SelectedTypeface.Style; TextFormat.FontWeight = dialog.SelectedTypeface.Weight; TextFormat.FontSize = dialog.SelectedSize; TextFormat.ConfiguredFontSize = dialog.SelectedSize; TextDecorations newDecorations = 0; if (dialog.IsUnderline) { newDecorations |= TextDecorations.Underline; } if (dialog.IsStrikethrough) { newDecorations |= TextDecorations.Strikethrough; } if (dialog.IsBaseline) { newDecorations |= TextDecorations.Baseline; } if (dialog.IsOverLine) { newDecorations |= TextDecorations.OverLine; } TextFormat.Decorations = newDecorations; ConfigManager.UndoManager.CloseBatch(); } } catch (Exception ex) { Logger.Error(ex, "Error opening text format editor."); } }
private void Button_Click(object sender, RoutedEventArgs e) { FontChooserDialog dialog = new FontChooserDialog(); dialog.Owner = Window.GetWindow(this); dialog.ShowDialog(); }