Example #1
0
        public UCTopologyItem(ITopologyItem v) : this()
        {
            Item         = v;
            AreInUse     = new AreInUse();
            _IsDataInput = Item == null || Item is IDataInput;

            RefreshDesign();
            if (_IsDataInput)
            {
                Size = new Size((int)(Width * 1.2), (int)(Height * 1.2));
            }

            if (!_IsDataInput && SystemHelper.IsWindows)
            {
                using (Graphics gp = CreateGraphics())
                {
                    if (_IsDataInput)
                    {
                        _EdgeFilter = RectangleEdgeFilter.BottomLeft | RectangleEdgeFilter.TopRight;
                    }
                    else
                    {
                        _EdgeFilter = RectangleEdgeFilter.All;
                    }

                    _EdgeBorder = 10F;
                    Region      = new Region(gp.GenerateRoundedRectangle(Bounds, _EdgeBorder, _EdgeFilter));
                }
            }
            else
            {
                _EdgeFilter = RectangleEdgeFilter.None;
                _EdgeBorder = 0;
            }
        }
Example #2
0
		public static void DrawRoundedRectangle( this Graphics graphics, Pen pen, float x, float y, float width, float height, float radius, RectangleEdgeFilter filter ) {
			RectangleF rectangle = new RectangleF( x, y, width, height );
			GraphicsPath path = graphics.GenerateRoundedRectangle( rectangle, radius, filter );
			SmoothingMode old = graphics.SmoothingMode;
			graphics.SmoothingMode = SmoothingMode.AntiAlias;
			graphics.DrawPath( pen, path );
			graphics.SmoothingMode = old;
		}
 private static GraphicsPath GenerateRoundedRectangle(
     this Graphics graphics,
     RectangleF rectangle,
     float radius,
     RectangleEdgeFilter filter)
 {
     float diameter;
     GraphicsPath path = new GraphicsPath();
     if (radius <= 0.0F || filter == RectangleEdgeFilter.None)
     {
         path.AddRectangle(rectangle);
         path.CloseFigure();
         return path;
     }
     else
     {
         if (radius >= (Math.Min(rectangle.Width, rectangle.Height)) / 2.0)
             return graphics.GenerateCapsule(rectangle);
         diameter = radius * 2.0F;
         SizeF sizeF = new SizeF(diameter, diameter);
         RectangleF arc = new RectangleF(rectangle.Location, sizeF);
         if ((RectangleEdgeFilter.TopLeft & filter) == RectangleEdgeFilter.TopLeft)
             path.AddArc(arc, 180, 90);
         else
         {
             path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y);
             path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y);
         }
         arc.X = rectangle.Right - diameter;
         if ((RectangleEdgeFilter.TopRight & filter) == RectangleEdgeFilter.TopRight)
             path.AddArc(arc, 270, 90);
         else
         {
             path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y);
             path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X + arc.Width, arc.Y);
         }
         arc.Y = rectangle.Bottom - diameter;
         if ((RectangleEdgeFilter.BottomRight & filter) == RectangleEdgeFilter.BottomRight)
             path.AddArc(arc, 0, 90);
         else
         {
             path.AddLine(arc.X + arc.Width, arc.Y, arc.X + arc.Width, arc.Y + arc.Height);
             path.AddLine(arc.X, arc.Y + arc.Height, arc.X + arc.Width, arc.Y + arc.Height);
         }
         arc.X = rectangle.Left;
         if ((RectangleEdgeFilter.BottomLeft & filter) == RectangleEdgeFilter.BottomLeft)
             path.AddArc(arc, 90, 90);
         else
         {
             path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X, arc.Y + arc.Height);
             path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y);
         }
         path.CloseFigure();
     }
     return path;
 }
Example #4
0
        ///--------------------------------------------------------------------------------------------------
        /// <summary> Paints the area. </summary>
        /// <remarks> Oscvic, 2016-01-18. </remarks>
        /// <param name="e">          Paint event information. </param>
        /// <param name="filter">     Specifies the filter. </param>
        /// <param name="StartColor"> The start color. </param>
        /// <param name="EndColor">   The end color. </param>
        /// <param name="invertDark"> true to invert dark. </param>
        ///--------------------------------------------------------------------------------------------------
        private void PaintArea(PaintEventArgs e, RectangleEdgeFilter filter, Color StartColor, Color EndColor, Boolean invertDark)
        {
            StartColor = (invertDark) ? ControlPaint.Dark(StartColor, PercentageOfDark) : StartColor;
            EndColor   = (invertDark) ? ControlPaint.Light(StartColor, PercentageOfLight) : ControlPaint.Dark(EndColor, PercentageOfDark);


            using (LinearGradientBrush brush = new LinearGradientBrush(
                       new Point(this.Width / 2, (invertDark) ? -(this.Height / 2) : 0),
                       new Point(this.Width / 2, this.Height + ((invertDark) ? 0 : this.Height / 2)),
                       StartColor, EndColor))
                e.Graphics.FillRoundedRectangle(brush, 0, 0, this.Width - 1, this.Height, Radius, filter);

            using (Pen pen = new Pen((invertDark) ? StartColor : EndColor))
                e.Graphics.DrawRoundedRectangle(pen, 0, 0, this.Width - 1, this.Height - 1, Radius, filter);
        }
