Inheritance: MarshalByRefObject, ICloneable, IDisposable
示例#1
1
		// From http://edu.cnzz.cn/show_3281.html
		public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap, Color colorTransparent) 
		{ 
			GraphicsPath graphicsPath = new GraphicsPath(); 
			if (colorTransparent == Color.Empty)
				colorTransparent = bitmap.GetPixel(0, 0); 

			for(int row = 0; row < bitmap.Height; row ++) 
			{ 
				int colOpaquePixel = 0;
				for(int col = 0; col < bitmap.Width; col ++) 
				{ 
					if(bitmap.GetPixel(col, row) != colorTransparent) 
					{ 
						colOpaquePixel = col; 
						int colNext = col; 
						for(colNext = colOpaquePixel; colNext < bitmap.Width; colNext ++) 
							if(bitmap.GetPixel(colNext, row) == colorTransparent) 
								break;
 
						graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1)); 
						col = colNext; 
					} 
				} 
			} 
			return graphicsPath; 
		} 
示例#2
1
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            using (Graphics g = e.Graphics)
            {
                GraphicsPath path = new GraphicsPath();

                path.AddLine(20, 20, 170, 20);
                path.AddLine(20, 20, 20, 100);
                // рисуем новую фигуру
                path.StartFigure();
                path.AddLine(240, 140, 240, 50);
                path.AddLine(240, 140, 80, 140);
                path.AddRectangle(new Rectangle(30, 30, 200, 100));
                // локальное преобразование траектории
                //Matrix X = new Matrix();
                //X.RotateAt(45, new PointF(60.0f, 100.0f));
                //path.Transform(X);
                // рисуем  path
                Pen redPen = new Pen(Color.Red, 2);
                g.FillPath(new SolidBrush(Color.Bisque), path);
                g.DrawPath(redPen, path);

            }

        }
示例#3
0
        /// <summary>
        /// Create the Top tab path
        /// </summary>
        /// <returns>GraphicsPath</returns>
        private GraphicsPath TopTabPath()
        {
            GraphicsPath path = new GraphicsPath();

            Rectangle r = TabItem.DisplayRectangle;
            r.Width -= 1;
            r.Height -= 1;

            // Allow for the TabStrip border

            if (TabItem.IsSelected == true)
                r.Height += 2;

            // Create the path
            
            int n = TabStripItem.TabDisplay.TabSpacing;

            Rectangle ar = new Rectangle(r.X, r.Y, Radius, Radius);

            path.AddLine(r.X, r.Bottom, r.X, r.Top + Radius);
            path.AddArc(ar, 180, 90);

            path.AddLine(r.X + Radius, r.Top, r.Right - n - Radius, r.Top);

            ar.X = r.Right - n - Radius;
            path.AddArc(ar, 270, 90);

            path.AddLine(r.Right - n, r.Top + Radius, r.Right - n, r.Bottom);

            return (path);
        }
示例#4
0
 public override GraphicsPath Get()
 {
     var shape = new GraphicsPath();
     var bounds = new Rectangle(this.state.Left, this.state.Top, this.state.Width, this.state.Height);
     shape.AddEllipse(bounds);
     return shape;
 }
示例#5
0
        public void Execute(GraphicsPath path)
        {
            CornersLine line1, line2;
            CornersArc arc;

            int i = 0;
            while (true)
            {
                if (i == list.Count) break;
                line1 = list[i] as CornersLine;
                i++;
                if (i == list.Count) break;
                if (list[i] is CornersArc)
                {
                    arc = list[i] as CornersArc;
                    i++;
                    if (i == list.Count)
                        line2 = list[0] as CornersLine;
                    else
                        line2 = list[i] as CornersLine;
                    CalculateRoundLines(line1, line2, arc);
                }
            }

            for (int j = 0; j < list.Count; j++)
            {
                (list[j] as CornersItem).addToPath(path);
            }
        }
示例#6
0
        public static void DrawRoundedRectangle(Graphics newGraphics, Color boxColor, Color gradFillColor1, Color gradFillColor2, int xPosition, int yPosition,
                   int height, int width, int cornerRadius)
        {
            using (var boxPen = new Pen(boxColor))
            {
                using (var path = new GraphicsPath())
                {
                    path.AddLine(xPosition + cornerRadius, yPosition, xPosition + width - (cornerRadius * 2), yPosition);
                    path.AddArc(xPosition + width - (cornerRadius * 2), yPosition, cornerRadius * 2, cornerRadius * 2, 270, 90);
                    path.AddLine(xPosition + width, yPosition + cornerRadius, xPosition + width,
                                 yPosition + height - (cornerRadius * 2));
                    path.AddArc(xPosition + width - (cornerRadius * 2), yPosition + height - (cornerRadius * 2), cornerRadius * 2,
                                cornerRadius * 2, 0, 90);
                    path.AddLine(xPosition + width - (cornerRadius * 2), yPosition + height, xPosition + cornerRadius,
                                 yPosition + height);
                    path.AddArc(xPosition, yPosition + height - (cornerRadius * 2), cornerRadius * 2, cornerRadius * 2, 90, 90);
                    path.AddLine(xPosition, yPosition + height - (cornerRadius * 2), xPosition, yPosition + cornerRadius);
                    path.AddArc(xPosition, yPosition, cornerRadius * 2, cornerRadius * 2, 180, 90);
                    path.CloseFigure();
                    newGraphics.DrawPath(boxPen, path);

                    var b = new LinearGradientBrush(new Point(xPosition, yPosition),
                                                    new Point(xPosition + width, yPosition + height), gradFillColor1,
                                                    gradFillColor2);

                    newGraphics.FillPath(b, path);
                }
            }
        }
示例#7
0
文件: Form1.cs 项目: sverreeh/clipper
        //------------------------------------------------------------------------------
        private static void DrawBezierCtrlLines(Graphics graphics,
      MultiPathSegment mps, uint color)
        {
            int cnt = mps.Count;
              if (cnt < 2) return;
              Pen pen = new Pen(MakeColor(color));
              GraphicsPath gpath = new GraphicsPath();
              PointF[] pts = new PointF[2];
              pts[0] = PathToPointF(mps[0]);
              pts[1] = PathToPointF(mps[1]);
              gpath.StartFigure();
              gpath.AddLines(pts);

              if (mps.IsValid())
            if (mps.curvetype == CurveType.CubicBezier)
            {
              pts[0] = PathToPointF(mps[2]);
              pts[1] = PathToPointF(mps[3]);
              gpath.StartFigure();
              gpath.AddLines(pts);
            }
            else
            {
              pts[0] = PathToPointF(mps[2]);
              gpath.StartFigure();
              gpath.AddLines(pts);
            }

              graphics.DrawPath(pen, gpath);
              pen.Dispose();
              gpath.Dispose();
        }
示例#8
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;
        }
示例#9
0
        public static float MeasureTextHeight(Font font, string text, bool bold)
        {
            using (var sf = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near })
            {
                using (var path = new GraphicsPath())
                {

                    var sb = new StringBuilder(text);
                    bool newLine = false;
                    const int leftMargin = 0;
                    int pathPointsStart = -1;
                    DrawText(font, sf, path, sb, false, bold, false, 0, 0, ref newLine, leftMargin, ref pathPointsStart);

                    float height = 0;
                    var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!!
                    int index = list.Length - 80;
                    if (index < 0)
                        index = 0;
                    for (int i = index; i < list.Length; i += 2)
                    {
                        if (list[i].Y > height)
                            height = list[i].Y;
                    }

                    for (int i = 0; i < list.Length; i += 2)
                    {
                        if (list[i].Y > height)
                            height = list[i].Y;
                    }

                    return height;
                }
            }
        }
        public override void DrawRegionRepresentation(Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            if (m_Param.Path.PointCount > 0)
            {
                GraphicsPath fill = new GraphicsPath();
                RectangleF rect = m_Param.Path.GetBounds();
                PointD refPt = (PointD)rect.Location + ((PointD)rect.Size.ToPointF()) / 2;
                // this will draw beyond the shape's location
                for (double i = -rect.Height; i < rect.Height; i++)
                {
                    PointD pt1 = refPt + PointD.Orthogonal(m_Param.V) * i * drawMethods.Spacing(m_Param.C);
                    PointD pt2 = pt1 + m_Param.V * rect.Width * rect.Height;
                    PointD pt3 = pt1 - m_Param.V * rect.Width * rect.Height;

                    fill.StartFigure();
                    fill.AddLine((Point)pt2, (Point)pt3);

                }

                GraphicsContainer c = gc.BeginContainer();
                gc.SetClip((Tools.Model.VectorPath)m_Param.Path);
                gc.DrawPath(r.RegionGuides, fill);
                gc.EndContainer(c);

            }
        }
示例#11
0
        public static GraphicsPath CreateRoundedRectanglePath(RectangleF rect, float radius)
        {
            GraphicsPath path = new GraphicsPath();

            if (rect.Width <= 0.0f || rect.Height <= 0.0f) return path;

            float x1 = rect.X;
            float x2 = rect.X + rect.Width;
            float y1 = rect.Y;
            float y2 = rect.Y + rect.Height;

            if (radius > rect.Width / 2) radius = rect.Width / 2;
            if (radius > rect.Height / 2) radius = rect.Width / 2;

            // Top left arc and top edge:
            if (radius > 0.0) path.AddArc(new RectangleF(x1, y1, radius * 2, radius * 2), 180, 90);
            path.AddLine(x1 + radius, y1, x2 - radius, y1);

            // Top right arc and right edge:
            if (radius > 0.0) path.AddArc(new RectangleF(x2 - radius * 2, y1, radius * 2, radius * 2), 270, 90);
            path.AddLine(x2, y1 + radius, x2, y2 - radius);

            // Bottom right arc and bottom edge:
            if (radius > 0.0) path.AddArc(new RectangleF(x2 - radius * 2, y2 - radius * 2, radius * 2, radius * 2), 0, 90);
            path.AddLine(x2 - radius, y2, x1 + radius, y2);

            // Bottom left arc and left edge:
            if (radius > 0.0) path.AddArc(new RectangleF(x1, y2 - radius * 2, radius * 2, radius * 2), 90, 90);
            path.AddLine(x1, y2 - radius, x1, y1 + radius);

            return path;
        }
示例#12
0
        private GraphicsPath createRoundedRectangles(int x, int y, int width, int height, int radius)
        {
            int xw = x + width;
            int yh = y + height;
            int xwr = xw - radius;
            int yhr = yh - radius;
            int xr = x + radius;
            int yr = y + radius;
            int r2 = radius * 2;
            int xwr2 = xw - r2;
            int yhr2 = yh - r2;

            GraphicsPath p = new GraphicsPath();
            p.StartFigure();
            p.AddArc(x, y, r2, r2, 180, 90);
            p.AddLine(xr, y, xwr, y);
            p.AddArc(xwr2, y, r2, r2, 270, 90);
            p.AddLine(xw, yr, xw, yhr);
            p.AddArc(xwr2, yhr2, r2, r2, 0, 90);
            p.AddLine(xwr, yh, xr, yh);
            p.AddArc(x, yhr2, r2, r2, 90, 90);
            p.AddLine(x, yhr, x, yr);
            p.CloseFigure();
            return p;
        }
示例#13
0
        public static GraphicsPath CreateRoundedRectangle(SizeF size, PointF location)
        {
            int cornerSize			= (int)GraphConstants.CornerSize * 2;
            int connectorSize		= (int)GraphConstants.ConnectorSize;
            int halfConnectorSize	= (int)Math.Ceiling(connectorSize / 2.0f);

            var height				= size.Height;
            var width				= size.Width;
            var halfWidth			= width / 2.0f;
            var halfHeight			= height / 2.0f;
            var connectorOffset		= (int)Math.Floor((GraphConstants.MinimumItemHeight - GraphConstants.ConnectorSize) / 2.0f);
            var left				= location.X;
            var top					= location.Y;
            var right				= location.X + width;
            var bottom				= location.Y + height;

            var path = new GraphicsPath(FillMode.Winding);
            path.AddArc(left, top, cornerSize, cornerSize, 180, 90);
            path.AddArc(right - cornerSize, top, cornerSize, cornerSize, 270, 90);

            path.AddArc(right - cornerSize, bottom - cornerSize, cornerSize, cornerSize, 0, 90);
            path.AddArc(left, bottom - cornerSize, cornerSize, cornerSize, 90, 90);
            path.CloseFigure();
            return path;
        }
示例#14
0
 protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
 {
     GraphicsPath grPath = new GraphicsPath();
     grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
     this.Region = new System.Drawing.Region(grPath);
     base.OnPaint(e);
 }
示例#15
0
        public static System.Drawing.Brush GetBrush(this Brush brush, Rect frame)
        {
            var cb = brush as SolidBrush;
            if (cb != null) {
                return new System.Drawing.SolidBrush (cb.Color.GetColor ());
            }

            var lgb = brush as LinearGradientBrush;
            if (lgb != null) {
                var s = lgb.Absolute ? lgb.Start : frame.Position + lgb.Start * frame.Size;
                var e = lgb.Absolute ? lgb.End : frame.Position + lgb.End * frame.Size;
                var b = new System.Drawing.Drawing2D.LinearGradientBrush (GetPointF (s), GetPointF (e), System.Drawing.Color.Black, System.Drawing.Color.Black);
                var bb = BuildBlend (lgb.Stops);
                if (bb != null) {
                    b.InterpolationColors = bb;
                }
                return b;
            }

            var rgb = brush as RadialGradientBrush;
            if (rgb != null) {
                var r = rgb.GetAbsoluteRadius (frame);
                var c = rgb.GetAbsoluteCenter (frame);
                var path = new GraphicsPath ();
                path.AddEllipse (GetRectangleF (new Rect (c - r, 2 * r)));
                var b = new PathGradientBrush (path);
                var bb = BuildBlend (rgb.Stops, true);
                if (bb != null) {
                    b.InterpolationColors = bb;
                }
                return b;
            }

            throw new NotImplementedException ("Brush " + brush);
        }
示例#16
0
        public static GraphicsPath GetRoundedCornerTab(GraphicsPath graphicsPath, Rectangle rect, bool upCorner)
        {
            if (graphicsPath == null)
                graphicsPath = new GraphicsPath();
            else
                graphicsPath.Reset();
            
            int curveSize = 6;
            if (upCorner)
            {
                graphicsPath.AddLine(rect.Left, rect.Bottom, rect.Left, rect.Top + curveSize / 2);
                graphicsPath.AddArc(new Rectangle(rect.Left, rect.Top, curveSize, curveSize), 180, 90);
                graphicsPath.AddLine(rect.Left + curveSize / 2, rect.Top, rect.Right - curveSize / 2, rect.Top);
                graphicsPath.AddArc(new Rectangle(rect.Right - curveSize, rect.Top, curveSize, curveSize), -90, 90);
                graphicsPath.AddLine(rect.Right, rect.Top + curveSize / 2, rect.Right, rect.Bottom);
            }
            else
            {
                graphicsPath.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom - curveSize / 2);
                graphicsPath.AddArc(new Rectangle(rect.Right - curveSize, rect.Bottom - curveSize, curveSize, curveSize), 0, 90);
                graphicsPath.AddLine(rect.Right - curveSize / 2, rect.Bottom, rect.Left + curveSize / 2, rect.Bottom);
                graphicsPath.AddArc(new Rectangle(rect.Left, rect.Bottom - curveSize, curveSize, curveSize), 90, 90);
                graphicsPath.AddLine(rect.Left, rect.Bottom - curveSize / 2, rect.Left, rect.Top);
            }

            return graphicsPath;
        }
示例#17
0
        public QuadroSimples()
        {
                caminho = new GraphicsPath();
                caminho2 = new GraphicsPath();

            InitializeComponent();
        }
        protected virtual GraphicsPath GetPath(int index)
        {
            Rectangle rect = base.GetTabRect(index);
            GraphicsPath gp = new GraphicsPath();
            
            switch (base.Alignment)
            {
                case TabAlignment.Top:
                    gp.AddLine(rect.Left + 1, rect.Bottom, rect.Left + 1, rect.Top);
                    gp.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom);
                    break;
                case TabAlignment.Bottom:
                    gp.AddLine(rect.Left + 1, rect.Top - 1, rect.Left + 1, rect.Bottom);
                    gp.AddLine(rect.Right, rect.Bottom, rect.Right, rect.Top - 1);
                    break;
                case TabAlignment.Left:
                    gp.AddLine(rect.Right + 1, rect.Top + 1, rect.Left + 1, rect.Top + 1);
                    gp.AddLine(rect.Left + 1, rect.Bottom, rect.Right, rect.Bottom);
                    break;
                case TabAlignment.Right:
                    gp.AddLine(rect.Left - 1, rect.Top + 1, rect.Right - 2, rect.Top + 1);
                    gp.AddLine(rect.Right - 2, rect.Bottom, rect.Left - 1, rect.Bottom);
                    break;
            }

            return gp;
        }
