Esempio n. 1
0
        public void AddNewElemAfter(UserControl pl, UserControl after, string name)
        {
            if (showed_modal)
            {
                CloseModalElem();
            }
            int k = list_of_controls.IndexOf(after) + 1;

            list_of_controls.Insert(k, pl);//помещаем контрол в конец
            GroupBox gr = new GroupBox();

            list_of_grbox.Insert(k, gr);

            gr.Size = new Size(pl.Width + 6, pl.Height + 10);

            int prev_max_height_control = this.Height - 45;

            if (pl.Height > max_height_control)
            {
                max_height_control = pl.Height;
                foreach (GroupBox ggr in list_of_grbox)
                {
                    ggr.Height = pl.Height + 10;
                }
            }
            else
            {
                gr.Height = max_height_control + 19;
            }

            gr.Text = name;
            gr.Left = width_controls + panel1.Width;
            //gr.BackColor = Color.Aquamarine;
            pl.Top  = 15;
            pl.Left = 0;

            CloseButton but = new CloseButton(pl, this);

            but.Location = new Point(gr.Width - 20, 2);
            but.Name     = "CloseButton";
            gr.Controls.Add(but);
            gr.Controls.Add(pl);

            for (int i = list_of_grbox.IndexOf(gr) + 1; i < list_of_grbox.Count; i++)
            {
                mainPanel.Controls.Remove(list_of_grbox[i]);
            }
            mainPanel.Controls.Add(gr);
            gr.Dock = DockStyle.Right;
            gr.SendToBack();
            list_of_grbox_dock.Add(gr);
            foreach (GroupBox uc in list_of_grbox_d)
            {
                uc.SendToBack();
            }
            pl.Dock = DockStyle.Fill;
            for (int i = list_of_grbox.IndexOf(gr) + 1; i < list_of_grbox.Count; i++)
            {
                mainPanel.Controls.Add(list_of_grbox[i]);
            }

            width_controls += gr.Width;
            change_width    = panel1.Width + width_controls + 6 - this.Width;
            change_height   = max_height_control - prev_max_height_control;

            speed = (Math.Abs(change_height) > Math.Abs(change_width)) ? Math.Abs(change_height) / delta_speed : Math.Abs(change_width) / delta_speed;
            if (speed < 3)
            {
                speed = 3;
            }
            timerr.Enabled = true;

            //this.Size = new Size(panel1.Width + width_controls, max_height_control + 45);
        }
Esempio n. 2
0
        public void AddNewElem(UserControl pl, string name)
        {
            if (showed_modal)
            {
                CloseModalElem();
            }
            list_of_controls.Insert(list_of_controls.Count, pl);//помещаем контрол в конец
            GroupBox gr = new GroupBox();

            list_of_grbox.Insert(list_of_grbox.Count, gr);

            gr.Size = new Size(pl.Width + 2, pl.Height);
            int prev_max_height_control = this.Height - 45;

            if (pl.Height > max_height_control)
            {
                //max_height_control = pl.Height;
                foreach (GroupBox ggr in list_of_grbox)
                {
                    //ggr.Height = pl.Height+10;
                }
            }
            else
            {
                gr.Height = max_height_control + 20;
            }
            gr.Text = name;
            gr.Left = width_controls + panel1.Width;
            //gr.BackColor = Color.Aquamarine;
            pl.Top  = 15;
            pl.Left = 0;

            if (!(pl is PanelGroup) && !(pl is TableEdit))
            {
                CloseButton but = new CloseButton(pl, this);
                but.Location = new Point(gr.Width - 20, 2);
                gr.Controls.Add(but);
            }

            mainPanel.Controls.Add(gr);
            gr.Dock = DockStyle.Right;

            gr.SendToBack();
            foreach (GroupBox uc in list_of_grbox_d)
            {
                uc.SendToBack();
            }
            list_of_grbox_dock.Add(gr);
            pl.Dock = DockStyle.Fill;
            gr.Controls.Add(pl);
            width_controls += gr.Width;

            change_width  = panel1.Width + width_controls + 6 - this.Width;
            change_height = max_height_control - prev_max_height_control;

            speed = (Math.Abs(change_height) > Math.Abs(change_width)) ? Math.Abs(change_height) / delta_speed : Math.Abs(change_width) / delta_speed;
            if (speed < 3)
            {
                speed = 3;
            }
            timerr.Enabled = true;

            //this.Size = new Size(panel1.Width + width_controls ,max_height_control+45);
        }