Example #5
0
 public static void FillRoundedRectangle(
     this Graphics graphics,
     Brush brush,
     RectangleF rectangle,
     int radius,
     RectangleEdgeFilter filter)
 {
     graphics.FillRoundedRectangle(
         brush,
         rectangle.X,
         rectangle.Y,
         rectangle.Width,
         rectangle.Height,
         radius,
         filter);
 }
Example #6
0
 public static void DrawRoundedRectangle(
     this Graphics graphics,
     Pen pen,
     RectangleF rectangle,
     int radius,
     RectangleEdgeFilter filter)
 {
     graphics.DrawRoundedRectangle(
         pen,
         rectangle.X,
         rectangle.Y,
         rectangle.Width,
         rectangle.Height,
         radius,
         filter);
 }
Example #7
0
		private static GraphicsPath GenerateRoundedRectangle( this Graphics graphics, RectangleF rectangle, float radius, RectangleEdgeFilter filter ) {
			float diameter;
			GraphicsPath path = new GraphicsPath();

			if( radius <= 0.0F || filter == RectangleEdgeFilter.None ) {
				path.AddRectangle( rectangle );
				path.CloseFigure();
				return path;
			} else {
				if( radius >= ( Math.Min( rectangle.Width, rectangle.Height ) ) / 2.0 )
					return graphics.GenerateCapsule( rectangle );

				diameter = radius * 2.0F;
				SizeF sizeF = new SizeF( diameter, diameter );
				RectangleF arc = new RectangleF( rectangle.Location, sizeF );
				if( ( RectangleEdgeFilter.TopLeft & filter ) == RectangleEdgeFilter.TopLeft )
					path.AddArc( arc, 180, 90 );
				else {
					path.AddLine( arc.X, arc.Y + arc.Height, arc.X, arc.Y );
					path.AddLine( arc.X, arc.Y, arc.X + arc.Width, arc.Y );
				}
				arc.X = rectangle.Right - diameter;
				if( ( RectangleEdgeFilter.TopRight & filter ) == RectangleEdgeFilter.TopRight )
					path.AddArc( arc, 270, 90 );
				else {
					path.AddLine( arc.X, arc.Y, arc.X + arc.Width, arc.Y );
					path.AddLine( arc.X + arc.Width, arc.Y + arc.Height, arc.X + arc.Width, arc.Y );
				}
				arc.Y = rectangle.Bottom - diameter;
				if( ( RectangleEdgeFilter.BottomRight & filter ) == RectangleEdgeFilter.BottomRight )
					path.AddArc( arc, 0, 90 );
				else {
					path.AddLine( arc.X + arc.Width, arc.Y, arc.X + arc.Width, arc.Y + arc.Height );
					path.AddLine( arc.X, arc.Y + arc.Height, arc.X + arc.Width, arc.Y + arc.Height );
				}
				arc.X = rectangle.Left;
				if( ( RectangleEdgeFilter.BottomLeft & filter ) == RectangleEdgeFilter.BottomLeft )
					path.AddArc( arc, 90, 90 );
				else {
					path.AddLine( arc.X + arc.Width, arc.Y + arc.Height, arc.X, arc.Y + arc.Height );
					path.AddLine( arc.X, arc.Y + arc.Height, arc.X, arc.Y );
				}
				path.CloseFigure();
			}
			return path;
		}
 public static void FillRoundedRectangle(
        this Graphics graphics,
        Brush brush,
        float x,
        float y,
        float width,
        float height,
        float radius,
        RectangleEdgeFilter filter)
 {
     RectangleF rectangle = new RectangleF(x, y, width, height);
     GraphicsPath path = graphics.GenerateRoundedRectangle(rectangle, radius, filter);
     SmoothingMode old = graphics.SmoothingMode;
     graphics.SmoothingMode = SmoothingMode.AntiAlias;
     graphics.FillPath(brush, path);
     graphics.SmoothingMode = old;
 }
