상속: IDisposable
예제 #1
0
 public PopupListWatcher(WindowWatcher windowWatcher, SynchronizationContext syncContextAuto)
 {
     _syncContextAuto = syncContextAuto;
     _windowWatcher   = windowWatcher;
     _windowWatcher.PopupListWindowChanged     += _windowWatcher_PopupListWindowChanged;
     _windowWatcher.FormulaEditLocationChanged += _windowWatcher_FormulaEditLocationChanged;
 }
 public void Dispose()
 {
     Logger.WindowWatcher.Info("ExcelToolTip Dispose Begin");
     _windowWatcher.ExcelToolTipWindowChanged -= _windowWatcher_ExcelToolTipWindowChanged;
     _windowWatcher = null;
     Logger.WindowWatcher.Info("ExcelToolTip Dispose End");
 }
예제 #3
0
 public FormulaEditWatcher(WindowWatcher windowWatcher, SynchronizationContext syncContextAuto)
 {
     _syncContextAuto = syncContextAuto;
     _windowWatcher   = windowWatcher;
     _windowWatcher.FormulaBarWindowChanged += _windowWatcher_FormulaBarWindowChanged;
     _windowWatcher.InCellEditWindowChanged += _windowWatcher_InCellEditWindowChanged;
 }
예제 #4
0
 public void Dispose()
 {
     Logger.WindowWatcher.Info($"PopupList Dispose Begin");
     _windowWatcher.PopupListWindowChanged -= _windowWatcher_PopupListWindowChanged;
     _windowWatcher = null;
     _selectionChangeHook?.Dispose();
     Logger.WindowWatcher.Info($"PopupList Dispose End");
 }
예제 #5
0
 public FormulaEditWatcher(WindowWatcher windowWatcher, SynchronizationContext syncContextAuto, SynchronizationContext syncContextMain)
 {
     _syncContextAuto = syncContextAuto;
     _syncContextMain = syncContextMain;
     _windowWatcher   = windowWatcher;
     _windowWatcher.FormulaBarWindowChanged += _windowWatcher_FormulaBarWindowChanged;
     _windowWatcher.InCellEditWindowChanged += _windowWatcher_InCellEditWindowChanged;
     _updateEditStateAfterTimeout            = new RenewableDelayExecutor(DelayBeforeStateUpdateMilliseconds, () => UpdateEditState());
 }
예제 #6
0
 public FormulaEditWatcher(WindowWatcher windowWatcher, SynchronizationContext syncContext)
 {
     windowWatcher.FormulaBarWindowChanged += delegate { WatchFormulaBar(windowWatcher.FormulaBarWindow); };
     windowWatcher.InCellEditWindowChanged += delegate { WatchInCellEdit(windowWatcher.InCellEditWindow); };
     windowWatcher.InCellEditFocused       += FocusChanged;
     windowWatcher.FormulaBarFocused       += FocusChanged;
     windowWatcher.MainWindowChanged       += SubscribeBoundingRectangleProperty;
     _syncContext = syncContext;
 }
 public void Dispose()
 {
     Debug.Assert(Thread.CurrentThread.ManagedThreadId == 1);
     Logger.WindowWatcher.Info("PopupList Dispose Begin");
     _windowWatcher.PopupListWindowChanged -= _windowWatcher_PopupListWindowChanged;
     _windowWatcher = null;
     _selectionChangeHook.Dispose();
     Logger.WindowWatcher.Info("PopupList Dispose End");
 }
예제 #8
0
        public void Dispose()
        {
            Logger.WindowWatcher.Info($"ExcelToolTip Dispose Begin");
            _windowWatcher.ExcelToolTipWindowChanged -= _windowWatcher_ExcelToolTipWindowChanged;
            _windowWatcher = null;

            //_syncContextAuto.Send(delegate
            //{
            //    Debug.Print("Disposing ExcelToolTipWatcher - In Automation context");
            //}, null);
            Logger.WindowWatcher.Info($"ExcelToolTip Dispose End");
        }
