Example #1
0
        private bool EnsureDateTimeMaskHandler()
        {
            RadDateTimePickerElement editorElement = this.EditorElement as RadDateTimePickerElement;

            if (editorElement == null)
            {
                return(false);
            }
            RadDateTimePickerCalendar dateTimeBehavior = editorElement.CurrentBehavior as RadDateTimePickerCalendar;

            if (dateTimeBehavior == null)
            {
                return(false);
            }
            RadMaskedEditBoxElement maskTextBox = editorElement.TextBoxElement as RadMaskedEditBoxElement;

            if (maskTextBox == null)
            {
                return(false);
            }
            if (maskTextBox.TextBoxItem.SelectionLength == maskTextBox.Text.Length)
            {
                return(false);
            }
            this.dateTimeMaskHandler = maskTextBox.Provider as MaskDateTimeProvider;
            if (this.dateTimeMaskHandler == null)
            {
                return(false);
            }
            return(true);
        }
Example #2
0
        public override bool EndEdit()
        {
            base.EndEdit();
            RadDateTimePickerElement editorElement  = (RadDateTimePickerElement)this.EditorElement;
            RadTextBoxElement        textBoxElement = (RadTextBoxElement)editorElement.TextBoxElement;

            editorElement.ValueChanging -= new ValueChangingEventHandler(this.RadDateTimeEditor_ValueChanging);
            editorElement.ValueChanged  -= new EventHandler(this.RadDateTimeEditor_ValueChanged);
            RadDateTimePickerCalendar currentBehavior = editorElement.GetCurrentBehavior() as RadDateTimePickerCalendar;

            if (currentBehavior != null)
            {
                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);
            }
            if (textBoxElement != null)
            {
                textBoxElement.KeyDown -= new KeyEventHandler(this.TextBoxElement_KeyDown);
                textBoxElement.KeyUp   -= new KeyEventHandler(this.textBoxElement_KeyUp);
            }
            (editorElement.GetCurrentBehavior() as RadDateTimePickerCalendar)?.PopupControl.Hide();
            return(true);
        }
Example #3
0
        public override bool EndEdit()
        {
            base.EndEdit();
            RadDateTimePickerElement editor         = (RadDateTimePickerElement)this.EditorElement;
            RadTextBoxElement        textBoxElement = editor.TextBoxElement;

            editor.ValueChanging -= new ValueChangingEventHandler(RadDateTimeEditor_ValueChanging);
            editor.ValueChanged  -= new EventHandler(RadDateTimeEditor_ValueChanged);
            RadDateTimePickerCalendar dateTimeBehavior = editor.GetCurrentBehavior() as RadDateTimePickerCalendar;

            if (dateTimeBehavior != null)
            {
                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 (textBoxElement != null)
            {
                textBoxElement.KeyDown -= new KeyEventHandler(TextBoxElement_KeyDown);
                textBoxElement.TextBoxItem.HostedControl.LostFocus -= new EventHandler(HostedControl_LostFocus);
            }
            RadDateTimePickerCalendar calendar = editor.GetCurrentBehavior() as RadDateTimePickerCalendar;

            if (calendar != null)
            {
                calendar.PopupControl.Hide();
            }
            return(true);
        }
Example #4
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);
            }
        }
Example #5
0
        private void PopupControl_Opened(object sender, EventArgs e)
        {
            RadDateTimePickerCalendar currentBehavior = (this.EditorElement as RadDateTimePickerElement).GetCurrentBehavior() as RadDateTimePickerCalendar;

            if (currentBehavior == null)
            {
                return;
            }
            currentBehavior.Calendar.SelectedDates.Clear();
            currentBehavior.Calendar.InvalidateCalendar();
        }
Example #6
0
        private void PopupControl_Opened(object sender, EventArgs e)
        {
            RadDateTimePickerElement  dateTimePicker         = this.EditorElement as RadDateTimePickerElement;
            RadDateTimePickerCalendar dateTimePickerCalendar = dateTimePicker.GetCurrentBehavior() as RadDateTimePickerCalendar;

            if (dateTimePickerCalendar != null)
            {
                dateTimePickerCalendar.Calendar.SelectedDates.Clear();
                dateTimePickerCalendar.Calendar.InvalidateCalendar();
            }
        }
Example #7
0
        protected override RadElement CreateEditorElement()
        {
            RadDateTimeEditorElement  timeEditorElement = new RadDateTimeEditorElement();
            RadDateTimePickerCalendar currentBehavior   = timeEditorElement.GetCurrentBehavior() as RadDateTimePickerCalendar;

            if (currentBehavior != null)
            {
                currentBehavior.Calendar.ShowFooter = true;
                timeEditorElement.CalendarSize      = new Size(200, 200);
            }
            return((RadElement)timeEditorElement);
        }
Example #8
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;
        }
Example #9
0
        protected override RadElement CreateEditorElement()
        {
            BaseDateTimeEditorElement editor           = new BaseDateTimeEditorElement();
            RadDateTimePickerCalendar calendarBehavior = editor.GetCurrentBehavior() as RadDateTimePickerCalendar;

            if (calendarBehavior != null)
            {
                calendarBehavior.Calendar.ShowFooter = true;
                editor.CalendarSize = new Size(200, 200);
            }

            return(editor);
        }
Example #10
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);
        }
Example #11
0
        protected override void OnThemeChanged()
        {
            base.OnThemeChanged();
            RadDateTimePickerCalendar currentBehavior = this.dateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;

            if (currentBehavior == null)
            {
                return;
            }
            currentBehavior.Calendar.ThemeName     = this.ThemeName;
            currentBehavior.PopupControl.ThemeName = this.ThemeName;
            if (currentBehavior.ShowTimePicker && currentBehavior.TimePicker != null)
            {
                currentBehavior.TimePicker.ThemeName = this.ThemeName;
                if (currentBehavior.ShowFooter)
                {
                    currentBehavior.FooterPanel.ThemeName = this.ThemeName;
                }
            }
            if (!TelerikHelper.IsMaterialTheme(this.ThemeName))
            {
                return;
            }
            Size size = TelerikDpiHelper.ScaleSize(new Size(300, 390), this.RootElement.DpiScaleFactor);

            if (this.dateTimePickerElement.ShowTimePicker)
            {
                currentBehavior.Calendar.MinimumSize = TelerikDpiHelper.ScaleSize(new Size(300, 0), this.RootElement.DpiScaleFactor);
                size.Width = 590;
            }
            currentBehavior.DropDownMinSize = size;
            RadCalendarElement calendarElement = currentBehavior.Calendar.CalendarElement;

            calendarElement.DrawBorder          = true;
            calendarElement.BorderBoxStyle      = BorderBoxStyle.FourBorders;
            calendarElement.BorderGradientStyle = GradientStyles.Solid;
            calendarElement.BorderBottomColor   = calendarElement.BorderBottomShadowColor = calendarElement.BorderRightColor = calendarElement.BorderRightShadowColor = calendarElement.BorderLeftShadowColor = calendarElement.BorderTopShadowColor = Color.Transparent;
            calendarElement.BorderLeftColor     = calendarElement.BorderTopColor = Color.FromArgb(236, 236, 236);
        }