Beispiel #1
0
        //Save framework focus element
        public static void FrameworkElementFocusSave(FrameworkElementFocus saveElement, FrameworkElement focusedElement)
        {
            try
            {
                AVActions.ActionDispatcherInvoke(delegate
                {
                    //Get the currently focused element
                    if (focusedElement == null)
                    {
                        focusedElement = (FrameworkElement)Keyboard.FocusedElement;
                    }

                    //Check the currently focused element
                    if (focusedElement != null)
                    {
                        //Get focus type
                        Type focusType = focusedElement.GetType().BaseType;

                        //Validate focus type
                        if (focusType == typeof(Window))
                        {
                            Debug.WriteLine("Invalid element focus type: " + focusType);
                            saveElement = null;
                            return;
                        }

                        //Check if save element is null
                        if (saveElement == null)
                        {
                            Debug.WriteLine("Save element is null creating new.");
                            saveElement = new FrameworkElementFocus();
                        }

                        //Save focused element
                        saveElement.FocusElement = focusedElement;
                        if (focusType == typeof(ListBoxItem))
                        {
                            saveElement.FocusListBox = AVFunctions.FindVisualParent <ListBox>(saveElement.FocusElement);
                            saveElement.FocusIndex   = saveElement.FocusListBox.SelectedIndex;
                        }

                        Debug.WriteLine("Saved element focus: " + focusedElement + " / index: " + saveElement.FocusIndex);
                    }
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed saving element focus: " + ex.Message);
            }
        }
Beispiel #2
0
        //Save framework focus element
        public static void FrameworkElementFocusSave(FrameworkElementFocus saveElement, FrameworkElement focusedElement)
        {
            try
            {
                AVActions.ActionDispatcherInvoke(delegate
                {
                    //Check if save element is null
                    if (saveElement == null)
                    {
                        Debug.WriteLine("Save element is null creating new.");
                        saveElement = new FrameworkElementFocus();
                    }

                    if (focusedElement != null)
                    {
                        saveElement.FocusElement = focusedElement;
                        if (saveElement.FocusElement != null && saveElement.FocusElement.GetType() == typeof(ListBoxItem))
                        {
                            saveElement.FocusListBox = AVFunctions.FindVisualParent <ListBox>(saveElement.FocusElement);
                            saveElement.FocusIndex   = saveElement.FocusListBox.SelectedIndex;
                        }
                        Debug.WriteLine("Saved focused element: " + focusedElement + " / index: " + saveElement.FocusIndex);
                    }
                    else
                    {
                        //Get the currently focused element
                        FrameworkElement frameworkElement = (FrameworkElement)Keyboard.FocusedElement;

                        //Check the currently focused element
                        if (frameworkElement != null)
                        {
                            saveElement.FocusElement = frameworkElement;
                            if (saveElement.FocusElement != null && saveElement.FocusElement.GetType() == typeof(ListBoxItem))
                            {
                                saveElement.FocusListBox = AVFunctions.FindVisualParent <ListBox>(saveElement.FocusElement);
                                saveElement.FocusIndex   = saveElement.FocusListBox.SelectedIndex;
                            }
                            Debug.WriteLine("Saved focused keyboard: " + frameworkElement + " / index: " + saveElement.FocusIndex);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed saving element focus: " + ex.Message);
            }
        }
Beispiel #3
0
 //Navigate arrow up
 void NavigateUp(ref bool Handled)
 {
     try
     {
         FrameworkElement frameworkElement = (FrameworkElement)Keyboard.FocusedElement;
         if (frameworkElement != null && frameworkElement.GetType() == typeof(ListBoxItem))
         {
             ListBox parentListbox = AVFunctions.FindVisualParent <ListBox>(frameworkElement);
             if (vVerticalLoopTargetLists.Contains(parentListbox.Name))
             {
                 if (parentListbox.SelectedIndex == 0)
                 {
                     int itemsCount = parentListbox.Items.Count;
                     ListboxFocusIndex(parentListbox, false, false, itemsCount - 1, vProcessCurrent.MainWindowHandle);
                     Handled = true;
                     return;
                 }
             }
         }
     }
     catch { }
 }
Beispiel #4
0
 //Listbox move to near character
 async Task ListBoxSelectNearCharacter(bool selectNextCharacter)
 {
     try
     {
         await AVActions.ActionDispatcherInvokeAsync(async delegate
         {
             FrameworkElement frameworkElement = (FrameworkElement)Keyboard.FocusedElement;
             if (frameworkElement != null && frameworkElement.GetType() == typeof(ListBoxItem))
             {
                 ListBox parentListbox = AVFunctions.FindVisualParent <ListBox>(frameworkElement);
                 if (vSelectTargetLists.Contains(parentListbox.Name))
                 {
                     if (parentListbox.Name == "lb_FilePicker")
                     {
                         await SelectNearCharacterFiles(selectNextCharacter, parentListbox);
                     }
                     else
                     {
                         await SelectNearCharacterApps(selectNextCharacter, parentListbox);
                     }
                 }
                 else
                 {
                     if (selectNextCharacter)
                     {
                         await KeySendSingle(KeysVirtual.Next, vProcessCurrent.MainWindowHandle);
                     }
                     else
                     {
                         await KeySendSingle(KeysVirtual.Prior, vProcessCurrent.MainWindowHandle);
                     }
                 }
             }
         });
     }
     catch { }
 }
Beispiel #5
0
 //Navigate arrow up
 void NavigateUp(ref bool Handled)
 {
     try
     {
         FrameworkElement frameworkElement = (FrameworkElement)Keyboard.FocusedElement;
         if (frameworkElement != null && frameworkElement.GetType() == typeof(ListBoxItem))
         {
             ListBox parentListbox = AVFunctions.FindVisualParent <ListBox>(frameworkElement);
             if (vTabTargetListsSingleColumn.Contains(parentListbox.Name))
             {
                 KeyPressReleaseCombo(KeysVirtual.Shift, KeysVirtual.Tab);
                 Handled = true;
                 return;
             }
             else if (vTabTargetListsFirstLastItem.Contains(parentListbox.Name))
             {
                 if (parentListbox.SelectedIndex == 0)
                 {
                     KeyPressReleaseCombo(KeysVirtual.Shift, KeysVirtual.Tab);
                     Handled = true;
                     return;
                 }
             }
             else if (vTabTargetListsFirstLastColumn.Contains(parentListbox.Name))
             {
                 if (ListBoxItemColumnPosition(parentListbox, (ListBoxItem)frameworkElement, true))
                 {
                     KeyPressReleaseCombo(KeysVirtual.Shift, KeysVirtual.Tab);
                     Handled = true;
                     return;
                 }
             }
             else if (vLoopTargetListsColumn.Contains(parentListbox.Name))
             {
                 if (parentListbox.SelectedIndex == 0)
                 {
                     int itemsCount = parentListbox.Items.Count;
                     ListboxFocusIndex(parentListbox, false, false, itemsCount - 1, vProcessCurrent.MainWindowHandle);
                     Handled = true;
                     return;
                 }
             }
         }
         else if (frameworkElement != null && frameworkElement.GetType() == typeof(Button))
         {
             if (vTabTargetButtonsDown.Any(x => x == frameworkElement.Name))
             {
                 KeyPressReleaseCombo(KeysVirtual.Shift, KeysVirtual.Tab);
                 Handled = true;
                 return;
             }
         }
         else if (frameworkElement != null && (frameworkElement.GetType() == typeof(TextBox) || frameworkElement.GetType() == typeof(Slider)))
         {
             KeyPressReleaseCombo(KeysVirtual.Shift, KeysVirtual.Tab);
             Handled = true;
             return;
         }
     }
     catch { }
 }