Exemple #1
0
        private void toolStrip_Font_Click(object sender, EventArgs e)
        {
            customRtb.TextChanged -= new EventHandler(customRtb_TextChanged);

            //-----FontForm-----//
            FontForm fontForm = new FontForm(customRtb.Font.FontFamily, customRtb.Font.Size, customRtb.Font.Style)
            {
                Owner    = this,
                Location = new Point(Location.X + 250, Location.Y + 50),
            };

            fontForm.ShowDialog();
            //-----//

            //-----FontDialog-----//
            //bool nonSelection = customRtb.SelectedText == "";
            //fontDialog1.Font = nonSelection ? customRtb.Font : customRtb.SelectionFont;

            //if (fontDialog1.ShowDialog() == DialogResult.Cancel)
            //    return;

            //if (nonSelection)
            //    customRtb.Font = new Font(fontDialog1.Font.FontFamily, fontDialog1.Font.Size, fontDialog1.Font.Style);
            //else
            //    customRtb.SelectionFont = new Font(fontDialog1.Font.FontFamily, fontDialog1.Font.Size, fontDialog1.Font.Style);
            //-----//

            customRtb.TextChanged += new EventHandler(customRtb_TextChanged);
        }
Exemple #2
0
        public MainForm()
        {
            InitializeComponent();
            CommonFunction.RegisterMarkTargetDelegate(MarkTargetLine);
            ReplaceForm.RegisterReplaceTargetDelegate(ReplaceTarget);
            GoToForm.RegisterGoToLineDelegate(GoToLine);
            EncryptForm.RegisterEncryptDelegate(EncryptText);
            FontForm.RegisterFontDelegate(ChangeFont);
            ColorForm.RegisterColorDelegate(ChangeColor);

            ContextMenuStrip cms = new ContextMenuStrip();

            ToolStripMenuItem undo = new ToolStripMenuItem("Undo");

            undo.Name   = undo.Text;
            undo.Click += new EventHandler(toolStrip_Undo_Click);
            cms.Items.Add(undo);
            ToolStripMenuItem redo = new ToolStripMenuItem("Redo");

            redo.Name   = redo.Text;
            redo.Click += new EventHandler(toolStrip_Redo_Click);
            cms.Items.Add(redo);
            cms.Items.Add(new ToolStripSeparator());

            ToolStripMenuItem cut = new ToolStripMenuItem("Cut");

            cut.Name   = cut.Text;
            cut.Click += new EventHandler(toolStrip_Cut_Click);
            cms.Items.Add(cut);
            ToolStripMenuItem copy = new ToolStripMenuItem("Copy");

            copy.Name   = copy.Text;
            copy.Click += new EventHandler(toolStrip_Copy_Click);
            cms.Items.Add(copy);
            ToolStripMenuItem paste = new ToolStripMenuItem("Paste");

            paste.Name   = paste.Text;
            paste.Click += new EventHandler(toolStrip_Paste_Click);
            cms.Items.Add(paste);
            cms.Items.Add(new ToolStripSeparator());

            ToolStripMenuItem selectAll = new ToolStripMenuItem("Select All");

            selectAll.Name   = selectAll.Text;
            selectAll.Click += new EventHandler(toolStrip_SelectAll_Click);
            cms.Items.Add(selectAll);

            cms.Opening += new CancelEventHandler(ContextMenuStrip_Opening);
            customRtb.ContextMenuStrip = cms;
        }
        private void formatToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Form FontDialog = new FontForm();

            FontDialog.ShowDialog();
            if (FontDialog.DialogResult == DialogResult.OK)
            {
                string[] data = FontDialog.Text.Split(',');
                if (data.Length != 3)
                {
                    throw new Exception("Error in response data!");
                }

                string fontName  = data[0];
                string fontStyle = data[1];
                string fontSize  = data[2];

                FontStyle fontEnum;
                bool      fontSty = Enum.TryParse(fontStyle, out fontEnum);

                Font f = new Font(new FontFamily(fontName), float.Parse(fontSize), fontEnum);
                txtMain.Font = f;
            }
        }