private void setGridPosition() { double top = System.Windows.Forms.SystemInformation.WorkingArea.Top / Shell.DpiScale; grid.Width = WindowManager.PrimaryMonitorWorkArea.Width / Shell.DpiScale; if (Settings.Instance.TaskbarMode == 1 && WindowManager.Instance.TaskbarWindows.Count > 0) { // special case, since work area is not reduced with this setting // this keeps the desktop going beneath the taskbar // get the taskbar's height Taskbar taskbar = WindowManager.Instance.GetScreenWindow(WindowManager.Instance.TaskbarWindows, System.Windows.Forms.Screen.PrimaryScreen); double taskbarHeight = 0; if (taskbar != null) { taskbarHeight = taskbar.ActualHeight; } grid.Height = (WindowManager.PrimaryMonitorWorkArea.Height / Shell.DpiScale) - taskbarHeight; if (Settings.Instance.TaskbarPosition == 1) { top += taskbarHeight; } } else { grid.Height = WindowManager.PrimaryMonitorWorkArea.Height / Shell.DpiScale; } grid.Margin = new Thickness(System.Windows.Forms.SystemInformation.WorkingArea.Left / Shell.DpiScale, top, 0, 0); }
public void ResetPosition() { double top = System.Windows.Forms.SystemInformation.WorkingArea.Top / Shell.DpiScale; double taskbarHeight = 0; if (Settings.Instance.TaskbarMode == 1 && WindowManager.Instance.TaskbarWindows.Count > 0) { // special case, since work area is not reduced with this setting // this keeps the desktop going beneath the taskbar // get the taskbar's height Taskbar taskbar = WindowManager.Instance.GetScreenWindow(WindowManager.Instance.TaskbarWindows, System.Windows.Forms.Screen.PrimaryScreen); if (taskbar != null) { taskbarHeight = taskbar.ActualHeight; } // top taskbar means we should push down if (Settings.Instance.TaskbarPosition == 1) { top += taskbarHeight; } } Width = WindowManager.PrimaryMonitorWorkArea.Width / Shell.DpiScale; Height = (WindowManager.PrimaryMonitorWorkArea.Height / Shell.DpiScale) - taskbarHeight; grid.Width = Width; grid.Height = Height; Top = top; Left = System.Windows.Forms.SystemInformation.WorkingArea.Left / Shell.DpiScale; }
private void MenuBar_OnMouseLeave(object sender, MouseEventArgs e) { if (Settings.Instance.TaskbarMode == 2) { Taskbar taskbar = WindowManager.GetScreenWindow(WindowManager.Instance.TaskbarWindows, Screen); if (taskbar != null && taskbar.appBarEdge == appBarEdge) { taskbar.CanAutoHide = true; } } }
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(); }
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 // an attempt to relaunch explorer it the application gets closed. doesnt work if VS terminates execution // AppDomain.CurrentDomain.ProcessExit += (o, e) => Shutdown(); #region InitializationRoutines 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; // 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); } 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(); }
/// <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); } } // Set desktop work area for when Explorer isn't running if (IsCairoUserShell) { AppBarHelper.SetWorkArea(screen); } } IsSettingScreens = false; } }
public static void Main(string[] args) { #region Initialization Routines ProcessCommandLineArgs(args); SingleInstanceCheck(); SetShellReadyEvent(); 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; // 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); } 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(); }
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(); 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 IsCairoUserShell = Shell.IsCairoUserShell; // Move to CairoDesktop.Plugins.CairoShellCoreServices.... Make this more robust, to account for system-shell or per-user-shell; if (Settings.EnableDesktop) // 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.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))); } } // Future: This should be moved to whatever plugin is responsible for MenuBar stuff if (Settings.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.EnableDesktop) { DesktopWindow = new Desktop(); DesktopWindow.Show(); } // Future: This should be moved to whatever plugin is responsible for MenuBar stuff if (Settings.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.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.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); } // 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? 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(); }
/// <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.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 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 (removedScreens.Count == sysScreens.Count) { // remove everything?! no way! 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.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.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); } } // Set desktop work area for when Explorer isn't running if (IsCairoUserShell) { AppBarHelper.SetWorkArea(screen); } } } IsSettingScreens = false; CairoLogger.Instance.Debug("Completed screen setup"); } }
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) // 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) { 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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.Window = ((CairoDesktop.Taskbar)(target)); return; case 2: this.TaskbarBorder = ((System.Windows.Controls.Border)(target)); return; case 3: this.quickLaunchList = ((System.Windows.Controls.ListView)(target)); return; case 4: this.TasksList = ((System.Windows.Controls.ListView)(target)); return; case 5: #line 162 "..\..\Taskbar.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click); #line default #line hidden return; case 6: this.CairoTaskbarTaskList = ((System.Windows.Controls.Primitives.Popup)(target)); return; case 7: this.TasksList2 = ((System.Windows.Controls.ListView)(target)); return; } this._contentLoaded = true; }