Handles the startup of the application, including ensuring that only a single instance is running.
        private void restartCairo(object sender, RoutedEventArgs e)
        {
            saveChanges();

            Startup.Restart();
        }
示例#2
0
        public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == appbarMessageId && appbarMessageId != -1)
            {
                switch ((NativeMethods.AppBarNotifications)wParam.ToInt32())
                {
                case NativeMethods.AppBarNotifications.PosChanged:
                    // Reposition to the top of the screen.
                    AppBarHelper.ABSetPos(this, Screen, this.ActualWidth * dpiScale, this.ActualHeight * dpiScale, AppBarHelper.ABEdge.ABE_TOP);
                    break;

                case NativeMethods.AppBarNotifications.FullScreenApp:
                    if ((int)lParam == 1)
                    {
                        CairoLogger.Instance.Debug("Cairo leaving on-top");
                        this.Topmost = false;
                        Shell.ShowWindowBottomMost(this.handle);

                        if (Settings.EnableTaskbar)
                        {
                            Startup.TaskbarWindow.SetFullScreenMode(true);
                        }
                    }
                    else
                    {
                        CairoLogger.Instance.Debug("Cairo entering on-top");
                        this.Topmost = true;
                        Shell.ShowWindowTopMost(this.handle);

                        if (Settings.EnableTaskbar)
                        {
                            Startup.TaskbarWindow.SetFullScreenMode(false);
                        }
                    }

                    break;

                case NativeMethods.AppBarNotifications.WindowArrange:
                    if ((int)lParam != 0)        // before
                    {
                        this.Visibility = Visibility.Collapsed;
                    }
                    else                             // after
                    {
                        this.Visibility = Visibility.Visible;
                    }

                    break;
                }
                handled = true;
            }
            else if (msg == NativeMethods.WM_ACTIVATE)
            {
                AppBarHelper.AppBarActivate(hwnd);
            }
            else if (msg == NativeMethods.WM_WINDOWPOSCHANGED)
            {
                AppBarHelper.AppBarWindowPosChanged(hwnd);
            }
            else if (msg == NativeMethods.WM_DPICHANGED)
            {
                if ((Settings.EnableMenuBarMultiMon || Settings.EnableTaskbarMultiMon) && !Startup.IsSettingScreens)
                {
                    Startup.ScreenSetup(); // update Cairo window list based on new screen setup
                }
                else if (!(Settings.EnableMenuBarMultiMon || Settings.EnableTaskbarMultiMon))
                {
                    Startup.ResetScreenCache();
                    Screen = System.Windows.Forms.Screen.PrimaryScreen;
                }

                if (Screen.Primary)
                {
                    Shell.DpiScale = (wParam.ToInt32() & 0xFFFF) / 96d;
                }

                this.dpiScale = (wParam.ToInt32() & 0xFFFF) / 96d;
                setPosition();
                AppBarHelper.ABSetPos(this, Screen, this.ActualWidth * dpiScale, this.ActualHeight * dpiScale, AppBarHelper.ABEdge.ABE_TOP);
            }
            else if (msg == NativeMethods.WM_DISPLAYCHANGE)
            {
                if ((Settings.EnableMenuBarMultiMon || Settings.EnableTaskbarMultiMon) && !Startup.IsSettingScreens && Screen.Primary)
                {
                    Startup.ScreenSetup(); // update Cairo window list based on new screen setup
                }
                else if (!(Settings.EnableMenuBarMultiMon || Settings.EnableTaskbarMultiMon))
                {
                    Startup.ResetScreenCache();
                    Screen = System.Windows.Forms.Screen.PrimaryScreen;
                }

                setPosition(((uint)lParam & 0xffff), ((uint)lParam >> 16));
                handled = true;
            }
            else if (msg == NativeMethods.WM_DEVICECHANGE && (int)wParam == 0x0007)
            {
                if ((Settings.EnableMenuBarMultiMon || Settings.EnableTaskbarMultiMon) && !Startup.IsSettingScreens && Screen.Primary)
                {
                    Startup.ScreenSetup(); // update Cairo window list based on new screen setup
                }
            }

            return(IntPtr.Zero);
        }
