private void Triangle_Click(object sender, EventArgs e) { using (TrianglePerimeters f = new TrianglePerimeters(this)) { f.ShowDialog(); this.Show(); } }
private void Edit_Click(object sender, EventArgs e) { IsEditing = true; if (SelectedFigure != null) { if (SelectedFigure is Rectangle) { var f = new RectPerimeters(this); f.ShowDialog(); if (CurrentFigure != null) { using (var graphics = PanelDraw.CreateGraphics()) { CurrentFigure.Color = OriginalColor; CurrentFigure.Location = SelectedFigure.Location; CurrentFigure.Index = SelectedFigure.Index; FigureList.Remove(SelectedFigure); CurrentFigure.Draw(graphics); FigureList.Add(CurrentFigure); } Mode.Text = "Figure: Rectangle has been edited successfully"; } } if (SelectedFigure is Circle) { var f = new CirclePerimeters(this); f.ShowDialog(); if (CurrentFigure != null) { using (var graphics = PanelDraw.CreateGraphics()) { CurrentFigure.Color = OriginalColor; CurrentFigure.Location = SelectedFigure.Location; CurrentFigure.Index = SelectedFigure.Index; FigureList.Remove(SelectedFigure); CurrentFigure.Draw(graphics); FigureList.Add(CurrentFigure); } Mode.Text = "Figure: Circle has been edited successfully"; } } if (SelectedFigure is Triangle) { var f = new TrianglePerimeters(this); f.ShowDialog(); if (CurrentFigure != null) { using (var graphics = PanelDraw.CreateGraphics()) { CurrentFigure.Color = OriginalColor; CurrentFigure.Location = SelectedFigure.Location; CurrentFigure.Index = SelectedFigure.Index; FigureList.Remove(SelectedFigure); CurrentFigure.Draw(graphics); FigureList.Add(CurrentFigure); } Mode.Text = "Figure: Triangle has been edited successfully"; } } SelectedFigure = null; CurrentFigure = null; PanelDraw.Invalidate(); IsEditing = false; } CalculateAreaPermiters(); PanelDraw.Invalidate(); if (SelectedFigure == null) { Mode.Text = "You must Select Figure"; } }