private void ConstructCanvas()
        {
            this.CanvasControl.SizeChanged += (s, e) =>
            {
                if (e.NewSize == e.PreviousSize)
                {
                    return;
                }
                this.Size.SIzeChange((float)e.NewSize.Width, (float)e.NewSize.Height);
            };
            this.CanvasControl.CreateResources += (sender, args) =>
            {
                float width  = (float)sender.ActualWidth;
                float height = (float)sender.ActualHeight;
                this.GrayAndWhiteBackground = new CanvasRenderTarget(sender, width, height);

                using (CanvasDrawingSession drawingSession = this.GrayAndWhiteBackground.CreateDrawingSession())
                {
                    CanvasBitmap bitmap     = GreyWhiteMeshHelpher.GetGreyWhiteMesh(sender);
                    ICanvasImage extendMesh = GreyWhiteMeshHelpher.GetBorderExtendMesh(height / 4, bitmap);
                    drawingSession.DrawImage(extendMesh);
                }
            };

            this.CanvasControl.Draw += (sender, args) =>
            {
                if (base.IsEnabled == false)
                {
                    return;
                }
                if (this.array is null)
                {
                    return;
                }

                // Background
                args.DrawingSession.DrawImage(this.GrayAndWhiteBackground);

                // LinearGradient
                this.Size.DrawLinearGradient(args.DrawingSession, this.CanvasControl, this.array);

                // Lines
                this.Size.DrawLines(args.DrawingSession);

                // Nodes
                this.Size.DrawNodes(args.DrawingSession, this.Manager);
            };
        }
예제 #2
0
        /// <summary>
        /// Initializes a LinearGradientBrush.
        /// </summary>
        /// <param name="transformer"> The transformer. </param>
        /// <returns> The product <see cref="IBrush"/>. </returns>
        public static IBrush LinearGradientBrush(Transformer transformer)
        {
            Vector2 center = transformer.Center;
            Vector2 yPoint = transformer.CenterBottom;

            return(new BrushBase
            {
                Type = BrushType.LinearGradient,

                Stops = GreyWhiteMeshHelpher.GetGradientStopArray(),
                Extend = CanvasEdgeBehavior.Clamp,

                Center = center,
                YPoint = yPoint,
            });
        }
예제 #3
0
        /// <summary>
        /// Initializes a LinearGradientBrush.
        /// </summary>
        /// <param name="startPoint"> The start point. </param>
        /// <param name="endPoint"> The end point. </param>
        /// <param name="color"> The color. </param>
        /// <returns> The product <see cref="IBrush"/>. </returns>
        public static IBrush LinearGradientBrush(Vector2 startPoint, Vector2 endPoint, Color color)
        {
            Vector2 center = startPoint;
            Vector2 yPoint = endPoint;

            return(new BrushBase
            {
                Type = BrushType.LinearGradient,

                Stops = GreyWhiteMeshHelpher.GetGradientStopArray(color),
                Extend = CanvasEdgeBehavior.Clamp,

                Center = center,
                YPoint = yPoint,
            });
        }
        private void ChangingStopsCore(Color color)
        {
            switch (this.Type)
            {
            case BrushType.Color:
                this.Stops = GreyWhiteMeshHelpher.GetGradientStopArray(this.Color);
                break;

            case BrushType.LinearGradient:
            case BrushType.RadialGradient:
            case BrushType.EllipticalGradient:
                break;

            default:
                this.Stops = GreyWhiteMeshHelpher.GetGradientStopArray(color);
                break;
            }
        }