Esempio n. 1
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();
            }
        }
        private void Load_OnClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            if (dialog.ShowDialog() == true)
            {
                ShapeHolder shapeHolder = ShapeHolderFactory.CreateShapeHolder(CanvasHolder);
                CanvasHolder.ActiveShapeHolder = shapeHolder;
                string       path      = dialog.FileName;
                StreamReader inputFile = new StreamReader(path);
                string       input     = inputFile.ReadLine();
                shapeHolder.FromString(input);
                inputFile.Close();
            }
        }
Esempio n. 3
0
        private void Draw_OnClick(object sender, RoutedEventArgs e)
        {
            Point position1 = new Point();
            Point position2 = new Point();

            position1.X = Convert.ToDouble(tbPositionX1.Text);
            position1.Y = Convert.ToDouble(tbPositionY1.Text);
            position2.X = Convert.ToDouble(tbPositionX2.Text);
            position2.Y = Convert.ToDouble(tbPositionY2.Text);

            ShapeHolder newShapeHolder = ShapeHolderFactory.CreateShapeHolder(CanvasHolder);
            HandlePoint newHandlePoint = new HandlePoint(position1, newShapeHolder);

            newShapeHolder.CreateByPoint(newHandlePoint);
            CanvasHolder.SelectHandlePoint(newHandlePoint);

            newHandlePoint.Move(position2);
            newHandlePoint.ModifyShape();
        }
Esempio n. 4
0
        public override void Start(object sender)
        {
            if (sender is Canvas)
            {
                Canvas      canvas        = (Canvas)sender;
                Point       mousePosition = Mouse.GetPosition(canvas);
                ShapeHolder shapeHolder   = CanvasHolder.ActiveShapeHolder;

                if (shapeHolder == null)
                {
                    shapeHolder = ShapeHolderFactory.CreateShapeHolder(CanvasHolder);
                    CanvasHolder.ActiveShapeHolder = shapeHolder;
                }
                HandlePoint newHandlePoint = new HandlePoint(mousePosition, shapeHolder);
                shapeHolder.CreateByPoint(newHandlePoint);

                if (shapeHolder.HandlePoints.Count > 2)
                {
                    shapeHolder.ModifyByPoint(newHandlePoint);
                }
            }
        }
        private void AddPoint_OnClick(object sender, RoutedEventArgs e)
        {
            Point position = new Point();

            position.X = Convert.ToDouble(tbPositionX.Text);
            position.Y = Convert.ToDouble(tbPositionY.Text);

            ShapeHolder shapeHolder = CanvasHolder.ActiveShapeHolder;

            if (shapeHolder == null)
            {
                shapeHolder = ShapeHolderFactory.CreateShapeHolder(CanvasHolder);
                CanvasHolder.ActiveShapeHolder = shapeHolder;
            }
            HandlePoint newHandlePoint = new HandlePoint(position, shapeHolder);

            shapeHolder.CreateByPoint(newHandlePoint);

            if (shapeHolder.HandlePoints.Count > 2)
            {
                shapeHolder.ModifyByPoint(newHandlePoint);
            }
        }