private void Event_OnEnterPressed_Handle(object sender, onInputControl_EventArgs e)
 {
     if (Event_OnEnterPressed != null)
     {
         e.Control_ = this;
         Event_OnEnterPressed(sender, e);
     }
 }
        private void Event_OnButtonClick_Handle(object sender, onInputControl_EventArgs e)
        {
            // Setup default event
            EventHandler <onInputControl_EventArgs> hookEvent = Event_OnActionButtonClick;
            var isButton = Input_Control_Tools.IsButton(_ControlType);

            if (isButton && hookEvent == null)
            {
                hookEvent = Event_OnValueChange;
            }

            // File Open Action Button
            if (Action_Custom == enControl_InputCustomAction.File_Open_Button)
            {
                // Get the button
                var button = sender as Button;
                if (button == null)
                {
                    return;
                }

                string path;
                if (button.Text.zDialogFile().File_OpenDialog(out path, _Path_Filter, _Path_FilterName))
                {
                    button.Text = path; // File open dialog
                }
                if (hookEvent == null)
                {
                    return;                    // -------------------------------------------
                }
            }

            // File Open Edit
            if (Action_Custom == enControl_InputCustomAction.File_Open_Edit)
            {
                string path;
                if (Field_Value.zDialogFile().File_OpenDialog(out path, _Path_FilterName, _Path_Filter))
                {
                    Field_Value = path; // File open dialog
                }
                if (hookEvent == null)
                {
                    return;                    // -------------------------------------------
                }
            }


            // Call Default Event Handler
            if (hookEvent == null)
            {
                hookEvent = _controller.Button_DefaultAction_Handle;                    // Default handle
            }
            // Fire Event
            e.Control_ = this;
            hookEvent(sender, e);
        }
Example #3
0
        private void input_Panel1_Event_OnActionButtonClick(object sender, onInputControl_EventArgs e)
        {
            var panel = _ActiveComponent as Panel;

            if (panel == null)
            {
                return;
            }

            input_Panel1.Field_Value = listBox_Components.Text;
            _designer.Panel_Main     = panel;
        }
Example #4
0
        private void OnValueChangeEvent(object sender, onInputControl_EventArgs e)
        {
            // Update the object from when the form values change
            Form      frm   = e.Control_.ParentForm;
            stateForm state = frm.zzState();

            if (state.DoEventsFlag == false)
            {
                return;                                // Events were stopped -> Exit <=========================================================
            }
            IObjectModel classObject = state.FormObjectModel;

            if (state.onValueChange != null)
            {
                state.onValueChange(sender, e);                                                  // Notify the client that the value has changed
            }
            Lamedal_WinForms.Instance.libUI.WinForms.FormGenerate.Form_ToObject(e, classObject); // Update the object in memory
            500.zExecute_Async(() => SyncFormAndObject(frm), "formRefresh", true);               // Sync the object back to the form in 1 sec
        }
