Example #1
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);
            rects = new List <Rectangle>();
            //Rectangle rec = new Rectangle(Width - 40, (CaptionHeight - 15) / 2, 35, 15);
            //GraphicsPath fk = GetGraphicPath.CreatePath(rec, 4, RoundStyle.All, false);
            //e.Graphics.DrawPath(new Pen(Color.Gray), fk);

            if (_ZDownVisible)
            {
                Rectangle rec = new Rectangle(Width - 20, (CaptionHeight - 15) / 2, 17, 15);
                if (_cstate == ControlState.Pressed)
                {
                    GraphicsPath fk = GetGraphicPath.CreatePath(rec, 4, RoundStyle.All, false);
                    e.Graphics.DrawPath(new Pen(Color.Gray), fk);
                }
                ControlPaintClass.RenderArrowInternal(e.Graphics, rec, _isExplan ? ArrowDirection.Up : ArrowDirection.Down, new SolidBrush(Color.Black));
                rects.Add(rec);
            }

            if (_ZImageVisible)
            {
                Rectangle rec1 = new Rectangle(Width - 35, (CaptionHeight - 10) / 2, 10, 10);
                if (_cstate == ControlState.Hover)
                {
                    Rectangle    rec11 = new Rectangle(Width - 40, (CaptionHeight - 15) / 2, 20, 15);
                    GraphicsPath fk    = GetGraphicPath.CreatePath(rec11, 4, RoundStyle.All, false);
                    e.Graphics.DrawPath(new Pen(Color.Gray), fk);
                }
                e.Graphics.DrawImage(Zcl, rec1);
                rects.Add(rec1);
            }
        }
Example #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            if (_JMBorderStyle)
            {
                switch (_JMRoundStyle)
                {
                case RoundStyle.None:
                    g.DrawRectangle(new Pen(_JMBorderLineColor, 1), 0, 0, this.Width - 1, this.Height - 1);
                    break;

                case RoundStyle.All:
                    GraphicsPath gp  = new GraphicsPath();
                    GraphicsPath gp1 = new GraphicsPath();

                    Rectangle rec  = new Rectangle(new Point(0, 0), new Size(this.Size.Width - 1, this.Size.Height - 1));
                    Rectangle rec1 = new Rectangle(new Point(0, 0), new Size(this.Size.Width, this.Size.Height));

                    gp          = GetGraphicPath.CreatePath(rec, _JMRadius, _JMRoundStyle, true);
                    gp1         = GetGraphicPath.CreatePath(rec1, _JMRadius, _JMRoundStyle, true);
                    this.Region = new Region(gp1);

                    g.DrawPath(new Pen(new SolidBrush(_JMBorderLineColor)), gp);
                    break;
                }
            }
        }
Example #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            int beforwidth = 1;

            Color textcolor = ForeColor;
            Font  textFont  = Font;

            if (IsEnter == SelectType.TextSelect)
            {
                Rectangle    rect = new Rectangle(0, 0, Width, Height);
                GraphicsPath aa   = GetGraphicPath.CreatePath(base.ClientRectangle, 5, RoundStyle.Left, true);
                g.FillPath(new SolidBrush(Color.FromArgb(204, 225, 210)), aa);
                //textcolor = Color.Blue;
                //textFont = new Font(Font.Name, Font.Size, FontStyle.Underline);
            }

            if (!IsExpland)
            {
                //g.DrawImage(Properties.Resources.TreePlus, new Point(3, 2));
                beforwidth += C_ImgHeight;
            }


            g.DrawString(ZText, textFont, new SolidBrush(textcolor), beforwidth, 2);
        }
Example #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            Image img = _JMImage;
            Color col = _JMFrameLineColor;

            Rectangle rect = new Rectangle(0, 0, this.Width - 1, this.Height - 1);

            GraphicsPath FW = GetGraphicPath.CreatePath(rect, 6, RoundStyle.None, true);

            //g.FillPath(new SolidBrush(Color.White), FW);
            if (bl)
            {
                img = _JMEnterImage;
                col = _JMEnterLineColor;
            }

            g.DrawPath(new Pen(col), FW);

            if (img != null)
            {
                Rectangle rec = new Rectangle(_JMImageLocation, _JMImgaeSize);
                g.DrawImage(img, rec);
            }
        }
