/// <summary> /// Shows the font selection dialog. /// </summary> public void ShowFontChooser() { string title = "Select a font"; fontDialog = new FontChooserDialog(title, window1); // Center the dialog on the main window. fontDialog.TransientFor = MainWidget as Window; fontDialog.WindowPosition = WindowPosition.CenterOnParent; // Select the current font. if (Utility.Configuration.Settings.FontName != null) { fontDialog.Font = Utility.Configuration.Settings.FontName.ToString(); } //fontDialog.FontActivated += OnChangeFont; fontDialog.Response += OnChangeFont; // Show the dialog. fontDialog.ShowAll(); }
private void Button_Click(object sender, RoutedEventArgs e) { FontChooserDialog dialog = new FontChooserDialog(); dialog.Owner = Window.GetWindow(this); dialog.ShowDialog(); }
private void previewText_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { FontChooserDialog fcd = new FontChooserDialog(); fcd.Owner = this; fcd.SelectFontSettings(previewText); fcd.ShowColor = (bool)showColorCheckBox.IsChecked; fcd.ShowTextDecorations = (bool)showTextDecorationsCheckBox.IsChecked; if (fcd.ShowDialog() == true) { fcd.ApplyFontSettings(previewText); } }
public bool?ShowDialog() { FontChooserDialog fontChooser = new FontChooserDialog(); fontChooser.SelectedFontFamily = new System.Windows.Media.FontFamily(SelectedFontFamily); fontChooser.SelectedFontSize = SelectedFontSize; fontChooser.SelectedFontColor = ColorHelper.ToWpfColor(SelectedFontColor); fontChooser.ShowTextDecorations = false; fontChooser.Owner = App.Current.GetActiveWindow(); var result = fontChooser.ShowDialog(); if (result == true) { SelectedFontFamily = fontChooser.SelectedFontFamily.Source; SelectedFontSize = fontChooser.SelectedFontSize; SelectedFontColor = ColorHelper.FromWpfColor(fontChooser.SelectedFontColor); } return(result); }
/// <summary> /// Set the font name of a font chooser dialog. /// </summary> /// <param name="fontChooser"></param> /// <param name="fontName"></param> public static void SetFontName(this FontChooserDialog fontChooser, string fontName) { fontChooser.Font = fontName; }