void ChangeFontButton_Click (object sender, EventArgs e) { FontDialog dialog = new FontDialog (); dialog.ShowDialog (); _richTextBox.SelectionFont = dialog.Font; _richTextBox.Focus (); }
void OnClicked(object sender, ToolBarButtonClickEventArgs e) { FontDialog dialog = new FontDialog(); if (dialog.ShowDialog(this) == DialogResult.OK) { text.Font = dialog.Font; LocateText(); } }
private void buttonStateFont_Click(object sender, EventArgs e) { if (checkBoxLabels.Checked) { FontDialog fontDialog = new FontDialog(); fontDialog.ShowColor = true; //fontDialog.ShowApply = true; fontDialog.ShowEffects = true; fontDialog.ShowHelp = true; fontDialog.Font = Properties.Settings.Default.FontStateLabels; fontDialog.Color = Properties.Settings.Default.FontStateColor; DialogResult result = fontDialog.ShowDialog(); if (result == DialogResult.OK) { labelStateFont.Font = fontDialog.Font; labelStateFont.ForeColor = fontDialog.Color; Properties.Settings.Default.FontStateLabels = fontDialog.Font; Properties.Settings.Default.FontStateColor = fontDialog.Color; Properties.Settings.Default.Save(); } } }
private void fontButton_Click(object sender, System.EventArgs e) { if (EventsHandlingPaused) { return; } if (curRuler == null) { return; } FontDialog dialog = new FontDialog(); dialog.Font = curRuler.TextFontStyle.CreateFont(view.MeasurementUnitConverter); if (dialog.ShowDialog() != DialogResult.OK) { return; } curRuler.TextFontStyle = new NFontStyle(dialog.Font); view.Refresh(); }
private Font ChooseFont(Font previousFont, int minSize, int maxSize) { var dialog = new FontDialog(); dialog.Font = previousFont; dialog.MinSize = minSize; dialog.MaxSize = maxSize; try { var result = dialog.ShowDialog(this); if (result == System.Windows.Forms.DialogResult.OK) { return(dialog.Font); } } catch (Exception ex) { Log.Error(ex); MessageBox.Show("This font is not supported.", "Font Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return(previousFont); }
protected override void RunButton() { Parent.Focus(); FontDialog dlg = new FontDialog(); dlg.Font = (Font)mOwnerPropertyEnum.Property.Value.GetValue(); if (dlg.ShowDialog() != DialogResult.Cancel) { mOwnerPropertyEnum.Property.Value.PreviousValue = mOwnerPropertyEnum.Property.Value.GetValue(); mOwnerPropertyEnum.Property.Value.SetValue(dlg.Font); if (mEdit != null) { mEdit.Text = mOwnerPropertyEnum.Property.Value.DisplayString; } mOwnerPropertyEnum.Property.ParentGrid.NotifyPropertyChanged(new PropertyChangedEventArgs(mOwnerPropertyEnum)); } mOwnerPropertyEnum.Property.ParentGrid.OnInPlaceCtrlFinishedEdition(); }
private void btnChangeEnglishFont_Click(object sender, EventArgs e) { FontDialog dialog = new FontDialog(); dialog.Font = painter.EnglishFont; //设置为上一次的字体,方便修改 try { if (dialog.ShowDialog() == DialogResult.OK && dialog.Font != null) { painter.EnglishFont = dialog.Font; lblEnglishFontInfo.Text = string.Format("{0} {1}", dialog.Font.Name, dialog.Font.Size); lblEnglishFontPreview.Font = dialog.Font; } } catch (ArgumentException ex) { if (ex.Message.Contains("TrueType")) { Utils.ShowError("OpenType font is not supported! Try google how to convert .otf to .ttf ."); } } dialog.Dispose(); }
private void lnkSelectFont_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { FontDialog fd = new FontDialog(); if (fd.ShowDialog() == DialogResult.OK) { var font = fd.Font; _text.FontName = $"'{font.Name}'"; //NOXLATE if (font.Bold) { _text.Bold = font.Bold.ToString(); } if (font.Italic) { _text.Italic = font.Italic.ToString(); } if (font.Underline) { _text.Underlined = font.Underline.ToString(); } _text.Height = font.Size.ToString(); } }
private void OnBtnSelListFont(object sender, EventArgs e) { FontDialog dlg = UIUtil.CreateFontDialog(false); AceFont fOld = Program.Config.UI.StandardFont; if (fOld.OverrideUIDefault) { dlg.Font = fOld.ToFont(); } else { try { dlg.Font = m_lvSecurityOptions.Font; } catch (Exception) { Debug.Assert(false); } } if (dlg.ShowDialog() == DialogResult.OK) { Program.Config.UI.StandardFont = new AceFont(dlg.Font); Program.Config.UI.StandardFont.OverrideUIDefault = true; } dlg.Dispose(); }
/// <summary> /// 处理菜单点击事件 /// </summary> /// <param name="e">事件参数</param> protected override void OnClick(EventArgs e) { if (this.bolDialogSelectFont) { this.bolFontNameOnly = false; using (System.Windows.Forms.FontDialog dlg = new FontDialog()) { dlg.Color = this.intColor; dlg.Font = new Font(strFontName, fFontSize, intFontStyle); dlg.ShowColor = true; if (dlg.ShowDialog( ) == System.Windows.Forms.DialogResult.OK) { intColor = dlg.Color; this.Font = dlg.Font; base.OnClick(e); } } } else { base.OnClick(e); } }
private void textBox_Font_MouseClick(object sender, MouseEventArgs e) { FontDialog fd = new FontDialog(); fd.Font = new Font(_discoveryForm.theme.FontName, _discoveryForm.theme.FontSize); fd.MinSize = 4; fd.MaxSize = 12; if (fd.ShowDialog() == DialogResult.OK) { if (fd.Font.Style == FontStyle.Regular) { _discoveryForm.theme.FontName = fd.Font.Name; _discoveryForm.theme.FontSize = fd.Font.Size; UpdatePatchesEtc(); _discoveryForm.ApplyTheme(); } else { EDDiscovery.Forms.MessageBoxTheme.Show("Font does not have regular style"); } } }
// フォントの設定 private FontDialog ShowFontDialog() { FontDialog fd = new FontDialog { Font = CPUInfo.Font, Color = ForeColor, MaxSize = 20, MinSize = 10, FontMustExist = true, AllowVerticalFonts = false, ShowColor = true, ShowEffects = false, FixedPitchOnly = false, AllowVectorFonts = true }; if (fd.ShowDialog() != DialogResult.OK) { return(null); } return(fd); }
private void textBox_Font_MouseClick(object sender, MouseEventArgs e) { FontDialog fd = new FontDialog(); fd.Font = new Font(theme.FontName, theme.FontSize); fd.MinSize = 4; fd.MaxSize = 12; if (fd.ShowDialog() == DialogResult.OK) { if (fd.Font.Style == FontStyle.Regular) { theme.FontName = fd.Font.Name; theme.FontSize = fd.Font.Size; UpdatePatchesEtc(); ApplyChanges?.Invoke(); } else { ExtendedControls.MessageBoxTheme.Show("Font does not have regular style"); } } }
private void btnFont_Click(object sender, EventArgs e) { FontDialog fd = new FontDialog(); fd.ShowColor = true; fd.FontMustExist = true; if (configuration.Color != null) { fd.Color = (Color) new ColorConverter().ConvertFromString(configuration.Color); } if (configuration.Font != null) { fd.Font = (Font) new FontConverter().ConvertFromString(configuration.Font); } if (fd.ShowDialog() == DialogResult.OK) { configuration.Font = new FontConverter().ConvertToString(fd.Font); configuration.Color = new ColorConverter().ConvertToString(fd.Color); } }
private void SetFontStyle() { var fontDialog = new FontDialog(); fontDialog.FixedPitchOnly = true; fontDialog.FontMustExist = true; fontDialog.MinSize = 6; if (Settings.Default.ButtonTextFaceFont != null) { fontDialog.Font = Settings.Default.ButtonTextFaceFont; } if (fontDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _dcsbiosDecoder.TextFont = fontDialog.Font; Settings.Default.ButtonTextFaceFont = fontDialog.Font; Settings.Default.Save(); SetIsDirty(); } }
/// <summary> /// 实例化字体对话框 /// </summary> /// <returns></returns> public static object fontDialogMethod(TextBox t) { Dictionary <string, object> retDic = new Dictionary <string, object>(); FontDialog fontD = new FontDialog(); fontD.AllowSimulations = true; fontD.AllowVectorFonts = true; fontD.AllowScriptChange = true; fontD.ScriptsOnly = true; fontD.Font = t.Font; fontD.ShowApply = true; fontD.ShowEffects = false; if (!retDic.ContainsKey("1")) { retDic.Add("1", fontD); } // 判断是否点击了应用 fontD.Apply += (object sender, EventArgs e) => { t.Font = fontD.Font; if (!retDic.ContainsKey("2")) { retDic.Add("2", DialogResult.OK); } }; DialogResult dialogResult = fontD.ShowDialog(); // 判断是否点击确定 if (dialogResult == DialogResult.OK) { t.Font = fontD.Font; if (!retDic.ContainsKey("2")) { retDic.Add("2", DialogResult.OK); } } return(retDic); }
private void button_ui_getDefaultFont_Click(object sender, EventArgs e) { Font font = null; if (String.IsNullOrEmpty(this.textBox_ui_defaultFont.Text) == false) { // Create the FontConverter. System.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Font)); font = (Font)converter.ConvertFromString(this.textBox_ui_defaultFont.Text); } else { font = Control.DefaultFont; } FontDialog dlg = new FontDialog(); dlg.ShowColor = false; dlg.Font = font; dlg.ShowApply = false; dlg.ShowHelp = true; dlg.AllowVerticalFonts = false; if (dlg.ShowDialog(this) != DialogResult.OK) { return; } { // Create the FontConverter. System.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Font)); this.textBox_ui_defaultFont.Text = converter.ConvertToString(dlg.Font); } }
private void buttonConsoleFont_Click(object sender, EventArgs e) { FontDialog fd = new FontDialog(); //load the current font fd.ShowEffects = false; fd.ShowColor = false; fd.FontMustExist = true; fd.AllowVectorFonts = false; fd.AllowVerticalFonts = false; //fd.FixedPitchOnly = true; monospace fd.Font = new Font(textConsoleFont.Text, float.Parse(textConsoleFontSize.Text), FontStyle.Regular); //capture an error due to this not being a truetype font try { if (fd.ShowDialog() != DialogResult.Cancel && fd.Font.Style == FontStyle.Regular) { textConsoleFont.Text = fd.Font.Name; textConsoleFontSize.Text = fd.Font.Size.ToString(); textConsoleFont.Font = new Font(fd.Font.Name, 10, FontStyle.Regular); } else { if (fd.Font.Style != FontStyle.Regular) { MessageBox.Show("IceChat only supports 'Regular' font styles", "Font Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch (Exception) { MessageBox.Show("IceChat only supports TrueType fonts", "Font Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void textBox_Font_MouseClick(object sender, MouseEventArgs e) { using (FontDialog fd = new FontDialog()) { fd.Font = BaseUtils.FontLoader.GetFont(Theme.FontName, Theme.FontSize); fd.MinSize = 4; fd.MaxSize = 36; DialogResult result; try { result = fd.ShowDialog(this); } catch (ArgumentException ex) { MessageBox.Show(ex.Message); return; } if (result == DialogResult.OK) { if (fd.Font.Style == FontStyle.Regular) { Theme.FontName = fd.Font.Name; Theme.FontSize = fd.Font.Size; UpdatePatchesEtc(); Theme.SetCustom(); ApplyChanges?.Invoke(Theme); } else { ExtendedControls.MessageBoxTheme.Show(this, "Font does not have regular style"); } } } }
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); } } //обновление пол¤ this.Text += " "; this.Select(this.Text.Length, 0); } Invalidate(); }
private void 字体_Click(object sender, EventArgs e) { // 创建字体对话框 FontDialog dlgFont = new FontDialog(); dlgFont.ShowColor = true; dlgFont.ShowApply = true; // 设置字体对框的默认字体, // 如果已经有选择文本,则设置为选择文本的字体和颜色 // 否则设置为全文的字体和姿色 if (rtbEditor.SelectionLength > 0) { dlgFont.Font = rtbEditor.SelectionFont; dlgFont.Color = rtbEditor.SelectionColor; } else { dlgFont.Font = rtbEditor.Font; dlgFont.Color = rtbEditor.ForeColor; } // 显示字体对话框,且用户按下了 “确认 ”按钮 if (dlgFont.ShowDialog() == DialogResult.OK) { // 如果有选择文件,刚修改选择文本的字体和颜色 if (rtbEditor.SelectionLength > 0) { rtbEditor.SelectionFont = dlgFont.Font; rtbEditor.SelectionColor = dlgFont.Color; } // 否则修改整个文本的字体和颜色 else { rtbEditor.Font = dlgFont.Font; rtbEditor.ForeColor = dlgFont.Color; } } }
public static Font SelectFont(Font currentFont) { using (FontDialog fd = new FontDialog()) { fd.Font = currentFont; fd.ShowApply = false; fd.ShowColor = false; fd.ShowEffects = false; fd.ShowHelp = false; if (fd.ShowDialog() == DialogResult.OK) { Font font = fd.Font; Size sizeM = TextRenderer.MeasureText("M", font); Size sizeDot = TextRenderer.MeasureText(".", font); if (sizeM != sizeDot) { if (MessageBox.Show("The font you've selected (" + fd.Font.FontFamily.Name.ToString() + ") doesn't appear to be a monospace font. Using anything other than a monospace font will cause display issues in the UI. Are you sure you want to use this font?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { return(fd.Font); } else { return(currentFont); } } else { return(fd.Font); } } else { return(currentFont); } } }
bool size_flag = true; //快捷工具栏-字体大小选中内容发生变化事件响应 private void 字体ToolStripMenuItem_Click(object sender, EventArgs e) { //新建字体对话框并初始化 FontDialog fd = new FontDialog(); fd.Font = rh.SelectionFont; fd.Color = rh.SelectionColor; fd.ShowColor = true; //打开字体对话框并进行设置 if (fd.ShowDialog() == DialogResult.OK) { rh.SelectionColor = fd.Color; rh.SelectionFont = fd.Font; } //处理快捷工具栏的字体信息同步设置 font_flag = false; size_flag = false; ts_color.BackColor = fd.Color; tcb_font.Text = fd.Font.FontFamily.Name; //tcb_fontsize.Text = fd.Font.Size.ToString(); int k = Array.IndexOf(v, fd.Font.Size); if (k > -1)//找到了 { tcb_fontsize.Text = d[k]; } else//没找到 { tcb_fontsize.Text = fd.Font.Size.ToString(); } ts_fontbold.Checked = fd.Font.Bold; ts_fontitalics.Checked = fd.Font.Italic; ts_fontunderline.Checked = fd.Font.Underline; font_flag = size_flag = true; }
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; }
/// <summary> /// Edits the value /// </summary> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { this.value = value; if (provider != null) { var service1 = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (service1 != null) { 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; var 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); }
Control PickFontWithStartingFont() { var button = new Button { Text = "Pick Font with initial starting font" }; button.Click += delegate { var dialog = new FontDialog { Font = selectedFont }; dialog.FontChanged += delegate { // need to handle this event for OS X, where the dialog is a floating window UpdatePreview(dialog.Font); Log.Write(dialog, "FontChanged, Font: {0}", dialog.Font); }; var result = dialog.ShowDialog(ParentWindow); // do not get the font here, it may return immediately with a result of DialogResult.None on certain platforms Log.Write(dialog, "Result: {0}", result); }; return(button); }
private void FontMenu_Click(object sender, RoutedEventArgs e) { var font = new FontDialog { AllowVerticalFonts = false, ShowColor = true, }; if (font.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var clr = new Color { A = font.Color.A, R = font.Color.R, G = font.Color.G, B = font.Color.B }; KeyBlock.FontFamily = NpsBlock.FontFamily = new FontFamily(font.Font.Name); KeyBlock.FontStyle = NpsBlock.FontStyle = font.Font.Italic ? FontStyles.Italic : FontStyles.Normal; KeyBlock.TextDecorations = NpsBlock.TextDecorations = font.Font.Underline ? TextDecorations.Underline : null; KeyBlock.Foreground = NpsBlock.Foreground = new SolidColorBrush(clr); } }
private void fontMenuItem_Click(object sender, EventArgs e) { FontDialog f = new FontDialog { Font = mLogBox.Font }; if (f.ShowDialog() != DialogResult.OK) { return; } bool saveConfig = false; JObject loCfg = Configuration.GetConfigFile(); if (loCfg["logFont"] == null) { loCfg["logFont"] = new JObject(); saveConfig = true; } if (loCfg["logFont"]["family"] == null || !loCfg["logFont"]["family"].ToString().Equals(f.Font.FontFamily.Name)) { loCfg["logFont"]["family"] = f.Font.FontFamily.Name; saveConfig = true; } if (loCfg["logFont"]["size"] == null || Math.Abs((float)loCfg["logFont"]["size"] - f.Font.Size) > 0) { loCfg["logFont"]["size"] = f.Font.Size; saveConfig = true; } if (saveConfig) { Configuration.SaveConfigFile(loCfg); } mLogBox.Font = new Font(f.Font.FontFamily, f.Font.Size, f.Font.Style); }
private void btnCellColor_Click(object sender, EventArgs e) { FontDialog fontDialog = new FontDialog(); FontConverter fontConverter = new FontConverter(); ColorConverter colorCovert = new ColorConverter(); fontDialog.ShowEffects = true; fontDialog.ShowColor = true; if (lblCellSample.Text != "") { fontDialog.Font = fontConverter.ConvertFromString(lblCellSample.Text) as Font; fontDialog.Color = lblCellSample.ForeColor; } if (DialogResult.OK == fontDialog.ShowDialog()) { txtCellFont.Text = fontConverter.ConvertToString(fontDialog.Font); txtCellFontColor.Text = colorCovert.ConvertToString(fontDialog.Color); lblCellSample.Font = fontDialog.Font; lblCellSample.ForeColor = fontDialog.Color; } }
private void 字型ZToolStripMenuItem_Click(object sender, EventArgs e) { FontDialog fontDialog = new FontDialog(); FontDialog fontDialog_save = new FontDialog(); fontDialog.ShowColor = true; fontDialog.ShowApply = true; try { fontDialog.Font = fontDialog_save.Font; fontDialog.Color = fontDialog_save.Color; } catch (Exception) { throw; } if (fontDialog.ShowDialog() == DialogResult.OK) { flowLayoutPanel1.Font = fontDialog.Font; flowLayoutPanel1.ForeColor = fontDialog.Color; } fontDialog_save.Font = fontDialog.Font; fontDialog_save.Color = fontDialog.Color; }
private void fontToolStripMenuItem_Click(object sender, EventArgs e) { FontDialog fd = new FontDialog(); fd.FixedPitchOnly = false; fd.FontMustExist = true; fd.ShowColor = false; fd.ShowHelp = false; fd.ShowEffects = false; fd.ShowApply = true; if (this.ActiveDocument != null) { fd.Font = ConfigurationManager.Font ?? this.ActiveDocument.Scintilla.Styles[0].Font; } fd.Apply += new EventHandler(fontDialog_Apply); if (fd.ShowDialog(this) == DialogResult.OK) { ConfigurationManager.Font = fd.Font; SetFont(fd.Font); } }
private void browseFont_Click(object sender, EventArgs e) { var dlg = new FontDialog(); dlg.ScriptsOnly = true; dlg.FixedPitchOnly = !showVariableFontsAsWell.Checked; dlg.FontMustExist = true; dlg.Font = app.inst.font; dlg.ShowEffects = false; if (dlg.ShowDialog() == DialogResult.OK) { var font = dlg.Font; int new_font_size = (int)Math.Round(font.Size); bool any_change = app.inst.font_name != font.Name || app.inst.font_size != new_font_size; app.inst.font_name = font.Name; app.inst.font_size = new_font_size; if (any_change) { app.inst.save(); needs_restart_ = true; DialogResult = DialogResult.OK; } } }
// Handle font menu protected void Font_Click(Object sender, EventArgs e) { FontDialog f = new FontDialog(); if(f.ShowDialog() == DialogResult.OK) text.Font = f.Font; }
private void ChangeFont_Click(object sender, EventArgs e) { FontDialog dialog = new FontDialog(); dialog.Font = menuBar.Font; if (dialog.ShowDialog() == DialogResult.OK) { menuBar.Font = dialog.Font; toolBar.Font = dialog.Font; } }
public void SetFont() { FontDialog dlgFont=new FontDialog(); dlgFont.Font=txtCPad.Font; dlgFont.ShowColor=true; dlgFont.Color=txtCPad.ForeColor; if(dlgFont.ShowDialog()==DialogResult.OK) { txtCPad.Font=dlgFont.Font; txtCPad.ForeColor=dlgFont.Color; } }