protected override void OnStartup(StartupEventArgs e) { bool createdNew; _mutex = new Mutex(true, @"LeagueSharp.Loader.Mutex", out createdNew); if (!createdNew) { if (e.Args.Length > 0) { var wnd = Injection.FindWindow(IntPtr.Zero, "LeagueSharp"); if (wnd != IntPtr.Zero) { if (e.Args[0] == "addregkey") { LSUriScheme.CreateRegistryKeys(true); } else { Clipboard.SetText(e.Args[0]); ShowWindow(wnd, 5); SetForegroundWindow(wnd); } } } _mutex = null; Environment.Exit(0); } base.OnStartup(e); }
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { Utility.CreateFileFromResource(Directories.ConfigFilePath, "LeagueSharp.Loader.Resources.config.xml"); try { Config.Instance = ((Config)Utility.MapXmlFileToClass(typeof(Config), Directories.ConfigFilePath)); } catch (Exception ee) { File.Delete(Directories.ConfigFilePath); System.Windows.MessageBox.Show("Couldn't load config.xml"); Environment.Exit(0); } Browser.Visibility = Visibility.Hidden; DataContext = this; GeneralSettingsItem.IsSelected = true; if (!File.Exists(Directories.CoreFilePath)) { System.Windows.MessageBox.Show(string.Format("Couldn't find {0}", Path.GetFileName(Directories.CoreFilePath))); Environment.Exit(0); } Updater.MainWindow = this; Updater.UpdateLoader(); Updater.GetRepositories( delegate(List <string> list) { if (list.Count > 0) { Config.Instance.KnownRepositories.Clear(); foreach (var repo in list) { Config.Instance.KnownRepositories.Add(repo); } } }); if (Config.Instance.FirstRun) { LSUriScheme.CreateRegistryKeys(false); } //Try to login with the saved credentials. if (!Auth.Login(Config.Instance.Username, Config.Instance.Password).Item1) { ShowLoginDialog(); } else { OnLogin(Config.Instance.Username); } Config.Instance.FirstRun = false; //Used to reload the assemblies from inside the game. KeyboardHook.SetHook(); KeyboardHook.OnKeyUpTrigger += KeyboardHookOnOnKeyUpTrigger; KeyboardHook.HookedKeys.Add(KeyInterop.VirtualKeyFromKey(Config.Instance.Hotkeys.SelectedHotkeys.First(h => h.Name == "Reload").Hotkey)); KeyboardHook.HookedKeys.Add(KeyInterop.VirtualKeyFromKey(Config.Instance.Hotkeys.SelectedHotkeys.First(h => h.Name == "CompileAndReload").Hotkey)); foreach (var hk in Config.Instance.Hotkeys.SelectedHotkeys) { hk.PropertyChanged += hk_PropertyChanged; } InjectThread = new Thread( () => { while (true) { if (Config.Instance.Install) { Injection.Pulse(); } Thread.Sleep(3000); } }); InjectThread.Start(); Config.Instance.PropertyChanged += ConfigOnPropertyChanged; foreach (var gameSetting in Config.Instance.Settings.GameSettings) { gameSetting.PropertyChanged += GameSettingOnPropertyChanged; } SettingsTabItem.Visibility = Visibility.Hidden; }
protected override void OnStartup(StartupEventArgs e) { bool createdNew; _mutex = new Mutex(true, @"LeagueSharp.Loader.Mutex", out createdNew); if (!createdNew) { if (e.Args.Length > 0) { var wnd = Injection.FindWindow(IntPtr.Zero, "LeagueSharp"); if (wnd != IntPtr.Zero) { if (e.Args[0] == "addregkey") { LSUriScheme.CreateRegistryKeys(true); } else { Clipboard.SetText(e.Args[0]); ShowWindow(wnd, 5); SetForegroundWindow(wnd); } } } _mutex = null; Environment.Exit(0); } //Load the language resources. var dict = new ResourceDictionary(); if (File.Exists(Directories.LanguageFileFilePath)) { dict.Source = new Uri("..\\Resources\\Language\\" + File.ReadAllText(Directories.LanguageFileFilePath) + ".xaml", UriKind.Relative); } else { var lid = Thread.CurrentThread.CurrentCulture.ToString().Contains("-") ? Thread.CurrentThread.CurrentCulture.ToString().Split('-')[0].ToUpperInvariant() : Thread.CurrentThread.CurrentCulture.ToString().ToUpperInvariant(); switch (lid) { case "DE": dict.Source = new Uri("..\\Resources\\Language\\German.xaml", UriKind.Relative); break; case "ES": dict.Source = new Uri("..\\Resources\\Language\\Spanish.xaml", UriKind.Relative); break; case "FR": dict.Source = new Uri("..\\Resources\\Language\\French.xaml", UriKind.Relative); break; case "IT": dict.Source = new Uri("..\\Resources\\Language\\Italian.xaml", UriKind.Relative); break; case "KO": dict.Source = new Uri("..\\Resources\\Language\\Korean.xaml", UriKind.Relative); break; case "PL": dict.Source = new Uri("..\\Resources\\Language\\Polish.xaml", UriKind.Relative); break; case "PT": dict.Source = new Uri("..\\Resources\\Language\\Portuguese.xaml", UriKind.Relative); break; case "RO": dict.Source = new Uri("..\\Resources\\Language\\Romanian.xaml", UriKind.Relative); break; case "RU": dict.Source = new Uri("..\\Resources\\Language\\Russian.xaml", UriKind.Relative); break; case "TR": dict.Source = new Uri("..\\Resources\\Language\\Turkish.xaml", UriKind.Relative); break; case "VI": dict.Source = new Uri("..\\Resources\\Language\\Vietnamese.xaml", UriKind.Relative); break; case "ZH": dict.Source = new Uri("..\\Resources\\Language\\Chinese.xaml", UriKind.Relative); break; default: dict.Source = new Uri("..\\Resources\\Language\\English.xaml", UriKind.Relative); break; } } Resources.MergedDictionaries.Add(dict); base.OnStartup(e); }
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { Utility.CreateFileFromResource("config.xml", "LeagueSharp.Loader.Resources.config.xml"); Config = ((Config)Utility.MapXmlFileToClass(typeof(Config), "config.xml")); Browser.Visibility = Visibility.Hidden; DataContext = this; GeneralSettingsItem.IsSelected = true; if (!File.Exists(Path.Combine(Directories.CoreDirectory, "Leaguesharp.Core.dll"))) { System.Windows.Forms.MessageBox.Show("Couldn't find Leaguesharp.Core.dll"); Environment.Exit(0); } Updater.Update(); Updater.GetPositories( delegate(List <string> list) { if (list.Count > 0) { Config.KnownRepositories.Clear(); foreach (var repo in list) { Config.KnownRepositories.Add(repo); } } }); if (Config.FirstRun) { LSUriScheme.CreateRegistryKeys(false); } LogsDataGrid.ItemsSource = Logs.MainLog.Items; //Try to login with the saved credentials. if (!Auth.Login(Config.Username, Config.Password).Item1) { ShowLoginDialog(); } else { OnLogin(Config.Username); } Config.FirstRun = false; PrepareAssemblies(Config.SelectedProfile.InstalledAssemblies, Config.FirstRun || Config.UpdateOnLoad, true); //Used to reload the assemblies from inside the game. KeyboardHook.SetHook(); KeyboardHook.OnKeyUpTrigger += KeyboardHookOnOnKeyUpTrigger; InjectThread = new Thread( () => { while (true) { if (Config.Install) { Injection.Pulse(); } Thread.Sleep(3000); } }); InjectThread.Start(); Config.PropertyChanged += ConfigOnPropertyChanged; foreach (var gameSetting in Config.Settings.GameSettings) { gameSetting.PropertyChanged += GameSettingOnPropertyChanged; } }