예제 #9
0
        public void Dispose()
        {
            Logger.WindowWatcher.Info($"ExcelToolTip Dispose Begin");
            _windowWatcher.ExcelToolTipWindowChanged -= _windowWatcher_ExcelToolTipWindowChanged;
            _windowWatcher = null;

            //_syncContextAuto.Send(delegate
            //{
            //    Debug.Print("Disposing ExcelToolTipWatcher - In Automation context");
            //}, null);
            Logger.WindowWatcher.Info($"ExcelToolTip Dispose End");
        }
예제 #10
0
        void RunUIAutomation(string xllPath)
        {
            // NOTE: Add for separate UI Automation Thread
            _syncContextAuto = new WindowsFormsSynchronizationContext();
            //_syncContextAuto = _syncContextMain;

            _windowWatcher      = new WindowWatcher(xllPath);
            _formulaEditWatcher = new FormulaEditWatcher(_windowWatcher, _syncContextAuto);
            _popupListWatcher   = new PopupListWatcher(_windowWatcher, _syncContextAuto);

            _windowWatcher.MainWindowChanged      += OnMainWindowChanged;
            _popupListWatcher.SelectedItemChanged += OnSelectedItemChanged;
            _formulaEditWatcher.StateChanged      += OnStateChanged;

            _windowWatcher.TryInitialize();
            // NOTE: Add for separate UI Automation Thread
            Application.Run();
        }
예제 #11
0
        private void SubscribeBoundingRectangleProperty(object sender, EventArgs args)
        {
            _syncContext.Post(delegate
            {
                if (_mainWindow != null)
                {
                    Automation.RemoveAutomationPropertyChangedEventHandler(_mainWindow, LocationChanged);
                }

                WindowWatcher windowWatcher = (WindowWatcher)sender;

                if (windowWatcher.MainWindow != IntPtr.Zero)
                {
                    _mainWindow = AutomationElement.FromHandle(windowWatcher.MainWindow);
                    Automation.AddAutomationPropertyChangedEventHandler(_mainWindow, TreeScope.Element, LocationChanged, AutomationElement.BoundingRectangleProperty);
                }
            }, null);
        }
예제 #12
0
        public void Dispose()
        {
            Logger.WindowWatcher.Info($"PopupList Dispose Begin");
            _windowWatcher.PopupListWindowChanged -= _windowWatcher_PopupListWindowChanged;
            _windowWatcher = null;

            _syncContextAuto.Send(delegate
            {
                Debug.Print("Disposing PopupListWatcher - In Automation context");
                if (_popupList != null)
                {
                    //Automation.RemoveAutomationEventHandler(SelectionItemPattern.ElementSelectedEvent, _popupList, PopupListElementSelectedHandler);
                    //Automation.RemoveAutomationPropertyChangedEventHandler(_popupList, PopupListBoundsChanged);
                    _popupList = null;
                }
            }, null);
            Logger.WindowWatcher.Info($"PopupList Dispose End");
        }
예제 #13
0
        public void Dispose()
        {
            Logger.Monitor.Info($"UIMonitor Dispose Begin");

            if (_syncContextAuto == null)
            {
                return;
            }

            // Send is not supported on _syncContextAuto
            _syncContextAuto.Send(delegate
            {
                // Remove all event handlers ASAP
                Automation.RemoveAllEventHandlers();
                if (_windowWatcher != null)
                {
//                        _windowWatcher.MainWindowChanged -= _windowWatcher_MainWindowChanged;
                    // _windowWatcher.SelectDataSourceWindowChanged -= _windowWatcher_SelectDataSourceWindowChanged;
                    _windowWatcher.Dispose();
                    _windowWatcher = null;
                }
                if (_formulaEditWatcher != null)
                {
                    _formulaEditWatcher.StateChanged -= _formulaEditWatcher_StateChanged;
                    _formulaEditWatcher.Dispose();
                    _formulaEditWatcher = null;
                }
                if (_popupListWatcher != null)
                {
                    _popupListWatcher.SelectedItemChanged -= _popupListWatcher_SelectedItemChanged;
                    _popupListWatcher.Dispose();
                    _popupListWatcher = null;
                }
            }, null);

            // Let the above delegate and nested calls run, then clean up.
            // (not sure it makes a difference anymore...)
            _syncContextAuto.Post(delegate
            {
                _syncContextAuto.Complete();
                _syncContextAuto = null;
            }, null);
            Logger.Monitor.Info($"UIMonitor Dispose End");
        }
