public XDrawer() { _actionMode = NOTHING; InitializeComponent(); figures = new Figure[100]; bMousePressed = false; whatToDraw = DRAW_RECT; _figures = new FigureList(); mainPopup = new MainPopup(this); pointPopup = new FigurePopup(this, "점", false); linePopup = new FigurePopup(this, "선", false); boxPopup = new FigurePopup(this, "사각형", true); circlePopup = new FigurePopup(this, "원", true); }
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(); }