示例#19
0
        public static void DrawPolygon(Graphics graphics, Polygon pol, Brush brush, Pen pen, IViewport viewport)
        {
            if (pol.ExteriorRing == null) return;
            if (pol.ExteriorRing.Vertices.Count <= 2) return;

            //Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
            var gp = new GraphicsPath();

            //Add the exterior polygon
            var points = GeometryRenderer.WorldToScreenGDI(pol.ExteriorRing, viewport);
            if (points.Length > 2)
                gp.AddPolygon(points);
            //Add the interior polygons (holes)
            foreach (LinearRing linearRing in pol.InteriorRings)
            {
                var interiorPoints = GeometryRenderer.WorldToScreenGDI(linearRing, viewport);
                if (interiorPoints.Length > 2)
                    gp.AddPolygon(interiorPoints);
            }

            if (gp.PointCount == 0) return;

            // Only render inside of polygon if the brush isn't null or isn't transparent
            if (brush != null && brush != Brushes.Transparent)
                graphics.FillPath(brush, gp);
            // Create an outline if a pen style is available
            if (pen != null)
                graphics.DrawPath(pen, gp);
        }
示例#20
0
		private void SimpleShapedForm_Load(object sender, EventArgs e)
		{
			GraphicsPath path = new GraphicsPath();
			path.AddEllipse(0, 0, this.Width, this.Height);
			this.Region = new Region(path);

		}
示例#21
0
        /// <summary>
        /// Repaints the form with cool background and stuff
        /// </summary>
        /// <param name="graph">The graphics object to paint to, the element will be drawn to 0, 0</param>
        public override void Paint(Graphics graph)
        {
            //Draws Rectangular Shapes
            if (Shape == ModelShape.Arrow)
            {
                _arrowPath = new GraphicsPath();

                //Draws the basic shape
                Pen arrowPen;
                if (Highlight < 1)
                    arrowPen = new Pen(Color.Cyan, 3F);
                else
                    arrowPen = new Pen(Color.Black, 3F);

                //Draws the curved arrow
                Point[] lineArray = new Point[4];
                lineArray[0] = new Point(_startPoint.X, _startPoint.Y);
                lineArray[1] = new Point(_startPoint.X - ((_startPoint.X - _stopPoint.X) / 3), _startPoint.Y);
                lineArray[2] = new Point(_stopPoint.X - ((_stopPoint.X - _startPoint.X) / 3), _stopPoint.Y);
                lineArray[3] = new Point(_stopPoint.X, _stopPoint.Y);
                graph.DrawBeziers(arrowPen, lineArray);
                _arrowPath.AddBeziers(lineArray);
                _arrowPath.Flatten();

                //Draws the arrow head
                Point[] arrowArray = new Point[3];
                arrowArray[0] = _stopPoint;
                arrowArray[1] = new Point(_stopPoint.X - (5 * Math.Sign(_stopPoint.X - _startPoint.X)), _stopPoint.Y - 2);
                arrowArray[2] = new Point(_stopPoint.X - (5 * Math.Sign(_stopPoint.X - _startPoint.X)), _stopPoint.Y + 2);
                graph.DrawPolygon(arrowPen, arrowArray);

                //Garbage collection
                arrowPen.Dispose();
            }
        }
示例#22
0
 public void child_Paint(object sender, PaintEventArgs e)
 {
     GraphicsPath path = new GraphicsPath();
     path.AddEllipse(this.ClientRectangle);
     Region region = new Region(path);
     this.Region = region;
 }
示例#23
0
 /// <summary>
 /// 建立带有圆角样式的路径。
 /// </summary>
 /// <param name="rect">用来建立路径的矩形。</param>
 /// <param name="radius">圆角的大小。</param>
 /// <returns>建立的路径。</returns>
 public static GraphicsPath CreateRoundPath(Rectangle rect, int radius)
 {
     GraphicsPath path = new GraphicsPath();
     int radiusCorrection = 1;
     path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
     path.AddArc(
         rect.Right - radius - radiusCorrection,
         rect.Y,
         radius,
         radius,
         270,
         90);
     path.AddArc(
         rect.Right - radius - radiusCorrection,
         rect.Bottom - radius - radiusCorrection,
         radius,
         radius, 0, 90);
     path.AddArc(
         rect.X,
         rect.Bottom - radius - radiusCorrection,
         radius,
         radius,
         90,
         90);
     path.CloseFigure();
     return path;
 }
示例#24
0
        //public static GraphicsPath GetBottomRoundRect(RectangleF r, int offset)
        //{
        //    int left = Math.Min((int)r.Left, (int)r.Right);
        //    int right = Math.Max((int)r.Left, (int)r.Right);
        //    int top = Math.Min((int)r.Top, (int)r.Bottom);
        //    int bottom = Math.Max((int)r.Top, (int)r.Bottom);
        //    GraphicsPath path = new GraphicsPath();
        //    path.AddLine(r.Right, r.Top, r.Right, r.Top);
        //    path.AddArc(right - offset, bottom - offset, offset, offset, 0.0f, 90.0f);
        //    path.AddArc(left, bottom - offset, offset, offset, 90.0f, 90.0f);
        //    path.AddLine(r.Left, r.Top, r.Left, r.Top);
        //    path.CloseFigure();
        //    return path;
        //}
        public static GraphicsPath GetTopRoundedRect(RectangleF r, int offset)
        {
            int left = Math.Min((int)r.Left, (int)r.Right);
            int right = Math.Max((int)r.Left, (int)r.Right);

            int top = Math.Min((int)r.Top, (int)r.Bottom);
            int bottom = Math.Max((int)r.Top, (int)r.Bottom);

            GraphicsPath path = new GraphicsPath();
            try
            {
                path.AddArc(right - offset, top, offset, offset, 270.0f, 90.0f);
                path.AddLine(r.Right, r.Bottom, r.Right, r.Bottom);
                path.AddLine(r.Left, r.Bottom, r.Left, r.Bottom);
                path.AddArc(left, top, offset, offset, 180.0f, 90.0f);
                path.CloseFigure();

                return path;
            }
            catch
            {
                path.Dispose();
                throw;
            }
        }
示例#25
0
        public override void AddTabBorder(GraphicsPath path, Rectangle tabBounds)
        {

            switch (tabControl.Alignment)
            {
                case TabAlignment.Top:
                    path.AddLine(tabBounds.X, tabBounds.Bottom, tabBounds.X, tabBounds.Y + this.radius);
                    path.AddArc(tabBounds.X, tabBounds.Y, this.radius * 2, this.radius * 2, 180, 90);
                    path.AddLine(tabBounds.X + this.radius, tabBounds.Y, tabBounds.Right - this.radius, tabBounds.Y);
                    path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Y, this.radius * 2, this.radius * 2, 270, 90);
                    path.AddLine(tabBounds.Right, tabBounds.Y + this.radius, tabBounds.Right, tabBounds.Bottom);
                    break;
                case TabAlignment.Bottom:
                    path.AddLine(tabBounds.Right, tabBounds.Y, tabBounds.Right, tabBounds.Bottom - this.radius);
                    path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 0, 90);
                    path.AddLine(tabBounds.Right - this.radius, tabBounds.Bottom, tabBounds.X + this.radius, tabBounds.Bottom);
                    path.AddArc(tabBounds.X, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 90, 90);
                    path.AddLine(tabBounds.X, tabBounds.Bottom - this.radius, tabBounds.X, tabBounds.Y);
                    break;
                case TabAlignment.Left:
                    path.AddLine(tabBounds.Right, tabBounds.Bottom, tabBounds.X + this.radius, tabBounds.Bottom);
                    path.AddArc(tabBounds.X, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 90, 90);
                    path.AddLine(tabBounds.X, tabBounds.Bottom - this.radius, tabBounds.X, tabBounds.Y + this.radius);
                    path.AddArc(tabBounds.X, tabBounds.Y, this.radius * 2, this.radius * 2, 180, 90);
                    path.AddLine(tabBounds.X + this.radius, tabBounds.Y, tabBounds.Right, tabBounds.Y);
                    break;
                case TabAlignment.Right:
                    path.AddLine(tabBounds.X, tabBounds.Y, tabBounds.Right - this.radius, tabBounds.Y);
                    path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Y, this.radius * 2, this.radius * 2, 270, 90);
                    path.AddLine(tabBounds.Right, tabBounds.Y + this.radius, tabBounds.Right, tabBounds.Bottom - this.radius);
                    path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 0, 90);
                    path.AddLine(tabBounds.Right - this.radius, tabBounds.Bottom, tabBounds.X, tabBounds.Bottom);
                    break;
            }
        }
示例#26
0
 public FormDashboard()
 {
     InitializeComponent();
     // закругление углов формы
     border = GetRoundedRectanglePath(this.Bounds, new SizeF(5, 5));
     region = new Region(border);
 }
示例#27
0
 public override GraphicsPath MakePath()
 {
     GraphicsPath path1 = new GraphicsPath(FillMode.Winding);
     RectangleF ef1 = this.Bounds;
     path1.AddEllipse(ef1.X, ef1.Y, ef1.Width, ef1.Height);
     return path1;
 }
示例#28
0
        public new void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons) {

            GraphicsPath gpSeekPosition = new GraphicsPath();
            gpSeekPosition.AddLine(new PointF(6.0F, 2), new PointF(this.SeekerBounds.Width - this.SeekerPosition * (this.SeekerBounds.Width - 15) - 5, 2));
            gpSeekPosition.Widen(this.m_pOneWidth);
            this.DrawBwShape(g, gpSeekPosition, this.ButtonOpacity, 4.0F, Color.Black, ControlPaint.LightLight(Color.LightSeaGreen));

            if (this.m_isMouseDown == true) {

                if (pntMouseLocation.X < pntDrawOffset.X) {
                    this.SeekerPosition = 0.0F;
                }
                else if (pntMouseLocation.X > pntDrawOffset.X + this.SeekerBounds.Width - 15) {
                    this.SeekerPosition = 1.0F;
                }
                else {
                    this.SeekerPosition = (pntMouseLocation.X - pntDrawOffset.X - 6) / (this.SeekerBounds.Width - 15);
                }
            }

            float xBeginningOffset = pntDrawOffset.X;

            pntDrawOffset.X += this.SeekerPosition * (this.SeekerBounds.Width - 15);

            this.HotSpot = new RectangleF(-pntDrawOffset.X + xBeginningOffset, -15, this.SeekerBounds.Width, 20);

            base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons);

            gpSeekPosition.Dispose();
        }
示例#29
0
 private void Task1_Paint(object sender, PaintEventArgs e)
 {
     e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     switch (_current)
     {
         case TextType.In:
             e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.DarkSlateGray), 10, 75);
             e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.Black), 12, 77);
             break;
         case TextType.Out:
             e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.Black), 10, 75);
             e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.DarkSlateGray), 12, 77);
             break;
         case TextType.Kon:
             GraphicsPath path = new GraphicsPath();
             path.AddString("Sample",
                 new FontFamily("Arial"),
                 (int) FontStyle.Italic,
                 50,
                 new Point(10, 75),
                 StringFormat.GenericDefault);
             e.Graphics.DrawPath(new Pen(Color.Black), path);
             break;
     }
 }
        /// <summary>
        /// Изчертава елипсите.
        /// </summary>
        /// <param name="graphics"></param>
        public override void DrawYourSelf(Graphics graphics)
        {
            GraphicsPath path = new GraphicsPath();
            path.StartFigure();
            path.AddEllipse(Location.X + ModelSize.Width / 3, Location.Y + ModelSize.Height / 3, ModelSize.Width / 3, ModelSize.Height / 3);
            path.CloseFigure();
            path.StartFigure();
            path.AddLine(Location.X + (ModelSize.Width * 2) / 3, Location.Y + ModelSize.Height / 2, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 2);
            path.CloseFigure();
            path.AddEllipse(new RectangleF(Location, ModelSize));
            path.CloseFigure();
            path.Transform(this.TMatrix.TransformationMatrix);

            /*
             * Създава се Pen, който изчертава контура, като използва
             * цвят и дебелина (определят се от конструктора)
             */
            Pen pen = new Pen(this.BorderColor, this.BorderWidth);
            // Правим същото, но за запълването
            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }
            graphics.DrawPath(pen, path);
            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
示例#31
0
        // draws link
        public void Draw(Graphics canvas)
        {
            Pen pen = new Pen(Color.Black, 1);

            // create arrow cap
            System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
            Point[] points = new Point[3];
            points[0] = new Point(0, 0);
            points[1] = new Point(-4, -7);
            points[2] = new Point(4, -7);
            graphicsPath.AddPolygon(points);
            pen.CustomEndCap = new System.Drawing.Drawing2D.CustomLineCap(graphicsPath, null);
            canvas.DrawLine(pen, from.Layout.X, from.Layout.Y, to.Layout.X, to.Layout.Y);
        }
示例#32
0
    /*******************************/
    /// <summary>
    /// Creates a GraphicsPath from two Int Arrays with a specific number of points.
    /// </summary>
    /// <param name="xPoints">Int Array to set the X points of the GraphicsPath</param>
    /// <param name="yPoints">Int Array to set the Y points of the GraphicsPath</param>
    /// <param name="pointsNumber">Number of points to add to the GraphicsPath</param>
    /// <returns>A new GraphicsPath</returns>
    public static System.Drawing.Drawing2D.GraphicsPath CreateGraphicsPath(int[] xPoints, int[] yPoints, int pointsNumber)
    {
        System.Drawing.Drawing2D.GraphicsPath tempGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
        if (pointsNumber == 2)
        {
            tempGraphicsPath.AddLine(xPoints[0], yPoints[0], xPoints[1], yPoints[1]);
        }
        else
        {
            System.Drawing.Point[] tempPointArray = new System.Drawing.Point[pointsNumber];
            for (int index = 0; index < pointsNumber; index++)
            {
                tempPointArray[index] = new System.Drawing.Point(xPoints[index], yPoints[index]);
            }

            tempGraphicsPath.AddPolygon(tempPointArray);
        }
        return(tempGraphicsPath);
    }
示例#33
0
        public static System.Drawing.Drawing2D.GraphicsPath Create(Rectangle bounds,
                                                                   int topoffset, int bottomoffset, int shrink)
        {
            System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath();
            p.StartFigure();

            //____
            p.AddLine(bounds.X + topoffset + shrink, bounds.Y + shrink, bounds.Width - bottomoffset - shrink, bounds.Y + shrink);
            // \
            p.AddLine(bounds.Width - bottomoffset - shrink, bounds.Y + shrink, bounds.Width - shrink, bounds.Y + bottomoffset + shrink);
            // |
            p.AddLine(bounds.Width - shrink, bounds.Y + bottomoffset + shrink, bounds.Width - topoffset - shrink, bounds.Height - shrink);
            // /
            p.AddLine(bounds.Width - topoffset - shrink, bounds.Height - shrink, bounds.X + bottomoffset + shrink, bounds.Height - shrink);
            //____
            p.AddLine(bounds.X + bottomoffset + shrink, bounds.Height - shrink, bounds.X + shrink, bounds.Height - bottomoffset - shrink);
            // \
            p.AddLine(bounds.X + shrink, bounds.Height - bottomoffset - shrink, bounds.X + topoffset + shrink, bounds.Y + shrink);

            p.CloseFigure();
            return(p);
        }
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        base.OnPaint(e);

        //* Create a new bitmap to hold the image and allow for its manipulation before it is displayed
        Bitmap backImage;

        if (img != null)
        {
            backImage = new Bitmap(img);
        }
        else
        {
            backImage = new Bitmap(PictureStream);
        }

        //* Rotate the image by using the arbitrary angle set by user.

        //* Move the origin to the center of the control:
        e.Graphics.TranslateTransform(ClientRectangle.Width / 2f, ClientRectangle.Height / 2f);
        //* Rotate the image:
        e.Graphics.RotateTransform(-m_Angle);
        //* Move the origin back to to the upper-left corner of the control:
        e.Graphics.TranslateTransform(-ClientRectangle.Width / 2f, -ClientRectangle.Height / 2f);

        //* Limit painting region so corners do not hide other close controls.
        System.Drawing.Drawing2D.GraphicsPath CircularPath = new System.Drawing.Drawing2D.GraphicsPath();
        CircularPath.AddEllipse(ClientRectangle);
        Region = new Region(CircularPath);

        //* Pass the current image to the FlipHV sub to flip it (if H or V flip is enabled) and display it
        FlipHV(e.Graphics, backImage, m_flipV, m_flipH);

        backImage.Dispose();

        //* Reset the transformation
        e.Graphics.ResetTransform();
    }
