private void CanUndoAndRedoIn(string textControlName)
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
            {
                Log.Warning("Test is disabled pre-RS5 because programmatically undoing and redoing in text controls is not supported pre-RS5");
                return;
            }

            using (var setup = new TextCommandBarFlyoutTestSetupHelper())
            {
                UIObject            textControl        = FindElement.ById(textControlName);
                ValueImplementation textControlAsValue = new ValueImplementation(textControl);

                string initialString = textControl.GetText();
                Log.Comment("Initial contents of {0} are '{1}'", textControlName, initialString);

                Log.Comment("Selecting all text in the {0}.", textControlName);
                FindElement.ById <Button>(string.Format("{0}SelectAllButton", textControlName)).InvokeAndWait();

                Log.Comment("Giving the {0} focus.", textControlName);
                FocusHelper.SetFocus(textControl);

                Log.Comment("Typing 'hello' into the {0}.", textControlName);
                TextInput.SendText("hello");
                Wait.ForIdle();

                string finalString = textControl.GetText();
                Log.Comment("Contents of {0} are now '{1}'", textControlName, finalString);

                Log.Comment("Opening TextCommandBarFlyout.");
                OpenFlyoutOn(textControlName, asTransient: false);

                using (ValueChangedEventWaiter waiter = textControlAsValue.IsAvailable ? new ValueChangedEventWaiter(new Edit(textControl), initialString) : null)
                {
                    Log.Comment("Undoing text entry.");
                    FindElement.ByName <Button>("Undo").InvokeAndWait();
                }

                Log.Comment("Contents of {0} are now '{1}'", textControlName, textControl.GetText());
                Verify.AreEqual(initialString, textControl.GetText());

                Log.Comment("Reopening TextCommandBarFlyout.");
                OpenFlyoutOn(textControlName, asTransient: false);

                using (ValueChangedEventWaiter waiter = textControlAsValue.IsAvailable ? new ValueChangedEventWaiter(new Edit(textControl), finalString) : null)
                {
                    Log.Comment("Redoing text entry.");
                    FindElement.ByName <Button>("Redo").InvokeAndWait();
                }

                Log.Comment("Contents of {0} are now '{1}'", textControlName, textControl.GetText());
                Verify.AreEqual(finalString, textControl.GetText());
            }
        }
Пример #2
0
 /// <summary>
 /// Clears and closes the control.
 /// </summary>
 private void ClearAndClose()
 {
     this.SearchAndPrescribe.DataContext = new Prescription();
     this.SearchAndPrescribe.Reset();
     this.Prescribe.Opacity            = 1;
     this.Prescribe.IsHitTestVisible   = true;
     this.Prescribe.IsEnabled          = true;
     this.SearchAndPrescribe.IsEnabled = false;
     (this.Resources["HideSearchAndPrescribeControl"] as Storyboard).Begin();
     FocusHelper.FocusControl(this.Prescribe);
 }
Пример #3
0
        private void intializeCommands()
        {
            m_Logger.Log("HeadingPaneViewModel.initializeCommands", Category.Debug, Priority.Medium);
            //
            CommandFindFocus = new RichDelegateCommand(
                @"SETTINGS CommandFindFocus DUMMY TXT",
                @"SETTINGS CommandFindFocus DUMMY TXT",
                null, // KeyGesture set only for the top-level CompositeCommand
                null,
                () =>
            {
                m_ShellView.RaiseEscapeEvent();

                FocusHelper.Focus(SearchBox);
                SearchBox.SelectAll();
            },
                () => SearchBox.Visibility == Visibility.Visible,
                null, //Settings_KeyGestures.Default,
                null  //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Nav_PageFindNext)
                );
            //
            CommandFindNext = new RichDelegateCommand(
                @"SETTINGS CommandFindNext DUMMY TXT",
                @"SETTINGS CommandFindNext DUMMY TXT",
                null, // KeyGesture set only for the top-level CompositeCommand
                null,
                () =>
            {
                m_ShellView.RaiseEscapeEvent();

                FindNext(true);
            },
                () => !string.IsNullOrEmpty(SearchTerm),
                null, //Settings_KeyGestures.Default,
                null  //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Nav_PageFindNext)
                );
            CommandFindPrev = new RichDelegateCommand(
                @"SETTINGS CommandFindPrevious DUMMY TXT",
                @"SETTINGS CommandFindPrevious DUMMY TXT",
                null, // KeyGesture set only for the top-level CompositeCommand
                null,
                () =>
            {
                m_ShellView.RaiseEscapeEvent();

                FindPrevious(true);
            },
                () => !string.IsNullOrEmpty(SearchTerm),
                null, //Settings_KeyGestures.Default,
                null  //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Nav_PageFindNext)
                );
        }
