void EDSToolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            if (e.ToolTipText.Trim() != "")
            {
                //e.DrawBackground();
                Graphics g = e.Graphics;

                //draw background
                LinearGradientBrush lgb = new LinearGradientBrush(new Rectangle(Point.Empty, e.Bounds.Size), Color.FromArgb(250, 252, 253), Color.FromArgb(206, 220, 240), LinearGradientMode.Vertical);
                g.FillRectangle(lgb, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
                lgb.Dispose();

                //Console.WriteLine(e.ToolTipText);

                //draw border
                ControlPaint.DrawBorder(g, e.Bounds, SystemColors.GrayText, ButtonBorderStyle.Dashed);
                //draw Image
                g.DrawImage(image, new Point(5, 5));

                // Draw the custom text.
                // The using block will dispose the StringFormat automatically.
                using (StringFormat sf = new StringFormat())
                {
                    using (Font f = new Font("Tahoma", 8))
                    {
                        e.Graphics.DrawString(e.ToolTipText, f,
                            Brushes.Black, e.Bounds.X + 25, e.Bounds.Y + 30, StringFormat.GenericTypographic);
                    }
                }
            }
        }
示例#2
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);

            if (m_clrColors.Count > 1)
            {
                float      percentage = Convert.ToSingle(ClientRectangle.Width - 2) * (1.0f / Convert.ToSingle(m_clrColors.Count - 1));
                Brush      b;
                RectangleF rectF;
                Color      c1;
                Color      c2;

                rectF = new RectangleF(new PointF(0.0f, 1.0f), new SizeF(percentage, ClientRectangle.Height - 2));
                for (int i = 0; i < m_clrColors.Count - 1; i++)
                {
                    c1 = Color.FromArgb(m_nTransparency, m_clrColors[i]);
                    c2 = Color.FromArgb(m_nTransparency, m_clrColors[i + 1]);

                    b = new System.Drawing.Drawing2D.LinearGradientBrush(rectF, c1, c2, m_fAngle);
                    pe.Graphics.FillRectangle(b, rectF);
                    rectF.Offset(percentage, 0);
                    b.Dispose();
                }
            }
        }
示例#3
0
 /// <summary>
 /// Paints the background in the gradient brush
 /// </summary>
 /// <param name="e"></param>
 protected override void OnPaintBackground(PaintEventArgs pevent)
 {
     LinearGradientBrush brush = 
         new LinearGradientBrush(pevent.ClipRectangle, _startColor, _endColor,  _gradientMode);
     pevent.Graphics.FillRectangle(brush, pevent.ClipRectangle);
     brush.Dispose();
 }
示例#4
0
        private void TimeViewer_Paint(object sender, PaintEventArgs e)
        {
            LinearGradientBrush b1 = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.LightGreen, Color.Green, LinearGradientMode.Vertical);
            e.Graphics.FillRectangle(b1, 0, 0, round * Width, 30);
            b1.Dispose();

            Font font = new Font("Arial", 20*1.33f, FontStyle.Regular, GraphicsUnit.Pixel);
            e.Graphics.DrawString(string.Format("{0:00}:{1:00}", time / 4, (time % 4) * 15), font, Brushes.White, 22, 0);
            font.Dispose();

            if(isShow)
            {
                string url = string.Format("d{0}.JPG", daytime);
                Image img = PicLoader.Read("Weather", url);
                e.Graphics.DrawImage(img, 6, 35, 30, 30);
                img.Dispose();
                url = string.Format("w{0}.JPG", weather);
                img = PicLoader.Read("Weather", url);
                e.Graphics.DrawImage(img, 41, 35, 30, 30);
                img.Dispose();
                url = string.Format("s{0}.JPG", special);
                img = PicLoader.Read("Weather", url);
                e.Graphics.DrawImage(img, 76, 35, 30, 30);
                img.Dispose();
            }
        }
示例#5
0
        protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs e)                        //all drawing is made here in OnPaintBackground...
        {
            base.OnPaintBackground(e);

            if (this.WindowState == FormWindowState.Minimized)
            {
                return;
            }


            Graphics g = e.Graphics;

            Rectangle rect = new Rectangle(this.pictureBox1.Location, this.pictureBox1.Size);


            System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(
                rect,
                Color.SteelBlue,
                Color.Black,
                System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal);


            if (this.WindowState != FormWindowState.Minimized)
            {
                e.Graphics.FillRectangle(brush, rect);

                Draw(g);                                                //All drawing is made here...
            }

            g = null;
            brush.Dispose();
        }
示例#6
0
        /// <summary>
        /// 设置选项卡头部颜色
        /// </summary>
        /// <param name="graph">The graph.</param>
        /// <param name="index">The index.</param>
        /// <param name="path">The path.</param>
        private void PaintTabBackground(System.Drawing.Graphics graph, int index, System.Drawing.Drawing2D.GraphicsPath path)
        {
            Rectangle rect = this.GetTabRect(index);

            if (rect.Width == 0 || rect.Height == 0)
            {
                return;
            }
            System.Drawing.Brush buttonBrush = new System.Drawing.Drawing2D.LinearGradientBrush(rect, _headerBackColor, _headerBackColor, LinearGradientMode.Vertical);  //非选中时候的 TabPage 页头部背景色
            //graph.FillPath(buttonBrush, path);
            //if (index == this.SelectedIndex)
            //{
            //    buttonBrush = new System.Drawing.SolidBrush(_headSelectedBackColor);
            //    graph.DrawLine(new Pen(_headerBackColor), rect.Right + 2, rect.Bottom, rect.Left + 1, rect.Bottom);
            //}
            buttonBrush.Dispose();
            if (index == this.SelectedIndex)
            {
                using (SolidBrush brush = new SolidBrush(_headSelectedBackColor))
                {
                    // rect.Inflate(1, 1);
                    //graph.FillRectangle(brush, rect);
                    graph.FillPath(brush, path);
                    graph.SmoothingMode = SmoothingMode.AntiAlias;//抗锯齿
                }
            }
            else
            {
            }
        }
示例#7
0
        //draw circular button function
        void DrawCircularButton(Graphics g)
        {
            Color c1 = Color.FromArgb(color1Transparent, color1);
            Color c2 = Color.FromArgb(color2Transparent, color2);


            Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, c1, c2, angle);

            g.FillEllipse(b, 5, 5, this.Width - 10, this.Height - 10);


            for (int i = 0; i < borderWidth; i++)
            {
                g.DrawArc(new Pen(new SolidBrush(buttonborder_1)), 5 + i, 5, this.Width - 10, this.Height - 10, 120, 180);
                g.DrawArc(new Pen(new SolidBrush(buttonborder_2)), 5, 5, this.Width - (10 + i), this.Height - 10, 300, 180);
            }



            if (showButtonText)
            {
                Point      p       = new Point(textX, textY);
                SolidBrush frcolor = new SolidBrush(this.ForeColor);
                g.DrawString(text, this.Font, frcolor, p);
            }

            b.Dispose();
        }
示例#8
0
        public static void DrawGlass(Rectangle rectangle, Graphics graphics)
        {
            if (rectangle.Width == 0 || rectangle.Height == 0)
                return;

            var clipPath = GetRoundedRectanglePath(rectangle);

            graphics.SetClip(clipPath);

            var glassRectangle = new Rectangle(rectangle.Location, new Size(rectangle.Width, rectangle.Height/2));

            // Apply a glass look
            Brush glassBrush = new LinearGradientBrush(glassRectangle, Color.Transparent,
                                                       Color.FromArgb(32, 255, 255, 255), 90.0f);

            var glassPath = GetRoundedRectanglePath(glassRectangle);

            graphics.FillPath(glassBrush, glassPath);

            glassPath.Dispose();
            glassBrush.Dispose();

            glassRectangle = new Rectangle(0, rectangle.Height - (rectangle.Height/4), rectangle.Width,
                                           rectangle.Height*3);
            glassPath = GetRoundedRectanglePath(glassRectangle);
            glassBrush = new SolidBrush(Color.FromArgb(16, Color.White));

            glassBrush.Dispose();
            glassPath.Dispose();

            graphics.SetClip(rectangle);
            clipPath.Dispose();
        }
        void RoundedRectanglePanel_SizeChanged(object sender, EventArgs e)
        {
            var bmp = new Bitmap(Bounds.Width, Bounds.Height);
            var g   = Graphics.FromImage(bmp);

            var bounds        = new Rectangle(0, 0, Bounds.Width, Bounds.Height);
            var cTopBorder    = Color.FromArgb(255, 221, 221, 221);
            var cBottomBorder = Color.FromArgb(255, 165, 165, 165);
            var cTop          = Color.FromArgb(255, 0xFA, 0xFA, 0xFA);
            var cBottom       = Color.FromArgb(255, 0xEB, 0xEB, 0xEB);
            var backBrush     = new System.Drawing.Drawing2D.LinearGradientBrush(bounds.Location, new Point(bounds.Left, bounds.Bottom), cTop, cBottom);
            var borderBrush   = new LinearGradientBrush(bounds.Location, new Point(bounds.Left, bounds.Bottom), cTopBorder, cBottomBorder);
            var pen           = new Pen(borderBrush);
            var graphicPath   = GetRoundedRect(new RectangleF(bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1), 3);

            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.FillPath(backBrush, graphicPath);
            g.DrawPath(pen, graphicPath);

            this.BackgroundImage = bmp;

            backBrush.Dispose();
            borderBrush.Dispose();
            pen.Dispose();
            graphicPath.Dispose();
            g.Dispose();
        }
