コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        public void Control_Type(enControl_InputType type = enControl_InputType.Edit, int rows = 1, bool actionButton = false)
        {
            #region Reset previous settings
            pAction_Button  = actionButton;
            lblName.Visible = true;
            if (actionButton)
            {
                Control_Columns(3);
            }
            else
            {
                Control_Columns();
            }

            if (type == enControl_InputType.Listbox)
            {
                if (rows < 3)
                {
                    rows = 3;                                                 // Listbox must be at least 3 rows
                }
            }
            Control_Rows(rows);           // Set the hight

            if (txtValue != null)
            {
                txtValue.Visible = false;
            }
            if (txtValueMasked != null)
            {
                txtValueMasked.Visible = false;
            }
            if (cboValue != null)
            {
                cboValue.Visible = false;
            }
            if (lstValue != null)
            {
                lstValue.Visible = false;
            }
            if (dtpValue != null)
            {
                dtpValue.Visible = false;
            }
            if (btnAction != null)
            {
                btnAction.Text = "..";
            }
            if (btnValue1 != null)
            {
                btnValue1.Visible = false;
            }
            if (btnValue2 != null)
            {
                btnValue2.Visible = false;
            }
            if (chkValue1 != null)
            {
                chkValue1.Visible = false;
            }
            if (chkValue2 != null)
            {
                chkValue2.Visible = false;
            }
            if (chkValue3 != null)
            {
                chkValue3.Visible = false;
            }
            if (rdoValue1 != null)
            {
                rdoValue1.Visible = false;
            }
            if (rdoValue2 != null)
            {
                rdoValue2.Visible = false;
            }
            if (rdoValue3 != null)
            {
                rdoValue3.Visible = false;
            }
            if (rdoValue4 != null)
            {
                rdoValue4.Visible = false;
            }
            lblName.Text = Control_Caption;
            #endregion

            // Edit
            if (type == enControl_InputType.Edit)
            {
                Input_Control_Tools.Create_TextBox(pnlText, ref txtValue, Handle_OnValueChange, Handle_KeyPress);
                txtValue.Visible = true;
                if (_ControlType == enControl_InputType.Edit_Masked)
                {
                    txtValue.Text = txtValueMasked.Text;
                }
            }

            // Edit_Masked
            if (type == enControl_InputType.Edit_Masked)
            {
                Input_Control_Tools.Create_TextboxMasked(pnlText, ref txtValueMasked, Handle_OnValueChange, Handle_KeyPress);
                txtValueMasked.Visible = true;
                if (_ControlType == enControl_InputType.Edit)
                {
                    txtValueMasked.Text = txtValue.Text;
                }
            }

            // Combobox
            if (type == enControl_InputType.Combobox)
            {
                Input_Control_Tools.Create_Combobox(pnlText, ref cboValue, Handle_OnValueChange);
                cboValue.Visible = true;
                if (_ControlType == enControl_InputType.Listbox)
                {
                    lstValue.Items.zTo_IList(cboValue.Items);                                              //cboValue.Items.zFrom_List(lstValue.Items, true);
                }
            }

            // Listbox
            if (type == enControl_InputType.Listbox)
            {
                Input_Control_Tools.Create_Listbox(pnlText, ref lstValue, Handle_OnValueChange);
                lstValue.Visible = true;
                if (_ControlType == enControl_InputType.Combobox)
                {
                    cboValue.Items.zTo_IList(lstValue.Items);                                               //lstValue.Items.zFrom_List(cboValue.Items, true);
                }
            }

            // DateTime
            if (type == enControl_InputType.DateTime)
            {
                Input_Control_Tools.Create_DateTimePicker(pnlText, ref dtpValue, Handle_OnValueChange);
                dtpValue.Visible = true;
            }

            #region Button
            if (type == enControl_InputType.Button1 || type == enControl_InputType.Button2 || type == enControl_InputType.Button3)
            {
                Input_Control_Tools.Create_Button1(pnlLabel, ref btnValue1, Handle_Button_Click);
                btnValue1.Text = _Control_Caption;
                Control_Columns(1);
                //pnlLabel.Visible =
                pnlLabel.Dock     = DockStyle.Fill;
                lblName.Visible   = false;
                btnValue1.Visible = true;
                // Button2
                if (type == enControl_InputType.Button2 || type == enControl_InputType.Button3)
                {
                    Input_Control_Tools.Create_Button2(pnlText, ref btnValue2, Handle_Button_Click);
                    btnValue2.Text = _Control_Caption2;
                    Control_Columns(2, enControl_InputWidth.Centre);
                    if (actionButton)
                    {
                        pnlButton.Visible = true;
                    }
                    lblName.Visible   = false;
                    btnValue2.Visible = true;
                }

                // Button3
                if (type == enControl_InputType.Button3)
                {
                    Control_Columns(3, enControl_InputWidth.Thirds);
                    btnAction.Text    = _Control_Caption3;
                    pnlButton.Visible = true;
                    lblName.Visible   = false;
                    btnAction.Visible = true;
                }
            }
            #endregion

            #region Checkbox
            if (type == enControl_InputType.Checkbox1 || type == enControl_InputType.Checkbox2 || type == enControl_InputType.Checkbox3)
            {
                Input_Control_Tools.Create_Checkbox(pnlLabel, ref chkValue1, _Control_Caption, Handle_OnValueChange);
                chkValue1.Text = _Control_Caption;
                chkValue1.Name = "chkValue1";
                Control_Columns(1);
                pnlLabel.Dock     = DockStyle.Fill;
                lblName.Visible   = false;
                chkValue1.Visible = true;
                if (type == enControl_InputType.Checkbox2 || type == enControl_InputType.Checkbox3)
                {
                    Input_Control_Tools.Create_Checkbox(pnlLabel, ref chkValue2, _Control_Caption2, Handle_OnValueChange);
                    chkValue2.Text    = _Control_Caption2;
                    chkValue2.Name    = "chkValue2";
                    chkValue2.Visible = true;
                }
                if (type == enControl_InputType.Checkbox3)
                {
                    Input_Control_Tools.Create_Checkbox(pnlLabel, ref chkValue3, _Control_Caption3, Handle_OnValueChange);
                    chkValue2.Text    = _Control_Caption2;
                    chkValue3.Text    = _Control_Caption3;
                    chkValue3.Name    = "chkValue3";
                    chkValue3.Visible = true;
                }
                chkValue1.SendToBack();
                if (chkValue3 != null)
                {
                    chkValue3.BringToFront();
                }
                if (actionButton)
                {
                    pnlButton.Visible = true;
                }
            }
            #endregion

            #region RadioButton
            if (type == enControl_InputType.RadioButton2 || type == enControl_InputType.RadioButton3 || type == enControl_InputType.RadioButton4)
            {
                Input_Control_Tools.Create_RadioButton(pnlLabel, ref rdoValue1, _Control_Caption, Handle_OnValueChange);
                Input_Control_Tools.Create_RadioButton(pnlLabel, ref rdoValue2, _Control_Caption2, Handle_OnValueChange);

                Control_Columns(1);
                pnlLabel.Dock     = DockStyle.Fill;
                lblName.Visible   = false;
                rdoValue1.Text    = _Control_Caption;
                rdoValue2.Text    = _Control_Caption2;
                rdoValue1.Visible = true;
                rdoValue2.Visible = true;
                rdoValue1.Name    = "rdoValue1";
                rdoValue2.Name    = "rdoValue2";

                rdoValue1.SendToBack();
                if (type == enControl_InputType.RadioButton3 || type == enControl_InputType.RadioButton4)
                {
                    Input_Control_Tools.Create_RadioButton(pnlLabel, ref rdoValue3, _Control_Caption3, Handle_OnValueChange);
                    rdoValue3.Text    = _Control_Caption3;
                    rdoValue3.Visible = true;
                    rdoValue3.Name    = "rdoValue3";
                    rdoValue3.BringToFront();
                }
                if (type == enControl_InputType.RadioButton4)
                {
                    Input_Control_Tools.Create_RadioButton(pnlLabel, ref rdoValue4, _Control_Caption4, Handle_OnValueChange);
                    rdoValue4.Text    = _Control_Caption4;
                    rdoValue4.Visible = true;
                    rdoValue4.Name    = "rdoValue4";
                    rdoValue4.BringToFront();
                }
                if (actionButton)
                {
                    pnlButton.Visible = true;
                }
            }
            #endregion

            pnlBorder.Invalidate();
            _ControlType = type;
        }