Пример #4
0
        private void OnKeyDown_ListItem(object sender, KeyEventArgs e)
        {
            var key = (e.Key == Key.System ? e.SystemKey : (e.Key == Key.ImeProcessed ? e.ImeProcessedKey : e.Key));

            // We capture only the RETURN KeyUp bubbling-up from UI descendants
            if (key != Key.Return || !(sender is ListViewItem))
            {
                return;
            }

            // If RETURN was pressed on the ListItem itself,
            // then we focus down into the editor UI (using a TAB gesture)
            if (e.OriginalSource is ListViewItem)
            {
                //Dispatcher.Invoke(DispatcherPriority.Normal, new ThreadStart(FUNC));
                Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                                       (Action)(() =>
                {
                    var ev = new KeyEventArgs(
                        Keyboard.PrimaryDevice,
                        Keyboard.PrimaryDevice.ActiveSource, //PresentationSource.FromVisual(this),
                        0,                                   //Environment.TickCount, //(int)new DateTime(Environment.TickCount, DateTimeKind.Utc).Ticks
                        Key.Tab)
                    {
                        RoutedEvent = Keyboard.KeyDownEvent
                    };

                    //RaiseEvent(ev);
                    //OnKeyDown(ev);

                    InputManager.Current.ProcessInput(ev);
                }));

                // We void the effect of the RETURN key
                // (which would normally close the parent dialog window by activating the default button: CANCEL)
                e.Handled = true;
            }
            // If RETURN was pressed on one of the editors,
            // then we re-focus on the ListItem
            else if (true || // Let's do it all the time !
                     e.OriginalSource is KeyGestureSinkBox || // TextBlock
                     e.OriginalSource is CheckBox ||
                     e.OriginalSource is TextBox || // ValidationAware TextBoxReadOnlyCaretVisible
                     e.OriginalSource is ComboBoxColor)
            {
                FocusHelper.Focus((UIElement)sender);

                // We void the effect of the RETURN key
                // (which would normally close the parent dialog window by activating the default button: CANCEL)
                e.Handled = true;
            }
        }
Пример #5
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     try
     {
         // This code makes shortcuts work for all UIActionHandlers.
         return(UIActionUtilities.TryExecute(keyData, FocusHelper.GetFocusedControl()) ||
                base.ProcessCmdKey(ref msg, keyData));
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
         return(true);
     }
 }
Пример #6
0
        void LauncherWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            ListCollectionView view = (ListCollectionView)CollectionViewSource.GetDefaultView(LauncherState.Current.LauncherCommands);

            view.Filter = CommandFilter;

            IntPtr windowHandle = new WindowInteropHelper(this).Handle;

            WinApi.SetWindowPos(windowHandle, WinApi.HWND_TOPMOST, 0, 0, 0, 0, WinApi.TOPMOST_FLAGS);

            FocusHelper.Focus(SearchTextBox);

            SearchTextBox.TextChanged += delegate { UpdateCommands(); };
            SearchTextBox.Recipients.CollectionChanged += delegate { UpdateCommands(); };
        }
Пример #7
0
        protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
        {
            base.OnGotKeyboardFocus(e);

            if (IsDropDownOpen)
            {
                var selectorController = SelectorController;
                var selectedItem       = selectorController?.SelectedItem;

                if (selectedItem != null)
                {
                    FocusHelper.SetKeyboardFocusedElement(selectedItem);
                }
            }
        }
Пример #8
0
        public void SelectTreeNodeWrapper(HeadingTreeNodeWrapper nodeTOC, bool focus)
        {
            if (nodeTOC == null || TreeView.SelectedItem == nodeTOC)
            {
                return;
            }
            //m_ignoreHeadingSelected = true;

            m_SelectedTreeViewItem = TreeView.SelectItem(nodeTOC, false);

            if (m_SelectedTreeViewItem != null && focus)
            {
                FocusHelper.FocusBeginInvoke(m_SelectedTreeViewItem);
            }
        }
