Ejemplo n.º 1
0
        public static void Main()
        {
            if (!SingleInstanceCheck())
            {
                return;
            }

            // If framework is not correct version then quit.
            if (!FrameworkCheck())
            {
                return;
            }

            InitializeParentWindow();

            App app = new App();

            MenuBarWindow = new MenuBar() { Owner = _parentWindow };
            MenuBarWindow.Show();
            app.MainWindow = MenuBarWindow;

#if (ENABLEFIRSTRUN)
            FirstRun(app);
#endif

            if (Properties.Settings.Default.EnableMenuBarShadow)
            {
                MenuBarShadowWindow = new MenuBarShadow() { Owner = _parentWindow };
                MenuBarShadowWindow.Show();
            }

            if (Properties.Settings.Default.EnableTaskbar)
            {
                TaskbarWindow = new Taskbar() { Owner = _parentWindow };
                TaskbarWindow.Show();
            }

            if (Properties.Settings.Default.EnableDesktop)
            {
                DesktopWindow = new Desktop() { Owner = _parentWindow };
                DesktopWindow.Show();
            }
            
            app.Run();

        }
Ejemplo n.º 2
0
        public static void Main()
        {
            #region Single Instance Check
            bool ok;
            cairoMutex = new System.Threading.Mutex(true, "CairoShell", out ok);

            if (!ok)
            {
                // Another instance is already running.
                return;
            }
            #endregion

            #region some real shell code
            int hShellReadyEvent;

            if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 5)
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, true, @"Global\msgina: ShellReadyEvent");
            else
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, false, "msgina: ShellReadyEvent");

            if (hShellReadyEvent != 0)
            {
                NativeMethods.SetEvent(hShellReadyEvent);
                NativeMethods.CloseHandle(hShellReadyEvent);
            }
            #endregion

            #region old code
            //if (!SingleInstanceCheck())
            //{
            //    return;
            //}

            // Causes crash?
            // If framework is not correct version then quit.
            //if (!FrameworkCheck())
            //{
            //    return;
            //}
            #endregion

            InitializeParentWindow();

            App app = new App();

            MenuBarWindow = new MenuBar() { Owner = _parentWindow };
            MenuBarWindow.Show();
            app.MainWindow = MenuBarWindow;

            #if (ENABLEFIRSTRUN)
            FirstRun(app);
            #endif

            if (Properties.Settings.Default.EnableDesktop)
            {
                DesktopWindow = new Desktop() { Owner = _parentWindow };
                DesktopWindow.Show();
                WindowInteropHelper f = new WindowInteropHelper(DesktopWindow);
                int result = NativeMethods.SetShellWindow(f.Handle);
                DesktopWindow.ShowWindowBottomMost(f.Handle);
            }

            if (Properties.Settings.Default.EnableMenuBarShadow)
            {
                MenuBarShadowWindow = new MenuBarShadow() { Owner = _parentWindow };
                MenuBarShadowWindow.Show();
            }

            if (Properties.Settings.Default.EnableTaskbar)
            {
                TaskbarWindow = new Taskbar() { Owner = _parentWindow };
                TaskbarWindow.Show();
            }

            app.Run();
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            if (args.Length > 0 && args[0] == "/restart")
            {
                isRestart = true;
            }
            else
            {
                isRestart = false;
            }

            #region Single Instance Check
            bool ok;
            cairoMutex = new System.Threading.Mutex(true, "CairoShell", out ok);

            if (!ok && !isRestart)
            {
                // Another instance is already running.
                return;
            }
            else if (!ok && isRestart)
            {
                // this is a restart so let's wait for the old instance to end
                System.Threading.Thread.Sleep(2000);
            }
            #endregion

            // Show a splash screen while WPF inits
            // not needed any more
            //SplashScreen splash = new SplashScreen("Resources/loadSplash.png");
            //splash.Show(false, true);

            #region some real shell code
            int hShellReadyEvent;

            if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 5)
            {
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, true, @"Global\msgina: ShellReadyEvent");
            }
            else
            {
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, false, "msgina: ShellReadyEvent");
            }

            if (hShellReadyEvent != 0)
            {
                NativeMethods.SetEvent(hShellReadyEvent);
                NativeMethods.CloseHandle(hShellReadyEvent);
            }
            #endregion

            // check if we are the current user's shell
            object userShell = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon", false).GetValue("Shell");
            procName = Process.GetCurrentProcess().ProcessName;
            if (userShell != null)
            {
                IsCairoUserShell = userShell.ToString().ToLower().Contains("cairodesktop");
            }
            else
            {
                IsCairoUserShell = false;
            }

            // Before we do anything, check if settings need to be upgraded
            if (Settings.IsFirstRun == true)
            {
                Settings.Upgrade();
            }

            if (Settings.EnableTaskbar)
            {
                // hide the windows taskbar according to user prefs
                switch (Settings.WindowsTaskbarMode)
                {
                case 0:
                    AppBarHelper.SetWinTaskbarPos(NativeMethods.SWP_HIDEWINDOW);
                    break;

                case 1:
                    AppBarHelper.SetWinTaskbarState(AppBarHelper.WinTaskbarState.AutoHide);
                    break;

                case 2:
                    break;

                default:
                    break;
                }
            }

            if (Settings.EnableDesktop)
            {
                // hide the windows desktop
                Shell.ToggleDesktopIcons(false);
            }

            _parentWindow = new Window();
            InitializeParentWindow(_parentWindow);

            _desktopWindow = new Window();
            InitializeParentWindow(_desktopWindow);
            DeskParent = _desktopWindow;

            App app = new App();
            app.InitializeComponent();

            // Set custom theme if selected
            string theme = Settings.CairoTheme;
            if (theme != "Default")
            {
                if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + theme))
                {
                    app.Resources.MergedDictionaries.Add((ResourceDictionary)XamlReader.Load(System.Xml.XmlReader.Create(AppDomain.CurrentDomain.BaseDirectory + theme)));
                }
            }

            // Set desktop work area for when Explorer isn't running
            if (IsCairoUserShell)
            {
                AppBarHelper.SetWorkArea();
            }

            MenuBarWindow = new MenuBar()
            {
                Owner = _parentWindow
            };
            app.MainWindow = MenuBarWindow;
            MenuBarWindow.Show();

            if (Settings.EnableDesktop)
            {
                DesktopWindow = new Desktop()
                {
                    Owner = _desktopWindow
                };
                DesktopWindow.Show();
            }

            if (Settings.EnableMenuBarShadow)
            {
                MenuBarShadowWindow = new MenuBarShadow()
                {
                    Owner = _desktopWindow
                };
                MenuBarShadowWindow.Show();
            }

            if (Settings.EnableTaskbar)
            {
                TaskbarWindow = new Taskbar()
                {
                    Owner = _parentWindow
                };
                TaskbarWindow.Show();
            }