示例#3
0
        public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == NativeMethods.WM_MOUSEACTIVATE)
            {
                handled = true;
                return(new IntPtr(NativeMethods.MA_NOACTIVATE));
            }

            if (msg == appbarMessageId && appbarMessageId != -1 && Settings.TaskbarMode == 0)
            {
                switch ((NativeMethods.AppBarNotifications)wParam.ToInt32())
                {
                case NativeMethods.AppBarNotifications.PosChanged:
                    // Reposition to the top of the screen.
                    AppBarHelper.ABSetPos(this, Screen, ActualWidth * dpiScale, ActualHeight * dpiScale, appBarEdge);
                    break;

                case NativeMethods.AppBarNotifications.FullScreenApp:
                    SetFullScreenMode((int)lParam == 1);

                    break;

                case NativeMethods.AppBarNotifications.WindowArrange:
                    if ((int)lParam != 0)        // before
                    {
                        Visibility = Visibility.Collapsed;
                    }
                    else                             // after
                    {
                        Visibility = Visibility.Visible;
                    }

                    break;
                }
                handled = true;
            }
            else if (msg == NativeMethods.WM_ACTIVATE && Settings.TaskbarMode == 0)
            {
                AppBarHelper.AppBarActivate(hwnd);
            }
            else if (msg == NativeMethods.WM_WINDOWPOSCHANGED && Settings.TaskbarMode == 0)
            {
                AppBarHelper.AppBarWindowPosChanged(hwnd);
            }
            else if (msg == NativeMethods.WM_DPICHANGED)
            {
                if (!(Settings.EnableMenuBarMultiMon || Settings.EnableTaskbarMultiMon))
                {
                    Startup.ResetScreenCache();
                    Screen = System.Windows.Forms.Screen.PrimaryScreen;
                }

                if (Screen.Primary)
                {
                    Shell.DpiScale = (wParam.ToInt32() & 0xFFFF) / 96d;
                }

                dpiScale = (wParam.ToInt32() & 0xFFFF) / 96d;
                AppBarHelper.ABSetPos(this, Screen, this.ActualWidth * dpiScale, this.ActualHeight * dpiScale, appBarEdge);
            }
            else if (msg == NativeMethods.WM_DISPLAYCHANGE)
            {
                if (!(Settings.EnableMenuBarMultiMon || Settings.EnableTaskbarMultiMon))
                {
                    Startup.ResetScreenCache();
                    Screen = System.Windows.Forms.Screen.PrimaryScreen;
                }

                setPosition(((uint)lParam & 0xffff), ((uint)lParam >> 16));
                handled = true;
            }

            return(IntPtr.Zero);
        }
示例#4
0
 private void shutdown()
 {
     Startup.Shutdown();
 }