Пример #9
0
        private string showTextEditorPopupDialog(string editedText, String dialogTitle)
        {
            m_Logger.Log("showTextEditorPopupDialog", Category.Debug, Priority.Medium);

            var editBox = new TextBoxReadOnlyCaretVisible
            {
                FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"],

                Text          = editedText,
                TextWrapping  = TextWrapping.WrapWithOverflow,
                AcceptsReturn = true
            };

            var windowPopup = new PopupModalWindow(m_ShellView,
                                                   dialogTitle,
                                                   new ScrollViewer
            {
                Content = editBox,
                HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                VerticalScrollBarVisibility   = ScrollBarVisibility.Auto
            },
                                                   PopupModalWindow.DialogButtonsSet.OkCancel,
                                                   PopupModalWindow.DialogButton.Ok,
                                                   true, 350, 200, null, 40, m_DescriptionPopupModalWindow);

            windowPopup.EnableEnterKeyDefault = true;

            editBox.Loaded += new RoutedEventHandler((sender, ev) =>
            {
                editBox.SelectAll();
                FocusHelper.FocusBeginInvoke(editBox);
            });

            windowPopup.ShowModal();


            if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton))
            {
                string str = editBox.Text == null ? "" : editBox.Text.Trim();
                //if (string.IsNullOrEmpty(str))
                //{
                //    return "";
                //}
                return(str);
            }

            return(null);
        }
Пример #10
0
        private void SetFocus(bool force)
        {
            var fields = (from n in mappedComponents.Values
                          from l in n
                          select l).ToList();

            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                FocusHelper.SetFocus(this, new List <string>(fields));

                if (CurrentItem != null && !string.IsNullOrEmpty(CurrentItem.AreaId))
                {
                    DBEdit1.Focus();
                }
            }), DispatcherPriority.Background, null);
        }
Пример #11
0
        void PopupControl_Selected(GridViewPopupEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            this.Data = e.Value;
            this.Text = e.Display;
            isChanged = true;

            if (e.IsClosed)
            {
                FocusHelper.FocusNext(this, false);
            }
        }
Пример #12
0
        //this works for adding new items, but not for adding missing items or highlighting existing ones.  why?
        private void SetSelectedListItem(NotifyingMetadataItem selection)
        {
            if (selection != null)
            {
                CollectionViewSource cvs = (CollectionViewSource)FindResource("MetadatasCVS");
                if (cvs != null)
                {
                    cvs.View.MoveCurrentTo(selection);
                }

                //MetadataList.SelectedItem = selection;

                MetadataList.ScrollIntoView(selection);

                FocusHelper.Focus(FocusableItem);
            }
        }
Пример #13
0
        private static void OnHasDefaultFocusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (!(e.NewValue is bool))
            {
                return;
            }
            var hasFocus = (bool)e.NewValue;

            if (!hasFocus)
            {
                return;
            }
            if (d is FrameworkElement element)
            {
                Controller.ExecuteAfterNextViewOpen(r => FocusHelper.FocusDelayed(element));
            }
        }
        public void ValidateSelectionFlyoutDoesNotTakeFocus()
        {
            using (var setup = new TextCommandBarFlyoutTestSetupHelper())
            {
                // RichEditBox only implements the Text pattern, which the "TextBlock" MITA type exposes.
                var richEditBox        = new TextBlock(FindElement.ById("RichEditBox"));
                var fillWithTextButton = new Button(FindElement.ById("RichEditBoxFillWithTextButton"));

                Log.Comment("Give focus to the RichEditBox.");
                FocusHelper.SetFocus(richEditBox);

                Log.Comment("Enter enough text to guarantee that double-tapping the RichEditBox will select text.");
                fillWithTextButton.InvokeAndWait();

                Log.Comment("Double-click to select the text and bring up the selection menu. The CommandBarFlyout should appear, but should not take focus.");
                InputHelper.LeftDoubleClick(richEditBox);
                Wait.ForIdle();

                var boldButton = FindElement.ByName("Bold");
                Verify.IsNotNull(boldButton);
                Verify.IsFalse(boldButton.HasKeyboardFocus);

                Log.Comment("Press backspace to delete the selected text. This should work because the RichEditBox should still have focus.");
                KeyboardHelper.PressKey(Key.Backspace);
                Wait.ForIdle();

                Verify.AreEqual(string.Empty, richEditBox.DocumentText);

                Log.Comment("Enter text again.");
                fillWithTextButton.InvokeAndWait();

                Log.Comment("Double-click to select the text and bring up the selection menu. The CommandBarFlyout should appear, but should not take focus.");
                InputHelper.LeftDoubleClick(richEditBox);
                Wait.ForIdle();

                boldButton = FindElement.ByName("Bold");
                Verify.IsNotNull(boldButton);
                Verify.IsFalse(boldButton.HasKeyboardFocus);

                Log.Comment("Press the A key to overwrite the selected text.");
                richEditBox.SendKeys("a");
                Wait.ForIdle();

                Verify.AreEqual("a", richEditBox.DocumentText);
            }
        }
