当前位置: 首页>>代码示例>>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;未经允许,请勿转载。