예제 #1
0
 public CommandSelectStart(double posX, double posY, GenericShape select, Brush brush)
 {
     this.posX = posX;
     this.posY = posY;
     this.brush = brush;
     this.select = select;
 }
예제 #2
0
        public void Execute()
        {
            GenericShape newForm = new GenericShape();
            rectangle = new RectangleShape(posX, posY, 0, 0, newShapeIndex, brush);

            newForm.Shape = rectangle.Shape;
            newForm.position = new Point(posX, posY);
            newForm.ShapeTyp = GenericShape.type.Rectangle;

            shapeContainer.shapes.Add(newShapeIndex, newForm);
        }
예제 #3
0
        public void Execute()
        {
            GenericShape newForm = new GenericShape();

            pencil = new Pencil(start, end, newShapeIndex, brush);

            newForm.Shape = pencil.Shape;
            //newForm.position = new Point(start, end);
            newForm.ShapeTyp = GenericShape.type.Pencil;

            shapeContainer.shapes.Add(newShapeIndex, newForm);
        }
예제 #4
0
        public void Execute()
        {
            GenericShape newForm = new GenericShape();

            ellipse = new EllipseShape(posX, posY, 0, 0, newShapeIndex, brush);

            newForm.Shape = ellipse.Shape;
            newForm.position = new Point(posX, posY);
            newForm.ShapeTyp = GenericShape.type.Ellipse;

            shapeContainer.shapes.Add(newShapeIndex, newForm);
        }
예제 #5
0
        public void Execute()
        {
            GenericShape newForm = new GenericShape();

            marker = new Marker(start, end, newShapeIndex, brush);

            newForm.Shape = marker.Shape;
            //newForm.position = new Point(start, end);
            newForm.ShapeTyp = GenericShape.type.Marker;

            shapeContainer.shapes.Add(newShapeIndex, newForm);
        }
예제 #6
0
        private void Scene_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ICommands com;

            EndMovePoint = e.GetPosition(Scene);
            double dX = EndMovePoint.X - StartMovePoint.X;
            double dY = EndMovePoint.Y - StartMovePoint.Y;

            switch (option.type)
            {
                case Options.op.newShape_regtangle:
                    if (shapeContainer.shapes.ContainsKey(newShapeIndex))
                    {
                        com = new CommandFinalizeRect(EndMovePoint.X, EndMovePoint.Y, newShapeIndex, shapeContainer, brush);
                        com.Execute();
                        newShapeIndex++;
                        Render();
                    }
                    break;

                case Options.op.newShape_ellipse:
                    if (shapeContainer.shapes.ContainsKey(newShapeIndex))
                    {
                        com = new CommandFinalizeEllipse(EndMovePoint.X, EndMovePoint.Y, newShapeIndex, shapeContainer, brush);
                        com.Execute();
                        newShapeIndex++;
                        Render();
                    }
                    break;

                case Options.op.newLine_Pencil:
                    if (shapeContainer.shapes.ContainsKey(newShapeIndex))
                    {
                        com = new CommandFinalizePencil(StartMovePoint, EndMovePoint, newShapeIndex, shapeContainer, brush);
                        com.Execute();
                        newShapeIndex++;
                        Render();
                    }
                    break;

                case Options.op.newLine_Marker:
                    if (shapeContainer.shapes.ContainsKey(newShapeIndex))
                    {
                        com = new CommandFinalizeMarker(StartMovePoint, EndMovePoint, newShapeIndex, shapeContainer, brush);
                        com.Execute();
                        newShapeIndex++;
                        Render();
                    }
                    break;

                case Options.op.resize:
                    Path path_r = resize.VisualHit as Path;
                    int index_r = Convert.ToInt32(path_r.Tag.ToString());

                    if (path_r.Data.GetType() == typeof(RectangleGeometry))
                    {
                        int index = Convert.ToInt32(path_r.Tag.ToString());
                        GenericShape form = shapeContainer.shapes[index];

                        if (composite.child.Contains(form))
                        {
                            foreach (var pair in composite.child)
                            {
                                int indexGroup = Convert.ToInt32(pair.Shape.Tag);
                                com = new CommandResizeRect(dX, dY, indexGroup, shapeContainer, pair.Shape, Brushes.Blue);
                                com.Execute();
                            }
                        }
                        else
                        {
                            com = new CommandResizeRect(dX, dY, index_r, shapeContainer, path_r, Brushes.Blue);
                            com.Execute();
                        }
                        Render();
                    }

                    break;

                case Options.op.moveShape:

                    HitTestResult result = VisualTreeHelper.HitTest(Scene, Mouse.GetPosition(Scene));
                    Path path = result.VisualHit as Path;

                    if (path.Data.GetType() == typeof(RectangleGeometry))
                    {
                        int index = Convert.ToInt32(path.Tag.ToString());
                        GenericShape form = shapeContainer.shapes[index];

                        if (composite.child.Contains(form))
                        {
                            foreach (var pair in composite.child)
                            {
                                int indexGroup = Convert.ToInt32(pair.Shape.Tag);

                                com = new CommandMoveRect(dX, dY, indexGroup, shapeContainer, pair.Shape, brush);
                                com.Execute();
                            }
                        }
                        else{
                            com = new CommandMoveRect(dX, dY, index, shapeContainer, path, brush);
                            com.Execute();
                        }
                    }

                 else if (path.Data.GetType() == typeof(EllipseGeometry))
                    {
                        int index = Convert.ToInt32(path.Tag.ToString());
                        GenericShape form = shapeContainer.shapes[index];

                        if (composite.child.Contains(form))
                        {
                            foreach (var pair in composite.child)
                            {
                                int indexGroup = Convert.ToInt32(pair.Shape.Tag);
                                com = new CommandMoveEllipse(dX, dY, indexGroup, shapeContainer, pair.Shape, brush);
                                com.Execute();
                            }
                        }
                        else{
                            com = new CommandMoveEllipse(dX, dY, index, shapeContainer, path, brush);
                            com.Execute();
                        }
                        Render();
                    }
                    break;

                case Options.op.groupShape:
                    ShapeComposite group = new ShapeComposite();

                    foreach (var pair in shapeContainer.shapes)
                    {
                        GenericShape temp = new GenericShape();
                        temp = pair.Value;
                        if ((temp.position.X > StartMovePoint.X) && (temp.position.Y > StartMovePoint.Y) && (temp.position.X < EndMovePoint.X) && (temp.position.Y < EndMovePoint.Y))
                        {
                            //group.add(temp);
                            composite.add(temp);
                            //Scene.Children.Add(temp.Shape);
                        }
                    }

                    //composite.add(group);
                    Scene.Children.Remove(select.Shape);
                    Render();
                    break;
            }
        }
예제 #7
0
 public void remove(GenericShape component)
 {
     child.Remove(component);
 }
예제 #8
0
 public void add(GenericShape component)
 {
     child.Add(component);
 }
예제 #9
0
 public void UpdateShape(GenericShape shape, int index)
 {
     shapes[index] = shape;
 }