當前位置: 首頁>>代碼示例>>C#>>正文


C# FontDialog.ShowDialog方法代碼示例

本文整理匯總了C#中System.Windows.Forms.FontDialog.ShowDialog方法的典型用法代碼示例。如果您正苦於以下問題:C# FontDialog.ShowDialog方法的具體用法?C# FontDialog.ShowDialog怎麽用?C# FontDialog.ShowDialog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.FontDialog的用法示例。


在下文中一共展示了FontDialog.ShowDialog方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: buttonChangeFont_Click

        private void buttonChangeFont_Click( object sender, EventArgs e )
        {
            var dialog = new FontDialog()
                { AllowScriptChange  = true
                , AllowSimulations   = true
                , AllowVectorFonts   = true
                , AllowVerticalFonts = true
                , Font               = (LastGdiFont==null) ? Configuration.Main.GdiFont : LastGdiFont
                , FontMustExist      = true
                , ShowColor          = false
                };
            var result = dialog.ShowDialog(this);
            if ( result != DialogResult.OK ) return;
            var font = LastGdiFont = dialog.Font;

            Size touse = new Size(0,0);
            for ( char ch=(char)0 ; ch<(char)255 ; ++ch ) {
                if ( "\u0001 \t\n\r".Contains(ch) ) continue; // annoying outliers
                var m = TextRenderer.MeasureText( ch.ToString(), font, Size.Empty, TextFormatFlags.NoPadding );
                touse.Width  = Math.Max( touse.Width , m.Width  );
                touse.Height = Math.Max( touse.Height, m.Height );
            }

            var scf = ShinyConsole.Font.FromGdiFont( font, touse.Width, touse.Height );
            pictureBoxFontPreview.Image = scf.Bitmap;
        }
開發者ID:MaulingMonkey,項目名稱:TtyRecMonkey,代碼行數:26,代碼來源:ConfigurationForm.cs

示例2: EditValue

 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     this.value = value;
     if ((provider != null) && (((IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService))) != null))
     {
         FontDialog dialog = new FontDialog();
         dialog.ShowApply = false;
         dialog.ShowColor = false;
         dialog.AllowVerticalFonts = false;
         dialog.AllowScriptChange = false;
         dialog.FixedPitchOnly = true;
         dialog.ShowEffects = false;
         dialog.ShowHelp = false;
         Font font = value as Font;
         if (font != null)
         {
             dialog.Font = font;
         }
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             this.value = dialog.Font;
         }
         dialog.Dispose();
     }
     value = this.value;
     this.value = null;
     return value;
 }
開發者ID:JamesH001,項目名稱:SX1231,代碼行數:28,代碼來源:HexFontEditor.cs

示例3: btnFont_Click

 /// <summary>
 /// 選擇(修改)字體
 /// </summary>
 /// <params name="sender"></params>
 /// <params name="e"></params>
 private void btnFont_Click(object sender, EventArgs e)
 {
     FontDialog pFontDialog = new FontDialog();
     pFontDialog.ShowDialog();
     if (pFontDialog.Font != null)
         m_pFont = pFontDialog.Font;
 }
開發者ID:ismethr,項目名稱:gas-geological-map,代碼行數:12,代碼來源:InputText.cs

示例4: btnEdit_Click

 private void btnEdit_Click(object sender, EventArgs e)
 {
     FontDialog dlg = new FontDialog();
     dlg.Font = UserFont;
     if (dlg.ShowDialog() == DialogResult.OK)
         UserFont = dlg.Font;
 }
開發者ID:JerreS,項目名稱:Crype,代碼行數:7,代碼來源:FontSettingControl.cs

示例5: EditValue

        /// <summary>
        /// Edits the value
        /// </summary>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            this.value = value;
            if (provider != null)
            {
                IWindowsFormsEditorService service1 = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService));
                if (service1 != null)
                {
                    FontDialog fontDialog = new FontDialog();
                    fontDialog.ShowApply = false;
                    fontDialog.ShowColor = false;
                    fontDialog.AllowVerticalFonts = false;
                    fontDialog.AllowScriptChange = false;
                    fontDialog.FixedPitchOnly = true;
                    fontDialog.ShowEffects = false;
                    fontDialog.ShowHelp = false;

                    Font font = value as Font;
                    if(font != null)
                    {
                        fontDialog.Font = font;
                    }
                    if (fontDialog.ShowDialog() == DialogResult.OK)
                    {
                        this.value = fontDialog.Font;
                    }

                    fontDialog.Dispose();
                }
            }

            value = this.value;
            this.value = null;
            return value;
        }
開發者ID:normanzb,項目名稱:mailtro,代碼行數:38,代碼來源:HexFontEditor.cs

示例6: ShowFontDialog

        public static DialogResult ShowFontDialog(WatermarkConfig Config)
        {
            DialogResult result = DialogResult.Cancel;
            try
            {
                var fDialog = new FontDialog
                {
                    ShowColor = true
                };
                try
                {
                    fDialog.Color = Config.WatermarkFontArgb;
                    fDialog.Font = Config.WatermarkFont;
                }
                catch (Exception err)
                {
                    DebugHelper.WriteException(err, "Error while initializing Font and Color");
                }

                result = fDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    Config.WatermarkFont = fDialog.Font;
                    Config.WatermarkFontArgb = fDialog.Color;
                }
            }
            catch (Exception ex)
            {
                DebugHelper.WriteException(ex, "Error while setting Watermark Font");
            }
            return result;
        }
開發者ID:modulexcite,項目名稱:ZScreen_Google_Code,代碼行數:32,代碼來源:StaticHelper.cs

