Beispiel #1
0
 private void SetControlType(ControlInformationHolder objProvidedProperties, Control ctl)
 {
     ctl.Click   += new EventHandler(this.CommonHandler);
     ctl.MouseUp += new MouseEventHandler(this.MouseUpHandler);
     ctl.KeyUp   += new KeyEventHandler(this.KeyUpHandler);
     objProvidedProperties.ControlType = ControlType.typeOther;
     if (ctl is TextBox)
     {
         objProvidedProperties.ControlType = ControlType.typeTextbox;
         TextBox box1 = (TextBox)ctl;
         box1.TextChanged += new EventHandler(this.CommonHandler);
     }
     else if (ctl is RichTextBox)
     {
         objProvidedProperties.ControlType = ControlType.typeRichTextBox;
         RichTextBox box2 = (RichTextBox)ctl;
         box2.TextChanged += new EventHandler(this.CommonHandler);
     }
     else if (ctl is ListBox)
     {
         objProvidedProperties.ControlType = ControlType.typeListBox;
         ListBox box3 = (ListBox)ctl;
         box3.TextChanged          += new EventHandler(this.CommonHandler);
         box3.SelectedValueChanged += new EventHandler(this.CommonHandler);
     }
     else if (ctl is ComboBox)
     {
         objProvidedProperties.ControlType = ControlType.typeComboBox;
         ComboBox box4 = (ComboBox)ctl;
         box4.TextChanged          += new EventHandler(this.CommonHandler);
         box4.SelectedValueChanged += new EventHandler(this.CommonHandler);
     }
     else if (ctl is RadioButton)
     {
         objProvidedProperties.ControlType = ControlType.typeRadioButton;
         RadioButton button1 = (RadioButton)ctl;
         button1.CheckedChanged += new EventHandler(this.CommonHandler);
     }
     else if (ctl is CheckBox)
     {
         objProvidedProperties.ControlType = ControlType.typeCheckBox;
         CheckBox box5 = (CheckBox)ctl;
         box5.CheckedChanged += new EventHandler(this.CommonHandler);
     }
     else if (ctl is DateTimePicker)
     {
         objProvidedProperties.ControlType = ControlType.typeDatePicker;
         DateTimePicker picker1 = (DateTimePicker)ctl;
         picker1.ValueChanged += new EventHandler(this.CommonHandler);
     }
     else if (ctl is MonthCalendar)
     {
         objProvidedProperties.ControlType = ControlType.typeMonthCalendar;
         MonthCalendar calendar1 = (MonthCalendar)ctl;
         calendar1.DateChanged += new DateRangeEventHandler(this.DateChangedHandler);
     }
     else
     {
         ctl.TextChanged += new EventHandler(this.CommonHandler);
     }
 }
Beispiel #2
0
        public void SetDirtyCheckingEnabled(Control ctrl, bool value)
        {
            if (value)
            {
                ControlInformationHolder obj = new ControlInformationHolder();
                if (this.colControlInformation[ctrl] == null)
                {
                    obj.DirtyCheckingEnabled = value;
                    this.colControlInformation.Add(ctrl, obj);
                }
                else
                {
                    obj = (ControlInformationHolder)this.colControlInformation[ctrl];
                    if (obj.DirtyCheckingEnabled == value)
                    {
                        return;
                    }
                    obj.DirtyCheckingEnabled = value;
                }
                this.SetControlType(obj, ctrl);
            }
            else if (!this.colControlInformation.Contains(ctrl))
            {
                ControlInformationHolder obj = new ControlInformationHolder();
                obj.DirtyCheckingEnabled = value;
                this.colControlInformation.Add(ctrl, obj);
            }
            else
            {
                ControlInformationHolder obj = new ControlInformationHolder();
                obj = (ControlInformationHolder)this.colControlInformation[ctrl];
                if (obj.DirtyCheckingEnabled)
                {
                    ctrl.Click   -= new EventHandler(this.CommonHandler);
                    ctrl.MouseUp -= new MouseEventHandler(this.MouseUpHandler);
                    ctrl.KeyUp   -= new KeyEventHandler(this.KeyUpHandler);
                    switch (obj.ControlType)
                    {
                    case ControlType.typeTextbox:
                    {
                        TextBox box5 = (TextBox)ctrl;
                        box5.TextChanged -= new EventHandler(this.CommonHandler);
                        break;
                    }

                    case ControlType.typeDatePicker:
                    {
                        DateTimePicker picker1 = (DateTimePicker)ctrl;
                        picker1.ValueChanged -= new EventHandler(this.CommonHandler);
                        break;
                    }

                    case ControlType.typeMonthCalendar:
                    {
                        MonthCalendar calendar1 = (MonthCalendar)ctrl;
                        calendar1.DateChanged -= new DateRangeEventHandler(this.DateChangedHandler);
                        break;
                    }

                    case ControlType.typeRadioButton:
                    {
                        RadioButton button1 = (RadioButton)ctrl;
                        button1.CheckedChanged -= new EventHandler(this.CommonHandler);
                        break;
                    }

                    case ControlType.typeCheckBox:
                    {
                        CheckBox box3 = (CheckBox)ctrl;
                        box3.CheckedChanged -= new EventHandler(this.CommonHandler);
                        break;
                    }

                    case ControlType.typeListBox:
                    {
                        ListBox box2 = (ListBox)ctrl;
                        box2.TextChanged          -= new EventHandler(this.CommonHandler);
                        box2.SelectedValueChanged -= new EventHandler(this.CommonHandler);
                        break;
                    }

                    case ControlType.typeComboBox:
                    {
                        ComboBox box1 = (ComboBox)ctrl;
                        box1.TextChanged          -= new EventHandler(this.CommonHandler);
                        box1.SelectedValueChanged -= new EventHandler(this.CommonHandler);
                        break;
                    }

                    case ControlType.typeRichTextBox:
                    {
                        RichTextBox box4 = (RichTextBox)ctrl;
                        box4.TextChanged -= new EventHandler(this.CommonHandler);
                        break;
                    }
                    }
                }
                obj.DirtyCheckingEnabled = value;
            }
        }
