Пример #1
0
 public override IEnumerable <Object> RenderPaths(IEnumerable <Path2D> paths, StylePen line,
                                                  StylePen highlightLine, StylePen selectLine,
                                                  StylePen outline, StylePen highlightOutline,
                                                  StylePen selectOutline, RenderState renderState)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Пример #2
0
 public override IEnumerable <DependencyObject> RenderPaths(IEnumerable <Path2D> paths, StyleBrush fill,
                                                            StyleBrush highlightFill, StyleBrush selectFill,
                                                            StylePen outline, StylePen highlightOutline,
                                                            StylePen selectOutline, RenderState renderState)
 {
     throw new NotImplementedException();
 }
            public override IEnumerable <RenderObject> RenderPaths(IEnumerable <Path2D> paths,
                                                                   StylePen outline, StylePen highlightOutline,
                                                                   StylePen selectOutline, RenderState renderState)
            {
                foreach (Path2D path in paths)
                {
                    RenderObject ro = new RenderObject();

                    ro.RenderedPaths = new Double[path.Figures.Count][];

                    for (Int32 figureIndex = 0; figureIndex < path.Figures.Count; figureIndex++)
                    {
                        ro.RenderedPaths[figureIndex] = new Double[path.Figures[figureIndex].Points.Count * 2];

                        for (Int32 pointIndex = 0; pointIndex < path.Figures[figureIndex].Points.Count; pointIndex++)
                        {
                            Point2D point = path.Figures[figureIndex].Points[pointIndex];
                            ro.RenderedPaths[figureIndex][pointIndex * 2]     = point.X;
                            ro.RenderedPaths[figureIndex][pointIndex * 2 + 1] = point.Y;
                        }
                    }

                    yield return(ro);
                }
            }
Пример #4
0
            public override IEnumerable <String> RenderPaths(IEnumerable <Path2D> path, StyleBrush fill,
                                                             StyleBrush highlightFill,
                                                             StyleBrush selectFill, StylePen outline,
                                                             StylePen highlightOutline,
                                                             StylePen selectOutline, RenderState renderState)
            {
                if (path == null)
                {
                    throw new ArgumentNullException("path");
                }

                yield return(path.ToString() +
                             fill == null
                                 ? String.Empty
                                 : fill.ToString() +
                             selectFill == null
                                       ? String.Empty
                                       : selectFill.ToString() +
                             highlightFill == null
                                             ? String.Empty
                                             : highlightFill.ToString() +
                             outline == null
                                                   ? String.Empty
                                                   : outline.ToString() +
                             highlightOutline == null
                                                         ? String.Empty
                                                         : highlightOutline.ToString() +
                             selectOutline == null
                                                               ? String.Empty
                                                               : selectOutline.ToString());
            }
Пример #5
0
        /// <summary>
        /// Creates a new GdiRenderObject instance.
        /// </summary>
        /// <param name="text">The text to draw.</param>
        /// <param name="font">The font to use to render the text.</param>
        /// <param name="bounds">The location and size to draw the text.</param>
        /// <param name="fill">
        /// The brush used to fill the path when the state is <see cref="RenderState.Normal"/>.
        /// </param>
        /// <param name="highlightFill">
        /// The brush used to fill the path when the state is <see cref="RenderState.Highlighted"/>.
        /// </param>
        /// <param name="selectFill">
        /// The brush used to fill the path when the state is <see cref="RenderState.Selected"/>.
        /// </param>
        /// <param name="outline">
        /// The pen used to outline the path when the state is <see cref="RenderState.Normal"/>.
        /// </param>
        /// <param name="highlightOutline">
        /// The pen used to outline the path when the state is <see cref="RenderState.Highlighted"/>.
        /// </param>
        /// <param name="selectOutline">
        /// The pen used to outline the path when the state is <see cref="RenderState.Selected"/>.
        /// </param>
        public CairoRenderObject(String text, FontFace font, Rectangle bounds,
                                 StyleBrush fill, StyleBrush highlightFill, StyleBrush selectFill,
                                 StylePen outline, StylePen highlightOutline, StylePen selectOutline)
        {
            _state = RenderState.Normal;
            Path   = null;

            Image           = null;
            Bounds          = new Rectangle();
            AffineTransform = null;
            ColorTransform  = null;

            Text             = text;
            Font             = font;
            Bounds           = bounds;
            Fill             = fill;
            HighlightFill    = highlightFill;
            SelectFill       = selectFill;
            Outline          = outline;
            HighlightOutline = highlightOutline;
            SelectOutline    = selectOutline;
            Line             = null;
            HighlightLine    = null;
            SelectLine       = null;
        }
 public override IEnumerable <RenderObject> RenderPaths(IEnumerable <Path2D> paths, StylePen line,
                                                        StylePen highlightLine, StylePen selectLine,
                                                        StylePen outline, StylePen highlightOutline,
                                                        StylePen selectOutline, RenderState renderState)
 {
     return(renderPath(paths));
 }