示例#35
0
    protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs myMenu)
    {
        if ((!myMenu.Item.Selected) && (!myMenu.Item.Pressed))
        {
            base.OnRenderMenuItemBackground(myMenu);
        }

        else
        {
            Rectangle itemBounds = new Rectangle(Point.Empty, new Size(myMenu.Item.Size.Width, myMenu.Item.Size.Height));

            System.Drawing.Drawing2D.LinearGradientBrush myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(itemBounds, highMenuColor, Color.FromArgb(255, 0, 0, 0), System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal);

            //Fill Color
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            gp = Tools.CnCRectangle.Create(itemBounds, 8, 4, 0);
            myMenu.Graphics.FillPath(myBrush, gp);
            //myMenu.Graphics.FillRectangle(myBrush, menuRectangle);
            // Border Color

            Rectangle linebounds = new Rectangle(itemBounds.X, itemBounds.Y, itemBounds.Width - 1, itemBounds.Height - 1);
            myMenu.Graphics.DrawLine(
                Pens.LightGray,
                new Point(linebounds.X, linebounds.Y + 1),
                new Point(linebounds.Width - 5, linebounds.Y + 1));
            myMenu.Graphics.DrawLine(
                Pens.LightGray,
                new Point(linebounds.Width - 5, linebounds.Y + 1),
                new Point(linebounds.Width, linebounds.Y + 6));

            myMenu.Graphics.DrawLine(
                Pens.LightGray,
                new Point(linebounds.Width, linebounds.Height - 1),
                new Point(linebounds.X + 4, linebounds.Height - 1));
            myMenu.Graphics.DrawLine(
                Pens.LightGray,
                new Point(linebounds.X + 4, linebounds.Height - 1),
                new Point(linebounds.X, linebounds.Height - 5));
            //myMenu.Graphics.DrawRectangle(Pens.Gray, 1, 1, menuRectangle.Width - 3, menuRectangle.Height - 3);

            if (myMenu.Item.Pressed)
            {
                myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(itemBounds, highMenuColor, Color.FromArgb(0, highMenuColor.R, highMenuColor.G, highMenuColor.B), System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal);

                myMenu.Graphics.FillPath(myBrush, gp);
                myMenu.Graphics.DrawLine(
                    Pens.White,
                    new Point(linebounds.X, linebounds.Y + 1),
                    new Point(linebounds.Width - 5, linebounds.Y + 1));
                myMenu.Graphics.DrawLine(
                    Pens.White,
                    new Point(linebounds.Width - 5, linebounds.Y + 1),
                    new Point(linebounds.Width, linebounds.Y + 6));

                myMenu.Graphics.DrawLine(
                    Pens.White,
                    new Point(linebounds.Width, linebounds.Height - 1),
                    new Point(linebounds.X + 4, linebounds.Height - 1));
                myMenu.Graphics.DrawLine(
                    Pens.White,
                    new Point(linebounds.X + 4, linebounds.Height - 1),
                    new Point(linebounds.X, linebounds.Height - 5));
                //myMenu.Graphics.FillRectangle(myBrush, itemBounds);
                //myMenu.Graphics.DrawRectangle(Pens.White, 1, 1, itemBounds.Width - 3, itemBounds.Height - 3);
            }
        }
    }
示例#36
0
 public GraphicsPathHandler()
 {
     Control = new sd2.GraphicsPath();
 }