示例#10
0
        //draw rectangular button function
        void DrawRectangularButton(Graphics g)
        {
            Color c1 = Color.FromArgb(color1Transparent, color1);
            Color c2 = Color.FromArgb(color2Transparent, color2);


            Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, c1, c2, angle);

            g.FillRectangle(b, 0, 0, this.Width, this.Height);


            for (int i = 0; i < borderWidth; i++)
            {
                g.DrawLine(new Pen(new SolidBrush(buttonborder_1)), this.Width - i, 0, this.Width - i, this.Height);
                g.DrawLine(new Pen(new SolidBrush(buttonborder_1)), 0, this.Height - i, this.Width, this.Height - i);

                g.DrawLine(new Pen(new SolidBrush(buttonborder_2)), 0 + i, 0, 0 + i, this.Height);
                g.DrawLine(new Pen(new SolidBrush(buttonborder_2)), 0, 0 + i, this.Width, i);
            }



            if (showButtonText)
            {
                Point      p       = new Point(textX, textY);
                SolidBrush frcolor = new SolidBrush(this.ForeColor);
                g.DrawString(text, this.Font, frcolor, p);
            }

            b.Dispose();
        }
示例#11
0
 /// <summary>
 /// TabContorl 背景色设置
 /// </summary>
 /// <param name="g">The g.</param>
 /// <param name="clipRect">The clip rect.</param>
 protected void PaintTransparentBackground(Graphics g, Rectangle clipRect)
 {
     if ((this.Parent != null))
     {
         clipRect.Offset(this.Location);
         PaintEventArgs e     = new PaintEventArgs(g, clipRect);
         GraphicsState  state = g.Save();
         g.SmoothingMode = SmoothingMode.HighSpeed;
         try
         {
             g.TranslateTransform((float)-this.Location.X, (float)-this.Location.Y);
             this.InvokePaintBackground(this.Parent, e);
             this.InvokePaint(this.Parent, e);
         }
         finally
         {
             g.Restore(state);
             clipRect.Offset(-this.Location.X, -this.Location.Y);
             //新加片段,待测试
             using (SolidBrush brush = new SolidBrush(_backColor))
             {
                 clipRect.Inflate(1, 1);
                 g.FillRectangle(brush, clipRect);
             }
         }
     }
     else
     {
         System.Drawing.Drawing2D.LinearGradientBrush backBrush = new System.Drawing.Drawing2D.LinearGradientBrush(this.Bounds, SystemColors.ControlLightLight, SystemColors.ControlLight, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
         g.FillRectangle(backBrush, this.Bounds);
         backBrush.Dispose();
     }
 }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics G = e.Graphics;
            LinearGradientBrush linearGradientBrush1 = new LinearGradientBrush(//创建线性渐变画刷
            new Point(0, 0),new Point(20, 20),                  //渐变起始点和终止点
            Color.Yellow,Color.Blue);                           //渐变起始颜色和终止颜色
            G.FillRectangle(linearGradientBrush1, new Rectangle(0, 0, 150, 150));//绘制矩形
            LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(//创建线性渐变画刷
            new Rectangle(0, 0, 20, 20),                      //渐变所在矩形
            Color.Yellow, Color.Blue, 60f);                     //渐变起始颜色、终止颜色以及渐变方向
            linearGradientBrush2.WrapMode = WrapMode.TileFlipXY;
            G.FillRectangle(linearGradientBrush2, new Rectangle(150, 0, 150, 150));//绘制矩形

            GraphicsPath graphicsPath1 = new GraphicsPath();        //创建绘制路径
            graphicsPath1.AddArc(new Rectangle(0, 150, 100, 100), 90, 180);//向路径中添加半左圆弧
            graphicsPath1.AddArc(new Rectangle(150, 150, 100, 100), 270, 180);//向路径中添加半右圆弧
            graphicsPath1.CloseFigure();                            //闭合路径
            PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath1);//创建路径渐变画刷
            pathGradientBrush.CenterColor = Color.Yellow;           //指定画刷中心颜色
            pathGradientBrush.SurroundColors = new Color[] { Color.Blue };//指定画刷周边颜色
            pathGradientBrush.CenterPoint = new PointF(125, 200);   //指定画刷中心点坐标
            G.SmoothingMode = SmoothingMode.AntiAlias;              //消锯齿
            G.FillPath(pathGradientBrush, graphicsPath1);           //利用画刷填充路径
            G.DrawPath(new Pen(Color.Lime, 3f), graphicsPath1);     //绘制闭合路径曲线

            linearGradientBrush1.Dispose();
            linearGradientBrush2.Dispose();
            graphicsPath1.Dispose();
            pathGradientBrush.Dispose();
        }
示例#13
0
        public static void FillRoundedRectangle(Rectangle rectangle, GlassGradient gradient, bool isSunk, bool isGlass,
                                                Graphics graphics)
        {
            if (rectangle.Width == 0 || rectangle.Height == 0)
                return;

            var path = GetRoundedRectanglePath(rectangle);

            var activeGradient = isSunk
                                     ? new GlassGradient(gradient.Bottom, gradient.Top)
                                     : new GlassGradient(gradient.Top, gradient.Bottom);

            var brush = activeGradient.GetBrush(rectangle);
            graphics.FillPath(brush, path);
            brush.Dispose();

            if (isGlass)
            {
                graphics.SetClip(path);

                var glassRectangle = isSunk
                                         ? new Rectangle(new Point(rectangle.Left, rectangle.Height/2),
                                                         new Size(rectangle.Width, rectangle.Height/2))
                                         : new Rectangle(rectangle.Location,
                                                         new Size(rectangle.Width, rectangle.Height/2));
                var glassPath = GetRoundedRectanglePath(glassRectangle);
                Brush glassBrush = new LinearGradientBrush(glassRectangle, Color.Transparent,
                                                           Color.FromArgb(32, 255, 255, 255), 90.0f);

                graphics.FillPath(glassBrush, glassPath);

                glassBrush.Dispose();
                glassPath.Dispose();
            }
        }
示例#14
0
        private void DrawComputerTiledModeView(IListItemEx sho, Graphics g, RectangleF lblrectTiles, StringFormat fmt)
        {
            var driveInfo = new DriveInfo(sho.ParsingName);

            if (driveInfo.IsReady)
            {
                ProgressBarRenderer.DrawHorizontalBar(g, new Rectangle((Int32)lblrectTiles.Left, (Int32)lblrectTiles.Bottom + 4, (Int32)lblrectTiles.Width - 10, 10));
                var fullProcent  = (100 * (driveInfo.TotalSize - driveInfo.AvailableFreeSpace)) / driveInfo.TotalSize;
                var barWidth     = (lblrectTiles.Width - 12) * fullProcent / 100;
                var rec          = new Rectangle((Int32)lblrectTiles.Left + 1, (Int32)lblrectTiles.Bottom + 5, (Int32)barWidth, 8);
                var gradRec      = new Rectangle(rec.Left, rec.Top - 1, rec.Width, rec.Height + 2);
                var criticalUsed = fullProcent >= 90;
                var warningUsed  = fullProcent >= 75;
                var averageUsed  = fullProcent >= 50;
                var brush        = new LinearGradientBrush(gradRec, criticalUsed ? Color.FromArgb(255, 0, 0) : warningUsed ? Color.FromArgb(255, 224, 0) : averageUsed ? Color.FromArgb(0, 220, 255) : Color.FromArgb(199, 248, 165),
                                                           criticalUsed ? Color.FromArgb(150, 0, 0) : warningUsed ? Color.FromArgb(255, 188, 0) : averageUsed ? Color.FromArgb(43, 84, 235) : Color.FromArgb(101, 247, 0), LinearGradientMode.Vertical);
                g.FillRectangle(brush, rec);
                brush.Dispose();
                var  lblrectSubiTem3  = new RectangleF(lblrectTiles.Left, lblrectTiles.Bottom + 16, lblrectTiles.Width, 15);
                Font subItemFont      = SystemFonts.IconTitleFont;
                var  subItemTextBrush = new SolidBrush(SystemColors.ControlDarkDark);
                g.DrawString($"{ShlWapi.StrFormatByteSize(driveInfo.AvailableFreeSpace)} free of {ShlWapi.StrFormatByteSize(driveInfo.TotalSize)}", subItemFont, subItemTextBrush, lblrectSubiTem3, fmt);

                subItemFont.Dispose();
                subItemTextBrush.Dispose();
            }
        }
        protected override void OnPaint(PaintEventArgs paintEvent)
        {
            base.OnPaint(paintEvent);
            paintEvent.Graphics.Clear(_backgroundColor);

            // High Rendering For Radiobutton Circle
            paintEvent.Graphics.SmoothingMode = SmoothingMode.HighQuality;

            // Draw Cirle & Border
            Brush gradientBrush = new LinearGradientBrush(new Rectangle(new Point(0, 0), new Size(14, 14)),
                _primaryGradientColor, _secondaryGradientColor, 90.0F);
            paintEvent.Graphics.FillEllipse(gradientBrush, new Rectangle(0, 0, 14, 14));
            paintEvent.Graphics.DrawEllipse(new Pen(_borderColor), new Rectangle(0, 0, 14, 14));

            // Draw Text
            paintEvent.Graphics.DrawString(this.Text, _font, new SolidBrush(_textColor), new PointF(19, 0));

            if (this.Checked)
            {
                paintEvent.Graphics.FillEllipse(new SolidBrush(_bulletColor), new Rectangle(4, 4, 6, 6));
            }

            // Dispose Of Brushes & Pens
            gradientBrush.Dispose();
        }
示例#16
0
 private void panel2_Paint(object sender, PaintEventArgs e)
 {
     System.Drawing.Drawing2D.LinearGradientBrush pnlGdt = new System.Drawing.Drawing2D.LinearGradientBrush(panel2.ClientRectangle,
     Color.Yellow, Color.Navy, 90f, true);
     e.Graphics.FillRectangle(pnlGdt, panel2.ClientRectangle);
     pnlGdt.Dispose();
 }