Example #5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            Rectangle    rec  = new Rectangle(0, 0, Width - 1, Height - 1);
            GraphicsPath path = GetGraphicPath.CreatePath(rec, 23, RoundStyle.None, true);

            g.FillPath(new SolidBrush(Color.White), path);
            g.DrawPath(new Pen(_borderColor), path);
            rec.Offset(0, 1);

            g.DrawRectangle(new Pen(_borderColor), rec);

            //path = GetGraphicPath.CreatePathTOP(rec, 19, false, 45);
            //g.DrawPath(new Pen(ColorClass.GetColor(_borderColor, 0, -20, -20, -20)), path);

            recDrop = new Rectangle(Width - 28, 5, 20, 16);
            //if (_mouse)
            //{
            Rectangle    recDrop1 = new Rectangle(Width - 26, 0, 28, 23);
            GraphicsPath pathDrop = GetGraphicPath.CreateVPath(recDrop1);

            g.DrawPath(new Pen(ColorClass.GetColor(_borderColor, 0, -20, -20, -20), 3), pathDrop);
            //}
        }
Example #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            Rectangle    rect        = new Rectangle(myPadding, myPadding, Width - myPadding * 2, Height - myPadding * 2);
            GraphicsPath Borderpath  = GetGraphicPath.CreatePath(rect, 8, RoundStyle.All, false);
            Color        Bordercolor = Color.FromArgb(198, 198, 198);

            if (tMouseEnter)
            {
                Bordercolor = Color.FromArgb(255, 128, 0);
                string str = ZMoney.ToString("N2");
                if (_isLock)
                {
                    str = "LOCK";
                }
                Rectangle    rectText = new Rectangle(myimgPadding, myimgPadding, imgsize.Width, imgsize.Height);
                StringFormat sf       = new StringFormat();
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                sf.Trimming      = StringTrimming.EllipsisCharacter;
                g.DrawString(str, Font, new SolidBrush(ForeColor), rectText, sf);

                //右上角 删除
                //Rectangle rectClose = new Rectangle(Width-18, 5, 12, 12);
                //g.FillRectangle(Brushes.Red, rectClose);
            }
            else
            {
                if (_img != null)
                {
                    Rectangle rectimg = new Rectangle(myimgPadding, myimgPadding, imgsize.Width, imgsize.Height);
                    g.DrawImage(_img, rectimg);
                }
            }

            if (!string.IsNullOrEmpty(_text))
            {
                Rectangle    rectText = new Rectangle(myimgPadding, Height - myimgPadding * 2, imgsize.Width + 2, myimgPadding * 1 + 5);
                StringFormat sf       = new StringFormat();
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                sf.Trimming      = StringTrimming.EllipsisCharacter;

                string str = _text;
                if (_text.Length > 5)
                {
                    str = _text.Substring(0, 5);
                }
                g.DrawString(str, Font, new SolidBrush(ForeColor), rectText, sf);
            }

            g.DrawPath(new Pen(Bordercolor), Borderpath);
        }
Example #7
0
        /// <summary>
        /// 画滚动条背景
        /// </summary>
        /// <param name="g"></param>
        private void DrawBack(Graphics g)
        {
            int x   = Width - ScrollWidth;
            int y   = this.Padding.Top;
            int wid = ScrollWidth;
            int hei = Height - this.Padding.Bottom - this.Padding.Top;

            Rectangle           rect = new Rectangle(x, y, wid, hei);
            GraphicsPath        path = GetGraphicPath.CreatePath(rect, round, RoundStyle.All, true);
            LinearGradientBrush lb   = new LinearGradientBrush(rect, Color.FromArgb(0, 61, 130), Color.FromArgb(0, 61, 130), LinearGradientMode.Horizontal);

            g.FillPath(lb, path);
        }
Example #8
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            Color col = _JMFrameLineColor;

            Rectangle rect = new Rectangle(0, 0, this.Width - 1, this.Height - 1);

            GraphicsPath FW = GetGraphicPath.CreatePath(rect, 6, RoundStyle.None, true);

            if (bl)
            {
                col = _JMEnterLineColor;
            }

            g.DrawPath(new Pen(col), FW);
        }