Пример #7
0
        private StylePen interpolatePen(StylePen min, StylePen max, Double attr)
        {
            Double frac = fraction(attr);

            StyleColor color = StyleColor.Interpolate(min.BackgroundBrush.Color, max.BackgroundBrush.Color, frac);
            StylePen   pen   = new StylePen(color, interpolateDouble(min.Width, max.Width, attr));

            pen.MiterLimit = interpolateFloat(min.MiterLimit, max.MiterLimit, attr);
            pen.StartCap   = (frac > 0.5 ? max.StartCap : min.StartCap);
            pen.EndCap     = (frac > 0.5 ? max.EndCap : min.EndCap);
            pen.LineJoin   = (frac > 0.5 ? max.LineJoin : min.LineJoin);
            pen.DashStyle  = (frac > 0.5 ? max.DashStyle : min.DashStyle);

            if (min.DashStyle == LineDashStyle.Custom && max.DashStyle == LineDashStyle.Custom)
            {
                pen.DashPattern = (frac > 0.5 ? max.DashPattern : min.DashPattern);
            }

            pen.DashOffset = (frac > 0.5 ? max.DashOffset : min.DashOffset);
            pen.DashCap    = (frac > 0.5 ? max.DashCap : min.DashCap);

            if (min.CompoundArray.Length > 0 && max.CompoundArray.Length > 0)
            {
                pen.CompoundArray = (frac > 0.5 ? max.CompoundArray : min.CompoundArray);
            }

            pen.Alignment = (frac > 0.5 ? max.Alignment : min.Alignment);
            //pen.CustomStartCap = (frac > 0.5 ? max.CustomStartCap : min.CustomStartCap);  //Throws ArgumentException
            //pen.CustomEndCap = (frac > 0.5 ? max.CustomEndCap : min.CustomEndCap);  //Throws ArgumentException
            return(pen);
        }
Пример #8
0
 static ViewSelection()
 {
     DefaultOutline             = new StylePen(StyleColor.Black, 1.0f);
     DefaultOutline.DashStyle   = LineDashStyle.Dash;
     DefaultOutline.DashBrushes = new StyleBrush[] { new SolidStyleBrush(StyleColor.White) };
     DefaultOutline.DashPattern = new Single[] { 4, 4 };
 }
Пример #9
0
 IEnumerable IVectorRenderer2D.RenderPaths(IEnumerable <Path2D> paths, StylePen line,
                                           StylePen highlightLine, StylePen selectLine, StylePen outline,
                                           StylePen highlightOutline, StylePen selectOutline,
                                           RenderState renderState)
 {
     return(RenderPaths(paths, line, highlightLine, selectLine,
                        outline, highlightOutline, selectOutline, renderState));
 }
Пример #10
0
 public override IEnumerable <Object> RenderPaths(IEnumerable <Path2D> paths, StyleBrush fill,
                                                  StyleBrush highlightFill, StyleBrush selectFill,
                                                  StylePen outline,
                                                  StylePen highlightOutline, StylePen selectOutline,
                                                  RenderState renderState)
 {
     yield break;
 }