Example #9
0
        public static void DrawRoundedRectangle(
            this Graphics graphics,
            Pen pen,
            float x,
            float y,
            float width,
            float height,
            float radius,
            RectangleEdgeFilter filter)
        {
            var rectangle = new RectangleF(x, y, width, height);
            var path      = graphics.GenerateRoundedRectangle(rectangle, radius, filter);
            var old       = graphics.SmoothingMode;

            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            graphics.DrawPath(pen, path);
            graphics.SmoothingMode = old;
        }
Example #10
0
        ///--------------------------------------------------------------------------------------------------
        /// <summary> Genera el evento <see cref="E:System.Windows.Forms.Control.Paint" />. </summary>
        /// <remarks> Oscvic, 2016-01-18. </remarks>
        /// <param name="e"> Objeto <see cref="T:System.Windows.Forms.PaintEventArgs" /> que contiene los datos
        ///                  del evento. </param>
        ///--------------------------------------------------------------------------------------------------
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            RectangleEdgeFilter filter = RectangleEdgeFilter.None;

            if (Extreme == Extreme.Left)
            {
                filter = RectangleEdgeFilter.TopLeft | RectangleEdgeFilter.BottomLeft;
            }
            else if (Extreme == Extreme.Right)
            {
                filter = RectangleEdgeFilter.TopRight | RectangleEdgeFilter.BottomRight;
            }
            else if (Extreme == Extreme.NoExtreme)
            {
                filter = RectangleEdgeFilter.All;
            }

            PaintArea(e, filter, TopColor, BottomColor, selected);

            if (this.Value != null)
            {
                String text = Value.ToString();

                SizeF size = e.Graphics.MeasureString(text, Font, this.Width - Padding.Left - Padding.Right);

                float width  = (Width / 2 - size.Width / 2) + 1;
                float height = (Height / 2 - size.Height / 2) + 1;
                width  = width <= 1 ? 1 : width;
                height = height <= 1 ? 1 : height;

                RectangleF rect = new RectangleF(new PointF(width, height), size);

                e.Graphics.DrawString(text, Font, new SolidBrush(ForeColor), rect);
            }
        }
Example #11
0
        public static void FillRoundedRectangle(
			this Graphics graphics,
			Brush brush,
			RectangleF rectangle,
			int radius,
			RectangleEdgeFilter filter)
        {
            graphics.FillRoundedRectangle(
                brush,
                rectangle.X,
                rectangle.Y,
                rectangle.Width,
                rectangle.Height,
                radius,
                filter);
        }
Example #12
0
        public static void DrawRoundedRectangle(
			this Graphics graphics,
			Pen pen,
			RectangleF rectangle,
			int radius,
			RectangleEdgeFilter filter)
        {
            graphics.DrawRoundedRectangle(
                pen,
                rectangle.X,
                rectangle.Y,
                rectangle.Width,
                rectangle.Height,
                radius,
                filter);
        }
Example #13
0
        private static GraphicsPath GenerateRoundedRectangle(RectangleF rectangle, float radius, RectangleEdgeFilter filter)
        {
            var path = new GraphicsPath();

            if (radius <= 0.0F || filter == RectangleEdgeFilter.None)
            {
                path.AddRectangle(rectangle);
                path.CloseFigure();
                return(path);
            }

            if (radius >= Math.Min(rectangle.Width, rectangle.Height) / 2.0)
            {
                return(GenerateCapsule(rectangle));
            }

            var diameter = radius * 2.0F;
            var sizeF    = new SizeF(diameter, diameter);
            var arc      = new RectangleF(rectangle.Location, sizeF);

            if (filter.HasFlag(RectangleEdgeFilter.TopLeft))
            {
                path.AddArc(arc, 180, 90);
            }
            else
            {
                path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y);
                path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y);
            }
            arc.X = rectangle.Right - diameter;
            if (filter.HasFlag(RectangleEdgeFilter.TopRight))
            {
                path.AddArc(arc, 270, 90);
            }
            else
            {
                path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y);
                path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X + arc.Width, arc.Y);
            }
            arc.Y = rectangle.Bottom - diameter;
            if (filter.HasFlag(RectangleEdgeFilter.BottomRight))
            {
                path.AddArc(arc, 0, 90);
            }
            else
            {
                path.AddLine(arc.X + arc.Width, arc.Y, arc.X + arc.Width, arc.Y + arc.Height);
                path.AddLine(arc.X, arc.Y + arc.Height, arc.X + arc.Width, arc.Y + arc.Height);
            }
            arc.X = rectangle.Left;
            if (filter.HasFlag(RectangleEdgeFilter.BottomLeft))
            {
                path.AddArc(arc, 90, 90);
            }
            else
            {
                path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X, arc.Y + arc.Height);
                path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y);
            }
            path.CloseFigure();
            return(path);
        }