示例#37
0
        private void Render(IGraphics ig)
        {
            string s = cbWhat.Text;

            if (string.IsNullOrEmpty(s))
            {
            }
            else if (s == "Clipping")
            {
                Pen pn  = new Pen(Color.LightGray, 5.6f);
                Pen pn2 = new Pen(Color.Yellow, 1.2f);

                ig.Clear(Color.Black);

                GraphicsContainer cnt = ig.BeginContainer();

                ig.SmoothingMode = SmoothingMode.HighQuality;

                ig.SetClip(new Rectangle(35, 35, 120, 120));

                ig.DrawRectangle(pn, 5, 5, 45, 70);
                ig.DrawRectangle(pn, 15, 25, 90, 120);
                ig.DrawRectangle(pn, 50, 30, 100, 170);
                ig.DrawRectangle(pn, 5, 80, 180, 30);
                ig.DrawRectangle(pn, 75, 10, 40, 160);

                ig.EndContainer(cnt);

                ig.DrawRectangle(pn2, 5, 5, 45, 70);
                ig.DrawRectangle(pn2, 15, 25, 90, 120);
                ig.DrawRectangle(pn2, 50, 30, 100, 170);
                ig.DrawRectangle(pn2, 5, 80, 180, 30);
                ig.DrawRectangle(pn2, 75, 10, 40, 160);
            }
            else if (s == "Transforms")
            {
                ig.Clear(Color.Black);

                ig.RotateTransform(15);
                ig.DrawRectangle(new Pen(Color.Red, 2.7f), 260, 80, 50, 40);
                ig.ResetTransform();
                ig.DrawRectangle(new Pen(Color.Red, 2.7f), 260, 80, 50, 40);

                ig.TranslateTransform(15, -5);

                GraphicsContainer cnt = ig.BeginContainer();

                ig.SmoothingMode = SmoothingMode.HighQuality;

                ig.RotateTransform(5);
                ig.FillEllipse(new SolidBrush(Color.Orange), 100, 100, 80, 40);
                ig.DrawRectangle(new Pen(Color.Orange, 2), 60, 80, 40, 40);

                GraphicsContainer cnt2 = ig.BeginContainer();

                ig.SmoothingMode = SmoothingMode.None;

                ig.RotateTransform(5);
                ig.ScaleTransform(1.1f, 1.2f);

                ig.FillEllipse(new SolidBrush(Color.YellowGreen), 130, 180, 80, 40);
                ig.DrawRectangle(new Pen(Color.YellowGreen, 2.7f), 62, 80, 40, 40);

                GraphicsContainer cnt3 = ig.BeginContainer();

                ig.SmoothingMode = SmoothingMode.HighQuality;

                Matrix mm = new Matrix();
                mm.Shear(0.3f, 0f);
                ig.Transform = mm;

                ig.FillEllipse(new SolidBrush(Color.Green), 180, 120, 80, 40);
                ig.DrawRectangle(new Pen(Color.Green, 2), 62, 84, 40, 40);

                ig.EndContainer(cnt3);

                ig.EndContainer(cnt2);

                ig.FillEllipse(new SolidBrush(Color.Blue), 120, 150, 80, 40);
                ig.DrawRectangle(new Pen(Color.Blue, 2), 64, 80, 40, 40);

                ig.EndContainer(cnt);

                ig.FillEllipse(new SolidBrush(Color.Indigo), 80, 210, 80, 40);
                ig.DrawRectangle(new Pen(Color.Indigo, 2), 66, 80, 40, 40);

                ig.DrawRectangle(new Pen(Color.White, 2), 270, 30, 50, 40);
                ig.ResetTransform();
                ig.DrawRectangle(new Pen(Color.White, 2), 270, 30, 50, 40);
            }
            else if (s == "Lines")
            {
                ig.SmoothingMode = SmoothingMode.AntiAlias;

                Pen ow = new Pen(Color.Purple, 12.6f);
                ow.EndCap     = LineCap.Round;
                ow.StartCap   = LineCap.Round;
                ow.MiterLimit = 6f;
                ow.LineJoin   = LineJoin.Miter;

                ig.SmoothingMode = SmoothingMode.None;

                Pen tp = new Pen(Color.Red, 2.7f);
                tp.DashStyle = DashStyle.DashDot;

                ig.DrawLine(tp, 70, 20, 190, 20);

                tp.DashStyle = DashStyle.Dash;

                ig.DrawLine(tp, 70, 30, 190, 30);

                tp.DashStyle   = DashStyle.Custom;
                tp.DashPattern = new float[] { 1, 8, 2, 2 };

                ig.DrawLine(tp, 70, 40, 190, 40);

                ig.SmoothingMode = SmoothingMode.AntiAlias;

                PointF[] pts = new PointF[4];
                pts[0] = new PointF(20, 50);
                pts[1] = new PointF(30, 90);
                pts[2] = new PointF(65, 60);
                pts[3] = new PointF(50, 40);
                ig.DrawLines(ow, pts);

                Point[] polly = new Point[]
                {
                    new Point(200, 40),
                    new Point(220, 140),
                    new Point(240, 100),
                    new Point(290, 70),
                    new Point(230, 10)
                };

                ig.DrawPolygon(tp, polly);

                //arrows
                Pen arr = new Pen(Color.DarkGoldenrod, 5.7f);

                {
                    arr.Width    = 2;
                    arr.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
                    const float arrowWidth   = 11.0f; // TUNE:
                    const float arrowHeight  = 14f;   // TUNE:
                    var         arrowOutline = new System.Drawing.Drawing2D.GraphicsPath();
                    arrowOutline.AddLines(new PointF[] {
                        new PointF(-(arrowWidth / 2), -arrowHeight),
                        new PointF(0, 0),
                        new PointF((arrowWidth / 2), -arrowHeight),
                        new PointF(-(arrowWidth / 2), -arrowHeight)
                    });
                    var generalizationArrow = new System.Drawing.Drawing2D.CustomLineCap(null, arrowOutline);
                    generalizationArrow.SetStrokeCaps(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round);
                    generalizationArrow.BaseInset = arrowHeight;
                    arr.CustomEndCap = generalizationArrow;
                    ig.DrawLine(arr, 0, 120, 100, 200);
                }

                arr.Width = 5;
                AdjustableArrowCap aac = new AdjustableArrowCap(5, 3, false);
                arr.EndCap       = LineCap.Custom;
                arr.CustomEndCap = aac;
                arr.StartCap     = LineCap.ArrowAnchor;
                ig.DrawLine(arr, 50, 120, 150, 200);

                arr.Width    = 7f;
                arr.EndCap   = LineCap.RoundAnchor;
                arr.StartCap = LineCap.SquareAnchor;
                ig.DrawLine(arr, 100, 120, 200, 200);

                arr.Width    = 9;
                arr.EndCap   = LineCap.DiamondAnchor;
                arr.StartCap = LineCap.ArrowAnchor;
                ig.DrawLine(arr, 150, 120, 250, 200);

                Point[] al = new Point[]
                {
                    new Point(200, 100),
                    new Point(300, 200),
                    new Point(300, 150)
                };

                arr.Width    = 9;
                arr.EndCap   = LineCap.DiamondAnchor;
                arr.StartCap = LineCap.DiamondAnchor;
                ig.DrawLines(arr, al);
            }
            else if (s == "Curves")
            {
                PointF[] bezzie = new PointF[]
                {
                    new PointF(20, 150),

                    new PointF(110, 190),
                    new PointF(120, 200),
                    new PointF(50, 220),

                    new PointF(60, 200),
                    new PointF(140, 180),
                    new PointF(100, 160),

                    new PointF(180, 260),
                    new PointF(200, 210),
                    new PointF(190, 210)
                };

                Pen bpn = new Pen(Color.MediumSeaGreen, 2.3f);
                bpn.DashStyle   = DashStyle.Custom;
                bpn.DashPattern = new float[] { 6, 1, 5, 2, 4, 3, 3, 4, 2, 5, 6, 1 };
                ig.DrawBeziers(bpn, bezzie);

                PointF[] curvy = new PointF[]
                {
                    new PointF(130, 40),
                    new PointF(70, 70),
                    new PointF(50, 20),
                    new PointF(120, 120),
                    new PointF(150, 80),
                    new PointF(80, 150),
                    new PointF(80, 110)
                };

                ig.DrawCurve(new Pen(Color.Blue, 5.7f), curvy);
                ig.DrawCurve(new Pen(Color.Red, 2.7f), curvy, 2, 3);
                ig.DrawCurve(new Pen(Color.Yellow, 1.7f), curvy, 1f);

                Point[] ccurvy = new Point[]
                {
                    new Point(280, 30),
                    new Point(260, 60),
                    new Point(200, 20),
                    new Point(290, 120),
                    new Point(290, 80),
                    new Point(230, 150),
                    new Point(150, 50)
                };
                ig.DrawClosedCurve(new Pen(Color.Green, 3.7f), ccurvy, 1f, FillMode.Alternate);
                ig.DrawClosedCurve(new Pen(Color.Purple, 1.7f), ccurvy, 0f, FillMode.Alternate);

                Point[] fcc = new Point[]
                {
                    new Point(160, 350),
                    new Point(190, 370),
                    new Point(130, 390),
                    new Point(190, 400),
                    new Point(195, 410),
                    new Point(100, 430),
                    new Point(160, 450)
                };
                ig.FillClosedCurve(new SolidBrush(Color.Red), fcc, FillMode.Winding, 1f);
                ig.FillClosedCurve(new SolidBrush(Color.Aquamarine), fcc, FillMode.Alternate, .2f);
            }
            else if (s == "Transparency")
            {
                Point[] fillpoly = new Point[]
                {
                    new Point(20, 130),
                    new Point(60, 90),
                    new Point(30, 20),
                    new Point(80, 20),
                    new Point(15, 90),
                    new Point(100, 50),
                    new Point(0, 50)
                };

                Color col = Color.FromArgb(96, 255, 0, 0);

                ig.FillEllipse(new SolidBrush(Color.Ivory), 60, 140, 60, 30);
                ig.FillPolygon(new SolidBrush(Color.Ivory), fillpoly, FillMode.Winding);

                ig.TranslateTransform(10, 10);
                ig.FillEllipse(new SolidBrush(col), 60, 140, 60, 30);
                ig.FillPolygon(new SolidBrush(col), fillpoly, FillMode.Alternate);
                ig.ResetTransform();

                ig.FillPie(new SolidBrush(Color.FromArgb(100, 255, 0, 0)), 10, 200, 200, 80, 315, 90);
                ig.FillPie(new SolidBrush(Color.FromArgb(100, 128, 128, 0)), 10, 200, 200, 80, 250, -90);
                ig.FillPie(new SolidBrush(Color.FromArgb(100, 128, 0, 128)), 15, 205, 190, 70, 180, 270);
                ig.FillPie(new SolidBrush(Color.FromArgb(100, 200, 60, 60)), 20, 210, 180, 60, 45, -270);
            }
            else if (s == "Fills")
            {
                LinearGradientBrush gbr1 = new LinearGradientBrush(new Point(0, 0), new Point(30, 20), Color.Blue, Color.Plum);

                ColorBlend blend = new ColorBlend(3);
                blend.Colors             = new Color[] { Color.Red, Color.Yellow, Color.MediumSlateBlue };
                blend.Positions          = new float[] { 0, .3f, 1f };
                gbr1.InterpolationColors = blend;

                Point[] sp = new Point[]
                {
                    new Point(145, 145),
                    new Point(305, 250),
                    new Point(220, 250),
                    new Point(180, 250)
                };
                ig.FillPolygon(gbr1, sp);

                LinearGradientBrush gbr2 = new LinearGradientBrush(new Point(0, 0), new Point(10, 20), Color.WhiteSmoke, Color.CornflowerBlue);
                gbr2.WrapMode = WrapMode.TileFlipXY;
                Point[] sp2 = new Point[]
                {
                    new Point(25, 205),
                    new Point(75, 150),
                    new Point(110, 110),
                    new Point(40, 80)
                };
                ig.FillPolygon(gbr2, sp2);

                ig.FillRectangle(new HatchBrush(HatchStyle.DiagonalBrick, Color.Khaki, Color.Peru), 000, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Vertical, Color.Bisque, Color.Peru), 020, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.DarkVertical, Color.Tan, Color.Peru), 040, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.DiagonalCross, Color.Chocolate, Color.Peru), 060, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.WideDownwardDiagonal, Color.BurlyWood, Color.Peru), 080, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.LargeConfetti, Color.Wheat, Color.Peru), 100, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.ZigZag, Color.SaddleBrown, Color.Peru), 120, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.HorizontalBrick, Color.Linen, Color.Peru), 140, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.LightHorizontal, Color.Maroon, Color.Peru), 160, 5, 20, 20);
                ig.FillRectangle(gbr1, 200, 5, 20, 20);
                ig.FillRectangle(gbr2, 220, 5, 20, 20);

                ig.FillRectangle(new HatchBrush(HatchStyle.Percent05, Color.CornflowerBlue, Color.LemonChiffon), 000, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent10, Color.CornflowerBlue, Color.LemonChiffon), 020, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent20, Color.CornflowerBlue, Color.LemonChiffon), 040, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent25, Color.CornflowerBlue, Color.LemonChiffon), 060, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent30, Color.CornflowerBlue, Color.LemonChiffon), 080, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent40, Color.CornflowerBlue, Color.LemonChiffon), 100, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent50, Color.CornflowerBlue, Color.LemonChiffon), 120, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent60, Color.CornflowerBlue, Color.LemonChiffon), 140, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent70, Color.CornflowerBlue, Color.LemonChiffon), 160, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent75, Color.CornflowerBlue, Color.LemonChiffon), 180, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent80, Color.CornflowerBlue, Color.LemonChiffon), 200, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent90, Color.CornflowerBlue, Color.LemonChiffon), 220, 30, 20, 20);
            }
            else if (s == "Arcs/Pies")
            {
                //GDI does not seem to draw arcs correctly except when the ellipse is a circle.
                //These arcs demonstrate the problem.  SVGGraphics calculates arcs correctly.
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 5 * 3, 120, 110 * 3, 110, 0, 240);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 10 * 3, 125, 100 * 3, 100, 0, 210);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 15 * 3, 130, 90 * 3, 90, 0, 180);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 20 * 3, 135, 80 * 3, 80, 0, 150);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 25 * 3, 140, 70 * 3, 70, 0, 120);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 30 * 3, 145, 60 * 3, 60, 0, 90);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 35 * 3, 150, 50 * 3, 50, 0, 60);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 40 * 3, 155, 40 * 3, 40, 0, 270);

                ig.DrawPie(new Pen(Color.Pink, 2.7f), 110, 50, 100, 100, 315, 90);
                ig.DrawPie(new Pen(Color.Purple, 2.7f), 110, 50, 100, 100, 250, -90);
                ig.DrawPie(new Pen(Color.DarkRed, 2.7f), 115, 55, 90, 90, 180, 270);
                ig.DrawPie(new Pen(Color.Red, 2.7f), 120, 60, 80, 80, 45, -270);
            }
            else if (s == "Text")
            {
                Font fnt1 = new Font("Helvetica", 12, FontStyle.Italic | FontStyle.Bold);
                Font fnt2 = new Font(FontFamily.GenericMonospace, 16, FontStyle.Bold);
                Font fnt3 = new Font("", 40, FontStyle.Underline);

                Rectangle    rc1  = new Rectangle(30, 30, 220, 20);
                StringFormat fmt1 = new StringFormat();
                fmt1.Alignment = StringAlignment.Near;

                ig.DrawRectangle(new Pen(Color.Blue), rc1);
                ig.DrawString("Text...1", fnt1, new SolidBrush(Color.DarkGreen), rc1, fmt1);

                Rectangle    rc2  = new Rectangle(0, 0, 120, 20);
                StringFormat fmt2 = new StringFormat();
                fmt2.Alignment = StringAlignment.Center;

                ig.TranslateTransform(30, 160);
                ig.RotateTransform(90);

                ig.DrawRectangle(new Pen(Color.Blue), rc2);
                ig.DrawString("Text...2", fnt2, new SolidBrush(Color.DarkGreen), rc2, fmt2);

                ig.ResetTransform();

                Rectangle    rc3  = new Rectangle(30, 90, 300, 30);
                StringFormat fmt3 = new StringFormat();
                fmt3.Alignment = StringAlignment.Far;

                ig.DrawRectangle(new Pen(Color.Blue), rc3);
                ig.DrawString("Text...3", fnt3, new SolidBrush(Color.DarkGreen), rc3, fmt3);

                //measurestring
                const string mme = "MeasureString Is Impossible To Emulate";
                SizeF        siz = ig.MeasureString(mme, fnt1);
                ig.DrawRectangle(new Pen(Color.Red), 20, 200, siz.Width, siz.Height);
                siz = ig.MeasureString(mme, fnt1, 150);
                ig.DrawRectangle(new Pen(Color.Orange), 20, 230, siz.Width, siz.Height);
                siz = ig.MeasureString(mme, fnt1, new SizeF(150, 150), new StringFormat(StringFormatFlags.DirectionVertical));
                ig.DrawRectangle(new Pen(Color.Yellow), 20, 200, siz.Width, siz.Height);
            }
            else if (s == "Rect-aligned Text")
            {
                ig.Clear(Color.White);
                ig.ScaleTransform(
                    (float)panel1.ClientSize.Width / RectAlignedTextTest.CanvasSize,
                    (float)panel1.ClientSize.Height / RectAlignedTextTest.CanvasSize);
                RectAlignedTextTest.DrawTest(ig);
            }
            else if (s == "Images")
            {
                Icon ike = new Icon(GetType(), "App.ico");
                ig.DrawIcon(ike, 10, 10);
                //ig.DrawIcon(ike, new Rectangle(270, 400, 30, 40));

                Bitmap bmp = new Bitmap(GetType(), "test.bmp");
                ig.DrawImage(bmp, 100f, 150f);
                GraphicsContainer cnt = ig.BeginContainer();
                ig.RotateTransform(5);
                ig.DrawImage(bmp, 160f, 50f, 120f, 70f);
                ig.EndContainer(cnt);
                //ig.DrawImageUnscaled(bmp, 270, 450, 20, 20);
            }
            else if (s == "Path")
            {
                /* The following example GraphicsPath code comes from the MSDN docs on the GraphicsPathIterator class
                 * https://msdn.microsoft.com/en-us/library/79k451ts.aspx
                 *
                 */
                // Create a graphics path.
                GraphicsPath myPath = new GraphicsPath();

                // Set up primitives to add to myPath.
                Point[]   myPoints = { new Point(20, 20), new Point(120, 120), new Point(20, 120), new Point(20, 20) };
                Rectangle myRect   = new Rectangle(120, 120, 100, 100);

                // Add 3 lines, a rectangle, an ellipse, and 2 markers.
                myPath.AddLines(myPoints);
                myPath.SetMarkers();
                myPath.AddRectangle(myRect);
                myPath.SetMarkers();
                myPath.AddEllipse(220, 220, 100, 100);
                ig.DrawPath(new Pen(Color.Black, 1.7f), myPath);
                LinearGradientBrush gbr2 = new LinearGradientBrush(new Point(0, 0), new Point(10, 20), Color.WhiteSmoke, Color.CornflowerBlue);
                gbr2.WrapMode = WrapMode.TileFlipXY;
                ig.FillPath(gbr2, myPath);

                GraphicsPath myPath2 = new GraphicsPath();
                myPath2.AddLine(100, 100, 130, 120);
                myPath2.AddEllipse(120, 120, 120, 140);
                myPath2.AddBezier(130, 160, 170, 160, 150, 130, 200, 110);
                ig.DrawPath(new Pen(Color.Blue, 1.7f), myPath2);
            }
            else if (s == "Path 2 (Slow)")
            {
                SolidBrush   mySolidBrush   = new SolidBrush(Color.Aqua);
                GraphicsPath myGraphicsPath = new GraphicsPath();

                Point[] myPointArray =
                {
                    new Point(15, 20),
                    new Point(20, 40),
                    new Point(50, 30)
                };

                FontFamily   myFontFamily   = new FontFamily("Times New Roman");
                PointF       myPointF       = new PointF(50, 20);
                StringFormat myStringFormat = new StringFormat();

                myGraphicsPath.AddArc(0, 0, 30, 20, -90, 180);
                myGraphicsPath.AddCurve(myPointArray);
                myGraphicsPath.AddString("a string in a path filled", myFontFamily,
                                         0, 24, myPointF, myStringFormat);
                myGraphicsPath.AddPie(230, 10, 40, 40, 40, 110);
                ig.FillPath(mySolidBrush, myGraphicsPath);
                ig.DrawPath(new Pen(Color.Green, 1.7f), myGraphicsPath);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
示例#38
0
        /// <summary>
        /// Esta función se encarga de cortar la imagen y preparar su numeración, cada trozo lo almacena
        /// en la lista "tmpImagenes"
        /// </summary>
        /// <param name="Columnas">Columnas que tiene el tablero</param>
        /// <param name="Filas">Filas que tiene el tablero</param>
        /// <param name="Height">Altura de cada celda</param>
        /// <param name="Width">Anchura de cada celda</param>
        /// <returns>Retorna true en caso de haber podido preparar la imagen, y false si por cualquier error no se ha podido preparar</returns>
        public bool Preparar_Imagen(int Columnas, int Filas, int Height, int Width)
        {
            tmpImagenes.Clear();
            bool tmpResult = false;

            try
            {
                if (File.Exists(this.Ruta) == true)
                {
                    Image PicMain = null;
                    PicMain = Image.FromFile(this.Ruta);
                    //Comprovamos si la imagen es más pequeña que el tablero, si lo es, la redimensionamos antes de cortarla
                    if ((PicMain.Width < (Width * Columnas)) || (PicMain.Height < (Height * Filas)))
                    {
                        PicMain = this.Set_Minimum_Size(PicMain, new Size(Columnas * Width, Filas * Height));
                    }
                    int       TamanyoTrozoWidth   = PicMain.Width / Columnas;
                    int       TamanyoTrozoHeight  = PicMain.Height / Filas;
                    Rectangle Rectangulo_Destino  = new Rectangle(0, 0, Width, Height);
                    Bitmap    bmpDest             = null;
                    Graphics  tmpGraficos_Dibujo  = null;
                    Graphics  tmpGraficos_Numeros = null;
                    Rectangle Rectangulo_Original = new Rectangle();
                    int       tmpColumnaActual    = 0;
                    int       Pixel_X             = 0;
                    int       Pixel_Y             = 0;
                    Pixel_X = 0;
                    Pixel_Y = 0;
                    Font tmpFontBack = new Font("Comic Sanz", 15F, FontStyle.Bold, GraphicsUnit.Pixel);
                    for (int I = 0; I < (Columnas * Filas); I++)
                    {
                        Rectangulo_Original = new Rectangle(Pixel_X, Pixel_Y, TamanyoTrozoWidth, TamanyoTrozoHeight);
                        bmpDest             = new Bitmap(TamanyoTrozoWidth, TamanyoTrozoHeight);
                        tmpGraficos_Dibujo  = Graphics.FromImage(bmpDest);
                        tmpGraficos_Dibujo.DrawImage(PicMain, Rectangulo_Destino, Rectangulo_Original, GraphicsUnit.Pixel);
                        tmpGraficos_Numeros = Graphics.FromImage(bmpDest);
                        //Insertamos el número dentro del trozo de imagen para numerarla
                        if (this.NumerarImagenes == true)
                        {
                            GraphicsPath Lapiz = new System.Drawing.Drawing2D.GraphicsPath();
                            Lapiz.AddString((I + 1).ToString(), tmpFontBack.FontFamily, Convert.ToInt32(FontStyle.Bold), 20F, new Point(0, 0), StringFormat.GenericTypographic);
                            tmpGraficos_Numeros.FillPath(Brushes.White, Lapiz);
                            tmpGraficos_Numeros.DrawPath(Pens.Black, Lapiz);
                            tmpGraficos_Numeros.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                            tmpGraficos_Numeros.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                        }
                        tmpImagenes.Add(bmpDest);
                        tmpColumnaActual += 1;
                        Pixel_X          += TamanyoTrozoWidth;
                        if (tmpColumnaActual >= Columnas)
                        {
                            tmpColumnaActual = 0;
                            Pixel_X          = 0;
                            Pixel_Y         += TamanyoTrozoHeight;
                        }
                    }
                    tmpResult = true;
                }
                return(tmpResult);
            }
            catch
            {
                return(tmpResult);
            }
        }
示例#39
0
 public static void FillPath(Graphics g, System.Drawing.Drawing2D.GraphicsPath p, Color c)
 {
     _br.Color = ToDrawingColor(c);
     g.FillPath(_br, p);
 }
示例#40
0
        public static void DrawText(Font font, StringFormat sf, System.Drawing.Drawing2D.GraphicsPath path, StringBuilder sb, bool isItalic, bool isBold, bool isUnderline, float left, float top, ref bool newLine, float leftMargin, ref int pathPointsStart)
        {
            var next = new PointF(left, top);

            if (path.PointCount > 0)
            {
                int k = 0;

                PointF[] list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!!
                for (int i = list.Length - 1; i >= 0; i--)
                {
                    if (list[i].X > next.X)
                    {
                        next.X = list[i].X;
                    }
                    k++;
                    if (k > 60)
                    {
                        break;
                    }
                    if (i <= pathPointsStart && pathPointsStart != -1)
                    {
                        break;
                    }
                }
            }

            if (newLine)
            {
                next.X          = leftMargin;
                newLine         = false;
                pathPointsStart = path.PointCount;
            }

            var fontStyle = FontStyle.Regular;

            if (isItalic && isBold && isUnderline)
            {
                fontStyle = FontStyle.Italic | FontStyle.Bold | FontStyle.Underline;
            }
            else if (isItalic && isBold)
            {
                fontStyle = FontStyle.Italic | FontStyle.Bold;
            }
            else if (isItalic && isUnderline)
            {
                fontStyle = FontStyle.Italic | FontStyle.Underline;
            }
            else if (isUnderline && isBold)
            {
                fontStyle = FontStyle.Underline | FontStyle.Bold;
            }
            else if (isItalic)
            {
                fontStyle = FontStyle.Italic;
            }
            else if (isBold)
            {
                fontStyle = FontStyle.Bold;
            }
            else if (isUnderline)
            {
                fontStyle = FontStyle.Underline;
            }
            try
            {
                path.AddString(sb.ToString(), font.FontFamily, (int)fontStyle, font.Size, next, sf);
            }
            catch
            {
                fontStyle = FontStyle.Regular;
                try
                {
                    path.AddString(sb.ToString(), font.FontFamily, (int)fontStyle, font.Size, next, sf);
                }
                catch
                {
                    path.AddString(sb.ToString(), new FontFamily("Arial"), (int)fontStyle, font.Size, next, sf);
                }
            }
            sb.Length = 0;
        }
示例#41
0
        /// <summary>
        /// Method used to draw outer arc.
        /// </summary>
        /// <param name="Graphics">Graphics</param>
        /// <param name="GaugeArcStart">Start angle of the Outer arc</param>
        /// <param name="GaugeArcEnd">Sweep angle of the Outer Arc</param>
        /// <param name="Center">Center point for Gauge</param>
        /// <param name="Gaugeradius">Radius of the Outer Arc</param>
        public void DrawOuterArc(Graphics Graphics, Int32 GaugeArcStart, Int32 GaugeArcEnd, Point Center, int GaugeRadius)
        {
            Graphics.SmoothingMode   = SmoothingMode.AntiAlias;
            Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
            GraphicsPath pth = new GraphicsPath();
            Color        c   = this.RadialGauge.Parent != null ? this.RadialGauge.Parent.BackColor : Color.Empty;
            Rectangle    r   = new Rectangle(0, 0, this.RadialGauge.Width, this.RadialGauge.Height);

            System.Drawing.Drawing2D.GraphicsPath basePath = new System.Drawing.Drawing2D.GraphicsPath();

            int x = this.RadialGauge.Width;
            int y = this.RadialGauge.Height;

            int rectWidth    = (int)Math.Ceiling(this.RadialGauge.Width * 0.94);                                               // 94 % of the actual radial gauge width
            int rectRimWidth = (int)(rectWidth - (this.GetFrameThickness() * 2)); /* (int)Math.Ceiling(this.Width * 0.865); */ // 86.5 % of the actual radial gauge width

            //Define rectangles inside which we will draw circles.
            int       xOffset = (this.RadialGauge.Width - rectWidth) / 2;
            int       yOffset = (this.RadialGauge.Width - rectRimWidth) / 2;
            Rectangle rect; Rectangle rectrim;

            rect    = new Rectangle(xOffset, xOffset, rectWidth, rectWidth);
            rectrim = new Rectangle(yOffset, yOffset, rectRimWidth, rectRimWidth);

            if (this.RadialGauge.FrameType == FrameType.HalfCircle)
            {
                PointF Intersection1 = PointF.Empty; PointF Intersection2 = PointF.Empty;
                x = this.RadialGauge.Width;
                y = this.RadialGauge.Width;

                float outerRadius = rectWidth / 2;
                float innerRadius = outerRadius - this.GetFrameThickness();

                rect    = Rectangle.Round(new RectangleF(Center.X - outerRadius, Center.Y - outerRadius, outerRadius * 2, outerRadius * 2));
                rectrim = Rectangle.Round(new RectangleF(Center.X - innerRadius, Center.Y - innerRadius, innerRadius * 2, innerRadius * 2));

                PointF Point1 = new PointF(Center.X - outerRadius, this.RadialGauge.Height - this.GetFrameThickness());
                PointF Point2 = new PointF(Center.X - outerRadius + rectWidth + this.GetFrameThickness(), this.RadialGauge.Height - this.GetFrameThickness());

                PointF[] intersectionsPoints = this.FindLineCircleIntersections(
                    Center.X, Center.Y, outerRadius, Point1, Point2);
                Intersection1 = intersectionsPoints[0];
                Intersection2 = intersectionsPoints[1];



                //OUTER
                LinearGradientBrush gb = new LinearGradientBrush(rect, this.RadialGauge.OuterFrameGradientStartColor, this.RadialGauge.OuterFrameGradientEndColor, LinearGradientMode.Vertical);

                pth.AddEllipse(rect);

                PathGradientBrush pgb = new PathGradientBrush(pth);

                pgb.CenterColor = this.RadialGauge.BackgroundGradientStartColor;

                pgb.SurroundColors = new Color[] { this.RadialGauge.BackgroundGradientEndColor };

                pgb.FocusScales = new PointF(0.1f, 0.1f);

                Blend bevelBlend = new Blend();
                bevelBlend.Positions = new float[] { 0.0f, .2f, .4f, .6f, .8f, 1.0f };
                bevelBlend.Factors   = new float[] { .2f, .4f, .6f, .6f, 1f, 1f };
                Rectangle lgbRect = rect;
                lgbRect.Inflate(1, 1);
                LinearGradientBrush innerBevelBrush = new LinearGradientBrush(lgbRect,
                                                                              this.RadialGauge.InnerFrameGradientStartColor,
                                                                              this.RadialGauge.InnerFrameGradientEndColor,
                                                                              LinearGradientMode.BackwardDiagonal);

                innerBevelBrush.Blend = bevelBlend;

                if (this.RadialGauge.ShowBackgroundFrame)
                {
                    Graphics.FillEllipse(gb, rect);
                    //Inner background
                    Graphics.FillEllipse(innerBevelBrush, rectrim);
                    rectrim.Inflate(-3, -3);
                    //Center circle
                    this.InnerRect = rectrim;
                    Graphics.FillEllipse(pgb, rectrim);
                    {
                        this.BottomRect = new Rectangle(rectrim.X + (xOffset / 2), this.RadialGauge.Height - xOffset, rect.Width - (2 * ((rectrim.X + (xOffset / 2)) - rect.X)), xOffset);
                    }


                    //Bottom rect
                    Graphics.FillRectangle(gb, this.BottomRect);
                }
            }

            GraphicsPath gp = new GraphicsPath();

            if (GaugeRadius > 0)
            {
                float thickness = GetArcThickness();
                Graphics.DrawArc(new Pen(thickness == 0 ? Color.Transparent : this.RadialGauge.GaugeArcColor, thickness), new Rectangle(Center.X - GaugeRadius, Center.Y - GaugeRadius,
                                                                                                                                        2 * GaugeRadius, 2 * GaugeRadius), GaugeArcStart, GaugeArcEnd);
                float rangeSweepAngle = this.RadialGauge.Value * this.RadialGauge.SweepAngle / (this.RadialGauge.MaximumValue - this.RadialGauge.MinimumValue);
                Graphics.DrawArc(new Pen(System.Drawing.ColorTranslator.FromHtml("#0CBDF4"), thickness), new Rectangle(Center.X - GaugeRadius, Center.Y - GaugeRadius,
                                                                                                                       2 * GaugeRadius, 2 * GaugeRadius), RadialGauge.StartAngle, rangeSweepAngle);

                SolidBrush br = new SolidBrush(this.RadialGauge.GaugeLableColor);
                SizeF      s;
                Point      p;

                Font  labelFont      = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                Color labelForeColor = Color.Black;

                br = new SolidBrush(labelForeColor);
                s  = Graphics.MeasureString("0M", labelFont);
                p  = new Point((int)((Center.X - GaugeRadius) - (s.Width / 2)), Center.Y + GaugeRadius / 6);
                Graphics.DrawString("0M", labelFont, br, p);
                s = Graphics.MeasureString("120M", labelFont);
                p = new Point((int)((Center.Y + GaugeRadius) - (s.Width / 2)), Center.Y + GaugeRadius / 6);
                Graphics.DrawString("120M", labelFont, br, p);

                br.Dispose();
            }
        }
示例#42
0
        /// <summary>This method will paint the control.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintBack(System.Drawing.Graphics g)
        {
            //Set Graphics smoothing mode to Anit-Alias--
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //-------------------------------------------

            //Declare Variables------------------
            int ArcWidth  = this.RoundCorners * 2;
            int ArcHeight = this.RoundCorners * 2;
            int ArcX1     = 0;
            int ArcX2     = (this.ShadowControl) ? (this.Width - (ArcWidth + 1)) - this.ShadowThickness : this.Width - (ArcWidth + 1);
            int ArcY1     = 10;
            int ArcY2     = (this.ShadowControl) ? (this.Height - (ArcHeight + 1)) - this.ShadowThickness : this.Height - (ArcHeight + 1);

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;
            //-----------------------------------

            //Check if shadow is needed----------
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 180, SweepAngle); // Top Left
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 270, SweepAngle); //Top Right
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 360, SweepAngle); //Bottom Right
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 90, SweepAngle);  //Bottom Left
                ShadowPath.CloseAllFigures();

                //Paint Rounded Rectangle------------
                g.FillPath(ShadowBrush, ShadowPath);
                //-----------------------------------
            }
            //-----------------------------------

            //Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, SweepAngle); // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, SweepAngle); //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, SweepAngle); //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, SweepAngle);  //Bottom Left
            path.CloseAllFigures();
            //-----------------------------------

            //Check if Gradient Mode is enabled--
            if (this.BackgroundGradientMode == GroupBoxGradientMode.None)
            {
                //Paint Rounded Rectangle------------
                g.FillPath(BackgroundBrush, path);
                //-----------------------------------
            }
            else
            {
                BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), this.BackgroundColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);

                //Paint Rounded Rectangle------------
                g.FillPath(BackgroundGradientBrush, path);
                //-----------------------------------
            }
            //-----------------------------------

            //Paint Borded-----------------------
            g.DrawPath(BorderPen, path);
            //-----------------------------------

            //Destroy Graphic Objects------------
            if (path != null)
            {
                path.Dispose();
            }
            if (BorderBrush != null)
            {
                BorderBrush.Dispose();
            }
            if (BorderPen != null)
            {
                BorderPen.Dispose();
            }
            if (BackgroundGradientBrush != null)
            {
                BackgroundGradientBrush.Dispose();
            }
            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
            }
            if (ShadowBrush != null)
            {
                ShadowBrush.Dispose();
            }
            if (ShadowPath != null)
            {
                ShadowPath.Dispose();
            }
            //-----------------------------------
        }
