Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        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;
            }
        }