示例#1
0
        public override void Highlight(DrawingContext dc, GeometryStyleBase geometryStyle)
        {
            if (null == dc || !(geometryStyle is LineStyle))
            {
                return;
            }

            LineStyle style = geometryStyle as LineStyle;
            Pen       pen   = new Pen(style.LineBrush, 6);

            pen.DashStyle = style.DashStyle;

            if (pen.CanFreeze)
            {
                pen.Freeze();
            }

            if (!_moving)
            {
                _beforeMoveFirstPoint  = geometryStyle.FirstPoint;
                _beforeMoveSecondPoint = geometryStyle.SecondPoint;
            }

            dc.DrawLine(pen, geometryStyle.FirstPoint, geometryStyle.SecondPoint);
        }
示例#2
0
        public virtual void Move(DrawingContext dc, GeometryStyleBase geometryStyle, double offsetX, double offsetY)
        {
            if (null == dc)
            {
                return;
            }

            geometryStyle.FirstPoint = new Point()
            {
                X = _beforeMoveFirstPoint.X + offsetX, Y = _beforeMoveFirstPoint.Y + offsetY
            };
            geometryStyle.SecondPoint = new Point()
            {
                X = _beforeMoveSecondPoint.X + offsetX, Y = _beforeMoveSecondPoint.Y + offsetY
            };

            if (geometryStyle.Highlight)
            {
                Highlight(dc, geometryStyle);
            }
            else
            {
                Render(dc, geometryStyle);
            }

            _moving = true;
        }