示例#17
0
        /// <summary>
        /// The graphics device and clip rectangle are in the parent coordinates.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="clipRectangle"></param>
        /// <param name="symbol">The symbol to use for drawing.</param>
        public void Draw(Graphics g, Rectangle clipRectangle, ISymbol symbol)
        {
            Color topLeft;
            Color bottomRight;
            if (_isSelected)
            {
                topLeft = _selectionColor.Darker(.3F);
                bottomRight = _selectionColor.Lighter(.3F);
            }
            else
            {
                topLeft = _backColor.Lighter(.3F);
                bottomRight = _backColor.Darker(.3F);
            }
            LinearGradientBrush b = new LinearGradientBrush(_bounds, topLeft, bottomRight, LinearGradientMode.ForwardDiagonal);
            GraphicsPath gp = new GraphicsPath();
            gp.AddRoundedRectangle(Bounds, _roundingRadius);
            g.FillPath(b, gp);
            gp.Dispose();
            b.Dispose();

            Matrix old = g.Transform;
            Matrix shift = g.Transform;
            shift.Translate(_bounds.Left + _bounds.Width / 2, _bounds.Top + _bounds.Height / 2);
            g.Transform = shift;

            if (symbol != null)
            {
                OnDrawSymbol(g, symbol);
            }

            g.Transform = old;
        }
示例#18
0
 void Reset()
 {
     if (brush != null)
     {
         brush.Dispose();
     }
     brush = null;
 }
示例#19
0
 protected override void OnPaint(PaintEventArgs e)
 {
     LinearGradientBrush b = new LinearGradientBrush(this.ClientRectangle,
         Color.FromArgb(150, 200, 255),
         Color.FromArgb(40, 65, 150),
         LinearGradientMode.ForwardDiagonal);
     e.Graphics.FillRectangle(b, e.ClipRectangle);
     b.Dispose();
 }
示例#20
0
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            Graphics g = e.Graphics;
            LinearGradientBrush b = new LinearGradientBrush(e.AffectedBounds, Color.DarkGray, Color.Black, 90);
            g.FillRectangle(b, e.AffectedBounds);
            b.Dispose();

            base.OnRenderToolStripBackground(e);
        }
		public override void PaintValue( PaintValueEventArgs args ) 
		{
			MetalGradient gradient = (MetalGradient)args.Value;
		
			LinearGradientBrush gradientBrush = new LinearGradientBrush( args.Bounds, gradient.Top, gradient.Bottom, 90.0f );

			args.Graphics.FillRectangle( gradientBrush, args.Bounds );

			gradientBrush.Dispose();
		}
示例#22
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Color color1 = Color.FromArgb(255,229,163);
            Color color2 = Color.FromArgb(253, 178, 51);

            LinearGradientBrush br = new LinearGradientBrush(this.ClientRectangle, color1 , color2, LinearGradientMode.Vertical);
            e.Graphics.FillRectangle(br, this.ClientRectangle);
            br.Dispose();
            base.OnPaint(e);
        }
 protected override void OnPaintBackground(PaintEventArgs e)
 {
     var g = e.Graphics;
     Brush b = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), Color.FromArgb(20, 30, 39), Color.FromArgb(41, 49, 73));
     var p = new Pen(Color.FromArgb(71, 84, 108));
     g.FillRectangle(b, ClientRectangle);
     g.DrawRectangle(p, new Rectangle(0, ClientSize.Height - 1, ClientSize.Width - 1, ClientSize.Height - 1));
     p.Dispose();
     b.Dispose();
 }
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     Graphics G = e.Graphics;
     LinearGradientBrush brush = new LinearGradientBrush(
         new Point(0, 0), new Point(20, 20), Color.Blue, Color.Green);
     brush.WrapMode = WrapMode.TileFlipXY;
     G.FillRectangle(brush, this.ClientRectangle);
     brush.Dispose();
 }
 protected override void OnPaintBackground(PaintEventArgs e)
 {
     Graphics g = e.Graphics;
     Brush b = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), Color.FromArgb(20, 30, 39), Color.FromArgb(41, 49, 73));
     Pen p = new Pen(Color.FromArgb(71, 84, 108));
     g.FillRectangle(b, this.ClientRectangle);
     p.Dispose();
     GC.SuppressFinalize(p);
     b.Dispose();
     GC.SuppressFinalize(b);
 }
示例#26
0
        public static void DrawGradient( Rectangle rectangle, MetalGradient gradient, Graphics graphics )
        {
            if ( rectangle.Width == 0 || rectangle.Height == 0 )
                return;

            LinearGradientBrush brush = new LinearGradientBrush( rectangle, gradient.Top, gradient.Bottom, 90.0f );

            graphics.FillRectangle( brush, rectangle );

            brush.Dispose();
        }
示例#27
0
 private void About_Paint(object sender, PaintEventArgs e)
 {
     Graphics g = e.Graphics;
     g.SmoothingMode = SmoothingMode.HighSpeed;
     LinearGradientBrush br = new LinearGradientBrush(new Point(0, 0), new Point(500, 400), Color.BurlyWood, Color.CornflowerBlue);
     LinearGradientBrush br1 = new LinearGradientBrush(new Point(0, 0), new Point(500, 400), Color.DarkMagenta, Color.RosyBrown);
     g.FillRectangle(br, new Rectangle(0, 0, this.Width, this.Height));
     g.DrawRectangle(new Pen(br1, 6), new Rectangle(0, 0, this.Width-1, this.Height-1));
     br.Dispose();
     br1.Dispose();
 }
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     Brush b = new SolidBrush(ForeColor);
     var lb = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), Color.FromArgb(255, Color.White), Color.FromArgb(50, Color.White), LinearGradientMode.Horizontal);
     int width = (int)((percent / 100)*Width);
     e.Graphics.FillRectangle(b, 0, 0, width, Height);
     e.Graphics.FillRectangle(lb, 0, 0, width, Height);
     b.Dispose();
     lb.Dispose();
 }
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     Brush b = new SolidBrush(this.ForeColor); // Create a brush that will draw the background of the Pbar
     // Create a linear gradient that will be drawn over the background. FromArgb means you can use the Alpha value wich is the transparency
     LinearGradientBrush lb = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), Color.FromArgb(255, Color.White), Color.FromArgb(50, Color.White), LinearGradientMode.ForwardDiagonal);
     // Calculate how much has the Pbar to be filled for "x" %
     int width = (int)((percent / 100) * this.Width);
     e.Graphics.FillRectangle(b, 0, 0, width, this.Height);
     e.Graphics.FillRectangle(lb, 0, 0, width, this.Height);
     b.Dispose(); lb.Dispose();
 }
示例#30
0
        public void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.FillEllipse(Brushes.Red, 100, y, 9, 9);

            SolidBrush brushblue = new SolidBrush(Color.Green);
            e.Graphics.FillRectangle(brushblue, x, 50, 15, 15);

            Rectangle rect = new Rectangle(140, z, 20, 20);
            LinearGradientBrush lBrush = new LinearGradientBrush(rect, Color.Red, Color.Yellow, LinearGradientMode.BackwardDiagonal);
            g.FillRectangle(lBrush, rect);
            lBrush.Dispose();
        }
示例#31
0
        /// <summary>
        /// 设置选项卡头部颜色
        /// </summary>
        /// <param name="graph">The graph.</param>
        /// <param name="index">The index.</param>
        /// <param name="path">The path.</param>
        private void PaintTabBackground(System.Drawing.Graphics graph, int index, System.Drawing.Drawing2D.GraphicsPath path)
        {
            Rectangle rect = this.GetTabRect(index);

            System.Drawing.Brush buttonBrush = new System.Drawing.Drawing2D.LinearGradientBrush(rect, _headerBackColor, _headerBackColor, LinearGradientMode.Vertical);  //非选中时候的 TabPage 页头部背景色
            graph.FillPath(buttonBrush, path);
            //if (index == this.SelectedIndex)
            //{
            //    //buttonBrush = new System.Drawing.SolidBrush(_headSelectedBackColor);
            //    graph.DrawLine(new Pen(_headerBackColor), rect.Right+2, rect.Bottom, rect.Left + 1, rect.Bottom);
            //}
            buttonBrush.Dispose();
        }
示例#32
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Rectangle           rc            = this.ClientRectangle;
            int                 gradientWidth = rc.Width;
            LinearGradientBrush linGrBrush    = new System.Drawing.Drawing2D.LinearGradientBrush(
                new Point(0, 10),
                new Point(gradientWidth, 10),
                gradientStartColor,
                gradientEndColor);

            float[] positions = { 0.0f, 0.05f, 0.95f, 1.0f };
            float[] factors   = { 0.4f, 1.0f, 0.5f, 0.4f };

            //Create a Blend object and assign it to linGrBrush.
            Blend blend = new Blend();

            blend.Factors    = factors;
            blend.Positions  = positions;
            linGrBrush.Blend = blend;

            // draw the gradient on the left edge
            e.Graphics.FillRectangle(linGrBrush, 0, 0, gradientWidth + 5, rc.Height);

            // draw a filled rectangle rest of the area
            using (Brush brush = new SolidBrush(gradientEndColor))
            {
                e.Graphics.FillRectangle(brush, gradientWidth, 0, rc.Width - gradientWidth, rc.Height);
            }
            linGrBrush.Dispose();


            // get the image from a resource file
            if (blendImage != null)
            {
                ImageAttributes ia = new ImageAttributes();
                ColorMatrix     cm = new ColorMatrix();
                cm.Matrix00 = 1;
                cm.Matrix11 = 1;
                cm.Matrix22 = 1;
                float transparancy = .14f;
                cm.Matrix33 = transparancy;
                ia.SetColorMatrix(cm);
                int       imgWidth  = blendImage.Width;
                int       imgHeight = blendImage.Height;
                Rectangle destRect  = new Rectangle(rc.Width - imgWidth, rc.Height - imgHeight,
                                                    imgWidth, imgHeight);
                e.Graphics.DrawImage(blendImage, destRect, 0, 0, imgWidth, imgHeight,
                                     GraphicsUnit.Pixel, ia);
            }
        }