Example #14
0
 public static GraphicsPath GenerateRoundedRectangle(this Graphics graphics, RectangleF rectangle, float radius, RectangleEdgeFilter filter)
 {
     return(GenerateRoundedRectangle(rectangle, radius, filter));
 }
Example #15
0
        private static void FillRoundedRectangle(Graphics gfx, Brush brush, RectangleF rectangle, int radius, RectangleEdgeFilter filter)
        {
            var path = GenerateRoundedRectangle(rectangle, radius, filter);

            FillPath(gfx, brush, path);
        }
Example #16
0
        public static void DrawRoundedRectangle(this Graphics graphics, Pen pen, float x, float y, float width, float height, float radius, RectangleEdgeFilter filter)
        {
            RectangleF   rectangle = new RectangleF(x, y, width, height);
            GraphicsPath path      = GenerateRoundedRectangle(rectangle, radius, filter);

            graphics.DrawPath(pen, path);
        }
Example #17
0
        public static void DrawGradientRoundedRectangle(this Graphics g, Rectangle rect, Color startColor, Color endColor, FillDirection direction = FillDirection.TopToBottom, Color borderColor = default(Color), int radius = 8, RectangleEdgeFilter filter = RectangleEdgeFilter.All)
        {
            // 填充渐变背景
            Rectangle gradientRect = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);

            using (GraphicsPath path = g.GenerateRoundedRectangle(gradientRect, radius, filter))
                using (LinearGradientBrush brush = new LinearGradientBrush(gradientRect, startColor, endColor, 90f))
                {
                    g.FillPath(brush, path);
                }

            // 画边框
            using (Pen borderPen = new Pen(borderColor))
            {
                GraphicsExtension.DrawRoundedRectangle(g, borderPen, rect, radius, filter);
            }
        }
Example #18
0
        /**888888888888888*/
        public static GraphicsPath GetRoundedPath(this Graphics graphics, float x, float y, float width, float height, float radius, RectangleEdgeFilter filter)
        {
            RectangleF   rectangle = new RectangleF(x, y, width, height);
            GraphicsPath path      = graphics.GenerateRoundedRectangle(rectangle, radius, filter);

            return(path);
        }
 public static void FillRoundedRectangle(
         this Graphics graphics,
         Brush brush,
         float x,
         float y,
         float width,
         float height,
         float radius,
         RectangleEdgeFilter filter)
 {
     try
     {
         RectangleF rectangle = new RectangleF(x, y, width, height);
         GraphicsPath path = graphics.GenerateRoundedRectangle(rectangle, radius, filter);
         SmoothingMode old = graphics.SmoothingMode;
         graphics.SmoothingMode = SmoothingMode.AntiAlias;
         graphics.FillPath(brush, path);
         graphics.SmoothingMode = old;
     }
     catch { }
 }
Example #20
0
 public static void DrawMonoRoundedRectangle(this Graphics g, Rectangle rect, Color backColor, int radius = 8, RectangleEdgeFilter filter = RectangleEdgeFilter.All, Color borderColor = default(Color))
 {
     // 填充单一背景
     using (Brush backBrush = new SolidBrush(backColor))
     {
         GraphicsExtension.FillRoundedRectangle(g, backBrush, rect, radius, filter);
     }
     // 画边框
     using (Pen borderPen = new Pen(borderColor))
     {
         GraphicsExtension.DrawRoundedRectangle(g, borderPen, rect, radius, filter);
     }
 }
 /**888888888888888*/
 public static GraphicsPath GetRoundedPath(this Graphics graphics, float x, float y, float width, float height, float radius, RectangleEdgeFilter filter)
 {
     RectangleF rectangle = new RectangleF(x, y, width, height);
     GraphicsPath path = graphics.GenerateRoundedRectangle(rectangle, radius, filter);
     return path;
 }
Example #22
0
        public static void FillRoundedRectangle(this Graphics graphics, Brush brush, float x, float y, float width, float height, float radius, RectangleEdgeFilter filter)
        {
            RectangleF   rectangle = new RectangleF(x, y, width, height);
            GraphicsPath path      = GenerateRoundedRectangle(rectangle, radius, filter);

            graphics.FillPath(brush, path);
        }
Example #23
0
        private static void DrawRoundedRectangle(Graphics gfx, Pen pen, RectangleF rectangle, int radius, RectangleEdgeFilter filter)
        {
            var path = GenerateRoundedRectangle(rectangle, radius, filter);

            DrawPath(gfx, pen, path);
        }