Finalised for first release build

This commit is contained in:
Serraniel 2017-01-29 10:20:54 +01:00
parent 9a4ca60458
commit dc708060fc
8 changed files with 139 additions and 78 deletions

View file

@ -105,6 +105,7 @@
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile> </Compile>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">

View file

@ -1,11 +1,4 @@
using System; 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; using System.Windows.Forms;
namespace Discord_Media_Loader namespace Discord_Media_Loader

View file

@ -45,6 +45,10 @@
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.cbSkip = new System.Windows.Forms.CheckBox(); 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(); ((System.ComponentModel.ISupportInitialize)(this.nupThreadCount)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -116,6 +120,7 @@
// //
// cbChannels // cbChannels
// //
this.cbChannels.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbChannels.FormattingEnabled = true; this.cbChannels.FormattingEnabled = true;
this.cbChannels.Location = new System.Drawing.Point(264, 32); this.cbChannels.Location = new System.Drawing.Point(264, 32);
this.cbChannels.Name = "cbChannels"; this.cbChannels.Name = "cbChannels";
@ -172,6 +177,7 @@
// //
// cbGuilds // cbGuilds
// //
this.cbGuilds.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbGuilds.FormattingEnabled = true; this.cbGuilds.FormattingEnabled = true;
this.cbGuilds.Location = new System.Drawing.Point(52, 32); this.cbGuilds.Location = new System.Drawing.Point(52, 32);
this.cbGuilds.Name = "cbGuilds"; this.cbGuilds.Name = "cbGuilds";
@ -200,11 +206,55 @@
this.cbSkip.Text = "Skip existing files"; this.cbSkip.Text = "Skip existing files";
this.cbSkip.UseVisualStyleBackColor = true; 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 // 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, 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.cbSkip);
this.Controls.Add(this.lbDownload); this.Controls.Add(this.lbDownload);
this.Controls.Add(this.lbScanCount); this.Controls.Add(this.lbScanCount);
@ -252,5 +302,9 @@
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.CheckBox cbSkip; 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;
} }
} }

View file