#if (ENABLEFIRSTRUN)
            FirstRun();
#endif

            // Close the splash screen
            //splash.Close(new TimeSpan(0, 0, 0, 0, 800));

            // login items only necessary if Explorer didn't start them
            if (IsCairoUserShell && !isRestart)
            {
                RunStartupApps();
            }

            app.Run();
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            #region Initialization Routines

            ProcessCommandLineArgs(args);
            if (!SingleInstanceCheck())
            {
                return;
            }
            SetShellReadyEvent();

            SetupSettings(); // run this before logging setup so that preferences are always used

            // Initialize current shell information here, since it won't be accurate if we wait until after we create our own Shell_TrayWnd
            Shell.SetIsCairoRunningAsShell();

            SetupLoggingSystem();
            WriteApplicationDebugInfoToConsole();

            SetSystemKeyboardShortcuts();

            // Move to App??? app.SetupPluginSystem();
            SetupPluginSystem(); // This will Load the Core Plugin and all other, will either reference it as a dependency or dont need it to be started first

            #endregion

            if (Settings.Instance.EnableDesktop && !GroupPolicyManager.Instance.NoDesktop) // Future: This should be moved to whatever plugin is responsible for desktop stuff
            {
                // hide the windows desktop
                Shell.ToggleDesktopIcons(false);
            }

            App app = new App();
            app.InitializeComponent();  // This sets up the Unhandled Exception stuff...

            setTheme(app);


            // Future: This should be moved to whatever plugin is responsible for Taskbar stuff
            if (Settings.Instance.EnableTaskbar)
            {
                AppBarHelper.SetWinTaskbarState(AppBarHelper.WinTaskbarState.AutoHide);
                AppBarHelper.SetWinTaskbarVisibility((int)NativeMethods.SetWindowPosFlags.SWP_HIDEWINDOW);
            }

            // Future: This should be moved to whatever plugin is responsible for MenuBar stuff
            MenuBar initialMenuBar = new MenuBar(System.Windows.Forms.Screen.PrimaryScreen);
            app.MainWindow = initialMenuBar;
            WindowManager.Instance.MenuBarWindows.Add(initialMenuBar);
            initialMenuBar.Show();

            // Future: This should be moved to whatever plugin is responsible for Desktop stuff
            if (Settings.Instance.EnableDesktop && !GroupPolicyManager.Instance.NoDesktop)
            {
                WindowManager.Instance.DesktopWindow = new Desktop();
                WindowManager.Instance.DesktopWindow.Show();
            }

            // Future: This should be moved to whatever plugin is responsible for Taskbar stuff
            if (Settings.Instance.EnableTaskbar)
            {
                Taskbar initialTaskbar = new Taskbar(System.Windows.Forms.Screen.PrimaryScreen);
                WindowManager.Instance.TaskbarWindows.Add(initialTaskbar);
                initialTaskbar.Show();
            }

            // Open windows on secondary displays and set work area
            WindowManager.Instance.InitialSetup();

            // Future: This should be moved to whatever plugin is responsible for SystemTray stuff. Possibly Core with no UI, then have a plugin that gives the UI?
            // Don't allow showing both the Windows taskbar and the Cairo tray
            if (Settings.Instance.EnableSysTray && (Settings.Instance.EnableTaskbar || Shell.IsCairoRunningAsShell))
            {
                NotificationArea.Instance.Initialize();
            }

#if ENABLEFIRSTRUN
            FirstRun();
#endif

#if !DEBUG
            // login items only necessary if Explorer didn't start them
            if (Shell.IsCairoRunningAsShell && !isRestart)
            {
                StartupRunner runner = new StartupRunner();
                runner.Run();
            }
