Exemplo n.º 1
0
        public void SetState(List <IShape> drawnShapes, ToolBar toolbar)
        {
            DrawnShapes.Clear();
            foreach (var shape in drawnShapes)
            {
                DrawnShapes.Add((IShape)shape.Clone());
            }

            ToolBar = (ToolBar)toolbar.Clone();
        }
Exemplo n.º 2
0
 public void DrawCurrentShape(int x, int y)
 {
     if (_currentShape != null)
     {
         _currentShape.Accept(new CenterShapeOnDrawing(x, y));
         DrawnShapes.Add(_currentShape);
         _g.RefreshView();
         _currentShape = null;
         CreateMemento();
     }
 }
Exemplo n.º 3
0
 public void CreateGroup(GroupShapes gr)
 {
     foreach (var shape in gr.Children)
     {
         DrawnShapes.Remove(shape);
         SelectedShapes.Remove(shape);
     }
     DrawnShapes.Add(gr);
     SelectedShapes.Add(gr);
     CreateMemento();
 }
Exemplo n.º 4
0
 public void RestoreState(Memento newState)
 {
     DrawnShapes.Clear();
     SelectedShapes.Clear();
     foreach (var shape in newState.DrawnShapes)
     {
         DrawnShapes.Add((IShape)shape.Clone());
     }
     ToolBar = (ToolBar)newState.ToolBar.Clone();
     _g.RefreshView();
     _g.RefreshToolBar();
 }
Exemplo n.º 5
0
 public void DeleteGroup(GroupShapes gr)
 {
     if (DrawnShapes.Contains(gr))
     {
         DrawnShapes.Remove(gr);
         foreach (var shape in gr.Children)
         {
             DrawnShapes.Add(shape);
         }
         SelectedShapes.Clear();
         _g.RefreshView();
     }
     CreateMemento();
 }
Exemplo n.º 6
0
        private void AddShape()
        {
            if (PendingShape != null)
            {
                PendingShape.Mode = ShapeModes.Drawn;
                DrawnShapes.Add(PendingShape);

                int idx = DrawnShapesCombo.SelectedIndex;
                DrawnShapesCombo.ItemsSource   = null;
                DrawnShapesCombo.ItemsSource   = DrawnShapes;
                DrawnShapesCombo.SelectedIndex = idx;

                PendingShape = null;
            }
            canvasControl.Invalidate();
        }
Exemplo n.º 7
0
        private async void ShapeAdd_Clicked(object sender, RoutedEventArgs e)
        {
            double sx, sy, ex, ey;

            try
            {
                sx = double.Parse(AddStartLocationX.Text);
                sy = double.Parse(AddStartLocationY.Text);
                ex = double.Parse(AddEndLocationX.Text);
                ey = double.Parse(AddEndLocationY.Text);
            }
            catch (Exception)
            {
                await InvalidValuesFormatDialog();

                return;
            }

            Point start = new Point(sx, sy);
            Point end   = new Point(ex, ey);

            if (CurrentShapeType == ShapeType.Rectangle)
            {
                DrawnShapes.Add(new MRectangle(start, end));
            }
            else if (CurrentShapeType == ShapeType.Circle)
            {
                start = new Point((ex - sx) / 2, (ey - sy) / 2);
                DrawnShapes.Add(new MCircle(start, end));
            }
            else if (CurrentShapeType == ShapeType.Line)
            {
                DrawnShapes.Add(new MLine(start, end));
            }

            canvasControl.Invalidate();
        }