From c24f3df4016926cbcd44845590e7272dc97c6864 Mon Sep 17 00:00:00 2001 From: hexafluoride Date: Thu, 14 Aug 2014 21:17:58 +0300 Subject: [PATCH] Finish overview panel and fix some stuff --- ByteFlood.suo | Bin 123904 -> 123904 bytes ByteFlood/ByteFlood.csproj | 1 + ByteFlood/Formatters/Subtract5Formatter.cs | 22 + ByteFlood/InfoClasses/TorrentInfo.cs | 120 ++-- ByteFlood/UI/MainWindow.xaml | 51 +- ByteFlood/Utility.cs | 4 +- MonoTorrent/MonoTorrent.csproj | 748 ++++++++++----------- 7 files changed, 500 insertions(+), 446 deletions(-) create mode 100644 ByteFlood/Formatters/Subtract5Formatter.cs diff --git a/ByteFlood.suo b/ByteFlood.suo index 8bb02f0e4fe577b7080f86fdbee775ee29c301db..9141792a703e56a453cc312055603eb41afd03b8 100644 GIT binary patch delta 121 zcmZoT!QOC!eM1flUqIW=)lavdXJlqzU~q75u436<#lq+(z+w#KPmkNks5IGtg>Cy6 z5yl>lY16dIYz61OZMElgJP(xAYVNj0l$p z*#ShCP~!nGlQ0AfmL35lw=^CB%mI;b5VjxzKmwDnK1!D!F#!;l=r;il15^NMmsvys KDesigner + diff --git a/ByteFlood/Formatters/Subtract5Formatter.cs b/ByteFlood/Formatters/Subtract5Formatter.cs new file mode 100644 index 0000000..20eff81 --- /dev/null +++ b/ByteFlood/Formatters/Subtract5Formatter.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Data; + +namespace ByteFlood.Formatters +{ + // thanks obama + public class Subtract5Formatter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return (double)value - 5; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return (int)value + 5; + } + } +} diff --git a/ByteFlood/InfoClasses/TorrentInfo.cs b/ByteFlood/InfoClasses/TorrentInfo.cs index ca4aa4d..ee9c828 100644 --- a/ByteFlood/InfoClasses/TorrentInfo.cs +++ b/ByteFlood/InfoClasses/TorrentInfo.cs @@ -30,61 +30,72 @@ public class TorrentInfo : INotifyPropertyChanged public string Path = ""; public string SavePath = ""; public TorrentSettings TorrentSettings { get; set; } - public string Name { get; set; } - public int Progress { get; set; } - public long Size { get; set; } - public int DownloadSpeed { get; set; } - public int UploadSpeed { get; set; } - public TimeSpan Elapsed { get; set; } - public DateTime StartTime { get; set; } - public int Seeders { get; set; } - public int Leechers { get; set; } - public long Downloaded { get; set; } - public long Uploaded { get; set; } - public string Status { get; set; } - public int PeerCount { get; set; } - public float RawRatio { get; set; } + public string Name { get; set; } + public int Progress { get { return (int)Torrent.Progress; } set { } } + public long Size { get { return Torrent.Torrent.Size; } } + public int DownloadSpeed { get { return Torrent.Monitor.DownloadSpeed; } } + public int UploadSpeed { get { return Torrent.Monitor.UploadSpeed; } } + public TimeSpan Elapsed { get { return DateTime.Now.Subtract(StartTime); } } + public DateTime StartTime { get; set; } + public long PieceLength { get { return Torrent.Torrent.PieceLength; } } + public int HashFails { get { return Torrent.HashFails; } } + public long WastedBytes { get { return PieceLength * HashFails; } } + public int Seeders { get { return Torrent.Peers.Seeds; } } + public int Leechers { get { return Torrent.Peers.Leechs; } } + public long Downloaded { get { return Torrent.Monitor.DataBytesDownloaded; } } + public long Uploaded { get { return Torrent.Monitor.DataBytesUploaded; } } + public string Status { get { return Torrent.State.ToString() == "DontDownload" ? "Don't download" : Torrent.State.ToString(); } } + public int PeerCount { get { return Seeders + Leechers; } } + public float RawRatio { get; set; } public float RatioLimit { get; set; } [XmlIgnore] + public float AverageDownloadSpeed { get { return downspeeds.Average(); } set { } } + [XmlIgnore] + public float AverageUploadSpeed { get { return upspeeds.Average(); } set { } } + [XmlIgnore] public ObservableCollection Peers = new ObservableCollection(); [XmlIgnore] public ObservableCollection Pieces = new ObservableCollection(); public ObservableCollection Files = new ObservableCollection(); public ObservableCollection Trackers = new ObservableCollection(); [XmlIgnore] - private bool hooked_pieces = false; + private bool hooked_pieces = false; private SynchronizationContext context; - #endregion - public List DownSpeeds - { - get - { - var t = downspeeds.Skip(downspeeds.Count - 50); - if (t.Count() < 50) - { - int count = 50 - t.Count(); - var f = Enumerable.Repeat(0f, count); - t = f.Concat(t); - } - return t.ToList(); - } - } - private List upspeeds = new List(); - public List UpSpeeds - { - get - { - var t = upspeeds.Skip(downspeeds.Count - 50); - if (t.Count() < 50) - { - int count = 50 - t.Count(); - var f = Enumerable.Repeat(0f, count); - t = f.Concat(t); - } - return t.ToList(); - } - } - private List downspeeds = new List(); + [XmlIgnore] + public List DownSpeeds + { + get + { + var t = downspeeds.Skip(downspeeds.Count - 50); + if (t.Count() < 50) + { + int count = 50 - t.Count(); + var f = Enumerable.Repeat(0f, count); + t = f.Concat(t); + } + return t.ToList(); + } + } + [XmlIgnore] + public List upspeeds = new List(); + [XmlIgnore] + public List UpSpeeds + { + get + { + var t = upspeeds.Skip(downspeeds.Count - 50); + if (t.Count() < 50) + { + int count = 50 - t.Count(); + var f = Enumerable.Repeat(0f, count); + t = f.Concat(t); + } + return t.ToList(); + } + } + [XmlIgnore] + public List downspeeds = new List(); + #endregion public TorrentInfo() // this is reserved for the XML deserializer. { @@ -255,7 +266,11 @@ public void Update() "ETA", "Size", "Elapsed", - "TorrentSettings"); + "TorrentSettings", + "WastedBytes", + "HashFails", + "AverageDownloadSpeed", + "AverageUploadSpeed"); } } catch (Exception ex) @@ -272,26 +287,15 @@ public void UpdateList(params string[] columns) private void UpdateProperties() { - this.Elapsed = DateTime.Now.Subtract(StartTime); this.Path = Torrent.Torrent.TorrentPath; this.SavePath = Torrent.SavePath; this.TorrentSettings = Torrent.Settings; - this.Status = Torrent.State.ToString(); - this.Size = this.Torrent.Torrent.Size; - this.Progress = Convert.ToInt32(Torrent.Progress); - this.DownloadSpeed = Torrent.Monitor.DownloadSpeed; var seconds = 0; if (this.DownloadSpeed > 0) { seconds = Convert.ToInt32(this.Size / this.DownloadSpeed); } this.ETA = new TimeSpan(0, 0, seconds); - this.UploadSpeed = Torrent.Monitor.UploadSpeed; - this.Seeders = Torrent.Peers.Seeds; - this.Leechers = Torrent.Peers.Leechs; - this.Downloaded = Torrent.Monitor.DataBytesDownloaded; - this.Uploaded = Torrent.Monitor.DataBytesUploaded; - this.PeerCount = Seeders + Leechers; if (!this.Torrent.Complete) this.RawRatio = ((float)Torrent.Monitor.DataBytesUploaded / (float)Torrent.Monitor.DataBytesDownloaded); else diff --git a/ByteFlood/UI/MainWindow.xaml b/ByteFlood/UI/MainWindow.xaml index fda260a..b0614bd 100644 --- a/ByteFlood/UI/MainWindow.xaml +++ b/ByteFlood/UI/MainWindow.xaml @@ -29,6 +29,7 @@ + @@ -36,7 +37,7 @@ - + @@ -45,7 +46,14 @@ - + + + + + + + + @@ -54,9 +62,30 @@ - + + + + + + + + - + + + + + + + + + + + + + + + @@ -114,10 +143,10 @@ - + - + @@ -171,10 +200,10 @@ - + - + @@ -185,8 +214,8 @@ - - + + @@ -195,6 +224,6 @@ -