public void test(IDrawingContext context) { Debug.Assert(context.Width == 80); Debug.Assert(context.Height == 40); context.roundedRect(0, 0, context.Width, context.Height, 8); }
public override void Render(IDrawingContext context) { double range = this.Bounds.Width/(MaxValue - MinValue); Pen backgroundPen = new Pen(Brushes.Black, 5); Brush TextBrush = Brushes.Black; double step = 0.5; int countValue = (int) (range / step); double stepX = this.Bounds.Width/countValue; for (int i = 0; i < countValue; i++) { var x = i* stepX; // context.DrawLine(backgroundPen, new Point(x, 0), new Point(x, this.Bounds.Height)); context.DrawText(TextBrush, new Point(x, 2),new FormattedText((i*step).ToString(), "Verdana", 22,FontStyle.Normal, TextAlignment.Center,FontWeight.Normal)); } //context.DrawLine(foreground, new Point(100, 100), new Point(200, 200)); /* var AxisMajorBrush = Brushes.Black; context.DrawRectange(new Pen(AxisMajorBrush,2),new Rect(new Point(10, 0), new Point(10, Height))); var borderBrush = Brushes.AliceBlue; var borderThickness = 3; var cornerRadius = 2; var rect = new Rect(Bounds.Size).Deflate(new Thickness(borderThickness)); context.FillRectange(backgroundPen.Brush, rect, cornerRadius); if (borderBrush != null && borderThickness > 0) { context.DrawRectange(new Pen(borderBrush, borderThickness), rect, cornerRadius); }*/ }
public IDisposable beginDraw(out IDrawingContext context) { var surface = _texture.AsSurface(); var rtProperties = new RenderTargetProperties() { DpiX = 96, DpiY = 96, Type = RenderTargetType.Default, PixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Premultiplied) }; var renderTarget = new RenderTarget(_factory, surface, rtProperties); var c = new RenderTargetDrawingContext(renderTarget, _width, _height); context = c; renderTarget.BeginDraw(); return new DisposeAction(() => { renderTarget.EndDraw(); c.Dispose(); renderTarget.Dispose(); surface.Dispose(); }); }
protected override void OnRender(IDrawingContext drawingContext) { if (this.Background != null) { drawingContext.DrawRectangle(new Rect(0, 0, this.ActualWidth, this.ActualHeight), this.Background); } }
public virtual void Draw(IDrawingContext context) { //������� foreach (PolygonDrawing polygon in polygons) { polygon.Draw(context); } }
public virtual void Draw(IDrawingContext context) { //���߶� foreach (IDrawing line in lines) { line.Draw(context); } }
/// <summary> /// Init. /// </summary> /// <param name="g">the Perspex graphics object to use</param> /// <param name="initialClip">the initial clip of the graphics</param> /// <param name="releaseGraphics">optional: if to release the graphics object on dispose (default - false)</param> public GraphicsAdapter(IDrawingContext g, RRect initialClip, bool releaseGraphics = false) : base(PerspexAdapter.Instance, initialClip) { ArgChecker.AssertArgNotNull(g, "g"); _g = g; _releaseGraphics = releaseGraphics; }
/// <summary> /// /// </summary> /// <param name="context"></param> public override void Render(IDrawingContext context) { base.Render(context); if (_state == null) { InitializeDrawable(); InitializeLayers(); ResizeDrawable(); } Draw(context); }
public override void Render(IDrawingContext context) { var selectionStart = SelectionStart; var selectionEnd = SelectionEnd; if (selectionStart != selectionEnd) { var start = Math.Min(selectionStart, selectionEnd); var length = Math.Max(selectionStart, selectionEnd) - start; var rects = FormattedText.HitTestTextRange(start, length); var brush = new SolidColorBrush(0xff086f9e); foreach (var rect in rects) { context.FillRectange(brush, rect); } } base.Render(context); if (selectionStart == selectionEnd) { var charPos = FormattedText.HitTestTextPosition(CaretIndex); var backgroundColor = (((Control)TemplatedParent).GetValue(BackgroundProperty) as SolidColorBrush)?.Color; var caretBrush = Brushes.Black; if(backgroundColor.HasValue) { byte red = (byte)~(backgroundColor.Value.R); byte green = (byte)~(backgroundColor.Value.G); byte blue = (byte)~(backgroundColor.Value.B); caretBrush = new SolidColorBrush(Color.FromRgb(red, green, blue)); } if (_caretBlink) { var x = Math.Floor(charPos.X) + 0.5; var y = Math.Floor(charPos.Y) + 0.5; var b = Math.Ceiling(charPos.Bottom) - 0.5; context.DrawLine( new Pen(caretBrush, 1), new Point(x, y), new Point(x, b)); } } }
/// <summary> /// Renders the <see cref="AccessText"/> to a drawing context. /// </summary> /// <param name="context">The drawing context.</param> public override void Render(IDrawingContext context) { base.Render(context); int underscore = Text?.IndexOf('_') ?? -1; if (underscore != -1 && ShowAccessKey) { var rect = FormattedText.HitTestTextPosition(underscore); var offset = new Vector(0, -0.5); context.DrawLine( new Pen(Foreground, 1), rect.BottomLeft + offset, rect.BottomRight + offset); } }
/// <summary> /// Renders the control. /// </summary> /// <param name="context">The drawing context.</param> public override void Render(IDrawingContext context) { var background = Background; var borderBrush = BorderBrush; var borderThickness = BorderThickness; var cornerRadius = CornerRadius; var rect = new Rect(Bounds.Size).Deflate(BorderThickness); if (background != null) { context.FillRectange(background, rect, cornerRadius); } if (borderBrush != null && borderThickness > 0) { context.DrawRectange(new Pen(borderBrush, borderThickness), rect, cornerRadius); } }
public override void Render(IDrawingContext context) { Brush background = this.Background; Brush borderBrush = this.BorderBrush; double borderThickness = this.BorderThickness; float cornerRadius = this.CornerRadius; Rect rect = new Rect(this.Bounds.Size).Deflate(this.BorderThickness); if (background != null) { context.FillRectange(background, rect, cornerRadius); } if (borderBrush != null && borderThickness > 0) { context.DrawRectange(new Pen(borderBrush, borderThickness), rect, cornerRadius); } }
public override void Render(IDrawingContext drawingContext) { Bitmap source = this.Source; if (source != null) { Rect viewPort = new Rect(this.Bounds.Size); Size sourceSize = new Size(source.PixelWidth, source.PixelHeight); Vector scale = CalculateScaling(this.Bounds.Size, sourceSize, this.Stretch); Size scaledSize = sourceSize * scale; Rect destRect = viewPort .CenterIn(new Rect(scaledSize)) .Intersect(viewPort); Rect sourceRect = new Rect(sourceSize) .CenterIn(new Rect(destRect.Size / scale)); drawingContext.DrawImage(source, 1, sourceRect, destRect); } }
public override void Render(IDrawingContext context) { var selectionStart = SelectionStart; var selectionEnd = SelectionEnd; if (selectionStart != selectionEnd) { var start = Math.Min(selectionStart, selectionEnd); var length = Math.Max(selectionStart, selectionEnd) - start; var rects = FormattedText.HitTestTextRange(start, length); var brush = new SolidColorBrush(0xff086f9e); foreach (var rect in rects) { context.FillRectange(brush, rect); } } base.Render(context); if (selectionStart == selectionEnd) { var charPos = FormattedText.HitTestTextPosition(CaretIndex); Brush caretBrush = Brushes.Black; if (_caretBlink) { var x = Math.Floor(charPos.X) + 0.5; var y = Math.Floor(charPos.Y) + 0.5; var b = Math.Ceiling(charPos.Bottom) - 0.5; context.DrawLine( new Pen(caretBrush, 1), new Point(x, y), new Point(x, b)); } } }
/// <summary> /// Renders the specified visual. /// </summary> /// <param name="visual">The visual to render.</param> /// <param name="context">The drawing context.</param> /// <param name="translation">The current translation.</param> /// <param name="transform">The current transform.</param> protected virtual void Render(IVisual visual, IDrawingContext context, Matrix translation, Matrix transform) { var opacity = visual.Opacity; if (visual.IsVisible && opacity > 0) { // Translate any existing transform into this controls coordinate system. Matrix offset = Matrix.CreateTranslation(visual.Bounds.Position); transform = offset * transform * -offset; // Update the current offset. translation *= Matrix.CreateTranslation(visual.Bounds.Position); // Apply the control's render transform, if any. if (visual.RenderTransform != null) { offset = Matrix.CreateTranslation(visual.TransformOrigin.ToPixels(visual.Bounds.Size)); transform *= -offset * visual.RenderTransform.Value * offset; } // Draw the control and its children. var m = transform * translation; var d = context.PushTransform(m); using (context.PushOpacity(opacity)) using (visual.ClipToBounds ? context.PushClip(visual.Bounds) : null) { visual.Render(context); d.Dispose(); foreach (var child in visual.VisualChildren.OrderBy(x => x.ZIndex)) { Render(child, context, translation, transform); } } } }
public override void Draw(IDrawingContext context) { context.Graphics.DrawLine(context.Pen, this.Points[0], this.Points[1]); }
/// <summary> /// Renders the visual to a <see cref="IDrawingContext"/>. /// </summary> /// <param name="context">The drawing context.</param> public virtual void Render(IDrawingContext context) { Contract.Requires<ArgumentNullException>(context != null); }
/// <summary> /// /// </summary> /// <param name="dc"></param> /// <param name="stroke"></param> /// <param name="rect"></param> /// <param name="offsetX"></param> /// <param name="offsetY"></param> /// <param name="cellWidth"></param> /// <param name="cellHeight"></param> /// <param name="isStroked"></param> private void DrawGridInternal( IDrawingContext dc, Pen stroke, ref Rect2 rect, double offsetX, double offsetY, double cellWidth, double cellHeight, bool isStroked) { double ox = rect.X; double oy = rect.Y; double sx = ox + offsetX; double sy = oy + offsetY; double ex = ox + rect.Width; double ey = oy + rect.Height; for (double x = sx; x < ex; x += cellWidth) { var p0 = new Point( _scaleToPage(x), _scaleToPage(oy)); var p1 = new Point( _scaleToPage(x), _scaleToPage(ey)); DrawLineInternal(dc, stroke, isStroked, ref p0, ref p1); } for (double y = sy; y < ey; y += cellHeight) { var p0 = new Point( _scaleToPage(ox), _scaleToPage(y)); var p1 = new Point( _scaleToPage(ex), _scaleToPage(y)); DrawLineInternal(dc, stroke, isStroked, ref p0, ref p1); } }
protected override void OnRender(IDrawingContext drawingContext) { if (this.Background != null) { drawingContext.DrawRectangle(new Rect(0, 0, this.ActualWidth, this.ActualHeight), this.Background); } drawingContext.DrawText( this.spriteFont, this.formattedText, new Point(this.Padding.Left, this.Padding.Top), this.Foreground ?? new SolidColorBrush(Colors.Black)); }
/// <summary> /// /// </summary> /// <param name="dc"></param> /// <param name="brush"></param> /// <param name="pen"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="rect"></param> private static void DrawEllipseInternal( IDrawingContext dc, Brush brush, Pen pen, bool isStroked, bool isFilled, ref Rect2 rect) { if (!isFilled && !isStroked) return; var r = new Rect(rect.X, rect.Y, rect.Width, rect.Height); var g = new EllipseGeometry(r); dc.DrawGeometry( isFilled ? brush : null, isStroked ? pen : null, g); // TODO: g.Dispose(); }
/// <summary> /// /// </summary> /// <param name="dc"></param> /// <param name="brush"></param> /// <param name="pen"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="rect"></param> private static void DrawRectangleInternal( IDrawingContext dc, Brush brush, Pen pen, bool isStroked, bool isFilled, ref Rect2 rect) { if (!isStroked && !isFilled) return; var r = new Rect(rect.X, rect.Y, rect.Width, rect.Height); if (isFilled) { dc.FillRectangle(brush, r); } if (isStroked) { dc.DrawRectangle(pen, r); } }
public virtual void RenderWire(Wire wire, IDrawingContext drawingContext) { var size = wire.Layout.Orientation == Orientation.Horizontal ? new Point(wire.Layout.Size, 0.0) : new Point(0.0, wire.Layout.Size); drawingContext.DrawLine(wire.Layout.Location, Point.Add(wire.Layout.Location, size), 2.0); }
protected static void RenderLine([NotNull] IDrawingContext drawingContext, ref WindowsRect clippingRect, IList <WindowsPoint> points, Color color) { // FIXME: calculate (optimistic) clipped line beforehand so that points that are eventually outside of the clipped area are not given to the rendering context. // FIXME: note that in the end the curve is still clipped by the canvas Clip property. drawingContext.DrawPolyline(points, color); }
public HorizontalAndVerticalAxisRenderer(CurveEditorViewModel editor, IDrawingContext drawingContext) { Editor = editor; DrawingContext = drawingContext; }
protected virtual void OnRender(IDrawingContext drawingContext) { }
/// <summary> /// Init. /// </summary> public GraphicsAdapter() : base(PerspexAdapter.Instance, RRect.Empty) { _g = null; _releaseGraphics = false; }
public override void OnRender(IDrawingContext drawingContext, Measurement measurement) { }
public override void Draw(IDrawingContext context) { context.Graphics.DrawCurve(context.Pen, this.Points.ToArray()); }
protected override void OnRender(IDrawingContext drawingContext, Measurement measurement) { Render(drawingContext); }
public virtual void RenderConnection(Point connection, IDrawingContext drawingContext) { drawingContext.DrawEllipse(connection, 2d, 2d, 2d, true); }
/// <summary> /// Actually renders the points of the curve. /// </summary> /// <param name="drawingContext"></param> /// <param name="clippingRect"></param> /// <param name="isCurrentCurve"></param> protected virtual void RenderPoints(IDrawingContext drawingContext, ref WindowsRect clippingRect, bool isCurrentCurve) { // Default implementation does nothing }
public DrawingManager(IDrawingContext drawingContext, IRenderer renderer) { this.drawingContext = drawingContext; this.renderer = renderer; }
public override void Render(IDrawingContext drawingContext) { base.Render(drawingContext); }
/// <summary> /// /// </summary> /// <param name="dc"></param> /// <param name="pen"></param> /// <param name="isStroked"></param> /// <param name="p0"></param> /// <param name="p1"></param> private static void DrawLineInternal( IDrawingContext dc, Pen pen, bool isStroked, ref Point p0, ref Point p1) { if (isStroked) { dc.DrawLine(pen, p0, p1); } }
public BufferedDrawingContext(IDrawingContext underlying) { this.underlying = underlying; }
/// <summary> /// /// </summary> /// <param name="dc"></param> /// <param name="container"></param> private void DrawBackgroundInternal(IDrawingContext dc, Container container) { Brush brush = ToSolidBrush(container.Background); var rect = new Rect(0, 0, container.Width, container.Height); dc.FillRectangle(brush, rect); // TODO: brush.Dispose(); }
public void Render(LayoutInformation layout, ILayoutContext layoutContext, IDrawingContext drawingContext) { Point renderLocation = Location.Resolve(layout, layoutContext.Options); TextAlignment tempAlignment = Alignment; var flipType = layout.GetFlipType(); if ((flipType & FlipType.Horizontal) == FlipType.Horizontal) { switch (Alignment) { case TextAlignment.BottomLeft: tempAlignment = TextAlignment.BottomRight; break; case TextAlignment.BottomRight: tempAlignment = TextAlignment.BottomLeft; break; case TextAlignment.CentreLeft: tempAlignment = TextAlignment.CentreRight; break; case TextAlignment.CentreRight: tempAlignment = TextAlignment.CentreLeft; break; case TextAlignment.TopLeft: tempAlignment = TextAlignment.TopRight; break; case TextAlignment.TopRight: tempAlignment = TextAlignment.TopLeft; break; } } if ((flipType & FlipType.Vertical) == FlipType.Vertical) { switch (Alignment) { case TextAlignment.BottomCentre: tempAlignment = TextAlignment.TopCentre; break; case TextAlignment.BottomLeft: tempAlignment = TextAlignment.TopLeft; break; case TextAlignment.BottomRight: tempAlignment = TextAlignment.TopRight; break; case TextAlignment.TopCentre: tempAlignment = TextAlignment.BottomCentre; break; case TextAlignment.TopLeft: tempAlignment = TextAlignment.BottomLeft; break; case TextAlignment.TopRight: tempAlignment = TextAlignment.BottomRight; break; } } List <TextRun> renderTextRuns = new List <TextRun>(TextRuns.Count); // Build runs foreach (TextRun run in TextRuns) { // Resolve value string renderValue; if (run.Text.StartsWith("$")) { renderValue = layoutContext.GetFormattedVariable(run.Text); } else { renderValue = run.Text; } System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\\[uU]([0-9A-F]{4})"); renderValue = regex.Replace(renderValue, match => ((char)int.Parse(match.Value.Substring(2), System.Globalization.NumberStyles.HexNumber)).ToString()); renderTextRuns.Add(new TextRun(renderValue, run.Formatting)); } if (layoutContext.Options.Absolute) { drawingContext.DrawText(Point.Add(renderLocation, layout.Location), tempAlignment, renderTextRuns); } else { drawingContext.DrawText(renderLocation, tempAlignment, renderTextRuns); } }
public void Draw(IDrawingContext context) { context.DrawLine(_startPoint, _endPoint); }
public override void Draw(IDrawingContext drawingContext) => drawingContext.DrawEllipse(this);
public abstract void Draw(IDrawingContext context);
public override void Draw(IDrawingContext context) { context.Graphics.DrawLines(context.Pen, this.Points.ToArray()); }
public TranslationDrawingContext(Vector offset, IDrawingContext underlying) { this.offset = offset; this.underlying = underlying; }
/// <summary> /// Renders the <see cref="TextBlock"/> to a drawing context. /// </summary> /// <param name="context">The drawing context.</param> public override void Render(IDrawingContext context) { Brush background = Background; if (background != null) { context.FillRectange(background, new Rect(Bounds.Size)); } FormattedText.Constraint = Bounds.Size; context.DrawText(Foreground, new Point(), FormattedText); }
/// <summary> /// Renders the visual to a <see cref="IDrawingContext"/>. /// </summary> /// <param name="context">The drawing context.</param> public virtual void Render(IDrawingContext context) { Contract.Requires <ArgumentNullException>(context != null); }
public override void Render(IDrawingContext context) { }
public override void Render(IDrawingContext context) { var geometry = this.RenderedGeometry; if (geometry != null) { var pen = new Pen(this.Stroke, this.StrokeThickness, this.StrokeDashArray); context.DrawGeometry(this.Fill, pen, geometry); } }
protected sealed override void RenderPoints([NotNull] IDrawingContext drawingContext, ref Rect clippingRect, bool isCurrentCurve) { var controlPointCount = controlPoints.Count; if (controlPointCount == 0) { drawingContext.DrawTexts(new[] { clippingRect.GetCenterLocation() }, Color.LightGray, new[] { $"{Resources.Strings.KeyGestures.GestureAddPoint} to add a keyframe" }, XAxis.FontFamily, XAxis.FontSize * 2, FontWeights.Bold, HorizontalAlignment.Center, VerticalAlignment.Center); return; } #if DEBUG_POINTS_ORDER var sortedPoints = new List <KeyFrameControlPointViewModel <TValue> >(controlPoints.Count); var firstPoint = controlPoints[0]; while (firstPoint != null) { sortedPoints.Add(firstPoint); firstPoint = firstPoint.Next as KeyFrameControlPointViewModel <TValue>; } #else // control points can temporarily be unordered during the dragging of one or more points var sortedPoints = controlPoints.OrderBy(p => p.ActualPoint.X).ToList(); #endif // sample the curve var drawPoints = new List <WindowsPoint>(); for (var i = 0; i < controlPointCount - 1; ++i) { var samples = SampleControlPoints(sortedPoints[i], sortedPoints[i + 1]); drawPoints.AddRange(samples.Select(TransformPoint)); } // last point drawPoints.Add(sortedPoints[controlPoints.Count - 1].ActualPoint); // render the curve RenderLine(drawingContext, ref clippingRect, drawPoints, Color); if (!isCurrentCurve) { return; } // Retrieve actual points (and selected actual points) var actualPoints = new List <WindowsPoint>(); var selectedActualPoints = new List <WindowsPoint>(); foreach (var controlPoint in controlPoints) { var actualPoint = controlPoint.ActualPoint; actualPoints.Add(actualPoint); if (controlPoint.IsSelected) { selectedActualPoints.Add(actualPoint); } } // Render the control points var radius = ControlPointRadius; drawingContext.DrawCircles(actualPoints, radius, ControlPointColor, ControlPointColor); // Render the selection circles over the selected control points radius *= 2; drawingContext.DrawCircles(selectedActualPoints, radius, Color.Transparent, Color.WhiteSmoke); // Render the tangents // TODO: also render tangents }
/// <summary> /// Renders the visual to a <see cref="IDrawingContext"/>. /// </summary> /// <param name="context">The drawing context.</param> public override void Render(IDrawingContext context) { Brush background = Background; if (background != null) { var renderSize = Bounds.Size; context.FillRectange(background, new Rect(renderSize)); } base.Render(context); }
public OffsetDrawingContext(IDrawingContext underlying, Point offset) { this.offset = offset; Underlying = underlying; }
public BufferedDrawingContext(IDrawingContext underlying) { textMeasurer = new TextMeasurer(); this.underlying = underlying; }
public override void Render(IDrawingContext drawingContext) { drawingContext.FillRectangle(Background, VisualBounds); base.Render(drawingContext); }