예제 #14
0
        public void Dispose()
        {
            _current._syncContextAuto.Send(delegate
            {
                if (_windowWatcher != null)
                {
                    _windowWatcher.MainWindowChanged -= OnMainWindowChanged;
                    _windowWatcher.Dispose();
                    _windowWatcher = null;
                }
                if (_formulaEditWatcher != null)
                {
                    _formulaEditWatcher.StateChanged -= OnStateChanged;
                    _formulaEditWatcher.Dispose();
                    _formulaEditWatcher = null;
                }
                if (_popupListWatcher != null)
                {
                    _popupListWatcher.SelectedItemChanged -= OnSelectedItemChanged;
                    _popupListWatcher.Dispose();
                    _popupListWatcher = null;
                }
            }, null);

            _syncContextMain.Send(delegate
            {
                if (_descriptionToolTip != null)
                {
                    _descriptionToolTip.Dispose();
                    _descriptionToolTip = null;
                }
                if (_argumentsToolTip != null)
                {
                    _argumentsToolTip.Dispose();
                    _argumentsToolTip = null;
                }
            }, null);

            // NOTE: Add for separate UI Automation Thread
            _threadAuto.Abort();
            _threadAuto      = null;
            _syncContextAuto = null;
            _syncContextMain = null;
        }
예제 #15
0
        public void Dispose()
        {
            _current._syncContextAuto.Send(delegate
                {
                    if (_windowWatcher != null)
                    {
                        _windowWatcher.MainWindowChanged -= OnMainWindowChanged;
                        _windowWatcher.Dispose();
                        _windowWatcher = null;
                    }
                    if (_formulaEditWatcher != null)
                    {
                        _formulaEditWatcher.StateChanged -= OnStateChanged;
                        _formulaEditWatcher.Dispose();
                        _formulaEditWatcher = null;
                    }
                    if (_popupListWatcher != null)
                    {
                        _popupListWatcher.SelectedItemChanged -= OnSelectedItemChanged;
                        _popupListWatcher.Dispose();
                        _popupListWatcher = null;
                    }
                }, null);

            _syncContextMain.Send(delegate
                {
                    if (_descriptionToolTip != null)
                    {
                        _descriptionToolTip.Dispose();
                        _descriptionToolTip = null;
                    }
                    if (_argumentsToolTip != null)
                    {
                        _argumentsToolTip.Dispose();
                        _argumentsToolTip = null;
                    }
                }, null);

            // NOTE: Add for separate UI Automation Thread
            _threadAuto.Abort();
            _threadAuto = null;
            _syncContextAuto = null;
            _syncContextMain = null;
        }