Example #9
0
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            //base.OnPaintBackground(e);
            Graphics g = e.Graphics;

            g.SmoothingMode   = SmoothingMode.HighQuality;   //高质量
            g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量

            g.DrawRectangle(new Pen(BackColor), this.ClientRectangle);

            //填充按钮颜色效果
            GraphicsPath gPath = GetGraphicPath.CreatePath(base.ClientRectangle, _radius, RoundStyle.All, true);

            gPath.CloseFigure();
            g.FillPath(new LinearGradientBrush(base.ClientRectangle, _backColorbegin, _backColorend, LinearGradientMode.Vertical), gPath);
            g.DrawPath(new Pen(new SolidBrush(_borderColor)), gPath);
            //g.SetClip(gPath);
        }
Example #10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            Rectangle rect = new Rectangle(0, 0, this.Width - 1, this.Height - 1);

            GraphicsPath aa = GetGraphicPath.CreatePath(rect, _ZRadian, RoundStyle.All, false);

            //aa.CloseFigure();
            g.FillPath(new SolidBrush(Color.White), aa);
            g.DrawPath(new Pen(_borderColor), aa);

            rect.Offset(0, 1);
            aa = GetGraphicPath.CreatePathTOP(rect, _ZRadian, false, 45);
            g.DrawPath(new Pen(ColorClass.GetColor(_borderColor, 0, -20, -20, -20)), aa);
        }
Example #11
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == Animate.WM_PAINT || m.Msg == 0x133)
            {
                IntPtr hDC = Win32.GetWindowDC(m.HWnd);
                if (hDC.ToInt32() == 0)
                {
                    return;
                }
                if (_JMBorderStyle)
                {
                    Graphics g = Graphics.FromHdc(hDC);
                    switch (_JMRoundStyle)
                    {
                    case RoundStyle.None:
                        g.DrawRectangle(new Pen(_JMBorderLineColor, 1), 0, 0, this.Width - 1, this.Height - 1);
                        break;

                    case RoundStyle.All:
                        GraphicsPath gp  = new GraphicsPath();
                        GraphicsPath gp1 = new GraphicsPath();

                        Rectangle rec  = new Rectangle(new Point(0, 0), new Size(this.Size.Width - 1, this.Size.Height - 1));
                        Rectangle rec1 = new Rectangle(new Point(0, 0), new Size(this.Size.Width, this.Size.Height));

                        gp          = GetGraphicPath.CreatePath(rec, _JMRadius, _JMRoundStyle, true);
                        gp1         = GetGraphicPath.CreatePath(rec1, _JMRadius, _JMRoundStyle, true);
                        this.Region = new Region(gp1);

                        g.DrawPath(new Pen(new SolidBrush(_JMBorderLineColor)), gp);
                        break;
                    }
                }
                m.Result = IntPtr.Zero;
                Win32.ReleaseDC(m.HWnd, hDC);
            }
        }
Example #12
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            Graphics g = pe.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            Rectangle rec = new Rectangle(0, 0, Width - 1, Height - 1);

            if (_SFVisibleClose)
            {
                if (_isMouseIn || _isFoucs)
                {
                    g.DrawRectangle(new Pen(Color.FromArgb(200, 100, 100, 100), 2), rec);
                    recX = new Rectangle(Width - 1 - 20, 0, 20, 20);
                    g.FillRectangle(new SolidBrush(Color.FromArgb(200, 0, 0, 150)), recX);
                    GraphicsPath pathX = GetGraphicPath.CreateCloseFlagPath(recX);

                    Color cl = _isMinX ? Color.Red : Color.White;
                    g.FillPath(new SolidBrush(cl), pathX);
                }
            }
        }
