Пример #1
0
        // Добавить операцию
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            OperForFreeTechUserControl o = new OperForFreeTechUserControl(this.Top + this.Height, this);

            this.Parent.Controls.Add(o);
            o.SetFocusOnComboBox();
        }
        //конструктор для редактируемой технологии
        public FreeTechnologyUserControl(BaseTechnology tech)
        {
            InitializeComponent();
            this.tech      = tech;
            LLOfOperations = new LinkedList <OperForFreeTechUserControl>();
            LinkedListNode <OperForFreeTechUserControl> prevNode = null;

            for (int i = 0; i < tech.listOfOperations.Count; i++)
            {
                OperForFreeTechUserControl operationUC;
                if (i != 0)
                {
                    operationUC = new OperForFreeTechUserControl(prevNode.Value.Top + prevNode.Value.Height + 5, prevNode.Value);
                    LLOfOperations.AddAfter(prevNode, operationUC);
                    operationUC.SetNameOfOper(tech.listOfOperations[i].name);
                    operationUC.SetTextOfOper(tech.listOfOperations[i].text);
                    operationUC.SetOsnastka(tech.listOfOperations[i].osnastka);
                }
                else    // первая операция
                {
                    operationUC = new OperForFreeTechUserControl(10);
                    LLOfOperations.AddFirst(operationUC);
                    operationUC.SetNameOfOper(tech.listOfOperations[i].name);
                    operationUC.SetTextOfOper(tech.listOfOperations[i].text);
                    operationUC.SetOsnastka(tech.listOfOperations[i].osnastka);
                }
                this.Controls.Add(operationUC);
                prevNode = LLOfOperations.Find(operationUC);
            }
            this.ControlAdded   += new System.Windows.Forms.ControlEventHandler(this.FreeTechnologyUserControl_ControlAdded);
            this.ControlRemoved += new System.Windows.Forms.ControlEventHandler(this.FreeTechnologyUserControl_ControlRemoved);
        }
 // удаление юзерконтрола операции
 private void FreeTechnologyUserControl_ControlRemoved(object sender, ControlEventArgs e)
 {
     // удаляем из списка
     LLOfOperations.Remove((OperForFreeTechUserControl)e.Control);
     //((OperForFreeTechUserControl)e.Control).Delete();
     ((OperForFreeTechUserControl)e.Control).Dispose();
     e.Control.Dispose();
     // перерисовка
     for (LinkedListNode <OperForFreeTechUserControl> oper = LLOfOperations.First; oper != null; oper = oper.Next)
     {
         if (oper == LLOfOperations.First)
         {
             oper.Value.Top = 10;
         }
         else
         {
             oper.Value.Top = oper.Previous.Value.Top + oper.Previous.Value.Height + 5;
         }
     }
     if (LLOfOperations.Count == 0)
     {
         OperForFreeTechUserControl oper1 = new OperForFreeTechUserControl(10);
         this.ControlAdded -= new System.Windows.Forms.ControlEventHandler(this.FreeTechnologyUserControl_ControlAdded);
         this.Controls.Add(oper1);
         this.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.FreeTechnologyUserControl_ControlAdded);
         LLOfOperations.AddFirst(oper1);
     }
 }
        private LinkedList <OperForFreeTechUserControl> LLOfOperations;      // связный список в котором будет хранится очерёдность всех операций-юзерконтролов

        //конструктор для вновь создаваемой технологии
        public FreeTechnologyUserControl()
        {
            InitializeComponent();
            LLOfOperations = new LinkedList <OperForFreeTechUserControl>();
            OperForFreeTechUserControl oper1 = new OperForFreeTechUserControl(10);  // первая операция

            this.Controls.Add(oper1);
            oper1.Left = 5;
            LLOfOperations.AddFirst(oper1);

            this.ControlAdded   += new System.Windows.Forms.ControlEventHandler(this.FreeTechnologyUserControl_ControlAdded);
            this.ControlRemoved += new System.Windows.Forms.ControlEventHandler(this.FreeTechnologyUserControl_ControlRemoved);
        }
Пример #5
0
 public OperForFreeTechUserControl(int top, OperForFreeTechUserControl prevOperation) : this(top)   // конструктор для последующих операций; prevOperation - предыдущая операция, из которой вызывается конструктор данной операции
 {
     this.Tag = prevOperation;
 }