Пример #1
0
		public void PatternsAndImages (Context ctx, double x, double y)
		{
			ctx.Save ();
			ctx.Translate (x, y);
			
			ctx.SetColor (Colors.Black);
			// Dashed lines

			ctx.SetLineWidth (2);
			ctx.SetLineDash (15, 10, 10, 5, 5);
			ctx.Rectangle (10, 10, 100, 100);
			ctx.Stroke ();
			ctx.SetLineDash (0);
			
			// Image
			var arcColor = new Color (1, 0, 1);
			ImageBuilder ib = new ImageBuilder (30, 30);
			ib.Context.Arc (15, 15, 15, 0, 360);
			ib.Context.SetColor (arcColor);
			ib.Context.Fill ();
			ib.Context.SetColor (Colors.DarkKhaki);
			ib.Context.Rectangle (0, 0, 5, 5);
			ib.Context.Fill ();
			var img = ib.ToVectorImage ();
			ctx.DrawImage (img, 0, 0);
			ctx.DrawImage (img, 0, 50, 50, 10);
			
			ctx.Arc (100, 100, 15, 0, 360);
			arcColor.Alpha = 0.4;
			ctx.SetColor (arcColor);
			ctx.Fill ();
			
			// ImagePattern
			
			ctx.Save ();
			
			ctx.Translate (x + 130, y);
			ctx.Pattern = new ImagePattern (img);
			ctx.Rectangle (0, 0, 100, 100);
			ctx.Fill ();
			ctx.Restore ();
			
			ctx.Restore ();
			
			// Setting pixels
			
			ctx.SetLineWidth (1);
			for (int i=0; i<50;i++) {
				for (var j=0; j<50;j++) {
					Color c = Color.FromHsl (0.5, (double)i / 50d, (double)j / 50d);
					ctx.Rectangle (i, j, 1, 1);
					ctx.SetColor (c);
					ctx.Fill ();
				}
			}
		}	
Пример #2
0
		protected override void OnDraw (Context ctx, Rectangle bounds)
		{
			var lineWidth = bounds.Width / 32d;
			var section = ((bounds.Width / 2) - lineWidth / 2) / 3;

			ctx.SetLineWidth (lineWidth);

			ctx.SetColor (Colors.Black);
			ctx.Arc (bounds.Center.X, bounds.Center.Y, 1, 0, 360);
			ctx.Stroke ();
			
			ctx.SetColor (Colors.Red);
			ctx.Arc (bounds.Center.X, bounds.Center.Y, section, 0, 360);
			ctx.Stroke ();

			ctx.SetColor (Colors.Green);
			ctx.Arc (bounds.Center.X, bounds.Center.Y, section * 2, 0, 360);
			ctx.Stroke ();

			ctx.SetColor (Colors.Blue);
			ctx.Arc (bounds.Center.X, bounds.Center.Y, section * 3, 0, 360);
			ctx.Stroke ();
		}
Пример #3
0
        protected void TestDrawing2(Xwt.Drawing.Context ctx, double x, double y)
        {
            ctx.Save();
            ctx.Translate(x, y);
            var arcColor = new Color(1, 0, 1);

            ctx.Arc(100, 100, 15, 0, 360);
            ctx.ClosePath();
            arcColor.Alpha = 0.4;
            ctx.SetColor(arcColor);
            ctx.StrokePreserve();
            ctx.Fill();

            ctx.Restore();
        }
Пример #4
0
        protected override void OnDraw(Context ctx, Rectangle dirtyRect)
        {
            ctx.Save ();
            ctx.Translate (-hscroll.Value, -vscroll.Value);
            ctx.Rectangle (new Rectangle (0, 0, imageSize, imageSize));
            ctx.SetColor (Xwt.Drawing.Colors.White);
            ctx.Fill ();
            ctx.Arc (imageSize / 2, imageSize / 2, imageSize / 2 - 20, 0, 360);
            ctx.SetColor (new Color (0,0,1));
            ctx.Fill ();
            ctx.Restore ();

            ctx.Rectangle (0, 0, Bounds.Width, 30);
            ctx.SetColor (new Color (1, 0, 0, 0.5));
            ctx.Fill ();
        }
