예제 #1
0
        /// <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;
        }
예제 #2
0
 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;
 }
예제 #3
0
파일: FontEditor.cs 프로젝트: d3x0r/xperdex
        private void EditFont_Click(object sender, EventArgs e)
        {
            font_tracker f = (font_tracker)this.FontList.SelectedItem;

            //pickedFont = null;
            System.Windows.Forms.FontDialog fd = new System.Windows.Forms.FontDialog();
            fd.Font = f.f;

            DialogResult result = fd.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                f.f      = fd.Font;
                f.family = fd.Font.FontFamily.Name;
                f.size   = fd.Font.Size;
                f.style  = fd.Font.Style;
                f.unit   = fd.Font.Unit;
                f.InvokeChanged();
                foreach (Control c in f.Controls)
                {
                    c.Font = f.f;
                }
            }
            fd.Dispose();
        }
예제 #4
0
        private void button_font_Click(object sender, EventArgs e)
        {
            //FontDialogクラスのインスタンスを作成
            FontDialog fd = new FontDialog();

            //初期のフォントを設定
            fd.Font = text.Font;
            //初期の色を設定
            fd.Color = text.ForeColor;
            //ユーザーが選択できるポイントサイズの最大値を設定する
            fd.MaxSize = 999;
            fd.MinSize = 2;
            //存在しないフォントやスタイルをユーザーが選択すると
            //エラーメッセージを表示する
            fd.FontMustExist = true;
            //横書きフォントだけを表示する
            fd.AllowVerticalFonts = false;
            //色を選択できるようにする
            fd.ShowColor = true;
            //取り消し線、下線、テキストの色などのオプションを指定可能にする
            //デフォルトがTrueのため必要はない
            fd.ShowEffects = true;
            //固定ピッチフォント以外も表示する
            //デフォルトがFalseのため必要はない
            fd.FixedPitchOnly = false;
            //ベクタ フォントを選択できるようにする
            //デフォルトがTrueのため必要はない
            fd.AllowVectorFonts = true;

            //ダイアログを表示する
            if (fd.ShowDialog() != DialogResult.Cancel)
            {
                //TextBox1のフォントと色を変える
                text.Font = fd.Font;
                text.ForeColor = fd.Color;
            }
            set_jimaku();
            fd.Dispose();
        }
예제 #5
0
 private void btn_FontSelect_Click(object sender, EventArgs e)
 {
     FontDialog fontdialog = new FontDialog();
     fontdialog.ShowColor = true;
     fontdialog.FontMustExist = true;
     fontdialog.Font = rtb_thread_main.Font;
     fontdialog.Color = rtb_thread_main.ForeColor;
     if (fontdialog.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
     {
         rtb_thread_main.Font = fontdialog.Font;
         rtb_thread_main.ForeColor = fontdialog.Color;
         if (!setFontDontSave)
         {
             FontSet.SaveUserFontStrig(fontdialog.Font.Name, fontdialog.Font.Size, FontSet.FontStyleString(fontdialog.Font), fontdialog.Color.Name);
         }
     }
     fontdialog.Dispose();
 }
예제 #6
0
        private void bFont_Click(object sender, System.EventArgs e)
        {
            FontDialog fd = new FontDialog();
            fd.ShowColor = true;

            // STYLE
            System.Drawing.FontStyle fs = 0;
            if (cbFontStyle.Text == "Italic")
                fs |= System.Drawing.FontStyle.Italic;

            if (cbTextDecoration.Text == "Underline")
                fs |= FontStyle.Underline;
            else if (cbTextDecoration.Text == "LineThrough")
                fs |= FontStyle.Strikeout;

            // WEIGHT
            switch (cbFontWeight.Text)
            {
                case "Bold":
                case "Bolder":
                case "500":
                case "600":
                case "700":
                case "800":
                case "900":
                    fs |= System.Drawing.FontStyle.Bold;
                    break;
                default:
                    break;
            }
            float size=10;
            size = DesignXmlDraw.GetSize(cbFontSize.Text);
            if (size <= 0)
            {
                size = DesignXmlDraw.GetSize(cbFontSize.Text+"pt");	// Try assuming pt
                if (size <= 0)	// still no good
                    size = 10;	// just set default value
            }
            Font drawFont = new Font(cbFontFamily.Text, size, fs);	// si.FontSize already in points

            fd.Font = drawFont;
            fd.Color =
                DesignerUtility.ColorFromHtml(cbColor.Text, System.Drawing.Color.Black);
            try
            {
                DialogResult dr = fd.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    drawFont.Dispose();
                    return;
                }

                // Apply all the font info
                cbFontWeight.Text = fd.Font.Bold ? "Bold" : "Normal";
                cbFontStyle.Text = fd.Font.Italic ? "Italic" : "Normal";
                cbFontFamily.Text = fd.Font.FontFamily.Name;
                cbFontSize.Text = fd.Font.Size.ToString() + "pt";
                cbColor.Text = ColorTranslator.ToHtml(fd.Color);
                if (fd.Font.Underline)
                    this.cbTextDecoration.Text = "Underline";
                else if (fd.Font.Strikeout)
                    this.cbTextDecoration.Text = "LineThrough";
                else
                    this.cbTextDecoration.Text = "None";
                drawFont.Dispose();
            }
            finally
            {
                fd.Dispose();
            }
            return;
        }