Example #13
0
        /// <summary>
        /// 画圆角渐变矩形
        /// </summary>
        /// <param name="g">画布</param>
        /// <param name="rect">矩形区域</param>
        /// <param name="baseColor">填充颜色</param>
        /// <param name="borderColor">外边框颜色</param>
        /// <param name="innerBorderColor">内边框颜色</param>
        /// <param name="style">圆角样式</param>
        /// <param name="roundWidth">圆角弧度</param>
        /// <param name="basePosition">渐变占用比率(0.5为一半)</param>
        /// <param name="drawBorder">是否画边框</param>
        /// <param name="drawGlass">是否画高亮区域</param>
        /// <param name="GlassLight">高亮亮度</param>
        /// <param name="mode">渐变方向</param>
        internal static void RenderBackgroundInternal(
            Graphics g,
            Rectangle rect,
            Color baseColor,
            Color borderColor,
            Color innerBorderColor,
            RoundStyle style,
            int roundWidth,
            float basePosition,
            bool drawBorder,
            bool drawGlass,
            int GlassLight,
            LinearGradientMode mode)
        {
            if (drawBorder)
            {
                rect.Width--;
                rect.Height--;
            }

            using (LinearGradientBrush brush = new LinearGradientBrush(
                       rect, Color.Transparent, Color.Transparent, mode))
            {
                Color[] colors = new Color[4];
                colors[0] = ColorClass.GetColor(baseColor, 0, 35, 24, 9);
                colors[1] = ColorClass.GetColor(baseColor, 0, 13, 8, 3);
                colors[2] = baseColor;
                colors[3] = ColorClass.GetColor(baseColor, 0, 35, 24, 9);

                ColorBlend blend = new ColorBlend();
                blend.Positions           = new float[] { 0.0f, basePosition, basePosition + 0.05f, 1.0f };
                blend.Colors              = colors;
                brush.InterpolationColors = blend;
                if (style != RoundStyle.None)
                {
                    using (GraphicsPath path =
                               GetGraphicPath.CreatePath(rect, roundWidth, style, false))
                    {
                        g.FillPath(brush, path);
                    }

                    if (baseColor.A > 80)
                    {
                        Rectangle rectTop = rect;

                        if (mode == LinearGradientMode.Vertical)
                        {
                            rectTop.Height = (int)(rectTop.Height * basePosition);
                        }
                        else
                        {
                            rectTop.Width = (int)(rect.Width * basePosition);
                        }
                        using (GraphicsPath pathTop = GetGraphicPath.CreatePath(
                                   rectTop, roundWidth, RoundStyle.Top, false))
                        {
                            using (SolidBrush brushAlpha =
                                       new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
                            {
                                g.FillPath(brushAlpha, pathTop);
                            }
                        }
                    }

                    if (drawGlass)
                    {
                        RectangleF glassRect = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            glassRect.Y      = rect.Y + rect.Height * basePosition;
                            glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
                        }
                        else
                        {
                            glassRect.X     = rect.X + rect.Width * basePosition;
                            glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
                        }
                        DrawGlass(g, glassRect, GlassLight, 0);
                    }

                    if (drawBorder)
                    {
                        using (GraphicsPath path =
                                   GetGraphicPath.CreatePath(rect, roundWidth, style, false))
                        {
                            using (Pen pen = new Pen(borderColor))
                            {
                                g.DrawPath(pen, path);
                            }
                        }

                        rect.Inflate(-1, -1);
                        using (GraphicsPath path =
                                   GetGraphicPath.CreatePath(rect, roundWidth, style, false))
                        {
                            using (Pen pen = new Pen(innerBorderColor))
                            {
                                g.DrawPath(pen, path);
                            }
                        }
                    }
                }
                else
                {
                    g.FillRectangle(brush, rect);
                    if (baseColor.A > 80)
                    {
                        Rectangle rectTop = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            rectTop.Height = (int)(rectTop.Height * basePosition);
                        }
                        else
                        {
                            rectTop.Width = (int)(rect.Width * basePosition);
                        }
                        using (SolidBrush brushAlpha =
                                   new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
                        {
                            g.FillRectangle(brushAlpha, rectTop);
                        }
                    }

                    if (drawGlass)
                    {
                        RectangleF glassRect = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            glassRect.Y      = rect.Y + rect.Height * basePosition;
                            glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
                        }
                        else
                        {
                            glassRect.X     = rect.X + rect.Width * basePosition;
                            glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
                        }
                        DrawGlass(g, glassRect, GlassLight, 0);
                    }

                    if (drawBorder)
                    {
                        using (Pen pen = new Pen(borderColor))
                        {
                            g.DrawRectangle(pen, rect);
                        }

                        rect.Inflate(-1, -1);
                        using (Pen pen = new Pen(innerBorderColor))
                        {
                            g.DrawRectangle(pen, rect);
                        }
                    }
                }
            }
        }
