コード例 #1
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();
        }
コード例 #2
0
ファイル: UIMonitor.cs プロジェクト: jmptrader/IntelliSense
        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");
        }
コード例 #3
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;
        }
コード例 #4
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;
        }
コード例 #5
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");
        }
コード例 #6
0
ファイル: UIMonitor.cs プロジェクト: Excel-DNA/IntelliSense
        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");
        }
コード例 #7
0
ファイル: UIMonitor.cs プロジェクト: zqwght/IntelliSense
        // 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();
        }
コード例 #8
0
ファイル: UIMonitor.cs プロジェクト: Excel-DNA/IntelliSense
        // 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();
        }
コード例 #9
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();
        }