Beispiel #1
0
        public void Render(LayoutInformation layout, ILayoutContext layoutContext, IDrawingContext drawingContext)
        {
            Point location = Location.Resolve(layout, layoutContext.Options);
            var   drawRect = new Rect(location, new Size(Width, Height));

            switch (layout.GetFlipType())
            {
            case FlipType.Horizontal:
                drawRect = new Rect(drawRect.X - Width, drawRect.Y, Width, Height);
                break;

            case FlipType.Vertical:
                drawRect = new Rect(drawRect.X, drawRect.Y - Height, Width, Height);
                break;

            case FlipType.Both:
                drawRect = new Rect(drawRect.X - Width, drawRect.Y - Height, Width, Height);
                break;
            }

            if (layoutContext.Options.Absolute)
            {
                drawingContext.DrawRectangle(Point.Add(drawRect.TopLeft, layout.Location), drawRect.Size, StrokeThickness, Fill);
            }
            else
            {
                drawingContext.DrawRectangle(drawRect.TopLeft, drawRect.Size, StrokeThickness, Fill);
            }
        }
Beispiel #2
0
 protected override void OnRender(IDrawingContext drawingContext)
 {
     if (this.Background != null)
     {
         drawingContext.DrawRectangle(new Rect(0, 0, this.ActualWidth, this.ActualHeight), this.Background);
     }
 }
Beispiel #3
0
 protected override void OnRender(IDrawingContext drawingContext)
 {
     if (this.Background != null)
     {
         drawingContext.DrawRectangle(new Rect(0, 0, this.ActualWidth, this.ActualHeight), this.Background);
     }
 }
 /// <summary>
 /// Renders the border around the curve area.
 /// </summary>
 /// <param name="drawingContext">The render.</param>
 /// <remarks>The border will only by rendered if there are axes.</remarks>
 private void RenderBox(IDrawingContext drawingContext)
 {
     if (SelectedCurve != null)
     {
         drawingContext.DrawRectangle(CurveArea, Color.Transparent, Color.Thistle);
     }
 }
Beispiel #5
0
        protected override void OnRender(IDrawingContext drawingContext)
        {
            if (this.BorderThickness != new Thickness() && this.BorderBrush != null)
            {
                this.GenerateBorders();

                foreach (Rect border in this.borders)
                {
                    drawingContext.DrawRectangle(border, this.BorderBrush);
                }
            }

            if (this.Background != null)
            {
                drawingContext.DrawRectangle(
                    new Rect(0, 0, this.ActualWidth, this.ActualHeight).Deflate(this.BorderThickness), this.Background);
            }
        }
 protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView)
 {
     if ((this.brushSize > 0.0) && (this.brushAlpha > 0))
     {
         double     opacity         = ((double)this.brushAlpha) / 255.0;
         Brush      brush           = SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.White, opacity);
         Brush      brush2          = SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.Black, opacity);
         double     canvasHairWidth = canvasView.CanvasHairWidth;
         RectDouble brushRect       = this.BrushRect;
         brushRect.Inflate(-canvasHairWidth, -canvasHairWidth);
         if (brushRect.HasPositiveArea)
         {
             RectFloat num4 = (RectFloat)brushRect;
             using (dc.UseAntialiasMode(AntialiasMode.Aliased))
             {
                 dc.DrawRectangle(brushRect, brush2, canvasHairWidth * 3.0);
                 dc.DrawRectangle(brushRect, brush, canvasHairWidth);
             }
         }
     }
     base.OnRender(dc, clipRect, canvasView);
 }
Beispiel #7
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));
        }
        protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView)
        {
            RectDouble cursorBounds      = this.CursorBounds;
            RectDouble cursorOutlineRect = this.GetCursorOutlineRect(canvasView, cursorBounds);
            double     opacity           = this.opacityAnimation.Value;

            dc.FillRectangle(cursorBounds, SolidColorBrushCache.Get((ColorRgba128Float)Colors.Black, opacity));
            double canvasHairWidth = canvasView.CanvasHairWidth;
            double thickness       = 1.0 * canvasHairWidth;

            dc.DrawRectangle(cursorOutlineRect, SolidColorBrushCache.Get((ColorRgba128Float)Colors.White, opacity), thickness);
            base.OnRender(dc, clipRect, canvasView);
        }