예제 #16
0
        // Must run on the main thread
        public void Dispose()
        {
            Debug.Assert(Thread.CurrentThread.ManagedThreadId == 1);
            Logger.Monitor.Info($"UIMonitor Dispose Begin");

            IntelliSenseEvents.Instance.OnIntellisenseInvalidated -= OnNewIntelliSenseDataAvailable;

            // Remove all event handlers ASAP
            // Since we are running on the main thread, we call Dispose directly
            // (might not be in a context where we can post to or wait for main thread sync context)
            if (_windowWatcher != null)
            {
                _windowWatcher.Dispose();
                _windowWatcher = null;
            }
            if (_formulaEditWatcher != null)
            {
                _formulaEditWatcher.StateChanged -= _formulaEditWatcher_StateChanged;
                _formulaEditWatcher.Dispose();
                _formulaEditWatcher = null;
            }
            if (_popupListWatcher != null)
            {
                _popupListWatcher.SelectedItemChanged -= _popupListWatcher_SelectedItemChanged;
                _popupListWatcher.Dispose();
                _popupListWatcher = null;
            }

            if (_syncContextAuto == null)
            {
                Debug.Fail("Unexpected");
                return;
            }

            // Let the above delegate and nested calls run, then clean up.
            // (not sure it makes a difference anymore...)
            _syncContextAuto.Post(delegate
            {
                _syncContextAuto.Complete();
                _syncContextAuto = null;
            }, null);
            Logger.Monitor.Info($"UIMonitor Dispose End");
        }
예제 #17
0
        public void Dispose()
        {
            Logger.Monitor.Info($"UIMonitor Dispose Begin");

            if (_syncContextAuto == null)
                return;

            // Send is not supported on _syncContextAuto
            _syncContextAuto.Send(delegate
                {
                    // Remove all event handlers ASAP
                    Automation.RemoveAllEventHandlers();
                    if (_windowWatcher != null)
                    {
            //                        _windowWatcher.MainWindowChanged -= _windowWatcher_MainWindowChanged;
                        // _windowWatcher.SelectDataSourceWindowChanged -= _windowWatcher_SelectDataSourceWindowChanged;
                        _windowWatcher.Dispose();
                        _windowWatcher = null;
                    }
                    if (_formulaEditWatcher != null)
                    {
                        _formulaEditWatcher.StateChanged -= _formulaEditWatcher_StateChanged;
                        _formulaEditWatcher.Dispose();
                        _formulaEditWatcher = null;
                    }
                    if (_popupListWatcher != null)
                    {
                        _popupListWatcher.SelectedItemChanged -= _popupListWatcher_SelectedItemChanged;
                        _popupListWatcher.Dispose();
                        _popupListWatcher = null;
                    }

                }, null);

            // Let the above delegate and nested calls run, then clean up.
            // (not sure it makes a difference anymore...)
            _syncContextAuto.Post(delegate
            {
                _syncContextAuto.Complete();
                _syncContextAuto = null;
            }, null);
            Logger.Monitor.Info($"UIMonitor Dispose End");
        }
예제 #18
0
        public FormulaEditWatcher(WindowWatcher windowWatcher, SynchronizationContext syncContextAuto)
        {
            _syncContextAuto = syncContextAuto;
            _windowWatcher = windowWatcher;
            _windowWatcher.FormulaBarWindowChanged += _windowWatcher_FormulaBarWindowChanged;
            _windowWatcher.InCellEditWindowChanged += _windowWatcher_InCellEditWindowChanged;

            // Focus event handler works beautifully, but Breaks the PopupList SelectedItemChange event handler ... !?
            //_syncContextAuto.Post(_ =>
            //{
            //    try
            //    {
            //        Automation.AddAutomationFocusChangedEventHandler(FocusChangedEventHandler);
            //        Logger.WindowWatcher.Verbose("FormulaEditWatcher Focus event handler added");
            //    }
            //    catch (Exception ex)
            //    {
            //        Logger.WindowWatcher.Warn($"FormulaEditWatcher Error adding focus event handler {ex}");
            //    }
            //}, null);
        }
