public UICore(UIWindow mainWindow, BattlelogBase battlelog, Config config) { this.mainWindow = mainWindow; this.battlelog = battlelog; this.config = config; this.managedOrigin = new Origin(); }
public async Task Initialize() { this.mainWindow.Icon = BitmapFrame.Create(new Uri(@"pack://application:,,/images/bg_icon.ico")); //Set runtime icon to Battlelogium badged ico switch (this.config.FullscreenMode) { case true: this.mainWindow.SetFullScreen(); break; case false: this.mainWindow.SetWindowed(); break; } if (config.CheckUpdates) { await this.CheckUpdate(); } bool isBattlelogAvailable = await BattlelogBase.CheckBattlelogConnectionAsync(); if (!isBattlelogAvailable) { bool offlineMode = MessageBoxUtils.ShowChoiceDialog("Battlelog is unavailable. Would you like to start Offline Campaign?", "Battlelog unavailable", "Start Campaign", "Exit Battlelogium"); switch (offlineMode) { case true: this.StartOfflineMode(); return; case false: this.mainWindow.Close(); return; } } this.battlelog.InitializeWebview(); this.battlelog.javascriptObject.InitJavascriptObject(this); this.mainWindow.MainControl.VersionNumber = "Battlelogium " + Assembly.GetEntryAssembly().GetName().Version.ToString(); this.mainWindow.MainControl.MainGrid.Children.Add(battlelog.battlelogWebview); this.mainWindow.Title = "Battlelogium - " + battlelog.battlefieldName; this.mainWindow.Closed += (s, e) => { if (config.ManageOrigin) { this.managedOrigin.KillOrigin(config.WaitTimeToKillOrigin * 1000); } }; this.mainWindow.PreviewKeyDown += mainWindow_PreviewKeyDown; this.mainWindow.PreviewMouseDown += (s, e) => { if (e.ChangedButton == MouseButton.Middle) { e.Handled = true; } }; //Disable opening link in new window with middle click this.battlelog.battlelogWebview.PropertyChanged += battlelogWebview_IsLoading; this.mainWindow.StateChanged += (s, e) => { try { this.battlelog.battlelogWebview.ExecuteScript("windowbutton.updateMaximizeButton()"); }catch { } }; if (config.ManageOrigin) { #if !NO_ORIGIN //ugly ifdefs are ugly. this.managedOrigin.StartOrigin(); #endif } if (config.DisableHardwareAccel) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } this.IsInitialized = true; }
public UIOfflineIndicator() { string[] args = Environment.GetCommandLineArgs(); if (args.Length <= 1) { MessageBox.Show("Invalid Commandline Parameters - BF3 for Battlefield 3, BF4 for Battlefield 4"); Environment.Exit(1); } Config config = new Config(); switch (args[1]) { case "BF3": this.battlelog = new Battlefield3(); break; case "BF4": this.battlelog = new Battlefield4(); break; case "MOHW": this.battlelog = new MedalOfHonorWarfighter(); break; case "BFH": this.battlelog = new BattlefieldHardline(); break; default: MessageBox.Show("Invalid Commandline Parameters - bf3 for Battlefield 3, bf4 for Battlefield 4,,bfh for Hardline, mohw for Medal of Honor Warfighter"); Environment.Exit(1); break; } InitializeComponent(); this.gameLabel.Content = "You are playing " + battlelog.battlefieldName + " Campaign. Please log in to Origin when prompted."; this.gameIcon.Source = new BitmapImage(new Uri("pack://*****:*****@"pack://application:,,/images/" + battlelog.battlefieldShortname + "/icon.ico")); this.KeyDown += (s, e) => { if (e.Key == Key.Enter) { this.WindowState = WindowState.Minimized; } }; this.SourceInitialized += (s, e) => { this.HideWindowButtons(); WindowChrome.SetWindowChrome(this, new WindowChrome() { CaptionHeight = 14D, ResizeBorderThickness = new Thickness(0) }); }; var origin = new OfflineOrigin(this.battlelog.gameId); origin.OriginUnexpectedClose += (s) => this.Dispatcher.Invoke(() => this.Close()); this.battlelog.GameQuit += (s, e) => { origin.KillOrigin(); this.Dispatcher.Invoke(() => this.Close()); }; origin.StartOrigin(); }
public void InitializeCore(BattlelogBase battlelog) { this.UICore = new UICore(this, battlelog, new Config()); this.IsCoreInitialized = true; this.UICore.Initialize(); }