public async Task <object> CommandRunGameExecute(object parameter) { startingGame = true; CommandManager.InvalidateRequerySuggested(); IWinAPI winApi = trackerFactory.GetWinAPI(); bool isLauncherRunning = winApi.IsLauncherProcessRunning(); if (winApi.GetEslProcess() == null && !winApi.IsLauncherProcessRunning()) { System.Diagnostics.Process.Start("bethesdanet://run/5"); trackerFactory.GetMessanger().Send(new ApplicationShowBalloonTip("ESL Tracker", "Starting game...")); await Task.Delay(TimeSpan.FromSeconds(60)); //wait 10 sec if (winApi.GetEslProcess() == null) { trackerFactory.GetMessanger().Send(new ApplicationShowBalloonTip("ESL Tracker", "There is probelm staring game, please check Bethesda.net Laucher.")); } } else if (trackerFactory.GetWinAPI().IsLauncherProcessRunning()) { trackerFactory.GetMessanger().Send(new ApplicationShowBalloonTip("ESL Tracker", "Bethesda.net Laucher is running - use it to start game.")); } else { trackerFactory.GetMessanger().Send(new ApplicationShowBalloonTip("ESL Tracker", "Game is already running")); } startingGame = false; CommandManager.InvalidateRequerySuggested(); return(null); }
internal void UpdateGameData(GameOutcome?outcome) { this.Game.Deck = tracker.ActiveDeck; this.Game.DeckVersionId = tracker.ActiveDeck.SelectedVersionId; this.Game.Outcome = outcome.Value; this.Game.Date = trackerFactory.GetDateTimeNow(); //game date - when it concluded (we dont know when it started) FileVersionInfo fvi = trackerFactory.GetWinAPI().GetEslFileVersionInfo(); if (fvi != null) { this.Game.ESLVersion = new SerializableVersion(fvi.FileMajorPart, fvi.FileMinorPart, fvi.FileBuildPart, fvi.FilePrivatePart); } else { this.Game.ESLVersion = tracker.Games .Where(g => g.ESLVersion != null) .OrderByDescending(g => g.Date) .Select(g => g.ESLVersion) .FirstOrDefault(); } if (this.Game.Type == GameType.PlayRanked) { if (Game.OpponentRank != PlayerRank.TheLegend) { this.Game.OpponentLegendRank = null; } if (this.Game.PlayerRank != PlayerRank.TheLegend) { this.Game.PlayerLegendRank = null; } settings.PlayerRank = this.Game.PlayerRank.Value; } }
public Task SaveScreenShot(string fileName) { IntPtr?eslHandle = trackerfactory.GetWinAPI().GetEslProcess()?.MainWindowHandle; if (eslHandle.HasValue) { var rect = new WinAPI.Rect(); WinAPI.GetWindowRect(eslHandle.Value, ref rect); int width = rect.right - rect.left; int height = rect.bottom - rect.top; var bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics gfxBmp = Graphics.FromImage(bmp); List <Window> hiddenWindows = new List <Window>(); Application.Current.Dispatcher.Invoke(() => { foreach (Window w in Application.Current.Windows) { // System.Diagnostics.Debugger.Log(1, "", "w"+ w.Title); // System.Diagnostics.Debugger.Log(1, "", " w.IsActive" + w.IsActive); // System.Diagnostics.Debugger.Log(1, "", " w.Topmost" + w.Topmost); // System.Diagnostics.Debugger.Log(1, "", Environment.NewLine) ; if (w.IsActive) //if other if visible - cannot do anything; otherwise if it was in back, it would be show at the top:/... { w.Hide(); hiddenWindows.Add(w); } } }); WinAPI.SetForegroundWindow(eslHandle.Value); gfxBmp.CopyFromScreen( rect.left, rect.top, 0, 0, new System.Drawing.Size(width, height), CopyPixelOperation.SourceCopy); foreach (Window w in hiddenWindows) { w.Dispatcher.Invoke(() => w.Show()); } string path = Path.Combine( DataPath, ScreenShotFolder, Path.ChangeExtension(fileName, "png") ); if (!Directory.Exists(Path.GetDirectoryName(path))) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } bmp.Save(path, System.Drawing.Imaging.ImageFormat.Png); gfxBmp.Dispose(); } return(Task.FromResult <object>(null)); }