Пример #5
0
        protected override void OnDraw(Context ctx, Rectangle cellArea)
        {
            ctx.Rectangle (BackgroundBounds);
            ctx.SetColor (new Color (0.9, 0.9, 0.9));
            ctx.Fill ();

            ctx.Rectangle (Bounds);
            ctx.SetColor (new Color (0.7, 0.7, 0.7));
            ctx.Fill ();

            var pct = GetValue (ValueField);
            var size = (cellArea.Width * pct.Value) / 100f;
            cellArea.Width = (int) size;

            ctx.SetLineWidth (1);
            ctx.Rectangle (cellArea.Inflate (-0.5, -0.5));
            ctx.SetColor (Selected ? Colors.Blue : Colors.LightBlue);
            ctx.FillPreserve ();
            ctx.SetColor (Colors.Gray);
            ctx.Stroke ();

            if (pct.YPos != -1) {
                ctx.MoveTo (cellArea.Right, Bounds.Y + pct.YPos);
                ctx.Arc (cellArea.Right, Bounds.Y + pct.YPos, 2.5, 0, 360);
                ctx.SetColor (Colors.Red);
                ctx.Fill ();
            }
        }
Пример #6
0
		public virtual void Rectangles (Context ctx, double x, double y)
		{
			ctx.Save ();
			ctx.Translate (x, y);
			
			// Simple rectangles
			
			ctx.SetLineWidth (1);
			ctx.Rectangle (0, 0, 10, 10);
			ctx.SetColor (Colors.Black);
			ctx.Fill ();
			
			ctx.Rectangle (15, 0, 10, 10);
			ctx.SetColor (Colors.Black);
			ctx.Stroke ();
			
			ctx.SetLineWidth (3);
			ctx.Rectangle (0, 15, 10, 10);
			ctx.SetColor (Colors.Black);
			ctx.Fill ();
			
			ctx.Rectangle (15, 15, 10, 10);
			ctx.SetColor (Colors.Black);
			ctx.Stroke ();
			
			ctx.Restore ();
			
			// Rectangle with hole
			ctx.Save ();
			ctx.Translate (x + 50, y);
			
			ctx.Rectangle (0, 0, 40, 40);
			ctx.MoveTo (35, 35);
			ctx.RelLineTo (0, -20);
			ctx.RelLineTo (-20, 0);
			ctx.RelLineTo (0, 20);
			ctx.ClosePath ();
			ctx.SetColor (Colors.Black);
			ctx.Fill ();
			
			ctx.Restore ();
			
			// Rounded Rectangle with Arcs
			ctx.Save ();
			ctx.Translate (x + 120, y);
			
			var r = 5;
			var l = 0;
			var t = 0;
			var w = 50;
			var h = 30;

			ctx.SetColor (Colors.Black);
			// top left  
			ctx.Arc (l + r, t + r, r, 180, 270);
			// top right 
			ctx.Arc (l + w - r, t + r, r, 270, 0);
			// bottom right  
			ctx.Arc (l + w - r, t + h - r, r, 0, 90);
			// bottom left 
			ctx.Arc (l + r, t + h - r, r, 90, 180);
			
			ctx.ClosePath ();
			ctx.StrokePreserve ();
			ctx.SetColor (Colors.AntiqueWhite);
			ctx.Fill ();
			ctx.Restore ();
		}