Пример #11
0
 IEnumerable IVectorRenderer2D.RenderPaths(IEnumerable <Path2D> paths, StyleBrush fill,
                                           StyleBrush highlightFill, StyleBrush selectFill, StylePen outline,
                                           StylePen highlightOutline, StylePen selectOutline,
                                           RenderState renderState)
 {
     return(RenderPaths(paths, fill, highlightFill, selectFill,
                        outline, highlightOutline, selectOutline, renderState));
 }
Пример #12
0
        public override IEnumerable <GeoJsonRenderObject> RenderPaths(IEnumerable <Path2D> paths, StylePen outline,
                                                                      StylePen highlightOutline, StylePen selectOutline,
                                                                      RenderState renderState)
        {
            yield break;

            //TODO:
        }
Пример #13
0
        public override IEnumerable <GdiRenderObject> RenderPaths(
            IEnumerable <Path2D> paths, StylePen outline, StylePen highlightOutline, StylePen selectOutline,
            RenderState renderState)
        {
            SolidStyleBrush transparentBrush = new SolidStyleBrush(StyleColor.Transparent);

            return(RenderPaths(paths, transparentBrush, transparentBrush,
                               transparentBrush, outline, highlightOutline, selectOutline, renderState));
        }
Пример #14
0
 private static void StrokePath(Context context, StylePen outline)
 {
     context.SetDash(ConvertDash(outline.DashPattern), outline.DashOffset);
     context.LineCap    = ConvertCap(outline.EndCap);
     context.LineJoin   = ConvertJoin(outline.LineJoin);
     context.LineWidth  = outline.Width;
     context.Antialias  = Antialias.Subpixel;
     context.MiterLimit = outline.MiterLimit;
     SetColour(context, outline.BackgroundBrush);
     context.StrokePreserve();
 }
Пример #15
0
        public void RenderPathOutlineTest()
        {
            GdiVectorRenderer renderer = new GdiVectorRenderer();

            Point2D[] points = new Point2D[]
            { new Point2D(1, 0), new Point2D(0, 1), new Point2D(-1, 0), new Point2D(0, -1) };

            Path2D path = new Path2D(points, true);

            StylePen outline   = new StylePen(new SolidStyleBrush(StyleColor.Blue), 1);
            StylePen highlight = new StylePen(new SolidStyleBrush(StyleColor.Red), 1);
            StylePen selected  = new StylePen(new SolidStyleBrush(StyleColor.Green), 1);

            IEnumerable <GdiRenderObject> renderObjects = renderer.RenderPaths(
                new Path2D[] { path }, outline, highlight, selected, RenderState.Normal);

            IEnumerator <GdiRenderObject> enumertor = renderObjects.GetEnumerator();

            enumertor.MoveNext();
            GdiRenderObject ro = enumertor.Current;

            Assert.AreEqual(RenderState.Normal, ro.State);
            Assert.IsInstanceOfType(typeof(SolidBrush), ro.Fill);
            Assert.IsNotNull(ro.GdiPath);
            Assert.AreEqual(4, ro.GdiPath.PointCount);
            Assert.AreEqual(new RectangleF(-1, -1, 2, 2), ro.GdiPath.GetBounds());

            PathData data = ro.GdiPath.PathData;

            for (Int32 i = 0; i < 4; i++)
            {
                Assert.AreEqual(points[i].X, data.Points[i].X, _e);
                Assert.AreEqual(points[i].Y, data.Points[i].Y, _e);
            }

            Assert.AreEqual(0, data.Types[0]);
            Assert.AreEqual(1, data.Types[1]);
            Assert.AreEqual(1, data.Types[2]);
            Assert.AreEqual(129, data.Types[3]);

            Pen expectedOutline   = new Pen(Brushes.Blue, 1.0f);
            Pen expectedHighlight = new Pen(Brushes.Red, 1.0f);
            Pen expectedSelected  = new Pen(Brushes.Green, 1.0f);

            Assert.IsTrue(pensAreEqual(expectedOutline, ro.Outline));
            Assert.IsTrue(pensAreEqual(expectedHighlight, ro.HighlightOutline));
            Assert.IsTrue(pensAreEqual(expectedSelected, ro.SelectOutline));

            expectedOutline.Dispose();
            expectedHighlight.Dispose();
            expectedSelected.Dispose();
            renderer.Dispose();
        }
        /// <summary>
        /// Renders a <see cref="IMultiLineString"/>.
        /// </summary>
        /// <param name="lines">IMultiLineString to be rendered.</param>
        /// <param name="fill">Pen used for filling (null or transparent for no filling).</param>
        /// <param name="highlightFill">Pen used for filling when highlighted.</param>
        /// <param name="selectFill">Pen used for filling when selected.</param>
        /// <param name="outline">Outline pen style (null if no outline).</param>
        /// <param name="highlightOutline">Outline pen style used when highlighted.</param>
        /// <param name="selectOutline">Outline pen style used when selected.</param>
        public virtual IEnumerable <TRenderObject> DrawMultiLineString(
            IMultiLineString lines, StylePen fill, StylePen highlightFill, StylePen selectFill,
            StylePen outline, StylePen highlightOutline, StylePen selectOutline, RenderState renderState)
        {
            if (lines == null)
            {
                throw new ArgumentNullException("lines");
            }

            return(drawLineStrings(lines, fill, highlightFill, selectFill,
                                   outline, highlightOutline, selectOutline, renderState));
        }
