/// <summary>
        /// Invoked when the edit element(DoubleTextBox) is loaded on the cell in column
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        protected override void OnEditElementLoaded(object sender, RoutedEventArgs e)
        {
            var uiElement = ((DoubleTextBox)sender);

            uiElement.ValueChanged += OnValueChanged;
#if UWP
            uiElement.Focus(FocusState.Programmatic);
#else
            uiElement.Focus();
#endif
            if (this.TreeGrid.EditorSelectionBehavior == EditorSelectionBehavior.SelectAll && PreviewInputText == null)
            {
                uiElement.SelectAll();
            }
            else
            {
                if (PreviewInputText == null || char.IsLetter(PreviewInputText.ToString(), 0))
                {
                    var index = uiElement.Text.Length;
                    uiElement.Select(index + 1, 0);
                    return;
                }
                double value;
                double.TryParse(PreviewInputText.ToString(), out value);
                uiElement.Value = value;
#if WPF
                var caretIndex = uiElement.Text.IndexOf(PreviewInputText.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal);
#else
                var caretIndex = uiElement.Text.IndexOf(PreviewInputText, StringComparison.Ordinal);
#endif
                uiElement.Select(caretIndex + 1, 0);
            }
            PreviewInputText = null;
        }
Esempio n. 2
0
        /// <summary>
        /// Called when [edit element loaded].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        protected override void OnEditElementLoaded(object sender, RoutedEventArgs e)
        {
            var uiElement = (TextBox)sender;

            uiElement.TextChanged += OnTextChanged;

            if (!this.FilterRowCell.IsDropDownOpen)
#if WinRT || UNIVERSAL
            { uiElement.Focus(FocusState.Programmatic); }
            uiElement.KeyUp += OnKeyUp;
#else
            { uiElement.Focus(); }
#endif
            if ((this.DataGrid.EditorSelectionBehavior == EditorSelectionBehavior.SelectAll || this.DataGrid.IsAddNewIndex(this.CurrentCellIndex.RowIndex)) && PreviewInputText == null)
            {
                uiElement.SelectAll();
            }
            else
            {
                if (PreviewInputText == null)
                {
                    var index = uiElement.Text.Length;
                    uiElement.Select(index + 1, 0);
                    return;
                }
                uiElement.Text = PreviewInputText;
                var caretIndex = (uiElement.Text).IndexOf(PreviewInputText.ToString());
                uiElement.Select(caretIndex + 1, 0);
            }
            PreviewInputText = null;
        }
Esempio n. 3
0
        /// <summary>
        /// Invoked when the edit element(CurrencyTextBox) is loaded on the cell in column
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        protected override void OnEditElementLoaded(object sender, RoutedEventArgs e)
        {
            var uiElement = (CurrencyTextBox)sender;

            uiElement.ValueChanged += OnValueChanged;
            uiElement.Focus();
            if ((this.DataGrid.EditorSelectionBehavior == EditorSelectionBehavior.SelectAll || this.DataGrid.IsAddNewIndex(this.CurrentCellIndex.RowIndex)) && PreviewInputText == null)
            {
                uiElement.SelectAll();
            }
            else
            {
                if (PreviewInputText == null || char.IsLetter(PreviewInputText.ToString(), 0))
                {
                    var index = uiElement.Text.Length;
                    uiElement.Select(index + 1, 0);
                    return;
                }
                decimal value;
                decimal.TryParse(PreviewInputText.ToString(), out value);
                uiElement.Value = value;
                var caretIndex = (uiElement.Text).IndexOf(PreviewInputText.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal);
                uiElement.Select(caretIndex + 1, 0);
            }
            PreviewInputText = null;
        }