Пример #7
0
			void Draw (Context ctx, bool fill)
			{
				var parent = (RoundedFrameBox)Parent;
				var border = parent.BorderSpacing;
				var radius = parent.cornerRadius;
				var rect = Bounds;

				ctx.MoveTo (rect.X, rect.Y);



				if (border.Top > 0) {
					ctx.NewPath ();
					if (radius.TopLeft > 0)
						ctx.Arc (rect.Left + radius.TopLeft + border.Left / 2, rect.Top + radius.TopLeft + border.Top / 2, radius.TopLeft, 180, 270);
					else
						PathTo (ctx, rect.Left, rect.Top + border.Top / 2, fill);

					if (radius.TopRight > 0) {
						ctx.LineTo (rect.Right - (radius.TopRight + border.Right / 2), rect.Top + border.Top / 2);
						ctx.Arc (rect.Right - (radius.TopRight + border.Right / 2), rect.Top + radius.TopRight + border.Top / 2, radius.TopRight, 270, 0);
					} else
						ctx.LineTo (rect.Right, rect.Top + border.Top / 2);
				} else
					PathTo (ctx, rect.Right - border.Right / 2, rect.Top, fill);

				if (border.Right > 0)
					// TODO: round corners if top/bottom border disabled
					ctx.LineTo (rect.Right - border.Right / 2, rect.Bottom - (border.Bottom > 0 ? radius.BottomRight : 0));
				else
					PathTo (ctx, rect.Right - border.Right / 2, rect.Bottom - (border.Bottom > 0 ? radius.BottomRight : 0), fill);

				if (border.Bottom > 0) {
					if (radius.BottomRight > 0)
						ctx.Arc (rect.Right - (radius.BottomRight + border.Right / 2), rect.Bottom - (radius.BottomRight + border.Bottom / 2), radius.BottomRight, 0, 90);
					else
						PathTo (ctx, rect.Right, rect.Bottom - border.Bottom / 2, fill);

					if (radius.BottomLeft > 0) {
						ctx.LineTo (rect.Left + (radius.BottomLeft + border.Left / 2), rect.Bottom - border.Bottom / 2);
						ctx.Arc (rect.Left + radius.BottomLeft + border.Left / 2, rect.Bottom - (radius.BottomLeft + border.Bottom / 2), radius.BottomLeft, 90, 180);
					} else
						ctx.LineTo (rect.Left + border.Left / 2, rect.Bottom - border.Bottom / 2);
				} else
					PathTo (ctx, rect.Left + border.Left / 2, rect.Bottom - border.Bottom / 2, fill);

				if (border.Left > 0)
					// TODO: round corners if top/bottom border disabled
					ctx.LineTo (rect.Left + border.Left / 2, rect.Top + (border.Top > 0 ? radius.TopLeft : 0));
				else
					PathTo (ctx, rect.Left + border.Left / 2, rect.Top + (border.Top > 0 ? radius.TopLeft : 0), fill);

				if (fill) {
					ctx.SetColor (parent.innerColor);
					ctx.Fill ();
				} else {
					ctx.SetColor (parent.borderColor);
					ctx.SetLineWidth (parent.borderWidth);
					ctx.Stroke ();
				}
			}
Пример #8
0
        protected override void OnDraw(Xwt.Drawing.Context ctx)
        {
            base.OnDraw(ctx);

            // Simple rectangles

            ctx.SetLineWidth(1);
            ctx.Rectangle(100, 5, 10, 10);
            ctx.SetColor(Color.Black);
            ctx.Fill();

            ctx.Rectangle(115, 5, 10, 10);
            ctx.SetColor(Color.Black);
            ctx.Stroke();

            //

            ctx.SetLineWidth(3);
            ctx.Rectangle(100, 20, 10, 10);
            ctx.SetColor(Color.Black);
            ctx.Fill();

            ctx.Rectangle(115, 20, 10, 10);
            ctx.SetColor(Color.Black);
            ctx.Stroke();

            // Rectangle with hole

            ctx.Rectangle(10, 100, 40, 40);
            ctx.MoveTo(45, 135);
            ctx.RelLineTo(0, -20);
            ctx.RelLineTo(-20, 0);
            ctx.RelLineTo(0, 20);
            ctx.ClosePath();
            ctx.SetColor(Color.Black);
            ctx.Fill();

            // Dashed lines

            ctx.SetLineDash(15, 10, 10, 5, 5);
            ctx.Rectangle(100, 100, 100, 100);
            ctx.Stroke();
            ctx.SetLineDash(0);

            ImageBuilder ib = new ImageBuilder(30, 30, ImageFormat.ARGB32);

            ib.Context.Arc(15, 15, 15, 0, 360);
            ib.Context.SetColor(new Color(1, 0, 1));
            ib.Context.Rectangle(0, 0, 5, 5);
            ib.Context.Fill();
            var img = ib.ToImage();

            ctx.DrawImage(img, 90, 90);
            ctx.DrawImage(img, 90, 140, 50, 10);

            ctx.Arc(190, 190, 15, 0, 360);
            ctx.SetColor(new Color(1, 0, 1, 0.4));
            ctx.Fill();

            ctx.Save();
            ctx.Translate(90, 220);
            ctx.Pattern = new ImagePattern(img);
            ctx.Rectangle(0, 0, 100, 70);
            ctx.Fill();
            ctx.Restore();

            ctx.Translate(30, 30);
            double end = 270;

            for (double n = 0; n <= end; n += 5)
            {
                ctx.Save();
                ctx.Rotate(n);
                ctx.MoveTo(0, 0);
                ctx.RelLineTo(30, 0);
                double c = n / end;
                ctx.SetColor(new Color(c, c, c));
                ctx.Stroke();
                ctx.Restore();
            }

            ctx.ResetTransform();
        }
