private void StartDrawingPolygon(object sender, EventArgs e)
        {
            DetachInputHandlerEventsFromDrawingArea();

            IPolygon polygonUnderCreation = new Polygon(new List <Vertice>(), new List <Edge>());

            polygonUnderCreation.AddVertice(new Vertice(), null, null);
            polygons.Add(polygonUnderCreation);

            inputHandler = new InputHandlerForPolygonCreation
            {
                OnSuccessfullElementMove = drawingArea.Refresh,
                OnVerticeAdd             = drawingArea.Refresh,
                OnFinishedDrawing        = StopDrawingPolygon,
                PolygonUnderCreation     = polygonUnderCreation
            };

            AttachInputHandlerEventsToDrawingArea();

            UpdateButtons();
            foreach (var button in CreateGroupBox.FindAllChildrenByType <Button>())
            {
                button.Enabled = false;
            }
            StopDrawingButton.Enabled = true;
            drawingArea.Refresh();
            FakeButton.Focus();
        }
        private void UpdateButtons()
        {
            if (inputHandler.SelectedElement is Vertice v)
            {
                foreach (var button in EditEdgeGroupBox.FindAllChildrenByType <Button>())
                {
                    button.Enabled = false;
                }
                foreach (var button in EditVerticeGroupBox.FindAllChildrenByType <Button>())
                {
                    button.Enabled = true;
                }
                foreach (var button in EditPolygonGroupBox.FindAllChildrenByType <Button>())
                {
                    button.Enabled = true;
                }
            }
            else if (inputHandler.SelectedElement is Edge e)
            {
                foreach (var button in EditVerticeGroupBox.FindAllChildrenByType <Button>())
                {
                    button.Enabled = false;
                }
                foreach (var button in EditPolygonGroupBox.FindAllChildrenByType <Button>())
                {
                    button.Enabled = true;
                }

                ChangeLengthButton.Enabled      = e.Type != EdgeType.FixedLength ? false : true;
                RemoveConstraintsButton.Enabled = e.Type == EdgeType.Normal ? false : true;
                MakeFixedLengthButton.Enabled   = e.Type == EdgeType.FixedLength ? false : true;
                MakeHorizontalButton.Enabled    = e.Type == EdgeType.Horizontal ? false : true;
                MakeVerticalButton.Enabled      = e.Type == EdgeType.Vertical ? false : true;
                SplitButton.Enabled             = true;
            }
            else
            {
                foreach (var button in EditEdgeGroupBox.FindAllChildrenByType <Button>())
                {
                    button.Enabled = false;
                }
                foreach (var button in EditVerticeGroupBox.FindAllChildrenByType <Button>())
                {
                    button.Enabled = false;
                }
                foreach (var button in EditPolygonGroupBox.FindAllChildrenByType <Button>())
                {
                    button.Enabled = false;
                }
            }
            foreach (var button in CreateGroupBox.FindAllChildrenByType <Button>())
            {
                button.Enabled = true;
            }

            StopDrawingButton.Enabled = false;
        }