#endif

            app.Run();
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            #region Single Instance Check
            bool ok;
            cairoMutex = new System.Threading.Mutex(true, "CairoShell", out ok);

            if (!ok)
            {
                // Another instance is already running.
                return;
            }
            #endregion

            // Show a splash screen while WPF inits
            SplashScreen splash = new SplashScreen("Resources/loadSplash.png");
            splash.Show(false, true);

            #region some real shell code
            int hShellReadyEvent;

            if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 5)
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, true, @"Global\msgina: ShellReadyEvent");
            else
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, false, "msgina: ShellReadyEvent");

            if (hShellReadyEvent != 0)
            {
                NativeMethods.SetEvent(hShellReadyEvent);
                NativeMethods.CloseHandle(hShellReadyEvent);
            }
            #endregion

            // check if we are the current user's shell
            object userShell = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon", false).GetValue("Shell");
            procName = Process.GetCurrentProcess().ProcessName;
            if (userShell != null)
                IsCairoUserShell = userShell.ToString().ToLower().Contains("cairodesktop");
            else
                IsCairoUserShell = false;

            // Before we do anything, check if settings need to be upgraded
            if (Properties.Settings.Default.IsFirstRun == true)
                Properties.Settings.Default.Upgrade();

            if (Properties.Settings.Default.EnableTaskbar)
            {
                // hide the windows taskbar
                SupportingClasses.AppBarHelper.SetWinTaskbarState(SupportingClasses.AppBarHelper.WinTaskbarState.AutoHide);
            }

            if (Properties.Settings.Default.EnableDesktop)
            {
                // hide the windows desktop
                Interop.Shell.ToggleDesktopIcons(false);
            }

            _parentWindow = new Window();
            InitializeParentWindow(_parentWindow);

            _desktopWindow = new Window();
            InitializeParentWindow(_desktopWindow);
            DeskParent = _desktopWindow;

            App app = new App();
            app.InitializeComponent();

            // Set custom theme if selected
            string theme = CairoDesktop.Properties.Settings.Default.CairoTheme;
            if (theme != "Default")
                if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + theme)) app.Resources.MergedDictionaries.Add((ResourceDictionary)XamlReader.Load(System.Xml.XmlReader.Create(AppDomain.CurrentDomain.BaseDirectory + theme)));

            MenuBarWindow = new MenuBar() { Owner = _parentWindow };
            app.MainWindow = MenuBarWindow;
            MenuBarWindow.Show();

            if (Properties.Settings.Default.EnableDesktop)
            {
                DesktopWindow = new Desktop() { Owner = _desktopWindow };
                DesktopWindow.Show();
            }

            if (Properties.Settings.Default.EnableMenuBarShadow)
            {
                MenuBarShadowWindow = new MenuBarShadow() { Owner = _desktopWindow };
                MenuBarShadowWindow.Show();
            }

            if (Properties.Settings.Default.EnableTaskbar)
            {
                TaskbarWindow = new Taskbar() { Owner = _parentWindow };
                TaskbarWindow.Show();
            }

            // Set desktop work area for when Explorer isn't running
            SupportingClasses.AppBarHelper.SetWorkArea();

            #if (ENABLEFIRSTRUN)
            FirstRun(app);
            #endif

            // If explorer isn't shell, run startup apps.
            if(IsCairoUserShell)
            {
                RunStartupApps();
            }

            // Close the splash screen
            splash.Close(new TimeSpan(0, 0, 0, 0, 800));

            app.Run();
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            #region Args

            if (args.Length > 0 && args[0] == "/restart")
            {
                isRestart = true;
            }
            else
            {
                isRestart = false;
            }

            if (args.Length > 0 && args[0] == "/tour")
            {
                isTour = true;
            }
            else
            {
                isTour = false;
            }

            #endregion

            #region Single Instance Check
            bool ok;
            cairoMutex = new System.Threading.Mutex(true, "CairoShell", out ok);

            if (!ok && !isRestart)
            {
                // Another instance is already running.
                return;
            }
            else if (!ok && isRestart)
            {
                // this is a restart so let's wait for the old instance to end
                System.Threading.Thread.Sleep(2000);
            }
            #endregion

            #region some real shell code
            int hShellReadyEvent;

            if (Environment.OSVersion.Platform == PlatformID.Win32NT && Shell.IsWindows2kOrBetter)
            {
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, true, @"Global\msgina: ShellReadyEvent");
            }
            else
            {
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, false, "msgina: ShellReadyEvent");
            }

            if (hShellReadyEvent != 0)
            {
                NativeMethods.SetEvent(hShellReadyEvent);
                NativeMethods.CloseHandle(hShellReadyEvent);
            }
            #endregion

            // check if we are the current user's shell
            // set here as well so that we don't behave differently once user changes setting
            IsCairoUserShell = ShellHelper.IsCairoUserShell;

            // Before we do anything, check if settings need to be upgraded
            if (Settings.IsFirstRun == true)
            {
                Settings.Upgrade();
            }

            if (Settings.EnableDesktop)
            {
                // hide the windows desktop
                Shell.ToggleDesktopIcons(false);
            }

            App app = new App();
            app.InitializeComponent();

            // Set custom theme if selected
            string theme = Settings.CairoTheme;
            if (theme != "Default")
            {
                if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + theme))
                {
                    app.Resources.MergedDictionaries.Add((ResourceDictionary)XamlReader.Load(System.Xml.XmlReader.Create(AppDomain.CurrentDomain.BaseDirectory + theme)));
                }
            }

            if (Settings.EnableTaskbar)
            {
                // hide Windows taskbar
                AppBarHelper.SetWinTaskbarState(AppBarHelper.WinTaskbarState.AutoHide);
                AppBarHelper.SetWinTaskbarPos((int)NativeMethods.SetWindowPosFlags.SWP_HIDEWINDOW);
            }

            MenuBarWindow  = new MenuBar(System.Windows.Forms.Screen.PrimaryScreen);
            app.MainWindow = MenuBarWindow;
            MenuBarWindow.Show();
            MenuBarWindows.Add(MenuBarWindow);

            if (Settings.EnableDesktop)
            {
                DesktopWindow = new Desktop();
                DesktopWindow.Show();
            }

            if (Settings.EnableMenuBarShadow)
            {
                MenuBarShadowWindow = new MenuBarShadow(MenuBarWindow, System.Windows.Forms.Screen.PrimaryScreen);
                MenuBarShadowWindow.Show();
                MenuBarShadowWindows.Add(MenuBarShadowWindow);
            }

            if (Settings.EnableTaskbar)
            {
                TaskbarWindow = new Taskbar(System.Windows.Forms.Screen.PrimaryScreen);
                TaskbarWindow.Show();
                TaskbarWindows.Add(TaskbarWindow);
            }

            if (Settings.EnableMenuBarMultiMon || Settings.EnableTaskbarMultiMon)
            {
                ScreenSetup(true);
            }

            // Set desktop work area for when Explorer isn't running
            if (IsCairoUserShell)
            {
                AppBarHelper.SetWorkArea();
            }

            // initialize system tray if enabled
            if (Settings.EnableSysTray == true)
            {
                NotificationArea.Instance.Initialize();
            }

#if (ENABLEFIRSTRUN)
            FirstRun();