Пример #9
0
        protected override void OnDraw(Context ctx)
        {
            ctx.Translate (-hscroll.Value, -vscroll.Value);
            ctx.Rectangle (new Rectangle (0, 0, imageSize, imageSize));
            ctx.SetColor (Color.White);
            ctx.Fill ();
            ctx.Arc (imageSize / 2, imageSize / 2, imageSize / 2 - 20, 0, 360);
            ctx.SetColor (new Color (0,0,1));
            ctx.Fill ();
            ctx.ResetTransform ();

            ctx.Rectangle (0, 0, Bounds.Width, 30);
            ctx.SetColor (new Color (1, 0, 0, 0.5));
            ctx.Fill ();
        }
Пример #10
0
        protected override void OnDraw(Context ctx, Rectangle dirtyRect)
        {
            base.OnDraw(ctx, dirtyRect);

            if (image != null) {
                if (Heighlighted && IsThumbnail) {
                    ctx.RoundRectangle(new Rectangle(Point.Zero, image.Size), 3);
                    ctx.SetColor(Colors.LightSteelBlue);
                    ctx.Fill();
                }

                ctx.DrawImage(image, (new Rectangle(Point.Zero, image.Size)).Inflate(-3, -3));

                if (mask != null && ShowMask) {
                    ctx.DrawImage(MaskBitmap, (new Rectangle(Point.Zero, image.Size)).Inflate(-3, -3), 0.6);
                }
            }

            if (isEditMode) {
                Point scaleFactor = new Point(
                                        scan.Size.Width / image.Size.Width,
                                        scan.Size.Height / image.Size.Height);
                ctx.SetColor(Mask.maskColor);

                foreach (MaskEntry p in scan.Mask.MaskPositions) {
                    switch (p.type) {
                    case MaskEntryType.Point:
                        ctx.SetLineWidth(p.pointerSize / scaleFactor.Y * 2);
                        ctx.LineTo(p.position.X / scaleFactor.X, p.position.Y / scaleFactor.Y);
                        ctx.Stroke();

                        ctx.Arc(
                            p.position.X / scaleFactor.X, p.position.Y / scaleFactor.Y,
                            p.pointerSize / scaleFactor.Y, 0, 360);
                        ctx.Fill();

                        ctx.MoveTo(p.position.X / scaleFactor.X, p.position.Y / scaleFactor.Y);
                        break;
                    case MaskEntryType.Space:
                        ctx.Stroke();
                        ctx.ClosePath();
                        break;
                    case MaskEntryType.Delete:
                        ctx.Arc(
                            p.position.X / scaleFactor.X, p.position.Y / scaleFactor.Y,
                            p.pointerSize / scaleFactor.Y, 0, 360);
                        ctx.Save();
                        ctx.Clip();
                        int newX = (int) Math.Min(Math.Max(
                                       p.position.X / scaleFactor.X - pointerSize / scaleFactor.Y, 0), scan.Size.Width);
                        int newY = (int) Math.Min(Math.Max(
                                       p.position.Y / scaleFactor.Y - pointerSize / scaleFactor.Y, 0), scan.Size.Height);

                        using (ImageBuilder ib =
                                   new ImageBuilder((pointerSize / scaleFactor.Y * 2), (pointerSize / scaleFactor.Y * 2))) {
                            BitmapImage bi = ib.ToBitmap();
                            image.WithBoxSize(image.Size).ToBitmap().CopyArea(
                                newX, newY,
                                (int) (pointerSize / scaleFactor.Y * 2), (int) (pointerSize / scaleFactor.Y * 2),
                                bi, 0, 0);
                            ctx.DrawImage(bi, new Point(newX, newY));
                        }
                        ctx.Restore();
                        ctx.ClosePath();
                        break;
                    }
                }

                ctx.Stroke();

                if (mousePosition != Point.Zero) {
                    ctx.Arc(mousePosition.X, mousePosition.Y, pointerSize / Math.Max(scaleFactor.X, scaleFactor.Y), 0, 360);
                    ctx.Fill();

                    if (mousePositionStart != Point.Zero) {
                        ctx.SetLineWidth((pointerSize / Math.Max(scaleFactor.X, scaleFactor.Y)) * 2);
                        ctx.SetColor(Mask.maskColor);
                        ctx.Arc(mousePositionStart.X, mousePositionStart.Y, pointerSize / Math.Max(scaleFactor.X, scaleFactor.Y), 0, 360);
                        ctx.Fill();
                        ctx.MoveTo(mousePosition);
                        ctx.LineTo(mousePositionStart);
                        ctx.Stroke();
                    }
                }
            }
        }