예제 #19
0
        public FormulaEditWatcher(WindowWatcher windowWatcher, SynchronizationContext syncContextAuto)
        {
            _syncContextAuto = syncContextAuto;
            _windowWatcher   = windowWatcher;
            _windowWatcher.FormulaBarWindowChanged += _windowWatcher_FormulaBarWindowChanged;
            _windowWatcher.InCellEditWindowChanged += _windowWatcher_InCellEditWindowChanged;

            // Focus event handler works beautifully, but Breaks the PopupList SelectedItemChange event handler ... !?
            //_syncContextAuto.Post(_ =>
            //{
            //    try
            //    {
            //        Automation.AddAutomationFocusChangedEventHandler(FocusChangedEventHandler);
            //        Logger.WindowWatcher.Verbose("FormulaEditWatcher Focus event handler added");
            //    }
            //    catch (Exception ex)
            //    {
            //        Logger.WindowWatcher.Warn($"FormulaEditWatcher Error adding focus event handler {ex}");
            //    }
            //}, null);
        }
예제 #20
0
        // This runs on the new thread we've created to do all the Automation stuff (_threadAuto)
        // It returns only after when the SyncContext.Complete() has been called (from the IntelliSenseDisplay.Dispose() below)
        void RunUIAutomation()
        {
            _syncContextAuto = new SingleThreadSynchronizationContext();

            Logger.Monitor.Verbose("UIMonitor.RunUIAutomation installing watchers");

            // Create and hook together the various watchers
            _windowWatcher       = new WindowWatcher(_syncContextAuto);
            _formulaEditWatcher  = new FormulaEditWatcher(_windowWatcher, _syncContextAuto);
            _popupListWatcher    = new PopupListWatcher(_windowWatcher, _syncContextAuto);
            _excelToolTipWatcher = new ExcelToolTipWatcher(_windowWatcher, _syncContextAuto);

            // These are the events we're interested in for showing, hiding and updating the IntelliSense forms
            _popupListWatcher.SelectedItemChanged += _popupListWatcher_SelectedItemChanged;
            _formulaEditWatcher.StateChanged      += _formulaEditWatcher_StateChanged;
            _excelToolTipWatcher.ToolTipChanged   += _excelToolTipWatcher_ToolTipChanged;

            _windowWatcher.TryInitialize();

            _syncContextAuto.RunOnCurrentThread();
        }
예제 #21
0
 // Runs on our automation thread
 void _windowWatcher_ExcelToolTipWindowChanged(object sender, WindowWatcher.WindowChangedEventArgs e)
 {
     switch (e.Type)
     {
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Show:
             if (!_toolTips.Contains(e.WindowHandle))
             {
                 _toolTips.Add(e.WindowHandle);
                 ToolTipChanged?.Invoke(this, new ToolTipChangeEventArgs(ToolTipChangeType.Show, e.WindowHandle));
             }
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Hide:
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Destroy:
             if (_toolTips.Remove(e.WindowHandle))
                 ToolTipChanged?.Invoke(this, new ToolTipChangeEventArgs(ToolTipChangeType.Hide, e.WindowHandle));
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Create:
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Focus:
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Unfocus:
         default:
             // Ignoring these....
             break;
     }
 }
예제 #22
0
 public ExcelToolTipWatcher(WindowWatcher windowWatcher, SynchronizationContext syncContextAuto)
 {
     _syncContextAuto = syncContextAuto;
     _windowWatcher   = windowWatcher;
     _windowWatcher.ExcelToolTipWindowChanged += _windowWatcher_ExcelToolTipWindowChanged;
 }
예제 #23
0
 public ExcelToolTipWatcher (WindowWatcher windowWatcher, SynchronizationContext syncContextAuto)
 {
     _syncContextAuto = syncContextAuto;
     _windowWatcher = windowWatcher;
     _windowWatcher.ExcelToolTipWindowChanged += _windowWatcher_ExcelToolTipWindowChanged;
 }
예제 #24
0
 public PopupListWatcher(WindowWatcher windowWatcher, SynchronizationContext syncContext)
 {
     _syncContext = syncContext;
     windowWatcher.PopupListWindowChanged += delegate { WatchPopupList(windowWatcher.PopupListWindow); };
     windowWatcher.MainWindowChanged      += SubscribeBoundingRectangleProperty;
 }
