public static void Start() { Directory.CreateDirectory("$SacredUtils\\temp"); File.Create("$SacredUtils\\temp\\updated.su"); Process.Start("mnxupdater.exe", ApplicationInfo.CurrentExe + " _newVersionSacredUtilsTemp.exe"); ApplicationUtils.Shutdown(); }
private void EventSubscribe() { Closing += (s, e) => SaveSettings(); MenuGrLabel.Click += (s, e) => ChangeApplicationSelectionSettings.SelectSettings(GraphicsStgOne, GraphicsPanel); MenuSnLabel.Click += (s, e) => ChangeApplicationSelectionSettings.SelectSettings(SoundStgOne, SoundPanel); MenuGpLabel.Click += (s, e) => ChangeApplicationSelectionSettings.SelectSettings(GamePlayStgOne, GameplayPanel); MenuCtLabel.Click += (s, e) => ChangeApplicationSelectionSettings.SelectSettings(ChatStgOne, ChatPanel); MenuFtLabel.Click += (s, e) => ChangeApplicationSelectionSettings.SelectSettings(FontStgOne, FontsPanel); MenuMdLabel.Click += (s, e) => ChangeApplicationSelectionSettings.SelectSettings(ModifyStgOne, ModifPanel); MenuStLabel.Click += (s, e) => ChangeApplicationSelectionSettings.SelectSettings(AppStgOne, SettingsPanel); MenuPlLabel.Click += (s, e) => ApplicationStartSacredGameFile.StartDialog(); if (Settings.EnableRefreshSettingsOnWindowFocus) { Activated += (s, e) => RefreshApplicationSettings.Refresh(); } Timeline.DesiredFrameRateProperty.OverrideMetadata( typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = Settings.DesiredFrameRateProperty } ); CloseBtn.Click += (s, e) => ApplicationUtils.Shutdown(); UpdateLbl.MouseDown += (s, e) => ApplicationStartUtilityUpdate.Start(); BaseWindow.PreviewKeyDown += ApplicationBaseWindowHotkeys.KeyDown; MinimizeBtn.Click += (s, e) => WindowState = WindowState.Minimized; MemoryLbl.MouseDown += (s, e) => GC.Collect(); HeaderPanel.MouseDown += DragWindow; Timer.Interval = new TimeSpan( 0, 0, Settings.ShowUsedMemoryUpdateInterval ); Timer.Tick += (s, e) => GetApplicationCurrentUsedMemory.Get(); Loaded += (sender, args) => { Task.Run(CheckAvailabilityAlphaUpdates.GetPerm); Task.Run(NetworkUtils.ShowNoConnection); Task.Run(GetSacredUtilsCelebrationDates.CheckDates); if (File.ReadAllText( $"{Environment.ExpandEnvironmentVariables("%appdata%")}\\SacredUtils\\LicenseAgreement.su") .Contains("true")) { GetChangeLogDialogVisibility.Get(); } ApplicationInfo.StartupStopwatch.Stop(); // Make Yourself ^_^ Log.Info( $"Loading SacredUtils application done ({ApplicationInfo.StartupStopwatch.Elapsed.TotalMilliseconds / 1000.00} seconds)!"); }; }
public virtual void Shutdown(Int32 code = 0) { ApplicationUtils.Shutdown(Dispatcher, code); }
public static void KeyDown(object sender, KeyEventArgs e) { if (e.Key == Settings.KeyPushUserToMainMenu) { ChangeApplicationSelectionSettings.UnSelectSettings( MainWindow.UnselectedStg ); } if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Settings.KeyOpenProgramLatestLogFile && File.Exists("$SacredUtils\\logs\\latest.log")) { Process.Start(Settings.DefaultOpenLogFileProgram, "$SacredUtils\\logs\\latest.log"); } if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Settings.KeyOpenProgramSettingFile && File.Exists("$SacredUtils\\conf\\settings.json")) { Process.Start(Settings.DefaultOpenLogFileProgram, "$SacredUtils\\conf\\settings.json"); } if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Settings.KeyOpenGameSettingsFile && File.Exists(Settings.SacredConfigurationFile)) { Process.Start(Settings.DefaultOpenLogFileProgram, Settings.SacredConfigurationFile); } if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Settings.KeyOpenProgramDirectory) { Process.Start(ApplicationInfo.CurrentPath); } if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Settings.KeyReloadProgram) { SaveSettings(); ApplicationUtils.Reload(); } if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Settings.KeyShutdownProgram) { ApplicationUtils.Shutdown(); } if (e.Key == Key.F5) { RefreshApplicationSettings.Refresh(); Log.Info("Sacred game settings successfully reloaded!"); } if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.PageDown) { // force crash for testing crash-report code. // ReSharper disable once ReturnValueOfPureMethodIsNotUsed if (_keyPresses == 1) { Convert.ToBoolean("1"); } else { _keyPresses = 1; } } if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.L) { // it code get download statistic from SacredUtils stat server. if (_keyPressesStat == 1) { _keyPressesStat = 0; string downloadCount = ApplicationGetDownloadStatistics.Get(); string[] count = downloadCount.Split('{', '}'); MessageBox.Show(count[1].Replace("\"", "").Replace("SacredUtilsDownloads", "SacredUtils Downloads Count")); } else { _keyPressesStat = 1; } } if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.I) { // it code open clear cache dialog host, for fixing some bugs. if (_keyPressesStat == 1) { _keyPressesStat = 0; ApplicationClearComponentCache.SearchCacheFiles(); } else { _keyPressesStat = 1; } } if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.G) { if (_keyPressesChangeLog == 1) { _keyPressesChangeLog = 0; if (Settings.EnableShowChangeLogAfterUpdate) { ApplicationChangeLogDialog applicationChangeLogDialog = new ApplicationChangeLogDialog(); MainWindow.MainWindowInstance.DialogFrame.Visibility = Visibility.Visible; MainWindow.MainWindowInstance.DialogFrame.Content = applicationChangeLogDialog; if (Settings.ApplicationUiTheme == Theme.Dark) { applicationChangeLogDialog.BaseDialog.DialogTheme = BaseTheme.Dark; } applicationChangeLogDialog.BaseDialog.IsOpen = true; } } else { _keyPressesChangeLog = 1; } } if (e.Key == Key.Tab) { e.Handled = !Settings.EnableApplicationTabKeyButton; } }