示例#3
0
        public override void Render(DrawingContext dc, GeometryStyleBase geometryStyle)
        {
            if (null == dc || !(geometryStyle is TextStyle))
            {
                return;
            }

            TextStyle style = geometryStyle as TextStyle;

            if (style.Font == null)
            {
                return;
            }

            FontFamily fontFamily = new FontFamily(style.Font.FontFamily.Name);

            if (!_moving)
            {
                _beforeMoveFirstPoint  = geometryStyle.FirstPoint;
                _beforeMoveSecondPoint = geometryStyle.SecondPoint;
            }

            if (style.Text == null)
            {
                dc.DrawRectangle(Brushes.Transparent, _pen, new Rect(geometryStyle.FirstPoint, geometryStyle.SecondPoint));
            }
            else
            {
                dc.DrawText(new FormattedText(style.Text, new System.Globalization.CultureInfo("zh-cn"), FlowDirection.LeftToRight,
                                              new Typeface(fontFamily, style.Font.Italic ? FontStyles.Italic : FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
                                              style.Font.Size, style.Foreground), geometryStyle.FirstPoint);
            }
        }
示例#4
0
        public override void Render(DrawingContext dc, GeometryStyleBase geometryStyle)
        {
            if (null == dc || !(geometryStyle is RectangleStyle))
            {
                return;
            }

            RectangleStyle style = geometryStyle as RectangleStyle;
            Pen            pen   = new Pen(style.LineBrush, 6);

            pen.DashStyle = style.DashStyle;

            if (pen.CanFreeze)
            {
                pen.Freeze();
            }

            if (!_moving)
            {
                _beforeMoveFirstPoint  = geometryStyle.FirstPoint;
                _beforeMoveSecondPoint = geometryStyle.SecondPoint;
            }

            dc.DrawRectangle(style.FillBrush, pen, new Rect(geometryStyle.FirstPoint, geometryStyle.SecondPoint));
        }
示例#5
0
        public override void Excute(GeometryStyleBase style)
        {
            if (style == null || style is LineStyle)
            {
                return;
            }

            double dx   = style.SecondPoint.X - style.FirstPoint.X;
            double dy   = style.SecondPoint.Y - style.FirstPoint.Y;
            double atan = Math.Atan(dy / dx);

            if (dx > 0)
            {
                if (dy > 0)
                {
                    style.SecondPoint = new Point(style.SecondPoint.X, style.FirstPoint.Y + dx);
                }
                else
                {
                    style.SecondPoint = new Point(style.SecondPoint.X, style.FirstPoint.Y - dx);
                }
            }
            else
            {
                if (dy > 0)
                {
                    style.SecondPoint = new Point(style.SecondPoint.X, style.FirstPoint.Y - dx);
                }
                else
                {
                    style.SecondPoint = new Point(style.SecondPoint.X, style.FirstPoint.Y + dx);
                }
            }
        }
示例#6
0
        public override void Render(DrawingContext dc, GeometryStyleBase geometryStyle)
        {
            if (null == dc || !(geometryStyle is CircleStyle))
            {
                return;
            }

            CircleStyle style = geometryStyle as CircleStyle;
            Pen         pen   = new Pen(style.LineBrush, 6);

            pen.DashStyle = style.DashStyle;

            if (pen.CanFreeze)
            {
                pen.Freeze();
            }

            if (!_moving)
            {
                _beforeMoveFirstPoint  = geometryStyle.FirstPoint;
                _beforeMoveSecondPoint = geometryStyle.SecondPoint;
            }

            dc.DrawEllipse(style.FillBrush, pen, new Point(
                               (geometryStyle.FirstPoint.X + geometryStyle.SecondPoint.X) / 2, (geometryStyle.FirstPoint.Y + geometryStyle.SecondPoint.Y) / 2),
                           Math.Abs(geometryStyle.FirstPoint.X - geometryStyle.SecondPoint.X) / 2, Math.Abs(geometryStyle.FirstPoint.Y - geometryStyle.SecondPoint.Y) / 2);
        }
示例#7
0
        public override void Render(DrawingContext dc, GeometryStyleBase geometryStyle)
        {
            if (null == dc || !(geometryStyle is ImageStyle))
            {
                return;
            }

            ImageStyle style = geometryStyle as ImageStyle;

            if (!_moving)
            {
                _beforeMoveFirstPoint  = geometryStyle.FirstPoint;
                _beforeMoveSecondPoint = geometryStyle.SecondPoint;
            }

            if (style.ImageUri == null)
            {
                dc.DrawRectangle(Brushes.Transparent, _pen, new Rect(geometryStyle.FirstPoint, geometryStyle.SecondPoint));
            }
            else
            {
                BitmapSource source = new System.Windows.Media.Imaging.BitmapImage(style.ImageUri);
                dc.DrawImage(source, new Rect(geometryStyle.FirstPoint, geometryStyle.SecondPoint));
            }
        }
示例#8
0
        public override void Excute(GeometryStyleBase style)
        {
            if (style == null || !(style is LineStyle))
            {
                return;
            }

            double dx   = style.SecondPoint.X - style.FirstPoint.X;
            double dy   = style.SecondPoint.Y - style.FirstPoint.Y;
            double atan = Math.Atan(dy / dx);

            if (atan <= Math.PI / 2 - 0.57)
            {
                style.SecondPoint = new Point(style.SecondPoint.X, style.FirstPoint.Y);
            }
            else if (atan >= Math.PI / 2 + 0.57)
            {
                style.SecondPoint = new Point(style.FirstPoint.X, style.SecondPoint.Y);
            }
            else
            {
                style.SecondPoint = new Point(style.SecondPoint.X, style.FirstPoint.Y
                                              + Math.Abs((style.SecondPoint.X - style.FirstPoint.X)));
            }
        }
示例#9
0
        public void Excute(GeometryStyleBase style)
        {
            if (style == null)
            {
                return;
            }

            foreach (var strategy in this)
            {
                strategy.Excute(style);
            }
        }
示例#10
0
        public override void Render(DrawingContext dc, GeometryStyleBase geometryStyle)
        {
            if (null == dc || !(geometryStyle is TriangleStyle))
            {
                return;
            }

            TriangleStyle style = geometryStyle as TriangleStyle;
            Pen           pen   = new Pen(style.LineBrush, 6);

            pen.DashStyle = style.DashStyle;

            if (pen.CanFreeze)
            {
                pen.Freeze();
            }

            if (!_moving)
            {
                _beforeMoveFirstPoint  = geometryStyle.FirstPoint;
                _beforeMoveSecondPoint = geometryStyle.SecondPoint;
            }

            PathGeometry triangle = new PathGeometry();
            PathFigure   figure   = new PathFigure();

            figure.IsClosed   = true;
            figure.StartPoint = new Point((geometryStyle.FirstPoint.X + geometryStyle.SecondPoint.X) / 2, geometryStyle.FirstPoint.Y);
            figure.Segments   = new PathSegmentCollection()
            {
                new LineSegment()
                {
                    Point = geometryStyle.SecondPoint
                },
                new LineSegment()
                {
                    Point = new Point(geometryStyle.FirstPoint.X, geometryStyle.SecondPoint.Y)
                }
            };

            triangle.Figures = new PathFigureCollection()
            {
                figure
            };

            dc.DrawGeometry(style.FillBrush, pen, triangle);
        }
示例#11
0
 public abstract void Highlight(DrawingContext dc, GeometryStyleBase geometryStyle);
示例#12
0
 public void Refresh(DrawingContext dc, GeometryStyleBase geometryStyle)
 {
     Render(dc, geometryStyle);
 }
示例#13
0
 public abstract void Render(DrawingContext dc, GeometryStyleBase geometryStyle);
示例#14
0
 public void Hide(DrawingContext dc, GeometryStyleBase geometryStyle)
 {
     //什么也不干就是隐藏
 }
示例#15
0
 public abstract void Excute(GeometryStyleBase style);
示例#16
0
文件: Image.cs 项目: MrWater/XCode
 public Image(GeometryStyleBase style, GeometryBaseAction action)
     : base()
 {
     Style  = style;
     Action = action;
 }
示例#17
0
文件: Triangle.cs 项目: MrWater/XCode
 public Triangle(GeometryStyleBase style, GeometryBaseAction action)
     : base()
 {
     Style  = style;
     Action = action;
 }