/// <summary>
        /// フォーカス移動
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cPasswordBox_KeyDown(object sender, KeyEventArgs e)
        {
            TraversalRequest vector = null;

            switch (e.Key)
            {
            case Key.Enter:
                vector = new TraversalRequest(FocusNavigationDirection.Next);
                break;

            case Key.Down:
                vector = new TraversalRequest(FocusNavigationDirection.Next);
                break;

            case Key.Up:
                vector = new TraversalRequest(FocusNavigationDirection.Previous);
                break;
            }
            if (vector != null)
            {
                e.Handled = true;
                FocusControl.SetFocusWithOrder(vector);
            }
        }
        private static void OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return || e.Key == Key.Enter)
            {
                var textBox = sender as TextBoxBase;
                if (textBox == null)
                {
                    return;
                }

                if (textBox.GetMoveFocusOnEnter())
                {
                    // MoveFocus takes a TraversalRequest as its argument.
                    var request = new TraversalRequest(FocusNavigationDirection.Next);

                    // Gets the element with keyboard focus.
                    // Change keyboard focus.
                    if (Keyboard.FocusedElement is UIElement elementWithFocus)
                    {
                        if (elementWithFocus.MoveFocus(request))
                        {
                            e.Handled = true;
                        }
                    }
                }

                if (textBox.IsFocused && textBox.GetLoseFocusOnEnter())
                {
                    var focusableAncestor = textBox.Ancestors()
                                            .OfType <IInputElement>()
                                            .FirstOrDefault(x => x.Focusable);
                    var scope = FocusManager.GetFocusScope(textBox);
                    FocusManager.SetFocusedElement(scope, focusableAncestor);
                }
            }
        }
Example #3
0
                public bool OnNoMoreTabStops(TraversalRequest request)
                {
                    var flag = true;

                    if (request != null)
                    {
                        switch (request.FocusNavigationDirection)
                        {
                        case FocusNavigationDirection.Next:
                        case FocusNavigationDirection.Right:
                        case FocusNavigationDirection.Down:
                            flag = true;
                            break;

                        case FocusNavigationDirection.Previous:
                        case FocusNavigationDirection.Left:
                        case FocusNavigationDirection.Up:
                            flag = false;
                            break;
                        }
                    }

                    var ancestor = NativeMethods.GetAncestor(this.source.Handle, 2);

                    if (ancestor != IntPtr.Zero)
                    {
                        var hWnd = NativeMethods.GetNextDlgTabItem(ancestor, this.source.Handle, !flag);
                        if (hWnd != IntPtr.Zero)
                        {
                            NativeMethods.SetFocus(hWnd);
                            return(true);
                        }
                    }

                    return(false);
                }
            public bool OnNoMoreTabStops(TraversalRequest request)
            {
                // First, determine if we are tabbing forward or backwards
                // outside of our content.
                bool forward = true;
                if (request != null)
                {
                    switch (request.FocusNavigationDirection)
                    {
                        case FocusNavigationDirection.Next:
                        case FocusNavigationDirection.Right:
                        case FocusNavigationDirection.Down:
                            break;

                        case FocusNavigationDirection.Previous:
                        case FocusNavigationDirection.Left:
                        case FocusNavigationDirection.Up:
                            forward = false;
                            break;
                    }
                }

                // Based on the direction, tab forward or backwards in our parent dialog.
                var nextHandle = DialogPageElementHost.GetNextFocusElement(_source.Handle, forward);
                if (nextHandle != IntPtr.Zero)
                {
                    // If we were able to find another control, send focus to it and inform
                    // WPF that we moved focus outside the HwndSource.
                    NativeMethods.SetFocus(nextHandle);
                    return true;
                }

                // If we couldn't find a dialog item to focus, inform WPF that it should
                // continue cycling inside its own tab order.
                return false;
            }
Example #5
0
 bool IKeyboardInputSink.TabInto(TraversalRequest request)
 {
     return(false);
 }