Esempio n. 4
0
        /// <summary>
        /// Invoked when the edit element(DoubleTextBox) is loaded on the cell in column.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        protected override void OnEditElementLoaded(object sender, RoutedEventArgs e)
        {
            var uiElement = ((DoubleTextBox)sender);

            uiElement.ValueChanged += OnValueChanged;
#if WinRT || UNIVERSAL
            uiElement.Focus(FocusState.Programmatic);
#else
            uiElement.Focus();
#endif
            if ((this.DataGrid.EditorSelectionBehavior == EditorSelectionBehavior.SelectAll || this.DataGrid.IsAddNewIndex(this.CurrentCellIndex.RowIndex)) && PreviewInputText == null)
            {
                uiElement.SelectAll();
            }
            else
            {
#if WinRT || UNIVERSAL
                if (PreviewInputText == null)
#else
                if (PreviewInputText == null || char.IsLetter(PreviewInputText.ToString(), 0))
#endif
                {
                    var index = uiElement.Text.Length;
                    uiElement.Select(index + 1, 0);
                    return;
                }
                double value;
                double.TryParse(PreviewInputText.ToString(), out value);
                uiElement.Value = value;
                var caretIndex = uiElement.Text.IndexOf(PreviewInputText, StringComparison.Ordinal);
                uiElement.Select(caretIndex + 1, 0);
            }
            PreviewInputText = null;
        }
        /// <summary>
        /// Processes the index of the caret.
        /// </summary>
        /// <param name="uiElement">The unique identifier element.</param>
        private void ProcessCaretIndex(UIElement uiElement)
        {
            var editor = uiElement as MaskedTextBox;

            if (editor != null)
            {
                if (this.TreeGrid.EditorSelectionBehavior == EditorSelectionBehavior.SelectAll && string.IsNullOrEmpty(PreviewInputText))
                {
                    editor.SelectAll();
                }
                else
                {
                    if (string.Equals(PreviewInputText, string.Empty) || PreviewInputText == null)
                    {
                        var caretIndex = editor.Text.Length;
                        editor.Select(caretIndex, 0);
                    }
                    if (!string.IsNullOrEmpty(PreviewInputText))
                    {
#if WPF
                        editor.Value = MaskedEditorModel.GetMaskedText(editor.Mask, PreviewInputText, editor.DateSeparator, editor.TimeSeparator, editor.DecimalSeparator, editor.NumberGroupSeparator, ' ', editor.CurrencySymbol);
#else
                        //editor.Text = SfMaskedEditorModel.GetMaskedText(editor.Mask, editor.MaskType, PreviewInputText, editor.PromptChar, editor.ValueMaskFormat, editor.Culture);
#endif
                        var caretIndex = (editor.Text).IndexOf(PreviewInputText.ToString());
                        editor.Select(caretIndex + 1, 0);
                    }
                }
            }
            PreviewInputText = string.Empty;
        }
Esempio n. 6
0
        /// <summary>
        /// Called when [edit element loaded].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        protected override void OnEditElementLoaded(object sender, RoutedEventArgs e)
        {
            var dateTimeEdit = ((DateTimeEdit)sender);

            dateTimeEdit.TextChanged        += OnTextChanged;
            dateTimeEdit.WatermarkVisibility = Visibility.Collapsed;
            dateTimeEdit.Focus();
            if ((this.DataGrid.EditorSelectionBehavior == EditorSelectionBehavior.SelectAll || this.DataGrid.IsAddNewIndex(this.CurrentCellIndex.RowIndex)) && PreviewInputText == null)
            {
                dateTimeEdit.SelectAll();
                return;
            }
            else
            {
                if (PreviewInputText == null)
                {
                    var index = dateTimeEdit.Text.Length;
                    dateTimeEdit.Select(index + 1, 0);
                    return;
                }
                if (dateTimeEdit.CanEdit)
                {
                    ((DateTimeEdit)CurrentCellRendererElement).SelectedText = PreviewInputText.ToString();
                }
                TextCompositionManager.StartComposition(new TextComposition(InputManager.Current, (DateTimeEdit)CurrentCellRendererElement, PreviewInputText.ToString()));
            }
            PreviewInputText = null;
        }
Esempio n. 7
0
        /// <summary>
        /// Invoked when the edit element(TextBox) is loaded on the cell in column.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        /// <summary>
        protected override void OnEditElementLoaded(object sender, RoutedEventArgs e)
        {
            var uiElement = (TextBox)sender;

            uiElement.TextChanged += OnTextChanged;
#if WPF
            uiElement.Focus();
#else
            uiElement.Focus(FocusState.Programmatic);
#endif
            if (this.TreeGrid.EditorSelectionBehavior == EditorSelectionBehavior.SelectAll && PreviewInputText == null)
            {
                uiElement.SelectAll();
            }
            else
            {
                if (PreviewInputText == null)
                {
                    var index = uiElement.Text.Length;
                    uiElement.Select(index + 1, 0);
                    return;
                }
                uiElement.Text = PreviewInputText;
                var caretIndex = (uiElement.Text).IndexOf(PreviewInputText.ToString());
                uiElement.Select(caretIndex + 1, 0);
            }
            PreviewInputText = null;
        }