Ejemplo n.º 1
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;
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 3
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());
            }
Ejemplo n.º 4
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));
 }
 public override IEnumerable <RenderObject> RenderPaths(IEnumerable <Path2D> paths,
                                                        StyleBrush fill, StyleBrush highlightFill,
                                                        StyleBrush selectFill, StylePen outline,
                                                        StylePen highlightOutline, StylePen selectOutline,
                                                        RenderState renderState)
 {
     return(renderPath(paths));
 }
Ejemplo n.º 6
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;
 }
Ejemplo n.º 7
0
        public override IEnumerable <GdiRenderObject> RenderText(String text, StyleFont font, Rectangle2D layoutRectangle,
                                                                 Path2D flowPath, StyleBrush fontBrush, Matrix2D transform)
        {
            GdiRenderObject renderedText = new GdiRenderObject(
                text, ViewConverter.Convert(font), ViewConverter.Convert(layoutRectangle),
                ViewConverter.Convert(fontBrush), null, null, null, null, null);

            yield return(renderedText);
        }
Ejemplo n.º 8
0
 public LabelStyle(StyleFont font,
                   StyleBrush foreground,
                   StyleBrush background,
                   Point2D offset,
                   Size2D collisionBuffer,
                   HorizontalAlignment horizontalAlignment,
                   VerticalAlignment verticalAlignment)
     : base(font, foreground, background, offset, collisionBuffer, horizontalAlignment, verticalAlignment)
 {
 }
        /// <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));
        }
Ejemplo n.º 10
0
        private static Brush getBrush(StyleBrush styleBrush)
        {
            if (styleBrush == null)
            {
                return(null);
            }

            BrushLookupKey key = new BrushLookupKey(styleBrush.GetType().TypeHandle, styleBrush.GetHashCode());
            Brush          brush;

            _brushCache.TryGetValue(key, out brush);
            return(brush);
        }
Ejemplo n.º 11
0
        IEnumerable ITextRenderer <Point2D, Size2D, Rectangle2D> .RenderText(
            String text, StyleFont font, Rectangle2D layoutRectangle, Path <Point2D, Rectangle2D> flowPath,
            StyleBrush fontBrush, IMatrix <DoubleComponent> transform)
        {
            if (!(flowPath is Path2D))
            {
                throw new ArgumentException("Parameter must be a Path2D instance.", "flowPath");
            }

            if (!(transform is Matrix2D))
            {
                throw new ArgumentException("Parameter must be a Matrix2D instance.", "transform");
            }

            return(RenderText(text, font, layoutRectangle, flowPath as Path2D, fontBrush, transform as Matrix2D));
        }
Ejemplo n.º 12
0
        private static void SetColour(Context context, StyleBrush brush)
        {
            SolidStyleBrush solid = brush as SolidStyleBrush;

            if (solid != null)
            {
                SetColour(context, brush.Color);
            }

            LinearGradientStyleBrush grad = brush as LinearGradientStyleBrush;

            if (grad != null)
            {
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 13
0
        public static Brush Convert(StyleBrush brush)
        {
            if (brush == null)
            {
                return(null);
            }

            Brush gdiBrush;

            gdiBrush = getBrush(brush);

            if (gdiBrush == null)
            {
                // TODO: need to accomodate other types of view brushes
                gdiBrush = new SolidBrush(Convert(brush.Color));

                saveBrush(brush, gdiBrush);
            }

            return(gdiBrush);
        }
Ejemplo n.º 14
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> 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);
        }
Ejemplo n.º 16
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);
            }
        }
Ejemplo n.º 17
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;
        }
Ejemplo n.º 18
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;
 }
Ejemplo n.º 19
0
 public override IEnumerable <Object> RenderText(String text, StyleFont font, Rectangle2D layoutRectangle, Path2D flowPath, StyleBrush fontBrush, Matrix2D transform)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Ejemplo n.º 20
0
 private static void FillPath(Context context, StyleBrush brush)
 {
     SetColour(context, brush);
     context.FillPreserve();
 }
Ejemplo n.º 21
0
 public abstract IEnumerable <TRenderObject> RenderText(String text, StyleFont font, Rectangle2D layoutRectangle,
                                                        Path2D flowPath, StyleBrush fontBrush, Matrix2D transform);
Ejemplo n.º 22
0
        public IEnumerable <TRenderObject> RenderText(String text, StyleFont font, Point2D location, StyleBrush fontBrush)
        {
            Rectangle2D layoutRectangle = new Rectangle2D(location, MeasureString(text, font));

            return(RenderText(text, font, layoutRectangle, null, fontBrush, null));
        }
Ejemplo n.º 23
0
 private static void DrawText(Context context, string text, FontFace face, StyleBrush brush, Rectangle rectangle)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 24
0
 public LabelStyle(StyleFont font, StyleBrush foreground) : base(font, foreground)
 {
 }
Ejemplo n.º 25
0
 IEnumerable ITextRenderer <Point2D, Size2D, Rectangle2D> .RenderText(String text, StyleFont font, Point2D location, StyleBrush fontBrush)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Ejemplo n.º 26
0
 public static StyleBrush Convert(StyleBrush brush)
 {
     return(brush);
 }
Ejemplo n.º 27
0
 public override IEnumerable <DependencyObject> RenderText(string text, StyleFont font,
                                                           Rectangle2D layoutRectangle, Path2D flowPath,
                                                           StyleBrush fontBrush, Matrix2D transform)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 28
0
 private StyleBrush interpolateBrush(StyleBrush min, StyleBrush max, Double attr)
 {
     return(new SolidStyleBrush(StyleColor.Interpolate(min.Color, max.Color, fraction(attr))));
 }
Ejemplo n.º 29
0
 private static void saveBrush(StyleBrush styleBrush, Brush brush)
 {
     _brushCache[new BrushLookupKey(styleBrush.GetType().TypeHandle, styleBrush.GetHashCode())] = brush;
 }
Ejemplo n.º 30
0
 /// <summary>Найти кисть в ресурсах</summary>
 /// <param name="Name">Имя кисти</param>
 public static SolidColorBrush GetBrushFromResource(StyleBrush Name)
 {
     return(Application.Current.Resources[Name.ToString()] as SolidColorBrush);
 }