예제 #7
0
        /*
          Открывает диалоговое окно "Форматировани шрифта"
        */
        private DialogResult FontFormattingDialog()
        {
            FontDialog fontDialog = new FontDialog();
            fontDialog.AllowScriptChange = true;
            fontDialog.AllowSimulations = true;
            fontDialog.AllowVectorFonts = true;
            fontDialog.AllowVerticalFonts = true;
            fontDialog.FontMustExist = true;
            fontDialog.ShowEffects = true;
            fontDialog.ShowColor = true;

            if(!String.IsNullOrEmpty(this.richTextBox.SelectedRtf))
            {
                fontDialog.Font = this.richTextBox.SelectionFont;
                fontDialog.Color = this.richTextBox.SelectionColor;
            }
            else
            {
                fontDialog.Font = this.richTextBox.Font;
                fontDialog.Color = this.richTextBox.SelectionColor;
            }

            DialogResult dialogResult;
            dialogResult = fontDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                this.richTextBox.SelectionFont = fontDialog.Font;
                this.richTextBox.SelectionColor = fontDialog.Color;
            }

            fontDialog.Dispose();

            return dialogResult;
        }
        /// <summary>
        /// Invokes the action.
        /// </summary>
        /// <param name="parameter">The parameter to the action; but not used.</param>
        protected override void Invoke(object parameter)
        {
            WinForms.FontDialog dialog = null;

            try
            {
                dialog = new WinForms.FontDialog();

                dialog.AllowScriptChange  = this.AllowScriptChange;
                dialog.AllowSimulations   = this.AllowSimulations;
                dialog.AllowVectorFonts   = this.AllowVectorFonts;
                dialog.AllowVerticalFonts = this.AllowVerticalFonts;
                dialog.Color          = this.Color;
                dialog.FixedPitchOnly = this.FixedPitchOnly;
                dialog.Font           = this.Font;
                dialog.FontMustExist  = this.FontMustExist;
                dialog.MaxSize        = this.MaxSize;
                dialog.MinSize        = this.MinSize;
                dialog.ScriptsOnly    = this.ScriptsOnly;
                dialog.ShowApply      = this.ShowApply;
                dialog.ShowColor      = this.ShowColor;
                dialog.ShowEffects    = this.ShowEffects;
                dialog.ShowHelp       = this.ShowHelp;
                dialog.Site           = this.Site;
                dialog.Tag            = this.Tag;

                if (this.ShowApply && (this.ApplyCommand != null))
                {
                    dialog.Apply += (sender, e) =>
                    {
                        var result = new FontDialogActionResult(dialog.Font, dialog.Color);
                        if (this.ApplyCommand.CanExecute(result))
                        {
                            this.ApplyCommand.Execute(result);
                        }
                    };
                }

                var oldFont      = dialog.Font;
                var oldColor     = dialog.Color;
                var dialogResult = dialog.ShowDialog(new Win32Window(this.Owner));

                switch (dialogResult)
                {
                case WinForms.DialogResult.OK:
                    if (this.OkCommand != null)
                    {
                        var result = new FontDialogActionResult(dialog.Font, dialog.Color);
                        if (this.OkCommand.CanExecute(result))
                        {
                            this.OkCommand.Execute(result);
                        }
                    }

                    break;

                case WinForms.DialogResult.Cancel:
                    if (this.CancelCommand != null)
                    {
                        var result = new FontDialogActionResult(oldFont, oldColor);
                        if (this.CancelCommand.CanExecute(result))
                        {
                            this.CancelCommand.Execute(result);
                        }
                    }

                    break;

                default:
                    throw new NotImplementedException("Should not reach here.");
                }
            }
            finally
            {
                dialog.Dispose();
            }
        }