示例#43
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pg"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static D2D.GraphicsPath ToGraphicsPath(this IPathGeometry pg, double dx, double dy, Func <double, float> scale)
        {
            var gp = new D2D.GraphicsPath
            {
                FillMode = pg.FillRule == FillRule.EvenOdd ? D2D.FillMode.Alternate : D2D.FillMode.Winding
            };

            foreach (var pf in pg.Figures)
            {
                var startPoint = pf.StartPoint;

                foreach (var segment in pf.Segments)
                {
                    if (segment is ArcSegment arcSegment)
                    {
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                        // TODO: Convert WPF/SVG elliptical arc segment format to GDI+ bezier curves.
                        //startPoint = arcSegment.Point;
                    }
                    else if (segment is CubicBezierSegment cubicBezierSegment)
                    {
                        gp.AddBezier(
                            scale(startPoint.X + dx),
                            scale(startPoint.Y + dy),
                            scale(cubicBezierSegment.Point1.X + dx),
                            scale(cubicBezierSegment.Point1.Y + dy),
                            scale(cubicBezierSegment.Point2.X + dx),
                            scale(cubicBezierSegment.Point2.Y + dy),
                            scale(cubicBezierSegment.Point3.X + dx),
                            scale(cubicBezierSegment.Point3.Y + dy));
                        startPoint = cubicBezierSegment.Point3;
                    }
                    else if (segment is LineSegment lineSegment)
                    {
                        gp.AddLine(
                            scale(startPoint.X + dx),
                            scale(startPoint.Y + dy),
                            scale(lineSegment.Point.X + dx),
                            scale(lineSegment.Point.Y + dy));
                        startPoint = lineSegment.Point;
                    }
                    else if (segment is PolyCubicBezierSegment polyCubicBezierSegment)
                    {
                        if (polyCubicBezierSegment.Points.Length >= 3)
                        {
                            gp.AddBezier(
                                scale(startPoint.X + dx),
                                scale(startPoint.Y + dy),
                                scale(polyCubicBezierSegment.Points[0].X + dx),
                                scale(polyCubicBezierSegment.Points[0].Y + dy),
                                scale(polyCubicBezierSegment.Points[1].X + dx),
                                scale(polyCubicBezierSegment.Points[1].Y + dy),
                                scale(polyCubicBezierSegment.Points[2].X + dx),
                                scale(polyCubicBezierSegment.Points[2].Y + dy));
                        }

                        if (polyCubicBezierSegment.Points.Length > 3 &&
                            polyCubicBezierSegment.Points.Length % 3 == 0)
                        {
                            for (int i = 3; i < polyCubicBezierSegment.Points.Length; i += 3)
                            {
                                gp.AddBezier(
                                    scale(polyCubicBezierSegment.Points[i - 1].X + dx),
                                    scale(polyCubicBezierSegment.Points[i - 1].Y + dy),
                                    scale(polyCubicBezierSegment.Points[i].X + dx),
                                    scale(polyCubicBezierSegment.Points[i].Y + dy),
                                    scale(polyCubicBezierSegment.Points[i + 1].X + dx),
                                    scale(polyCubicBezierSegment.Points[i + 1].Y + dy),
                                    scale(polyCubicBezierSegment.Points[i + 2].X + dx),
                                    scale(polyCubicBezierSegment.Points[i + 2].Y + dy));
                            }
                        }

                        startPoint = polyCubicBezierSegment.Points.Last();
                    }
                    else if (segment is PolyLineSegment polyLineSegment)
                    {
                        if (polyLineSegment.Points.Length >= 1)
                        {
                            gp.AddLine(
                                scale(startPoint.X + dx),
                                scale(startPoint.Y + dy),
                                scale(polyLineSegment.Points[0].X + dx),
                                scale(polyLineSegment.Points[0].Y + dy));
                        }

                        if (polyLineSegment.Points.Length > 1)
                        {
                            for (int i = 1; i < polyLineSegment.Points.Length; i++)
                            {
                                gp.AddLine(
                                    scale(polyLineSegment.Points[i - 1].X + dx),
                                    scale(polyLineSegment.Points[i - 1].Y + dy),
                                    scale(polyLineSegment.Points[i].X + dx),
                                    scale(polyLineSegment.Points[i].Y + dy));
                            }
                        }

                        startPoint = polyLineSegment.Points.Last();
                    }
                    else if (segment is PolyQuadraticBezierSegment polyQuadraticSegment)
                    {
                        if (polyQuadraticSegment.Points.Length >= 2)
                        {
                            var    p1 = startPoint;
                            var    p2 = polyQuadraticSegment.Points[0];
                            var    p3 = polyQuadraticSegment.Points[1];
                            double x1 = p1.X;
                            double y1 = p1.Y;
                            double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                            double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                            double x3 = x2 + (p3.X - p1.X) / 3.0;
                            double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                            double x4 = p3.X;
                            double y4 = p3.Y;
                            gp.AddBezier(
                                scale(x1 + dx),
                                scale(y1 + dy),
                                scale(x2 + dx),
                                scale(y2 + dy),
                                scale(x3 + dx),
                                scale(y3 + dy),
                                scale(x4 + dx),
                                scale(y4 + dy));
                        }

                        if (polyQuadraticSegment.Points.Length > 2 &&
                            polyQuadraticSegment.Points.Length % 2 == 0)
                        {
                            for (int i = 3; i < polyQuadraticSegment.Points.Length; i += 3)
                            {
                                var    p1 = polyQuadraticSegment.Points[i - 1];
                                var    p2 = polyQuadraticSegment.Points[i];
                                var    p3 = polyQuadraticSegment.Points[i + 1];
                                double x1 = p1.X;
                                double y1 = p1.Y;
                                double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                                double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                                double x3 = x2 + (p3.X - p1.X) / 3.0;
                                double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                                double x4 = p3.X;
                                double y4 = p3.Y;
                                gp.AddBezier(
                                    scale(x1 + dx),
                                    scale(y1 + dy),
                                    scale(x2 + dx),
                                    scale(y2 + dy),
                                    scale(x3 + dx),
                                    scale(y3 + dy),
                                    scale(x4 + dx),
                                    scale(y4 + dy));
                            }
                        }

                        startPoint = polyQuadraticSegment.Points.Last();
                    }
                    else if (segment is QuadraticBezierSegment quadraticBezierSegment)
                    {
                        var    p1 = startPoint;
                        var    p2 = quadraticBezierSegment.Point1;
                        var    p3 = quadraticBezierSegment.Point2;
                        double x1 = p1.X;
                        double y1 = p1.Y;
                        double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                        double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                        double x3 = x2 + (p3.X - p1.X) / 3.0;
                        double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                        double x4 = p3.X;
                        double y4 = p3.Y;
                        gp.AddBezier(
                            scale(x1 + dx),
                            scale(y1 + dy),
                            scale(x2 + dx),
                            scale(y2 + dy),
                            scale(x3 + dx),
                            scale(y3 + dy),
                            scale(x4 + dx),
                            scale(y4 + dy));
                        startPoint = quadraticBezierSegment.Point2;
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                    }
                }

                if (pf.IsClosed)
                {
                    gp.CloseFigure();
                }
                else
                {
                    gp.StartFigure();
                }
            }

            return(gp);
        }
