Ejemplo n.º 1
0
        public void test(IDrawingContext context)
        {
            Debug.Assert(context.Width == 80);
            Debug.Assert(context.Height == 40);

            context.roundedRect(0, 0, context.Width, context.Height, 8);
        }
Ejemplo n.º 2
0
        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);
            }*/
        }
Ejemplo n.º 3
0
        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();
                });
        }
Ejemplo n.º 4
0
 protected override void OnRender(IDrawingContext drawingContext)
 {
     if (this.Background != null)
     {
         drawingContext.DrawRectangle(new Rect(0, 0, this.ActualWidth, this.ActualHeight), this.Background);
     }
 }
Ejemplo n.º 5
0
 public virtual void Draw(IDrawingContext context)
 {
     //�������
     foreach (PolygonDrawing polygon in polygons)
     {
         polygon.Draw(context);
     }
 }
Ejemplo n.º 6
0
 public virtual void Draw(IDrawingContext context)
 {
     //���߶�
     foreach (IDrawing line in lines)
     {
         line.Draw(context);
     }
 }
Ejemplo n.º 7
0
        /// <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;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        public override void Render(IDrawingContext context)
        {
            base.Render(context);

            if (_state == null)
            {
                InitializeDrawable();
                InitializeLayers();
                ResizeDrawable();
            }

            Draw(context);
        }
Ejemplo n.º 9
0
        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));
                }
            }
        }
Ejemplo n.º 10
0
        /// <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);
            }
        }
Ejemplo n.º 11
0
        /// <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);
            }
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
0
        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));
                }
            }
        }
Ejemplo n.º 15
0
        /// <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);
                    }
                }
            }
        }
Ejemplo n.º 16
0
 public override void Draw(IDrawingContext context)
 {
     context.Graphics.DrawLine(context.Pen, this.Points[0], this.Points[1]);
 }
Ejemplo n.º 17
0
 /// <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);
 }
Ejemplo n.º 18
0
        /// <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);
            }
        }
Ejemplo n.º 19
0
        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));
        }
Ejemplo n.º 20
0
        /// <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();
        }
Ejemplo n.º 21
0
        /// <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);
            }
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
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);
 }
Ejemplo n.º 24
0
 public HorizontalAndVerticalAxisRenderer(CurveEditorViewModel editor, IDrawingContext drawingContext)
 {
     Editor         = editor;
     DrawingContext = drawingContext;
 }
Ejemplo n.º 25
0
 protected virtual void OnRender(IDrawingContext drawingContext)
 {
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Init.
 /// </summary>
 public GraphicsAdapter()
     : base(PerspexAdapter.Instance, RRect.Empty)
 {
     _g = null;
     _releaseGraphics = false;
 }
Ejemplo n.º 27
0
 public override void OnRender(IDrawingContext drawingContext, Measurement measurement)
 {
 }
Ejemplo n.º 28
0
 public override void Draw(IDrawingContext context)
 {
     context.Graphics.DrawCurve(context.Pen, this.Points.ToArray());
 }
Ejemplo n.º 29
0
 protected override void OnRender(IDrawingContext drawingContext, Measurement measurement)
 {
     Render(drawingContext);
 }
Ejemplo n.º 30
0
 public virtual void RenderConnection(Point connection, IDrawingContext drawingContext)
 {
     drawingContext.DrawEllipse(connection, 2d, 2d, 2d, true);
 }
Ejemplo n.º 31
0
 /// <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
 }
Ejemplo n.º 32
0
 public DrawingManager(IDrawingContext drawingContext, IRenderer renderer)
 {
     this.drawingContext = drawingContext;
     this.renderer       = renderer;
 }
Ejemplo n.º 33
0
 public override void Draw(IDrawingContext context)
 {
     context.Graphics.DrawLine(context.Pen, this.Points[0], this.Points[1]);
 }
Ejemplo n.º 34
0
 public override void Render(IDrawingContext drawingContext)
 {
     base.Render(drawingContext);
 }
Ejemplo n.º 35
0
 /// <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);
     }
 }
Ejemplo n.º 36
0
 public BufferedDrawingContext(IDrawingContext underlying)
 {
     this.underlying = underlying;
 }
Ejemplo n.º 37
0
 /// <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();
 }
Ejemplo n.º 38
0
        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);
            }
        }
Ejemplo n.º 39
0
 public void Draw(IDrawingContext context)
 {
     context.DrawLine(_startPoint, _endPoint);
 }
Ejemplo n.º 40
0
 public override void Draw(IDrawingContext drawingContext) => drawingContext.DrawEllipse(this);
Ejemplo n.º 41
0
 public DrawingManager(IDrawingContext drawingContext, IRenderer renderer)
 {
     this.drawingContext = drawingContext;
     this.renderer = renderer;
 }
Ejemplo n.º 42
0
 public abstract void Draw(IDrawingContext context);
Ejemplo n.º 43
0
 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;
 }
Ejemplo n.º 45
0
        /// <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);
        }
Ejemplo n.º 46
0
 /// <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);
 }
Ejemplo n.º 47
0
 public override void Render(IDrawingContext context)
 {
 }
Ejemplo n.º 48
0
        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);
            }
        }
Ejemplo n.º 49
0
 /// <summary>
 /// Init.
 /// </summary>
 public GraphicsAdapter()
     : base(PerspexAdapter.Instance, RRect.Empty)
 {
     _g = null;
     _releaseGraphics = false;
 }
Ejemplo n.º 50
0
        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
        }
Ejemplo n.º 51
0
        /// <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);
        }
Ejemplo n.º 52
0
 public OffsetDrawingContext(IDrawingContext underlying, Point offset)
 {
     this.offset = offset;
     Underlying  = underlying;
 }
Ejemplo n.º 53
0
 public BufferedDrawingContext(IDrawingContext underlying)
 {
     textMeasurer    = new TextMeasurer();
     this.underlying = underlying;
 }
Ejemplo n.º 54
0
 public override void Render(IDrawingContext drawingContext)
 {
     drawingContext.FillRectangle(Background, VisualBounds);
     base.Render(drawingContext);
 }