Exemplo n.º 1
0
        private void ShapesMenuDropDown_Click(object sender, EventArgs e)
        {
            string filename = (sender as ToolStripMenuItem).Text;

            quadrilaterals.AddRange(QuadrilateralBL.LoadFigures(filename));
            Graphic.Redraw(panelMain, graphics, quadrilaterals);
        }
Exemplo n.º 2
0
        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);
                }
            }
        }
Exemplo n.º 3
0
        private void Save_Click(object sender, EventArgs e)
        {
            saveFileDialog1 = UI.CreateSaveFileDialog();

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                QuadrilateralBL.SerializeList(quadrilaterals, saveFileDialog1.FileName);
            }
        }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
        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());
        }