Exemplo n.º 1
0
        private SimpleToggle InitToolbarInsertToggle(ref int x, int y, string t,
			Image bImg, EventHandler eh)
        {
            SimpleToggle ctl = new SimpleToggle();
            ctl.UpColor = this.BackColor;
            ctl.Click += eh;	// click handler for all inserts

            if (bImg == null)
            {
                ctl.Text = t;
                using ( Graphics g = ctl.CreateGraphics() )
                {
                    SizeF fs = g.MeasureString( ctl.Text, ctl.Font);
                    ctl.Height = (int) fs.Height + 8;	// 8 is for margins
                    ctl.Width = (int) fs.Width + 12;
                }
            }
            else
            {
                ctl.Image = bImg;
                ctl.ImageAlign = ContentAlignment.MiddleCenter;
                ctl.Height = bImg.Height + 5;
                ctl.Width = bImg.Width + 8;
                ctl.Text = "";
            }

            ctl.Tag = t;
            ctl.Left = x;
            ctl.Top = y;
            ctl.FlatStyle = FlatStyle.Flat;
            ToolTip tipb = new ToolTip();
            tipb.AutomaticDelay = 500;
            tipb.ShowAlways = true;
            tipb.SetToolTip(ctl, t);
            mainTB.Controls.Add(ctl);

            x = x+ ctl.Width;

            return ctl;
        }
Exemplo n.º 2
0
        private int InitToolbarUnderline(int x, int y)
        {
            ctlUnderline = new SimpleToggle();
            ctlUnderline.UpColor = this.BackColor;
            ctlUnderline.Click +=new EventHandler(ctlUnderline_Click);
            ctlUnderline.Font = new Font("Courier New", 10, FontStyle.Underline | FontStyle.Bold);
            ctlUnderline.Text = "U";
            using ( Graphics g = ctlUnderline.CreateGraphics() )
            {
                SizeF fs = g.MeasureString( ctlUnderline.Text, ctlUnderline.Font );
                ctlUnderline.Height = (int) fs.Height + 6;	// 6 is for margins
                ctlUnderline.Width = ctlUnderline.Height;
            }

            ctlUnderline.Tag = "italic";
            ctlUnderline.Left = x;
            ctlUnderline.Top = y;
            ctlUnderline.FlatStyle = FlatStyle.Flat;
            ToolTip tipb = new ToolTip();
            tipb.AutomaticDelay = 500;
            tipb.ShowAlways = true;
            tipb.SetToolTip(ctlUnderline, "Underline");
            mainTB.Controls.Add(ctlUnderline);

            return ctlUnderline.Width;
        }
Exemplo n.º 3
0
        private int InitToolbarBold(int x, int y)
        {
            ctlBold = new SimpleToggle();
            ctlBold.UpColor = this.BackColor;

            ctlBold.Click +=new EventHandler(ctlBold_Click);

            ctlBold.Font = new Font("Courier New", 10, FontStyle.Bold);
            ctlBold.Text = "B";
            using ( Graphics g = ctlBold.CreateGraphics() )
            {
                SizeF fs = g.MeasureString( ctlBold.Text, ctlBold.Font );
                ctlBold.Height = (int) fs.Height + 6;	// 6 is for margins
                ctlBold.Width = ctlBold.Height;
            }

            ctlBold.Tag = "bold";
            ctlBold.Left = x;
            ctlBold.Top = y;
            ctlBold.FlatStyle = FlatStyle.Flat;
            ctlBold.TextAlign = ContentAlignment.MiddleCenter;

            ToolTip tipb = new ToolTip();
            tipb.AutomaticDelay = 500;
            tipb.ShowAlways = true;
            tipb.SetToolTip(ctlBold, "Bold");
            mainTB.Controls.Add(ctlBold);

            return ctlBold.Width;
        }