Exemple #1
0
		private void DrawVLine (DrawingContext dc)
		{
			var activeArea = GetArea (Region.Selection.SelectedToken, Region);
			if (activeArea == null)
				return;

			var width = Region.Selection.Type == SelectionType.Left ? -2 : activeArea.Width + 2;

			if (Region.Selection.SelectedToken is TextToken) {
				var textToken = Region.Selection.SelectedToken as TextToken;

				if (!string.IsNullOrEmpty (textToken.Text) && Region.Selection.Position != 0) {
					var ft = new FormattedText (textToken.Text.Substring (0, Region.Selection.Position), textToken.FontFamily, textToken.FontSize, Colors.Black);

					width = ft.Width + 2;
				} else
					width = 0;
			}

			var startPoint = activeArea.PointToScreen (new Point (width, -2));
			startPoint = Region.PointFromScreen (startPoint);

			var endPoint = activeArea.PointToScreen (new Point (width, activeArea.Height + 2));
			endPoint = Region.PointFromScreen (endPoint);

			dc.DrawLine (new Pen (Colors.Red, 1.5), startPoint, endPoint);
		}
Exemple #2
0
		protected override void OnRender (DrawingContext dc)
		{
			if (!Region.IsFocused)
				return;

			DrawVLine (dc);
			DrawHLine (dc);
		}	
Exemple #3
0
		protected override void OnRender (DrawingContext dc)
		{
			if (!IsVisible)
				return;

			dc.DrawLine (new Pen (Colors.Red, 2), new Point (X + 5, Y), new Point (X + 5, Y + 10));
			dc.DrawLine (new Pen (Colors.Red, 2), new Point (X, Y + 5), new Point (X + 10, Y + 5));
		}
		protected override void OnRender (DrawingContext dc)
		{
			if (Data == null)
				return;


			dc.DrawGeometry (Fill, new Pen (Stroke, StrokeThickness), Data);
		}
		protected override void OnRender (DrawingContext dc)
		{
			var anialias = dc.Antialias;
			
			dc.Antialias = SnapsToDevicePixels ? Antialias.None : anialias;

			dc.DrawEllipse (Fill, new Pen (Stroke, StrokeThickness), new Point (Width / 2, Height / 2), Width / 2, Height / 2);

			dc.Antialias = anialias;
		}
		protected override void OnRender (DrawingContext dc)
		{
			var anialias = dc.Antialias;
			
			dc.Antialias = SnapsToDevicePixels ? Antialias.None : anialias;

			dc.DrawLine (new Pen (Stroke, StrokeThickness), 
			             new Point (StrokeThickness / 2, StrokeThickness / 2), 
			             new Point (Width - StrokeThickness / 2, Height - StrokeThickness / 2));

			dc.Antialias = anialias;
		}
		protected override void OnRender (DrawingContext dc)
		{
			var anialias = dc.Antialias;
			
			dc.Antialias = SnapsToDevicePixels ? Antialias.None : anialias;

			var rect = new Rect (StrokeThickness / 2, StrokeThickness / 2, 
			                     Width - StrokeThickness / 2, Height - StrokeThickness / 2);

			dc.DrawRectangle (Fill, new Pen (Stroke, StrokeThickness), rect);

			dc.Antialias = anialias;
		}
Exemple #8
0
		private void DrawHLine (DrawingContext dc)
		{
			var activeArea = GetArea (Region.Selection.SelectedToken, Region);
			if (activeArea == null)
				return;

			var startPoint = activeArea.PointToScreen (new Point (-1, activeArea.Height + 2));
			startPoint = Region.PointFromScreen (startPoint);

			var endPoint = activeArea.PointToScreen (new Point (activeArea.Width + 2, activeArea.Height + 2));
			endPoint = Region.PointFromScreen (endPoint);

			dc.DrawLine (new Pen (Colors.Red, 1.5), startPoint, endPoint);
		} 
			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);
			}
Exemple #10
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);
			}
Exemple #11
0
			protected override void OnRender (DrawingContext dc)
			{
				base.OnRender (dc);
				DrawArc (dc, new Point (0, -3), new Point (0, Height + 3), new Size (10, Height), SweepDirection.Clockwise);
			}
		protected override void OnRender (DrawingContext dc)
		{
			foreach (var adorner in adorners) {
				adorner.Render (dc);
			}
		}
		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);
		}
		public void Render (DrawingContext dc)
		{
			OnRender (dc);

			for (int i = 0; i < VisualChildrenCount; i++) {
				var child = GetVisualChild (i);
				if (child is UIElement) {
					var uielement = child as UIElement;

					if (uielement.IsVisible) {
						dc.PushTransform (uielement.VisualTransform);
						
						if (uielement.VisualTransform is TransformGroup)
							uielement.Render (dc);
						else
							uielement.Render (dc);
						

						dc.Pop ();
					}
				}
			}
		}
		protected virtual void OnRender (DrawingContext dc)
		{			
		}
		protected override void OnRender (DrawingContext dc)
		{	
			dc.DrawText (new FormattedText (Text, FontFamily, FontSize, Foreground), new Point (0, 0));
		}
		protected override void OnRender (DrawingContext dc)
		{
			base.OnRender (dc);

			AdornerLayer.Render (dc);
		}