@ -1,22 +1,15 @@
using System; using System;
using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Discord; using Discord;
using Discord.Net; using Discord.Net;
using Nito.AsyncEx;
using ConnectionState = Discord.ConnectionState; using ConnectionState = Discord.ConnectionState;
using Message = Discord.Message;
namespace Discord_Media_Loader namespace Discord_Media_Loader
{ {
@ -42,13 +35,12 @@ namespace Discord_Media_Loader
{ {
if (control.InvokeRequired) if (control.InvokeRequired)
{ {
control.Invoke(new SetControlPropertyThreadSafeDelegate(SetControlPropertyThreadSafe), control.Invoke(new SetControlPropertyThreadSafeDelegate(SetControlPropertyThreadSafe), control, propertyName, propertyValue);
new object[] { control, propertyName, propertyValue });
} }
else 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) while (Client.State != ConnectionState.Connected && !abort)
{ {
var password = ""; string password;
if (LoginForm.Exec(ref email, out password)) if (LoginForm.Exec(ref email, out password))
{ {
@ -78,7 +70,7 @@ namespace Discord_Media_Loader
Cursor = Cursors.Default; Cursor = Cursors.Default;
} }
} }
catch (HttpException ex) catch (HttpException)
{ {
// ignore http exception on invalid login // ignore http exception on invalid login
} }
@ -94,6 +86,8 @@ namespace Discord_Media_Loader
private async void MainForm_Shown(object sender, EventArgs e) private async void MainForm_Shown(object sender, EventArgs e)
{ {
lbVersion.Text = $"v{Assembly.GetExecutingAssembly().GetName().Version}";
SetEnabled(false); SetEnabled(false);
if (!await Login()) if (!await Login())
@ -167,10 +161,7 @@ namespace Discord_Media_Loader
private void OnUpdateProgress(UpdateProgessEventArgs e) private void OnUpdateProgress(UpdateProgessEventArgs e)
{ {
EventHandler<UpdateProgessEventArgs> handler = UpdateProgress; EventHandler<UpdateProgessEventArgs> handler = UpdateProgress;
if (handler != null) handler?.Invoke(this, e);
{
handler(this, e);
}
} }
private static long DateTimeToUnixTimeStamp(DateTime dateTime) private static long DateTimeToUnixTimeStamp(DateTime dateTime)
@ -203,17 +194,13 @@ namespace Discord_Media_Loader
var limit = 100; var limit = 100;
var stop = false; var stop = false;
ulong lastId = ulong.MaxValue; var lastId = ulong.MaxValue;
var isFirst = true; var isFirst = true;
ulong msgScanCount = 0; ulong msgScanCount = 0;
ulong fileFound = 0;
ulong downloadCount = 0; ulong downloadCount = 0;
var locker = new object(); var locker = new object();
var timeDiffSteps = (int)Math.Floor(int.MaxValue / 2 / (DateTime.Now - dtpLimit.Value.Date).TotalHours);
int progress = 0;
Task.Run(async () => Task.Run(async () =>
{ {
@ -222,9 +209,9 @@ namespace Discord_Media_Loader
Discord.Message[] messages; Discord.Message[] messages;
if (isFirst) if (isFirst)
messages = await channel.DownloadMessages(limit, null, Relative.Before, true); messages = await channel.DownloadMessages(limit, null);
else else
messages = await channel.DownloadMessages(limit, lastId, Relative.Before, true); messages = await channel.DownloadMessages(limit, lastId);
isFirst = false; isFirst = false;
@ -241,8 +228,6 @@ namespace Discord_Media_Loader
foreach (var a in m.Attachments) foreach (var a in m.Attachments)
{ {
fileFound++;
if (!path.EndsWith(@"\")) if (!path.EndsWith(@"\"))
path += @"\"; path += @"\";
@ -288,14 +273,25 @@ namespace Discord_Media_Loader
} }
}); });
Process.Start(path);
SetEnabled(true); 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 class UpdateProgessEventArgs : EventArgs
{ {
internal ulong Scanned { get; set; } = 0; internal ulong Scanned { get; set; }
internal ulong Downloaded { get; set; } = 0; internal ulong Downloaded { get; set; }
} }
} }

View file

@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace Discord_Media_Loader namespace Discord_Media_Loader

View file

@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden // 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 // 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.48")] [assembly: AssemblyVersion("0.1.0.51")]
[assembly: AssemblyFileVersion("0.1.0.48")] [assembly: AssemblyFileVersion("0.1.0.51")]

View file

@ -3,47 +3,42 @@
// Dieser Code wurde von einem Tool generiert. // 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 // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code neu generiert wird. // der Code erneut generiert wird.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace Discord_Media_Loader.Properties namespace Discord_Media_Loader.Properties {
{ using System;
/// <summary> /// <summary>
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
/// </summary> /// </summary>
// Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
// über ein Tool wie ResGen oder Visual Studio 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 // 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.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources internal class Resources {
{
private static global::System.Resources.ResourceManager resourceMan; private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture; private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() internal Resources() {
{
} }
/// <summary> /// <summary>
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager internal static global::System.Resources.ResourceManager ResourceManager {
{ get {
get if (object.ReferenceEquals(resourceMan, null)) {
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Discord_Media_Loader.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Discord_Media_Loader.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
@ -53,19 +48,32 @@ namespace Discord_Media_Loader.Properties
/// <summary> /// <summary>
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
/// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden. /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture internal static global::System.Globalization.CultureInfo Culture {
{ get {
get
{
return resourceCulture; return resourceCulture;
} }
set set {
{
resourceCulture = value; resourceCulture = value;
} }
} }
/// <summary>
/// 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.
/// </summary>
internal static string AboutString {
get {
return ResourceManager.GetString("AboutString", resourceCulture);
}
}
} }
} }

View file

@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
@ -60,6 +60,7 @@
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
@ -68,9 +69,10 @@
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
@ -109,9 +112,19 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="AboutString" xml:space="preserve">
<value>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)</value>
</data>
</root> </root>