Пример #11
0
 void DrawFocus(Context ctx, Point p)
 {
     // Draw a 'zoom'-style Focus at specified point
     double focusRadius = 32;
     double r = 12, w = focusRadius - 1;
     Point o = Point.Zero;	// Drawing origin
     // Align single-thickness lines on 0.5 pixel coords
     o.X += 0.5;
     o.Y += 0.5;
     ctx.Save ();
     ctx.Translate (p);	// Final translation
     // Hairlines in X-direction
     ctx.MoveTo (o.X + r, o.Y);
     ctx.LineTo (o.X + w, o.Y);
     ctx.MoveTo (o.X - r, o.Y);
     ctx.LineTo (o.X - w, o.Y);
     // Hairlines in Y-direction
     ctx.MoveTo (o.X, o.Y + r);
     ctx.LineTo (o.X, o.Y + w);
     ctx.MoveTo (o.X, o.Y - r);
     ctx.LineTo (o.X, o.Y - w);
     // Inner single-thickness circle
     ctx.MoveTo (o.X + r, o.Y);
     ctx.Arc (o.X, o.Y, r, 0, 360);
     ctx.SetColor (Colors.Black);
     ctx.SetLineWidth (1);
     ctx.Stroke ();
     // Double thickness outer arcs. Draw at (0,0) and rotate
     o = Point.Zero;
     r = 22;
     ctx.Rotate (5);
     ctx.MoveTo (r, 0);
     ctx.Arc (o.X, o.Y, r, 0, 80);
     ctx.MoveTo (o.X, r);
     ctx.Arc (o.X, o.Y, r, 90, 170);
     ctx.MoveTo (-r, o.Y);
     ctx.Arc (o.X, o.Y, r, 180, 260);
     ctx.MoveTo (o.X, -r);
     ctx.Arc (o.X, o.Y, r, 270, 350);
     ctx.SetLineWidth (2);
     ctx.Stroke ();
     ctx.Restore ();
 }
