예제 #1
0
        /// <summary>
        /// Remove all controls from the main panel and rebuild all.
        /// </summary>
        /// <param name="designer">The designer</param>
        /// <param name="panelMain">The panel main</param>
        /// <param name="clearAll">if set to <c>true</c> [clear all].</param>
        public static void Form_PanelClear(Component designer, Panel panelMain, bool clearAll = false)
        {
            IDesignerHost host = UIDesigner_Service.IDesignerHost_FromComponent(designer);

            if (panelMain == null)
            {
                clearAll = true;
            }
            if (host == null)
            {
                panelMain.Controls.Clear(); // It was called from runtime
            }
            else
            {
                List <Control> controls = (clearAll) ? UIDesigner_Tools.Host_Controls_All(host) : panelMain.Controls.Cast <Control>().ToList();
                foreach (Control control in controls)
                {
                    if (control is Form)
                    {
                        continue;
                    }
                    host.DestroyComponent(control);
                }
            }
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <summary>Indicates that a comonents value is in the process of changing.</summary>
        public static void Change_Begin(DesignerActionList designer)
        {
            IComponentChangeService service = UIDesigner_Service.IComponentChangeService_FromActionList(designer);

            if (service != null)
            {
                service.OnComponentChanging(designer, null);
            }
        }
예제 #4
0
        /// <summary>Set the selected controls.</summary>
        public static void Host_Controls_SelectedSet(IDesignerHost host, List <Control> controls)
        {
            if (host == null)
            {
                return;
            }

            ISelectionService selService = UIDesigner_Service.ISelectionService_FromHost(host);

            selService.SetSelectedComponents(controls);
        }
예제 #5
0
        /// <summary>Return the selected controls.</summary>
        public static List <Control> Host_Controls_Selected(IDesignerHost host)
        {
            if (host == null)
            {
                return(null);
            }

            ISelectionService selectionService = UIDesigner_Service.ISelectionService_FromHost(host);

            return(selectionService.GetSelectedComponents().OfType <Control>().ToList());
        }
예제 #6
0
        /// <summary>Set the selected controls.</summary>
        public static void Host_Controls_SelectedSet1(IDesignerHost host, Component control)
        {
            if (host == null)
            {
                return;
            }

            ISelectionService selService = UIDesigner_Service.ISelectionService_FromHost(host);
            var controls = new List <Component>();

            controls.Add(control);
            selService.SetSelectedComponents(controls);
        }
예제 #7
0
        private static void Create_Event(IDesignerHost host, Input_Control input, string eventName, string eventMethodName)
        {
            IEventBindingService      eventBindingService = UIDesigner_Service.IEventBindingService_FromHost(host);
            EventDescriptorCollection eventColl           = TypeDescriptor.GetEvents(input, new Attribute[0]);

            if (eventColl != null)
            {
                var eventDescriptor = eventColl[eventName] as EventDescriptor;
                if (eventDescriptor != null)
                {
                    PropertyDescriptor propertyDescriptor = eventBindingService.GetEventProperty(eventDescriptor);
                    propertyDescriptor.SetValue(input, eventMethodName);
                }
            }
        }
예제 #8
0
        /// <summary>Return the selected controls.</summary>
        public static void Host_Controls_SelectionChange(IDesignerHost host, EventHandler selectionChanged, bool remove = false)
        {
            if (host == null)
            {
                return;
            }

            ISelectionService selService = UIDesigner_Service.ISelectionService_FromHost(host);

            selService.SelectionChanged -= selectionChanged;
            if (remove == false)
            {
                selService.SelectionChanged += selectionChanged;
            }
        }
예제 #9
0
        /// <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;
            }
        }
예제 #10
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
            }
        }