Example #14
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == Animate.WM_PAINT || m.Msg == 0x133)
            {
                IntPtr hDC = Win32.GetWindowDC(m.HWnd);
                if (hDC.ToInt32() == 0)
                {
                    return;
                }
                if (_JMBorderStyle)
                {
                    Graphics g = Graphics.FromHdc(hDC);
                    switch (_JMRoundStyle)
                    {
                    case RoundStyle.None:
                        g.DrawRectangle(new Pen(_JMBorderLineColor, 1), 0, 0, this.Width - 1, this.Height - 1);
                        break;

                    case RoundStyle.All:
                        GraphicsPath gp  = new GraphicsPath();
                        GraphicsPath gp1 = new GraphicsPath();

                        Rectangle rec  = new Rectangle(new Point(0, 0), new Size(this.Size.Width - 1, this.Size.Height - 1));
                        Rectangle rec1 = new Rectangle(new Point(0, 0), new Size(this.Size.Width, this.Size.Height));

                        gp          = GetGraphicPath.CreatePath(rec, _JMRadius, _JMRoundStyle, true);
                        gp1         = GetGraphicPath.CreatePath(rec1, _JMRadius, _JMRoundStyle, true);
                        this.Region = new Region(gp1);

                        g.DrawPath(new Pen(new SolidBrush(_JMBorderLineColor)), gp);
                        break;
                    }
                }
                if (_JMTitleImageVisible)
                {
                    if (_JMTitleImage != null)
                    {
                        Graphics  g    = Graphics.FromHdc(hDC);
                        Rectangle rect = new Rectangle(_JMTiTleImageLocation, _JMTitleImageSize);
                        g.DrawImage(_JMTitleImage, rect);
                    }
                }
                if (_JMTitleVisible)
                {
                    if (_JMTitle != "")
                    {
                        Graphics   g         = Graphics.FromHdc(hDC);
                        SizeF      titlesize = g.MeasureString(_JMTitle, this.Font);
                        RectangleF rect      = new RectangleF(_JMTitleLocation, titlesize);
                        g.DrawString(_JMTitle, this.Font, new SolidBrush(_JMTitleColor), rect);
                    }
                }
                if (_JMTitleTZVisible)
                {
                    if (_JMTitleTiaoZhuan != null)
                    {
                        Graphics  g    = Graphics.FromHdc(hDC);
                        Rectangle rect = new Rectangle(_JMTitleTZLocation, _JMTitleTZSize);
                        g.DrawImage(_JMTitleTiaoZhuan, rect);
                    }
                }

                //m.Result = IntPtr.Zero;
                Win32.ReleaseDC(m.HWnd, hDC);
            }
        }