#endif

            // login items only necessary if Explorer didn't start them
            if (IsCairoUserShell && !isRestart)
            {
                RunStartupApps();
            }

            app.Run();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Compares the system screen list to the screens associated with Cairo windows, then creates or destroys windows as necessary.
        /// Only affects non-primary screens, as Cairo always opens on at least the primary screen.
        /// Runs at startup and when a WM_DISPLAYCHANGE message is received by the main MenuBar window.
        /// </summary>
        public static void ScreenSetup(bool skipChecks = false)
        {
            lock (screenSetupLock)
            {
                IsSettingScreens = true;

                List <string> sysScreens     = new List <string>();
                List <string> openScreens    = new List <string>();
                List <string> addedScreens   = new List <string>();
                List <string> removedScreens = new List <string>();

                ResetScreenCache();

                if (!skipChecks)
                {
                    // enumerate screens

                    if (Settings.EnableMenuBarMultiMon || !Settings.EnableTaskbar)
                    {
                        foreach (MenuBar bar in MenuBarWindows)
                        {
                            if (bar.Screen != null)
                            {
                                openScreens.Add(bar.Screen.DeviceName);
                            }
                        }
                    }
                    else if (Settings.EnableTaskbarMultiMon)
                    {
                        foreach (Taskbar bar in TaskbarWindows)
                        {
                            if (bar.Screen != null)
                            {
                                openScreens.Add(bar.Screen.DeviceName);
                            }
                        }
                    }
                    else
                    {
                        return;
                    }

                    foreach (var screen in System.Windows.Forms.Screen.AllScreens)
                    {
                        Trace.WriteLine(string.Format("{0} found at {1} with area {2}; primary? {3}", screen.DeviceName, screen.Bounds.ToString(), screen.WorkingArea.ToString(), screen.Primary.ToString()));

                        sysScreens.Add(screen.DeviceName);
                    }

                    // figure out which screens have been added vs removed

                    foreach (string name in sysScreens)
                    {
                        if (!openScreens.Contains(name))
                        {
                            addedScreens.Add(name);
                        }
                    }

                    foreach (string name in openScreens)
                    {
                        if (!sysScreens.Contains(name))
                        {
                            removedScreens.Add(name);
                        }
                    }

                    if (removedScreens.Count == sysScreens.Count)
                    {
                        // remove everything?! no way!
                        return;
                    }

                    // close windows associated with removed screens
                    foreach (string name in removedScreens)
                    {
                        // close taskbars
                        Taskbar taskbarToClose = null;
                        foreach (Taskbar bar in TaskbarWindows)
                        {
                            if (bar.Screen != null && bar.Screen.DeviceName == name)
                            {
                                taskbarToClose = bar;
                                break;
                            }
                        }

                        if (taskbarToClose != null)
                        {
                            taskbarToClose.Close();
                            TaskbarWindows.Remove(taskbarToClose);
                        }

                        // close menu bars
                        MenuBar barToClose = null;
                        foreach (MenuBar bar in MenuBarWindows)
                        {
                            if (bar.Screen != null && bar.Screen.DeviceName == name)
                            {
                                barToClose = bar;
                                break;
                            }
                        }

                        if (barToClose != null)
                        {
                            if (!barToClose.IsClosing)
                            {
                                barToClose.Close();
                            }
                            MenuBarWindows.Remove(barToClose);
                        }

                        // close menu bar shadows
                        MenuBarShadow barShadowToClose = null;
                        foreach (MenuBarShadow bar in MenuBarShadowWindows)
                        {
                            if (bar.Screen != null && bar.Screen.DeviceName == name)
                            {
                                barShadowToClose = bar;
                                break;
                            }
                        }

                        if (barShadowToClose != null)
                        {
                            if (!barShadowToClose.IsClosing)
                            {
                                barShadowToClose.Close();
                            }
                            MenuBarShadowWindows.Remove(barShadowToClose);
                        }
                    }

                    // update screens of stale windows
                    foreach (MenuBar bar in MenuBarWindows)
                    {
                        if (bar.Screen != null)
                        {
                            foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
                            {
                                if (screen.DeviceName == bar.Screen.DeviceName)
                                {
                                    bar.Screen = screen;
                                    break;
                                }
                            }
                        }
                    }

                    foreach (MenuBarShadow bar in MenuBarShadowWindows)
                    {
                        if (bar.Screen != null)
                        {
                            foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
                            {
                                if (screen.DeviceName == bar.Screen.DeviceName)
                                {
                                    bar.Screen = screen;
                                    break;
                                }
                            }
                        }
                    }

                    foreach (Taskbar bar in TaskbarWindows)
                    {
                        if (bar.Screen != null)
                        {
                            foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
                            {
                                if (screen.DeviceName == bar.Screen.DeviceName)
                                {
                                    bar.Screen = screen;
                                    bar.setPosition();
                                    break;
                                }
                            }
                        }
                    }
                }

                // open windows on newly added screens
                foreach (var screen in System.Windows.Forms.Screen.AllScreens)
                {
                    if ((skipChecks && !screen.Primary) || addedScreens.Contains(screen.DeviceName))
                    {
                        if (Settings.EnableMenuBarMultiMon)
                        {
                            // menu bars
                            MenuBar newMenuBar = new MenuBar(screen);
                            newMenuBar.Show();
                            MenuBarWindows.Add(newMenuBar);

                            if (Settings.EnableMenuBarShadow)
                            {
                                // menu bar shadows
                                MenuBarShadow newMenuBarShadow = new MenuBarShadow(newMenuBar, screen);
                                newMenuBarShadow.Show();
                                MenuBarShadowWindows.Add(newMenuBarShadow);
                            }
                        }

                        if (Settings.EnableTaskbarMultiMon && Settings.EnableTaskbar)
                        {
                            // taskbars
                            Taskbar newTaskbar = new Taskbar(screen);
                            newTaskbar.Show();
                            TaskbarWindows.Add(newTaskbar);
                        }
                    }
                }

                IsSettingScreens = false;
            }
        }
