Example #1
0
        private void Gate_MouseDown(object sender, MouseEventArgs e)
        {
            textBoxLocation.Text = ActiveControl.Name.ToString();
            Gate_Front newGate = new Gate_Front(this.ActiveControl.Name.ToString());

            Form1.getInstance().gates.Add(newGate);
            newGate.createGateDueToType();
            //  DecentUserControl DecentUserControlChild = new DecentUserControl(ActiveControl.Name.ToString());
            Point d;

            d = Gate_Front.MousePosition;
            if (d.X < 2 * flowLayoutPanel1.Right && d.X > 0)
            {
                //  notgate2.Show();
                // lw 3wzen na3mal click msh drag wa drop
                DoDragDrop(newGate, DragDropEffects.Link);
                newGate.Parent = panel2;
                mousePos       = Gate_Front.MousePosition;


                // int dx = mousePos.X - DecentUserControlChild.Width - panel2.Left;
                // int dy = mousePos.Y - panel2.Top - 3 * DecentUserControlChild.Height + DecentUserControlChild.Height / 2;
                newGate.Location = new Point(mousePos.X - panel2.Left - 3 * newGate.Width / 2, mousePos.Y - 100);
            }
        }
        private void buttonGate_Click(object sender, EventArgs e)
        {
            //<summary>
            //// creates Gate_front object that creates a Gate object of type suitable to the name of the button
            //// for example a button Named "OR" will create an OR gate and call its draw function
            //// also that class is responsible for handling interactions with the gate object from the front end.
            //</summary>
            Gate_Front newGate = new Gate_Front(ActiveControl.Name.ToString());

            this.Controls.Add(newGate);
        }