示例#33
0
        //draw round rectangular button function
        void DrawRoundRectangularButton(Graphics g)
        {
            Color c1 = Color.FromArgb(color1Transparent, color1);
            Color c2 = Color.FromArgb(color2Transparent, color2);


            Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, c1, c2, angle);

            Region region = new System.Drawing.Region(new Rectangle(5, 5, this.Width, this.Height));

            GraphicsPath grp = new GraphicsPath();

            grp.AddArc(5, 5, 40, 40, 180, 90);
            grp.AddLine(25, 5, this.Width - 25, 5);
            grp.AddArc(this.Width - 45, 5, 40, 40, 270, 90);
            grp.AddLine(this.Width - 5, 25, this.Width - 5, this.Height - 25);
            grp.AddArc(this.Width - 45, this.Height - 45, 40, 40, 0, 90);
            grp.AddLine(25, this.Height - 5, this.Width - 25, this.Height - 5);
            grp.AddArc(5, this.Height - 45, 40, 40, 90, 90);
            grp.AddLine(5, 25, 5, this.Height - 25);

            region.Intersect(grp);

            g.FillRegion(b, region);

            for (int i = 0; i < borderWidth; i++)
            {
                g.DrawArc(new Pen(buttonborder_1), 5 + i, 5 + i, 40, 40, 180, 90);
                g.DrawLine(new Pen(buttonborder_1), 25, 5 + i, this.Width - 25, 5 + i);
                g.DrawArc(new Pen(buttonborder_1), this.Width - 45 - i, 5 + i, 40, 40, 270, 90);
                g.DrawLine(new Pen(buttonborder_1), 5 + i, 25, 5 + i, this.Height - 25);


                g.DrawLine(new Pen(buttonborder_2), this.Width - 5 - i, 25, this.Width - 5 - i, this.Height - 25);
                g.DrawArc(new Pen(buttonborder_2), this.Width - 45 - i, this.Height - 45 - i, 40, 40, 0, 90);
                g.DrawLine(new Pen(buttonborder_2), 25, this.Height - 5 - i, this.Width - 25, this.Height - 5 - i);
                g.DrawArc(new Pen(buttonborder_2), 5 + i, this.Height - 45 - i, 40, 40, 90, 90);
            }



            if (showButtonText)
            {
                Point      p       = new Point(textX, textY);
                SolidBrush frcolor = new SolidBrush(this.ForeColor);
                g.DrawString(text, this.Font, frcolor, p);
            }

            b.Dispose();
        }
示例#34
0
        public static Image Bevel(Image img)
        {

            Image bitmapNew = (Image)img.Clone();

            int widTh, heTh;
            widTh = bitmapNew.Width; heTh = bitmapNew.Height;

            int BevW = 10, LowA = 0, HighA = 180, Dark = 80, Light = 255;
            // hilight color, low and high

            Color clrHi1 = Color.FromArgb(LowA, Light, Light, Light);
            Color clrHi2 = Color.FromArgb(HighA, Light, Light, Light);
            Color clrDark1 = Color.FromArgb(LowA, Dark, Dark, Dark);
            Color clrDark2 = Color.FromArgb(HighA, Dark, Dark, Dark);

            LinearGradientBrush b; Rectangle rectSide;
            Graphics g = Graphics.FromImage(bitmapNew);
            Size szHorz = new Size(widTh, BevW);
            Size szVert = new Size(BevW, heTh);

            szHorz += new Size(0, 2); szVert += new Size(2, 0);
            rectSide = new Rectangle(new Point(0, heTh - BevW), szHorz);
            b = new LinearGradientBrush(rectSide, clrDark1, clrDark2, LinearGradientMode.Vertical);
            rectSide.Inflate(0, -1);
            g.FillRectangle(b, rectSide);

            rectSide = new Rectangle(new Point(widTh - BevW, 0), szVert);
            b.Dispose();
            b = new LinearGradientBrush(rectSide, clrDark1, clrDark2, LinearGradientMode.Horizontal);
            rectSide.Inflate(-1, 0);
            g.FillRectangle(b, rectSide);
            szHorz -= new Size(0, 2); szVert -= new Size(2, 0);
            
            rectSide = new Rectangle(new Point(0, 0), szHorz);
            b.Dispose();
            b = new LinearGradientBrush(rectSide, clrHi2, clrHi1, LinearGradientMode.Vertical);
            g.FillRectangle(b, rectSide);

            rectSide = new Rectangle(new Point(0, 0), szVert);
            b.Dispose();
            b = new LinearGradientBrush(rectSide, clrHi2, clrHi1, LinearGradientMode.Horizontal);
            g.FillRectangle(b, rectSide);

            // dispose graphics objects and return bitmap

            b.Dispose();
            g.Dispose();
            return bitmapNew;
        }
        void IGlyphPainter.PaintPath(Graphics g, System.Drawing.Drawing2D.GraphicsPath path)
        {
            RectangleF bounds = path.GetBounds();
            LinearGradientBrush brush = new LinearGradientBrush(bounds, color1, color2, mode);
            g.FillPath(brush, path);
            brush.Dispose();

            if(numericUpDown1.Value != 0)
            {
                Pen pen = new Pen(colorBorder, (float)numericUpDown1.Value);
                g.DrawPath(pen, path);
                pen.Dispose();
            }
        }
示例#36
0
        protected new void PaintTransparentBackground(Graphics graphics, Rectangle clipRect)
        {
            if ((this.Parent != null))
            {
                clipRect.Offset(this.Location);
                PaintEventArgs e     = new PaintEventArgs(graphics, clipRect);
                GraphicsState  state = graphics.Save();
                graphics.SmoothingMode = SmoothingMode.HighSpeed;
                try
                {
                    graphics.TranslateTransform((float)-this.Location.X, (float)-this.Location.Y);
                    this.InvokePaintBackground(this.Parent, e);
                    this.InvokePaint(this.Parent, e);
                }

                finally
                {
                    graphics.Restore(state);
                    clipRect.Offset(-this.Location.X, -this.Location.Y);
                }
            }
            else
            {
                System.Drawing.Drawing2D.LinearGradientBrush backBrush = new System.Drawing.Drawing2D.LinearGradientBrush(this.Bounds, SystemColors.ControlLightLight, SystemColors.ControlLight, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                graphics.FillRectangle(backBrush, this.Bounds);
                backBrush.Dispose();
            }

            //! Background color attempt
            //graphics.Clear(Color.White);
            //if ((this.Parent != null))
            //{
            //    clipRect.Offset(this.Location);
            //    PaintEventArgs e = new PaintEventArgs(graphics, clipRect);
            //    GraphicsState state = graphics.Save();
            //    graphics.SmoothingMode = SmoothingMode.HighSpeed;
            //    try
            //    {
            //        graphics.TranslateTransform((float)-this.Location.X, (float)-this.Location.Y);
            //        this.InvokePaintBackground(this.Parent, e);
            //        this.InvokePaint(this.Parent, e);
            //    }
            //    finally
            //    {
            //        graphics.Restore(state);
            //        clipRect.Offset(-this.Location.X, -this.Location.Y);
            //    }
            //}
        }
		protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
		{
			if(((e.Item.Owner is ContextMenuStrip) || (e.Item.OwnerItem != null)) &&
				e.Item.Selected)
			{
				Rectangle rect = e.Item.ContentRectangle;
				rect.Offset(0, -1);
				rect.Height += 1;

				Color clrStart = CtsrColorTable.StartGradient(this.ColorTable.MenuItemSelected);
				Color clrEnd = CtsrColorTable.EndGradient(this.ColorTable.MenuItemSelected);
				Color clrBorder = this.ColorTable.MenuItemBorder;

				if(!e.Item.Enabled)
				{
					Color clrBase = this.ColorTable.MenuStripGradientEnd;
					clrStart = UIUtil.ColorTowardsGrayscale(clrStart, clrBase, 0.5);
					clrEnd = UIUtil.ColorTowardsGrayscale(clrEnd, clrBase, 0.2);
					clrBorder = UIUtil.ColorTowardsGrayscale(clrBorder, clrBase, 0.2);
				}

				LinearGradientBrush br = new LinearGradientBrush(rect,
					clrStart, clrEnd, LinearGradientMode.Vertical);
				Pen p = new Pen(clrBorder);

				SmoothingMode smOrg = e.Graphics.SmoothingMode;
				e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
				
				GraphicsPath gp = UIUtil.CreateRoundedRectangle(rect.X, rect.Y,
					rect.Width, rect.Height, 2);
				if(gp != null)
				{
					e.Graphics.FillPath(br, gp);
					e.Graphics.DrawPath(p, gp);
					gp.Dispose();
				}
				else // Shouldn't ever happen...
				{
					e.Graphics.FillRectangle(br, rect);
					e.Graphics.DrawRectangle(p, rect);
				}

				e.Graphics.SmoothingMode = smOrg;

				p.Dispose();
				br.Dispose();
			}
			else base.OnRenderMenuItemBackground(e);
		}
示例#38
0
 void maintableLayoutPanel_Paint(object sender, PaintEventArgs e)
 {
     base.OnPaint(e);
     if (!DesignMode)
     {
         System.Drawing.Drawing2D.LinearGradientBrush br = new System.Drawing.Drawing2D.LinearGradientBrush(
             e.ClipRectangle,
             SystemColors.ControlDark,
             SystemColors.Control,
             LinearGradientMode.Horizontal);
         e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
         e.Graphics.FillPath(br, Rounder.GetRoundedBounds(e.ClipRectangle, Corners.None));
         br.Dispose();
     }
 }
        int yMouseDown = 0; //鼠标按下时的Y坐标

        #endregion Fields

        #region Constructors

        public MouseListBox()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
            InitializeComponent();

            Graphics G = Graphics.FromImage(imageItem);
            LinearGradientBrush brush = new LinearGradientBrush(    //创建线性渐变画刷
            new Point(0, 0), new Point(0, 20), Color.Orange, Color.Lime);
            brush.WrapMode = WrapMode.TileFlipXY;
            G.FillRectangle(brush, 0, 0, 100, 40);                  //填充图像
            brush.Dispose();
            G.Dispose();
            formatItem.Alignment = StringAlignment.Center;          //水平居中
            formatItem.LineAlignment = StringAlignment.Center;      //垂直居中
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            //dòng này nếu muốn có số chạy giữa thanh progressBar
            //label1.Location = new Point((this.Width / 2) - (label1.Width / 2), (this.Height / 2) - (label1.Height / 2));

            LinearGradientBrush lgb = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), Color.White, this.ForeColor, LinearGradientMode.ForwardDiagonal);

            int Width = (int)((percent / max) * this.Width);

            e.Graphics.FillRectangle(lgb, 0, 0, Width, this.Height);

            lgb.Dispose();
        }