Example #15
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            base.OnPaintBackground(e);

            Rectangle rectangle;  //图片范围
            Rectangle rectangle2; //字体范围

            this.CalculateRect(out rectangle, out rectangle2);

            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            if (base.Enabled)
            {
                //填充按钮颜色效果
                GraphicsPath aa = GetGraphicPath.CreatePath(base.ClientRectangle, _JMRadius, RoundStyle.All, true);
                aa.CloseFigure();

                //加载鼠标进入效果
                if (SFVisibleEffect)
                {
                    Color        col1 = ColorClass.GetColor(_JMBaseColorTwo, 0, -20, -20, -20);
                    Color        col2 = ColorClass.GetColor(_JMBaseColor, 0, -20, -20, -20);
                    GraphicsPath bb   = GetGraphicPath.CreatePath(base.ClientRectangle, _JMRadius, RoundStyle.All, true);
                    bb.CloseFigure();
                    g.FillPath(new LinearGradientBrush(base.ClientRectangle, col1, col2, LinearGradientMode.Vertical), bb);
                    g.DrawPath(new Pen(new SolidBrush(Color.DarkGray)), aa);
                }
                else if (SFDownEffect)//加载鼠标按下效果 || Focused
                {
                    Color        col1 = ColorClass.GetColor(_JMBaseColorTwo, 0, -35, -35, -35);
                    Color        col2 = ColorClass.GetColor(_JMBaseColor, 0, -35, -35, -35);
                    GraphicsPath cc   = GetGraphicPath.CreatePath(base.ClientRectangle, _JMRadius, RoundStyle.All, true);
                    cc.CloseFigure();
                    g.FillPath(new LinearGradientBrush(base.ClientRectangle, col1, col2, LinearGradientMode.Vertical), cc);
                    g.DrawPath(new Pen(new SolidBrush(Color.DarkGray)), aa);
                }
                else
                {
                    g.FillPath(new LinearGradientBrush(base.ClientRectangle, _JMBaseColorTwo, _JMBaseColor, LinearGradientMode.Vertical), aa);
                    g.DrawPath(new Pen(new SolidBrush(Color.DarkGray)), aa);
                }
                //加载图片
                if (base.Image != null)
                {
                    g.InterpolationMode = InterpolationMode.HighQualityBilinear;
                    g.DrawImage(base.Image, rectangle);
                }
            }
            else//不可用为“灰色”
            {
                //填充按钮颜色效果
                GraphicsPath aa = GetGraphicPath.CreatePath(base.ClientRectangle, _JMRadius, RoundStyle.All, true);
                aa.CloseFigure();
                g.FillPath(new LinearGradientBrush(base.ClientRectangle, SystemColors.ControlDark, SystemColors.ControlDark, LinearGradientMode.Vertical), aa);
                g.DrawPath(new Pen(new SolidBrush(Color.DarkGray)), aa);
            }

            //加载文字
            TextRenderer.DrawText(g, this.Text, this.Font, rectangle2, this.ForeColor, TextFormat.GetTextFormatFlags(this.TextAlign, this.RightToLeft == RightToLeft.Yes));

            if (_JMSFNew)
            {
                e.Graphics.DrawImage(Properties.Resources._new, new Rectangle(Width - 12, Height / 2 - 5, 10, 10));
            }
        }
