Пример #1
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();
        }
Пример #2
0
        void _excelToolTipWatcher_ToolTipChanged(object sender, ExcelToolTipWatcher.ToolTipChangeEventArgs e)
        {
            // We assume the ExcelToolTip changes happen before the corresponding FunctionList / FormulaEdit changes
            // So we keep track of the last shown one.
            // This allows the FormulaEdit or transitions to pick it up, hopefully not getting confused with the FunctionList tooltip
            // TODO: Check that the tooltip gets cleared from the CurrentState is it is hidden

            Logger.Monitor.Verbose($"!> ExcelToolTip ToolTipChanged Received: {e} with state: {CurrentState.GetType().Name}");

            if (e.ChangeType == ExcelToolTipWatcher.ToolTipChangeType.Show)
            {
                _lastExcelToolTipShown = e.Handle;
            }
            else if (e.ChangeType == ExcelToolTipWatcher.ToolTipChangeType.Hide)
            {
                if (_lastExcelToolTipShown == e.Handle)
                    _lastExcelToolTipShown = _excelToolTipWatcher.GetLastToolTipOrZero();

                var fe = CurrentState as UIState.FormulaEdit;
                if (fe != null)
                {
                    // Either a FormulaEdit or a FunctionList
                    if (fe.ExcelToolTipWindow == e.Handle)
                    {
                        // OK - it's no longer valid
                        // TODO: Manage the state update
                        // This is a kind of pop.... is it right?
                        var newState = fe.WithToolTipWindow(_lastExcelToolTipShown);
                        OnStateChanged(newState);
                    }
                }
            }
        }
Пример #3
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();
        }