예제 #25
0
 // Runs on the Automation thread
 void _windowWatcher_FormulaBarWindowChanged(object sender, WindowWatcher.WindowChangedEventArgs e)
 {
     switch (e.Type)
     {
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Create:
             // CONSIDER: Is this too soon to set up the AutomationElement ??
             SetEditWindow(e.WindowHandle, ref _hwndFormulaBar, ref _formulaBar);
             UpdateEditState();
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Destroy:
             //if (_formulaEditFocus == FormulaEditFocus.FormulaBar)
             //{
             //    _formulaEditFocus = FormulaEditFocus.None;
             //    UpdateEditState();
             //}
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Focus:
             if (_formulaEditFocus != FormulaEditFocus.FormulaBar)
             {
                 Logger.WindowWatcher.Verbose($"FormulaEdit - FormulaBar Focus");
                 _formulaEditFocus = FormulaEditFocus.FormulaBar;
                 UpdateFormulaPolling();
                 UpdateEditState();
             }
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Unfocus:
             if (_formulaEditFocus == FormulaEditFocus.FormulaBar)
             {
                 Logger.WindowWatcher.Verbose($"FormulaEdit - FormulaBar Unfocus");
                 _formulaEditFocus = FormulaEditFocus.None;
                 UpdateFormulaPolling();
                 UpdateEditState();
             }
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Show:
                 Logger.WindowWatcher.Verbose($"FormulaEdit - FormulaBar Show");
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Hide:
                 Logger.WindowWatcher.Verbose($"FormulaEdit - FormulaBar Hide");
             break;
         default:
             throw new ArgumentOutOfRangeException("Unexpected Window Change Type", "e.Type");
     }
 }
예제 #26
0
 // Runs on the Automation thread
 void _windowWatcher_InCellEditWindowChanged(object sender, WindowWatcher.WindowChangedEventArgs e)
 {
     switch (e.Type)
     {
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Create:
             // CONSIDER: Is this too soon to set up the AutomationElement ??
             // TODO: Yes - need to do AutomationElement later (new Window does not have TextPattern ready)
             SetEditWindow(e.WindowHandle, ref _hwndInCellEdit, ref _inCellEdit);
             UpdateEditState();
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Destroy:
             //if (_formulaEditFocus == FormulaEditFocus.InCellEdit)
             //{
             //    _formulaEditFocus = FormulaEditFocus.None;
             //    UpdateEditState();
             //}
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Focus:
             if (_formulaEditFocus != FormulaEditFocus.InCellEdit)
             {
                 Logger.WindowWatcher.Verbose($"FormulaEdit - InCellEdit Focus");
                 _formulaEditFocus = FormulaEditFocus.InCellEdit;
                 UpdateFormulaPolling();
                 UpdateEditState();
             }
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Unfocus:
             if (_formulaEditFocus == FormulaEditFocus.InCellEdit)
             {
                 Logger.WindowWatcher.Verbose($"FormulaEdit - InCellEdit Unfocus");
                 _formulaEditFocus = FormulaEditFocus.None;
                 UpdateFormulaPolling();
                 UpdateEditState();
             }
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Show:
             Logger.WindowWatcher.Verbose($"FormulaEdit - InCellEdit Show");
             break;
         case WindowWatcher.WindowChangedEventArgs.ChangeType.Hide:
             Logger.WindowWatcher.Verbose($"FormulaEdit - InCellEdit Hide");
             break;
         default:
             throw new ArgumentOutOfRangeException("Unexpected Window Change Type", "e.Type");
     }
 }