Example #16
0
        /// <summary>
        /// 画饼图
        /// </summary>
        /// <param name="g">画布</param>
        private void DrawChart(Graphics g)
        {
            CanMoveScroll = 0;
            Rectangle rec = new Rectangle(Padding.Left, Padding.Top, PieWidth, PieHeight);//

            //起始角度
            float startAngle = 0f;
            //弧度
            float sweepAngle = 0f;


            PointF startP = new PointF(PieWidth, PieOrigin.Y);
            PointF endP   = new PointF(0, PieOrigin.Y);

            if (m_values == null)
            {
                Color itc = Color.Gray;
                sweepAngle = 360;

                g.FillPie(new SolidBrush(itc), rec, startAngle, sweepAngle);
                g.DrawPie(new Pen(Color.FromArgb(224, 224, 224)), rec, startAngle, sweepAngle);

                //画底部
                if (startAngle < 180)
                {
                    float        endang = startAngle + sweepAngle > 180 ? 180 : startAngle + sweepAngle;
                    GraphicsPath gpath  = GetGraphicPath.CreatePathForCylinderSurfaceSection(rec, startAngle, endang, startP, endP, m_height3D);
                    g.FillPath(new SolidBrush(ColorClass.GetColor(itc, 0, -80, -80, -80)), gpath);
                }
                Rectangle rectmx = new Rectangle(180, 20 + 3, 11, 11);
                g.DrawString("无数据", Font, new SolidBrush(ForeColor), new PointF(rectmx.X + rectmx.Width + 5, 20 + 3));
                jmButtonTriangle2.Visible = false;
            }
            else
            {
                //画所有饼块
                for (int i = 0; i < m_values.Length; i++)
                {
                    decimal item = m_values[i];
                    Color   itc  = Color.Black;
                    Color   ite  = new Color();
                    if (m_pieColor.Length - 1 < i)
                    {
                        itc = ColorClass.GetColor(m_pieColor[i % (m_pieColor.Length - 1)], -20, 20, 6, 30);
                    }
                    else
                    {
                        itc = m_pieColor[i];
                    }
                    if (item == 0)
                    {
                        if (sumValue == 0)
                        {
                            ite = Color.Gray;
                            g.FillPie(new SolidBrush(ite), rec, startAngle, 360);
                            g.DrawPie(new Pen(Color.FromArgb(224, 224, 224)), rec, startAngle, 360);
                            sweepAngle = 0;
                        }
                        else
                        {
                            sweepAngle = 0;
                        }
                    }
                    else
                    {
                        sweepAngle = (float)(360 / (sumValue / item));
                    }

                    g.FillPie(new SolidBrush(itc), rec, startAngle, sweepAngle);
                    g.DrawPie(new Pen(Color.FromArgb(224, 224, 224)), rec, startAngle, sweepAngle);

                    //画底部
                    if (startAngle < 180)
                    {
                        float        endang = startAngle + sweepAngle > 180 ? 180 : startAngle + sweepAngle;
                        GraphicsPath gpath  = GetGraphicPath.CreatePathForCylinderSurfaceSection(rec, startAngle, endang, startP, endP, m_height3D);
                        g.FillPath(new SolidBrush(ColorClass.GetColor(sumValue == 0 ? ite : itc, 0, -80, -80, -80)), gpath);
                    }
                    if (m_bool)
                    {
                        if ((i * 20 + 9 + scroll) > 0 && (i * 20 + 9 + scroll) < this.Height - 40)
                        {
                            //画明细
                            Rectangle rectmx = new Rectangle(Padding.Left + PieWidth + 15, (i + 1) * 20 + 3 + scroll, 11, 11);
                            g.FillRectangle(new SolidBrush(itc), rectmx);


                            Rectangle    textRect  = new Rectangle(rectmx.X + rectmx.Width + 3, (i + 1) * 20 + 3 + scroll, 100, 14);
                            Rectangle    valueRect = new Rectangle(rectmx.X + rectmx.Width + 3 + 20, (i + 1) * 20 + 3 + scroll, 100, 14);
                            Rectangle    PMRect    = new Rectangle(rectmx.X + rectmx.Width + 3 + 130, (i + 1) * 20 + 3 + scroll, 100, 14);
                            StringFormat sformat   = new StringFormat();
                            sformat.LineAlignment = StringAlignment.Center;

                            string tiptext = "";
                            string bfbtext = "";
                            string pmtext  = "";
                            if (m_text == null)
                            {
                                tiptext = "";
                                bfbtext = sumValue == 0 ? "0.00%" : (m_values[i] / sumValue).ToString("p");
                                pmtext  = "TOP" + (i + 1);
                            }
                            else if (i >= m_text.Length)
                            {
                                tiptext = "";
                                bfbtext = sumValue == 0 ? "0.00%" : (m_values[i] / sumValue).ToString("p");
                                pmtext  = "TOP" + (i + 1);
                            }
                            else
                            {
                                string st = m_text[i].Length > 5 ? m_text[i].Substring(0, 4).ToString() + "..." : m_text[i];

                                tiptext = st;
                                bfbtext = sumValue == 0 ? "0.00%" : (m_values[i] / sumValue).ToString("p");
                                pmtext  = "TOP" + (i + 1);
                            }

                            g.DrawString(tiptext, this.Font, new SolidBrush(ForeColor), textRect, sformat);

                            sformat.Alignment = StringAlignment.Far;
                            g.DrawString(bfbtext, this.Font, new SolidBrush(ForeColor), valueRect, sformat);

                            sformat.Alignment = StringAlignment.Near;
                            g.DrawString(pmtext, this.Font, new SolidBrush(ForeColor), PMRect, sformat);
                            //g.DrawString(tiptext, Font, new SolidBrush(ForeColor), new PointF(rectmx.X + rectmx.Width + 3, (i + 1) * 20 + 3 + scroll));
                        }
                        else
                        {
                            CanMoveScroll += 20;
                        }
                    }
                    startAngle  += sweepAngle;
                    allRadius[i] = startAngle;
                    //if (CanMoveScroll > 0 && -scroll < CanMoveScroll)
                    //{
                    //    jmButtonTriangle2.Visible = true;
                    //}
                    //else
                    //{
                    //    jmButtonTriangle2.Visible = false;
                    //}
                }

                if (m_bool)
                {
                    if ((m_values.Length > 10 && clickshu == 0) || (m_values.Length > 10 && clickshu < m_values.Length - 10))
                    {
                        jmButtonTriangle2.Visible = true;
                    }
                    else
                    {
                        jmButtonTriangle2.Visible = false;
                    }
                }

                //底部3D
                //GraphicsPath gpath = GetGraphicPath.CreatePathForCylinderSurfaceSection(rec, 120, 180, startP, endP, m_height3D);
                //g.FillPath(new SolidBrush(Color.FromArgb(100, 100, 100)), gpath);

                //g.FillRectangle(Brushes.Blue, recs);
            }
            Rectangle    recs = new Rectangle(40, PieHeight + Padding.Top, 100, 50);
            StringFormat sf   = new StringFormat();

            sf.Alignment     = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;;
            g.DrawString(Text, this.Font, new SolidBrush(Color.Black), recs, sf);
        }
