Ejemplo n.º 1
0
        public override void BeginEdit()
        {
            this.Value = this.initialValue;

            base.BeginEdit();

            //This is need to always make selected the first part ot date mask when the editor is opened
            RadDateTimePickerElement  editor           = (RadDateTimePickerElement)this.EditorElement;
            RadTextBoxElement         textBoxElement   = editor.TextBoxElement;
            RadDateTimePickerCalendar dateTimeBehavior = editor.CurrentBehavior as RadDateTimePickerCalendar;

            editor.TextBoxElement.TextBoxItem.HostedControl.Focus();
            editor.TextBoxElement.TextBoxItem.SelectionStart  = 0;
            editor.TextBoxElement.TextBoxItem.SelectionLength = 1;

            if (dateTimeBehavior != null)
            {
                dateTimeBehavior.DropDownMinSize = new Size(editor.Size.Width, 200);
                RadMaskedEditBoxElement maskTextBox = editor.TextBoxElement as RadMaskedEditBoxElement;
                MaskDateTimeProvider    maskHandler = (MaskDateTimeProvider)maskTextBox.Provider;
                maskHandler.SelectFirstEditableItem();
                this.selectedItemIndex = maskHandler.SelectedItemIndex;
                //int lastCaretPos = maskHandler.;
                //int lastSelectionPos = maskHandler.SelectionPosition;
                //while (maskHandler.SelectionPosition >= 0)
                //{
                //    lastSelectionPos = maskHandler.SelectionPosition;
                //    maskHandler.HandleLeftKey();
                //    if (lastSelectionPos == maskHandler.SelectionPosition)
                //        break;
                //}
                //this.selectedItemIndex = maskHandler.SelectedFormatInfoIndex;
                //maskTextBox.SelectionLength = maskHandler.SelectionLength;

                dateTimeBehavior.PopupControl.Opened += new EventHandler(PopupControl_Opened);
                dateTimeBehavior.PopupControl.Closed += new RadPopupClosedEventHandler(PopupControl_Closed);
                dateTimeBehavior.Calendar.CalendarElement.CalendarStatusElement.ClearButton.Click += new EventHandler(ClearButton_Click);
                dateTimeBehavior.Calendar.CalendarElement.CalendarStatusElement.TodayButton.Click += new EventHandler(TodayButton_Click);

                if (editor.Value == editor.NullDate)
                {
                    maskTextBox.Text = String.Empty;
                }
            }

            editor.NotifyParentOnMouseInput = false;
            editor.BackColor      = Color.White;
            editor.ValueChanging += new ValueChangingEventHandler(RadDateTimeEditor_ValueChanging);
            editor.ValueChanged  += new EventHandler(RadDateTimeEditor_ValueChanged);

            if (textBoxElement != null)
            {
                textBoxElement.KeyDown += new KeyEventHandler(TextBoxElement_KeyDown);
            }
        }
Ejemplo n.º 2
0
        public override void BeginEdit()
        {
            this.Value = this.initialValue;
            base.BeginEdit();
            RadDateTimePickerElement  editorElement   = (RadDateTimePickerElement)this.EditorElement;
            RadTextBoxElement         textBoxElement1 = (RadTextBoxElement)editorElement.TextBoxElement;
            RadDateTimePickerCalendar currentBehavior = editorElement.CurrentBehavior as RadDateTimePickerCalendar;

            editorElement.TextBoxElement.TextBoxItem.SelectAll();
            editorElement.TextBoxElement.TextBoxItem.HostedControl.Focus();
            if (currentBehavior != null)
            {
                currentBehavior.DropDownMinSize = new Size(editorElement.Size.Width, 200);
                RadMaskedEditBoxElement textBoxElement2 = editorElement.TextBoxElement;
                MaskDateTimeProvider    provider        = (MaskDateTimeProvider)textBoxElement2.Provider;
                if (editorElement.TextBoxElement.MaskType != MaskType.FreeFormDateTime)
                {
                    provider.SelectFirstEditableItem();
                }
                this.selectedItemIndex = provider.SelectedItemIndex;
                currentBehavior.PopupControl.Opened += new EventHandler(this.PopupControl_Opened);
                currentBehavior.PopupControl.Closed += new RadPopupClosedEventHandler(this.PopupControl_Closed);
                currentBehavior.Calendar.CalendarElement.CalendarStatusElement.ClearButton.Click += new EventHandler(this.ClearButton_Click);
                currentBehavior.Calendar.CalendarElement.CalendarStatusElement.TodayButton.Click += new EventHandler(this.TodayButton_Click);
                DateTime?nullable = editorElement.Value;
                DateTime nullDate = editorElement.NullDate;
                if ((!nullable.HasValue ? 0 : (nullable.GetValueOrDefault() == nullDate ? 1 : 0)) != 0)
                {
                    textBoxElement2.Text = string.Empty;
                }
            }
            editorElement.NotifyParentOnMouseInput = false;
            if (!RadTextBoxEditor.IsDarkTheme(this.OwnerElement))
            {
                int num = (int)editorElement.SetDefaultValueOverride(VisualElement.BackColorProperty, (object)Color.White);
            }
            editorElement.ValueChanging += new ValueChangingEventHandler(this.RadDateTimeEditor_ValueChanging);
            editorElement.ValueChanged  += new EventHandler(this.RadDateTimeEditor_ValueChanged);
            if (textBoxElement1 != null)
            {
                textBoxElement1.KeyDown += new KeyEventHandler(this.TextBoxElement_KeyDown);
                textBoxElement1.KeyUp   += new KeyEventHandler(this.textBoxElement_KeyUp);
            }
            if (editorElement.ElementTree != null)
            {
                RadControl control = editorElement.ElementTree.Control as RadControl;
                if (control != null && control.ThemeName == "TelerikMetroTouch" || ThemeResolutionService.ApplicationThemeName == "TelerikMetroTouch")
                {
                    editorElement.CalendarSize = new Size(300, 300);
                }
            }
            this.isValidated = false;
        }
