Exemplo n.º 1
0
        public Form Form_Generate(object classObject, EventHandler <onInputControl_EventArgs> onValueChange = null, enForm_Panels panels = enForm_Panels.OnePanel)
        {
            var model = classObject as IObjectModel;

            return(Form_Generate(model, onValueChange: onValueChange, panels: panels));
        }
Exemplo n.º 2
0
        /// <summary>Generates the controls on the designer panels.</summary>
        /// <param name="classObject">The class objectect</param>
        /// <param name="onValueChange">The on valueue change setting. Default value = null.</param>
        /// <param name="panels">The panels setting. Default value = OnePanel.</param>
        /// <returns>Form</returns>
        public Form Form_Generate(IObjectModel classObject, EventHandler <onInputControl_EventArgs> onValueChange = null, enForm_Panels panels = enForm_Panels.OnePanel)
        {
            BlueprintData_TableAttribute attribute;

            LamedalCore_.Instance.Types.Class.ClassAttributes.Find_Class(classObject.GetType(), out attribute, new BlueprintData_TableAttribute());
            if (attribute != null)
            {
                panels = (enForm_Panels)attribute.TotalPanels;
            }


            if (panels == enForm_Panels.OnePanel)   // Create form with 1 panel
            {
                var frmDialog1 = new Form_ClassDialog1();
                if (Generate_Controls(frmDialog1, classObject, frmDialog1.panel2, onValueChange: onValueChange))
                {
                    return(frmDialog1);
                }
            }
            if (panels == enForm_Panels.TwoPanels)  // Create form with 2 panels
            {
                var frmDialog2 = new Form_ClassDialog2();
                if (Generate_Controls(frmDialog2, classObject, frmDialog2.panel2, frmDialog2.panel3, onValueChange: onValueChange))
                {
                    return(frmDialog2);
                }
            }
            if (panels == enForm_Panels.TreePanels)   // Create form with 3 panels
            {
                var frmDialog3 = new Form_ClassDialog3();
                if (Generate_Controls(frmDialog3, classObject, frmDialog3.panel2, frmDialog3.panel3, frmDialog3.panel4, onValueChange))
                {
                    return(frmDialog3);
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Panels generates the form.
        /// </summary>
        /// <param name="designer">The designer</param>
        /// <param name="panels">The e form panels</param>
        /// <param name="panelMain">The panel main</param>
        /// <param name="panel1">Return the panel1</param>
        /// <param name="panel2">Return the panel to</param>
        /// <param name="panel3">Return the panel3</param>
        /// <param name="showMsg">if set to <c>true</c> [show MSG].</param>
        public static void Form_PanelSetup(Component designer, enForm_Panels panels, Panel panelMain,
                                           out Panel panel1, out Panel panel2, out Panel panel3, bool showMsg = true)
        {
            panel1 = null; panel2 = null; panel3 = null;

            if (panels == enForm_Panels.Custom)
            {
                return;                                  // Do nothing
            }
            if (showMsg)
            {
                string warningMsg = "The form will be cleared of all controls and rebuild! Continue?";
                if (warningMsg.zDialog().MessageBox_YesNo() == false)
                {
                    return;
                }
            }

            IDesignerHost host = UIDesigner_Service.IDesignerHost_FromComponent(designer);
            Form          form = null;

            if (host == null)
            {
                if (panelMain == null)
                {
                    return;
                }
                form = panelMain.FindForm();
            }
            else
            {
                form = UIDesigner_Tools.Host_Controls_Form(host);
            }
            if (form == null)
            {
                "Error! Unable to identify main form!".zOk();
                return;
            }

            var formWidth = panels.zAttribute_AsInt();

            //int value, formWidth;
            //if (panels.zAttribute_AsInt(out value, out formWidth) == false)
            //{
            //    // enumValue_Attribute not setup
            //    ("Error! enumValue_Attribute not setup for '{0}'".zFormat(panels.ToString())).zOk();
            //    return;
            //}

            if (form.Width > formWidth || form.Width < formWidth - 50)
            {
                form.Width = formWidth;
            }

            // Remove all controls from the main panel and rebuild all
            Form_PanelClear(designer, panelMain, false);

            // Build the new panels
            if (panels == enForm_Panels.OnePanel)
            {
                panel1 = Create_Panel(host, panelMain, DockStyle.Fill);
            }
            else if (panels == enForm_Panels.TwoPanels)
            {
                panel1 = Create_Panel(host, panelMain, DockStyle.Left);
                panel2 = Create_Panel(host, panelMain, DockStyle.Fill);
            }
            else if (panels == enForm_Panels.TreePanels)
            {
                panel1 = Create_Panel(host, panelMain, DockStyle.Left);
                panel2 = Create_Panel(host, panelMain, DockStyle.Left);
                panel3 = Create_Panel(host, panelMain, DockStyle.Fill);
            }
            else if (panels == enForm_Panels.Custom)
            {
                // Do Nothing
            }
        }