示例#44
0
        public override void AddTabBorder(System.Drawing.Drawing2D.GraphicsPath path, System.Drawing.Rectangle tabBounds)
        {
            int spread;
            int eigth;
            int sixth;
            int quarter;

            if (this._TabControl.Alignment <= TabAlignment.Bottom)
            {
                spread  = (int)Math.Floor((decimal)tabBounds.Height * 2 / 3);
                eigth   = (int)Math.Floor((decimal)tabBounds.Height * 1 / 8);
                sixth   = (int)Math.Floor((decimal)tabBounds.Height * 1 / 6);
                quarter = (int)Math.Floor((decimal)tabBounds.Height * 1 / 4);
            }
            else
            {
                spread  = (int)Math.Floor((decimal)tabBounds.Width * 2 / 3);
                eigth   = (int)Math.Floor((decimal)tabBounds.Width * 1 / 8);
                sixth   = (int)Math.Floor((decimal)tabBounds.Width * 1 / 6);
                quarter = (int)Math.Floor((decimal)tabBounds.Width * 1 / 4);
            }

            switch (this._TabControl.Alignment)
            {
            case TabAlignment.Top:

                path.AddCurve(new Point[] { new Point(tabBounds.X, tabBounds.Bottom)
                                            , new Point(tabBounds.X + sixth, tabBounds.Bottom - eigth)
                                            , new Point(tabBounds.X + spread - quarter, tabBounds.Y + eigth)
                                            , new Point(tabBounds.X + spread, tabBounds.Y) });
                path.AddLine(tabBounds.X + spread, tabBounds.Y, tabBounds.Right - spread, tabBounds.Y);
                path.AddCurve(new Point[] { new Point(tabBounds.Right - spread, tabBounds.Y)
                                            , new Point(tabBounds.Right - spread + quarter, tabBounds.Y + eigth)
                                            , new Point(tabBounds.Right - sixth, tabBounds.Bottom - eigth)
                                            , new Point(tabBounds.Right, tabBounds.Bottom) });
                break;

            case TabAlignment.Bottom:
                path.AddCurve(new Point[] { new Point(tabBounds.Right, tabBounds.Y)
                                            , new Point(tabBounds.Right - sixth, tabBounds.Y + eigth)
                                            , new Point(tabBounds.Right - spread + quarter, tabBounds.Bottom - eigth)
                                            , new Point(tabBounds.Right - spread, tabBounds.Bottom) });
                path.AddLine(tabBounds.Right - spread, tabBounds.Bottom, tabBounds.X + spread, tabBounds.Bottom);
                path.AddCurve(new Point[] { new Point(tabBounds.X + spread, tabBounds.Bottom)
                                            , new Point(tabBounds.X + spread - quarter, tabBounds.Bottom - eigth)
                                            , new Point(tabBounds.X + sixth, tabBounds.Y + eigth)
                                            , new Point(tabBounds.X, tabBounds.Y) });
                break;

            case TabAlignment.Left:
                path.AddCurve(new Point[] { new Point(tabBounds.Right, tabBounds.Bottom)
                                            , new Point(tabBounds.Right - eigth, tabBounds.Bottom - sixth)
                                            , new Point(tabBounds.X + eigth, tabBounds.Bottom - spread + quarter)
                                            , new Point(tabBounds.X, tabBounds.Bottom - spread) });
                path.AddLine(tabBounds.X, tabBounds.Bottom - spread, tabBounds.X, tabBounds.Y + spread);
                path.AddCurve(new Point[] { new Point(tabBounds.X, tabBounds.Y + spread)
                                            , new Point(tabBounds.X + eigth, tabBounds.Y + spread - quarter)
                                            , new Point(tabBounds.Right - eigth, tabBounds.Y + sixth)
                                            , new Point(tabBounds.Right, tabBounds.Y) });

                break;

            case TabAlignment.Right:
                path.AddCurve(new Point[] { new Point(tabBounds.X, tabBounds.Y)
                                            , new Point(tabBounds.X + eigth, tabBounds.Y + sixth)
                                            , new Point(tabBounds.Right - eigth, tabBounds.Y + spread - quarter)
                                            , new Point(tabBounds.Right, tabBounds.Y + spread) });
                path.AddLine(tabBounds.Right, tabBounds.Y + spread, tabBounds.Right, tabBounds.Bottom - spread);
                path.AddCurve(new Point[] { new Point(tabBounds.Right, tabBounds.Bottom - spread)
                                            , new Point(tabBounds.Right - eigth, tabBounds.Bottom - spread + quarter)
                                            , new Point(tabBounds.X + eigth, tabBounds.Bottom - sixth)
                                            , new Point(tabBounds.X, tabBounds.Bottom) });
                break;
            }
        }
示例#45
0
        /// <summary>
        /// This method will paint the group title.
        /// </summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintGroupText(System.Drawing.Graphics g)
        {
            //Check if string has something
            if (this.GroupTitle == string.Empty)
            {
                return;
            }

            //Set Graphics smoothing mode to Anit-Alias
            g.SmoothingMode = SmoothingMode.AntiAlias;

            //Declare Variables
            SizeF StringSize  = g.MeasureString(this.GroupTitle, this.Font);
            Size  StringSize2 = StringSize.ToSize();

            if (this.GroupImage != null)
            {
                StringSize2.Width += 18;
            }
            int ArcWidth  = this.RoundCorners;
            int ArcHeight = this.RoundCorners;
            int ArcX1     = 20;
            int ArcX2     = (StringSize2.Width + 34) - (ArcWidth + 1);
            int ArcY1     = 0;
            int ArcY2     = 24 - (ArcHeight + 1);

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = (this.PaintGroupBox) ? new SolidBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             TextColorBrush  = new SolidBrush(this.ForeColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;

            //Check if shadow is needed
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle); // Top Left
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle); //Top Right
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle); //Bottom Right
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle);  //Bottom Left
                ShadowPath.CloseAllFigures();

                //Paint Rounded Rectangle
                g.FillPath(ShadowBrush, ShadowPath);
            }
            //Create Rounded Rectangle Path
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle); // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle); //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle); //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle);  //Bottom Left
            path.CloseAllFigures();

            //Check if Gradient Mode is enabled
            if (this.PaintGroupBox)
            {
                //Paint Rounded Rectangle
                g.FillPath(BackgroundBrush, path);
            }
            else
            {
                if (this.BackgroundGradientMode == GroupBoxGradientMode.None)
                {
                    //Paint Rounded Rectangle
                    g.FillPath(BackgroundBrush, path);
                }
                else
                {
                    BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), this.BackgroundColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);

                    //Paint Rounded Rectangle
                    g.FillPath(BackgroundGradientBrush, path);
                }
            }
            //Paint Borded
            g.DrawPath(BorderPen, path);

            //Paint Text
            int CustomStringWidth = (this.GroupImage != null) ? 44 : 28;

            g.DrawString(this.GroupTitle, this.Font, TextColorBrush, CustomStringWidth, 5);

            //Draw GroupImage if there is one
            if (this.GroupImage != null)
            {
                g.DrawImage(this.GroupImage, 28, 4, 16, 16);
            }

            //Destroy Graphic Objects
            if (path != null)
            {
                path.Dispose();
            }
            if (BorderBrush != null)
            {
                BorderBrush.Dispose();
            }
            if (BorderPen != null)
            {
                BorderPen.Dispose();
            }
            if (BackgroundGradientBrush != null)
            {
                BackgroundGradientBrush.Dispose();
            }
            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
            }
            if (TextColorBrush != null)
            {
                TextColorBrush.Dispose();
            }
            if (ShadowBrush != null)
            {
                ShadowBrush.Dispose();
            }
            if (ShadowPath != null)
            {
                ShadowPath.Dispose();
            }
        }
示例#46
0
        /// <summary>
        /// 文字列を描画したテクスチャを返す(メイン処理)
        /// </summary>
        /// <param name="rectDrawn">描画された領域</param>
        /// <param name="ptOrigin">描画文字列</param>
        /// <param name="drawstr">描画文字列</param>
        /// <param name="drawmode">描画モード</param>
        /// <param name="fontColor">描画色</param>
        /// <param name="edgeColor">縁取色</param>
        /// <param name="gradationTopColor">グラデーション 上側の色</param>
        /// <param name="gradationBottomColor">グラデーション 下側の色</param>
        /// <returns>描画済テクスチャ</returns>
        protected Bitmap DrawPrivateFont_V(string drawstr, Color fontColor, Color edgeColor, bool bVertical)
        {
            if (this._fontfamily == null || drawstr == null || drawstr == "")
            {
                // nullを返すと、その後bmp→texture処理や、textureのサイズを見て__の処理で全部例外が発生することになる。
                // それは非常に面倒なので、最小限のbitmapを返してしまう。
                // まずはこの仕様で進めますが、問題有れば(上位側からエラー検出が必要であれば)例外を出したりエラー状態であるプロパティを定義するなり検討します。
                if (drawstr != "")
                {
                    Trace.TraceWarning("DrawPrivateFont()の入力不正。最小値のbitmapを返します。");
                }
                _rectStrings = new Rectangle(0, 0, 0, 0);
                _ptOrigin    = new Point(0, 0);
                return(new Bitmap(1, 1));
            }

            //StreamWriter stream = stream = new StreamWriter("Test.txt", false);

            //try
            //{
            //    stream = new StreamWriter("Test.txt", false);
            //}
            //catch (Exception ex)
            //{
            //    stream.Close();
            //    stream = new StreamWriter("Test.txt", false);
            //}

            string[] strName = new string[drawstr.Length];
            for (int i = 0; i < drawstr.Length; i++)
            {
                strName[i] = drawstr.Substring(i, 1);
            }

            #region [ キャンバスの大きさ予測 ]
            //大きさを計算していく。
            int nHeight = 0;
            for (int i = 0; i < strName.Length; i++)
            {
                Size strSize = System.Windows.Forms.TextRenderer.MeasureText(strName[i], this._font, new Size(int.MaxValue, int.MaxValue),
                                                                             System.Windows.Forms.TextFormatFlags.NoPrefix |
                                                                             System.Windows.Forms.TextFormatFlags.NoPadding);

                //stringformatは最初にやっていてもいいだろう。
                StringFormat sFormat = new StringFormat();
                sFormat.LineAlignment = StringAlignment.Center;         // 画面下部(垂直方向位置)
                sFormat.Alignment     = StringAlignment.Center;         // 画面中央(水平方向位置)


                //できるだけ正確な値を計算しておきたい...!
                Bitmap    bmpDummy   = new Bitmap(150, 150); //とりあえず150
                Graphics  gCal       = Graphics.FromImage(bmpDummy);
                Rectangle rect正確なサイズ = this.MeasureStringPrecisely(gCal, strName[i], this._font, strSize, sFormat);
                int       n余白サイズ     = strSize.Height - rect正確なサイズ.Height;

                Rectangle rect = new Rectangle(0, -n余白サイズ + 2, 46, (strSize.Height + 16));

                if (strName[i] == "ー" || strName[i] == "-" || strName[i] == "~" || strName[i] == "<" || strName[i] == ">" || strName[i] == "(" || strName[i] == ")" || strName[i] == "「" || strName[i] == "」" || strName[i] == "[" || strName[i] == "]")
                {
                    nHeight += (rect正確なサイズ.Width) + 4;
                }
                else if (strName[i] == "_")
                {
                    nHeight += (rect正確なサイズ.Height) + 6;
                }
                else if (strName[i] == " ")
                {
                    nHeight += (12);
                }
                else
                {
                    nHeight += (rect正確なサイズ.Height) + 10;
                }

                //念のため解放
                bmpDummy.Dispose();
                gCal.Dispose();

                //stream.WriteLine( "文字の大きさ{0},大きさ合計{1}", ( rect正確なサイズ.Height ) + 6, nHeight );
            }
            #endregion

            Bitmap   bmpCambus = new Bitmap(46, nHeight);
            Graphics Gcambus   = Graphics.FromImage(bmpCambus);

            //キャンバス作成→1文字ずつ作成してキャンバスに描画という形がよさそうかな?
            int nNowPos = 0;
            int nAdded  = 0;
            if (this._pt < 18)
            {
                nAdded = nAdded - 2;
            }

            for (int i = 0; i < strName.Length; i++)
            {
                Size strSize = System.Windows.Forms.TextRenderer.MeasureText(strName[i], this._font, new Size(int.MaxValue, int.MaxValue),
                                                                             System.Windows.Forms.TextFormatFlags.NoPrefix |
                                                                             System.Windows.Forms.TextFormatFlags.NoPadding);

                //stringformatは最初にやっていてもいいだろう。
                StringFormat sFormat = new StringFormat();
                sFormat.LineAlignment = StringAlignment.Center;         // 画面下部(垂直方向位置)
                sFormat.Alignment     = StringAlignment.Near;           // 画面中央(水平方向位置)

                //できるだけ正確な値を計算しておきたい...!
                Bitmap    bmpDummy   = new Bitmap(150, 150); //とりあえず150
                Graphics  gCal       = Graphics.FromImage(bmpDummy);
                Rectangle rect正確なサイズ = this.MeasureStringPrecisely(gCal, strName[i], this._font, strSize, sFormat);
                int       n余白サイズ     = strSize.Height - rect正確なサイズ.Height;

                //Bitmap bmpV = new Bitmap( 36, ( strSize.Height + 12 ) - 6 );

                Bitmap bmpV = new Bitmap((rect正確なサイズ.Width + 12) + nAdded, (rect正確なサイズ.Height) + 12);

                bmpV.MakeTransparent();
                Graphics gV = Graphics.FromImage(bmpV);
                gV.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;


                Rectangle rect = new Rectangle(-3 - nAdded, -rect正確なサイズ.Y - 2, (strSize.Width + 12), (strSize.Height + 12));
                //Rectangle rect = new Rectangle( 0, -rect正確なサイズ.Y - 2, 36, rect正確なサイズ.Height + 10);

                // DrawPathで、ポイントサイズを使って描画するために、DPIを使って単位変換する
                // (これをしないと、単位が違うために、小さめに描画されてしまう)
                float sizeInPixels = _font.SizeInPoints * gV.DpiY / 72;                  // 1 inch = 72 points

                System.Drawing.Drawing2D.GraphicsPath gpV = new System.Drawing.Drawing2D.GraphicsPath();
                gpV.AddString(strName[i], this._fontfamily, (int)this._font.Style, sizeInPixels, rect, sFormat);

                // 縁取りを描画する
                //int nEdgePt = (_pt / 3); // 縁取りをフォントサイズ基準に変更
                int nEdgePt = (10 * _pt / CDTXMania.Skin.Font_Edge_Ratio_Vertical); // SkinConfigにて設定可能に(rhimm)
                Pen pV      = new Pen(edgeColor, nEdgePt);
                pV.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
                gV.DrawPath(pV, gpV);

                // 塗りつぶす
                Brush brV;
                {
                    brV = new SolidBrush(fontColor);
                }
                gV.FillPath(brV, gpV);

                if (brV != null)
                {
                    brV.Dispose();
                }
                brV = null;
                if (pV != null)
                {
                    pV.Dispose();
                }
                pV = null;
                if (gpV != null)
                {
                    gpV.Dispose();
                }
                gpV = null;
                if (gV != null)
                {
                    gV.Dispose();
                }
                gV = null;

                int n補正  = 0;
                int nY補正 = 0;

                if (strName[i] == "ー" || strName[i] == "-" || strName[i] == "~")
                {
                    bmpV.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    n補正 = 2;
                    if (this._pt < 20)
                    {
                        n補正 = 0;
                    }
                    //nNowPos = nNowPos - 2;
                }
                else if (strName[i] == "<" || strName[i] == ">" || strName[i] == "(" || strName[i] == ")" || strName[i] == "[" || strName[i] == "]" || strName[i] == "」")
                {
                    bmpV.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    n補正 = 2;
                    if (this._pt < 20)
                    {
                        n補正 = 0;
                        //nNowPos = nNowPos - 4;
                    }
                }
                else if (strName[i] == "「")
                {
                    bmpV.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    n補正 = 2;
                    if (this._pt < 20)
                    {
                        n補正 = 2;
                        //nNowPos = nNowPos;
                    }
                }
                else if (strName[i] == "・")
                {
                    n補正 = -8;
                    if (this._pt < 20)
                    {
                        n補正 = -8;
                        //nNowPos = nNowPos;
                    }
                }
                else if (strName[i] == ".")
                {
                    n補正 = 8;
                    if (this._pt < 20)
                    {
                        n補正 = 8;
                        //nNowPos = nNowPos;
                    }
                }
                //else if( strName[ i ] == "_" )
                //    nNowPos = nNowPos + 20;
                else if (strName[i] == " ")
                {
                    nNowPos = nNowPos + 10;
                }


                //bmpV.Save( "String" + i.ToString() + ".png" );


                if (i == 0)
                {
                    nNowPos = 4;
                }
                Gcambus.DrawImage(bmpV, (bmpCambus.Width / 2) - (bmpV.Width / 2) + n補正, nNowPos);
                nNowPos += bmpV.Size.Height - 6;

                if (bmpV != null)
                {
                    bmpV.Dispose();
                }
                bmpV = null;
                if (gCal != null)
                {
                    gCal.Dispose();
                }
                gCal = null;

                //bmpCambus.Save( "test.png" );
                //if( this._pt < 20 )
                //    bmpCambus.Save( "test_S.png" );

                _rectStrings = new Rectangle(0, 0, strSize.Width, strSize.Height);
                _ptOrigin    = new Point(6 * 2, 6 * 2);


                //stream.WriteLine( "黒無しサイズ{0},余白{1},黒あり予測サイズ{2},ポ↑ジ↓{3}",rect正確なサイズ.Height, n余白サイズ, rect正確なサイズ.Height + 8, nNowPos );
            }
            //stream.Close();

            if (Gcambus != null)
            {
                Gcambus.Dispose();
            }

            //return bmp;
            return(bmpCambus);
        }