Ejemplo n.º 8
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.Window = ((CairoDesktop.MenuBar)(target));
     
     #line 20 "..\..\MenuBar.xaml"
     this.Window.Loaded += new System.Windows.RoutedEventHandler(this.OnWindowLoaded);
     
     #line default
     #line hidden
     
     #line 21 "..\..\MenuBar.xaml"
     this.Window.Initialized += new System.EventHandler(this.OnWindowInitialized);
     
     #line default
     #line hidden
     
     #line 22 "..\..\MenuBar.xaml"
     this.Window.Closing += new System.ComponentModel.CancelEventHandler(this.OnWindowClosing);
     
     #line default
     #line hidden
     
     #line 23 "..\..\MenuBar.xaml"
     this.Window.SizeChanged += new System.Windows.SizeChangedEventHandler(this.OnWindowResize);
     
     #line default
     #line hidden
     return;
     case 3:
     this.CairoMenuBarContainer = ((System.Windows.Controls.DockPanel)(target));
     return;
     case 4:
     this.CairoMenuBar = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 5:
     this.CairoMenuIcon = ((System.Windows.Controls.Image)(target));
     return;
     case 6:
     this.OpenAboutCairo = ((System.Windows.Controls.MenuItem)(target));
     
     #line 84 "..\..\MenuBar.xaml"
     this.OpenAboutCairo.Click += new System.Windows.RoutedEventHandler(this.AboutCairo);
     
     #line default
     #line hidden
     return;
     case 7:
     
     #line 89 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenTaskManager);
     
     #line default
     #line hidden
     return;
     case 8:
     
     #line 92 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.InitAppGrabberWindow);
     
     #line default
     #line hidden
     return;
     case 9:
     
     #line 96 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.InitCairoSettingsWindow);
     
     #line default
     #line hidden
     return;
     case 10:
     
     #line 99 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenControlPanel);
     
     #line default
     #line hidden
     return;
     case 11:
     
     #line 103 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenCloseCairoBox);
     
     #line default
     #line hidden
     return;
     case 12:
     
     #line 107 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.SysSleep);
     
     #line default
     #line hidden
     return;
     case 13:
     
     #line 110 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenRebootBox);
     
     #line default
     #line hidden
     return;
     case 14:
     
     #line 113 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenShutDownBox);
     
     #line default
     #line hidden
     return;
     case 15:
     
     #line 116 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenLogoffBox);
     
     #line default
     #line hidden
     return;
     case 16:
     this.categorizedProgramsList = ((System.Windows.Controls.ItemsControl)(target));
     return;
     case 17:
     
     #line 174 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenUserFolder);
     
     #line default
     #line hidden
     return;
     case 18:
     
     #line 177 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenMyDocs);
     
     #line default
     #line hidden
     return;
     case 19:
     this.PlacesDownloadsItem = ((System.Windows.Controls.MenuItem)(target));
     
     #line 180 "..\..\MenuBar.xaml"
     this.PlacesDownloadsItem.Click += new System.Windows.RoutedEventHandler(this.OpenDownloads);
     
     #line default
     #line hidden
     return;
     case 20:
     
     #line 183 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenMyMusic);
     
     #line default
     #line hidden
     return;
     case 21:
     
     #line 186 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenMyPics);
     
     #line default
     #line hidden
     return;
     case 22:
     
     #line 191 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenMyComputer);
     
     #line default
     #line hidden
     return;
     case 23:
     
     #line 194 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenProgramFiles);
     
     #line default
     #line hidden
     return;
     case 24:
     
     #line 198 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenRecycleBin);
     
     #line default
     #line hidden
     return;
     case 25:
     this.CairoMenuBarRight = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 26:
     this.SysTray = ((CairoDesktop.SystemTray)(target));
     return;
     case 27:
     this.dateText = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 28:
     this.monthCalendar = ((Microsoft.Windows.Controls.Calendar)(target));
     return;
     case 29:
     
     #line 221 "..\..\MenuBar.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OpenTimeDateCPL);
     
     #line default
     #line hidden
     return;
     case 30:
     this.CairoSearchMenu = ((System.Windows.Controls.MenuItem)(target));
     
     #line 234 "..\..\MenuBar.xaml"
     this.CairoSearchMenu.SubmenuOpened += new System.Windows.RoutedEventHandler(this.FocusSearchBox);
     
     #line default
     #line hidden
     return;
     case 31:
     this.CairoSearchMenuIcon = ((System.Windows.Controls.Image)(target));
     return;
     case 32:
     this.searchStr = ((System.Windows.Controls.TextBox)(target));
     return;
     case 33:
     this.stacksContainer = ((CairoDesktop.StacksContainer)(target));
     return;
     }
     this._contentLoaded = true;
 }