示例#41
0
        protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
        {
            base.OnPaintBackground(pevent);
            pevent.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            System.Drawing.Drawing2D.GraphicsPath graphPath;
            graphPath = this.CreatePath();
            //	Create Gradient Brush (Cannot be width or height 0)
            System.Drawing.Drawing2D.LinearGradientBrush filler;
            System.Drawing.Rectangle rect = this.ClientRectangle;
            if (this.ClientRectangle.Width == 0)
            {
                rect.Width += 1;
            }
            if (this.ClientRectangle.Height == 0)
            {
                rect.Height += 1;
            }

            /*if (this.m_GradientMode == LinearGradientMode.None)
             * {
             *      filler = new System.Drawing.Drawing2D.LinearGradientBrush(rect, this.m_BackColor1, this.m_BackColor1, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
             * }
             * else
             * {
             *      filler = new System.Drawing.Drawing2D.LinearGradientBrush(rect, this.m_BackColor1, this.m_BackColor2, ((System.Drawing.Drawing2D.LinearGradientMode)this.m_GradientMode));
             * }
             */
            filler = new System.Drawing.Drawing2D.LinearGradientBrush(rect, this.m_BackColor1, this.m_BackColor2, ((System.Drawing.Drawing2D.LinearGradientMode) this.m_GradientMode));


            pevent.Graphics.FillPath(filler, graphPath);
            //filler.Dispose();	// Fxcop warning
            if (this.m_BorderStyle == System.Windows.Forms.BorderStyle.FixedSingle)
            {
                System.Drawing.Pen borderPen = new System.Drawing.Pen(this.m_BorderColor, this.m_BorderWidth);
                pevent.Graphics.DrawPath(borderPen, graphPath);
                borderPen.Dispose();
            }
            else if (this.m_BorderStyle == System.Windows.Forms.BorderStyle.Fixed3D)
            {
                DrawBorder3D(pevent.Graphics, this.ClientRectangle);
            }
            else if (this.m_BorderStyle == System.Windows.Forms.BorderStyle.None)
            {
            }
            filler.Dispose();
            graphPath.Dispose();
        }
示例#42
0
 protected override void OnPaintBackground(PaintEventArgs pevent)
 {
     Brush b = null;
     try
     {
         b = new LinearGradientBrush(new Point(0, 0), new Point(this.ClientRectangle.Width, 0), GradientBeginColor, GradientEndColor);
         pevent.Graphics.FillRectangle(b, this.ClientRectangle);
     }
     finally
     {
         if (b != null)
         {
             b.Dispose();
         }
     }
 }
示例#43
0
		/// <summary>
		/// Draw the scale of the control
		/// </summary>
		/// <param name="Gr"></param>
		/// <param name="rc"></param>
		/// <returns></returns>
		public virtual bool DrawScale( Graphics Gr, RectangleF rc )
		{
			if ( this.Knob == null )
				return false;
			
			Color cKnob = this.Knob.ScaleColor;
			Color cKnobDark = LBColorManager.StepColor ( cKnob, 60 );
			
			LinearGradientBrush br = new LinearGradientBrush ( rc, cKnobDark, cKnob, 45 );
				
			Gr.FillEllipse ( br, rc );
			
			br.Dispose();

			return true;
		}
示例#44
0
    private void DrawBackground(Graphics graphics)
    {
      //
      // Create gradient brush
      //
      Brush gradientBrush = new LinearGradientBrush(workingLabel.ClientRectangle,
                                                    firstColor,
                                                    lastColor,
                                                    LinearGradientMode.Horizontal);

      //
      // Draw brush
      //
      graphics.FillRectangle(gradientBrush, ClientRectangle);
      gradientBrush.Dispose();
    }
示例#45
0
        protected override void  OnPaintBackground(PaintEventArgs pevent)
        {
            Rectangle rec = pevent.ClipRectangle;

            if (m_bMultiTabHead)
            {
                if (m_enumState == TabHeadState.SELECTED)
                {
                    base.OnPaintBackground(pevent);
                }
                else
                {
                    Color cTop    = Color.FromArgb(255, 0xFA, 0xFA, 0xFA);
                    Color cBottom = Color.FromArgb(255, 0xEB, 0xEB, 0xEB);
                    System.Drawing.Drawing2D.LinearGradientBrush backBrush = new System.Drawing.Drawing2D.LinearGradientBrush(rec.Location, new Point(rec.Left, rec.Bottom), cTop, cBottom);
                    pevent.Graphics.FillRectangle(backBrush, pevent.ClipRectangle);
                    backBrush.Dispose();

                    Pen pen = new Pen(Color.FromArgb(255, 208, 208, 208), 1);
                    if (m_enumState != TabHeadState.ALLFOLDED)
                    {
                        Pen penBottom = new Pen(Color.FromArgb(255, 165, 165, 165), 1);
                        pevent.Graphics.DrawLine(penBottom, rec.Left, rec.Bottom - 1, rec.Right - 1, rec.Bottom - 1);
                        penBottom.Dispose();
                        if (m_iIndex % 2 == 0)
                        {
                            pevent.Graphics.DrawLine(pen, rec.Right - 1, rec.Top, rec.Right - 1, rec.Bottom - 1);
                        }
                    }

                    if (m_iIndex % 2 == 1)
                    {
                        pevent.Graphics.DrawLine(pen, rec.Left, rec.Top, rec.Left, rec.Bottom - 1);
                    }

                    pen.Dispose();
                }
            }
            else
            {
                Color cTop    = Color.FromArgb(255, 0xFA, 0xFA, 0xFA);
                Color cBottom = Color.FromArgb(255, 0xEB, 0xEB, 0xEB);
                System.Drawing.Drawing2D.LinearGradientBrush backBrush = new System.Drawing.Drawing2D.LinearGradientBrush(rec.Location, new Point(rec.Left, rec.Bottom), cTop, cBottom);
                pevent.Graphics.FillRectangle(backBrush, pevent.ClipRectangle);
                backBrush.Dispose();
            }
        }
示例#46
0
		protected override void OnDrawItem(DrawItemEventArgs e)
		{
			RectangleF tabTextArea = RectangleF.Empty;
			
			for(int nIndex = 0 ; nIndex < this.TabCount ; nIndex++)
			{
				if (TabPages[nIndex].Text.Trim() == TabPages[nIndex].Text)
					TabPages[nIndex].Text += "    ";

				if( nIndex != this.SelectedIndex )
				{
					/*if not active draw ,inactive close button*/
					tabTextArea = (RectangleF)this.GetTabRect(nIndex);
					//using(Bitmap bmp = Properties.Resources.delete)
					//{
					//    e.Graphics.DrawImage(bmp,
					//        tabTextArea.X+tabTextArea.Width -16, 5, 13, 13);
					//}
				}
				else
				{
					tabTextArea = (RectangleF)this.GetTabRect(nIndex);
					LinearGradientBrush br = new LinearGradientBrush(tabTextArea,
						SystemColors.ControlLightLight,SystemColors.Control,
						LinearGradientMode.Vertical);
					e.Graphics.FillRectangle(br,tabTextArea);

					/*if active draw ,inactive close button*/
					using(Bitmap bmp = Properties.Resources.delete)
					{
						e.Graphics.DrawImage(bmp,
							tabTextArea.X+tabTextArea.Width -16, 5, 13, 13);
					}
					br.Dispose();
				}
				string str = this.TabPages[nIndex].Text;
				StringFormat stringFormat = new StringFormat();
				stringFormat.Alignment = StringAlignment.Center; 
				using(SolidBrush brush = new SolidBrush(
					this.TabPages[nIndex].ForeColor))
				{
					/*Draw the tab header text*/
					tabTextArea.Offset((nIndex == this.SelectedIndex) ? - 7.0f : 0.0f, 2.0f);
					e.Graphics.DrawString(str,this.Font, brush,	tabTextArea,stringFormat);
				}
			}
		}
示例#47
0
		public static void Draw2ColorBar(Graphics dc, RectangleF r, Orientation orientation, Color c1, Color c2)
		{
			RectangleF lr1 = r;
			float angle = 0;

			if (orientation == Orientation.Vertical)
				angle = 270;
			if (orientation == Orientation.Horizontal)
				angle = 0;

			if (lr1.Height > 0 && lr1.Width > 0)
			{
				LinearGradientBrush lb1 = new LinearGradientBrush(lr1, c1, c2, angle, false);
				dc.FillRectangle(lb1, lr1);
				lb1.Dispose();
			}
		}
        protected override void OnPaint(PaintEventArgs e)  //PTK added
        {
            this.OnPaintBackground(e);
            base.OnPaint(e);
            this.AutoSize = false;
            text          = this.Text;
            Color      c1      = Color.Transparent;
            Color      c2      = Color.Transparent;
            Brush      b       = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, c1, c2, angle);
            SolidBrush frcolor = new SolidBrush(Color.Black);

            e.Graphics.FillRectangle(b, ClientRectangle);
            e.Graphics.DrawString(text, new System.Drawing.Font("MS Gothic", 26F, System.Drawing.FontStyle.Bold), frcolor, new Point(textX, textY));
            Rectangle rc = new Rectangle(boxlocatx, boxlocaty, boxsize, boxsize);

            ControlPaint.DrawRadioButton(e.Graphics, rc, this.Checked ? ButtonState.Checked : ButtonState.Normal);
            b.Dispose();
        }