Example #17
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            int _x = this.Padding.Left;
            int _y = this.Padding.Top;
            int _w = Width - _x - this.Padding.Right;
            int _h = Height - _y - this.Padding.Bottom;

            Rectangle rec = new Rectangle(_x, _y, Width, Height);

            //整个灰色 进度条
            Rectangle    recprocess = new Rectangle(_x, (Height - processHeight) / 2, Width, processHeight);
            GraphicsPath proPath    = GetGraphicPath.CreatePath(recprocess, 10, RoundStyle.All, false);

            g.FillPath(new SolidBrush(Color.LightGray), proPath);

            //可用空间 进度条
            int          kyw    = (int)((Width - _x) / maxValue * kyMaxValue);
            Rectangle    recky  = new Rectangle(_x, (Height - processHeight) / 2, kyw, processHeight);
            GraphicsPath kyPath = GetGraphicPath.CreatePath(recky, 10, RoundStyle.Left, false);

            g.FillPath(new SolidBrush(Color.Orange), kyPath);

            //已用空间 进度条
            int yyw = (int)((Width - _x) / maxValue * yyValue);

            if (yyw > 0)
            {
                Rectangle    recyy  = new Rectangle(_x, (Height - processHeight) / 2, yyw, processHeight);
                GraphicsPath yyPath = GetGraphicPath.CreatePath(recyy, 10, RoundStyle.Left, false);
                g.FillPath(new SolidBrush(Color.Blue), yyPath);

                StringFormat sf = new StringFormat();
                sf.Alignment     = StringAlignment.Near;
                sf.LineAlignment = StringAlignment.Center;

                int yyfw = (int)g.MeasureString(" " + yyValue + "mb", Font).Width;
                if (yyw >= yyfw)
                {
                    g.DrawString(" " + yyValue + "mb", Font, new SolidBrush(Color.White), recyy, sf);
                }
            }

            #region 竖线
            int mfw = (int)((Width - _x) / maxValue * 25);
            g.DrawLine(new Pen(Color.White, 2), new Point(mfw, recky.Y), new Point(mfw, recky.Bottom));
            int vip1w = (int)((Width - _x) / maxValue * 100);
            g.DrawLine(new Pen(Color.White, 2), new Point(vip1w, recky.Y), new Point(vip1w, recky.Bottom));
            #endregion

            #region 画上下string
            int ty = (Height - processHeight) / 2 - 12;
            int by = (Height - processHeight) / 2 + processHeight + 4;

            g.DrawString(allkj[0], Font, new SolidBrush(ForeColor), new Point(_x, ty));

            int _mfx = mfw - (int)(g.MeasureString(allkj[1], Font).Width / 2);
            g.DrawString(allkj[1], Font, new SolidBrush(ForeColor), new Point(_mfx, ty));

            int _mfdex = mfw - (int)(g.MeasureString(allkjde[1], Font).Width / 2);
            g.DrawString(allkjde[1], Font, new SolidBrush(ForeColor), new Point(_mfdex, by));

            int _vipx = vip1w - (int)(g.MeasureString(allkj[2], Font).Width / 2);
            g.DrawString(allkj[2], Font, new SolidBrush(ForeColor), new Point(_vipx, ty));

            int _vipdex = vip1w - (int)(g.MeasureString(allkjde[2], Font).Width / 2);
            g.DrawString(allkjde[2], Font, new SolidBrush(ForeColor), new Point(_vipdex, by));

            int _vip2x = Width - (int)(g.MeasureString(allkj[3], Font).Width);
            g.DrawString(allkj[3], Font, new SolidBrush(ForeColor), new Point(_vip2x, ty));

            int _vipde2x = Width - (int)(g.MeasureString(allkjde[3], Font).Width);
            g.DrawString(allkjde[3], Font, new SolidBrush(ForeColor), new Point(_vipde2x, by));
            #endregion
        }