Пример #17
0
        private static Pen getPen(StylePen stylePen)
        {
            if (stylePen == null)
            {
                return(null);
            }

            PenLookupKey key = new PenLookupKey(stylePen.GetType().TypeHandle, stylePen.GetHashCode());
            Pen          pen;

            _penCache.TryGetValue(key, out pen);
            return(pen);
        }
        /// <summary>
        /// Renders a <see cref="IMultiPolygon"/>.
        /// </summary>
        /// <param name="multipolygon">IMultiPolygon to render.</param>
        /// <param name="fill">
        /// Brush used for filling (null or transparent for no filling).
        /// </param>
        /// <param name="highlightFill">
        /// Brush used for filling when highlighted.
        /// </param>
        /// <param name="selectFill">
        /// Brush used for filling when selected.
        /// </param>
        /// <param name="outline">
        /// Outline pen style (null if no outline).
        /// </param>
        /// <param name="highlightOutline">
        /// Outline pen style used when highlighted.
        /// </param>
        /// <param name="selectOutline">
        /// Outline pen style used when selected.
        /// </param>
        public virtual IEnumerable <TRenderObject> DrawMultiPolygon(IMultiPolygon multipolygon,
                                                                    StyleBrush fill, StyleBrush highlightFill, StyleBrush selectFill,
                                                                    StylePen outline, StylePen highlightOutline, StylePen selectOutline,
                                                                    RenderState renderState)
        {
            if (multipolygon == null)
            {
                throw new ArgumentNullException("multipolygon");
            }

            return(drawPolygons(multipolygon, fill, highlightFill, selectFill,
                                outline, highlightOutline, selectOutline, renderState));
        }
Пример #19
0
        public static StylePen RandomPen()
        {
            StylePen p = new StylePen(RandomColor(), random.Next(1, 5))
            {
                Alignment  = StylePenAlignment.Center,
                LineJoin   = StyleLineJoin.MiterClipped,
                MiterLimit = 2,
                StartCap   = StyleLineCap.NoAnchor,
                EndCap     = StyleLineCap.NoAnchor
            };

            return(p);
        }
Пример #20
0
        public void RenderPathWithOutlineOnly()
        {
            Point2D[] points = new Point2D[8];
            points[0] = new Point2D(10, 10);
            points[1] = new Point2D(11, 11);
            points[2] = new Point2D(10, 0);
            points[3] = new Point2D(0, 0);
            points[4] = new Point2D(-1, -1);
            points[5] = new Point2D(0, 0);
            points[6] = new Point2D(0, 5);
            points[7] = new Point2D(0, 10);

            Path2D               path    = new Path2D(points, true);
            StylePen             outline = new StylePen(new SolidStyleBrush(StyleColor.WhiteSmoke), 1);
            TestVector2DRenderer r       = new TestVector2DRenderer();
            IEnumerable <String> result  =
                r.RenderPaths(new Path2D[] { path }, outline, outline, outline, RenderState.Normal);
        }
