private void FlowNetworkSimulator_MouseClick(object sender, MouseEventArgs e)
        {
            flowLabel.Visible = false;
            mousepoint        = PointToClient(Cursor.Position);
            tooltip.RemoveAll();
            IWin32Window win = this;

            if (e.Button == MouseButtons.Left)
            {
                isSelected = false;

                if ((tempComponent = canvas.SelectComponent(mousepoint)) != null)
                {
                    isSelected = true;

                    trackBar1.Enabled = false;
                    textBox1.Enabled  = false;
                    textBox2.Enabled  = false;
                    switch (tempComponent.GetType())
                    {
                    case ComponentType.Pipeline:
                        textBox2.Enabled = true;
                        break;

                    case ComponentType.Pump:
                        textBox1.Enabled = true;
                        textBox2.Enabled = true;
                        break;

                    case ComponentType.Splitter:
                        trackBar1.Enabled = true;
                        break;
                    }
                    fh.saved = false;
                    this.Refresh();
                }
                if (selectedComponent != null && !canvas.IsOverlapping(selectedComponent.SelectionArea) && area.IntersectsWith(new Rectangle(mousepoint, new Size(40, 40))))
                {
                    selectedComponent.Position = new Point(mousepoint.X, mousepoint.Y);
                    selectedComponent.UpdateSelectionArea();
                    canvas.CreateComponent(selectedComponent);
                    if (!compIsMoving)
                    {
                        canvas.CreateUndo(ActionType.Create, selectedComponent);
                    }
                    UndoButton.Enabled = true;
                    selectedComponent  = null;
                    compIsMoving       = false;
                    fh.saved           = false;
                    this.Refresh();
                    this.Cursor = Cursors.Arrow;
                }



                if (selectedComponent != null && canvas.IsOverlapping(selectedComponent.SelectionArea) || !area.IntersectsWith(new Rectangle(mousepoint, new Size(40, 40))))
                {
                    UndoButton.Enabled = true;
                    if (compIsMoving)
                    {
                        canvas.UndoRedoList.RemoveAt(canvas.UndoRedoIndex);
                        canvas.UndoRedoIndex--;
                        selectedComponent.Position = oldCoordinates;
                        selectedComponent.UpdateSelectionArea();
                        // if(selectedComponent)
                        canvas.CreateComponent(selectedComponent);
                        compIsMoving = false;
                        fh.saved     = false;
                        this.Refresh();
                    }

                    selectedComponent = null;
                    //this.Cursor = Cursors.Arrow;
                    tooltip.Show("You cannot place a component here", win, mousepoint);
                    this.Cursor = Cursors.Arrow;
                }
                if (addNewPipeline)
                {
                    if (!connectedComp1)
                    {
                        first          = new Point(mousepoint.X, mousepoint.Y);
                        connectedComp1 = true;
                    }
                    else
                    {
                        second = new Point(mousepoint.X, mousepoint.Y);
                        if (canvas.DrawPipeline(canvas.SelectComponent(first), canvas.SelectComponent(second)))
                        {
                            connectedComp1 = false;
                            addNewPipeline = false;


                            fh.saved = false;
                            this.Refresh();
                            this.Cursor = Cursors.Arrow;
                        }
                        else
                        {
                            tooltip.Show("Unable to establish a connection", win, Cursor.Position);
                            connectedComp1 = false;
                            fh.saved       = false;
                            this.Cursor    = Cursors.Arrow;
                            this.Refresh();
                        }
                    }
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                //  mousepoint = this.formPointToClient(Cursor.Position);
                //this.Cursor = Cursors.Arrow;


                if ((tempComponent = canvas.SelectComponent(mousepoint)) != null)
                {
                    isSelected = true;
                    this.Refresh();
                    cmsEdit.Show(Cursor.Position);
                }
                else if ((selectedPipeline = canvas.SelectPipeline(mousepoint)) != null)
                {
                    cmsEditPipeline.Show(Cursor.Position);
                    wireIsSelected = true;
                }
                else
                {
                    isSelected = false;
                }
                fh.saved = false;
                this.Refresh();
            }

            if (isSelected)
            {
                Component temp = canvas.SelectComponent(mousepoint);
                UpdateFlowLabel(temp);
                fh.saved = false;
            }
            if ((selectedPipeline = canvas.SelectPipeline(mousepoint)) != null)
            {
                UpdateFlowLabel(selectedPipeline);
                fh.saved = false;
            }
        }