Beispiel #3
0
        private bool FieldIsDirty(ControlInformationHolder objField, Control ctl)
        {
            bool bReturn = false;

            if (!this.m_bDirtyCheckingStarted)
            {
                return(false);
            }
            if (!objField.DirtyCheckingEnabled)
            {
                return(false);
            }
            switch (objField.ControlType)
            {
            case ControlType.typeTextbox:
            {
                if (String.Compare(objField.StringValue, ctl.Text, false) == 0)
                {
                    return(false);
                }
                return(true);
            }

            case ControlType.typeDatePicker:
            {
                DateTimePicker picker1 = (DateTimePicker)ctl;
                if ((objField.BooleanValue == picker1.Checked) && (String.Compare(objField.StringValue, picker1.Value.ToLongDateString(), false) == 0))
                {
                    return(false);
                }
                return(true);
            }

            case ControlType.typeMonthCalendar:
            {
                MonthCalendar calendar1 = (MonthCalendar)ctl;
                if ((DateTime.Compare(objField.DateValue, calendar1.SelectionStart) == 0) & (DateTime.Compare(objField.EndDateValue, calendar1.SelectionEnd) == 0))
                {
                    return(false);
                }
                return(true);
            }

            case ControlType.typeRadioButton:
            {
                RadioButton button1 = (RadioButton)ctl;
                if (objField.BooleanValue == button1.Checked)
                {
                    return(false);
                }
                return(true);
            }

            case ControlType.typeCheckBox:
            {
                CheckBox box1 = (CheckBox)ctl;
                if ((objField.CheckStateValue == box1.CheckState) && (objField.BooleanValue == box1.Checked))
                {
                    return(false);
                }
                return(true);
            }

            case ControlType.typeListBox:
            {
                ListBox box3 = (ListBox)ctl;
                if (box3.SelectionMode != SelectionMode.One)
                {
                    string text1 = this.ConstructIndices(box3);
                    if (String.Compare(objField.StringValue, text1, false) == 0)
                    {
                        return(false);
                    }
                    return(true);
                }
                if (objField.IntegerValue == box3.SelectedIndex)
                {
                    return(false);
                }
                return(true);
            }

            case ControlType.typeComboBox:
            {
                ComboBox box2 = (ComboBox)ctl;
                if (box2.DropDownStyle != ComboBoxStyle.DropDownList)
                {
                    if (String.Compare(objField.StringValue, box2.Text, false) == 0)
                    {
                        return(false);
                    }
                    return(true);
                }
                if (objField.IntegerValue == box2.SelectedIndex)
                {
                    return(false);
                }
                return(true);
            }

            case ControlType.typeRichTextBox:
            {
                RichTextBox box4 = (RichTextBox)ctl;
                if (objField.IntegerValue == (box4.Text + box4.Rtf).GetHashCode())
                {
                    return(false);
                }
                return(true);
            }

            case ControlType.typeOther:
            {
                if (DirtyChecker.CustomIsDirtyContainer != null)
                {
                    if (DirtyChecker.CustomIsDirtyContainer.ControlSupported(ctl))
                    {
                        return(DirtyChecker.CustomIsDirtyContainer.CustomIsDirty(ctl));
                    }
                    if (String.Compare(objField.StringValue, ctl.Text, false) == 0)
                    {
                        return(false);
                    }
                    return(true);
                }
                if (String.Compare(objField.StringValue, ctl.Text, false) == 0)
                {
                    return(false);
                }
                return(true);
            }
            }

            return(bReturn);
        }