Example #5
0
        /// <summary>
        /// Converts the generated form to object.
        /// </summary>
        /// <param name="e">The input event arguments control</param>
        /// <param name="Object">The object</param>
        public void Form_ToObject(onInputControl_EventArgs e, IObjectModel Object)
        {
            // Value on the form has changed -> update the object
            Input_Control input      = e.Control_;
            string        fieldName  = input.Field_Name;
            string        fieldValue = input.Field_Value;
            FieldInfo     fieldInfo  = Object.GetType().GetField(fieldName);
            Type          fieldType  = fieldInfo.FieldType;

            object value;

            if (fieldValue.zIsNullOrEmpty())
            {
                value = LamedalCore_.Instance.Types.Object.DefaultValue(fieldType);
            }
            else
            {
                value = LamedalCore_.Instance.Types.Object.CastTo(fieldValue, fieldType);
            }
            fieldInfo.SetValue(Object, value);
        }
        private void Event_OnValueChange_Handle(object sender, onInputControl_EventArgs e)
        {
            // Rules
            var thisIsCheckbox    = Input_Control_Tools.IsCheckbox(e.ControlType);
            var thisIsRadioButton = Input_Control_Tools.IsRadioButton(e.ControlType);

            if (thisIsCheckbox || thisIsRadioButton)
            {
                // Get controls
                var control = this.Parent;
                if (control != null)
                {
                    List <Component> controls = Components_FromControls(control.Controls, typeof(Input_Control));
                    foreach (var component in controls)
                    {
                        var input = component as Input_Control;
                        if (input == null)
                        {
                            continue;
                        }

                        #region Visible setting
                        if (input.VisibleSet_Control != null && input.VisibleSet_Control.Name == this.Name)
                        {
                            if (thisIsCheckbox)
                            {
                                if (input.VisibleSet_Index == 1)
                                {
                                    input.Visible = this.Field_Value1;
                                }
                                if (input.VisibleSet_Index == 2)
                                {
                                    input.Visible = this.Field_Value2;
                                }
                                if (input.VisibleSet_Index == 3)
                                {
                                    input.Visible = this.Field_Value3;
                                }
                            }
                            if (thisIsRadioButton)
                            {
                                if (input.VisibleSet_Index == 1)
                                {
                                    input.Visible = (this.Field_Value == "1");
                                }
                                if (input.VisibleSet_Index == 2)
                                {
                                    input.Visible = (this.Field_Value == "2");
                                }
                                if (input.VisibleSet_Index == 3)
                                {
                                    input.Visible = (this.Field_Value == "3");
                                }
                                if (input.VisibleSet_Index == 4)
                                {
                                    input.Visible = (this.Field_Value == "4");
                                }
                            }
                        }
                        #endregion

                        #region Enable setting
                        if (input.EnableSet_Control != null && input.EnableSet_Control.Name == this.Name)
                        {
                            if (thisIsCheckbox)
                            {
                                if (input.EnableSet_Index == 1)
                                {
                                    input.Enabled = this.Field_Value1;
                                }
                                if (input.EnableSet_Index == 2)
                                {
                                    input.Enabled = this.Field_Value2;
                                }
                                if (input.EnableSet_Index == 3)
                                {
                                    input.Enabled = this.Field_Value3;
                                }
                            }
                            if (thisIsRadioButton)
                            {
                                if (input.EnableSet_Index == 1)
                                {
                                    input.Enabled = (this.Field_Value == "1");
                                }
                                if (input.EnableSet_Index == 2)
                                {
                                    input.Enabled = (this.Field_Value == "2");
                                }
                                if (input.EnableSet_Index == 3)
                                {
                                    input.Enabled = (this.Field_Value == "3");
                                }
                                if (input.EnableSet_Index == 4)
                                {
                                    input.Enabled = (this.Field_Value == "4");
                                }
                            }
                        }
                        #endregion
                    }
                }
            }

            if (Event_OnValueChange != null)
            {
                e.Control_ = this;
                Event_OnValueChange(sender, e);
            }
        }
        /// <summary>
        /// Return the current Value.
        /// </summary>
        /// <param name="ctrl">The CTRL.</param>
        /// <param name="args">The <see cref="onInputControl_EventArgs"/> instance containing the event data.</param>
        /// <returns></returns>
        public object Value_Get(out Control ctrl, out onInputControl_EventArgs args)
        {
            object value  = null;
            bool   value1 = false;
            bool   value2 = false;
            bool   value3 = false;
            string text   = "";

            ctrl = null;
            switch (_ControlType)
            {
            case enControl_InputType.Edit:
                ctrl  = txtValue;
                value = txtValue.Text;
                break;

            case enControl_InputType.Edit_Masked:
                ctrl  = txtValueMasked;
                value = txtValueMasked.Text;
                break;

            case enControl_InputType.DateTime:
                ctrl  = dtpValue;
                value = dtpValue.Value;
                break;

            case enControl_InputType.Checkbox1:
                ctrl  = chkValue1;
                value = chkValue1.Checked;
                if (chkValue1.Checked)
                {
                    text = chkValue1.Text;
                }
                break;

            case enControl_InputType.Checkbox2:
                ctrl   = chkValue2;
                value1 = chkValue1.Checked;
                value2 = chkValue2.Checked;
                if (chkValue1.Checked)
                {
                    text += chkValue1.Text + ", ";
                }
                if (chkValue2.Checked)
                {
                    text += chkValue2.Text;
                }
                break;

            case enControl_InputType.Checkbox3:
                ctrl   = chkValue3;
                value1 = chkValue1.Checked;
                value2 = chkValue2.Checked;
                value3 = chkValue3.Checked;
                if (chkValue1.Checked)
                {
                    text += chkValue1.Text + ", ";
                }
                if (chkValue2.Checked)
                {
                    text += chkValue2.Text + ", ";
                }
                if (chkValue3.Checked)
                {
                    text += chkValue3.Text;
                }
                break;

            case enControl_InputType.RadioButton2:
                value = rdoValue1.Checked ? 1 : 2;
                text  = rdoValue1.Checked ? rdoValue1.Text : rdoValue2.Text;
                ctrl  = value.zObject().AsInt() == 1 ? rdoValue1 : rdoValue2;
                break;

            case enControl_InputType.RadioButton3:
                value = rdoValue1.Checked ? 1 : rdoValue2.Checked ? 2 : 3;
                text  = rdoValue1.Checked ? rdoValue1.Text : rdoValue2.Checked ? rdoValue2.Text : rdoValue3.Text;
                ctrl  = value.zObject().AsInt() == 1 ? rdoValue1 : value.zObject().AsInt() == 2 ? rdoValue2 : rdoValue3;
                break;

            case enControl_InputType.RadioButton4:
                value = rdoValue1.Checked ? 1 : rdoValue2.Checked ? 2 : rdoValue3.Checked ? 3 : 4;
                text  = rdoValue1.Checked ? rdoValue1.Text : rdoValue2.Checked ? rdoValue2.Text : rdoValue3.AutoCheck ? rdoValue3.Text : rdoValue4.Text;
                ctrl  = value.zObject().AsInt() == 1 ? rdoValue1 : value.zObject().AsInt() == 2 ? rdoValue2 : value.zObject().AsInt() == 3 ? rdoValue3 : rdoValue4;
                break;

            case enControl_InputType.Combobox:
                ctrl  = cboValue;
                value = cboValue.SelectedIndex;
                text  = cboValue.Text;
                break;

            case enControl_InputType.Listbox:
                ctrl  = lstValue;
                value = lstValue.SelectedIndex;
                text  = lstValue.Text;
                break;

            case enControl_InputType.Button1:
                ctrl  = btnValue1;
                value = btnValue1.Text;
                break;

            case enControl_InputType.Button2:
            case enControl_InputType.Button3:
                ctrl  = btnAction;
                value = btnAction.Text;
                break;

            default:
                var msg = "Control Type '" + _ControlType + "'not defined yet in Input_Control_Class.Value_Get()!";
                throw new ArgumentException(msg, nameof(_ControlType));
            }
            args = new onInputControl_EventArgs(_ControlType, value, text, value1, value2, value3);
            return(value);
        }