コード例 #1
0
        /// <summary>
        /// 创建区域
        /// </summary>
        /// <param name="rect">区域位置和大小</param>
        /// <returns>区域</returns>
        public Region CreateRegion(Rectangle rect)
        {
            if (this.m_RoundStyle == RoundStyle.None)//直角
            {
                if ((this.m_RoundCornerStyle & CornerStyle.Horizontal) != 0)
                {
                    rect.Inflate(2, 0);
                }
                else if ((this.m_RoundCornerStyle & CornerStyle.Vertical) != 0)
                {
                    rect.Inflate(0, 2);
                }
                else
                {
                    return(null);
                }
            }
            else//有圆角
            {
                if ((this.m_RoundCornerStyle & CornerStyle.Horizontal) != 0)
                {
                    rect.Inflate(5, 1);
                }
                else if ((this.m_RoundCornerStyle & CornerStyle.Vertical) != 0)
                {
                    rect.Inflate(1, 5);
                }
                else
                {
                    return(null);
                }
            }

            using (GraphicsPath path = RenderEngine.CreateGraphicsPath(rect, this.m_RoundCornerStyle, this.m_RoundStyle, this.m_RoundRadius, false))
            {
                return(new Region(path));
            }
        }
コード例 #2
0
        /// <summary>
        /// 绘制Metrol选中边框
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderMetroCheck(Rectangle rect)
        {
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(rect))
            {
                return;
            }

            //左侧
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Left) != 0)
            {
                rect.X     += 2;
                rect.Width -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Left) != 0)
            {
                rect.X     += 1;
                rect.Width -= 1;
            }

            //上边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Top) != 0)
            {
                rect.Y      += 2;
                rect.Height -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Top) != 0)
            {
                rect.Y      += 1;
                rect.Height -= 1;
            }

            //右边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Right) != 0)
            {
                rect.Width -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Right) != 0)
            {
                rect.Width -= 1;
            }

            //下边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Bottom) != 0)
            {
                rect.Height -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Bottom) != 0)
            {
                rect.Height -= 1;
            }

            //设置剪切区
            this.m_Graphics.SetClip(rect);

            //绘制宽边框
            using (GraphicsPath pathBorder = RenderEngine.CreateGraphicsPath(rect),
                   pathBorderIn = RenderEngine.CreateGraphicsPath(Rectangle.Inflate(rect, -3, -3)),
                   pathTriangle = new GraphicsPath())
            {
                //边框区域
                pathBorder.AddPath(pathBorderIn, true);

                //右上角三角区域
                Point[] points = new Point[] {
                    new Point(rect.X + rect.Width - 40, rect.Y),
                    new Point(rect.X + rect.Width, rect.Y),
                    new Point(rect.X + rect.Width, rect.Y + 40)
                };
                pathTriangle.AddPolygon(points);

                //绘制
                using (Brush brush = new SolidBrush(this.CurrentBackColor))
                {
                    this.m_Graphics.FillPath(brush, pathBorder);
                    this.m_Graphics.FillPath(brush, pathTriangle);
                }
            }

            //绘制对号
            RenderEngine.DrawCheck(this.m_Graphics, new Rectangle(rect.Right - 22, rect.Y + 2, 20, 20), this.CurrentForeColor);
        }
コード例 #3
0
        /// <summary>
        /// 渲染Metrol按下边框
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderMetroPress(Rectangle rect)
        {
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(rect))
            {
                return;
            }

            //左侧
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Left) != 0)
            {
                rect.X     += 2;
                rect.Width -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Left) != 0)
            {
                rect.X     += 1;
                rect.Width -= 1;
            }

            //上边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Top) != 0)
            {
                rect.Y      += 2;
                rect.Height -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Top) != 0)
            {
                rect.Y      += 1;
                rect.Height -= 1;
            }

            //右边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Right) != 0)
            {
                rect.Width -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Right) != 0)
            {
                rect.Width -= 1;
            }

            //下边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Bottom) != 0)
            {
                rect.Height -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Bottom) != 0)
            {
                rect.Height -= 1;
            }

            //设置剪切区
            this.m_Graphics.SetClip(rect);

            //绘制宽边框
            using (GraphicsPath pathBorder = RenderEngine.CreateGraphicsPath(rect),
                   pathBorderIn = RenderEngine.CreateGraphicsPath(Rectangle.Inflate(rect, -3, -3)))
            {
                //边框区域
                pathBorder.AddPath(pathBorderIn, true);

                //绘制
                using (Brush brush = new SolidBrush(this.CurrentBorderColor))
                {
                    this.m_Graphics.FillPath(brush, pathBorder);
                }
            }
        }