Пример #12
0
        /// <summary>
        /// Draws the marker at the given position
        /// </summary>
        /// <param name="ctx">The Drawing Context with which to draw.</param>
        /// <param name="x">The [physical] x position to draw the marker.</param>
        /// <param name="y">The [physical] y position to draw the marker.</param>
        public void Draw(Context ctx, double x, double y )
        {
            ctx.Save ();
            ctx.SetLineWidth (lineWidth);
            ctx.SetColor (lineColor);

            switch (markerType) {
            case MarkerType.Cross1:
                ctx.MoveTo (x-h, y+h);
                ctx.LineTo (x+h, y-h);
                ctx.MoveTo (x+h, y+h);
                ctx.LineTo (x-h, y-h);
                ctx.Stroke ();
                break;

            case MarkerType.Cross2:
                ctx.MoveTo (x, y-h);
                ctx.LineTo (x, y+h);
                ctx.MoveTo (x-h, y);
                ctx.LineTo (x+h, y);
                ctx.Stroke ();
                break;

            case MarkerType.Circle:
                ctx.MoveTo (x+h,y);
                ctx.Arc (x, y, h, 0, 360);
                ctx.ClosePath ();
                if (filled ) {
                    ctx.SetColor (fillColor);
                    ctx.FillPreserve ();
                }
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.Square:
                ctx.Rectangle (x-h, y-h, size, size);
                ctx.ClosePath ();
                if (filled) {
                    ctx.SetColor (fillColor);
                    ctx.FillPreserve ();
                }
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.Triangle:
                ctx.MoveTo (x-h, y+h);
                ctx.LineTo (x, y-h);
                ctx.LineTo (x+h, y+h);
                ctx.ClosePath ();
                if (filled) {
                    ctx.SetColor (fillColor);
                    ctx.FillPreserve ();
                }
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.TriangleDown:
                ctx.MoveTo (x-h, y-h);
                ctx.LineTo (x, y+h);
                ctx.LineTo (x+h, y-h);
                ctx.ClosePath ();
                if (filled) {
                    ctx.SetColor (fillColor);
                    ctx.FillPreserve ();
                }
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.FilledCircle:
                ctx.MoveTo (x+h,y);
                ctx.Arc (x, y, h, 0, 360);
                ctx.ClosePath ();
                ctx.SetColor (fillColor);
                ctx.FillPreserve ();
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.FilledSquare:
                ctx.Rectangle (x-h, y-h, size, size);
                ctx.ClosePath ();
                ctx.SetColor (fillColor);
                ctx.FillPreserve ();
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.FilledTriangle:
                ctx.MoveTo (x-h, y+h);
                ctx.LineTo (x, y-h);
                ctx.LineTo (x+h, y+h);
                ctx.ClosePath ();
                ctx.SetColor (fillColor);
                ctx.FillPreserve ();
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.Diamond:
                ctx.MoveTo (x-h, y);
                ctx.LineTo (x, y-h);
                ctx.LineTo (x+h, y);
                ctx.LineTo (x, y+h);
                ctx.ClosePath ();
                if (filled) {
                    ctx.SetColor (fillColor);
                    ctx.FillPreserve ();
                }
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.Flag:
                ctx.MoveTo (x, y-size);
                ctx.LineTo (x+size, y-size+size/3);
                ctx.LineTo (x, y-size+2*size/3);
                ctx.ClosePath ();
                ctx.MoveTo (x, y);
                ctx.LineTo (x, y-size);
                if (filled) {
                    ctx.SetColor (fillColor);
                    ctx.FillPreserve ();
                }
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.FlagDown:
                ctx.MoveTo (x, y+size);
                ctx.LineTo (x+size, y+size-size/3);
                ctx.LineTo (x, y+size-2*size/3);
                ctx.ClosePath ();
                ctx.MoveTo (x, y);
                ctx.LineTo (x, y+size);
                if (filled) {
                    ctx.SetColor (fillColor);
                    ctx.FillPreserve ();
                }
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.FilledFlag:
                ctx.MoveTo (x, y-size);
                ctx.LineTo (x+size, y-size+size/3);
                ctx.LineTo (x, y-size+2*size/3);
                ctx.ClosePath ();
                ctx.MoveTo (x, y);
                ctx.LineTo (x, y-size);
                ctx.SetColor (fillColor);
                ctx.FillPreserve ();
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.None:
                    break;
            }
            ctx.Restore ();
        }
Пример #13
0
        void DrawFocus( Context ctx, double x, double y )
        {
            if (!cursorVisible)
                return;

            double r = 16;

            ctx.Save ();

            x += 0.5;
            y += 0.5;

            ctx.SetLineWidth (3);
            ctx.SetColor (new Color (0, 0, 0, 0.5));
            ctx.Arc (x, y, r, 0, 360);
            ctx.Stroke ();

            ctx.SetLineWidth (1);

            ctx.MoveTo (x+r, y);
            ctx.RelLineTo (r, 0);
            ctx.MoveTo (x-r, y);
            ctx.RelLineTo (-r, 0);

            ctx.MoveTo (x, y+r);
            ctx.RelLineTo (0, r);
            ctx.MoveTo (x, y-r);
            ctx.RelLineTo (0, -r);
            ctx.Stroke ();

            r += 10;
            ctx.Arc (x, y, r, 10, 80);
            ctx.Stroke ();
            ctx.Arc (x, y, r, 100, 170);
            ctx.Stroke ();
            ctx.Arc (x, y, r, 190, 260);
            ctx.Stroke ();
            ctx.Arc (x, y, r, 280, 350);
            ctx.Stroke ();

            ctx.Restore ();
        }
