Removed Progress Bar
This commit is contained in:
parent
c25f5bbb0a
commit
9a4ca60458
23
Discord Media Loader/MainForm.Designer.cs
generated
23
Discord Media Loader/MainForm.Designer.cs
generated
|
@ -44,7 +44,7 @@
|
||||||
this.lbDownload = new System.Windows.Forms.Label();
|
this.lbDownload = new System.Windows.Forms.Label();
|
||||||
this.cbGuilds = new System.Windows.Forms.ComboBox();
|
this.cbGuilds = new System.Windows.Forms.ComboBox();
|
||||||
this.lbGuild = new System.Windows.Forms.Label();
|
this.lbGuild = new System.Windows.Forms.Label();
|
||||||
this.pgbProgress = new System.Windows.Forms.ProgressBar();
|
this.cbSkip = new System.Windows.Forms.CheckBox();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nupThreadCount)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.nupThreadCount)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
this.btnDownload.Location = new System.Drawing.Point(12, 167);
|
this.btnDownload.Location = new System.Drawing.Point(12, 167);
|
||||||
this.btnDownload.Name = "btnDownload";
|
this.btnDownload.Name = "btnDownload";
|
||||||
this.btnDownload.Size = new System.Drawing.Size(415, 23);
|
this.btnDownload.Size = new System.Drawing.Size(415, 23);
|
||||||
this.btnDownload.TabIndex = 10;
|
this.btnDownload.TabIndex = 20;
|
||||||
this.btnDownload.Text = "Start downloading";
|
this.btnDownload.Text = "Start downloading";
|
||||||
this.btnDownload.UseVisualStyleBackColor = true;
|
this.btnDownload.UseVisualStyleBackColor = true;
|
||||||
this.btnDownload.Click += new System.EventHandler(this.btnDownload_Click);
|
this.btnDownload.Click += new System.EventHandler(this.btnDownload_Click);
|
||||||
|
@ -188,19 +188,24 @@
|
||||||
this.lbGuild.TabIndex = 0;
|
this.lbGuild.TabIndex = 0;
|
||||||
this.lbGuild.Text = "Guild:";
|
this.lbGuild.Text = "Guild:";
|
||||||
//
|
//
|
||||||
// pgbProgress
|
// cbSkip
|
||||||
//
|
//
|
||||||
this.pgbProgress.Location = new System.Drawing.Point(15, 219);
|
this.cbSkip.AutoSize = true;
|
||||||
this.pgbProgress.Name = "pgbProgress";
|
this.cbSkip.Checked = true;
|
||||||
this.pgbProgress.Size = new System.Drawing.Size(413, 23);
|
this.cbSkip.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.pgbProgress.TabIndex = 15;
|
this.cbSkip.Location = new System.Drawing.Point(227, 141);
|
||||||
|
this.cbSkip.Name = "cbSkip";
|
||||||
|
this.cbSkip.Size = new System.Drawing.Size(106, 17);
|
||||||
|
this.cbSkip.TabIndex = 16;
|
||||||
|
this.cbSkip.Text = "Skip existing files";
|
||||||
|
this.cbSkip.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(439, 253);
|
this.ClientSize = new System.Drawing.Size(439, 253);
|
||||||
this.Controls.Add(this.pgbProgress);
|
this.Controls.Add(this.cbSkip);
|
||||||
this.Controls.Add(this.lbDownload);
|
this.Controls.Add(this.lbDownload);
|
||||||
this.Controls.Add(this.lbScanCount);
|
this.Controls.Add(this.lbScanCount);
|
||||||
this.Controls.Add(this.nupThreadCount);
|
this.Controls.Add(this.nupThreadCount);
|
||||||
|
@ -246,6 +251,6 @@
|
||||||
private System.Windows.Forms.Label lbDownload;
|
private System.Windows.Forms.Label lbDownload;
|
||||||
private System.Windows.Forms.ComboBox cbGuilds;
|
private System.Windows.Forms.ComboBox cbGuilds;
|
||||||
private System.Windows.Forms.Label lbGuild;
|
private System.Windows.Forms.Label lbGuild;
|
||||||
private System.Windows.Forms.ProgressBar pgbProgress;
|
private System.Windows.Forms.CheckBox cbSkip;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,7 @@ namespace Discord_Media_Loader
|
||||||
{
|
{
|
||||||
private DiscordClient Client { get; } = new DiscordClient();
|
private DiscordClient Client { get; } = new DiscordClient();
|
||||||
private event EventHandler<UpdateProgessEventArgs> UpdateProgress;
|
private event EventHandler<UpdateProgessEventArgs> UpdateProgress;
|
||||||
|
private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -32,8 +33,6 @@ namespace Discord_Media_Loader
|
||||||
{
|
{
|
||||||
SetControlPropertyThreadSafe(lbDownload, "Text", $"Files downloaded: {e.Downloaded}");
|
SetControlPropertyThreadSafe(lbDownload, "Text", $"Files downloaded: {e.Downloaded}");
|
||||||
SetControlPropertyThreadSafe(lbScanCount, "Text", $"Messages scanned: {e.Scanned}");
|
SetControlPropertyThreadSafe(lbScanCount, "Text", $"Messages scanned: {e.Scanned}");
|
||||||
//SetControlPropertyThreadSafe(pgbProgress, "Max", e.MaxProgress);
|
|
||||||
//SetControlPropertyThreadSafe(pgbProgress, "Value", e.Progress);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,12 +173,20 @@ namespace Discord_Media_Loader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long DateTimeToUnixTimeStamp(DateTime dateTime)
|
||||||
|
{
|
||||||
|
TimeSpan elapsedTime = dateTime - Epoch;
|
||||||
|
return (long)elapsedTime.TotalSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void btnDownload_Click(object sender, EventArgs e)
|
private void btnDownload_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var path = tbxPath.Text;
|
var path = tbxPath.Text;
|
||||||
var useStopDate = cbLimitDate.Checked;
|
var useStopDate = cbLimitDate.Checked;
|
||||||
var stopDate = dtpLimit.Value;
|
var stopDate = dtpLimit.Value;
|
||||||
var threadLimit = nupThreadCount.Value;
|
var threadLimit = nupThreadCount.Value;
|
||||||
|
var skipExisting = cbSkip.Checked;
|
||||||
|
|
||||||
if (!Directory.Exists(path))
|
if (!Directory.Exists(path))
|
||||||
{
|
{
|
||||||
|
@ -204,8 +211,8 @@ namespace Discord_Media_Loader
|
||||||
ulong downloadCount = 0;
|
ulong downloadCount = 0;
|
||||||
var locker = new object();
|
var locker = new object();
|
||||||
|
|
||||||
var timeDiffSteps = (uint)Math.Floor(int.MaxValue / 2 / (DateTime.Now - dtpLimit.Value.Date).TotalHours);
|
var timeDiffSteps = (int)Math.Floor(int.MaxValue / 2 / (DateTime.Now - dtpLimit.Value.Date).TotalHours);
|
||||||
uint progress = 0;
|
int progress = 0;
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
|
@ -235,6 +242,17 @@ namespace Discord_Media_Loader
|
||||||
foreach (var a in m.Attachments)
|
foreach (var a in m.Attachments)
|
||||||
{
|
{
|
||||||
fileFound++;
|
fileFound++;
|
||||||
|
|
||||||
|
if (!path.EndsWith(@"\"))
|
||||||
|
path += @"\";
|
||||||
|
|
||||||
|
var fname = $"{guild.Name}_{channel.Name}_{DateTimeToUnixTimeStamp(m.Timestamp)}_{a.Filename}";
|
||||||
|
fname = Path.GetInvalidFileNameChars().Aggregate(fname, (current, c) => current.Replace(c, '-'));
|
||||||
|
fname = path + fname;
|
||||||
|
|
||||||
|
if (skipExisting && File.Exists(fname))
|
||||||
|
continue;
|
||||||
|
|
||||||
while (clients.Count >= threadLimit)
|
while (clients.Count >= threadLimit)
|
||||||
{
|
{
|
||||||
// wait
|
// wait
|
||||||
|
@ -252,19 +270,11 @@ namespace Discord_Media_Loader
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!path.EndsWith(@"\"))
|
wc.DownloadFileAsync(new Uri(a.Url), fname);
|
||||||
path += @"\";
|
|
||||||
|
|
||||||
var fname = $"{guild.Name}_{channel.Name}_{m.Timestamp}_{a.Filename}";
|
|
||||||
fname = Path.GetInvalidFileNameChars().Aggregate(fname, (current, c) => current.Replace(c, '-'));
|
|
||||||
|
|
||||||
|
|
||||||
wc.DownloadFileAsync(new Uri(a.Url), $@"{path}{fname}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msgScanCount++;
|
msgScanCount++;
|
||||||
progress += timeDiffSteps;
|
OnUpdateProgress(new UpdateProgessEventArgs() { Downloaded = downloadCount, Scanned = msgScanCount});
|
||||||
OnUpdateProgress(new UpdateProgessEventArgs() { Downloaded = downloadCount, Scanned = msgScanCount, Progress = progress });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop = stop || messages.Length < limit;
|
stop = stop || messages.Length < limit;
|
||||||
|
@ -287,7 +297,5 @@ namespace Discord_Media_Loader
|
||||||
{
|
{
|
||||||
internal ulong Scanned { get; set; } = 0;
|
internal ulong Scanned { get; set; } = 0;
|
||||||
internal ulong Downloaded { get; set; } = 0;
|
internal ulong Downloaded { get; set; } = 0;
|
||||||
internal uint Progress { get; set; } = 0;
|
|
||||||
internal uint MaxProgress { get; set; } = int.MaxValue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.1.0.42")]
|
[assembly: AssemblyVersion("0.1.0.48")]
|
||||||
[assembly: AssemblyFileVersion("0.1.0.42")]
|
[assembly: AssemblyFileVersion("0.1.0.48")]
|
||||||
|
|
Loading…
Reference in a new issue