Example #6
0
        /// <summary>
        /// Обработка нажатия клавиш [Enter] и [Up] в DataGrid поиска сущностей
        /// </summary>
        private void SearchProduct2DataGrid_OnPreviewKeyUp(object senderIsDataGrid, KeyEventArgs eventArgs)
        {
            const int startOfListIndex = 0;
            // DataGrid поиска сущности
            var searchDataGrid = senderIsDataGrid as DataGrid;

            if (searchDataGrid == null)
            {
                return;
            }
            // Grid-обёртка DataGrid и TextBox поиска
            var searchWrapperGrid = VisualTreeHelper.GetParent(searchDataGrid) as Grid;

            if (searchWrapperGrid == null)
            {
                return;
            }
            // TextBox поиска/добавления
            var searchTextBox = searchWrapperGrid.Children.OfType <TextBox>().FirstOrDefault();

            if (searchTextBox == null)
            {
                return;
            }

            // Если фокус ввода на первой записи DataGrid и нажата [Up] - перевод клавиатурного фокуса ввода к TextBox
            if (startOfListIndex == searchDataGrid.SelectedIndex && eventArgs.Key == Key.Up)
            {
                searchTextBox.Focus();
            }

            // Если записей не 0 и нажат [Enter] - заносим текст объекта в TextBox и переводим фокус к след. контролу
            else if (searchDataGrid.Items.Count > 0 && eventArgs.Key == Key.Enter)
            {
                // Выбранная строка (объект) DataGrid поиска сущности
                var rawSelectedItem = searchDataGrid.SelectedItem;
                if (rawSelectedItem == null)
                {
                    return;
                }
                string displayed;
                var    selectedItemType = rawSelectedItem.GetType();
                if (selectedItemType == typeof(Product)) // Если тип найденой сущности: [Изделие]
                {
                    _selectedProduct2                = (Product)rawSelectedItem;
                    Product2CodeLabel.Content        = _selectedProduct2.CodeProduct.ToString(CultureInfo.CurrentCulture);
                    Product2NameLabel.Content        = _selectedProduct2.Name;
                    Product2MarkLabel.Content        = _selectedProduct2.Mark;
                    AddProductInListButton.IsEnabled = true;
                    displayed = _selectedProduct2.CodeProduct.ToString(CultureInfo.CurrentCulture);
                }
                else
                {
                    displayed = rawSelectedItem.ToString();
                }
                // Вывод выбраного значения в TextBox поиска/добавления
                searchTextBox.Text = displayed;

                // Перевод фокуса ввода на нижележащий визуальный элемент после [DataGrid] поиска сущности
                var request = new TraversalRequest(FocusNavigationDirection.Down)
                {
                    Wrapped = false
                };
                eventArgs.Handled = true;
                if (searchDataGrid.MoveFocus(request))
                {
                    searchDataGrid.Visibility = Visibility.Collapsed;
                }
            }
        }
Example #7
0
        protected override bool TabIntoCore(TraversalRequest request)
        {
            int result = Win32.SetFocus(_handler);

            return(result > 0);
        }
        /// <summary>
        /// Moves the focused element.
        /// </summary>
        /// <param name="direction">The direction.</param>
        private void MoveFocus(FocusNavigationDirection direction)
        {
            var request = new TraversalRequest(direction);

            MoveFocus(request);
        }
Example #9
0
 protected override bool TabIntoCore(TraversalRequest request)
 {
     return(NativeMethods.SetFocus(hWnd) != hWnd);
 }
Example #10
0
 bool IKeyboardInputSink.TabInto(TraversalRequest request)
 {
     return(TabIntoCore(request));
 }
Example #11
0
 protected override bool TabIntoCore(TraversalRequest request)
 {
     return(Win32.SetFocus(_handler) > 0);
 }
Example #12
0
 public override sealed bool MoveFocus(TraversalRequest request);
