Beispiel #1
0
        void DrawSample(Graphics graphics)
        {
            using (graphics.Generator.Context)
            {
                graphics.FillRectangle(Brushes.Green(), 0, 0, 200, 200);
                if (UseGraphicsPathClip)
                {
                    var path = GraphicsPath.GetRoundRect(new RectangleF(10, 10, 180, 180), 20);
                    graphics.SetClip(path);
                }
                else
                {
                    graphics.SetClip(new RectangleF(10, 10, 180, 180));
                }

                if (UseClearColor)
                {
                    graphics.Clear(new SolidBrush(new Color(Colors.Red, 0.5f)));
                }
                else
                {
                    graphics.Clear();
                }
                graphics.FillEllipse(Brushes.Blue(), 25, 25, 150, 150);
            }
        }
Beispiel #2
0
        void DrawSample(Graphics graphics)
        {
            using (graphics.Platform.Context)
            {
                graphics.FillRectangle(Brushes.Green, 0, 0, 200, 200);
                switch (clipMode)
                {
                case ClearClipMode.GraphicsPath:
                    var path = GraphicsPath.GetRoundRect(new RectangleF(10, 10, 180, 180), 20);
                    graphics.SetClip(path);
                    break;

                case ClearClipMode.Rectangle:
                    graphics.SetClip(new RectangleF(10, 10, 180, 180));
                    break;
                }

                if (UseClearColor)
                {
                    graphics.Clear(new SolidBrush(new Color(Colors.Red, 0.5f)));
                }
                else
                {
                    graphics.Clear();
                }
                var rnd = new Random();
                graphics.FillEllipse(Brushes.Blue, rnd.Next(50), rnd.Next(50), 150, 150);
            }
        }
Beispiel #3
0
        void Draw(Graphics g)
        {
            if (brush == null)
            {
                return;
            }


            var rect = new RectangleF(10, 10, 200, 100);

            if (Mode == DrawMode.Fill)
            {
                var pen = new Pen(Colors.Black);
                /**/
                g.FillEllipse(brush, rect);
                g.DrawEllipse(pen, rect);
                /**/
                rect = new RectangleF(10, 120, 200, 80);
                g.FillRectangle(brush, rect);
                g.DrawRectangle(pen, rect);
                /**/
                rect = new RectangleF(10, 210, 200, 80);
                g.FillPie(brush, rect, 100, 240);
                g.DrawArc(pen, rect, 100, 240);
                /**/
                var points = new[] { new PointF(300, 10), new PointF(350, 30), new PointF(400, 90), new PointF(320, 100) };
                g.FillPolygon(brush, points);
                g.DrawPolygon(pen, points);
                /**/
                var path = GraphicsPath.GetRoundRect(new Rectangle(300, 120, 50, 50), 8);
                g.FillPath(brush, path);
                g.DrawPath(pen, path);
                /**/
                pen.Dispose();
            }
            else
            {
                var pen = new Pen(brush, 10);
                /**/
                g.DrawEllipse(pen, rect);
                /**/
                rect = new RectangleF(10, 120, 200, 80);
                g.DrawRectangle(pen, rect);
                /**/
                rect = new RectangleF(10, 210, 200, 80);
                g.DrawArc(pen, rect, 100, 240);
                /**/
                var points = new[] { new PointF(300, 10), new PointF(350, 30), new PointF(400, 90), new PointF(320, 100) };
                g.DrawPolygon(pen, points);
                /**/
                /**/
                var path = GraphicsPath.GetRoundRect(new Rectangle(300, 120, 50, 50), 8);
                g.DrawPath(pen, path);
                pen.Dispose();
            }
        }
Beispiel #4
0
        public ClipTransformSection()
        {
            Padding = new Padding(10);
            var drawable = new Drawable();

            bool showInvalid         = false;
            var  showInvalidCheckBox = new CheckBox {
                Text = "Show Invalid Regions"
            };

            showInvalidCheckBox.CheckedBinding.Bind(() => showInvalid, v => { showInvalid = v ?? false; drawable.Invalidate(); });

            drawable.Paint += (sender, e) =>
            {
                var g = e.Graphics;

                var rect = new RectangleF(drawable.ClientSize);
                Func <RectangleF> boundsRect = () => g.CurrentTransform.Inverse().TransformRectangle(rect);

                g.SaveTransform();

                g.SetClip(new RectangleF(0, 0, 50, 50));
                g.FillRectangle(Colors.Red, rect);

                g.TranslateTransform(50, 0);
                if (!showInvalid)
                {
                    g.FillRectangle(Colors.Green, boundsRect());
                }

                g.TranslateTransform(0, 50);
                g.SetClip(new RectangleF(0, 0, 50, 50));
                g.FillRectangle(Colors.Red, boundsRect());

                g.ScaleTransform(2, 2);
                g.TranslateTransform(25, 25);
                if (!showInvalid)
                {
                    g.FillRectangle(Colors.Green, boundsRect());
                }

                g.SetClip(GraphicsPath.GetRoundRect(new RectangleF(0, 0, 25, 25), 4));
                g.FillRectangle(Colors.Red, boundsRect());

                g.ScaleTransform(2, 2);
                g.TranslateTransform(25, 25);
                if (!showInvalid)
                {
                    g.FillRectangle(Colors.Green, boundsRect());
                }

                g.SetClip(new RectangleF(-25 / 2f, -25 / 2f, 25 / 2f, 25 / 2f));
                g.FillRectangle(Colors.Red, boundsRect());

                g.RestoreTransform();

                if (!showInvalid)
                {
                    g.FillRectangle(Colors.Green, boundsRect());
                }
            };

            var options = new StackLayout
            {
                Orientation = Orientation.Horizontal,
                VerticalContentAlignment = VerticalAlignment.Center,
                Spacing = 5,
                Items   = { showInvalidCheckBox }
            };

            Content = new StackLayout {
                Spacing = 5,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Items = { options, new StackLayoutItem(drawable, expand: true) }
            };
        }