Ejemplo n.º 3
0
        public override void BeginEdit()
        {
            base.BeginEdit();
            RadDateTimePickerElement  editorElement   = (RadDateTimePickerElement)this.EditorElement;
            RadTextBoxElement         textBoxElement1 = (RadTextBoxElement)editorElement.TextBoxElement;
            RadDateTimePickerCalendar currentBehavior = editorElement.CurrentBehavior as RadDateTimePickerCalendar;

            editorElement.TextBoxElement.TextBoxItem.HostedControl.Focus();
            editorElement.TextBoxElement.TextBoxItem.SelectionStart  = 0;
            editorElement.TextBoxElement.TextBoxItem.SelectionLength = 1;
            if (currentBehavior != null)
            {
                currentBehavior.DropDownMinSize = new Size(editorElement.Size.Width, 200);
                RadMaskedEditBoxElement textBoxElement2 = editorElement.TextBoxElement;
                MaskDateTimeProvider    provider        = (MaskDateTimeProvider)textBoxElement2.Provider;
                provider.SelectFirstEditableItem();
                this.selectedItemIndex = provider.SelectedItemIndex;
                currentBehavior.PopupControl.Opened += new EventHandler(this.PopupControl_Opened);
                currentBehavior.PopupControl.Closed += new RadPopupClosedEventHandler(this.PopupControl_Closed);
                currentBehavior.Calendar.CalendarElement.CalendarStatusElement.ClearButton.Click += new EventHandler(this.ClearButton_Click);
                currentBehavior.Calendar.CalendarElement.CalendarStatusElement.TodayButton.Click += new EventHandler(this.TodayButton_Click);
                DateTime?nullable = editorElement.Value;
                DateTime nullDate = editorElement.NullDate;
                if ((!nullable.HasValue ? 0 : (nullable.GetValueOrDefault() == nullDate ? 1 : 0)) != 0)
                {
                    textBoxElement2.Text = string.Empty;
                }
            }
            editorElement.NotifyParentOnMouseInput = false;
            if (!BaseTextBoxEditor.IsDarkTheme(this.OwnerElement))
            {
                int num = (int)editorElement.SetDefaultValueOverride(VisualElement.BackColorProperty, (object)Color.White);
            }
            editorElement.ValueChanging += new ValueChangingEventHandler(this.RadDateTimeEditor_ValueChanging);
            editorElement.ValueChanged  += new EventHandler(this.RadDateTimeEditor_ValueChanged);
            if (textBoxElement1 == null)
            {
                return;
            }
            textBoxElement1.KeyDown += new KeyEventHandler(this.TextBoxElement_KeyDown);
            textBoxElement1.TextBoxItem.HostedControl.LostFocus += new EventHandler(this.HostedControl_LostFocus);
        }
        public override void BeginEdit()
        {
            base.BeginEdit();
            RadTimePickerElement editorElement = this.EditorElement as RadTimePickerElement;

            editorElement.RightToLeft = this.RightToLeft;
            editorElement.MaskedEditBox.TextBoxItem.KeyDown += new KeyEventHandler(this.OnTextBoxItemKeyDown);
            editorElement.MaskedEditBox.TextBoxItem.KeyUp   += new KeyEventHandler(this.OnTextBoxItemKeyUp);
            editorElement.ValueChanged    += new EventHandler(this.OnEditorElementValueChanged);
            editorElement.ValueChanging   += new CancelEventHandler(this.OnEditorElementValueChanging);
            editorElement.PopupClosed     += new RadPopupClosedEventHandler(this.OnEditorElementPopupClosed);
            editorElement.Validating      += new CancelEventHandler(this.OnEditorElementValidating);
            editorElement.Validated       += new EventHandler(this.OnEditorElementValidated);
            editorElement.ValidationError += new ValidationErrorEventHandler(this.OnEditorElementValidationError);
            MaskDateTimeProvider provider = editorElement.MaskedEditBox.Provider as MaskDateTimeProvider;

            provider.SelectFirstEditableItem();
            provider.SelectedItemChanged += new EventHandler(this.OnSelectedItemChanged);
            editorElement.MaskedEditBox.TextBoxItem.HostedControl.Focus();
            this.selectedItemChanged = false;
        }