/// <summary> /// Return the main form for the component. It is important to delay the loading of this /// </summary> /// <param name="component">The component</param> /// <returns></returns> public static Form Form_Main(Component component) { var host = UIDesigner_Service.IDesignerHost_FromComponent(component); var form = UIDesigner_Tools.Host_Controls_Form(host); return(form); }
/// <summary> /// Setups the form. /// </summary> /// <param name="designer">The designer.</param> /// <param name="formSize">Size of the form.</param> /// <param name="panelMain">The panel main.</param> public static void Form_Size(Component designer, enForm_Size formSize, Panel panelMain = null) { IDesignerHost host = UIDesigner_Service.IDesignerHost_FromComponent(designer); Form form = null; if (host == null) { if (panelMain == null) { "Error! Main panel can not be null.".zOk(); return; } form = panelMain.FindForm(); } else { form = UIDesigner_Tools.Host_Controls_Form(host); } if (form == null) { "Error! Unable to identify main form!".zOk(); return; } // Setup the form sizes var formHeight = formSize.zAttribute_AsInt(); //int value, formHeight; //if (formSize.zValue_AsInt(out value, out formHeight) == false) //{ // // enumValue_Attribute not setup // ("Error! enumValue_Attribute not setup for '{0}'".zFormat(formSize.ToString())).zOk(); // return; //} if (form.Height > formHeight || form.Height < formHeight - 50) { form.Height = formHeight; } }
/// <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 } }