From dc708060fc08e32eee63db1b02027c4ce83127c5 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Sun, 29 Jan 2017 10:20:54 +0100 Subject: [PATCH] Finalised for first release build --- .../Discord Media Loader.csproj | 1 + Discord Media Loader/LoginForm.cs | 7 -- Discord Media Loader/MainForm.Designer.cs | 56 ++++++++++++++- Discord Media Loader/MainForm.cs | 50 ++++++------- Discord Media Loader/Program.cs | 3 - .../Properties/AssemblyInfo.cs | 5 +- .../Properties/Resources.Designer.cs | 72 ++++++++++--------- .../Properties/Resources.resx | 23 ++++-- 8 files changed, 139 insertions(+), 78 deletions(-) diff --git a/Discord Media Loader/Discord Media Loader.csproj b/Discord Media Loader/Discord Media Loader.csproj index 1977f71..274394d 100644 --- a/Discord Media Loader/Discord Media Loader.csproj +++ b/Discord Media Loader/Discord Media Loader.csproj @@ -105,6 +105,7 @@ True Resources.resx + True diff --git a/Discord Media Loader/LoginForm.cs b/Discord Media Loader/LoginForm.cs index 2bd512e..2286fe2 100644 --- a/Discord Media Loader/LoginForm.cs +++ b/Discord Media Loader/LoginForm.cs @@ -1,11 +1,4 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace Discord_Media_Loader diff --git a/Discord Media Loader/MainForm.Designer.cs b/Discord Media Loader/MainForm.Designer.cs index 0f0caf0..879ad82 100644 --- a/Discord Media Loader/MainForm.Designer.cs +++ b/Discord Media Loader/MainForm.Designer.cs @@ -45,6 +45,10 @@ this.cbGuilds = new System.Windows.Forms.ComboBox(); this.lbGuild = new System.Windows.Forms.Label(); this.cbSkip = new System.Windows.Forms.CheckBox(); + this.lbCopyright = new System.Windows.Forms.Label(); + this.lbGithub = new System.Windows.Forms.LinkLabel(); + this.lbAbout = new System.Windows.Forms.LinkLabel(); + this.lbVersion = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.nupThreadCount)).BeginInit(); this.SuspendLayout(); // @@ -116,6 +120,7 @@ // // cbChannels // + this.cbChannels.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbChannels.FormattingEnabled = true; this.cbChannels.Location = new System.Drawing.Point(264, 32); this.cbChannels.Name = "cbChannels"; @@ -172,6 +177,7 @@ // // cbGuilds // + this.cbGuilds.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbGuilds.FormattingEnabled = true; this.cbGuilds.Location = new System.Drawing.Point(52, 32); this.cbGuilds.Name = "cbGuilds"; @@ -200,11 +206,55 @@ this.cbSkip.Text = "Skip existing files"; this.cbSkip.UseVisualStyleBackColor = true; // + // lbCopyright + // + this.lbCopyright.AutoSize = true; + this.lbCopyright.Location = new System.Drawing.Point(12, 274); + this.lbCopyright.Name = "lbCopyright"; + this.lbCopyright.Size = new System.Drawing.Size(151, 13); + this.lbCopyright.TabIndex = 22; + this.lbCopyright.Text = "Copyright (c) 2017 by Serraniel"; + // + // lbGithub + // + this.lbGithub.AutoSize = true; + this.lbGithub.Location = new System.Drawing.Point(169, 274); + this.lbGithub.Name = "lbGithub"; + this.lbGithub.Size = new System.Drawing.Size(40, 13); + this.lbGithub.TabIndex = 23; + this.lbGithub.TabStop = true; + this.lbGithub.Text = "GitHub"; + this.lbGithub.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lbGithub_LinkClicked); + // + // lbAbout + // + this.lbAbout.AutoSize = true; + this.lbAbout.Location = new System.Drawing.Point(223, 274); + this.lbAbout.Name = "lbAbout"; + this.lbAbout.Size = new System.Drawing.Size(35, 13); + this.lbAbout.TabIndex = 24; + this.lbAbout.TabStop = true; + this.lbAbout.Text = "About"; + this.lbAbout.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lbAbout_LinkClicked); + // + // lbVersion + // + this.lbVersion.Location = new System.Drawing.Point(328, 274); + this.lbVersion.Name = "lbVersion"; + this.lbVersion.Size = new System.Drawing.Size(100, 13); + this.lbVersion.TabIndex = 25; + this.lbVersion.Text = "version"; + this.lbVersion.TextAlign = System.Drawing.ContentAlignment.TopRight; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(439, 253); + this.ClientSize = new System.Drawing.Size(439, 296); + this.Controls.Add(this.lbVersion); + this.Controls.Add(this.lbAbout); + this.Controls.Add(this.lbGithub); + this.Controls.Add(this.lbCopyright); this.Controls.Add(this.cbSkip); this.Controls.Add(this.lbDownload); this.Controls.Add(this.lbScanCount); @@ -252,5 +302,9 @@ private System.Windows.Forms.ComboBox cbGuilds; private System.Windows.Forms.Label lbGuild; private System.Windows.Forms.CheckBox cbSkip; + private System.Windows.Forms.Label lbCopyright; + private System.Windows.Forms.LinkLabel lbGithub; + private System.Windows.Forms.LinkLabel lbAbout; + private System.Windows.Forms.Label lbVersion; } } \ No newline at end of file diff --git a/Discord Media Loader/MainForm.cs b/Discord Media Loader/MainForm.cs index 8716354..957aa1e 100644 --- a/Discord Media Loader/MainForm.cs +++ b/Discord Media Loader/MainForm.cs @@ -1,22 +1,15 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Diagnostics; -using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Reflection; -using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Discord; using Discord.Net; -using Nito.AsyncEx; using ConnectionState = Discord.ConnectionState; -using Message = Discord.Message; namespace Discord_Media_Loader { @@ -42,13 +35,12 @@ namespace Discord_Media_Loader { if (control.InvokeRequired) { - control.Invoke(new SetControlPropertyThreadSafeDelegate(SetControlPropertyThreadSafe), - new object[] { control, propertyName, propertyValue }); + control.Invoke(new SetControlPropertyThreadSafeDelegate(SetControlPropertyThreadSafe), control, propertyName, propertyValue); } else { - control.GetType().InvokeMember(propertyName, BindingFlags.SetProperty, null, control, new object[] { propertyValue }); + control.GetType().InvokeMember(propertyName, BindingFlags.SetProperty, null, control, new[] { propertyValue }); } } @@ -59,7 +51,7 @@ namespace Discord_Media_Loader while (Client.State != ConnectionState.Connected && !abort) { - var password = ""; + string password; if (LoginForm.Exec(ref email, out password)) { @@ -78,7 +70,7 @@ namespace Discord_Media_Loader Cursor = Cursors.Default; } } - catch (HttpException ex) + catch (HttpException) { // ignore http exception on invalid login } @@ -94,6 +86,8 @@ namespace Discord_Media_Loader private async void MainForm_Shown(object sender, EventArgs e) { + lbVersion.Text = $"v{Assembly.GetExecutingAssembly().GetName().Version}"; + SetEnabled(false); if (!await Login()) @@ -167,10 +161,7 @@ namespace Discord_Media_Loader private void OnUpdateProgress(UpdateProgessEventArgs e) { EventHandler handler = UpdateProgress; - if (handler != null) - { - handler(this, e); - } + handler?.Invoke(this, e); } private static long DateTimeToUnixTimeStamp(DateTime dateTime) @@ -203,17 +194,13 @@ namespace Discord_Media_Loader var limit = 100; var stop = false; - ulong lastId = ulong.MaxValue; + var lastId = ulong.MaxValue; var isFirst = true; ulong msgScanCount = 0; - ulong fileFound = 0; ulong downloadCount = 0; var locker = new object(); - var timeDiffSteps = (int)Math.Floor(int.MaxValue / 2 / (DateTime.Now - dtpLimit.Value.Date).TotalHours); - int progress = 0; - Task.Run(async () => { @@ -222,9 +209,9 @@ namespace Discord_Media_Loader Discord.Message[] messages; if (isFirst) - messages = await channel.DownloadMessages(limit, null, Relative.Before, true); + messages = await channel.DownloadMessages(limit, null); else - messages = await channel.DownloadMessages(limit, lastId, Relative.Before, true); + messages = await channel.DownloadMessages(limit, lastId); isFirst = false; @@ -241,8 +228,6 @@ namespace Discord_Media_Loader foreach (var a in m.Attachments) { - fileFound++; - if (!path.EndsWith(@"\")) path += @"\"; @@ -288,14 +273,25 @@ namespace Discord_Media_Loader } }); + Process.Start(path); SetEnabled(true); }); } + + private void lbGithub_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start("https://github.com/Serraniel/DiscordMediaLoader/releases"); + } + + private void lbAbout_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + MessageBox.Show(Properties.Resources.AboutString); + } } internal class UpdateProgessEventArgs : EventArgs { - internal ulong Scanned { get; set; } = 0; - internal ulong Downloaded { get; set; } = 0; + internal ulong Scanned { get; set; } + internal ulong Downloaded { get; set; } } } diff --git a/Discord Media Loader/Program.cs b/Discord Media Loader/Program.cs index a3a1342..837140a 100644 --- a/Discord Media Loader/Program.cs +++ b/Discord Media Loader/Program.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using System.Windows.Forms; namespace Discord_Media_Loader diff --git a/Discord Media Loader/Properties/AssemblyInfo.cs b/Discord Media Loader/Properties/AssemblyInfo.cs index aacf74e..5dacbc3 100644 --- a/Discord Media Loader/Properties/AssemblyInfo.cs +++ b/Discord Media Loader/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // Allgemeine Informationen über eine Assembly werden über die folgenden @@ -32,5 +31,5 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.0.48")] -[assembly: AssemblyFileVersion("0.1.0.48")] +[assembly: AssemblyVersion("0.1.0.51")] +[assembly: AssemblyFileVersion("0.1.0.51")] diff --git a/Discord Media Loader/Properties/Resources.Designer.cs b/Discord Media Loader/Properties/Resources.Designer.cs index 4fb9e89..116551a 100644 --- a/Discord Media Loader/Properties/Resources.Designer.cs +++ b/Discord Media Loader/Properties/Resources.Designer.cs @@ -1,71 +1,79 @@ //------------------------------------------------------------------------------ // // Dieser Code wurde von einem Tool generiert. -// Laufzeitversion: 4.0.30319.42000 +// Laufzeitversion:4.0.30319.42000 // -// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn -// der Code neu generiert wird. +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. // //------------------------------------------------------------------------------ -namespace Discord_Media_Loader.Properties -{ - - +namespace Discord_Media_Loader.Properties { + using System; + + /// /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. /// - // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse - // über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen - // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu. + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Discord_Media_Loader.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle - /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden. + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Discord Media Loader by Serraniel - Apache 2.0 License + ///https://github.com/Serraniel/DiscordMediaLoader/ + /// + ///Made with: + ///Discord.Net (Copyright (c) 2015 RogueException - MIT License) + ///Newtonsoft.Json (Copyright (c) 2007 James Newton-King - MIT License) + ///Nito.AsyncEx (Copyright (c) 2014 StephenCleary - MIT License) + ///WebSocket4Net (Copyright (c) kerryjiang - Apache 2.0 License) ähnelt. + /// + internal static string AboutString { + get { + return ResourceManager.GetString("AboutString", resourceCulture); + } + } } } diff --git a/Discord Media Loader/Properties/Resources.resx b/Discord Media Loader/Properties/Resources.resx index af7dbeb..03f47a6 100644 --- a/Discord Media Loader/Properties/Resources.resx +++ b/Discord Media Loader/Properties/Resources.resx @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,19 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Discord Media Loader by Serraniel - Apache 2.0 License +https://github.com/Serraniel/DiscordMediaLoader/ + +Made with: +Discord.Net (Copyright (c) 2015 RogueException - MIT License) +Newtonsoft.Json (Copyright (c) 2007 James Newton-King - MIT License) +Nito.AsyncEx (Copyright (c) 2014 StephenCleary - MIT License) +WebSocket4Net (Copyright (c) kerryjiang - Apache 2.0 License) + \ No newline at end of file