Пример #15
0
        private void OnStartPauseButtonClicked(object sender, RoutedEventArgs e)
        {
            if (state == TiwaState.Paused)
            {
                Start();
            }
            else
            {
                Pause();
            }

            FocusHelper.Focus(this.buttonClose);

            if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
            {
                this.Minimize();
            }
        }
Пример #16
0
        /// <summary>
        /// Called when the view is activated
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="eventArgs">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        private void OnActivated(object sender, EventArgs eventArgs)
        {
            if (!MoveFocusToDefaultOnActivate)
            {
                return;
            }

            var defaultControl = FindExplicitDefaultControl(this);

            if (defaultControl == null)
            {
                defaultControl = FindDefaultControl(this);
            }
            if (defaultControl != null)
            {
                FocusHelper.FocusDelayed(defaultControl);
            }
        }
Пример #17
0
        public void CanSelectSuggestion()
        {
            using (var setup = new TestSetupHelper("AutoSuggestBox Tests"))
            {
                Edit autoSuggestBoxTextBox = new Edit(FindElement.ByNameAndClassName("AutoSuggestBox with suggestions", "TextBox"));
                FocusHelper.SetFocus(autoSuggestBoxTextBox);
                KeyboardHelper.EnterText(autoSuggestBoxTextBox, "test");
                KeyboardHelper.PressKey(Key.Enter);
                InvokeImplementation dolorItem = new InvokeImplementation(FindElement.ByNameAndClassName("dolor", "ListViewItem"));

                using (ValueChangedEventWaiter waiter = new ValueChangedEventWaiter(autoSuggestBoxTextBox, "dolor"))
                {
                    dolorItem.Invoke();
                }

                Verify.AreEqual("dolor", autoSuggestBoxTextBox.Value);
            }
        }
Пример #18
0
        protected bool ApplyFocus(TItem item)
        {
            if (IsLogical)
            {
                var focusScope = FocusManager.GetFocusScope(item);

                if (focusScope == null)
                {
                    return(FocusHelper.Focus(item));
                }

                FocusManager.SetFocusedElement(focusScope, item);

                return(ReferenceEquals(FocusManager.GetFocusedElement(focusScope), item));
            }

            return(FocusHelper.Focus(item));
        }
        private void OnMouseClickCheckBox(object sender, RoutedEventArgs e)
        {
            var item = FocusableItem;

            if (item != null)
            {
                FocusHelper.FocusBeginInvoke(item, DispatcherPriority.Background);
            }
            //((UIElement)sender).Dispatcher.BeginInvoke(
            //    new Action(() =>
            //    {
            //        UIElement ui = FocusableItem;
            //        if (ui != null && ui.Focusable)
            //        {
            //            FocusHelper.Focus(FocusableItem);
            //        }
            //    }),
            //    DispatcherPriority.Background);
        }
Пример #20
0
        /// <summary>Raises the System.Windows.Controls.Primitives.Selector.SelectionChanged routed event</summary>
        /// <param name="e">Provides data for System.Windows.Controls.SelectionChangedEventArgs.</param>
        protected override void OnSelectionChanged(SelectionChangedEventArgs e)
        {
            base.OnSelectionChanged(e);

            var result = SelectedContent as ViewResult;

            if (result == null || result.View == null)
            {
                return;
            }

            FocusHelper.FocusDelayed(this);

            InputBindings.Clear();
            foreach (InputBinding binding in result.View.InputBindings)
            {
                InputBindings.Add(binding);
            }
        }