示例#5
0
        public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == appbarMessageId && appbarMessageId != -1)
            {
                switch ((NativeMethods.AppBarNotifications)wParam.ToInt32())
                {
                case NativeMethods.AppBarNotifications.PosChanged:
                    // Reposition to the top of the screen.
                    AppBarHelper.ABSetPos(this, Screen, this.ActualWidth * dpiScale, this.ActualHeight * dpiScale, AppBarHelper.ABEdge.ABE_TOP);
                    break;

                case NativeMethods.AppBarNotifications.FullScreenApp:
                    // we have our own implementation now

                    /*if ((int)lParam == 1)
                     * {
                     *  CairoLogger.Instance.Debug("Cairo leaving on-top");
                     *  this.Topmost = false;
                     *  Shell.ShowWindowBottomMost(this.handle);
                     *
                     *  if (Settings.Instance.EnableTaskbar)
                     *  {
                     *      Startup.TaskbarWindow.SetFullScreenMode(true);
                     *  }
                     * }
                     * else
                     * {
                     *  CairoLogger.Instance.Debug("Cairo entering on-top");
                     *  this.Topmost = true;
                     *  Shell.ShowWindowTopMost(this.handle);
                     *
                     *  if (Settings.Instance.EnableTaskbar)
                     *  {
                     *      Startup.TaskbarWindow.SetFullScreenMode(false);
                     *  }
                     * }
                     */
                    break;

                case NativeMethods.AppBarNotifications.WindowArrange:
                    if ((int)lParam != 0)        // before
                    {
                        this.Visibility = Visibility.Collapsed;
                    }
                    else                             // after
                    {
                        this.Visibility = Visibility.Visible;
                    }

                    break;
                }
                handled = true;
            }
            else if (msg == NativeMethods.WM_ACTIVATE)
            {
                AppBarHelper.AppBarActivate(hwnd);
            }
            else if (msg == NativeMethods.WM_WINDOWPOSCHANGING)
            {
                // Extract the WINDOWPOS structure corresponding to this message
                NativeMethods.WINDOWPOS wndPos = NativeMethods.WINDOWPOS.FromMessage(lParam);

                // Determine if the z-order is changing (absence of SWP_NOZORDER flag)
                // If we are intentionally trying to become topmost, make it so
                if (isRaising && (wndPos.flags & NativeMethods.SetWindowPosFlags.SWP_NOZORDER) == 0)
                {
                    // Sometimes Windows thinks we shouldn't go topmost, so poke here to make it happen.
                    wndPos.hwndInsertAfter = (IntPtr)NativeMethods.HWND_TOPMOST;
                    wndPos.UpdateMessage(lParam);
                }
            }
            else if (msg == NativeMethods.WM_WINDOWPOSCHANGED)
            {
                AppBarHelper.AppBarWindowPosChanged(hwnd);
            }
            else if (msg == NativeMethods.WM_DPICHANGED)
            {
                if ((Settings.Instance.EnableMenuBarMultiMon || Configuration.Settings.Instance.EnableTaskbarMultiMon) && !Startup.IsSettingScreens)
                {
                    Startup.ScreenSetup(); // update Cairo window list based on new screen setup
                }
                else if (!(Settings.Instance.EnableMenuBarMultiMon || Configuration.Settings.Instance.EnableTaskbarMultiMon))
                {
                    Startup.ResetScreenCache();
                    Screen = System.Windows.Forms.Screen.PrimaryScreen;
                }

                if (Screen.Primary)
                {
                    Shell.DpiScale = (wParam.ToInt32() & 0xFFFF) / 96d;
                }

                this.dpiScale = (wParam.ToInt32() & 0xFFFF) / 96d;
                setPosition();
                AppBarHelper.ABSetPos(this, Screen, this.ActualWidth * dpiScale, this.ActualHeight * dpiScale, AppBarHelper.ABEdge.ABE_TOP);
            }
            else if (msg == NativeMethods.WM_DISPLAYCHANGE)
            {
                if ((Settings.Instance.EnableMenuBarMultiMon || Configuration.Settings.Instance.EnableTaskbarMultiMon) && !Startup.IsSettingScreens && Screen.Primary)
                {
                    Startup.ScreenSetup(); // update Cairo window list based on new screen setup
                }
                else if (!(Settings.Instance.EnableMenuBarMultiMon || Configuration.Settings.Instance.EnableTaskbarMultiMon))
                {
                    Startup.ResetScreenCache();
                    Screen = System.Windows.Forms.Screen.PrimaryScreen;
                }

                setPosition(((uint)lParam & 0xffff), ((uint)lParam >> 16));
                handled = true;
            }
            else if (msg == NativeMethods.WM_DEVICECHANGE && (int)wParam == 0x0007)
            {
                if ((Settings.Instance.EnableMenuBarMultiMon || Configuration.Settings.Instance.EnableTaskbarMultiMon) && !Startup.IsSettingScreens && Screen.Primary)
                {
                    Startup.ScreenSetup(); // update Cairo window list based on new screen setup
                }
            }

            return(IntPtr.Zero);
        }