示例7: OnMouseUp

 protected override void OnMouseUp(MouseEventArgs mevent)
 {
     IsDragMode = false;
     base.OnMouseUp(mevent);
     if (mevent.Button == MouseButtons.Right)
     {
         using (ColorDialog cd = new ColorDialog())
         {
             cd.FullOpen = true;
             if (cd.ShowDialog() == DialogResult.OK)
             {
                 this.ForeColor = cd.Color;
             }
         }
         using (FontDialog fd = new FontDialog())
         {
             try
             {
                 fd.AllowScriptChange = false;
                 fd.AllowSimulations = false;
                 if (fd.ShowDialog() == DialogResult.OK)
                 {
                     this.Font = fd.Font;
                 }
             }
             catch (Exception ex)
             {
                 //Not a truetype font
                 MessageBox.Show(this, ex.Message + Environment.NewLine + "Шрифт не изменен.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
     }
 }
開發者ID:Ossir,項目名稱:Ad-Constructor,代碼行數:33,代碼來源:TextBox.cs

示例8: EditValue

        /// <summary>
        /// Edits the value
        /// </summary>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            editedValue = value;
            using (var fontDialog = new FontDialog())
            {
                fontDialog.ShowApply = false;
                fontDialog.ShowColor = false;
                fontDialog.AllowVerticalFonts = false;
                fontDialog.AllowScriptChange = false;
                fontDialog.FixedPitchOnly = true;
                fontDialog.ShowEffects = false;
                fontDialog.ShowHelp = false;

                Font font = value as Font;
                if (font != null) fontDialog.Font = font;

                if (fontDialog.ShowDialog() == DialogResult.OK)
                    editedValue = fontDialog.Font;
            }

            value = editedValue;
            editedValue = null;

            return value;
        }
開發者ID:sagar1589,項目名稱:Delta.Cryptography,代碼行數:28,代碼來源:FixedSizeFontEditor.cs

示例9: Button_Click_1

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            FontDialog fd = new FontDialog();

            System.Windows.Forms.DialogResult dr = fd.ShowDialog();
            if (dr != System.Windows.Forms.DialogResult.Cancel)
            {
                FontFamily fontFamily = new System.Windows.Media.FontFamily(fd.Font.Name);
                double fontSize = fd.Font.Size * 96.0 / 72.0; ;
                FontWeight fontWeight = fd.Font.Bold ? FontWeights.Bold : FontWeights.Regular;
                FontStyle fontStyle = fd.Font.Italic ? FontStyles.Italic : FontStyles.Normal;

                tbSourse.FontFamily = fontFamily;
                tbTranslated.FontFamily = fontFamily;
                tbSourse.FontSize = fontSize;
                tbTranslated.FontSize = fontSize;
                tbSourse.FontWeight = fontWeight;
                tbTranslated.FontWeight = fontWeight;
                tbSourse.FontStyle = fontStyle;
                tbTranslated.FontStyle = fontStyle;

                Properties.Settings.Default.FontFamily = fontFamily;
                Properties.Settings.Default.FontSize = fontSize;
                Properties.Settings.Default.FontWeight = fontWeight;
                Properties.Settings.Default.FontStyle = fontStyle;
                Properties.Settings.Default.Save();
            }
        }
開發者ID:novg,項目名稱:yTranslator,代碼行數:28,代碼來源:MainWindow.xaml.cs

示例10: ChangeFontButton_Click

 private void ChangeFontButton_Click(object sender, EventArgs e)
 {
     var fd = new FontDialog { Font = LogMessageTextBox.Font };
     if (fd.ShowDialog() == DialogResult.OK)
     {
         LogMessageTextBox.Font = fd.Font;
     }
 }
開發者ID:NeilQ,項目名稱:ip-sync,代碼行數:8,代碼來源:LogForm.cs

示例11: fontToolStripMenuItem1_Click

 private void fontToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     FontDialog font = new FontDialog();
     font.Font = notepad_interface.SelectionFont;
     if (font.ShowDialog() == DialogResult.OK){
         notepad_interface.SelectionFont = font.Font;
     }
 }
開發者ID:jasmith152,項目名稱:Notepad,代碼行數:8,代碼來源:Form1.cs

示例12: OnClick

 protected override void OnClick(EventArgs e)
 {
     var fod = new FontDialog();
     fod.Font = SelectedFont.CreateFont();
     if(fod.ShowDialog() == DialogResult.OK) {
         SelectedFont = FontDescription.FromFont(fod.Font);
     }
 }
開發者ID:raphaelr,項目名稱:countanything,代碼行數:8,代碼來源:FontInput.cs

示例13: changeFontToolStripMenuItem_Click

        private void changeFontToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FontDialog fd = new FontDialog();
            fd.Font = this.clockLabel.Font;
            fd.ShowDialog();

            this.clockLabel.Font = fd.Font;
        }
開發者ID:JohnLettman,項目名稱:Coursework,代碼行數:8,代碼來源:MainWindow.cs

示例14: fontBtn_Click

        private void fontBtn_Click(object sender, EventArgs e)
        {
            FontDialog fontDlg = new FontDialog();
            fontDlg.Font = textBox.Font;

            if (fontDlg.ShowDialog() == DialogResult.OK)
                textBox.Font = fontDlg.Font;
        }
開發者ID:pchmielowski,項目名稱:Paint,代碼行數:8,代碼來源:TextDialog.cs

示例15: fontsToolStripMenuItem_Click

 private void fontsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FontDialog FontSelect = new FontDialog(); //Font dialog
     if (FontSelect.ShowDialog() == DialogResult.OK)
     {
         rtfContent.Font = FontSelect.Font; //sets font
     }
 }
開發者ID:rguarascia,項目名稱:The_Editor,代碼行數:8,代碼來源:Form1.cs


注:本文中的System.Windows.Forms.FontDialog.ShowDialog方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。