Example #13
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtDescripcion.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgDescripcionRequerida;
                    txtDescripcion.Focus();
                    txtDescripcion.SelectAll();
                }
                else if (string.IsNullOrWhiteSpace(skAyudaOrganizacion.Clave) ||
                         string.IsNullOrWhiteSpace(skAyudaOrganizacion.Descripcion))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgOrganizacionRequerida;

                    txtDescripcion.Focus();
                    var tRequest = new TraversalRequest(FocusNavigationDirection.Next);
                    txtDescripcion.MoveFocus(tRequest);
                }

                else if (cmbTipoCorral.SelectedItem == null || Contexto.TipoCorral.TipoCorralID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgTipoCorralRequerida;
                    cmbTipoCorral.Focus();
                }
                else if (string.IsNullOrWhiteSpace(txtCapacidad.Text) || txtCapacidad.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgCapacidadRequerida;
                    txtCapacidad.Focus();
                    txtCapacidad.SelectAll();
                }
                else if (string.IsNullOrWhiteSpace(txtSeccion.Text) || txtSeccion.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgSeccionRequerida;
                    txtSeccion.Focus();
                    txtSeccion.SelectAll();
                }
                else if (string.IsNullOrWhiteSpace(txtOrden.Text) || txtOrden.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CorralEdicion_MsgOrdenRequerida;
                    txtOrden.Focus();
                    txtOrden.SelectAll();
                }
                else
                {
                    var    lotePL         = new LotePL();
                    int    corralId       = Extensor.ValorEntero(txtCorralId.Text);
                    string descripcion    = txtDescripcion.Text;
                    int    organizacionID = Contexto.Organizacion.OrganizacionID;

                    var corralPL = new CorralPL();
                    //CorralInfo corral = corralPL.ValidaCorralConLoteConExistenciaActivo(Contexto.CorralID);
                    //if (corral != null)
                    //{
                    //    mensaje = Properties.Resources.Corral_MsgConExistencia;
                    //    resultado = false;
                    //}
                    //else

                    CorralInfo corral = corralPL.ObtenerPorDescripcionOrganizacion(descripcion, organizacionID);

                    if (corral != null && (corralId == 0 || corralId != corral.CorralID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.CorralEdicion_MsgDescripcionExistente,
                                                  corral.CorralID);
                    }
                    var loteFiltro = new LoteInfo
                    {
                        OrganizacionID = organizacionID,
                        CorralID       = corralId
                    };
                    LoteInfo lote = lotePL.ObtenerPorCorralID(loteFiltro);
                    if (lote != null)
                    {
                        if (corral != null)
                        {
                            if (corral.TipoCorral.TipoCorralID != Contexto.TipoCorral.TipoCorralID)
                            {
                                resultado = false;
                                mensaje   = string.Format(Properties.Resources.CorralEdicion_MsgCambiarTipoCorral,
                                                          lote.Lote);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
Example #14
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(skAyudaOrigen.Clave) ||
                    string.IsNullOrWhiteSpace(skAyudaOrigen.Descripcion) ||
                    skAyudaOrigen.Clave == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ConfiguracionEmbarqueEdicion_MsgOrganizacionOrigen;
                    skAyudaOrigen.AsignarFoco();
                }
                else if (string.IsNullOrWhiteSpace(skAyudaDestino.Clave) ||
                         string.IsNullOrWhiteSpace(skAyudaDestino.Descripcion) ||
                         skAyudaDestino.Clave == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ConfiguracionEmbarqueEdicion_MsgOrganizacionDestino;
                    skAyudaDestino.AsignarFoco();
                }
                else if (skAyudaOrigen.Clave == skAyudaDestino.Clave)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ProgramacionEmbarque_DestinoIgualOrigen;
                    txtConfiguracionEmbarqueId.Focus();
                    var tRequest = new TraversalRequest(FocusNavigationDirection.Next);
                    txtConfiguracionEmbarqueId.MoveFocus(tRequest);
                }
                else if (!dtuKilometros.Value.HasValue || string.IsNullOrWhiteSpace(dtuKilometros.Text) ||
                         dtuKilometros.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ConfiguracionEmbarqueEdicion_MsgKilometrosRequerida;
                    dtuKilometros.Focus();
                }
                else if (!dtuHoras.Value.HasValue || string.IsNullOrWhiteSpace(dtuHoras.Text) ||
                         dtuHoras.Text == "0.0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ConfiguracionEmbarqueEdicion_MsgHorasRequerida;
                    dtuHoras.Focus();
                }
                else
                {
                    int configuracionEmbarqueId = Extensor.ValorEntero(txtConfiguracionEmbarqueId.Text);
                    int organizacionOrigenId    = Extensor.ValorEntero(skAyudaOrigen.Clave);
                    int organizacionDestinoId   = Extensor.ValorEntero(skAyudaDestino.Clave);

                    var configuracionEmbarquePL = new ConfiguracionEmbarquePL();
                    ConfiguracionEmbarqueInfo configuracionEmbarque =
                        configuracionEmbarquePL.ObtenerPorOrganizacion(organizacionOrigenId,
                                                                       organizacionDestinoId);

                    if (configuracionEmbarque != null &&
                        (configuracionEmbarqueId == 0 ||
                         configuracionEmbarqueId != configuracionEmbarque.ConfiguracionEmbarqueID))
                    {
                        resultado = false;
                        mensaje   =
                            string.Format(
                                Properties.Resources.ConfiguracionEmbarqueEdicion_MsgConfiguracionExistente,
                                configuracionEmbarque.ConfiguracionEmbarqueID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
Example #15
0
 public bool TabInto(TraversalRequest request)
 {
     this.SetFocusToHwndHost(true, IntPtr.Zero);
     return(true);
 }
Example #16
0
        private void AddJumps(object sender, KeyEventArgs e)
        {
            DependencyObject dpobj = sender as DependencyObject;
            string           name  = dpobj.GetValue(FrameworkElement.NameProperty) as string;

            if (e.Key == Key.Tab && name == "jump" + jumpHeight.SelectedItem.ToString())
            {
                List <string> jumps = new List <string>();
                jumps.AddRange(ReadJumps());
                if (jumps.Count == Int32.Parse(jumpHeight.SelectedItem.ToString()))
                {
                    List <Jump> addJumps      = new List <Jump>();
                    string      visibleString = "";
                    int         i             = 0;
                    foreach (string j in jumps)
                    {
                        visibleString += j + "    ";
                        Jump temp = new Jump();
                        temp.Number = i;
                        i++;
                        temp.CUID   = newCompetition.Users[newCompetition.Users.Count - 1].ID;
                        temp.Code   = j.Split('%')[0];
                        temp.Height = Int32.Parse(j.Split('%')[1]);

                        newJumps.Add(temp);
                    }

                    usersListBox.Items.Add(visibleString);
                    //usersListBox.Items.Add(MainWindow.ID.ToString());

                    ClearJumps();
                    RevertColor();
                }
            }
            else if (e.Key == Key.Tab && name.EndsWith("t"))
            {
                TraversalRequest tRequest      = new TraversalRequest(FocusNavigationDirection.Right);
                UIElement        keyboardFocus = Keyboard.FocusedElement as UIElement;

                if (keyboardFocus != null)
                {
                    keyboardFocus.MoveFocus(tRequest);
                }

                e.Handled = true;
            }
            else if (e.Key == Key.Tab)
            {
                TraversalRequest tRequest      = new TraversalRequest(FocusNavigationDirection.Left);
                UIElement        keyboardFocus = Keyboard.FocusedElement as UIElement;

                if (keyboardFocus != null)
                {
                    keyboardFocus.MoveFocus(tRequest);
                }

                tRequest      = new TraversalRequest(FocusNavigationDirection.Down);
                keyboardFocus = Keyboard.FocusedElement as UIElement;

                if (keyboardFocus != null)
                {
                    keyboardFocus.MoveFocus(tRequest);
                }

                e.Handled = true;
            }
        }
Example #17
0
 /// <summary>
 ///     Set focus to the first or last tab stop (according to the
 ///     TraversalRequest).  If it can't, because it has no tab stops,
 ///     the return value is false.
 /// </summary>
 protected virtual bool TabIntoCore(TraversalRequest request)
 {
     return(false);
 }
Example #18
0
        bool ValidateSMTP()
        {
            object element;

#if !SILVERLIGHT
            element = FocusManager.GetFocusedElement(UtilDisplay.GetCurentWindow());
            if (element is Control)
            {
                var ctrl = element as Control;
                TraversalRequest tReq = new TraversalRequest(FocusNavigationDirection.Down);
                ctrl.MoveFocus(tReq);
            }
#else
            element = FocusManager.GetFocusedElement();
            if (element is SLTextBox)
            {
                var dp = (element as TextBox).Tag as DateEditor;
                if (dp != null)
                {
                    dp.UpdateEditValueSource();
                }
            }
#endif
            if (isSMTPValidated == true)
            {
                return(true);
            }
            if (editrow._host == string.Empty)
            {
                editrow._host = null;
            }
            if (editrow._smtpUser == string.Empty)
            {
                editrow._smtpUser = null;
            }
            if (string.IsNullOrEmpty(editrow._smtpPassword))
            {
                editrow._smtpPassword = null;
            }
            var loadedRow = this.LoadedRow as DebtorEmailSetupClient;
            if (loadedRow == null && !string.IsNullOrEmpty(editrow._host))
            {
                isSMTPValidated = false;
            }
            else if (loadedRow != null && ((editrow._host != null && editrow._host != loadedRow._host) || (editrow._port != 0 && editrow._port != loadedRow._port) || (editrow._smtpUser != null && editrow._smtpUser != loadedRow._smtpUser) || (editrow._smtpPassword != null && editrow._smtpPassword != loadedRow._smtpPassword) ||
                                           (editrow.AllowDifferentSender == true && editrow.AllowDifferentSender != loadedRow.AllowDifferentSender) ||
                                           (editrow.AllowDifferentSender == true && editrow.EmailSendFrom != loadedRow.EmailSendFrom)))
            {
                isSMTPValidated = false;
            }
            if (isSMTPValidated == false)
            {
#if !SILVERLIGHT
                if (UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("SMTPVerifyMsg"), Uniconta.ClientTools.Localization.lookup("Warning"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
#else
                if (UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("SMTPVerifyMsg"), Uniconta.ClientTools.Localization.lookup("Warning"), MessageBoxButton.OKCancel) == MessageBoxResult.OK)
#endif
                {
                    FrmRibbon_OnItemClicked("TestMail");
                    return(false);
                }
                else
                {
                    isSMTPValidated = null;
                    return(false);
                }
            }
            return(true);
        }
Example #19
0
 bool IKeyboardInputSite.OnNoMoreTabStops(TraversalRequest request)
 {
     return(Browser.TabOut(request.FocusNavigationDirection == FocusNavigationDirection.Next));
     // i. Tabbing-in is handled by ApplicationProxyInternal.
 }
Example #20
0
 public bool OnNoMoreTabStops(TraversalRequest request)
 {
     // TODO: Allow the ElementHost's container to handle Tab/Arrow navigation
     return(false);
 }
 protected override bool TabIntoCore(TraversalRequest request)
 {
     return(base.TabIntoCore(request));
 }
Example #22
0
        private void OnMoveFocusToPatternsTree(object sender, RoutedEventArgs e)
        {
            var traversalRequest = new TraversalRequest(FocusNavigationDirection.First);

            this.ctrlPatterns.MoveFocus(traversalRequest);
        }
Example #23
0
 static ModalContentPresenter()
 {
     traversalDirection = new TraversalRequest(FocusNavigationDirection.First);
 }
Example #24
0
 public bool TabInto(TraversalRequest request)
 {
     return(false);
 }
Example #25
0
        /// <summary>
        /// Обработка нажатия мышки на строку DataGrid поиска сущностей
        /// </summary>
        private void SearchDataGrid_OnPreviewMouseDown(object senderIsDataGrid, MouseButtonEventArgs eventArgs)
        {
            // DataGrid поиска сущности
            var searchDataGrid = senderIsDataGrid as DataGrid;

            if (searchDataGrid == null)
            {
                return;
            }
            // Grid-обёртка DataGrid и TextBox поиска
            var searchWrapperGrid = VisualTreeHelper.GetParent(searchDataGrid) as Grid;

            if (searchWrapperGrid == null)
            {
                return;
            }
            // TextBox поиска/добавления
            var searchTextBox = searchWrapperGrid.Children.OfType <TextBox>().FirstOrDefault();

            if (searchTextBox == null)
            {
                return;
            }
            // Выбранная строка (объект) DataGrid поиска сущности
            var rawSelectedItem = searchDataGrid.SelectedItem;

            if (rawSelectedItem == null)
            {
                return;
            }
            string displayed;
            var    selectedItemType = rawSelectedItem.GetType();

            if (selectedItemType == typeof(Product)) // Если тип найденой сущности: [Изделие]
            {
                _selectedProduct1             = (Product)rawSelectedItem;
                Product1CodeLabel.Content     = _selectedProduct1.CodeProduct.ToString(CultureInfo.CurrentCulture);
                Product1NameLabel.Content     = _selectedProduct1.Name;
                Product1MarkLabel.Content     = _selectedProduct1.Mark;
                MaterialWrapperGrid.IsEnabled = true;
                MaterialCodeLabel.Content     = string.Empty;
                MaterialNameLabel.Content     = string.Empty;
                MaterialMarkLabel.Content     = string.Empty;
                MaterialGostLabel.Content     = string.Empty;
                MeasureLabel.Content          = string.Empty;
                AuxiliaryMaterialConsumptionRateLabel.Content = string.Empty;
                _searchMaterialStorage = Nu65StorageMssql.GetMaterialsByProductIdWhithMeasure(_selectedProduct1.Id);
                _searchMaterialStorage.Sort();
                SearchMaterialDataGrid.ItemsSource = _searchMaterialStorage;
                displayed = _selectedProduct1.CodeProduct.ToString(CultureInfo.CurrentCulture);
            }
            else if (selectedItemType == typeof(Material)) // Если тип найденой сущности: [Материал]
            {
                _selectedMaterial         = (Material)rawSelectedItem;
                MaterialCodeLabel.Content = _selectedMaterial.CodeMaterial.ToString(CultureInfo.CurrentCulture);
                MaterialNameLabel.Content = _selectedMaterial.Name;
                MaterialMarkLabel.Content = _selectedMaterial.Profile;
                MaterialGostLabel.Content = _selectedMaterial.Gost;
                MeasureLabel.Content      = _selectedMaterial.Measure.ShortName;
                WorkGuildLabel.Content    = _selectedMaterial.WorkGuildId;
                RegionLabel.Content       = _selectedMaterial.ParcelId;
                AuxiliaryMaterialConsumptionRateLabel.Content = _selectedMaterial.AuxiliaryMaterialConsumptionRate;
                displayed = _selectedMaterial.CodeMaterial.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                displayed = rawSelectedItem.ToString();
            }
            // Вывод выбраного значения в TextBox поиска/добавления
            searchTextBox.Text = displayed;

            // Перевод фокуса ввода на нижележащий визуальный элемент после [DataGrid] поиска сущности
            var request = new TraversalRequest(FocusNavigationDirection.Down)
            {
                Wrapped = false
            };

            eventArgs.Handled = true;
            if (searchDataGrid.MoveFocus(request))
            {
                searchDataGrid.Visibility = Visibility.Collapsed;
            }
        }
Example #26
0
 /// <summary>
 ///     Request to move the focus from this element to another element
 /// </summary>
 /// <param name="request">Determine how to move the focus</param>
 /// <returns> Returns true if focus is moved successfully. Returns false if there is no next element</returns>
 public virtual bool MoveFocus(TraversalRequest request)
 {
     return(false);
 }
Example #27
0
        private void SearchProduct2DataGrid_OnPreviewMouseDown(object senderIsDataGrid, MouseButtonEventArgs eventArgs)
        {
            // DataGrid поиска сущности
            var searchDataGrid = senderIsDataGrid as DataGrid;

            if (searchDataGrid == null)
            {
                return;
            }
            // Grid-обёртка DataGrid и TextBox поиска
            var searchWrapperGrid = VisualTreeHelper.GetParent(searchDataGrid) as Grid;

            if (searchWrapperGrid == null)
            {
                return;
            }
            // TextBox поиска/добавления
            var searchTextBox = searchWrapperGrid.Children.OfType <TextBox>().FirstOrDefault();

            if (searchTextBox == null)
            {
                return;
            }
            // Выбранная строка (объект) DataGrid поиска сущности
            var rawSelectedItem = searchDataGrid.SelectedItem;

            if (rawSelectedItem == null)
            {
                return;
            }
            string displayed;
            var    selectedItemType = rawSelectedItem.GetType();

            if (selectedItemType == typeof(Product)) // Если тип найденой сущности: [Изделие]
            {
                _selectedProduct2                = (Product)rawSelectedItem;
                Product2CodeLabel.Content        = _selectedProduct2.CodeProduct.ToString(CultureInfo.CurrentCulture);
                Product2NameLabel.Content        = _selectedProduct2.Name;
                Product2MarkLabel.Content        = _selectedProduct2.Mark;
                AddProductInListButton.IsEnabled = true;
                displayed = _selectedProduct2.CodeProduct.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                displayed = rawSelectedItem.ToString();
            }
            // Вывод выбраного значения в TextBox поиска/добавления
            searchTextBox.Text = displayed;

            // Перевод фокуса ввода на нижележащий визуальный элемент после [DataGrid] поиска сущности
            var request = new TraversalRequest(FocusNavigationDirection.Down)
            {
                Wrapped = false
            };

            eventArgs.Handled = true;
            if (searchDataGrid.MoveFocus(request))
            {
                searchDataGrid.Visibility = Visibility.Collapsed;
            }
        }
Example #28
0
        private void wxTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            var textBox = sender as TextBox;

            if (textBox == null || textBox.Text == null)
            {
                return;
            }
            if (Keyboard.Modifiers != 0)
            {
                return;
            }

            TraversalRequest tRequest = null;

            switch (e.Key)
            {
            case Key.Up:
                if (textBox.SelectionLength == 0 && !_KeyPressing)                         // Detect first line
                {
                    if (textBox.GetLineIndexFromCharacterIndex(textBox.SelectionStart) == 0)
                    {
                        tRequest = new TraversalRequest(FocusNavigationDirection.Up);
                    }
                }
                break;

            case Key.Down:
                if (textBox.SelectionLength == 0 && !_KeyPressing)                         // Detect last line
                {
                    if (textBox.GetLineIndexFromCharacterIndex(textBox.SelectionStart) == textBox.LineCount - 1)
                    {
                        tRequest = new TraversalRequest(FocusNavigationDirection.Down);
                    }
                }
                break;

            case Key.Left:
                if (textBox.SelectionStart == 0 && textBox.SelectionLength == 0 && !_KeyPressing)
                {
                    tRequest = new TraversalRequest(FocusNavigationDirection.Left);
                }
                break;

            case Key.Right:
                if (textBox.IsReadOnly && !textBox.IsReadOnlyCaretVisible)
                {
                    e.Handled = true;
                    textBox.IsReadOnlyCaretVisible = true;
                }
                else if (textBox.SelectionStart == textBox.Text.Length && textBox.SelectionLength == 0 && !_KeyPressing)
                {
                    tRequest = new TraversalRequest(FocusNavigationDirection.Right);
                }
                break;
            }

            if (tRequest != null)
            {
                e.Handled = true;
                textBox.MoveFocus(tRequest);
            }
            else
            {
                _KeyPressing = true;
            }
        }
Example #29
0
        private void txt_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("txt_PreviewKeyDown: " + txt.Text);

            if (_ehEntrada)
            {
                _bufferSearch.Append(txt.Text);
                _ehEntrada = false;
            }

            if (e.Key == Key.Escape || e.Key == Key.Delete)
            {
                e.Handled = true;
                return;
            }

            if (e.Key != Key.Enter && e.Key != Key.Tab)
            {
                AjustarSarchBuffer(e.Key);
                Filtrar("");
            }

            if (e.Key == Key.Down)
            {
                if (Items != null && Items.Count > 0)
                {
                    OpenPopup();
                    lista.Focus();
                    lista.SelectedItem = ListaFiltrada.FirstOrDefault();
                    lista.UpdateLayout();

                    ListBoxItem listItem = null;
                    listItem = (ListBoxItem)lista.ItemContainerGenerator.ContainerFromItem(lista.SelectedItem);
                    if (listItem != null)
                    {
                        listItem.Focus();
                        TraversalRequest tRequest      = new TraversalRequest(FocusNavigationDirection.Previous);
                        UIElement        keyboardFocus = Keyboard.FocusedElement as UIElement;
                        if (keyboardFocus != null)
                        {
                            keyboardFocus.MoveFocus(tRequest);
                        }
                    }

                    e.Handled = true;
                }
            }
            else if (e.Key == Key.Tab)
            {
                _ehEntrada           = false;
                _ehSaida             = true;
                InternalItemSelected = ListaFiltrada.FirstOrDefault() != null?ListaFiltrada.FirstOrDefault() : null;

                if (InternalItemSelected != null)
                {
                    _bufferSearch.Clear();
                    _bufferSearch.Append(InternalItemSelected.Descricao);
                    LabelLinkItemSelected = SetLabelLink(GetDescricaoObject(MapaObjects[InternalItemSelected.Codigo]));
                    txt.CaretIndex        = txt.Text.Length;
                    SetValue(SelectedItemProperty, MapaObjects[InternalItemSelected.Codigo]);
                    FecharPopup();
                }
                else
                {
                    _bufferSearch.Clear();
                    SetValue(SelectedItemProperty, MapaObjects["null"]);
                    LabelLinkItemSelected = SetLabelLink(GetDescricaoObject(MapaObjects["null"]));
                    FecharPopup();
                }
            }
            else if (e.Key == Key.Enter)
            {
                _ehEntrada           = false;
                _ehSaida             = true;
                InternalItemSelected = ListaFiltrada.FirstOrDefault() != null?ListaFiltrada.FirstOrDefault() : null;

                if (InternalItemSelected != null)
                {
                    _bufferSearch.Clear();
                    _bufferSearch.Append(InternalItemSelected.Descricao);
                    LabelLinkItemSelected = SetLabelLink(GetDescricaoObject(MapaObjects[InternalItemSelected.Codigo]));
                    txt.CaretIndex        = txt.Text.Length;
                    SetValue(SelectedItemProperty, MapaObjects[InternalItemSelected.Codigo]);
                    FecharPopup();
                    e.Handled = true;
                }
                else
                {
                    _bufferSearch.Clear();
                    SetValue(SelectedItemProperty, MapaObjects["null"]);
                    FecharPopup();
                    e.Handled = true;
                }
            }
            else if (e.Key == Key.Right)
            {
                InternalItemSelected = ListaFiltrada.FirstOrDefault() != null?ListaFiltrada.FirstOrDefault() : null;

                if (InternalItemSelected != null)
                {
                    _bufferSearch.Clear();
                    _bufferSearch.Append(InternalItemSelected.Descricao);
                    LabelLinkItemSelected = SetLabelLink(GetDescricaoObject(MapaObjects[InternalItemSelected.Codigo]));
                    txt.CaretIndex        = txt.Text.Length;
                    SetValue(SelectedItemProperty, MapaObjects[InternalItemSelected.Codigo]);
                    _ehEntrada = false;
                    _ehSaida   = true;
                    FecharPopup();
                }
            }
            else if (e.Key == Key.Back && txt.Text.Length == 1)
            {
                txt.Text       = "";
                txtHolder.Text = "";
                _bufferSearch.Clear();
                txt.Focus();
            }
            else if (e.Key == Key.Back && txt.SelectionLength == txt.Text.Length)
            {
                txt.Text       = "";
                txtHolder.Text = "";
                _bufferSearch.Clear();
                Filtrar("");
            }
            else if (e.Key == Key.Back && txt.SelectionLength > 0)
            {
                Regex  regex     = new Regex(Regex.Escape(txt.SelectedText));
                string resultado = regex.Replace(txt.Text, "");
                _bufferSearch.Clear();
                if (resultado.Length > 0)
                {
                    _bufferSearch.Append(resultado);
                }

                txt.Text       = resultado;
                txtHolder.Text = "";
                txt.CaretIndex = txt.Text.Length;
                Filtrar("");
                e.Handled = true;
            }
            else if (e.Key == Key.Back && this._bufferSearch.Length < MinimumSearchLength)
            {
                FecharPopup(false);
            }
        }
Example #30
0
        private void OnMoveFocusToEventsGrid(object sender, RoutedEventArgs e)
        {
            var traversalRequest = new TraversalRequest(FocusNavigationDirection.First);

            this.dgEvents.MoveFocus(traversalRequest);
        }