예제 #27
0
        // This runs on the new thread we've created to do all the Automation stuff (_threadAuto)
        // It returns only after when the SyncContext.Complete() has been called (from the IntelliSenseDisplay.Dispose() below)
        void RunUIAutomation()
        {
            _syncContextAuto = new SingleThreadSynchronizationContext();

            Logger.Monitor.Verbose("UIMonitor.RunUIAutomation installing watchers");

            // Create and hook together the various watchers
            _windowWatcher = new WindowWatcher(_syncContextAuto);
            _formulaEditWatcher = new FormulaEditWatcher(_windowWatcher, _syncContextAuto);
            _popupListWatcher = new PopupListWatcher(_windowWatcher, _syncContextAuto);
            _excelToolTipWatcher = new ExcelToolTipWatcher(_windowWatcher, _syncContextAuto);

            // These are the events we're interested in for showing, hiding and updating the IntelliSense forms
              //          _windowWatcher.MainWindowChanged += _windowWatcher_MainWindowChanged;
            // _windowWatcher.SelectDataSourceWindowChanged += _windowWatcher_SelectDataSourceWindowChanged;
            _popupListWatcher.SelectedItemChanged += _popupListWatcher_SelectedItemChanged;
            _formulaEditWatcher.StateChanged += _formulaEditWatcher_StateChanged;
            _excelToolTipWatcher.ToolTipChanged += _excelToolTipWatcher_ToolTipChanged;

            _windowWatcher.TryInitialize();

            _syncContextAuto.RunOnCurrentThread();
        }
예제 #28
0
 //// Runs on our automation thread
 //void _windowWatcher_MainWindowChanged(object sender, EventArgs args)
 //{
 //    Logger.Monitor.Verbose("!> MainWindowChanged");
 //    Logger.Monitor.Verbose("!> " + ReadCurrentState().ToString());
 //    OnStateChanged();
 //}
 // Runs on our automation thread
 void _windowWatcher_SelectDataSourceWindowChanged(object sender, WindowWatcher.WindowChangedEventArgs args)
 {
     Logger.Monitor.Verbose($"!> SelectDataSourceWindowChanged ({args.Type})");
     OnStateChanged();
 }
예제 #29
0
 public FormulaEditWatcher(WindowWatcher windowWatcher, SynchronizationContext syncContext)
 {
     windowWatcher.FormulaBarWindowChanged += delegate { WatchFormulaBar(windowWatcher.FormulaBarWindow); };
     windowWatcher.InCellEditWindowChanged += delegate { WatchInCellEdit(windowWatcher.InCellEditWindow); };
     windowWatcher.InCellEditFocused += FocusChanged;
     windowWatcher.FormulaBarFocused += FocusChanged;
     windowWatcher.MainWindowChanged += SubscribeBoundingRectangleProperty;
     _syncContext = syncContext;
 }
예제 #30
0
 public PopupListWatcher(WindowWatcher windowWatcher, SynchronizationContext syncContext)
 {
     _syncContext = syncContext;
     windowWatcher.PopupListWindowChanged += delegate { WatchPopupList(windowWatcher.PopupListWindow); };
     windowWatcher.MainWindowChanged += SubscribeBoundingRectangleProperty;
 }
예제 #31
0
        void RunUIAutomation(string xllPath)
        {
            // NOTE: Add for separate UI Automation Thread
            _syncContextAuto = new WindowsFormsSynchronizationContext();
            //_syncContextAuto = _syncContextMain;

            _windowWatcher = new WindowWatcher(xllPath);
            _formulaEditWatcher = new FormulaEditWatcher(_windowWatcher, _syncContextAuto);
            _popupListWatcher = new PopupListWatcher(_windowWatcher, _syncContextAuto);

            _windowWatcher.MainWindowChanged += OnMainWindowChanged;
            _popupListWatcher.SelectedItemChanged += OnSelectedItemChanged;
            _formulaEditWatcher.StateChanged += OnStateChanged;

            _windowWatcher.TryInitialize();
            // NOTE: Add for separate UI Automation Thread
             Application.Run();
        }