Ejemplo n.º 9
0
        public static void Main(string[] args)
        {
            #region Initialization Routines

            ProcessCommandLineArgs(args);
            if (!SingleInstanceCheck())
            {
                return;
            }
            SetShellReadyEvent();

            SetupSettings(); // run this before logging setup so that preferences are always used
            SetupLoggingSystem();
            WriteApplicationDebugInfoToConsole();

            SetSystemKeyboardShortcuts();

            // Move to App??? app.SetupPluginSystem();
            SetupPluginSystem(); // This will Load the Core Plugin and all other, will either reference it as a dependancy or dont need it to be started first


            #endregion

            // check if we are the current user's shell
            // set here as well so that we don't behave differently once user changes setting
            // First check if there is an existing Shell_TrayWnd. If so, then Explorer is actually running as shell so assume we are not.
            IntPtr taskbarHwnd = NativeMethods.FindWindow("Shell_TrayWnd", "");
            IsCairoRunningAsShell = Shell.IsCairoConfiguredAsShell && taskbarHwnd == IntPtr.Zero; // Move to CairoDesktop.Plugins.CairoShellCoreServices.... Make this more robust, to account for system-shell or per-user-shell;

            if (Settings.Instance.EnableDesktop && !GroupPolicyManager.Instance.NoDesktop)        // Future: This should be moved to whatever plugin is responsible for desktop stuff
            {
                // hide the windows desktop
                Shell.ToggleDesktopIcons(false);
            }

            App app = new App();
            app.InitializeComponent();  // This sets up the Unhandled Exception stuff...

            // Themes are very UI centric. We should devise a way of having Plugins/Extensions contribute to this.
            string theme = Settings.Instance.CairoTheme;
            if (theme != "Default")
            {
                string themeFilePath = AppDomain.CurrentDomain.BaseDirectory + theme;
                if (System.IO.File.Exists(themeFilePath))
                {
                    ResourceDictionary newRes = new ResourceDictionary();
                    newRes.Source = new Uri(themeFilePath, UriKind.RelativeOrAbsolute);
                    app.Resources.MergedDictionaries.Add(newRes);
                }
            }

            Settings.Instance.PropertyChanged += (s, e) =>
            {
                if (e != null && !string.IsNullOrWhiteSpace(e.PropertyName) && e.PropertyName == "CairoTheme")
                {
                    App.Current.Resources.MergedDictionaries.Clear();
                    ResourceDictionary cairoResource = new ResourceDictionary();

                    // Put our base theme back
                    cairoResource.Source = new Uri("Cairo.xaml", UriKind.RelativeOrAbsolute);
                    App.Current.Resources.MergedDictionaries.Add(cairoResource);

                    string newTheme = Settings.Instance.CairoTheme;
                    if (newTheme != "Default")
                    {
                        string newThemeFilePath = AppDomain.CurrentDomain.BaseDirectory + newTheme;
                        if (System.IO.File.Exists(newThemeFilePath))
                        {
                            ResourceDictionary newRes = new ResourceDictionary();
                            newRes.Source = new Uri(newThemeFilePath, UriKind.RelativeOrAbsolute);
                            app.Resources.MergedDictionaries.Add(newRes);
                        }
                    }
                }
            };


            // Future: This should be moved to whatever plugin is responsible for MenuBar stuff
            if (Settings.Instance.EnableTaskbar)
            {
                AppBarHelper.SetWinTaskbarState(AppBarHelper.WinTaskbarState.AutoHide);
                AppBarHelper.SetWinTaskbarPos((int)NativeMethods.SetWindowPosFlags.SWP_HIDEWINDOW);
            }

            // Future: This should be moved to whatever plugin is responsible for MenuBar stuff
            MenuBarWindow  = new MenuBar(System.Windows.Forms.Screen.PrimaryScreen);
            app.MainWindow = MenuBarWindow;
            MenuBarWindow.Show();
            MenuBarWindows.Add(MenuBarWindow);

            // Future: This should be moved to whatever plugin is responsible for Desktop stuff
            if (Settings.Instance.EnableDesktop && !GroupPolicyManager.Instance.NoDesktop)
            {
                DesktopWindow = new Desktop();
                DesktopWindow.Show();
            }

            // Future: This should be moved to whatever plugin is responsible for MenuBar stuff
            if (Settings.Instance.EnableMenuBarShadow)
            {
                MenuBarShadowWindow = new MenuBarShadow(MenuBarWindow, System.Windows.Forms.Screen.PrimaryScreen);
                MenuBarShadowWindow.Show();
                MenuBarShadowWindows.Add(MenuBarShadowWindow);
            }

            // Future: This should be moved to whatever plugin is responsible for Taskbar stuff
            if (Settings.Instance.EnableTaskbar)
            {
                TaskbarWindow = new Taskbar(System.Windows.Forms.Screen.PrimaryScreen);
                TaskbarWindow.Show();
                TaskbarWindows.Add(TaskbarWindow);
            }

            // Future: This should be moved to whatever plugin is responsible for Taskbar/MennuBart stuff
            if (Settings.Instance.EnableMenuBarMultiMon || Settings.Instance.EnableTaskbarMultiMon)
            {
                ScreenSetup(true);
            }
            else if (IsCairoRunningAsShell) // Set desktop work area for when Explorer isn't running
            {
                AppBarHelper.SetWorkArea(System.Windows.Forms.Screen.PrimaryScreen);
            }

            // Future: This should be moved to whatever plugin is responsible for SystemTray stuff. Possibly Core with no UI, then have a plugin that gives the UI?
            // Don't allow showing both the Windows taskbar and the Cairo tray
            if (Settings.Instance.EnableSysTray == true && (Settings.Instance.EnableTaskbar == true || IsCairoRunningAsShell))
            {
                NotificationArea.Instance.Initialize();
            }

#if ENABLEFIRSTRUN
            FirstRun();
#endif

            // login items only necessary if Explorer didn't start them
            if (IsCairoRunningAsShell && !isRestart)
            {
                RunStartupApps();
            }

            app.Run();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Compares the system screen list to the screens associated with Cairo windows, then creates or destroys windows as necessary.
        /// Only affects non-primary screens, as Cairo always opens on at least the primary screen.
        /// Runs at startup and when a WM_DISPLAYCHANGE message is received by the main MenuBar window.
        /// </summary>
        public static void ScreenSetup(bool skipChecks = false)
        {
            lock (screenSetupLock)
            {
                CairoLogger.Instance.Debug("Beginning screen setup");
                IsSettingScreens = true;

                bool shouldSetScreens = true;

                List <string> sysScreens     = new List <string>();
                List <string> openScreens    = new List <string>();
                List <string> addedScreens   = new List <string>();
                List <string> removedScreens = new List <string>();

                ResetScreenCache();

                if (screenState.Length == System.Windows.Forms.Screen.AllScreens.Length)
                {
                    bool same = true;
                    for (int i = 0; i < screenState.Length; i++)
                    {
                        System.Windows.Forms.Screen current = System.Windows.Forms.Screen.AllScreens[i];
                        if (!(screenState[i].Bounds == current.Bounds && screenState[i].DeviceName == current.DeviceName && screenState[i].Primary == current.Primary && screenState[i].WorkingArea == current.WorkingArea))
                        {
                            same = false;
                            break;
                        }
                    }

                    if (same)
                    {
                        CairoLogger.Instance.Debug("Skipping screen setup due to no differences");
                        shouldSetScreens = false;
                    }
                    else
                    {
                        screenState = System.Windows.Forms.Screen.AllScreens;
                    }
                }
                else
                {
                    screenState = System.Windows.Forms.Screen.AllScreens;
                }

                if (shouldSetScreens)
                {
                    if (!skipChecks)
                    {
                        // enumerate screens

                        if (Settings.Instance.EnableMenuBarMultiMon || !Configuration.Settings.Instance.EnableTaskbar)
                        {
                            foreach (MenuBar bar in MenuBarWindows)
                            {
                                if (bar.Screen != null)
                                {
                                    openScreens.Add(bar.Screen.DeviceName);
                                }
                            }
                        }
                        else if (Settings.Instance.EnableTaskbarMultiMon)
                        {
                            foreach (Taskbar bar in TaskbarWindows)
                            {
                                if (bar.Screen != null)
                                {
                                    openScreens.Add(bar.Screen.DeviceName);
                                }
                            }
                        }
                        else
                        {
                            IsSettingScreens = false;
                            return;
                        }

                        foreach (var screen in screenState)
                        {
                            CairoLogger.Instance.Debug(string.Format("{0} found at {1} with area {2}; primary? {3}", screen.DeviceName, screen.Bounds.ToString(), screen.WorkingArea.ToString(), screen.Primary.ToString()));

                            sysScreens.Add(screen.DeviceName);
                        }

                        // figure out which screens have been added vs removed

                        foreach (string name in sysScreens)
                        {
                            if (!openScreens.Contains(name))
                            {
                                addedScreens.Add(name);
                            }
                        }

                        foreach (string name in openScreens)
                        {
                            if (!sysScreens.Contains(name))
                            {
                                removedScreens.Add(name);
                            }
                        }

                        if (sysScreens.Count == 0)
                        {
                            // remove everything?! no way!
                            IsSettingScreens = false;
                            return;
                        }

                        // close windows associated with removed screens
                        foreach (string name in removedScreens)
                        {
                            CairoLogger.Instance.Debug("Removing windows associated with screen " + name);

                            // close taskbars
                            Taskbar taskbarToClose = null;
                            foreach (Taskbar bar in TaskbarWindows)
                            {
                                if (bar.Screen != null && bar.Screen.DeviceName == name)
                                {
                                    taskbarToClose = bar;
                                    break;
                                }
                            }

                            if (taskbarToClose != null)
                            {
                                taskbarToClose.Close();
                                TaskbarWindows.Remove(taskbarToClose);
                            }

                            // close menu bars
                            MenuBar barToClose = null;
                            foreach (MenuBar bar in MenuBarWindows)
                            {
                                if (bar.Screen != null && bar.Screen.DeviceName == name)
                                {
                                    CairoLogger.Instance.DebugIf(bar.Screen.Primary, "Closing menu bar on primary display");

                                    barToClose = bar;
                                    break;
                                }
                            }

                            if (barToClose != null)
                            {
                                if (!barToClose.IsClosing)
                                {
                                    barToClose.Close();
                                }
                                MenuBarWindows.Remove(barToClose);
                            }

                            // close menu bar shadows
                            MenuBarShadow barShadowToClose = null;
                            foreach (MenuBarShadow bar in MenuBarShadowWindows)
                            {
                                if (bar.Screen != null && bar.Screen.DeviceName == name)
                                {
                                    barShadowToClose = bar;
                                    break;
                                }
                            }

                            if (barShadowToClose != null)
                            {
                                if (!barShadowToClose.IsClosing)
                                {
                                    barShadowToClose.Close();
                                }
                                MenuBarShadowWindows.Remove(barShadowToClose);
                            }
                        }

                        CairoLogger.Instance.Debug("Refreshing screen information for stale windows");

                        // update screens of stale windows
                        foreach (MenuBar bar in MenuBarWindows)
                        {
                            if (bar.Screen != null)
                            {
                                foreach (System.Windows.Forms.Screen screen in screenState)
                                {
                                    if (screen.DeviceName == bar.Screen.DeviceName)
                                    {
                                        bar.Screen = screen;
                                        break;
                                    }
                                }
                            }
                        }

                        foreach (MenuBarShadow bar in MenuBarShadowWindows)
                        {
                            if (bar.Screen != null)
                            {
                                foreach (System.Windows.Forms.Screen screen in screenState)
                                {
                                    if (screen.DeviceName == bar.Screen.DeviceName)
                                    {
                                        bar.Screen = screen;
                                        break;
                                    }
                                }
                            }
                        }

                        foreach (Taskbar bar in TaskbarWindows)
                        {
                            if (bar.Screen != null)
                            {
                                foreach (System.Windows.Forms.Screen screen in screenState)
                                {
                                    if (screen.DeviceName == bar.Screen.DeviceName)
                                    {
                                        bar.Screen = screen;
                                        bar.setPosition();
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    // open windows on newly added screens
                    foreach (var screen in screenState)
                    {
                        if ((skipChecks && !screen.Primary) || addedScreens.Contains(screen.DeviceName))
                        {
                            CairoLogger.Instance.Debug("Opening windows on screen " + screen.DeviceName);

                            if (Settings.Instance.EnableMenuBarMultiMon)
                            {
                                CairoLogger.Instance.DebugIf(screen.Primary, "Opening MenuBar on new primary display");

                                // menu bars
                                MenuBar newMenuBar = new MenuBar(screen);
                                newMenuBar.Show();
                                MenuBarWindows.Add(newMenuBar);

                                if (Settings.Instance.EnableMenuBarShadow)
                                {
                                    // menu bar shadows
                                    MenuBarShadow newMenuBarShadow = new MenuBarShadow(newMenuBar, screen);
                                    newMenuBarShadow.Show();
                                    MenuBarShadowWindows.Add(newMenuBarShadow);
                                }
                            }

                            if (Settings.Instance.EnableTaskbarMultiMon && Configuration.Settings.Instance.EnableTaskbar)
                            {
                                // taskbars
                                Taskbar newTaskbar = new Taskbar(screen);
                                newTaskbar.Show();
                                TaskbarWindows.Add(newTaskbar);
                            }
                        }

                        // Set desktop work area for when Explorer isn't running
                        if (IsCairoRunningAsShell)
                        {
                            AppBarHelper.SetWorkArea(screen);
                        }
                    }
                }

                IsSettingScreens = false;
                CairoLogger.Instance.Debug("Completed screen setup");
            }
        }
Ejemplo n.º 11
0
        public static void Main(string[] args)
        {
            #region Initialization Routines

            ProcessCommandLineArgs(args);
            SingleInstanceCheck();
            SetShellReadyEvent();

            SetupSettings(); // run this before logging setup so that preferences are always used
            SetupLoggingSystem();
            WriteApplicationDebugInfoToConsole();

            SetupPluginSystem();

            #endregion

            // check if we are the current user's shell
            // set here as well so that we don't behave differently once user changes setting
            IsCairoUserShell = Shell.IsCairoUserShell;

            if (Settings.EnableDesktop)
            {
                // hide the windows desktop
                Shell.ToggleDesktopIcons(false);
            }

            App app = new App();
            app.InitializeComponent();

            // Set custom theme if selected
            string theme = Settings.CairoTheme;
            if (theme != "Default")
            {
                if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + theme))
                {
                    app.Resources.MergedDictionaries.Add((ResourceDictionary)XamlReader.Load(System.Xml.XmlReader.Create(AppDomain.CurrentDomain.BaseDirectory + theme)));
                }
            }

            if (Settings.EnableTaskbar)
            {
                // hide Windows taskbar
                AppBarHelper.SetWinTaskbarState(AppBarHelper.WinTaskbarState.AutoHide);
                AppBarHelper.SetWinTaskbarPos((int)NativeMethods.SetWindowPosFlags.SWP_HIDEWINDOW);
            }

            MenuBarWindow  = new MenuBar(System.Windows.Forms.Screen.PrimaryScreen);
            app.MainWindow = MenuBarWindow;
            MenuBarWindow.Show();
            MenuBarWindows.Add(MenuBarWindow);

            if (Settings.EnableDesktop)
            {
                DesktopWindow = new Desktop();
                DesktopWindow.Show();
            }

            if (Settings.EnableMenuBarShadow)
            {
                MenuBarShadowWindow = new MenuBarShadow(MenuBarWindow, System.Windows.Forms.Screen.PrimaryScreen);
                MenuBarShadowWindow.Show();
                MenuBarShadowWindows.Add(MenuBarShadowWindow);
            }

            if (Settings.EnableTaskbar)
            {
                TaskbarWindow = new Taskbar(System.Windows.Forms.Screen.PrimaryScreen);
                TaskbarWindow.Show();
                TaskbarWindows.Add(TaskbarWindow);
            }

            if (Settings.EnableMenuBarMultiMon || Settings.EnableTaskbarMultiMon)
            {
                ScreenSetup(true);
            }
            else if (IsCairoUserShell) // Set desktop work area for when Explorer isn't running
            {
                AppBarHelper.SetWorkArea(System.Windows.Forms.Screen.PrimaryScreen);
            }

            // initialize system tray if enabled
            if (Settings.EnableSysTray == true)
            {
                NotificationArea.Instance.Initialize();
            }

#if (ENABLEFIRSTRUN)
            FirstRun();
#endif

            // login items only necessary if Explorer didn't start them
            if (IsCairoUserShell && !isRestart)
            {
                RunStartupApps();
            }

            app.Run();
        }
Ejemplo n.º 12
0
        public MenuBarShadow(ICairoApplication cairoApplication, WindowManager windowManager, MenuBar bar)
        {
            _cairoApplication = cairoApplication;
            _menuBar = bar;
            _windowManager = windowManager;

            InitializeComponent();

            SetPosition();
        }
Ejemplo n.º 13
0
        public static void Main()
        {
            #region Single Instance Check
            bool ok;
            cairoMutex = new System.Threading.Mutex(true, "CairoShell", out ok);

            if (!ok)
            {
                // Another instance is already running.
                return;
            }
            #endregion

            #region some real shell code
            int hShellReadyEvent;

            if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 5)
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, true, @"Global\msgina: ShellReadyEvent");
            else
                hShellReadyEvent = NativeMethods.OpenEvent(NativeMethods.EVENT_MODIFY_STATE, false, "msgina: ShellReadyEvent");

            if (hShellReadyEvent != 0)
            {
                NativeMethods.SetEvent(hShellReadyEvent);
                NativeMethods.CloseHandle(hShellReadyEvent);
            }
            #endregion

            #region old code
            //if (!SingleInstanceCheck())
            //{
            //    return;
            //}

            // Causes crash?
            // If framework is not correct version then quit.
            //if (!FrameworkCheck())
            //{
            //    return;
            //}
            #endregion

            InitializeParentWindow();

            App app = new App();

            MenuBarWindow = new MenuBar() { Owner = _parentWindow };
            MenuBarWindow.Show();
            app.MainWindow = MenuBarWindow;

            #if (ENABLEFIRSTRUN)
            FirstRun(app);
            #endif

            /*if (Properties.Settings.Default.EnableDesktop)
            {
                //DesktopWindow = new Desktop() { Owner = _parentWindow };
                DesktopWindow = new Desktop() {};
                DesktopWindow.Show();
                WindowInteropHelper f = new WindowInteropHelper(DesktopWindow);
                int result = NativeMethods.SetShellWindow(f.Handle);
                DesktopWindow.ShowWindowBottomMost(f.Handle);
            }*/

            Int32 TOPMOST_FLAGS = 0x0001 | 0x0002;
            WindowInteropHelper menuBarHelper = new WindowInteropHelper (MenuBarWindow);
            MenuBarPtr = menuBarHelper.Handle;
            NativeMethods.SetWindowPos (menuBarHelper.Handle, (IntPtr)NativeMethods.HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);

            CairoDesktop.NativeWindowEx _HookWin = new CairoDesktop.NativeWindowEx();
            _HookWin.CreateHandle (new System.Windows.Forms.CreateParams ());
            NativeMethods.SetTaskmanWindow (_HookWin.Handle);
            NativeMethods.RegisterShellHookWindow(_HookWin.Handle);
            WM_SHELLHOOKMESSAGE = NativeMethods.RegisterWindowMessage("SHELLHOOK");

            Sound = new CairoDesktop.Sound.SoundAPI();
            Sound.Initialize(_HookWin.Handle);

            _HookWin.MessageReceived += ShellWinProc;

            //'Assume no error occurred

            app.Run();
        }
        public MenuExtraActionCenter(MenuBar menuBar)
        {
            InitializeComponent();

            _parentHwnd = menuBar.Handle;
        }