示例#49
0
        public static void FillRectangle(Graphics g, Rectangle rect, Color backgroundColor, Color borderColor, Color frontColor, String text, StringFormat format, Point textPosition)
        {
            Rectangle rectA = new Rectangle(rect.X, rect.Y, rect.Width - 1, rect.Height - 1);

            // Enable anti-alias
            g.SmoothingMode = SmoothingMode.AntiAlias;

            // Draw content filled rectangle
            if (rectA.Width >= 1.5f)
            {
                Brush sectionBrush = new System.Drawing.Drawing2D.LinearGradientBrush(rectA, backgroundColor, BlendColors(backgroundColor, Color.Black, 0.4f), System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                g.FillRectangle(sectionBrush, rectA);
                sectionBrush.Dispose();
            }

            // Draw text
            if (text != null)
            {
                Region     oldClip  = g.Clip;
                RectangleF clipRect = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height);
                clipRect.Intersect(g.ClipBounds);
                g.SetClip(clipRect);

                Font  font  = new Font("Tahoma", 8, FontStyle.Regular);
                Brush brush = new SolidBrush(frontColor);
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.DrawString(text, font, brush, textPosition, format);
                g.SmoothingMode = SmoothingMode.None;

                font.Dispose();
                brush.Dispose();
                format.Dispose();

                g.Clip = oldClip;
            }

            // Draw border
            Pen borderPen = new Pen(Color.FromArgb(192, borderColor.R, borderColor.G, borderColor.B));

            g.DrawRectangle(borderPen, rectA);
            borderPen.Dispose();

            g.SmoothingMode = SmoothingMode.None;
        }
 protected override void OnPaint(System.Windows.Forms.PaintEventArgs pevent)
 {
     pevent.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
     pevent.Graphics.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.High;
     pevent.Graphics.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
     pevent.Graphics.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     System.Drawing.Brush brush1 = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, base.BackColor, _BackColor2, BackFillMode);
     pevent.Graphics.FillRectangle(brush1, ClientRectangle);
     brush1.Dispose();
     System.Drawing.Pen       pen        = new System.Drawing.Pen(BorderColor, 2.0F);
     System.Drawing.Rectangle rectangle3 = ClientRectangle;
     System.Drawing.Rectangle rectangle4 = ClientRectangle;
     System.Drawing.Rectangle rectangle5 = ClientRectangle;
     System.Drawing.Rectangle rectangle1 = new System.Drawing.Rectangle(rectangle3.Location, new System.Drawing.Size(rectangle4.Width, rectangle5.Height));
     pevent.Graphics.DrawRectangle(pen, rectangle1);
     pen.Dispose();
     System.Drawing.StringFormat stringFormat = new System.Drawing.StringFormat();
     stringFormat.Alignment     = System.Drawing.StringAlignment.Center;
     stringFormat.LineAlignment = System.Drawing.StringAlignment.Center;
     stringFormat.HotkeyPrefix  = System.Drawing.Text.HotkeyPrefix.Hide;
     stringFormat.FormatFlags   = System.Drawing.StringFormatFlags.LineLimit;
     stringFormat.Trimming      = System.Drawing.StringTrimming.EllipsisCharacter;
     System.Drawing.Brush brush2 = new System.Drawing.SolidBrush(base.ForeColor);
     pevent.Graphics.DrawString(Text, Font, brush2, ClientRectangle, stringFormat);
     if (Image != null)
     {
         System.Drawing.Image     image      = Image;
         System.Drawing.Rectangle rectangle6 = ClientRectangle;
         System.Drawing.Point     point1     = rectangle6.Location;
         System.Drawing.Rectangle rectangle7 = ClientRectangle;
         int i1 = point1.X + 5;
         if (this.ImageAlign == ContentAlignment.MiddleCenter)
         {
             i1 = point1.X + ((rectangle7.Width - image.Width) / 2);
         }
         System.Drawing.Rectangle rectangle8 = ClientRectangle;
         System.Drawing.Point     point2     = rectangle8.Location;
         System.Drawing.Rectangle rectangle9 = ClientRectangle;
         int i2 = point2.Y + ((rectangle9.Height - image.Height) / 2);
         System.Drawing.Rectangle rectangle2 = new System.Drawing.Rectangle(i1, i2, image.Width, image.Height);
         pevent.Graphics.DrawImage(image, rectangle2);
     }
 }
示例#51
0
        private void colorDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            e.Graphics.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

            int   rectangleLocationX     = e.CellBounds.X + 3;
            int   rectangleLocationY     = e.CellBounds.Y + 3;
            int   rectangleWidth         = e.CellBounds.Width - 6;
            int   rectangleHeight        = e.CellBounds.Height - 6;
            float emptySpotGradientAngle = (float)70.0;

            System.Drawing.Rectangle spotRectangle                      = new System.Drawing.Rectangle(rectangleLocationX, rectangleLocationY, rectangleWidth, rectangleHeight);
            System.Drawing.Rectangle gradientBigRectangle               = new System.Drawing.Rectangle(rectangleLocationX, rectangleLocationY, rectangleWidth, rectangleHeight * 2);
            System.Drawing.Rectangle gradientBiggerRectangle            = new System.Drawing.Rectangle(rectangleLocationX - 10, rectangleLocationY - 10, rectangleWidth + 20, rectangleHeight * 3);
            System.Drawing.Drawing2D.LinearGradientBrush normalPenBrush = new LinearGradientBrush(gradientBiggerRectangle, Color.Silver, Color.Black, emptySpotGradientAngle, true);
            System.Drawing.Pen normalPen = new System.Drawing.Pen(normalPenBrush, 3.0f);
            System.Drawing.Drawing2D.LinearGradientBrush br;
            float filledSpotGradientAngle = (float)270.0;
            Color c = colorArray[e.ColumnIndex];

            br = new System.Drawing.Drawing2D.LinearGradientBrush(gradientBigRectangle, Color.Black, c, filledSpotGradientAngle, false);
            e.Graphics.FillRectangle(br, spotRectangle);

            //  hilite ellipse = based on http://www3.telus.net/ryanfransen/article_glassspheres.html
            int       r3w = Convert.ToInt16(spotRectangle.Width);
            int       r3h = Convert.ToInt16(spotRectangle.Height * 0.4);
            Rectangle r3  = new Rectangle(
                new Point(spotRectangle.Location.X, spotRectangle.Location.Y + 1),
                new Size(r3w, r3h));
            LinearGradientBrush br2 = new LinearGradientBrush(r3, Color.White, Color.Transparent, 90);

            br2.WrapMode = WrapMode.TileFlipX;
            e.Graphics.FillRectangle(br2, r3);
            br2.Dispose();
            e.Graphics.DrawRectangle(normalPen, spotRectangle);
            e.PaintContent(e.ClipBounds);
            e.Handled = true;
            br.Dispose();
            normalPen.Dispose();
            normalPenBrush.Dispose();
        }
示例#52
0
        /// <summary>
        /// Draws the actual scale on the gauge
        /// </summary>
        /// <param name="g"></param>
        private void DrawScale(Graphics g)
        {
            Rectangle scalerect = rcentre;

            scalerect.Inflate(-2, -2);
            Color realstart = Color.FromArgb(m_alphaForGaugeColors, m_startColor);
            Color realend   = Color.FromArgb(m_alphaForGaugeColors, m_endColor);

            scalerect = new Rectangle(scalerect.X + 1, scalerect.Y + 1, scalerect.Width, scalerect.Height);
            System.Drawing.Drawing2D.LinearGradientBrush gb = new System.Drawing.Drawing2D.LinearGradientBrush(rcentre, realstart, realend, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
            // percentage calulation
            float range      = m_maxValue - m_minValue;
            float percentage = (m_value - m_minValue) / range;

            //float percentage = (m_value) / (m_maxValue - m_minValue);
            if (percentage > 1)
            {
                percentage = 1;
            }
            float     width    = scalerect.Width * percentage;
            Rectangle fillrect = new Rectangle(scalerect.X - 1, scalerect.Y - 1, (int)width, scalerect.Height + 1);

            g.FillRectangle(gb, fillrect);

            // draw peak & hold?

            if (m_MaxPeakHoldValue > float.MinValue && m_peakholdOpaque > 0)
            {
                Color peakholdcolor = Color.FromArgb(m_peakholdOpaque, Color.Red);
                percentage = (m_MaxPeakHoldValue - m_minValue) / range;
                if (percentage > 1)
                {
                    percentage = 1;
                }
                width = scalerect.Width * percentage;
                g.DrawLine(new Pen(peakholdcolor, 3), new Point(scalerect.X - 1 + (int)width, scalerect.Y - 1), new Point(scalerect.X - 1 + (int)width, scalerect.Y + scalerect.Height));
            }

            gb.Dispose();
        }
示例#53
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Rectangle aRect;

            System.Drawing.Drawing2D.GraphicsPath oPath;
            LinearGradientBrush _splitBrush;
            Rectangle           _splitRect = new Rectangle(0, this.Height - 10, this.Width, 10);

            aRect = new Rectangle(0, 0, this.Width - 1, this.Height - 1);
            oPath = Ai.Renderer.Drawing.roundedRectangle(aRect, 2, 2, 2, 2);
            oPath.CloseFigure();
            e.Graphics.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            e.Graphics.FillPath(new SolidBrush(Color.FromArgb(250, 250, 250)), oPath);
            if (_showSizingGrip != SizingGripMode.None)
            {
                _splitBrush = new System.Drawing.Drawing2D.LinearGradientBrush(_splitRect,
                                                                               Color.Black, Color.White, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                _splitBrush.InterpolationColors = Ai.Renderer.Drawing.SizingGripBlend;
                e.Graphics.FillRectangle(_splitBrush, _splitRect);
                if (_showSizingGrip == SizingGripMode.BottomRight)
                {
                    Ai.Renderer.Drawing.drawGrip(e.Graphics, this.Width - 12, this.Height - 12);
                }
                else
                {
                    Ai.Renderer.Drawing.drawVGrip(e.Graphics, _splitRect);
                }
                e.Graphics.DrawLine(Ai.Renderer.Drawing.GripBorderPen, 0, _splitRect.Y, this.Width, _splitRect.Y);
                _splitBrush.Dispose();
            }
            e.Graphics.DrawPath(new Pen(Color.FromArgb(134, 134, 134)), oPath);
            oPath.Dispose();
            aRect       = new Rectangle(0, 0, this.Width, this.Height);
            oPath       = Ai.Renderer.Drawing.roundedRectangle(aRect, 2, 2, 2, 2);
            this.Region = new Region(oPath);
            oPath.Dispose();
        }
示例#54
0
        /// <summary>
        /// Paints the background for the control.  If the TransparencyMode is true,
        /// no background is painted.
        /// </summary>
        /// <param name="pevent"></param>
        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            if (TransparentMode)
            {
                return;
            }

            // Getting the graphics object
            Graphics g = pevent.Graphics;

            // Creating the rectangle for the gradient
            Rectangle rBackground = new Rectangle(0, 0, this.Width, this.Height);

            // Creating the lineargradient
            System.Drawing.Drawing2D.LinearGradientBrush bBackground
                = new System.Drawing.Drawing2D.LinearGradientBrush(rBackground, _Color1, _Color2, _ColorAngle);

            // Draw the gradient onto the form
            g.FillRectangle(bBackground, rBackground);

            // Disposing of the resources held by the brush
            bBackground.Dispose();
        }
