Пример #1
0
		protected override void OnRender (DrawingContext dc)
		{
			if (Data == null)
				return;


			dc.DrawGeometry (Fill, new Pen (Stroke, StrokeThickness), Data);
		}
Пример #2
0
			protected void DrawArc (DrawingContext dc, Point start, Point end, Size size, SweepDirection sweepDirection)
			{
				var figure = new PathFigure ();
				figure.StartPoint = start;

				figure.Segments.Add (new ArcSegment () 
				{ 
					Point = end, Size = size, SweepDirection = sweepDirection
				}
				);
				
				var geometry = new PathGeometry ();
				geometry.Figures.Add (figure);

				dc.DrawGeometry (null, new Pen (Colors.Black, 2), geometry);
			}
Пример #3
0
			protected override void OnRender (DrawingContext dc)
			{
				base.OnRender (dc);

				var figure = new PathFigure ()
				{
					StartPoint = new Point (0, 0.3 * Height)
				};

				figure.Segments.Add (new LineSegment () { Point = new Point (3, 0.3 * Height) });
				figure.Segments.Add (new LineSegment () { Point = new Point (6, Height) });
				figure.Segments.Add (new LineSegment () { Point = new Point (10, 0) });
				figure.Segments.Add (new LineSegment () { Point = new Point (Width + 2, 0) });
				
				var geometry = new PathGeometry ();
				geometry.Figures.Add (figure);

				dc.DrawGeometry (null, new Pen (Colors.Black, 2), geometry);
			}
Пример #4
0
		protected override void OnRender (DrawingContext dc)
		{		
			if (Child == null)
				return;
			
			var x = BorderThickness / 2;
			var y = BorderThickness / 2;
			var width = Width - BorderThickness;
			var height = Height - BorderThickness;

			var figure = new PathFigure ();
			figure.StartPoint = new Point (x + CornerRadius.TopLeft, y);
			figure.IsClosed = true;
			
			figure.Segments.Add (new LineSegment () { Point = new Point(x + width - CornerRadius.TopRight, y)});
			if (CornerRadius.TopRight > 0) {
				figure.Segments.Add (new ArcSegment () 
			    	{
						Point = new Point(x + width, y + CornerRadius.TopRight),
						Size = new Size(CornerRadius.TopRight, CornerRadius.TopRight),
						SweepDirection = SweepDirection.Clockwise,
						IsLargeArc = false
					}
				);
			}
			figure.Segments.Add (new LineSegment () { Point = new Point(x + width, y + height - CornerRadius.BottomRight) });
			if (CornerRadius.BottomRight > 0) {
				figure.Segments.Add (new ArcSegment () 
			    	{
						Point = new Point(x + width - CornerRadius.BottomRight, y + height),
						Size = new Size(CornerRadius.BottomRight, CornerRadius.BottomRight),
						SweepDirection = SweepDirection.Clockwise,
						IsLargeArc = false
					}
				);
			}
			figure.Segments.Add (new LineSegment () { Point = new Point(x + CornerRadius.BottomLeft, y + height) });
			if (CornerRadius.BottomLeft > 0) {
				figure.Segments.Add (new ArcSegment () 
				    {
						Point = new Point(x, y + height - CornerRadius.BottomLeft),
						Size = new Size(CornerRadius.BottomLeft, CornerRadius.BottomLeft),
						SweepDirection = SweepDirection.Clockwise,
						IsLargeArc = false
					}
				);
			}
			figure.Segments.Add (new LineSegment () { Point = new Point(x, y + CornerRadius.TopLeft) });
			if (CornerRadius.TopLeft > 0) {				
				figure.Segments.Add (new ArcSegment () 
			    	{
						Point = new Point(x + CornerRadius.TopLeft, y),
						Size = new Size(CornerRadius.TopLeft, CornerRadius.TopLeft),
						SweepDirection = SweepDirection.Clockwise,
						IsLargeArc = false
					}
				);
			}
			
			var path = new PathGeometry ();
			path.Figures.Add (figure);				
			
			//todo: resove it
			var brush = Background;
			
			if (brush is LinearGradientBrush) {
				var b = brush as LinearGradientBrush;
				var newBrush = new LinearGradientBrush ()
				{
					StartPoint = new Point (b.StartPoint.X * width, b.StartPoint.Y * height),
					EndPoint = new Point (b.EndPoint.X * width, b.EndPoint.Y * height)
				};
				
				newBrush.GradientStops.AddRange (b.GradientStops);
				
				brush = newBrush;
			}
			
			dc.DrawGeometry (brush, new Pen (BorderColor, BorderThickness), path);
		}