Example #1
0
        protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
        {
            if (drawingContext == null)
            {
                throw new ArgumentNullException("drawingContext");
            }
            if (null == drawingAttributes)
            {
                throw new ArgumentNullException("drawingAttributes");
            }
            Pen pen = new Pen
            {
                StartLineCap = PenLineCap.Round,
                EndLineCap   = PenLineCap.Round,
                Brush        = new SolidColorBrush(drawingAttributes.Color),
                Thickness    = drawingAttributes.Width
            };

            BrushConverter bc         = new BrushConverter();
            Brush          BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString());

            drawingContext.DrawRectangle(
                BackGround,
                pen,
                new Rect(new Point(StylusPoints[0].X, StylusPoints[0].Y),
                         new Point(StylusPoints[1].X, StylusPoints[1].Y)));
        }
Example #2
0
        protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
        {
            if (drawingContext == null)
            {
                throw new ArgumentNullException("drawingContext");
            }
            if (null == drawingAttributes)
            {
                throw new ArgumentNullException("drawingAttributes");
            }
            Pen pen = new Pen
            {
                StartLineCap = PenLineCap.Round,
                EndLineCap   = PenLineCap.Round,
                Brush        = new SolidColorBrush(drawingAttributes.Color),
                Thickness    = drawingAttributes.Width
            };

            BrushConverter    bc         = new BrushConverter();
            Brush             BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString());
            GeometryConverter gc         = new GeometryConverter();
            Geometry          geometry   = (Geometry)gc.ConvertFromString(string.Format("M {0},{1} {2},{3} {4},{5} Z", StylusPoints[0].X, StylusPoints[1].Y, (Math.Abs(StylusPoints[1].X - StylusPoints[0].X)) / 2 + StylusPoints[0].X, StylusPoints[0].Y, StylusPoints[1].X, StylusPoints[1].Y));
            GeometryDrawing   gd         = new GeometryDrawing(BackGround, pen, geometry);

            drawingContext.DrawDrawing(gd);
        }
Example #3
0
        private static void PersistDrawingFlags(DrawingAttributes da, Stream stream, GuidList guidList, ref uint cbData, ref BinaryWriter bw)
        {
            //
            // always serialize DrawingFlags, even when it is the default of AntiAliased.  V1 loaders
            // expect it.
            //
            Debug.Assert(bw != null);
            cbData += SerializationHelper.Encode(stream, (uint)guidList.FindTag(KnownIds.DrawingFlags, true));
            cbData += SerializationHelper.Encode(stream, (uint)(int)da.DrawingFlags);

            if (da.ContainsPropertyData(KnownIds.CurveFittingError))
            {
                Debug.Assert(bw != null);
                cbData += SerializationHelper.Encode(stream, (uint)guidList.FindTag(KnownIds.CurveFittingError, true));
                cbData += SerializationHelper.Encode(stream, (uint)(int)da.GetPropertyData(KnownIds.CurveFittingError));
            }
        }
Example #4
0
        protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
        {
            if (drawingContext == null)
            {
                throw new ArgumentNullException("drawingContext");
            }
            if (null == drawingAttributes)
            {
                throw new ArgumentNullException("drawingAttributes");
            }
            Pen pen = new Pen
            {
                StartLineCap = PenLineCap.Round,
                EndLineCap   = PenLineCap.Round,
                Brush        = new SolidColorBrush(drawingAttributes.Color),
                Thickness    = drawingAttributes.Width
            };
            Rect r = new Rect(
                new Point(StylusPoints[0].X, StylusPoints[0].Y),
                new Point(StylusPoints[1].X, StylusPoints[1].Y));

            Point center = new Point(
                (r.Left + r.Right) / 2.0,
                (r.Top + r.Bottom) / 2.0);

            double radiusX = (r.Right - r.Left) / 2.0;
            double radiusY = (r.Bottom - r.Top) / 2.0;

            BrushConverter bc         = new BrushConverter();
            Brush          BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString());

            drawingContext.DrawEllipse(
                BackGround,
                pen,
                center,
                radiusX,
                radiusY);
        }