Esempio n. 1
0
        private void OnButtonClick(object sender, RoutedEventArgs eventArgs)
        {
            var fontDialog = new FontDialog();
            fontDialog.Chooser.SelectedFontFamily = FontChooser.SelectedFontFamily;
            fontDialog.Chooser.SelectedFontSize = FontChooser.SelectedFontSize;
            fontDialog.Chooser.SelectedFontStyle = FontChooser.SelectedFontStyle;
            fontDialog.Chooser.SelectedFontStretch = FontChooser.SelectedFontStretch;
            fontDialog.Chooser.SelectedFontWeight = FontChooser.SelectedFontWeight;

            bool? result = fontDialog.ShowDialog();
            if (result.GetValueOrDefault())
            {
                FontChooser.SelectedFontFamily = fontDialog.Chooser.SelectedFontFamily;
                FontChooser.SelectedFontSize = fontDialog.Chooser.SelectedFontSize;
                FontChooser.SelectedFontStyle = fontDialog.Chooser.SelectedFontStyle;
                FontChooser.SelectedFontStretch = fontDialog.Chooser.SelectedFontStretch;
                FontChooser.SelectedFontWeight = fontDialog.Chooser.SelectedFontWeight;
            }
        }
Esempio n. 2
0
 private void ShowFontDialog(object sender, RoutedEventArgs eventArgs)
 {
     var fontDialog = new FontDialog();
     fontDialog.ShowDialog();
 }
Esempio n. 3
0
        private void SelectFont()
        {
            var fontDialog = new FontDialog();

            if (!string.IsNullOrEmpty(Options.FontFamily))
                fontDialog.Chooser.SelectedFontFamily = new FontFamily(Options.FontFamily);
            if (Options.FontSize > 0)
                fontDialog.Chooser.SelectedFontSize = Options.FontSize;

            // ReSharper disable PossibleNullReferenceException
            if (!string.IsNullOrEmpty(Options.FontStretch))
                fontDialog.Chooser.SelectedFontStretch = (FontStretch)_fontStretchConverter.ConvertFrom(Options.FontStretch);
            if (!string.IsNullOrEmpty(Options.FontStyle))
                fontDialog.Chooser.SelectedFontStyle = (FontStyle)_fontStyleConverter.ConvertFrom(Options.FontStyle);
            if (!string.IsNullOrEmpty(Options.FontWeight))
                fontDialog.Chooser.SelectedFontWeight = (FontWeight)_fontWeightConverter.ConvertFrom(Options.FontWeight);
            // ReSharper restore PossibleNullReferenceException

            var result = fontDialog.ShowDialog();
            if (result.GetValueOrDefault())
            {
                Options.FontFamily = fontDialog.Chooser.SelectedFontFamily.ToString();
                Options.FontSize = fontDialog.Chooser.SelectedFontSize;
                Options.FontStyle = fontDialog.Chooser.SelectedFontStyle.ToString();
                Options.FontStretch = fontDialog.Chooser.SelectedFontStretch.ToString();
                Options.FontWeight = fontDialog.Chooser.SelectedFontWeight.ToString();
                RaisePropertyChanged(() => Font);
            }
        }