Example #1
0
        private void treeDesignMenuItem_Click(object sender, EventArgs e)
        {
            //Блок, на который кликнули
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            ContextMenuStrip  cms  = (ContextMenuStrip)(item.GetCurrentParent());
            Control           btn  = cms.SourceControl;

            //Ищем родительскую панель
            Control parent = btn;

            while (!(parent is Panel || parent is TableLayoutPanel ||
                     parent is UserControl || parent is Form))
            {
                parent = parent.Parent;
            }

            //ФОрма с дизйном блока
            Admin.BlockDesignForm f = new Admin.BlockDesignForm(btn);
            f.ShowDialog();
            Admin.AdminDesignForm.ApplyDesign(this);
        }
Example #2
0
        /// <summary>
        /// ЧТение дизайна блока из БД
        /// </summary>
        public static void ReadBlockDesign(Control block)
        {
            //Ищем родительскую форму/UserControl
            Control parent = block;

            while (!(parent is Form || parent is UserControl))
            {
                parent = parent.Parent;
            }


            //Размеры
            try
            {
                string width  = BlockDesignForm.SelectBlockParam("WIDTH", block, parent);
                string height = BlockDesignForm.SelectBlockParam("HEIGHT", block, parent);

                int Width  = Convert.ToInt32(width);
                int Height = Convert.ToInt32(height);


                //Ищем родительскую панель
                Control parent2 = block;
                while (!(parent2 is Panel || parent2 is TableLayoutPanel ||
                         parent2 is UserControl || parent2 is Form))
                {
                    parent2 = parent2.Parent;
                }



                //Применяем дизайн
                if (parent2 is TableLayoutPanel)
                {
                    try
                    {
                        //ТейблПанель, на которой дерево лежит
                        TableLayoutPanel             b   = (TableLayoutPanel)parent2;
                        TableLayoutPanelCellPosition pos = b.GetPositionFromControl(block);

                        //Применяем дизайн
                        b.ColumnStyles[pos.Column].Width = Width;
                        b.RowStyles[pos.Row].Height      = Height;
                    }
                    catch (Exception) { }
                }
                else
                {
                    try
                    {
                        parent2.Size = new Size(Width, Height);
                    }
                    catch (Exception) { }
                }
            }
            catch (Exception) { }

            //Соцсети
            if (block.Name == "SocialUC")
            {
                try
                {
                    UserControls.SocialUC social = (UserControls.SocialUC)block;

                    social.VKPictureBox.Visible = false;
                    string vk = BlockDesignForm.SelectBlockParam("VK", block, parent);
                    social.VKPictureBox.Visible = (vk == "1");

                    social.InstaPictureBox.Visible = false;
                    string insta = BlockDesignForm.SelectBlockParam("Insta", block, parent);
                    social.InstaPictureBox.Visible = (insta == "1");
                }
                catch (Exception) { }
            }
        }