Пример #21
0
        public void LoadData(object dataInstance)
        {
            var helper = ((OverviewDataHelper)dataInstance);

            using (mailbox.Messages.ReaderLock)
                SelectedMessage =
                    mailbox.Messages.FirstOrDefault(
                        c => c.MessageId == helper.MessageId);

            if (SelectedMessage == null)
            {
                throw new ApplicationException(
                          String.Format("Message was not found. MessageId = {0}", ((OverviewDataHelper)dataInstance).MessageId));
            }

            // Mark all messages as read
            SelectedMessage.MarkRead();

            OnPropertyChanged("SelectedMessage");
            OnPropertyChanged("Title");

            if (SelectedConversation == null || SelectedMessage.Conversation != SelectedConversation)
            {
                SelectedConversation = SelectedMessage.Conversation;
                OnPropertyChanged("SelectedConversation");

                Messages.Replace(SelectedConversation.Messages);

                if (list != null)
                {
                    list.SelectedItem = SelectedMessage;

                    Dispatcher.BeginInvoke(DispatcherPriority.Input, (Action)(() => list.ScrollIntoView(SelectedMessage)));
                }
            }

            MessageActionsBox.Show(SelectedMessage);
            ThreadView.Show(SelectedMessage);
            UserProfileControl.SourceAddress = SelectedMessage.From;

            FocusHelper.Focus(TabSink);
        }
Пример #22
0
        private void OnSearchBoxKeyUp(object sender, KeyEventArgs e)
        {
            var key = (e.Key == Key.System ? e.SystemKey : (e.Key == Key.ImeProcessed ? e.ImeProcessedKey : e.Key));

            if (key == Key.Return && m_ViewModel.CommandFindNext.CanExecute())
            {
                m_ViewModel.CommandFindNext.Execute();
            }

            if (key == Key.Escape)
            {
                SearchBox.Text = "";

                var item = FocusableItem;
                if (item != null)
                {
                    FocusHelper.FocusBeginInvoke(item);
                }
            }
        }
        void GotoLabel_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ClientStats.LogEventWithSegment("Goto folder (keyboard)", ActivityView.Label.ToString());

            LogicalTreeWalker.Walk((FrameworkElement)TabHost.HeaderContent, delegate(UIElement element)
            {
                if (Responder.GetIsSearchResponder(element))
                {
                    FocusHelper.Focus(element);

                    if (element is TextBox)
                    {
                        var tb = (TextBox)element;

                        tb.Text           = "label: ";
                        tb.SelectionStart = tb.Text.Length;
                    }
                }
            });
        }
Пример #24
0
        public static Test Parse(XElement testCaseNode)
        {
            var test = new Test();

            test.Name   = FocusHelper.ExtractTestCaseName(testCaseNode);
            test.Status = testCaseNode.Attribute("result").Value.ToStatus();

            // TestCase Time Info
            test.StartTime = ExtractPropertyValue(testCaseNode, "StartTime");
            test.EndTime   = ExtractPropertyValue(testCaseNode, "FinishTime");

            test.Description = ExtractDescription(testCaseNode);
            test.CategoryList.AddRange(ExtractCategories(testCaseNode));

            test.StatusMessage = ExtractStatusMessage(testCaseNode);
            test.StackTrace    = ExtractStackTrace(testCaseNode);

            test.ArtifactSet = ExtractArtifactSet(testCaseNode);

            return(test);
        }
Пример #25
0
        void AddLabel_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ClientStats.LogEvent("Add label in stream");

            using (new ListViewIndexFix(streamView.StreamListView))
            {
                if (State.SelectedMessages.Count == 1)
                {
                    var lvItem = (ListViewItem)streamView.StreamListView.ItemContainerGenerator.ContainerFromItem(State.SelectedMessage);
                    var editor = (LabelsEditorControl)VisualTreeWalker.FindName("LabelsEditor", lvItem);

                    editor.Visibility = Visibility.Visible;
                    FocusHelper.Focus(editor);
                }
                else
                {
                    // Show modal labels adder
                    EventBroker.Publish(AppEvents.RequestAddLabels, State.SelectedMessages.ToList());
                }
            }
        }