Beispiel #9
0
        public void Render(LayoutInformation layout, ILayoutContext layoutContext, IDrawingContext drawingContext)
        {
            Point location = Location.Resolve(layout, layoutContext.Options);
            var   drawRect = new Rect(location, new Size(Width, Height));

            if (layout.IsFlipped && layout.Orientation == Orientation.Horizontal)
            {
                drawRect = new Rect(drawRect.X - Width, drawRect.Y, Width, Height);
            }
            else if (layout.IsFlipped && layout.Orientation == Orientation.Vertical)
            {
                drawRect = new Rect(drawRect.X, drawRect.Y - Height, Width, Height);
            }

            if (layoutContext.Options.Absolute)
            {
                drawingContext.DrawRectangle(Point.Add(drawRect.TopLeft, layout.Location), drawRect.Size, StrokeThickness, Fill);
            }
            else
            {
                drawingContext.DrawRectangle(drawRect.TopLeft, drawRect.Size, StrokeThickness, Fill);
            }
        }
Beispiel #10
0
 protected override void OnRender(IDrawingContext dc, RectFloat clipRect)
 {
     using (dc.UseAntialiasMode(AntialiasMode.Aliased))
     {
         SizeInt32 num;
         Size      clientSize = base.ClientSize;
         if ((clientSize.Width < 2) || (clientSize.Height < 2))
         {
             num = new SizeInt32(3, 3);
         }
         else
         {
             num = new SizeInt32(clientSize.Width, clientSize.Height);
         }
         dc.Clear(new ColorRgba128Float?((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.Window));
         int    num2 = (int)(this.tolerance * 100f);
         string text = string.Format(percentageFormat, num2);
         if (this.textLayout == null)
         {
             this.textLayout = UIText.CreateLayout(dc, text, this.Font, null, HotkeyRenderMode.Ignore, 65535.0, 65535.0);
             this.textLayout.ParagraphAlignment = ParagraphAlignment.Center;
             this.textLayout.FontSize          *= 0.9;
         }
         else
         {
             this.textLayout.Text = text;
         }
         this.textLayout.MaxWidth  = num.Width - 6;
         this.textLayout.MaxHeight = num.Height - 6;
         PointDouble origin = new PointDouble(3.0, 3.0);
         dc.DrawTextLayout(origin, this.textLayout, SolidColorBrushCache.Get(base.Enabled ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.WindowText) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.GrayText)), DrawTextOptions.None);
         RectDouble rect = new RectDouble(0.0, 0.0, (double)num.Width, (double)num.Height);
         RectDouble num5 = RectDouble.Inflate(rect, -0.5, -0.5);
         dc.DrawRectangle(num5, SolidColorBrushCache.Get(base.Enabled ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.ControlDark) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.ControlDark)), 1.0);
         RectDouble num6 = new RectDouble(1.0, 1.0, (num.Width - 2.0) * this.tolerance, (double)(num.Height - 2));
         PaintDotNet.UI.Media.Brush brush = SolidColorBrushCache.Get(base.Enabled ? (this.hovering ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.HotTrack) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.Highlight)) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.Control));
         dc.FillRectangle(num6, brush);
         using (dc.UseAxisAlignedClip((RectFloat)num6, AntialiasMode.PerPrimitive))
         {
             dc.DrawTextLayout(origin, this.textLayout, SolidColorBrushCache.Get(base.Enabled ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.HighlightText) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.GrayText)), DrawTextOptions.None);
         }
     }
     base.OnRender(dc, clipRect);
 }
Beispiel #11
0
 public void DrawRectangle(Point start, Size size, double thickness, bool fill = false)
 {
     Expand(new Rect(start, size));
     underlying?.DrawRectangle(start, size, thickness, fill);
 }
 public void DrawRectangle(Point start, Size size, double thickness, bool fill = false)
 {
     underlying.DrawRectangle(start.Add(offset), size, thickness, fill);
 }
Beispiel #13
0
        protected override void OnRender(IDrawingContext drawingContext)
        {
            if (this.BorderThickness != new Thickness() && this.BorderBrush != null)
            {
                this.GenerateBorders();

                foreach (Rect border in this.borders)
                {
                    drawingContext.DrawRectangle(border, this.BorderBrush);
                }
            }

            if (this.Background != null)
            {
                drawingContext.DrawRectangle(
                    new Rect(0, 0, this.ActualWidth, this.ActualHeight).Deflate(this.BorderThickness), this.Background);
            }
        }
Beispiel #14
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));
        }
Beispiel #15
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);
            }
        }
 public void Draw(IDrawingContext context)
 {
     context.DrawRectangle(_rect);
 }
Beispiel #17
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.FillRectangle(background, rect, cornerRadius);
            }

            if (borderBrush != null && borderThickness > 0)
            {
                context.DrawRectangle(new Pen(borderBrush, borderThickness), rect, cornerRadius);
            }
        }