示例#47
0
        /// <summary>
        /// 文字列を描画したテクスチャを返す(メイン処理)
        /// </summary>
        /// <param name="rectDrawn">描画された領域</param>
        /// <param name="ptOrigin">描画文字列</param>
        /// <param name="drawstr">描画文字列</param>
        /// <param name="drawmode">描画モード</param>
        /// <param name="fontColor">描画色</param>
        /// <param name="edgeColor">縁取色</param>
        /// <param name="gradationTopColor">グラデーション 上側の色</param>
        /// <param name="gradationBottomColor">グラデーション 下側の色</param>
        /// <returns>描画済テクスチャ</returns>
        protected Bitmap DrawPrivateFont(string drawstr, DrawMode drawmode, Color fontColor, Color edgeColor, Color gradationTopColor, Color gradationBottomColor)
        {
            if (this._fontfamily == null || drawstr == null || drawstr == "")
            {
                // nullを返すと、その後bmp→texture処理や、textureのサイズを見て__の処理で全部例外が発生することになる。
                // それは非常に面倒なので、最小限のbitmapを返してしまう。
                // まずはこの仕様で進めますが、問題有れば(上位側からエラー検出が必要であれば)例外を出したりエラー状態であるプロパティを定義するなり検討します。
                if (drawstr != "")
                {
                    Trace.TraceWarning("DrawPrivateFont()の入力不正。最小値のbitmapを返します。");
                }
                _rectStrings = new Rectangle(0, 0, 0, 0);
                _ptOrigin    = new Point(0, 0);
                return(new Bitmap(1, 1));
            }
            bool bEdge      = ((drawmode & DrawMode.Edge) == DrawMode.Edge);
            bool bGradation = ((drawmode & DrawMode.Gradation) == DrawMode.Gradation);

            // 縁取りの縁のサイズは、とりあえずフォントの大きさの1/4とする
            //int nEdgePt = (bEdge)? _pt / 4 : 0;
            //int nEdgePt = (bEdge) ? (_pt / 3) : 0; // 縁取りが少なすぎるという意見が多かったため変更。 (AioiLight)
            int nEdgePt = (bEdge) ? (10 * _pt / CDTXMania.Skin.Font_Edge_Ratio) : 0; //SkinConfigにて設定可能に(rhimm)

            // 描画サイズを測定する
            Size stringSize = System.Windows.Forms.TextRenderer.MeasureText(drawstr, this._font, new Size(int.MaxValue, int.MaxValue),
                                                                            System.Windows.Forms.TextFormatFlags.NoPrefix |
                                                                            System.Windows.Forms.TextFormatFlags.NoPadding
                                                                            );

            stringSize.Width += 10; //2015.04.01 kairera0467 ROTTERDAM NATIONの描画サイズがうまくいかんので。

            //取得した描画サイズを基に、描画先のbitmapを作成する
            Bitmap bmp = new Bitmap(stringSize.Width + nEdgePt * 2, stringSize.Height + nEdgePt * 2);

            bmp.MakeTransparent();
            Graphics g = Graphics.FromImage(bmp);

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            StringFormat sf = new StringFormat();

            sf.LineAlignment = StringAlignment.Far;      // 画面下部(垂直方向位置)
            sf.Alignment     = StringAlignment.Center;   // 画面中央(水平方向位置)
            sf.FormatFlags   = StringFormatFlags.NoWrap; // どんなに長くて単語の区切りが良くても改行しない (AioiLight)
            sf.Trimming      = StringTrimming.None;      // どんなに長くてもトリミングしない (AioiLight)
            // レイアウト枠
            Rectangle r = new Rectangle(0, 0, stringSize.Width + nEdgePt * 2, stringSize.Height + nEdgePt * 2);

            if (bEdge)                  // 縁取り有りの描画
            {
                // DrawPathで、ポイントサイズを使って描画するために、DPIを使って単位変換する
                // (これをしないと、単位が違うために、小さめに描画されてしまう)
                float sizeInPixels = _font.SizeInPoints * g.DpiY / 72;                  // 1 inch = 72 points

                System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
                gp.AddString(drawstr, this._fontfamily, (int)this._font.Style, sizeInPixels, r, sf);

                // 縁取りを描画する
                Pen p = new Pen(edgeColor, nEdgePt);
                p.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
                g.DrawPath(p, gp);

                // 塗りつぶす
                Brush br;
                if (bGradation)
                {
                    br = new LinearGradientBrush(r, gradationTopColor, gradationBottomColor, LinearGradientMode.Vertical);
                }
                else
                {
                    br = new SolidBrush(fontColor);
                }
                g.FillPath(br, gp);

                if (br != null)
                {
                    br.Dispose();
                }
                br = null;
                if (p != null)
                {
                    p.Dispose();
                }
                p = null;
                if (gp != null)
                {
                    gp.Dispose();
                }
                gp = null;
            }
            else
            {
                // 縁取りなしの描画
                System.Windows.Forms.TextRenderer.DrawText(g, drawstr, _font, new Point(0, 0), fontColor);
            }
#if debug表示
            g.DrawRectangle(new Pen(Color.White, 1), new Rectangle(1, 1, stringSize.Width - 1, stringSize.Height - 1));
            g.DrawRectangle(new Pen(Color.Green, 1), new Rectangle(0, 0, bmp.Width - 1, bmp.Height - 1));
#endif
            _rectStrings = new Rectangle(0, 0, stringSize.Width, stringSize.Height);
            _ptOrigin    = new Point(nEdgePt * 2, nEdgePt * 2);


            #region [ リソースを解放する ]
            if (sf != null)
            {
                sf.Dispose();
            }
            sf = null;
            if (g != null)
            {
                g.Dispose();
            }
            g = null;
            #endregion

            return(bmp);
        }
示例#48
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="GraphicsPath" /> class.
 /// </summary>
 public GraphicsPath()
 {
     _pathGeometry = new GDIGraphicsPath();
 }
示例#49
0
 public override void AddTabBorder(System.Drawing.Drawing2D.GraphicsPath path, System.Drawing.Rectangle tabBounds)
 {
 }
示例#50
0
        /// <summary>
        /// Gets the cut rect.
        /// </summary>
        /// <param name="baseRect">The base rect.</param>
        /// <param name="radius">The radius.</param>
        /// <param name="corner">The corner.</param>
        /// <returns></returns>
        private static GraphicsPath GetCutRect(RectangleF baseRect,
                                               float radius, Corner corner)
        {
            // if corner radius is less than or equal to zero,

            // return the original rectangle

            if (radius <= 0.0F)
            {
                GraphicsPath mPath = new GraphicsPath();
                mPath.AddRectangle(baseRect);
                mPath.CloseFigure();
                return(mPath);
            }

            // if the corner radius is greater than or equal to

            // half the width, or height (whichever is shorter)

            // then return a capsule instead of a lozenge

            //if (radius >= (System.Math.Min(baseRect.Width, baseRect.Height)) / 2.0)
            //    return GetCapsule(baseRect);

            // create the arc for the rectangle sides and declare

            // a graphics path object for the drawing

            //float diameter = radius * 2.0F;
            //SizeF sizeF = new SizeF(diameter, diameter);
            //RectangleF arc = new RectangleF(baseRect.Location, sizeF);
            GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();

            if ((corner & Corner.TopLeft) == Corner.TopLeft)
            {
                path.AddLine(new PointF(radius, baseRect.Y), new PointF(0, radius));
            }
            else
            {
                path.AddLine(new PointF(baseRect.X, baseRect.Y), new PointF(radius, baseRect.Y));
                path.AddLine(new PointF(baseRect.X, baseRect.Y), new PointF(baseRect.X, radius));
            }

            //画多边形边
            path.AddLine(
                new PointF(radius, baseRect.Y),
                new PointF(baseRect.Right - radius, baseRect.Y)
                );

            // top right corner

            if ((corner & Corner.TopRight) == Corner.TopRight)
            {
                path.AddLine(
                    new PointF(baseRect.Right - radius, baseRect.Y),
                    new PointF(baseRect.Right, radius));
            }
            else
            {
                path.AddLine(new PointF(baseRect.Right - radius, baseRect.Y), new PointF(baseRect.Right, baseRect.Y));
                path.AddLine(new PointF(baseRect.Right, baseRect.Y), new PointF(baseRect.Right, radius));
            }


            // bottom right arc
            if ((corner & Corner.BottomRight) == Corner.BottomRight)
            {
                path.AddLine(
                    new PointF(baseRect.Right, baseRect.Bottom - radius),
                    new PointF(baseRect.Right - radius, baseRect.Bottom));
            }
            else
            {
                path.AddLine(new PointF(baseRect.Right, baseRect.Bottom - radius), new PointF(baseRect.Right, baseRect.Bottom));
                path.AddLine(new PointF(baseRect.Right, baseRect.Bottom), new PointF(baseRect.Right - radius, baseRect.Bottom));
            }


            path.AddLine(
                new PointF(baseRect.Right - radius, baseRect.Bottom),
                new PointF(radius, baseRect.Bottom));

            if ((corner & Corner.BottomLeft) == Corner.BottomLeft)
            {
                path.AddLine(
                    new PointF(radius, baseRect.Bottom),
                    new PointF(0, baseRect.Bottom - radius));
            }
            else
            {
                path.AddLine(new PointF(baseRect.Right - radius, baseRect.Bottom), new PointF(baseRect.X, baseRect.Bottom));
                path.AddLine(new PointF(baseRect.X, baseRect.Bottom), new PointF(baseRect.X, baseRect.Bottom - radius));
            }
            // bottom left arc

            path.AddLine(
                new PointF(baseRect.X, baseRect.Bottom - radius),
                new PointF(baseRect.X, radius));

            if ((corner & Corner.TopLeft) != Corner.TopLeft)
            {
                path.AddLine(new PointF(baseRect.X, baseRect.Y), new PointF(baseRect.X, radius));
            }

            path.CloseFigure();
            return(path);
        }
示例#51
0
 public static void DrawPath(Graphics g, System.Drawing.Drawing2D.GraphicsPath p, Color c)
 {
     _pen.Color = ToDrawingColor(c);
     g.DrawPath(_pen, p);
 }
示例#52
0
        /// <summary>
        /// NS, 2013-12-02, draw circle inside polygon
        /// </summary>
        /// <param name="g"></param>
        /// <param name="pol"></param>
        /// <param name="brush"></param>
        /// <param name="pen"></param>
        /// <param name="clip"></param>
        /// <param name="map"></param>
        /// <param name="circleline"></param>
        /// <param name="drawcircle"></param>
        /// <param name="radius"></param>
        public static void DrawPolygonWithCircle(System.Drawing.Graphics g, IPolygon pol, System.Drawing.Brush brush,
                                                 System.Drawing.Pen pen, bool clip, SharpMap.Map map, System.Drawing.Pen circleline, bool drawcircle, int radius)
        {
            try
            {
                if (pol.Shell == null)
                {
                    return;
                }
                if (pol.Shell.Coordinates.Length > 2)
                {
                    if (drawcircle)
                    {
                        System.Drawing.PointF pp = SharpMap.Utilities.Transform.WorldtoMap(pol.Centroid.Coordinate, map);
                        g.SmoothingMode = SmoothingMode.AntiAlias;
                        g.DrawEllipse(circleline, (pp.X - radius), (pp.Y - radius), radius * 2f, radius * 2f);
                    }

                    //Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
                    System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

                    //Add the exterior polygon
                    if (!clip)
                    {
                        gp.AddPolygon(Transform.TransformToImage(pol.Shell, map));
                    }
                    //gp.AddPolygon(LimitValues(Transform.TransformToImage(pol.Shell, map), extremeValueLimit));
                    else
                    {
                        gp.AddPolygon(clipPolygon(Transform.TransformToImage(pol.Shell, map), map.Size.Width, map.Size.Height));
                    }

                    //Add the interior polygons (holes)
                    for (int i = 0; i < pol.Holes.Length; i++)
                    {
                        if (!clip)
                        {
                            gp.AddPolygon(Transform.TransformToImage(pol.Holes[i], map));
                        }
                        //gp.AddPolygon(LimitValues(Transform.TransformToImage(pol.Holes[i], map), extremeValueLimit));
                        else
                        {
                            gp.AddPolygon(clipPolygon(Transform.TransformToImage(pol.Holes[i], map), map.Size.Width, map.Size.Height));
                        }
                    }

                    // Only render inside of polygon if the brush isn't null or isn't transparent
                    if (brush != null && brush != System.Drawing.Brushes.Transparent)
                    {
                        g.FillPath(brush, gp);
                    }
                    // Create an outline if a pen style is available
                    if (pen != null)
                    {
                        g.DrawPath(pen, gp);
                    }
                }
            }
            catch (InvalidOperationException e)
            {
                log.WarnFormat("Error during rendering", e);
            }
            catch (OverflowException e)
            {
                log.WarnFormat("Error during rendering", e);
            }
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics;

            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            g.Clear(Parent.BackColor);

            // card rectangle path
            RectangleF expansionPanelRectF = new RectangleF(ClientRectangle.Location, ClientRectangle.Size);

            expansionPanelRectF.X -= 0.5f;
            expansionPanelRectF.Y -= 0.5f;
            GraphicsPath expansionPanelPath = DrawHelper.CreateRoundRect(expansionPanelRectF, 2);

            // button shadow (blend with form shadow)
            DrawHelper.DrawSquareShadow(g, ClientRectangle);

            // Draw expansion panel
            // Disabled
            if (!Enabled)
            {
                using (SolidBrush disabledBrush = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundDisabledColor, SkinManager.BackgroundDisabledColor.A)))
                {
                    g.FillPath(disabledBrush, expansionPanelPath);
                }
            }
            // Mormal
            else
            {
                if ((_buttonState == ButtonState.HeaderOver | _buttonState == ButtonState.ColapseExpandOver) && _collapse)
                {
                    RectangleF expansionPanelBorderRectF = new RectangleF(ClientRectangle.X + 1, ClientRectangle.Y + 1, ClientRectangle.Width - 2, ClientRectangle.Height - 2);
                    expansionPanelBorderRectF.X -= 0.5f;
                    expansionPanelBorderRectF.Y -= 0.5f;
                    GraphicsPath expansionPanelBoarderPath = DrawHelper.CreateRoundRect(expansionPanelBorderRectF, 2);

                    g.FillPath(SkinManager.ExpansionPanelFocusBrush, expansionPanelBoarderPath);
                }
                else
                {
                    using (SolidBrush normalBrush = new SolidBrush(SkinManager.BackgroundColor))
                    {
                        g.FillPath(normalBrush, expansionPanelPath);
                    }
                }
            }

            // Calc text Rect
            var       RectangleX = (RightToLeft == RightToLeft.Yes) ? Width - (TextRenderer.MeasureText(_titleHeader, Font).Width + _expansionPanelDefaultPadding + _leftrightPadding) : _leftrightPadding;
            Rectangle headerRect = new Rectangle(
                RectangleX,
                (_headerHeight - _textHeaderHeight) / 2,
                TextRenderer.MeasureText(_titleHeader, Font).Width + _expansionPanelDefaultPadding,
                _textHeaderHeight);

            //Draw  headers
            using (NativeTextRenderer NativeText = new NativeTextRenderer(g))
            {
                // Draw header text
                var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left;
                NativeText.DrawTransparentText(
                    _titleHeader,
                    SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft),
                    Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor,
                    headerRect.Location,
                    headerRect.Size,
                    textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle);
            }

            if (!String.IsNullOrEmpty(_descriptionHeader))
            {
                //Draw description header text
                RectangleX = (RightToLeft == RightToLeft.Yes) ? _leftrightPadding + _expansionPanelDefaultPadding : headerRect.Right + _expansionPanelDefaultPadding;
                var       RectangleW            = (RightToLeft == RightToLeft.Yes) ? headerRect.Left - _expansionPanelDefaultPadding - _expansionPanelDefaultPadding : _expandcollapseBounds.Left - (headerRect.Right + _expansionPanelDefaultPadding) - _expansionPanelDefaultPadding;
                Rectangle headerDescriptionRect = new Rectangle(
                    RectangleX,
                    (_headerHeight - _textHeaderHeight) / 2,
                    RectangleW,
                    _textHeaderHeight);

                using (NativeTextRenderer NativeText = new NativeTextRenderer(g))
                {
                    // Draw description header text
                    var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left;
                    NativeText.DrawTransparentText(
                        _descriptionHeader,
                        SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft),
                        SkinManager.TextDisabledOrHintColor,
                        headerDescriptionRect.Location,
                        headerDescriptionRect.Size,
                        textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle);
                }
            }

            if (_showCollapseExpand == true)
            {
                using (var formButtonsPen = new Pen(_useAccentColor && Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.TextDisabledOrHintColor, 2))
                {
                    if (_collapse)
                    {
                        //Draw Expand button
                        System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath();
                        PointF TopLeft   = new PointF(_expandcollapseBounds.X + 6, _expandcollapseBounds.Y + 9);
                        PointF MidBottom = new PointF(_expandcollapseBounds.X + 12, _expandcollapseBounds.Y + 15);
                        PointF TopRight  = new PointF(_expandcollapseBounds.X + 18, _expandcollapseBounds.Y + 9);
                        pth.AddLine(TopLeft, MidBottom);
                        pth.AddLine(TopRight, MidBottom);
                        g.DrawPath(formButtonsPen, pth);
                    }
                    else
                    {
                        // Draw Collapse button
                        System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath();
                        PointF BottomLeft  = new PointF(_expandcollapseBounds.X + 6, _expandcollapseBounds.Y + 15);
                        PointF MidTop      = new PointF(_expandcollapseBounds.X + 12, _expandcollapseBounds.Y + 9);
                        PointF BottomRight = new PointF(_expandcollapseBounds.X + 18, _expandcollapseBounds.Y + 15);
                        pth.AddLine(BottomLeft, MidTop);
                        pth.AddLine(BottomRight, MidTop);
                        g.DrawPath(formButtonsPen, pth);
                    }
                }
            }

            if (!_collapse && _showValidationButtons)
            {
                //Draw divider
                g.DrawLine(new Pen(SkinManager.DividersColor, 1), new Point(0, Height - _footerHeight), new Point(Width, Height - _footerHeight));
            }
        }