Пример #26
0
        public void Init(MainWindowViewModel vm)
        {
            ViewModel   = vm.Settings;
            DataContext = ViewModel;

            BindingHelper.CreateCommandBinding(this.ExportExtenderSettingsButton, "ExportExtenderSettingsCommand", ViewModel);
            BindingHelper.CreateCommandBinding(this.SaveSettingsButton, "SaveSettingsCommand", ViewModel);

            KeybindingsListView.ItemsSource = vm.Keys.All;
            KeybindingsListView.SetBinding(ListView.ItemsSourceProperty, new Binding("All")
            {
                Source = vm.Keys,
                Mode   = BindingMode.OneWay
            });
            KeybindingsListView.SetBinding(ListView.SelectedItemProperty, new Binding("SelectedHotkey")
            {
                Source = ViewModel,
                Mode   = BindingMode.OneWayToSource
            });

            this.KeyDown += SettingsWindow_KeyDown;
            KeybindingsListView.Loaded += (o, e) =>
            {
                if (KeybindingsListView.SelectedIndex < 0)
                {
                    KeybindingsListView.SelectedIndex = 0;
                }
                ListViewItem row = (ListViewItem)KeybindingsListView.ItemContainerGenerator.ContainerFromIndex(KeybindingsListView.SelectedIndex);
                if (row != null && !FocusHelper.HasKeyboardFocus(row))
                {
                    Keyboard.Focus(row);
                }
            };
            KeybindingsListView.KeyUp += KeybindingsListView_KeyUp;

            CreateExtenderSettings();
            //this.WhenAnyValue(x => x.ViewModel.ExportExtenderSettingsCommand).BindTo(this, view => view.ExportExtenderSettingsButton.Command);
            //this.WhenAnyValue(x => x.ViewModel.SaveSettingsCommand).BindTo(this, view => view.SaveSettingsButton.Command);
        }
        void Cancel_Click(object sender, RoutedEventArgs e)
        {
            ClientStats.LogEvent("Cancel status update in realtime streams overview column");

            if (ShowViral)
            {
                ShowViral = false;
                OnPropertyChanged("ShowViral");

                SettingsManager.ClientSettings.AppConfiguration.IsFirstStatusUpdate = false;
                SettingsManager.Save();
            }
            else
            {
                ReplyTo = null;
                OnPropertyChanged("ReplyTo");
            }

            PART_StatusUpdateTextbox.Text = String.Empty;

            // Put focus back on listview
            FocusHelper.Focus(((TabItem)StreamsTab.SelectedItem));
        }
#pragma warning restore 1591
        private void initCommands()
        {
            CommandFocus = new RichDelegateCommand(
                Tobi_Plugin_ToolBars_Lang.CmdToolbarFocus_ShortDesc,
                null,
                null, // KeyGesture obtained from settings (see last parameters below)
                m_ShellView.LoadTangoIcon("applications-other"),
                () =>
            {
                if (FocusCollapsed.IsVisible)
                {
                    FocusHelper.FocusBeginInvoke(FocusCollapsed);
                }
                else
                {
                    FocusHelper.FocusBeginInvoke(FocusExpanded);
                }
            },
                () => true,
                Settings_KeyGestures.Default,
                PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Focus_Toolbar));
            m_ShellView.RegisterRichCommand(CommandFocus);
        }
        private bool TryGetFocusForRs3(UIObject breadcrumb, int indexToFocus, bool isEllipsisVisible, bool isRightToLeft)
        {
            Log.Comment("Try Set focus for RS3 build");

            UIObject anchor = RetrieveRTLCheckBox();

            FocusHelper.SetFocus(anchor);

            // For RS2 we need two Tab if the ellipsis is onscreen and 3 if it's not
            KeyboardHelper.PressKey(Key.Tab);
            KeyboardHelper.PressKey(Key.Tab);

            if (!isEllipsisVisible)
            {
                if (isRightToLeft)
                {
                    KeyboardHelper.PressKey(Key.Left);
                }
                else
                {
                    KeyboardHelper.PressKey(Key.Right);
                }
            }

            bool elementGotFocus = breadcrumb.Children[indexToFocus].HasKeyboardFocus;

            if (elementGotFocus)
            {
                Log.Comment("Got focus with RS3 way");
            }
            else
            {
                Log.Comment("Didn't got focus with RS3 way");
            }

            return(elementGotFocus);
        }
Пример #30
0
        private void OnIsDropDownOpenChangedSelector()
        {
            var selectorController = SelectorController;

            if (selectorController == null)
            {
                return;
            }

            if (IsDropDownOpen)
            {
                //selectorController.SuspendSelection();

                var selectedItem = selectorController.SelectedItem;

                if (selectedItem != null)
                {
                    ItemCollection.BringIntoViewInternal(new BringIntoViewRequest <TItem>(selectedItem, BringIntoViewMode.Top));

                    FocusNavigator.FocusedItem = selectedItem;
                    FocusHelper.QueryFocus(selectedItem);
                }
                else
                {
                    ItemCollection.BringIntoViewInternal(0);
                    FocusNavigator.ClearFocus();
                }
            }
            else
            {
                if (selectorController.IsSelectionSuspended)
                {
                    //selectorController.RestoreSelection();
                    //selectorController.ResumeSelection();
                }
            }
        }