Beispiel #18
0
        public static bool RenderFromXml(Stream xmlStream, IDrawingContext drawingContext, out Size imageSize)
        {
            var doc = XDocument.Load(xmlStream);

            var previewNode = doc.Elements().First(x => x.Name == PreviewNamespace + "preview");

            imageSize = new Size(double.Parse(previewNode.Attribute("width").Value),
                                 double.Parse(previewNode.Attribute("height").Value));

            var renderElements = previewNode.Elements();

            foreach (var renderElement in renderElements)
            {
                if (renderElement.Name == "line")
                {
                    Point  start     = Point.Parse(renderElement.Attribute("start").Value);
                    Point  end       = Point.Parse(renderElement.Attribute("end").Value);
                    double thickness = double.Parse(renderElement.Attribute("thickness").Value);
                    drawingContext.DrawLine(start, end, thickness);
                }
                else if (renderElement.Name == "rect")
                {
                    Point  start     = Point.Parse(renderElement.Attribute("start").Value);
                    Size   size      = Size.Parse(renderElement.Attribute("size").Value);
                    double thickness = double.Parse(renderElement.Attribute("thickness").Value);
                    bool   fill      = bool.Parse(renderElement.Attribute("fill").Value);
                    drawingContext.DrawRectangle(start, size, thickness, fill);
                }
                else if (renderElement.Name == "ellipse")
                {
                    Point  centre    = Point.Parse(renderElement.Attribute("centre").Value);
                    double radiusx   = double.Parse(renderElement.Attribute("rx").Value);
                    double radiusy   = double.Parse(renderElement.Attribute("ry").Value);
                    double thickness = double.Parse(renderElement.Attribute("thickness").Value);
                    bool   fill      = bool.Parse(renderElement.Attribute("fill").Value);
                    drawingContext.DrawEllipse(centre, radiusx, radiusy, thickness, fill);
                }
                else if (renderElement.Name == "path")
                {
                    Point  start     = Point.Parse(renderElement.Attribute("start").Value);
                    double thickness = double.Parse(renderElement.Attribute("thickness").Value);
                    bool   fill      = bool.Parse(renderElement.Attribute("fill").Value);
                    string data      = renderElement.Value;
                    List <IPathCommand> pathCommands = new List <IPathCommand>();
                    using (MemoryStream dataStream = new MemoryStream(Convert.FromBase64String(data)))
                    {
                        BinaryReader reader = new BinaryReader(dataStream);

                        int numCommands = reader.ReadInt32();

                        for (int l = 0; l < numCommands; l++)
                        {
                            CommandType  pType      = (CommandType)reader.ReadInt32();
                            IPathCommand theCommand = null;
                            switch (pType)
                            {
                            case CommandType.MoveTo:
                                theCommand = new MoveTo();
                                break;

                            case CommandType.LineTo:
                                theCommand = new LineTo();
                                break;

                            case CommandType.CurveTo:
                                theCommand = new CurveTo();
                                break;

                            case CommandType.EllipticalArcTo:
                                theCommand = new EllipticalArcTo();
                                break;

                            case CommandType.QuadraticBeizerCurveTo:
                                theCommand = new QuadraticBeizerCurveTo();
                                break;

                            case CommandType.SmoothCurveTo:
                                theCommand = new SmoothCurveTo();
                                break;

                            case CommandType.SmoothQuadraticBeizerCurveTo:
                                theCommand = new SmoothQuadraticBeizerCurveTo();
                                break;

                            default:
                                theCommand = new ClosePath();
                                break;
                            }
                            theCommand.Read(reader);
                            pathCommands.Add(theCommand);
                        }
                    }
                    drawingContext.DrawPath(start, pathCommands, thickness, fill);
                }
                else if (renderElement.Name == "text")
                {
                    Point          anchor    = Point.Parse(renderElement.Attribute("anchor").Value);
                    TextAlignment  alignment = (TextAlignment)Enum.Parse(typeof(TextAlignment), renderElement.Attribute("alignment").Value);
                    List <TextRun> runs      = new List <TextRun>();
                    foreach (var runNode in renderElement.Elements())
                    {
                        if (runNode.Name != "run")
                        {
                            continue;
                        }

                        double size = double.Parse(runNode.Attribute("size").Value);
                        TextRunFormattingType formattingType = (TextRunFormattingType)Enum.Parse(typeof(TextRunFormattingType), runNode.Attribute("formatting").Value);
                        string text = runNode.Value;
                        runs.Add(new TextRun(text, new TextRunFormatting(formattingType, size)));
                    }
                    drawingContext.DrawText(anchor, alignment, runs);
                }
            }

            return(true);
        }