示例#54
0
 private void DiagnosisUC_Load(object sender, EventArgs e)
 {
     System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
     path        = RoundedRect(Bounds, 10);
     this.Region = new Region(path);
 }
示例#55
0
        private void NextUIState()
        {
            nextButton.Visible = false;
            prevButton.Visible = false;
            choicesPanel.Controls.Clear();
            Env.Run();

            // Get the state-list.
            String evalStr = "(find-all-facts ((?f state-list)) TRUE)";

            using (FactAddressValue allFacts = (FactAddressValue)((MultifieldValue)Env.Eval(evalStr))[0])
            {
                string currentID = allFacts.GetFactSlot("current").ToString();
                evalStr = "(find-all-facts ((?f UI-state)) " +
                          "(eq ?f:id " + currentID + "))";
            }


            using (FactAddressValue evalFact = (FactAddressValue)((MultifieldValue)Env.Eval(evalStr))[0])
            {
                System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
                gp.AddEllipse(0, 0, pictureBox1.Width - 3, pictureBox1.Height - 3);
                Region rg = new Region(gp);
                pictureBox1.Region = rg;
                pictureBox2.Region = rg;
                pictureBox3.Region = rg;
                string state = evalFact.GetFactSlot("state").ToString();
                if (state.Equals("initial"))
                {
                    pictureBox1.Visible = false;
                    pictureBox2.Visible = false;
                    pictureBox3.Visible = false;
                    nextButton.Visible  = true;
                    nextButton.Tag      = "Next";
                    nextButton.Text     = "Next";
                    prevButton.Visible  = false;
                }
                else if (state.Equals("finalPurple"))
                {
                    choicesPanel.Visible = false;
                    pictureBox1.BringToFront();
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(173, 3, 252);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalYellow"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(255, 255, 38);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalGreen"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(17, 217, 34);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalBlue"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(38, 107, 255);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalRed"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(255, 38, 38);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalBeige"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(247, 231, 139);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalNavy"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(22, 8, 66);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalOrange"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(255, 157, 0);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalPink"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(255, 0, 132);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalOrangeGreen"))
                {
                    pictureBox1.Visible   = true;
                    pictureBox2.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(280, 150);
                    pictureBox2.Location  = new Point(360, 150);
                    pictureBox1.BackColor = Color.FromArgb(255, 157, 0);
                    pictureBox2.BackColor = Color.FromArgb(17, 217, 34);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalGreenWhiteBeige"))
                {
                    pictureBox1.Visible   = true;
                    pictureBox2.Visible   = true;
                    pictureBox3.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(250, 150);
                    pictureBox2.Location  = new Point(330, 150);
                    pictureBox3.Location  = new Point(390, 150);
                    pictureBox1.BackColor = Color.FromArgb(17, 217, 34);
                    pictureBox2.BackColor = Color.White;
                    pictureBox3.BackColor = Color.FromArgb(247, 231, 139);
                    prevButton.Visible    = false;
                }
                else
                {
                    pictureBox1.Visible = false;
                    pictureBox2.Visible = false;
                    pictureBox3.Visible = false;
                    nextButton.Visible  = true;
                    nextButton.Tag      = "Next";
                    prevButton.Tag      = "Prev";
                    prevButton.Visible  = true;
                }



                using (MultifieldValue validAnswers = (MultifieldValue)evalFact.GetFactSlot("valid-answers"))
                {
                    String selected = evalFact.GetFactSlot("response").ToString();
                    for (int i = 0; i < validAnswers.Count; i++)
                    {
                        RadioButton rb = new RadioButton();
                        rb.Text     = (SymbolValue)validAnswers[i];
                        rb.Tag      = rb.Text;
                        rb.Visible  = true;
                        rb.Location = new Point(200, 30 * (i + 1));
                        choicesPanel.Controls.Add(rb);
                    }
                }
                messageLabel.Text = GetString((SymbolValue)evalFact.GetFactSlot("display"));
            }
        }
示例#56
0
 public override void AddToGraphicsPath(System.Drawing.Drawing2D.GraphicsPath path)
 {
     path.AddPath(this.path, false);
 }
示例#57
0
        private void OnDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();

            Rectangle rect = e.Bounds;

            rect.X      += 1;
            rect.Y      += 1;
            rect.Height -= 2;
            rect.Width   = rect.Height;

            System.Drawing.Brush brush =
                new System.Drawing.SolidBrush(Color.White);
            System.Drawing.Brush fill =
                new System.Drawing.SolidBrush(Color.LightSteelBlue);
            System.Drawing.Pen pen =
                new System.Drawing.Pen(Color.Black, 0);

            e.Graphics.FillRectangle(brush, rect);
            e.Graphics.DrawRectangle(pen, rect);

            System.Drawing.Drawing2D.SmoothingMode mode =
                e.Graphics.SmoothingMode;
            e.Graphics.SmoothingMode =
                System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            rect.Inflate(-2, -2);
            string        shapeId = _list.Items[e.Index].ToString();
            ShapeTemplate shape   = ShapeTemplate.FromId(shapeId);
            RectangleF    rectf   = new RectangleF(
                (float)rect.X, (float)rect.Y,
                (float)rect.Width, (float)rect.Height);

            MindFusion.FlowChartX.ShapeTemplate.PathData data =
                shape.initData(rectf, 0);

            System.Drawing.Drawing2D.GraphicsPath path =
                shape.getPath(data, 0);
            e.Graphics.FillPath(fill, path);
            e.Graphics.DrawPath(pen, path);
            path.Dispose();

            path = shape.getDecorationPath(data, 0);
            if (path != null)
            {
                e.Graphics.DrawPath(pen, path);
                path.Dispose();
            }

            e.Graphics.SmoothingMode = mode;

            pen.Dispose();
            fill.Dispose();
            brush.Dispose();

            // Draw the text;
            rectf.X     = rectf.Right + 6;
            rectf.Width = (float)e.Bounds.Width - rectf.X;

            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Near;
            format.LineAlignment = StringAlignment.Center;
            System.Drawing.Brush textBrush =
                new System.Drawing.SolidBrush(Color.Black);
            e.Graphics.DrawString(shapeId, Font, textBrush, rectf, format);
            textBrush.Dispose();
            format.Dispose();
        }
示例#58
0
        public static D2D.GraphicsPath ToGraphicsPath(this PathGeometryViewModel pg, Func <double, float> scale)
        {
            var gp = new D2D.GraphicsPath
            {
                FillMode = pg.FillRule == FillRule.EvenOdd ? D2D.FillMode.Alternate : D2D.FillMode.Winding
            };

            foreach (var pf in pg.Figures)
            {
                var startPoint = pf.StartPoint;

                foreach (var segment in pf.Segments)
                {
                    if (segment is ArcSegmentViewModel arcSegment)
                    {
                        // TODO: Convert WPF/SVG elliptical arc segment format to GDI+ bezier curves.
                        startPoint = arcSegment.Point;
                    }
                    else if (segment is CubicBezierSegmentViewModel cubicBezierSegment)
                    {
                        gp.AddBezier(
                            scale(startPoint.X),
                            scale(startPoint.Y),
                            scale(cubicBezierSegment.Point1.X),
                            scale(cubicBezierSegment.Point1.Y),
                            scale(cubicBezierSegment.Point2.X),
                            scale(cubicBezierSegment.Point2.Y),
                            scale(cubicBezierSegment.Point3.X),
                            scale(cubicBezierSegment.Point3.Y));
                        startPoint = cubicBezierSegment.Point3;
                    }
                    else if (segment is LineSegmentViewModel lineSegment)
                    {
                        gp.AddLine(
                            scale(startPoint.X),
                            scale(startPoint.Y),
                            scale(lineSegment.Point.X),
                            scale(lineSegment.Point.Y));
                        startPoint = lineSegment.Point;
                    }
                    else if (segment is QuadraticBezierSegmentViewModel quadraticBezierSegment)
                    {
                        var    p1 = startPoint;
                        var    p2 = quadraticBezierSegment.Point1;
                        var    p3 = quadraticBezierSegment.Point2;
                        double x1 = p1.X;
                        double y1 = p1.Y;
                        double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                        double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                        double x3 = x2 + (p3.X - p1.X) / 3.0;
                        double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                        double x4 = p3.X;
                        double y4 = p3.Y;
                        gp.AddBezier(
                            scale(x1),
                            scale(y1),
                            scale(x2),
                            scale(y2),
                            scale(x3),
                            scale(y3),
                            scale(x4),
                            scale(y4));
                        startPoint = quadraticBezierSegment.Point2;
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                    }
                }

                if (pf.IsClosed)
                {
                    gp.CloseFigure();
                }
                else
                {
                    gp.StartFigure();
                }
            }

            return(gp);
        }
示例#59
0
 GraphicsPathHandler(sd2.GraphicsPath control)
 {
     Control = control;
 }
示例#60
0
        public static void Run()
        {
            // ExStart:ExtractBorder
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            Document doc = new Document(dataDir + "input.pdf");

            Stack graphicsState = new Stack();

            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap((int)doc.Pages[1].PageInfo.Width, (int)doc.Pages[1].PageInfo.Height);
            System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
            // Default ctm matrix value is 1,0,0,1,0,0
            System.Drawing.Drawing2D.Matrix lastCTM = new System.Drawing.Drawing2D.Matrix(1, 0, 0, -1, 0, 0);
            // System.Drawing coordinate system is top left based, while pdf coordinate system is low left based, so we have to apply the inversion matrix
            System.Drawing.Drawing2D.Matrix inversionMatrix = new System.Drawing.Drawing2D.Matrix(1, 0, 0, -1, 0, (float)doc.Pages[1].PageInfo.Height);
            System.Drawing.PointF           lastPoint       = new System.Drawing.PointF(0, 0);
            System.Drawing.Color            fillColor       = System.Drawing.Color.FromArgb(0, 0, 0);
            System.Drawing.Color            strokeColor     = System.Drawing.Color.FromArgb(0, 0, 0);

            using (System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bitmap))
            {
                gr.SmoothingMode = SmoothingMode.HighQuality;
                graphicsState.Push(new System.Drawing.Drawing2D.Matrix(1, 0, 0, 1, 0, 0));

                // Process all the contents commands
                foreach (Operator op in doc.Pages[1].Contents)
                {
                    Operator.GSave             opSaveState      = op as Operator.GSave;
                    Operator.GRestore          opRestoreState   = op as Operator.GRestore;
                    Operator.ConcatenateMatrix opCtm            = op as Operator.ConcatenateMatrix;
                    Operator.MoveTo            opMoveTo         = op as Operator.MoveTo;
                    Operator.LineTo            opLineTo         = op as Operator.LineTo;
                    Operator.Re                opRe             = op as Operator.Re;
                    Operator.EndPath           opEndPath        = op as Operator.EndPath;
                    Operator.Stroke            opStroke         = op as Operator.Stroke;
                    Operator.Fill              opFill           = op as Operator.Fill;
                    Operator.EOFill            opEOFill         = op as Operator.EOFill;
                    Operator.SetRGBColor       opRGBFillColor   = op as Operator.SetRGBColor;
                    Operator.SetRGBColorStroke opRGBStrokeColor = op as Operator.SetRGBColorStroke;

                    if (opSaveState != null)
                    {
                        // Save previous state and push current state to the top of the stack
                        graphicsState.Push(((System.Drawing.Drawing2D.Matrix)graphicsState.Peek()).Clone());
                        lastCTM = (System.Drawing.Drawing2D.Matrix)graphicsState.Peek();
                    }
                    else if (opRestoreState != null)
                    {
                        // Throw away current state and restore previous one
                        graphicsState.Pop();
                        lastCTM = (System.Drawing.Drawing2D.Matrix)graphicsState.Peek();
                    }
                    else if (opCtm != null)
                    {
                        System.Drawing.Drawing2D.Matrix cm = new System.Drawing.Drawing2D.Matrix(
                            (float)opCtm.Matrix.A,
                            (float)opCtm.Matrix.B,
                            (float)opCtm.Matrix.C,
                            (float)opCtm.Matrix.D,
                            (float)opCtm.Matrix.E,
                            (float)opCtm.Matrix.F);

                        // Multiply current matrix with the state matrix
                        ((System.Drawing.Drawing2D.Matrix)graphicsState.Peek()).Multiply(cm);
                        lastCTM = (System.Drawing.Drawing2D.Matrix)graphicsState.Peek();
                    }
                    else if (opMoveTo != null)
                    {
                        lastPoint = new System.Drawing.PointF((float)opMoveTo.X, (float)opMoveTo.Y);
                    }
                    else if (opLineTo != null)
                    {
                        System.Drawing.PointF linePoint = new System.Drawing.PointF((float)opLineTo.X, (float)opLineTo.Y);
                        graphicsPath.AddLine(lastPoint, linePoint);

                        lastPoint = linePoint;
                    }
                    else if (opRe != null)
                    {
                        System.Drawing.RectangleF re = new System.Drawing.RectangleF((float)opRe.X, (float)opRe.Y, (float)opRe.Width, (float)opRe.Height);
                        graphicsPath.AddRectangle(re);
                    }
                    else if (opEndPath != null)
                    {
                        graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
                    }
                    else if (opRGBFillColor != null)
                    {
                        fillColor = opRGBFillColor.getColor();
                    }
                    else if (opRGBStrokeColor != null)
                    {
                        strokeColor = opRGBStrokeColor.getColor();
                    }
                    else if (opStroke != null)
                    {
                        graphicsPath.Transform(lastCTM);
                        graphicsPath.Transform(inversionMatrix);
                        gr.DrawPath(new System.Drawing.Pen(strokeColor), graphicsPath);
                        graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
                    }
                    else if (opFill != null)
                    {
                        graphicsPath.FillMode = FillMode.Winding;
                        graphicsPath.Transform(lastCTM);
                        graphicsPath.Transform(inversionMatrix);
                        gr.FillPath(new System.Drawing.SolidBrush(fillColor), graphicsPath);
                        graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
                    }
                    else if (opEOFill != null)
                    {
                        graphicsPath.FillMode = FillMode.Alternate;
                        graphicsPath.Transform(lastCTM);
                        graphicsPath.Transform(inversionMatrix);
                        gr.FillPath(new System.Drawing.SolidBrush(fillColor), graphicsPath);
                        graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
                    }
                }
            }
            dataDir = dataDir + "ExtractBorder_out_.png";
            bitmap.Save(dataDir, ImageFormat.Png);
            // ExEnd:ExtractBorder
            Console.WriteLine("\nBorder extracted successfully as image.\nFile saved at " + dataDir);
        }