Пример #21
0
        public override IEnumerable <CairoRenderObject> RenderPaths(IEnumerable <Path2D> paths, StylePen line,
                                                                    StylePen highlightLine, StylePen selectLine,
                                                                    StylePen outline, StylePen highlightOutline,
                                                                    StylePen selectOutline, RenderState renderState)
        {
            foreach (Path2D path in paths)
            {
                CairoRenderObject holder =
                    new CairoRenderObject(path, null, null, null, ViewConverter.Convert(line),
                                          ViewConverter.Convert(highlightLine), ViewConverter.Convert(selectLine),
                                          ViewConverter.Convert(outline), ViewConverter.Convert(highlightOutline),
                                          ViewConverter.Convert(selectOutline));

                holder.State = renderState;

                yield return(holder);
            }
        }
Пример #22
0
        public static Pen Convert(StylePen pen)
        {
            if (pen == null)
            {
                return(null);
            }

            Pen gdiPen;

            gdiPen = getPen(pen);

            if (gdiPen == null)
            {
                Brush brush = Convert(pen.BackgroundBrush);
                gdiPen = new Pen(brush, (Single)pen.Width);

                gdiPen.Alignment = (PenAlignment)(Int32)pen.Alignment;
                if (pen.CompoundArray != null)
                {
                    gdiPen.CompoundArray = pen.CompoundArray;
                }
                //gdiPen.CustomEndCap = new System.Drawing.Drawing2D.CustomLineCap();
                //gdiPen.CustomStartCap = new System.Drawing.Drawing2D.CustomLineCap();
                gdiPen.DashCap    = (DashCap)(Int32)pen.DashCap;
                gdiPen.DashOffset = pen.DashOffset;
                if (pen.DashPattern != null)
                {
                    gdiPen.DashPattern = pen.DashPattern;
                }
                gdiPen.DashStyle  = (DashStyle)(Int32)pen.DashStyle;
                gdiPen.EndCap     = (LineCap)(Int32)pen.EndCap;
                gdiPen.LineJoin   = (LineJoin)(Int32)pen.LineJoin;
                gdiPen.MiterLimit = pen.MiterLimit;
                //gdiPen.PenType = System.Drawing.Drawing2D.PenType...
                gdiPen.StartCap  = (LineCap)(Int32)pen.StartCap;
                gdiPen.Transform = Convert(pen.Transform);
                savePen(pen, gdiPen);
            }

            return(gdiPen);
        }
        private IEnumerable <TRenderObject> drawPolygons(IEnumerable <IPolygon> polygons,
                                                         StyleBrush fill, StyleBrush highlightFill, StyleBrush selectFill,
                                                         StylePen outline, StylePen highlightOutline, StylePen selectOutline,
                                                         RenderState renderState)
        {
            if (fill == null)
            {
                throw new ArgumentNullException("fill");
            }
            if (outline == null)
            {
                throw new ArgumentNullException("outline");
            }

            IEnumerable <Path2D> paths = convertToPaths(polygons);

            if (highlightFill == null)
            {
                highlightFill = fill;
            }
            if (selectFill == null)
            {
                selectFill = fill;
            }
            if (highlightOutline == null)
            {
                highlightOutline = outline;
            }
            if (selectOutline == null)
            {
                selectOutline = outline;
            }

            IEnumerable <TRenderObject> renderedObjects = VectorRenderer.RenderPaths(
                paths, fill, highlightFill, selectFill, outline,
                highlightOutline, selectOutline, renderState);

            return(renderedObjects);
        }
