void LibTorrentAlerts_TorrentStatsUpdated(Ragnar.TorrentStatus status) { string key = status.InfoHash.ToHex(); if (this._torrents.ContainsKey(key)) { this._torrents[key].DoStatsUpdate(status); } }
public static Brush GetBrushFromTorrentState(Ragnar.TorrentStatus s) { Style pstyle = (Style)Application.Current.TryFindResource(typeof(ProgressBar)); Brush def = Brushes.Gray;; foreach (Setter setter in pstyle.Setters) { if (setter.Property == ProgressBar.ForegroundProperty) { var brush = setter.Value as Brush; if (brush != null) { def = brush; // set to default progressbar color } break; } } Brush yellow = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFe5e500")); // we need a better color for this if (s.IsFinished) { if (s.IsSeeding) { return(def); } return(Brushes.Green); } else { if (s.State == Ragnar.TorrentState.Downloading) { if (s.Paused) { return(Brushes.Orange); } else { return(def); } } if (!string.IsNullOrWhiteSpace(s.Error)) { return(Brushes.Red); } } return(def); }