private static void SaveSettings(WindowExplorer eWindow) { GlobalSettings.Default.WindowState = eWindow.WindowState; eWindow.WindowState = WindowState.Normal; // Reset the State before getting the window size. GlobalSettings.Default.WindowHeight = eWindow.Height; GlobalSettings.Default.WindowWidth = eWindow.Width; GlobalSettings.Default.WindowTop = eWindow.Top; GlobalSettings.Default.WindowLeft = eWindow.Left; GlobalSettings.Default.Save(); }
public bool Load(string[] args) { // Fetch the game version and store, so it can be retrieved during crash if the toolbox makes it this far. GlobalSettings.Default.SEVersion = SpaceEngineersConsts.GetSEVersion(); // Test the Space Engineers version to make sure users are using an version that is new enough for SEToolbox to run with! // This is usually because a user has not updated a manual install of a Dedicated Server, or their Steam did not update properly. if (GlobalSettings.Default.SEVersion < GlobalSettings.GetAppVersion(true)) { MessageBox.Show(string.Format(Res.DialogOldSEVersionMessage, SpaceEngineersConsts.GetSEVersion(), GlobalSettings.Default.SEBinPath, GlobalSettings.GetAppVersion()), Res.DialogOldSEVersionTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation); Application.Current.Shutdown(); return false; } // Force pre-loading of any Space Engineers resources. SpaceEngineersCore.LoadDefinitions(); // Load the Space Engineers assemblies, or dependant classes after this point. var explorerModel = new ExplorerModel(); if (args.Any(a => a.ToUpper() == "/WR" || a.ToUpper() == "-WR")) { ResourceReportModel.GenerateOfflineReport(explorerModel, args); Application.Current.Shutdown(); return false; } var eViewModel = new ExplorerViewModel(explorerModel); var eWindow = new WindowExplorer(eViewModel); //if (allowClose) //{ eViewModel.CloseRequested += (sender, e) => { SaveSettings(eWindow); Application.Current.Shutdown(); }; //} eWindow.Loaded += (sender, e) => { Splasher.CloseSplash(); if (GlobalSettings.Default.WindowLeft.HasValue) eWindow.Left = GlobalSettings.Default.WindowLeft.Value; if (GlobalSettings.Default.WindowTop.HasValue) eWindow.Top = GlobalSettings.Default.WindowTop.Value; if (GlobalSettings.Default.WindowWidth.HasValue) eWindow.Width = GlobalSettings.Default.WindowWidth.Value; if (GlobalSettings.Default.WindowHeight.HasValue) eWindow.Height = GlobalSettings.Default.WindowHeight.Value; if (GlobalSettings.Default.WindowState.HasValue) eWindow.WindowState = GlobalSettings.Default.WindowState.Value; }; eWindow.ShowDialog(); return true; }