Exemple #1
0
        private void StampChooseFontButton_OnClick(object sender, EventArgs e)
        {
            var fontDialog = new FontDialog();

            fontDialog.Font = new Font(ViewModel.CurrentProfile.Stamping.FontName,
                                       ViewModel.CurrentProfile.Stamping.FontSize);

            try
            {
                if (fontDialog.ShowDialog() == DialogResult.OK)
                {
                    var postScriptName = FontHelper.FindPostScriptName(fontDialog.Font.Name);

                    if (postScriptName == null)
                    {
                        var message = TranslationHelper.TranslatorInstance.GetTranslation("ProfileSettingsWindow",
                                                                                          "FontFileNotSupported",
                                                                                          "The selected font is not supported. Please select a different font.");

                        throw new InvalidOperationException(message);
                    }

                    ViewModel.CurrentProfile.Stamping.FontName           = fontDialog.Font.Name;
                    ViewModel.CurrentProfile.Stamping.PostScriptFontName = postScriptName;
                    ViewModel.CurrentProfile.Stamping.FontSize           = fontDialog.Font.Size;

                    UpdateFontLabel(ViewModel.CurrentProfile.Stamping);
                }
            }
            catch (Exception ex)
            {
                if (ex is ArgumentException || ex is InvalidOperationException)
                {
                    var message = TranslationHelper.TranslatorInstance.GetTranslation("ProfileSettingsWindow",
                                                                                      "FontFileNotSupported",
                                                                                      "The selected font is not supported. Please select a different font.");
                    MessageWindow.ShowTopMost(message, "clawPDF", MessageWindowButtons.OK,
                                              MessageWindowIcon.Warning);
                    return;
                }

                throw;
            }
        }