private void ShapesMenuDropDown_Click(object sender, EventArgs e) { string filename = (sender as ToolStripMenuItem).Text; quadrilaterals.AddRange(QuadrilateralBL.LoadFigures(filename)); Graphic.Redraw(panelMain, graphics, quadrilaterals); }
private void PanelMain_Click(object sender, EventArgs e) { MouseEventArgs mouseEvent = e as MouseEventArgs; if (mouseEvent.Button == MouseButtons.Right) { Point point = new Point(mouseEvent.Location.X, mouseEvent.Location.Y); if (!isFigureChecked) { activeQquadrilateral = quadrilaterals.FirstOrDefault(p => Geometry.IsInPolygon(p.ToArray(), point) == true); if (activeQquadrilateral != null) { isFigureChecked = true; UI.Show(labelFigureChecked, buttonCancel, buttonPolygonColor); } } else { if (activeQquadrilateral == null) { throw new ApplicationException("error, this figure does not exist ... "); } quadrilaterals.Remove(activeQquadrilateral); activeQquadrilateral = QuadrilateralBL.MoveToPoint(activeQquadrilateral, point); quadrilaterals.Add(activeQquadrilateral); Graphic.Redraw(panelMain, graphics, quadrilaterals); } } }
private void Save_Click(object sender, EventArgs e) { saveFileDialog1 = UI.CreateSaveFileDialog(); if (saveFileDialog1.ShowDialog() == DialogResult.OK) { QuadrilateralBL.SerializeList(quadrilaterals, saveFileDialog1.FileName); } }
private void Open_Click(object sender, EventArgs e) { openFileDialog1 = UI.CreateOpenFileDialog(); if (openFileDialog1.ShowDialog() == DialogResult.OK) { Reset(); quadrilaterals = QuadrilateralBL.DeserializeList(openFileDialog1.FileName); Graphic.Redraw(panelMain, graphics, quadrilaterals); } }
public static void LoadShapesMenu(ToolStripMenuItem toolStripMenuItem, ShapesMenuDropDown_Click function) { var figures = QuadrilateralBL.LoadFiguresList(); toolStripMenuItem.DropDownItems.Clear(); List <ToolStripMenuItem> ul = new List <ToolStripMenuItem>(); foreach (var item in figures) { ToolStripMenuItem li = new ToolStripMenuItem(item); li.Click += new EventHandler(function); ul.Add(li); } toolStripMenuItem.DropDownItems.AddRange(ul.ToArray()); }