Esempio n. 1
0
        private void Setup_Panels()
        {
            if (IsNotSave())
            {
                return;
            }
            if (_panelMain == null)
            {
                // Lets try to get the main panel
                "No Main Panel assigned.".zOk();
                _formHost = UIDesigner_Service.IDesignerHost_FromComponent(this);
                var panels = UIDesigner_Tools.Host_Controls_All <Panel>(_formHost);
                foreach (Panel panel in panels)
                {
                    if (panel.Tag.ToString() == "MainPanel")
                    {
                        _panelMain = panel;
                    }
                }
                if (panels.Count == 0)
                {
                    Setup_PanelMain();
                }

                if (_panelMain == null)
                {
                    "Cannot change panels if Panel_Main is not assigned!".zOk();
                    return;
                }
            }
            UIDesigner_Generate.Form_PanelSetup(this, Panel_Setup, Panel_Main, out _panel1, out _panel2, out _panel3);
        }
Esempio n. 2
0
        private void comboBox_FormPanels_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_SetupFlag)
            {
                return;
            }

            // Convert to enum and set the component
            var formPanels = comboBox_FormPanels.Text;

            _designer.Panel_Setup = formPanels.zEnum_To_EnumValue <enForm_Panels>();

            // Get the panels
            var panelName = input_Panel1.Field_Value;

            if (listBox_Components.zListBox_SearchItem(panelName) == -1)
            {
                "Error! No panel selected!".zOk();
                return;
            }
            var panelMain = _ActiveComponent as Panel;

            if (panelMain == null)
            {
                "Error! Active control is not a panel.".zOk();
                return;
            }

            Panel panel1;
            Panel panel2;
            Panel panel3;

            UIDesigner_Generate.Form_PanelSetup(_designer, _designer.Panel_Setup, panelMain, out panel1, out panel2, out panel3);
        }
Esempio n. 3
0
        private void Setup_FormSize()
        {
            if (_Form_Startup)
            {
                return;                  // Prevent actions during construction
            }
            if (Form_Size == enForm_Size.Manual)
            {
                return;
            }
            if (_formName == null)
            {
                return;
            }

            UIDesigner_Generate.Form_Size(this, Form_Size);
        }
Esempio n. 4
0
        private void Setup_Reset()
        {
            if (IsNotSave())
            {
                return;
            }
            if ("This will remove all controls. Continue?".zDialog().MessageBox_YesNo() == false)
            {
                return;
            }

            UIDesigner_Generate.Form_PanelClear(this, Panel_Main, true);
            _panelMain = null;
            if ("Rebuild the main form?".zDialog().MessageBox_YesNo() == true)
            {
                Setup_();
            }
        }
Esempio n. 5
0
        /// <summary>Generates the controls on the designer panels.</summary>
        /// <param name="designer">The designer</param>
        /// <param name="classType">The class type</param>
        /// <param name="classAttribute">The class attributeuteibute</param>
        /// <param name="panel1">The panel1</param>
        /// <param name="panel2">The panel to setting. Default value = null.</param>
        /// <param name="panel3">The panel3 setting. Default value = null.</param>
        /// <param name="onValueChange">The on valueue change setting. Default value = null.</param>
        /// <returns>The height of the form should be</returns>
        public int Generate_Controls(IDesignerHost designer, Type classType, BlueprintData_TableAttribute classAttribute, Panel panel1, Panel panel2 = null, Panel panel3 = null, EventHandler <onInputControl_EventArgs> onValueChange = null)
        {
            Panel panel = null;

            if (panel1 == null)
            {
                "Error! Cannot generate controls if Panel_1 is unknown.".zOk();
                return(0);
            }

            // Find decorated properties for the class that is to be generated
            bool class_GenerateAllFields = (classAttribute == null) ? true : classAttribute.GenerateAllFields;

            // For class type, get all fields that was marked with BlueprintData_FieldAttribute
            Input_Control input = null;
            IList <Tuple <FieldInfo, BlueprintData_FieldAttribute> > fields = LamedalCore_.Instance.Types.Class.ClassAttributes.Find_Fields(classType, new BlueprintData_FieldAttribute());
            // List<Tuple<FieldInfo, Attribute>> fields = _dotNet.ClassAttribute.Field_FindAttributes(classType, typeof(BlueprintData_FieldAttribute), class_GenerateAllFields);
            dynamic defaultO = UIDesigner_Form.Create(classType);

            foreach (Tuple <FieldInfo, BlueprintData_FieldAttribute> field in fields)
            {
                // ===================================
                // Read all the definition information
                // ===================================
                FieldInfo fieldInfo  = field.Item1;
                object    value      = fieldInfo.GetValue(defaultO);
                string    fieldValue = value.zObject().AsStr();
                string    fieldName  = fieldInfo.Name;

                var fieldDefinition = field.Item2 as BlueprintData_FieldAttribute;
                if (fieldDefinition == null)
                {
                    if (class_GenerateAllFields)
                    {
                        fieldDefinition = new BlueprintData_FieldAttribute();
                    }
                    else
                    {
                        "Error! Field '{0}' does not have attribute BlueprintData_FieldAttribute.".zFormat(fieldName).zOk();
                        continue;  // <========================================================================================
                    }
                }
                if (fieldDefinition.IsVisible == false)
                {
                    continue;                                      // <=================================================
                }
                string fieldCaption = fieldDefinition.Caption;
                if (fieldCaption == "")
                {
                    fieldCaption = fieldName;
                }
                Type   fieldType        = fieldInfo.FieldType;
                string fieldDescription = fieldDefinition.Description;
                bool   fieldIsPassword  = fieldDefinition.IsPassword;
                bool   fieldIsRequired  = fieldDefinition.IsRequired;
                int    fieldValueMax    = fieldDefinition.ValueMax;
                int    fieldValueMin    = fieldDefinition.ValueMin;
                int    fieldLengthMax   = fieldDefinition.LengthMax;
                int    fieldLengthMin   = fieldDefinition.LengthMin;

                // Create the form for capturing values
                if (panel == null)
                {
                    panel = panel1;
                }
                input = UIDesigner_Generate.Create_Input(designer, panel, fieldName, fieldCaption, fieldType, fieldValue, onValueChange);
                // Set the panel
                if (panel == panel3)
                {
                    panel = panel1;
                }
                else if (panel == panel2)
                {
                    if (panel3 == null)
                    {
                        panel = panel1;
                    }
                    else
                    {
                        panel = panel3;
                    }
                }
                else if (panel == panel1)
                {
                    if (panel2 != null)
                    {
                        panel = panel2;
                    }
                }


                if (input != null)
                {
                    input.Field_Description = fieldDescription;
                }
            }

            if (input != null)
            {
                return(input.Top + input.Height + 80);
            }
            return(0);
        }