private void Steam_AppInfoChanged(AppInfoChangedEventArgs e) { if (InvokeRequired) { Invoke(new MethodInvoker(() => { Steam_AppInfoChanged(e); })); return; } if (lbWatching.Items.Count > 0) { bool doShutdown = lbWatching.Items.Cast <AppInfo>().All(x => !x.IsDownloading); if (doShutdown) { Shutdown(); } } if (e.AppInfo.IsDownloading && !lbUnwatched.Items.Contains(e.AppInfo) && !lbWatching.Items.Contains(e.AppInfo)) { lbUnwatched.Items.Add(e.AppInfo); } else if (AppInfo.CheckDownloading(e.PreviousState) && !e.AppInfo.IsDownloading) { if (lbWatching.Items.Contains(e.AppInfo)) { lbWatching.Items.Remove(e.AppInfo); } else if (lbUnwatched.Items.Contains(e.AppInfo)) { lbUnwatched.Items.Remove(e.AppInfo); } } }
private static void fsw_Changed(object sender, FileSystemEventArgs e) { string json = null; try { // This is necessary because sometimes the file is still accessed by steam, so let's wait for 10 ms and try again. // Maximum 5 times int counter = 1; do { try { json = AcfToJson(File.ReadAllLines(e.FullPath).ToList()); break; } catch (IOException) { System.Threading.Thread.Sleep(50); } }while (counter++ <= 5); } catch { return; } // Shouldn't happen, but might occur if Steam holds the acf file too long if (json == null) { return; } dynamic newJson = JsonConvert.DeserializeObject(json); int newID = JsonToAppInfo(newJson).ID; // Search for changed app, if null it's a new app AppInfo info = Apps.FirstOrDefault(x => x.ID == newID); AppInfoChangedEventArgs eventArgs; if (info != null) // Download state changed { eventArgs = new AppInfoChangedEventArgs(info, info.State); // Only update existing AppInfo info.State = int.Parse(newJson.StateFlags.ToString()); } else // New download started { // Add new AppInfo info = JsonToAppInfo(newJson); Apps.Add(info); eventArgs = new AppInfoChangedEventArgs(info, -1); } OnAppInfoChanged(eventArgs); }
private void Steam_AppInfoChanged(object sender, AppInfoChangedEventArgs e) { if (StateMachine.WatchedGames.Count > 0) { bool doShutdown = StateMachine.WatchedGames.All(x => !x.IsDownloading); if (doShutdown) { Shutdown(); } } if (e.AppInfo.IsDownloading && !StateMachine.WatchedGames.Contains(e.AppInfo)) { if (StateMachine.WaitForAll) { StateMachine.WatchedGames.Add(e.AppInfo); } } else if (App.CheckDownloading(e.PreviousState) && !e.AppInfo.IsDownloading) { StateMachine.WatchedGames.Remove(e.AppInfo); } }
static void OnAppInfoChanged(AppInfoChangedEventArgs e) { AppInfoChanged?.Invoke(e); }
static void OnAppInfoChanged(object sender, AppInfoChangedEventArgs e) { AppInfoChanged?.Invoke(sender, e); }