Ejemplo n.º 1
3
        private void 열기ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog chooser = new OpenFileDialog();

            chooser.Title            = "File Open";
            chooser.Filter           = "All Files (*.*)|*.*";
            chooser.InitialDirectory = ".";
            if (chooser.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            _fileName = chooser.FileName;
            _figures.Clear();
            _selectedFigure = null;


            BinaryFormatter formatter = new BinaryFormatter();
            Stream          input     = File.OpenRead(_fileName);

            _figures = (FigureList)formatter.Deserialize(input);
            input.Close();


            for (int i = 0; i < _figures.Count; i++)
            {
                Figure ptr = _figures.getAt(i);
                ptr.makeRegion();
                ptr.setView(canvas);
                if (ptr is Point)
                {
                    ptr.setPopup(pointPopup);
                }
                else if (ptr is Line)
                {
                    ptr.setPopup(linePopup);
                }
                else if (ptr is Box)
                {
                    ptr.setPopup(boxPopup);
                }
                else if (ptr is Circle)
                {
                    ptr.setPopup(circlePopup);
                }
            }
            canvas.Invalidate();
        }
Ejemplo n.º 2
0
        public void Copy_Click(object sentder, EventArgs e)
        {
            if (_selectedFigure == null)
            {
                return;
            }
            Figure newFigure = _selectedFigure.clone();

            newFigure.makeRegion();
            _figures.addTail(newFigure);
            _selectedFigure = null;
            canvas.Invalidate();
        }
Ejemplo n.º 3
0
        private void canvas_MouseUp(object sender, MouseEventArgs e)
        {
            if (_selectedFigure != null)
            {
                Graphics g = canvas.CreateGraphics();

                _figures.addTail(_selectedFigure);
                bMousePressed = false;

                _selectedFigure.makeRegion();

                _selectedFigure = null;

                _actionMode = NOTHING;
                canvas.Invalidate();
            }
        }