Beispiel #1
0
 public override void Start(object sender)
 {
     if (sender is Ellipse)
     {
         Ellipse     pointShape = (Ellipse)sender;
         HandlePoint point      = CanvasHolder.GetHandlePointByShape(pointShape);
         if (point is AnchorPoint)
         {
             CanvasHolder.SelectHandlePoint(point);
             moveAnchor = true;
             ProgressTimer.Start();
         }
     }
     else if (sender is Shape)
     {
         Shape       shape         = (Shape)sender;
         ShapeHolder shapeHolder   = CanvasHolder.GetShapeHolderByShape(shape);
         AnchorPoint anchorPoint   = shapeHolder.AnchorPoint;
         Point       mousePosition = Mouse.GetPosition(CanvasHolder.Canvas);
         if (anchorPoint == null)
         {
             anchorPoint             = new AnchorPoint(mousePosition, shapeHolder);
             shapeHolder.AnchorPoint = anchorPoint;
             CanvasHolder.SelectHandlePoint(anchorPoint);
             moveAnchor = true;
             ProgressTimer.Start();
         }
         else
         {
             position   = mousePosition;
             moveAnchor = false;
             ProgressTimer.Start();
         }
     }
 }
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            Canvas canvas = this.Canvas;

            CanvasHolder = new CanvasHolder(canvas);
            DataContext  = CanvasHolder;
        }
Beispiel #3
0
        public Operation(CanvasHolder canvasHolder)
        {
            CanvasHolder = canvasHolder;

            ProgressTimer          = new DispatcherTimer();
            ProgressTimer.Interval = TimeSpan.FromMilliseconds(1);
            ProgressTimer.Tick    += onTimerTick;
        }
Beispiel #4
0
        public override void Start(object sender)
        {
            if (sender is Ellipse)
            {
                Ellipse     pointShape        = (Ellipse)sender;
                HandlePoint activeHandlePoint = CanvasHolder.GetHandlePointByShape(pointShape);
                CanvasHolder.SelectHandlePoint(activeHandlePoint);

                ProgressTimer.Start();
            }
        }
        public override void Start(object sender)
        {
            if (sender is Shape)
            {
                Shape  shape  = sender as Shape;
                Canvas canvas = CanvasHolder.Canvas;
                position    = Mouse.GetPosition(canvas);
                shapeHolder = CanvasHolder.GetShapeHolderByShape(shape);
                CanvasHolder.ActiveShapeHolder = shapeHolder;

                ProgressTimer.Start();
            }
        }
Beispiel #6
0
        public override void Start(object sender)
        {
            if (sender is Canvas)
            {
                Canvas canvas        = (Canvas)sender;
                Point  mousePosition = Mouse.GetPosition(canvas);

                ShapeHolder newShapeHolder = ShapeHolderFactory.CreateShapeHolder(CanvasHolder);
                HandlePoint newHandlePoint = new HandlePoint(mousePosition, newShapeHolder);
                newShapeHolder.CreateByPoint(newHandlePoint);
                CanvasHolder.SelectHandlePoint(newHandlePoint);

                ProgressTimer.Start();
            }
        }
Beispiel #7
0
        public PolygonHolder(CanvasHolder canvasHolder) : base(canvasHolder)
        {
            Polygon polygon = new Polygon();

            polygon.Stroke          = Brushes.Black;
            polygon.Fill            = Brushes.Black;
            polygon.StrokeThickness = CanvasHolder.CurrentStrokeThickness;
            polygon.Visibility      = Visibility.Hidden;

            polygon.MouseDown += canvasHolder.MouseDownEventHandler;
            polygon.MouseUp   += canvasHolder.MouseUpEventHandler;

            Shape = polygon;
            CanvasHolder.Canvas.Children.Add(polygon);
        }
        public CurveHolder(CanvasHolder canvasHolder, int T) : base(canvasHolder)
        {
            CurvePoints = new List <Point>(T + 1);
            Lines       = new List <Line>(T);
            this.T      = T;

            Line line;

            for (int i = 0; i < T; i++)
            {
                line                 = new Line();
                line.Stroke          = Brushes.Black;
                line.StrokeThickness = CanvasHolder.CurrentStrokeThickness;
                line.Visibility      = Visibility.Hidden;
                Lines.Add(line);
                CanvasHolder.Canvas.Children.Add(line);

                CurvePoints.Add(new Point());
            }
            CurvePoints.Add(new Point());
        }
Beispiel #9
0
        public static ShapeHolder CreateShapeHolder(CanvasHolder canvasHolder)
        {
            switch (canvasHolder.CurrentShapeHolderType)
            {
            case ShapeHolderType.Line:
                return(new LineHolder(canvasHolder));

            case ShapeHolderType.Rectangle:
                return(new RectangleHolder(canvasHolder));

            case ShapeHolderType.Circle:
                return(new CircleHolder(canvasHolder));

            case ShapeHolderType.Curve:
                return(new CurveHolder(canvasHolder, 20));

            case ShapeHolderType.Polygon:
                return(new PolygonHolder(canvasHolder));

            default:
                return(null);
            }
        }
 public TranslateByVectorOperation(CanvasHolder canvasHolder) : base(canvasHolder)
 {
     OptionsControl = new TranslateByVectorOptionsControl(canvasHolder);
     OperationType  = OperationType.TranslateByVector;
 }
Beispiel #11
0
 public ShapeHolder(CanvasHolder canvasHolder)
 {
     HandlePoints = new List <HandlePoint>();
     CanvasHolder = canvasHolder;
     CanvasHolder.AddShapeHolder(this);
 }
 public DrawPointByPointOptionsControl(CanvasHolder canvasHolder)
 {
     CanvasHolder = canvasHolder;
     InitializeComponent();
     DataContext = canvasHolder;
 }
Beispiel #13
0
 public override void Finish()
 {
     ProgressTimer.Stop();
     CanvasHolder.UnselectHandlePoint();
 }
Beispiel #14
0
 public DrawOperation(CanvasHolder canvasHolder) : base(canvasHolder)
 {
     OptionsControl = new DrawOptionsControl(canvasHolder);
     OperationType  = OperationType.Draw;
 }
 public TranslateByVectorOptionsControl(CanvasHolder canvasHolder)
 {
     CanvasHolder = canvasHolder;
     InitializeComponent();
 }
Beispiel #16
0
 public LineHolder(CanvasHolder canvasHolder) : base(canvasHolder)
 {
 }
Beispiel #17
0
 public RotateOperation(CanvasHolder canvasHolder) : base(canvasHolder)
 {
     OptionsControl = new RotateOptionsControl(canvasHolder);
     OperationType  = OperationType.Rotate;
 }
Beispiel #18
0
 public ScaleOperation(CanvasHolder canvasHolder) : base(canvasHolder)
 {
     OptionsControl = new ScaleOptionsControl(canvasHolder);
     OperationType  = OperationType.Scale;
 }
Beispiel #19
0
 public ModifyOperation(CanvasHolder canvasHolder) : base(canvasHolder)
 {
     OptionsControl = new ModifyOptionsControl(canvasHolder);
     OperationType  = OperationType.Modify;
 }
 public RectangleHolder(CanvasHolder canvasHolder) : base(canvasHolder)
 {
 }
 public CircleHolder(CanvasHolder canvasHolder) : base(canvasHolder)
 {
 }
Beispiel #22
0
 public ScaleOptionsControl(CanvasHolder canvasHolder)
 {
     CanvasHolder = canvasHolder;
     InitializeComponent();
     DataContext = CanvasHolder;
 }