コード例 #1
0
ファイル: MoveCommand.cs プロジェクト: tosjo/DesignPatterns
 public MoveCommand(List<Draw>shapeList, Draw shape, Point startMousePoint, Point endMousePoint)
 {
     _shapeList = shapeList;
     _shape = shape;
     _startMousePoint = startMousePoint;
     _endMousePoint = endMousePoint;
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: tosjo/DesignPatterns
        public Point GetHandle(int handleNumber, Draw shape)
        {
            Point point = new Point();

            switch (handleNumber)
            {
                case 1:
                    point = new Point(shape.GetNormalizedRectangle().Left, shape.GetNormalizedRectangle().Top);
                    break;
                case 2:
                    point = new Point(shape.GetNormalizedRectangle().Right, shape.GetNormalizedRectangle().Top);
                    break;
                case 3:
                    point = new Point(shape.GetNormalizedRectangle().Left, shape.GetNormalizedRectangle().Bottom);
                    break;
                case 4:
                    point = new Point(shape.GetNormalizedRectangle().Right, shape.GetNormalizedRectangle().Bottom);
                    break;

            }

            return point;
        }
コード例 #3
0
ファイル: RemoveCommand.cs プロジェクト: tosjo/DesignPatterns
 public RemoveCommand(List<Draw> shapeList, Draw shape)
 {
     _shapeList = shapeList;
     _shape = shape;
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: tosjo/DesignPatterns
        public Rectangle GetHandleRectangle(int handleNumber, Draw shape)
        {
            Point point = GetHandle(handleNumber, shape);

            return new Rectangle(point.X - 3, point.Y - 3, 7, 7);
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: tosjo/DesignPatterns
        private void drawResizeHandles(Draw shape, Graphics e)
        {
            Point topLeft = new Point(shape.GetNormalizedRectangle().Left, shape.GetNormalizedRectangle().Top);
            Point topRight = new Point(shape.GetNormalizedRectangle().Right, shape.GetNormalizedRectangle().Top);
            Point bottomLeft = new Point(shape.GetNormalizedRectangle().Left, shape.GetNormalizedRectangle().Bottom);
            Point bottomRight = new Point(shape.GetNormalizedRectangle().Right, shape.GetNormalizedRectangle().Bottom);

            Rectangle topLeftRectangle = new Rectangle(topLeft.X - 4, topLeft.Y - 4, 8, 8);
            e.DrawRectangle(new Pen(Color.Red, 1), topLeftRectangle);

            Rectangle topRightRectangle = new Rectangle(topRight.X - 4, topLeft.Y - 4, 8, 8);
            e.DrawRectangle(new Pen(Color.Red, 1), topRightRectangle);

            Rectangle bottomLeftRectangle = new Rectangle(bottomLeft.X - 4, bottomLeft.Y - 4, 8, 8);
            e.DrawRectangle(new Pen(Color.Red, 1), bottomLeftRectangle);

            Rectangle bottomRightRectangle = new Rectangle(bottomRight.X - 4, bottomRight.Y - 4, 8, 8);
            e.DrawRectangle(new Pen(Color.Red, 1), bottomRightRectangle);
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: tosjo/DesignPatterns
 private void RefreshShapeSelection(Point point)
 {
     var selectedShape = FindShapeByPoint(_shapeList, point);
     if (selectedShape != _selected)
     {
         _selected = selectedShape;
         Invalidate();
     }
     if (_moving != null)
         Invalidate();
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: tosjo/DesignPatterns
        //Open button clicked
        private void button4_Click(object sender, EventArgs e)
        {
            DialogResult result1 = MessageBox.Show(@"Are you sure you want to open a file? Your current document will be gone",
            @"Important Question",
            MessageBoxButtons.OKCancel);
            switch (result1)
            {
                case DialogResult.Cancel:

                    break;
                case DialogResult.OK:

                    ClearAll();

                    OpenFileDialog openFileDialog1 = new OpenFileDialog();
                    if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        StreamReader file =
                            new StreamReader(openFileDialog1.FileName);
                        string line;
                        while ((line = file.ReadLine()) != null)
                        {
                            //try
                            //{
                                string[] data = line.Split(' ');
                                if (((data[0])[0]).ToString() == "E")
                                {
                                    Draw shape = new DrawEllipse((Int16.Parse(data[1])), (Int16.Parse(data[2])), (Int16.Parse(data[3])), (Int16.Parse(data[4])));
                                    _compositeList.Add(shape);

                                    //shapeList.Add(composite);
                                }
                                else if (((data[0])[0]).ToString() == "R")
                                {
                                    Draw shape = new DrawRectangle((Int16.Parse(data[1])), (Int16.Parse(data[2])), (Int16.Parse(data[3])), (Int16.Parse(data[4])));
                                    _shapeList.Add(shape);
                                }
                                UpdateControls();
                                _selected = null;
                            //}
                            //catch
                            //{
                            //    MessageBox.Show(@"shit went terribly wrong");
                            //    ClearAll();
                            //    UpdateControls();
                            //    Invalidate();
                            //    break;
                            //}
                        }
                        Composite composite = new Composite(_compositeList, _shapeList);
                        composite.AddToList();
                    }
                    break;
            }
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: tosjo/DesignPatterns
        //Undo button clicked
        private void button1_Click(object sender, EventArgs e)
        {
            ICommand undoneCommand = _commandStack.Pop();
            undoneCommand.Undo();
            _undoneCommands.Push(undoneCommand);

            _selected = null;
            //Draw undoneShape = ShapeList[ShapeList.Count - 1];
            //UndoneList.Add(undoneShape);
            //ShapeList.RemoveAt(ShapeList.Count() - 1);
            Invalidate();
            UpdateControls();
        }
コード例 #9
0
 public DrawCommand(List <Draw> shapeList, Draw shape)
 {
     _shapeList = shapeList;
     _shape     = shape;
 }
コード例 #10
0
ファイル: ResizeCommand.cs プロジェクト: tosjo/DesignPatterns
 public ResizeCommand(Draw shape, Point startLocation, Point endLocation)
 {
     _shape = shape;
     _startLocation = startLocation;
     _endLocation = endLocation;
 }
コード例 #11
0
ファイル: DrawCommand.cs プロジェクト: tosjo/DesignPatterns
 public DrawCommand(List<Draw>shapeList, Draw shape)
 {
     _shapeList = shapeList;
     _shape = shape;
 }