private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     if (eventType == EVENT_SYSTEM_FOREGROUND)
     {
         ActiveWindowChanged?.Invoke(this, hwnd);
     }
 }
        internal ProcessProvider(ActiveWindowChanged callback, string processName)
        {
            action = () =>
            {
                while (loop)
                {
                    var processes = Process.GetProcessesByName(processName);
                    var foregroundWindow = GetForegroundWindow();
                    var windowFound = false;

                    foreach (var window in processes.Select(EnumerateProcessWindowHandles).SelectMany(windows =>
                    {
                        var intPtrs = windows as IntPtr[] ?? windows.ToArray();
                        return intPtrs;
                    }).Where(window => foregroundWindow != hWndLast))
                    {
                        if (foregroundWindow != Process.GetCurrentProcess().MainWindowHandle)
                        {
                            hWndLast = window;
                            callback(foregroundWindow == window, window);
                        }
                    }

                    Thread.Sleep(150);
                }
            };

            Task.Factory.StartNew(action);
        }
示例#3
0
 public static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     var x = GetActiveWindowTitle();
     //if (wink != null)
     {
         ActiveWindowChanged?.Invoke(null, x);
         //wink.Lock = x != "GTA: San Andreas";
     }
 }
示例#4
0
        void SetActiveWindow(Window window)
        {
            if (_activeWindow == window)
            {
                return;
            }

            _activeWindow = window;
            ActiveWindowChanged?.Invoke(window, EventArgs.Empty);
        }
示例#5
0
 private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     switch (eventType)
     {
     case EVENT_SYSTEM_FOREGROUND:
     case EVENT_SYSTEM_MINIMIZESTART:
     case EVENT_SYSTEM_MINIMIZEEND:
         Task.Factory.StartNew(() => {
             ActiveWindowChanged?.Invoke(this, new ActiveWindowChangedEventArgs(hwnd));
         });
         break;
     }
 }
示例#6
0
        void SetActiveWindow(Window window)
        {
            if (_activeWindow == window)
            {
                return;
            }

            _activeWindow       = window;
            _activeWindowHandle = window is null
                                ? IntPtr.Zero
                                : WinRT.Interop.WindowNative.GetWindowHandle(window);

            ActiveWindowChanged?.Invoke(window, EventArgs.Empty);
        }
        private async Task CreateVisualComponentAsync(int instanceId)
        {
            var factory   = Services.GetService <IInteractiveWindowComponentContainerFactory>();
            var evaluator = new RInteractiveEvaluator(RSessions, RSession, History, Connections, Services, _settings, Console);

            var window            = factory.Create(instanceId, evaluator, RSessions);
            var interactiveWindow = window.InteractiveWindow;

            interactiveWindow.TextView.Closed += (_, __) => evaluator.Dispose();
            _operations.InteractiveWindow      = interactiveWindow;

            if (!RSessions.HasBroker)
            {
                var connectedToBroker = await Connections.TryConnectToPreviouslyUsedAsync();

                if (!connectedToBroker)
                {
                    var showConnectionsWindow = Connections.RecentConnections.Any();
                    if (!showConnectionsWindow)
                    {
                        var message = Resources.NoLocalR.FormatInvariant(Environment.NewLine + Environment.NewLine,
                                                                         Environment.NewLine);
                        var ui = Services.UI();
                        showConnectionsWindow = ui.ShowMessage(message, MessageButtons.YesNo) == MessageButtons.No;
                    }

                    if (!showConnectionsWindow)
                    {
                        var installer = Services.GetService <IMicrosoftRClientInstaller>();
                        installer.LaunchRClientSetup(Services);
                    }
                    else
                    {
                        var toolWindows = Services.GetService <IRInteractiveWorkflowToolWindowService>();
                        toolWindows.Connections().Show(focus: false, immediate: false);
                    }
                }
            }

            await interactiveWindow.InitializeAsync();

            RSession.RestartOnBrokerSwitch = true;

            ActiveWindow = window;
            ActiveWindow.Container.UpdateCommandStatus(true);
            _visualComponentTcs.SetResult(ActiveWindow);
            ActiveWindowChanged?.Invoke(this, new ActiveWindowChangedEventArgs(window));
        }
示例#8
0
 protected virtual void OnActiveWindowChanged()
 {
     ActiveWindowChanged?.Invoke(this, EventArgs.Empty);
 }
示例#9
0
 private static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     ActiveWindowHandle = hwnd;
     ActiveWindowChanged?.Invoke(null, hwnd);
 }
示例#10
0
 private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild,
                           uint dwEventThread, uint dwmsEventTime)
 {
     ActiveWindowChanged?.Invoke(hwnd);
 }
示例#11
0
 private void OnActiveWindowChanged()
 {
     ActiveWindowChanged?.Invoke(this, EventArgs.Empty);
 }
示例#12
0
 internal static void RaiseActiveWindowChanged() =>
 ActiveWindowChanged?.Invoke();