Пример #14
0
        /// <summary>
        /// Draw the marker.
        /// </summary>
        /// <param name="ctx">Context.</param>
        public override void Draw(Context ctx)
        {
            ctx.SetColor(PipelineNode.NodeColorBorder);

            Rectangle bndTmp = Bounds;

            ctx.RoundRectangle(bndTmp.Inflate(-2, -2), 2);
            if (compatible.IsFinal()) {
                ctx.SetColor(Colors.LightGray);
            } else {
                ctx.RoundRectangle(bndTmp.Inflate(-1, -1), 3);
                using (LinearGradient g = new LinearGradient(bndTmp.Left, bndTmp.Top, bndTmp.Right, bndTmp.Bottom)) {
                    g.AddColorStop(0, Colors.Black.BlendWith(NodeColor, 0.7));
                    g.AddColorStop(1, NodeColor);
                    ctx.Pattern = g;
                    ctx.Fill();
                }

                ctx.SetColor(NodeColor);
            }
            ctx.Fill();

            if (IsInput) {
                int inputBufferSize = inputData.Count;
                List<Result> ihCopy;
                lock (inputHistoryLock) {
                    ihCopy = new List<Result>(inputHistory);
                }
                foreach (Result input in ihCopy) {
                    if (input.IsUsed(parent)) {
                        inputBufferSize++;
                    } else {
                        lock (inputHistoryLock) {
                            inputHistory.Remove(input);
                        }
                    }
                }
                if (inputBufferSize > 0) {
                    bool sourceNodeIsAbove = true;
                    if (edges.Count > 0 && edges[0] != null) {
                        if (edges[0].to.Bounds.Center.Y > Bounds.Center.Y - 4.0) {
                            sourceNodeIsAbove = false;
                        }
                    }

                    textLayout.Text = inputBufferSize.ToString();
                    double textWidth = textLayout.GetSize().Width;
                    double textHeight = textLayout.GetSize().Height;
                    Point inputbufferSizeLocation =
                        Bounds.Location.Offset(
                            -24 -(textWidth/2),
                            sourceNodeIsAbove ? textHeight + 6 : -6 - textHeight);

                    ctx.Arc(
                        inputbufferSizeLocation.X + textWidth / 2,
                        inputbufferSizeLocation.Y + textHeight / 2,
                        Math.Max(textHeight, textWidth) / 2 + 1,
                        0, 360
                    );
                    ctx.Fill();

                    ctx.SetColor(PipelineNode.NodeColor);
                    ctx.DrawTextLayout(textLayout, inputbufferSizeLocation);
                }
            } else {
                // if this is a final node
                if (parent.algorithm.Output[positionNo].IsFinal()) {
                    ctx.MoveTo(bndTmp.Right + 4, bndTmp.Top);
                    ctx.LineTo(bndTmp.Right + 4, bndTmp.Bottom);
                    ctx.Stroke();

                    // draw output size on end nodes (= number of features
                    if (parent.results != null &&
                        parent.results.Count > 0 &&
                        parent.results[0].Item1 != null &&
                        parent.results[0].Item1.Length - 1 >= Position) {

                        textLayout.Text = parent.results.Count.ToString();
                        double textWidth = textLayout.GetSize().Width;
                        double textHeight = textLayout.GetSize().Height;
                        Point outputbufferSizeLocation =
                            Bounds.Location.Offset(Bounds.Width * 1.8, 0);

                        ctx.Arc(
                            outputbufferSizeLocation.X + textWidth / 2,
                            outputbufferSizeLocation.Y + textHeight / 2,
                            Math.Max(textHeight, textWidth) / 2 + 1,
                            0, 360
                        );
                        ctx.Fill();

                        ctx.SetColor(PipelineNode.NodeColor);
                        ctx.DrawTextLayout(textLayout, outputbufferSizeLocation);
                    }
                }
            }
        }
Пример #15
0
        void DrawFocus(Context ctx, Point p)
        {
            // Draw a 'zoom'-style Focus at specified point.
            // Following values draw at (0,0) with Size (64,64)
            double r1 = 12, r2 = 22, w = 31;
            Point o = Point.Zero;	// Drawing origin
            // Align single-thickness lines on 0.5 pixel coords
            o.X += 0.5;
            o.Y += 0.5;

            ctx.Save ();
            ctx.SetColor (Colors.Black);
            ctx.SetLineWidth (1);
            ctx.Translate (p);	// Final translation to point p
            // draw as 4 quadrants, each rotated by +90 degrees
            for (double theta = 0; theta < 300; theta += 90) {
                ctx.Rotate (theta);
                // Hairline in X-direction, ending at x=r1
                ctx.MoveTo (o.X + w, o.Y);
                ctx.LineTo (o.X + r1, o.Y);
                // Inner single-thickness arc
                ctx.Arc (o.X, o.Y, r1, 0, 90);
                ctx.Stroke ();
                // Double thickness outer arc, 10 - 80 degrees. Draw at (0,0) and rotate
                ctx.Save ();
                ctx.Rotate (10);
                ctx.MoveTo (r2, 0);
                ctx.Arc (0, 0, r2, 0, 70);
                ctx.SetLineWidth (2);
                ctx.Stroke ();
                ctx.Restore ();
            }
            ctx.Restore ();
        }