コード例 #1
0
        public void Render(Graphics g, Point offset)
        {
            Rectangle bounds = base.Bounds;

            bounds.X += offset.X;
            bounds.Y += offset.Y;
            using (Brush brush = new SolidBrush(this.ForeColor))
            {
                using (Brush brush2 = new SolidBrush(this.BackColor))
                {
                    Rectangle rc = bounds;
                    ExtendDraw.FillRoundedRectangle(g, brush, rc, base.m_scale * 5, 3);
                    rc.Inflate(-base.m_scale, -base.m_scale);
                    ExtendDraw.FillRoundedRectangle(g, brush2, rc, base.m_scale * 5, 3);
                }
                Region clip = g.Clip;
                bounds    = this.GetTextBounds(g);
                bounds.X += offset.X;
                bounds.Y += offset.Y;
                g.Clip    = new Region(bounds);
                StringFormat format = new StringFormat();
                if (!this.m_bMultiLine)
                {
                    SizeF ef = g.MeasureString(this.Text, base.Font);
                    if (bounds.Width <= ef.Width)
                    {
                        bounds.Width = (int)ef.Width;
                    }
                    format.LineAlignment = StringAlignment.Center;
                }
                format.Alignment = StringAlignment.Center;
                g.DrawString(this.Text, base.Font, brush, bounds, format);
                g.Clip = clip;
            }
        }
コード例 #2
0
ファイル: MenuElement.cs プロジェクト: windygu/haina
 public void Render(Graphics g, Point offset)
 {
     using (Brush brush = new SolidBrush(this.BackColor))
     {
         using (Brush brush2 = new SolidBrush(this.ForeColor))
         {
             Rectangle bounds = base.Bounds;
             bounds.X     += offset.X;
             bounds.Y     += offset.Y;
             bounds.Height = this.m_itemHeight;
             int num  = 0;
             int num2 = this.m_items.Length - 1;
             foreach (Resco.Controls.MessageBox.MenuItem item in this.m_items)
             {
                 bool flag = num == this.m_selected;
                 if (num == num2)
                 {
                     ExtendDraw.FillRoundedRectangle(g, flag ? brush2 : brush, bounds, base.m_scale * 5, 12);
                 }
                 else
                 {
                     g.FillRectangle(flag ? brush2 : brush, bounds);
                 }
                 if (item.Image != null)
                 {
                     int num3 = (bounds.Height - item.Image.Height) / 2;
                     ExtendDraw.DrawImage(g, item.Image, num3 + bounds.Left, num3 + bounds.Top, item.Image.GetPixel(0, 0));
                 }
                 StringFormat format = new StringFormat();
                 format.Alignment     = StringAlignment.Center;
                 format.LineAlignment = StringAlignment.Center;
                 g.DrawString(item.Text, base.Font, flag ? brush : brush2, bounds, format);
                 if (!item.Enabled)
                 {
                     Rectangle rect = bounds;
                     rect.Inflate(-2 * base.m_scale, -2 * base.m_scale);
                     ExtendDraw.BlendRect(g, rect, Color.FromArgb(-2130706433));
                 }
                 if (num > 0)
                 {
                     using (Pen pen = new Pen(this.LineColor))
                     {
                         g.DrawLine(pen, bounds.X, bounds.Y, bounds.Right - 1, bounds.Y);
                     }
                 }
                 num++;
                 bounds.Y += this.m_itemHeight;
             }
         }
     }
 }
コード例 #3
0
        private Rectangle GetTextBounds(Graphics g)
        {
            Rectangle bounds = base.Bounds;

            bounds.Inflate(-20 * base.m_scale, 0);
            if (this.m_bMultiLine)
            {
                int height = ExtendDraw.MeasureString(g, this.Text, base.Font, bounds.Width).Height;
                if (height < bounds.Height)
                {
                    bounds.Y     += (bounds.Height - height) / 2;
                    bounds.Height = height;
                }
            }
            return(bounds);
        }
コード例 #4
0
 public override void OnResize()
 {
     if (this.m_bMultiLine)
     {
         using (Graphics graphics = base.m_parent.CreateGraphics())
         {
             int num = ExtendDraw.MeasureString(graphics, this.Text, base.Font, base.Width - (40 * base.m_scale)).Height + (0x36 * base.m_scale);
             if (num > (100 * base.m_scale))
             {
                 num = 100 * base.m_scale;
             }
             base.Height = num;
             return;
         }
     }
     base.Height = 0x1b * base.m_scale;
 }
コード例 #5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics  g = e.Graphics;
            Rectangle c = this.CalcClientRect();

            if (this.m_bFirstPaint)
            {
                int b = 2 * ((int)(g.DpiY / 96f));
                List <Rectangle> r = new List <Rectangle>();
                r.Add(base.Bounds);
                this.GetRects(r, c, b);
                Color[] colors = new Color[] { Color.FromArgb(-1610612736), Color.FromArgb(0x50000000), Color.FromArgb(0x50000000), Color.FromArgb(0x50000000), Color.FromArgb(0x50000000), Color.FromArgb(0x50000000), Color.FromArgb(0x50000000), Color.FromArgb(0x50000000), Color.FromArgb(0x50000000) };
                ExtendDraw.BlendRects(g, base.Bounds, r.ToArray(), colors);
                this.m_bFirstPaint = false;
            }
            else
            {
                using (SolidBrush brush = new SolidBrush(Color.Black))
                {
                    g.FillRectangle(brush, base.Bounds);
                }
            }
            int width  = c.Width;
            int height = c.Height;

            using (Bitmap bitmap = new Bitmap(width, height))
            {
                using (Graphics graphics2 = Graphics.FromImage(bitmap))
                {
                    int x = c.X;
                    int y = c.Y;
                    ExtendDraw.BitBlt(graphics2, new Rectangle(0, 0, width, height), g, x, y);
                    Point offset = new Point(-x, -y);
                    this.Render(graphics2, offset);
                    ExtendDraw.BitBlt(g, new Rectangle(x, y, width, height), graphics2, 0, 0);
                }
            }
        }