예제 #9
0
파일: Form1.cs 프로젝트: alannet/example
        private void button1_Click(object sender, System.EventArgs e)
        {
            // Font Dialog
            FontDialog aFontDialog = new FontDialog();
            aFontDialog.ShowColor = true;
            aFontDialog.ShowEffects = true;
            aFontDialog.MinSize = 1;
            aFontDialog.MaxSize = 35;
            aFontDialog.Font = this.Font;
            if (aFontDialog.ShowDialog() == DialogResult.OK)
            {
                this.Font = aFontDialog.Font;
            }

            aFontDialog.Dispose ();

            //	Color Dialog
            /*

            ColorDialog aClrDialog = new ColorDialog();
            aClrDialog.AllowFullOpen = false;
            aClrDialog.Color = this.BackColor;
            if (aClrDialog.ShowDialog() == DialogResult.OK)
            {
                this.BackColor = aClrDialog.Color;
            }

            aClrDialog.Dispose();
            */

            // File Dialog

            /*
            OpenFileDialog aOpenFileDialog = new OpenFileDialog();
            aOpenFileDialog.Filter = "Text Files (*.txt)|*.txt|Word Documents" +
                "(*.doc)|*.doc|All Files (*.*)|*.*";
            aOpenFileDialog.ShowReadOnly = true;
            aOpenFileDialog.Multiselect = true;
            aOpenFileDialog.Title = "Open files for custom application";
            if (aOpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.txtSSN.Text = aOpenFileDialog.FileName;
                //Do something useful with aOpenFileDialog.FileName
                //or aOpenFileDialog.FileNames
            }

            aOpenFileDialog.Dispose();
            */
        }
예제 #10
0
        private void menuFont_Click(object sender, EventArgs e)
        {
            FontDialog dialog = new FontDialog();
            dialog.Font = _fntCurrent;

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                _fntCurrent = dialog.Font;
                ArrangeWindow();
            }

            dialog.Dispose();
        }
예제 #11
0
        private void Pixiv_Button_Font_Click(object sender, EventArgs e)
        {
            // ダイアログを表示 //
            FontDialog fd = new FontDialog();

            fd.Font = nicoVideoFont;
            fd.MinSize = 5;
            fd.ShowEffects = false;

            if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                nicoVideoFont = fd.Font;
            }

            fd.Dispose();
        }
예제 #12
0
 private void button1_Click(object sender, EventArgs e)
 {
     FontDialog fd = new FontDialog();
     fd.FontMustExist = true;
     fd.Font = fontname.Font;
     if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         Interactivity.codes.codeTextBox.Font = fd.Font;
         fontname.Tag = fd.Font;
         fontname.Text = fd.Font.ToString();
         fontname.Font = new Font(fd.Font.FontFamily, 8.5F, fd.Font.Style);
         Properties.Settings.Default.EditorFont = fd.Font;
     }
     fd.Dispose();
 }
예제 #13
0
 private void ChangeFonts()
 {
     if (model == null){
         return;
     }
     FontDialog fontDialog = new FontDialog{ShowColor = true, Font = textFont, Color = textColor};
     if (fontDialog.ShowDialog() != DialogResult.Cancel){
         textFont = fontDialog.Font;
         textColor = fontDialog.Color;
         textBrush = new SolidBrush(textColor);
     }
     fontDialog.Dispose();
     Invalidate(true);
 }