private void bLauncher_Click(object sender, RoutedEventArgs e) { try { string game_path = ((string)MainWindow.JsonSettingsGet("game.path")).Replace(Properties.Resources.Default_JSON_Splitter, @"\"); if (System.IO.File.Exists(game_path + "WoTLauncher.exe")) { Task.Factory.StartNew(() => new Classes.Optimize().Start( (bool)MainWindow.JsonSettingsGet("settings.winxp"), (bool)MainWindow.JsonSettingsGet("settings.kill"), (bool)MainWindow.JsonSettingsGet("settings.force"), (bool)MainWindow.JsonSettingsGet("settings.aero"), (bool)MainWindow.JsonSettingsGet("settings.video"), (bool)MainWindow.JsonSettingsGet("settings.weak"), false )); Task.Factory.StartNew(() => MainWindow.ProcessStart(game_path, "WoTLauncher.exe")); Dispatcher.BeginInvoke(new ThreadStart(delegate { switch ((int)MainWindow.JsonSettingsGet("settings.launcher")) { case 1: MainWindow.State.Hide(); break; case 2: MainWindow.State.WindowState = System.Windows.WindowState.Minimized; break; case 3: MainWindow.State.Close(); break; default: break; } })); } else { MessageBox.Show(Lang.Set("MainProject", "Game_Not_Found", (string)MainWindow.JsonSettingsGet("info.language"))); } } catch (Exception ex) { Task.Factory.StartNew(() => Debugging.Save("General.xaml", "bLauncher_Click()", ex.Message, ex.StackTrace)); } }
private void bUpdate_Click(object sender, RoutedEventArgs e) { MainWindow.ProcessStart((string)MainWindow.JsonSettingsGet("multipack.link")); }
private void bOptimize_Click(object sender, RoutedEventArgs e) { try { if (MessageBox.Show(Lang.Set("Optimize", "Optimize", lang) + "?", (string)MainWindow.JsonSettingsGet("info.ProductName"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) { StatusBarSet(true); new Classes.Optimize().Start( (bool)MainWindow.JsonSettingsGet("settings.winxp"), true, true, true, (bool)MainWindow.JsonSettingsGet("settings.video"), (bool)MainWindow.JsonSettingsGet("settings.weak"), true ); StatusBarSet(true); } } catch (Exception ex) { Task.Factory.StartNew(() => Debugging.Save("General.xaml", "bOptimize_Click()", ex.Message, ex.StackTrace)); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { // Устанавливаем заголовок в зависимости от типа версии try { lType.Content = Lang.Set("PageGeneral", (string)MainWindow.JsonSettingsGet("multipack.type"), lang) + " #" + Version.Parse((string)MainWindow.JsonSettingsGet("multipack.version")).Revision; } catch (Exception) { lType.Content = Lang.Set("PageGeneral", "base", lang); } // Загружаем список видео и новостей try { Task.Factory.StartNew(() => StatusBarSet(false, 1, true, true)).Wait(); Task.WaitAll(new Task[] { Task.Factory.StartNew(() => YoutubeClass.Start()), Task.Factory.StartNew(() => WargamingClass.Start()) }); Task.WaitAll(new Task[] { Task.Factory.StartNew(() => ViewNews()), Task.Factory.StartNew(() => ViewNews(false)) }); Task.Factory.StartNew(() => StatusBarSet(false, 1, true, true, true)); Task.Factory.StartNew(() => Notify()); // Выводим уведомления видео } catch (Exception ex) { Task.Factory.StartNew(() => Debugging.Save("General.xaml", "Page_Loaded()", ex.Message, ex.StackTrace)); } Task.Factory.StartNew(() => { try { if ((bool)MainWindow.JsonSettingsGet("multipack.update") && MainWindow.JsonSettingsGet("multipack.update") != null) { Dispatcher.BeginInvoke(new ThreadStart(delegate { lStatus.Text = Lang.Set("PageGeneral", "UpdatesMultipack", (string)MainWindow.JsonSettingsGet("info.language"), (string)MainWindow.JsonSettingsGet("multipack.new_version")); bNotification.Visibility = System.Windows.Visibility.Visible; bUpdate.Visibility = System.Windows.Visibility.Visible; })); } else { Dispatcher.BeginInvoke(new ThreadStart(delegate { bNotification.Visibility = System.Windows.Visibility.Hidden; bUpdate.Visibility = System.Windows.Visibility.Hidden; })); } if ((bool)MainWindow.JsonSettingsGet("game.update") && MainWindow.JsonSettingsGet("game.update") != null) { Dispatcher.BeginInvoke(new ThreadStart(delegate { lStatus.Text = Lang.Set("PageGeneral", "UpdatesGame", lang, (string)MainWindow.JsonSettingsGet("game.new_version")); })); } } catch (Exception ex) { Task.Factory.StartNew(() => Debugging.Save("General.xaml", "Page_Loaded()", "multipack.update", ex.Message, ex.StackTrace)); } }); try { StatusBarSet(false, 1, true, true, true); } catch (Exception ex) { Task.Factory.StartNew(() => Debugging.Save("General.xaml", "Page_Loaded()", ex.Message, ex.StackTrace)); } Dispatcher.BeginInvoke(new ThreadStart(delegate { try { MainWindow.LoadPage.Visibility = Visibility.Hidden; } catch (Exception) { } })); }
/// <summary> /// Открытие ссылок из нотификатора /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NotifyClick(object sender, EventArgs e) { try { Process.Start((string)MainWindow.JsonSettingsGet("info.notify_link")); } catch (Exception ex) { Task.Factory.StartNew(() => Debugging.Save("MainWindow", "NotifyClick()", "Link: " + (string)MainWindow.JsonSettingsGet("info.notify_link"), ex.Message, ex.StackTrace)); } }
private void Notify() { /* * Видео */ try { if ((bool)MainWindow.JsonSettingsGet("info.video") && MainWindow.JsonSettingsGet("info.video") != null) { if (YoutubeClass.Count() > 0) { DeleteOldVideo(); // Перед выводом уведомлений проверяем даты. Все лишние удаляем foreach (var el in YoutubeClass.List) { if (show_notify) { bool show_this = true; string id_md5 = Variables.Md5(el.ID); try { string elem = MainWindow.JsonSettingsGet("youtube").ToString(); if (elem.IndexOf(id_md5) > -1) { show_this = false; } } catch (Exception) { } if (show_this) { Thread.Sleep(Convert.ToInt16(Properties.Resources.Default_Sleeping_Notify)); for (int i = 0; i < 2; i++) // Если цикл прерван случайно, то выжидаем еще 5 секунд перед повторным запуском { try { // Если запущен клиент игры - ждем 5 секунд до следующей проверки while (Process.GetProcessesByName("WorldOfTanks").Length > 0 || Process.GetProcessesByName("WoTLauncher").Length > 0) { Thread.Sleep(5000); } Thread.Sleep(Convert.ToInt16(Properties.Resources.Default_Sleeping_Notify)); } catch (Exception) { } } try { MainWindow.JsonSettingsSet("info.notify_link", el.Link); Task.Factory.StartNew(() => ShowNotify(Lang.Set("PageGeneral", "ShowVideo", lang), el.Title)); string elem = MainWindow.JsonSettingsGet("youtube").ToString(); if (elem.IndexOf(id_md5) == -1) { MainWindow.JsonSettingsSet("youtube", id_md5, "array"); } else { Thread.Sleep(Convert.ToInt16(Properties.Resources.Default_Sleeping_Notify)); } } catch (Exception ex0) { Task.Factory.StartNew(() => Debugging.Save("General.xaml", "Notify()", "YOUTUBE (Inner)", el.ToString(), ex0.Message, ex0.StackTrace, ex0.Source)); } } } } } } } catch (Exception ex) { Task.Factory.StartNew(() => Debugging.Save("General.xaml", "Notify()", "YOUTUBE", ex.Message, ex.StackTrace, ex.Source)); } /* * Новости */ try { if ((bool)MainWindow.JsonSettingsGet("info.news") && MainWindow.JsonSettingsGet("info.news") != null) { if (WargamingClass.Count() > 0) { foreach (var el in WargamingClass.List) { if (show_notify) { bool show_this = true; string id_md5 = Variables.Md5(el.Link); try { string elem = MainWindow.JsonSettingsGet("wargaming").ToString(); if (elem.IndexOf(id_md5) > -1) { show_this = false; } } catch (Exception) { } if (show_this) { Thread.Sleep(Convert.ToInt16(Properties.Resources.Default_Sleeping_Notify)); for (int i = 0; i < 2; i++) // Если цикл прерван случайно, то выжидаем еще 5 секунд перед повторным запуском { try { // Если запущен клиент игры - ждем 5 секунд до следующей проверки while (Process.GetProcessesByName("WorldOfTanks").Length > 0 || Process.GetProcessesByName("WoTLauncher").Length > 0) { Thread.Sleep(5000); } Thread.Sleep(Convert.ToInt16(Properties.Resources.Default_Sleeping_Notify)); } catch (Exception) { } } try { MainWindow.JsonSettingsSet("info.notify_link", el.Link); Task.Factory.StartNew(() => ShowNotify(Lang.Set("PageGeneral", "ShowNews", lang), el.Title)); string elem = MainWindow.JsonSettingsGet("wargaming").ToString(); if (elem.IndexOf(id_md5) == -1) { MainWindow.JsonSettingsSet("wargaming", Variables.Md5(el.Link), "array"); } else { Thread.Sleep(Convert.ToInt16(Properties.Resources.Default_Sleeping_Notify)); } } catch (Exception ex0) { Task.Factory.StartNew(() => Debugging.Save("General.xaml", "Notify()", "WARGAMING", el.ToString(), ex0.Message, ex0.StackTrace)); } } } } } } } catch (Exception ex) { Task.Factory.StartNew(() => Debugging.Save("General.xaml", "Notify()", "WARGAMING", ex.Message, ex.StackTrace)); } }