示例#55
0
        //draw round rectangular button function
        void DrawRoundRectangularButton(Graphics g)
        {
            Color c1     = Color.FromArgb(color1Transparent, color1);
            Color c2     = Color.FromArgb(color2Transparent, color2);
            int   radius = 20;

            Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, c1, c2, angle);

            Region region = new System.Drawing.Region(new Rectangle(5, 5, this.Width, this.Height));

            GraphicsPath grp = new GraphicsPath();

            grp.AddArc(5, 5, radius, radius, 180, 90);

            grp.AddArc(this.Width - (radius + 5), 5, radius, radius, 270, 90);

            grp.AddArc(this.Width - (radius + 5), this.Height - (radius + 5), radius, radius, 0, 90);

            grp.AddArc(5, this.Height - (radius + 5), radius, radius, 90, 90);


            region.Intersect(grp);

            g.FillRegion(b, region);



            if (showButtonText)
            {
                Point      p       = new Point(textX, textY);
                SolidBrush frcolor = new SolidBrush(this.ForeColor);
                g.DrawString(text, this.Font, frcolor, p);
            }

            b.Dispose();
        }
示例#56
0
        private void PaintReViewTimelineControl(PaintEventArgs e)
        {
            // Create pens and brushes
            Pen   foregroundPen       = new Pen(ForegroundColor);
            Brush foregroundBrush     = new SolidBrush(ForegroundColor);
            Brush playbackheaderBrush = new SolidBrush(PlaybackHeaderColor);
            Brush backgroundBrush     = new SolidBrush(TimelineBackColor);

            Rectangle rect = new Rectangle((int)e.Graphics.VisibleClipBounds.X, (int)e.Graphics.VisibleClipBounds.Y, (int)e.Graphics.VisibleClipBounds.Width, (int)e.Graphics.VisibleClipBounds.Height);

            e.Graphics.FillRectangle(backgroundBrush, rect);

            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            int startY    = rect.Y + rect.Height;
            int direction = -1;

            if (!OrientationUp)
            {
                startY    = rect.Y;
                direction = 1;
            }

            int   majorTimeInterval  = MajorTimeInterval;
            float majorPixelInterval = TimeToPixels(majorTimeInterval);
            float minorPixelInterval = (majorPixelInterval / 10.0f);

            float startX = panOffset.X % majorPixelInterval + rect.X;
            float endX   = startX + rect.Width - panOffset.X % majorPixelInterval;

            int count = 0;

            for (float xC = startX; xC <= endX; xC += minorPixelInterval)
            {
                if (count % 10 == 0)
                {
                    // Render major tick
                    int time = (int)(Math.Round(PixelsToTime((float)Math.Round(xC - rect.X - panOffset.X)) * 10.0f) / 10.0f);
                    e.Graphics.DrawString(TimeToString(time), font, foregroundBrush, xC, (rect.Y + rect.Height / 2) + (OrientationUp ? 0 : 5), format);
                    e.Graphics.DrawLine(foregroundPen, xC, startY, xC, startY + direction * 8);
                }
                else
                {
                    // Render minor tick
                    e.Graphics.DrawLine(foregroundPen, xC, startY, xC, startY + direction * 4);
                }
                count++;
            }

            startX = rect.X + panOffset.X;
            if (model != null)
            {
                e.Graphics.FillRectangle(playbackheaderBrush, startX, startY + direction * 2, (int)TimeToPixels(model.Duration), 2);
            }

            Rectangle triangleRect = GetPlaybackHeaderRect();

            triangleRect.Y     += OrientationUp ? (triangleRect.Height - triangleRect.Width) : 0;
            triangleRect.Height = triangleRect.Width;
            DrawingUtils.FillTriangle(e.Graphics, triangleRect, PlaybackHeaderColor, OrientationUp ? 0.0f : 180.0f);

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            foreach (Annotation annotation in annotationList)
            {
                RectangleF annotationRect = GetAnnotationRectangle(annotation);

                Brush annotationBrush = new System.Drawing.Drawing2D.LinearGradientBrush(annotationRect, annotation == selectedAnnotation ? SelectedAnnotationColor : AnnotationColor, Color.White, System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal);

                e.Graphics.FillEllipse(annotationBrush, annotationRect);
                e.Graphics.DrawEllipse(foregroundPen, annotationRect);
                e.Graphics.DrawLine(foregroundPen, annotationRect.X + annotationRect.Width / 2.0f, 15.0f, annotationRect.X + annotationRect.Width / 2.0f, 100.0f);

                annotationBrush.Dispose();
            }
            e.Graphics.SmoothingMode = SmoothingMode.None;

            foregroundBrush.Dispose();
            foregroundPen.Dispose();
        }
示例#57
0
        public static Bitmap getMaskBMP(string text)
        {
            Bitmap bitmap;

            string[]      strArray = text.Split(new char[] { ',' });
            int           width    = 0;
            int           height   = 0;
            int           num3     = 0;
            int           num4     = 0;
            List <Bitmap> list     = new List <Bitmap>();

            for (int i = 0; i < strArray.Length; i++)
            {
                string str = strArray[i].Trim();
                if (string.IsNullOrEmpty(str) || str == "\n" || str == "\r" || str == "\n\r")
                {
                    str = "*";
                }
                PointF           origin = new PointF(0f, 0f);
                CharacterRange[] ranges = new CharacterRange[] { new CharacterRange(0, str.Length) };
                new StringFormat().SetMeasurableCharacterRanges(ranges);
                int          emHeight    = defaultFont.FontFamily.GetEmHeight(defaultFont.Style);
                int          cellAscent  = defaultFont.FontFamily.GetCellAscent(defaultFont.Style);
                int          cellDescent = defaultFont.FontFamily.GetCellDescent(defaultFont.Style);
                int          lineSpacing = defaultFont.FontFamily.GetLineSpacing(defaultFont.Style);
                int          num10       = (int)Math.Round((double)((defaultFont.Size * (lineSpacing - cellAscent)) / ((float)emHeight)));
                GraphicsPath path        = new GraphicsPath();
                path.AddString(str, defaultFont.FontFamily, (int)defaultFont.Style, (defaultFont.Size * 96f) / 72f, origin, StringFormat.GenericDefault);
                System.Drawing.Brush brush = new System.Drawing.Drawing2D.LinearGradientBrush(path.GetBounds(), maskUPColor, maskDownColor, LinearGradientMode.Vertical);
                if (i < (strArray.Length - 1))
                {
                    num3 = (int)Math.Round((double)((path.GetBounds().Width + path.GetBounds().X) + (path.GetBounds().X / 2f)));
                }
                else
                {
                    num3 = (int)Math.Round((double)(path.GetBounds().Width + (path.GetBounds().X * 2f)));
                }
                num4   = (int)Math.Round((double)(path.GetBounds().Height + (path.GetBounds().Y * 2f)));
                bitmap = new Bitmap(num3, num4);
                Graphics graphics = Graphics.FromImage(bitmap);
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.DrawPath(new System.Drawing.Pen(penColor, (float)penWidth), path);
                graphics.FillPath(brush, path);
                path.Dispose();
                brush.Dispose();
                graphics.Dispose();
                list.Add(bitmap);
                if (num4 > height)
                {
                    height = num4;
                }
                width += num3;
            }
            bitmap = new Bitmap(width, height);
            Graphics graphics2 = Graphics.FromImage(bitmap);

            width = 0;
            foreach (Bitmap bitmap2 in list)
            {
                graphics2.DrawImage(bitmap2, new Point(width, 0));
                width += bitmap2.Width;
                bitmap2.Dispose();
            }
            graphics2.Dispose();
            list.Clear();
            return(bitmap);
        }