Пример #24
0
        public override IEnumerable <GdiRenderObject> RenderPaths(
            IEnumerable <Path2D> paths, StyleBrush fill, StyleBrush highlightFill,
            StyleBrush selectFill, StylePen outline, StylePen highlightOutline, StylePen selectOutline,
            RenderState renderState)
        {
            foreach (Path2D path in paths)
            {
                GdiPath gdiPath = ViewConverter.Convert(path);

                GdiRenderObject holder = new GdiRenderObject(gdiPath, ViewConverter.Convert(fill),
                                                             ViewConverter.Convert(highlightFill),
                                                             ViewConverter.Convert(selectFill),
                                                             null, null, null,
                                                             ViewConverter.Convert(outline),
                                                             ViewConverter.Convert(highlightOutline),
                                                             ViewConverter.Convert(selectOutline));

                holder.State = renderState;

                yield return(holder);
            }
        }
Пример #25
0
        /// <summary>
        /// Creates a new GdiRenderObject instance.
        /// </summary>
        /// <param name="image">The symbol to draw.</param>
        /// <param name="imageBounds">The location and size to draw the symbol.</param>
        /// <param name="transform">The affine transform applied to the symbol before drawing.</param>
        /// <param name="colorTransform">The color transform applied to the symbol before drawing.</param>
        public CairoRenderObject(Surface image, Rectangle imageBounds, CairoMatrix transform, CairoMatrix colorTransform)
        {
            _state          = RenderState.Normal;
            Image           = image;
            Bounds          = imageBounds;
            AffineTransform = transform;
            ColorTransform  = colorTransform;

            Path             = null;
            Fill             = null;
            HighlightFill    = null;
            SelectFill       = null;
            Line             = null;
            HighlightLine    = null;
            SelectLine       = null;
            Outline          = null;
            HighlightOutline = null;
            SelectOutline    = null;

            Text = null;
            Font = null;
        }
        private IEnumerable <TRenderObject> drawLineStrings(IEnumerable <ILineString> lines,
                                                            StylePen fill, StylePen highlightFill, StylePen selectFill,
                                                            StylePen outline, StylePen highlightOutline, StylePen selectOutline,
                                                            RenderState renderState)
        {
            if (fill == null)
            {
                throw new ArgumentNullException("fill");
            }

            IEnumerable <Path2D> paths = convertToPaths(lines);

            if (highlightFill == null)
            {
                highlightFill = fill;
            }
            if (selectFill == null)
            {
                selectFill = fill;
            }
            if (highlightOutline == null)
            {
                highlightOutline = outline;
            }
            if (selectOutline == null)
            {
                selectOutline = outline;
            }

            IEnumerable <TRenderObject> renderedObjects = VectorRenderer.RenderPaths(paths,
                                                                                     fill, highlightFill, selectFill, outline, highlightOutline, selectOutline,
                                                                                     renderState);

            foreach (TRenderObject ro in renderedObjects)
            {
                yield return(ro);
            }
        }