示例#58
0
        //Draws the bar and the white rectangle
        void DrawRectangularButton(Graphics g)
        {
            Color c1 = Color.FromArgb(color1Transparent, color1);
            Color c2 = Color.FromArgb(color2Transparent, color2);

            //Bar
            Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, c1, c2, angle);

            g.FillRectangle(b, 0, 0, this.Width, this.Height);


            for (int i = 0; i < borderWidth; i++)
            {
                g.DrawLine(new Pen(new SolidBrush(buttonborder_1)), this.Width - i, 0, this.Width - i, this.Height);
                g.DrawLine(new Pen(new SolidBrush(buttonborder_1)), 0, this.Height - i, this.Width, this.Height - i);

                g.DrawLine(new Pen(new SolidBrush(buttonborder_2)), 0 + i, 0, 0 + i, this.Height);
                g.DrawLine(new Pen(new SolidBrush(buttonborder_2)), 0, 0 + i, this.Width, i);
            }

            //White rectangle
            Brush b2 = new SolidBrush(Color.White);

            //actualValue=0;;actualValue=a lo que sea
            //cursorPosition=0;;cursorPosition=6

            //Normalizar los valores
            if ((actualValue - cursorPosition) > 2)
            {
                actualValue -= 1;
            }

            if ((actualValue - cursorPosition) <= -1)
            {
                actualValue += 1;
            }


            if (actualValue >= 1 && actualValue <= 7)
            {
                cursorPosition = actualValue - 1;
            }

            if (actualValue != 7)//Para pintar el trozo final de la barra de blanco
            {
                g.FillRectangle(b2, cursorPosition * (this.Width / 7), 0, this.Width / 7, this.Height);
            }
            else
            {
                g.FillRectangle(b2, cursorPosition * (this.Width / 7), 0, this.Width, this.Height);
            }


            //Black Marks
            Brush b3 = new SolidBrush(Color.Black);

            for (int i = 0; i < 8; i++)
            {
                g.DrawLine(new Pen(Color.Black), i * (this.Width / 7), 0, i * (this.Width / 7), this.Height);
            }
            //g.DrawLine(new Pen(new SolidBrush(Color.Black)), cursorLevel * (this.Width / 7), this.Height, this.Width / 7, this.Height);

            /*Brush b3 = new SolidBrush(Color.Black);
             * Pen pen = new Pen(b3);
             * Point[] points = {
             *  new Point(0, 0),
             *  new Point(this.Width / 7, this.Height /7),
             *  new Point(0, this.Height / 7)
             * };
             * g.DrawPolygon(pen, points);
             */
            if (showButtonText)
            {
                Point      p       = new Point(textX, textY);
                SolidBrush frcolor = new SolidBrush(this.ForeColor);
                g.DrawString(text, this.Font, frcolor, p);
            }


            b.Dispose();
        }
示例#59
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            // base.onpaint (e);

            // System.Drawing.Graphics pp=this.creategraphics();

            // e.Graphics.clear(Color.transparent);

            // e.Graphics.drawellipse(new System.Drawing.Pen(System.Drawing.Color.whitesmoke,5),0,0,this.Width,this.Height);

            // System.Drawing.solidbrush dd=new solidbrush(System.Drawing.Color.whitesmoke);

            // e.Graphics.fillellipse(dd,0,0,this.Width,this.Height);



            // (this.backcolor.tostring ())

            Color c5 = Color.FromArgb

                           (255, 255, 255);

            Color c2 = Color.FromArgb

                           (192, 192, 192);

            if (mouseover)
            {
                c5 = Color.FromArgb(245, 245, 245);

                //c2=Color.FromArgb(192,192,192);

                c2 = Color.FromArgb(180, 175, 190);
            }

            Brush b = new System.Drawing.Drawing2D.LinearGradientBrush

                          (ClientRectangle, c5, c2, LinearGradientMode.Vertical);

            //System.Drawing.region=new region(

            int offsetwidth = this.Width / 50;

            Point[] points = new Point[8];

            points[0].X = offsetwidth;

            points[0].Y = 0;



            points[1].X = this.Width - offsetwidth;

            points[1].Y = 0;



            points[2].X = this.Width;

            points[2].Y = offsetwidth;



            points[3].X = this.Width;

            points[3].Y = this.Height - offsetwidth;



            points[4].X = this.Width - offsetwidth;

            points[4].Y = this.Height;



            points[5].X = offsetwidth;

            points[5].Y = this.Height;



            points[6].X = 0;

            points[6].Y = this.Height - offsetwidth;



            points[7].X = 0;

            points[7].Y = offsetwidth;

            // e.Graphics.fillrectangle (b, ClientRectangle);

            e.Graphics.FillPolygon(b, points, FillMode.Winding);

            if (this.Focused)
            {
                int offsetwidth1 = (this.Width - 5) / 50 + 2;

                Point[] points1 = new Point[8];

                points1[0].X = offsetwidth1;

                points1[0].Y = 2;



                points1[1].X = this.Width - offsetwidth1;

                points1[1].Y = 2;



                points1[2].X = this.Width - 1;

                points1[2].Y = offsetwidth1;



                points1[3].X = this.Width - 1;

                points1[3].Y = this.Height - offsetwidth1;



                points1[4].X = this.Width - offsetwidth1;

                points1[4].Y = this.Height - 1;



                points1[5].X = 1;

                points1[5].Y = this.Height - 1;



                points1[6].X = 2;

                points1[6].Y = this.Height - offsetwidth1;



                points1[7].X = 2;

                points1[7].Y = offsetwidth1;

                // e.Graphics.drawpolygon(new Pen(Color.yellow,2),points1);

                Pen p = new Pen(Color.Orange, 2);

                Pen p1 = new Pen(Color.Wheat, 2);

                //p.dashstyle=dashstyle.dashdot;

                e.Graphics.DrawLine(p1, points1[0], points1[1]);



                e.Graphics.DrawLine(p, points1[1], points1[2]);

                e.Graphics.DrawLine(p, points1[2], points1[3]);

                e.Graphics.DrawLine(p, points1[3], points1[4]);

                e.Graphics.DrawLine(p, points1[4], points1[5]);

                e.Graphics.DrawLine(p, points1[5], points1[6]);

                e.Graphics.DrawLine(p1, points1[6], points1[7]);

                e.Graphics.DrawLine(p1, points1[7], points1[0]);
            }

            e.Graphics.DrawPolygon(new Pen(Color.DarkBlue, 2), points);

            // e.Graphics.DrawLine(new Pen(Color.darkblue,2),new Point(0,0),new Point(this.Width,0));

            // e.Graphics.DrawLine(new Pen(Color.darkblue,2),new Point(0,0),new Point(0,this.Height));

            // e.Graphics.DrawLine(new Pen(Color.darkblue,2),new Point(this.Width,this.Height),new Point(this.Width,0));

            // e.Graphics.DrawLine(new Pen(Color.darkblue,2),new Point(this.Width,this.Height),new Point(0,this.Height));

            StringFormat drawformat = new StringFormat();

            drawformat.FormatFlags = StringFormatFlags.DisplayFormatControl;

            drawformat.LineAlignment = StringAlignment.Center;

            drawformat.Alignment = System.Drawing.StringAlignment.Center;



            e.Graphics.DrawString(this.Text, this.Font, new LinearGradientBrush(this.ClientRectangle, Color.Black, Color.Black, LinearGradientMode.Vertical), this.ClientRectangle, drawformat);

            b.Dispose();
        }
示例#60
0
        /// <summary>
        /// Draws the recommended and threshold ranges on the gauge
        /// </summary>
        /// <param name="g"></param>
        private void DrawRanges(Graphics g)
        {
            if (m_ShowRanges)
            {
                // draw recommended range
                Pen       p         = new Pen(Color.FromArgb(m_alphaForGaugeColors, m_BevelLineColor));
                float     range     = m_maxValue - m_minValue;
                Rectangle scalerect = new Rectangle(rcentre.X, rcentre.Y + rcentre.Height + 1, rcentre.Width, 6);
                //scalerect.Inflate(-1, -1);

                if (m_recommendedValue >= m_minValue && m_recommendedValue < m_maxValue)
                {
                    // calculate range based on percentage
                    // percentage = percentage of entire scale!
                    System.Drawing.Drawing2D.LinearGradientBrush gb = new System.Drawing.Drawing2D.LinearGradientBrush(scalerect, m_BackGroundColor, m_recommendedRangeColor, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                    float centerpercentage           = (m_recommendedValue - m_minValue) / range;
                    float recommendedstartpercentage = centerpercentage;
                    recommendedstartpercentage -= (float)m_recommendedPercentage / 200;
                    float recommendedendpercentage = centerpercentage;
                    recommendedendpercentage += (float)m_recommendedPercentage / 200;
                    float     startx         = scalerect.Width * recommendedstartpercentage;
                    float     endx           = scalerect.Width * recommendedendpercentage;
                    float     centerx        = scalerect.Width * centerpercentage;
                    Rectangle startfillrect  = new Rectangle(scalerect.X + (int)startx, scalerect.Y, (int)centerx - (int)startx, scalerect.Height);
                    Rectangle startcolorrect = startfillrect;
                    startcolorrect.Inflate(1, 0);

                    System.Drawing.Drawing2D.LinearGradientBrush gb1 = new System.Drawing.Drawing2D.LinearGradientBrush(startcolorrect, Color.Transparent, m_recommendedRangeColor, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
                    g.FillRectangle(gb1, startfillrect);
                    Rectangle endfillrect  = new Rectangle(scalerect.X + (int)centerx, scalerect.Y, (int)endx - (int)centerx, scalerect.Height);
                    Rectangle endcolorrect = endfillrect;
                    endcolorrect.Inflate(1, 0);
                    System.Drawing.Drawing2D.LinearGradientBrush gb2 = new System.Drawing.Drawing2D.LinearGradientBrush(endcolorrect, m_recommendedRangeColor, Color.Transparent, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
                    g.FillRectangle(gb2, endfillrect);
                    g.DrawRectangle(p, startfillrect.X, startfillrect.Y, startfillrect.Width + endfillrect.Width, startfillrect.Height);
                    gb.Dispose();
                    gb1.Dispose();
                    gb2.Dispose();
                }

                // draw threshold
                if (m_thresholdValue >= m_minValue && m_thresholdValue < m_maxValue)
                {
                    // percentage
                    float percentage = (m_thresholdValue - m_minValue) / range;
                    if (percentage > 1)
                    {
                        percentage = 1;
                    }
                    if (percentage < 0)
                    {
                        percentage = 0;
                    }
                    float     startx        = scalerect.Width * percentage;
                    Rectangle fillrect      = new Rectangle(scalerect.X + (int)startx, scalerect.Y, scalerect.Width - (int)startx, scalerect.Height);
                    Rectangle fillcolorrect = fillrect;
                    fillcolorrect.Inflate(1, 0);
                    System.Drawing.Drawing2D.LinearGradientBrush gb = new System.Drawing.Drawing2D.LinearGradientBrush(fillcolorrect, Color.Transparent, m_thresholdColor, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
                    g.FillRectangle(gb, fillrect);
                    // nog een rectangle erom heen?
                    g.DrawRectangle(p, fillrect);
                    gb.Dispose();
                }
                p.Dispose();
            }
        }