Пример #27
0
        /// <summary>
        /// Creates a new CairoRenderObject instance.
        /// </summary>
        /// <param name="path">The path to draw.</param>
        /// <param name="fill">
        /// The brush used to fill the path when the state is <see cref="RenderState.Normal"/>.
        /// </param>
        /// <param name="highlightFill">
        /// The brush used to fill the path when the state is <see cref="RenderState.Highlighted"/>.
        /// </param>
        /// <param name="selectFill">
        /// The brush used to fill the path when the state is <see cref="RenderState.Selected"/>.
        /// </param>
        /// <param name="line">
        /// The pen used to draw a line when the state is <see cref="RenderState.Normal"/>.
        /// </param>
        /// <param name="highlightLine">
        /// The pen used to draw a line when the state is <see cref="RenderState.Highlighted"/>.
        /// </param>
        /// <param name="selectLine">
        /// The pen used to draw a line when the state is <see cref="RenderState.Selected"/>.
        /// </param>
        /// <param name="outline">
        /// The pen used to outline the path when the state is <see cref="RenderState.Normal"/>.
        /// </param>
        /// <param name="highlightOutline">
        /// The pen used to outline the path when the state is <see cref="RenderState.Highlighted"/>.
        /// </param>
        /// <param name="selectOutline">
        /// The pen used to outline the path when the state is <see cref="RenderState.Selected"/>.
        /// </param>
        public CairoRenderObject(Path2D path, StyleBrush fill, StyleBrush highlightFill, StyleBrush selectFill,
                                 StylePen line, StylePen highlightLine, StylePen selectLine,
                                 StylePen outline, StylePen highlightOutline, StylePen selectOutline)
        {
            _state           = RenderState.Normal;
            Path             = path;
            Fill             = fill;
            HighlightFill    = highlightFill;
            SelectFill       = selectFill;
            Line             = line;
            HighlightLine    = highlightLine;
            SelectLine       = selectLine;
            Outline          = outline;
            HighlightOutline = highlightOutline;
            SelectOutline    = selectOutline;

            Image           = null;
            Bounds          = new Rectangle();
            AffineTransform = new CairoMatrix();
            ColorTransform  = null;

            Text = null;
            Font = null;
        }
Пример #28
0
 private static void savePen(StylePen stylePen, Pen pen)
 {
     _penCache[new PenLookupKey(stylePen.GetType().TypeHandle, stylePen.GetHashCode())] = pen;
 }
Пример #29
0
        private static Stream RandomIcon(out Size2D sz)
        {
            sz = RandomSymbolSize();
            Bitmap b = new Bitmap((int)sz.Width, (int)sz.Height);

            Graphics g = Graphics.FromImage(b);

            g.Clear(Color.Transparent);

            int rnd = random.Next(6);

            switch (rnd)
            {
            case 0:
            {
                StylePen p = RandomPen();
                g.DrawEllipse(ViewConverter.Convert(p), (int)Math.Ceiling(p.Width / 2),
                              (int)Math.Ceiling(p.Width / 2), b.Width - (int)p.Width,
                              b.Height - (int)p.Width);
                break;
            }

            case 1:
            {
                g.FillEllipse(ViewConverter.Convert(RandomBrush()), 0, 0, b.Width, b.Height);
                break;
            }

            case 2:
            {
                StylePen p = RandomPen();
                g.DrawRectangle(ViewConverter.Convert(p), (int)Math.Ceiling(p.Width / 2),
                                (int)Math.Ceiling(p.Width / 2), b.Width - (int)p.Width,
                                b.Height - (int)p.Width);
                break;
            }

            case 3:
                g.FillRectangle(ViewConverter.Convert(RandomBrush()), 0, 0, b.Width, b.Height);
                break;

            case 4:
            {
                StylePen p = RandomPen();
                g.FillEllipse(ViewConverter.Convert(RandomBrush()), 0, 0, b.Width, b.Height);
                g.DrawEllipse(ViewConverter.Convert(p), (int)Math.Ceiling(p.Width / 2),
                              (int)Math.Ceiling(p.Width / 2), b.Width - (int)p.Width,
                              b.Height - (int)p.Width);
                break;
            }

            case 5:
            {
                StylePen p = RandomPen();
                g.FillRectangle(ViewConverter.Convert(RandomBrush()), 0, 0, b.Width, b.Height);
                g.DrawRectangle(ViewConverter.Convert(p), (int)Math.Ceiling(p.Width / 2),
                                (int)Math.Ceiling(p.Width / 2), b.Width - (int)p.Width,
                                b.Height - (int)p.Width);
                break;
            }
            }

            MemoryStream ms = new MemoryStream();

            b.Save(ms, ImageFormat.Png);
            return(ms);
        }
Пример #30
0
 /// <summary>
 /// Creates a new selection using the <see cref="DefaultOutline"/> and <see cref="DefaultFill"/>
 /// for the <see cref="OutlineStyle"/> and <see cref="FillBrush"/> respectively.
 /// </summary>
 public ViewSelection()
 {
     _outline = DefaultOutline;
     _fill    = DefaultFill;
 }