Merge branch 'develop' into feature/DatabaseJobs
# Conflicts: # Discord Media Loader.Application/Classes/Core.cs # Discord Media Loader.Application/Classes/Job.cs # Discord Media Loader.Application/Classes/JobScheduler.cs # Discord Media Loader.Application/Classes/Settings.cs # Discord Media Loader.Application/DML.Application.csproj
This commit is contained in:
commit
5cd9a0c200
|
@ -8,6 +8,7 @@ using System.Windows.Forms;
|
|||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using DML.AppCore.Classes;
|
||||
using DML.Application.Classes.RPC;
|
||||
using DML.Application.Dialogs;
|
||||
using DML.Client;
|
||||
using LiteDB;
|
||||
|
@ -26,11 +27,14 @@ namespace DML.Application.Classes
|
|||
internal static LiteDatabase Database { get; set; }
|
||||
internal static Settings Settings { get; set; }
|
||||
internal static JobScheduler Scheduler { get; } = new JobScheduler();
|
||||
internal static RavenClient Raven = new RavenClient("https://0de964231669473e9098b9f6cc1d6278:79d9f2eb24034de199b2a37cc058e0f2@sentry.io/257114");
|
||||
|
||||
internal static RavenClient Raven { get; } = new RavenClient("https://0de964231669473e9098b9f6cc1d6278:79d9f2eb24034de199b2a37cc058e0f2@sentry.io/257114");
|
||||
internal static bool ShuttingDown { get; private set; } = false;
|
||||
internal static string DataDirectory
|
||||
=> Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Serraniel\Discord Media Loader");
|
||||
|
||||
internal static DiscordRpc.RichPresence RpcPresence;
|
||||
internal static DiscordRpc.EventHandlers RpcHandlers = new DiscordRpc.EventHandlers();
|
||||
|
||||
public static async Task Run(string[] paramStrings)
|
||||
{
|
||||
try
|
||||
|
@ -233,9 +237,33 @@ namespace DML.Application.Classes
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Settings.RescanRequired = false;
|
||||
Settings.Store();
|
||||
|
||||
if (Settings.UseRPC)
|
||||
{
|
||||
Logger.Info("Initializing RPC client");
|
||||
Logger.Trace("Registering RPC handlers");
|
||||
RpcHandlers.readyCallback += RpcReadyCallback;
|
||||
RpcHandlers.disconnectedCallback += RpcDisconnectedCallback;
|
||||
RpcHandlers.errorCallback += RpcErrorCallback;
|
||||
RpcPresence.startTimestamp = DiscordRpcHelper.DateTimeToTimestamp(DateTime.UtcNow);
|
||||
|
||||
Logger.Debug("Calling RPC initialize");
|
||||
DiscordRpc.Initialize("430025401851707393", ref RpcHandlers, true, null);
|
||||
|
||||
// Do not await ;)
|
||||
Task.Run(async () =>
|
||||
{
|
||||
while (!ShuttingDown)
|
||||
{
|
||||
Logger.Trace("Running RPC callbacks");
|
||||
await Task.Delay(5000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
splash.Close();
|
||||
|
||||
Logger.Info("Starting scheduler...");
|
||||
|
@ -243,8 +271,14 @@ namespace DML.Application.Classes
|
|||
|
||||
System.Windows.Forms.Application.Run(new MainForm());
|
||||
|
||||
// shutting down
|
||||
ShuttingDown = true;
|
||||
|
||||
Logger.Info("Stopping scheduler...");
|
||||
Scheduler.Stop();
|
||||
|
||||
Logger.Info("Shutting down RPC client");
|
||||
DiscordRpc.Shutdown();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -272,5 +306,26 @@ namespace DML.Application.Classes
|
|||
Logger.Trace($"Trying to find channel in {server} by id: {id}");
|
||||
return (from c in server.TextChannels where c.Id == id select c).FirstOrDefault();
|
||||
}
|
||||
|
||||
internal static void RpcUpdatePresence()
|
||||
{
|
||||
Logger.Debug("Updating RPC presence");
|
||||
DiscordRpc.UpdatePresence(ref RpcPresence);
|
||||
}
|
||||
|
||||
private static void RpcReadyCallback()
|
||||
{
|
||||
Logger.Debug("RpcReady");
|
||||
}
|
||||
|
||||
private static void RpcDisconnectedCallback(int errorCode, string message)
|
||||
{
|
||||
Logger.Warn($"RPC disconnect received: {errorCode} - {message}");
|
||||
}
|
||||
|
||||
private static void RpcErrorCallback(int errorCode, string message)
|
||||
{
|
||||
Logger.Error($"RPC error received: {errorCode} - {message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ using Discord.WebSocket;
|
|||
using DML.Application.Classes;
|
||||
using DML.Client;
|
||||
using SweetLib.Utils;
|
||||
using SweetLib.Utils.Extensions;
|
||||
using static SweetLib.Utils.Logger.Logger;
|
||||
|
||||
namespace DML.AppCore.Classes
|
||||
|
@ -120,7 +121,7 @@ namespace DML.AppCore.Classes
|
|||
lastId = m.Id;
|
||||
}
|
||||
|
||||
if (SweetUtils.DateTimeToUnixTimeStamp(m.CreatedAt.UtcDateTime) <= StopTimestamp)
|
||||
if (m.CreatedAt.UtcDateTime.ToUnixTimeStamp() <= StopTimestamp)
|
||||
{
|
||||
Debug("Found a message with a known timestamp...Stopping scan.");
|
||||
finished = true;
|
||||
|
@ -156,7 +157,7 @@ namespace DML.AppCore.Classes
|
|||
ChannelId = r.Channel.Id,
|
||||
DownloadSource = a.Url,
|
||||
Filename = a.Filename,
|
||||
TimeStamp = SweetUtils.DateTimeToUnixTimeStamp(r.CreatedAt.UtcDateTime),
|
||||
TimeStamp = r.CreatedAt.UtcDateTime.ToUnixTimeStamp(),
|
||||
FileSize = a.Size
|
||||
};
|
||||
mediaData.Store();
|
||||
|
@ -166,7 +167,7 @@ namespace DML.AppCore.Classes
|
|||
if (result.Count > 0)
|
||||
{
|
||||
Trace("Updating StopTimestamp for next scan...");
|
||||
StopTimestamp = SweetUtils.DateTimeToUnixTimeStamp(result[result.Count - 1].CreatedAt.UtcDateTime);
|
||||
StopTimestamp = result[result.Count - 1].CreatedAt.UtcDateTime.ToUnixTimeStamp();
|
||||
KnownTimestamp = StopTimestamp;
|
||||
Store();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,16 @@ using System.Collections.Generic;
|
|||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using DML.AppCore.Classes;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using DML.Application.Classes;
|
||||
using SweetLib.Utils;
|
||||
using SweetLib.Utils.Extensions;
|
||||
using SweetLib.Utils.Logger;
|
||||
|
||||
namespace DML.Application.Classes
|
||||
|
|
59
Discord Media Loader.Application/Classes/RPC/DiscordRpc.cs
Normal file
59
Discord Media Loader.Application/Classes/RPC/DiscordRpc.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DML.Application.Classes.RPC
|
||||
{
|
||||
// https://github.com/discordapp/discord-rpc/blob/master/examples/button-clicker/Assets/DiscordRpc.cs
|
||||
// Give that man a cookie ^.^
|
||||
|
||||
public class DiscordRpc
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void ReadyCallback();
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void DisconnectedCallback(int errorCode, string message);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void ErrorCallback(int errorCode, string message);
|
||||
|
||||
public struct EventHandlers
|
||||
{
|
||||
public ReadyCallback readyCallback;
|
||||
public DisconnectedCallback disconnectedCallback;
|
||||
public ErrorCallback errorCallback;
|
||||
}
|
||||
|
||||
// Values explanation and example: https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields
|
||||
[System.Serializable]
|
||||
public struct RichPresence
|
||||
{
|
||||
public string state; /* max 128 bytes */
|
||||
public string details; /* max 128 bytes */
|
||||
public long startTimestamp;
|
||||
public long endTimestamp;
|
||||
public string largeImageKey; /* max 32 bytes */
|
||||
public string largeImageText; /* max 128 bytes */
|
||||
public string smallImageKey; /* max 32 bytes */
|
||||
public string smallImageText; /* max 128 bytes */
|
||||
public string partyId; /* max 128 bytes */
|
||||
public int partySize;
|
||||
public int partyMax;
|
||||
public string matchSecret; /* max 128 bytes */
|
||||
public string joinSecret; /* max 128 bytes */
|
||||
public string spectateSecret; /* max 128 bytes */
|
||||
public bool instance;
|
||||
}
|
||||
|
||||
[DllImport(RpcWrapper.Dll, EntryPoint = "Discord_Initialize", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId);
|
||||
|
||||
[DllImport(RpcWrapper.Dll, EntryPoint = "Discord_UpdatePresence", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void UpdatePresence(ref RichPresence presence);
|
||||
|
||||
[DllImport(RpcWrapper.Dll, EntryPoint = "Discord_RunCallbacks", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void RunCallbacks();
|
||||
|
||||
[DllImport(RpcWrapper.Dll, EntryPoint = "Discord_Shutdown", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Shutdown();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DML.Application.Classes.RPC
|
||||
{
|
||||
public static class DiscordRpcHelper
|
||||
{
|
||||
public static long DateTimeToTimestamp(DateTime dt)
|
||||
{
|
||||
return (dt.Ticks - 621355968000000000) / 10000000;
|
||||
}
|
||||
}
|
||||
}
|
29
Discord Media Loader.Application/Classes/RPC/RpcWrapper.cs
Normal file
29
Discord Media Loader.Application/Classes/RPC/RpcWrapper.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DML.Application.Classes.RPC
|
||||
{
|
||||
public class RpcWrapper
|
||||
{
|
||||
public const string Dll = "discord-rpc-win32";
|
||||
|
||||
public RpcWrapper()
|
||||
{
|
||||
if (!File.Exists(Dll + ".dll"))
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Missing " + Dll + ".dll\n\n" +
|
||||
"Grab it from the release on GitHub or from the DiscordRpcDemo/lib/ folder in the repo then put it alongside DiscordRpcDemo.exe.\n\n" +
|
||||
"https://github.com/nostrenz/cshap-discord-rpc-demo"
|
||||
);
|
||||
|
||||
System.Windows.Forms.Application.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ namespace DML.Application.Classes
|
|||
public bool SkipExistingFiles { get; set; } = true;
|
||||
public int ThreadLimit { get; set; } = 50;
|
||||
public bool RescanRequired { get; set; } = true;
|
||||
public bool UseRPC { get; set; } = false;
|
||||
|
||||
public void Store()
|
||||
{
|
||||
|
|
|
@ -161,7 +161,10 @@
|
|||
<Compile Include="Classes\Core.cs" />
|
||||
<Compile Include="Classes\Job.cs" />
|
||||
<Compile Include="Classes\JobScheduler.cs" />
|
||||
<Compile Include="Classes\MediaData.cs" />
|
||||
<Compile Include="Classes\RPC\DiscordRpc.cs" />
|
||||
<Compile Include="Classes\RPC\DiscordRpcHelper.cs" />
|
||||
<Compile Include="Classes\RPC\RpcWrapper.cs" />
|
||||
<Compile Include="Classes\MediaData.cs" />
|
||||
<Compile Include="Dialogs\LoginDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -57,6 +57,12 @@
|
|||
this.btnDelete = new System.Windows.Forms.Button();
|
||||
this.lbxJobs = new System.Windows.Forms.ListBox();
|
||||
this.tmrRefreshProgress = new System.Windows.Forms.Timer(this.components);
|
||||
this.lbStatus = new System.Windows.Forms.ToolStripDropDownButton();
|
||||
this.onlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.doNotDenyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.doNotDisturbToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.invisibleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tmrTriggerRefresh = new System.Windows.Forms.Timer(this.components);
|
||||
this.pnlSettings.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.edThreadLimit)).BeginInit();
|
||||
this.groupBox1.SuspendLayout();
|
||||
|
@ -77,7 +83,7 @@
|
|||
this.pnlSettings.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.pnlSettings.Location = new System.Drawing.Point(0, 0);
|
||||
this.pnlSettings.Name = "pnlSettings";
|
||||
this.pnlSettings.Size = new System.Drawing.Size(553, 93);
|
||||
this.pnlSettings.Size = new System.Drawing.Size(690, 93);
|
||||
this.pnlSettings.TabIndex = 0;
|
||||
this.pnlSettings.TabStop = false;
|
||||
this.pnlSettings.Text = "Settings";
|
||||
|
@ -113,7 +119,7 @@
|
|||
//
|
||||
this.cbSkipExisting.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cbSkipExisting.AutoSize = true;
|
||||
this.cbSkipExisting.Location = new System.Drawing.Point(447, 42);
|
||||
this.cbSkipExisting.Location = new System.Drawing.Point(584, 42);
|
||||
this.cbSkipExisting.Name = "cbSkipExisting";
|
||||
this.cbSkipExisting.Size = new System.Drawing.Size(106, 17);
|
||||
this.cbSkipExisting.TabIndex = 5;
|
||||
|
@ -127,7 +133,7 @@
|
|||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.edNameScheme.Location = new System.Drawing.Point(113, 39);
|
||||
this.edNameScheme.Name = "edNameScheme";
|
||||
this.edNameScheme.Size = new System.Drawing.Size(328, 20);
|
||||
this.edNameScheme.Size = new System.Drawing.Size(465, 20);
|
||||
this.edNameScheme.TabIndex = 4;
|
||||
this.edNameScheme.TextChanged += new System.EventHandler(this.DoSomethingChanged);
|
||||
//
|
||||
|
@ -143,7 +149,7 @@
|
|||
// btnSearchFolders
|
||||
//
|
||||
this.btnSearchFolders.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnSearchFolders.Location = new System.Drawing.Point(522, 11);
|
||||
this.btnSearchFolders.Location = new System.Drawing.Point(659, 11);
|
||||
this.btnSearchFolders.Name = "btnSearchFolders";
|
||||
this.btnSearchFolders.Size = new System.Drawing.Size(25, 23);
|
||||
this.btnSearchFolders.TabIndex = 2;
|
||||
|
@ -157,7 +163,7 @@
|
|||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.edOperatingFolder.Location = new System.Drawing.Point(113, 13);
|
||||
this.edOperatingFolder.Name = "edOperatingFolder";
|
||||
this.edOperatingFolder.Size = new System.Drawing.Size(403, 20);
|
||||
this.edOperatingFolder.Size = new System.Drawing.Size(540, 20);
|
||||
this.edOperatingFolder.TabIndex = 1;
|
||||
this.edOperatingFolder.TextChanged += new System.EventHandler(this.DoSomethingChanged);
|
||||
//
|
||||
|
@ -180,7 +186,7 @@
|
|||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.groupBox1.Location = new System.Drawing.Point(0, 93);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(553, 57);
|
||||
this.groupBox1.Size = new System.Drawing.Size(690, 57);
|
||||
this.groupBox1.TabIndex = 1;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Add a job";
|
||||
|
@ -188,7 +194,7 @@
|
|||
// btnAddJob
|
||||
//
|
||||
this.btnAddJob.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnAddJob.Location = new System.Drawing.Point(481, 19);
|
||||
this.btnAddJob.Location = new System.Drawing.Point(618, 19);
|
||||
this.btnAddJob.Name = "btnAddJob";
|
||||
this.btnAddJob.Size = new System.Drawing.Size(66, 23);
|
||||
this.btnAddJob.TabIndex = 4;
|
||||
|
@ -203,7 +209,7 @@
|
|||
this.cbChannel.FormattingEnabled = true;
|
||||
this.cbChannel.Location = new System.Drawing.Point(294, 19);
|
||||
this.cbChannel.Name = "cbChannel";
|
||||
this.cbChannel.Size = new System.Drawing.Size(181, 21);
|
||||
this.cbChannel.Size = new System.Drawing.Size(318, 21);
|
||||
this.cbChannel.TabIndex = 3;
|
||||
//
|
||||
// lbChannel
|
||||
|
@ -236,14 +242,15 @@
|
|||
// statusStrip
|
||||
//
|
||||
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.lbStatus,
|
||||
this.pgbProgress,
|
||||
this.lbProgress,
|
||||
this.lblVersionPlaceholder,
|
||||
this.lbVersion,
|
||||
this.btnDropDown});
|
||||
this.statusStrip.Location = new System.Drawing.Point(0, 311);
|
||||
this.statusStrip.Location = new System.Drawing.Point(0, 393);
|
||||
this.statusStrip.Name = "statusStrip";
|
||||
this.statusStrip.Size = new System.Drawing.Size(553, 22);
|
||||
this.statusStrip.Size = new System.Drawing.Size(690, 22);
|
||||
this.statusStrip.TabIndex = 2;
|
||||
this.statusStrip.Text = "statusStrip1";
|
||||
//
|
||||
|
@ -260,7 +267,7 @@
|
|||
// lblVersionPlaceholder
|
||||
//
|
||||
this.lblVersionPlaceholder.Name = "lblVersionPlaceholder";
|
||||
this.lblVersionPlaceholder.Size = new System.Drawing.Size(302, 17);
|
||||
this.lblVersionPlaceholder.Size = new System.Drawing.Size(426, 17);
|
||||
this.lblVersionPlaceholder.Spring = true;
|
||||
//
|
||||
// lbVersion
|
||||
|
@ -301,7 +308,7 @@
|
|||
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.groupBox2.Location = new System.Drawing.Point(0, 150);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(553, 161);
|
||||
this.groupBox2.Size = new System.Drawing.Size(690, 243);
|
||||
this.groupBox2.TabIndex = 3;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Jobs";
|
||||
|
@ -309,9 +316,9 @@
|
|||
// btnDelete
|
||||
//
|
||||
this.btnDelete.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.btnDelete.Location = new System.Drawing.Point(3, 135);
|
||||
this.btnDelete.Location = new System.Drawing.Point(3, 217);
|
||||
this.btnDelete.Name = "btnDelete";
|
||||
this.btnDelete.Size = new System.Drawing.Size(547, 23);
|
||||
this.btnDelete.Size = new System.Drawing.Size(684, 23);
|
||||
this.btnDelete.TabIndex = 1;
|
||||
this.btnDelete.Text = "Delete selected";
|
||||
this.btnDelete.UseVisualStyleBackColor = true;
|
||||
|
@ -325,7 +332,7 @@
|
|||
this.lbxJobs.FormattingEnabled = true;
|
||||
this.lbxJobs.Location = new System.Drawing.Point(6, 19);
|
||||
this.lbxJobs.Name = "lbxJobs";
|
||||
this.lbxJobs.Size = new System.Drawing.Size(541, 108);
|
||||
this.lbxJobs.Size = new System.Drawing.Size(678, 186);
|
||||
this.lbxJobs.TabIndex = 0;
|
||||
//
|
||||
// tmrRefreshProgress
|
||||
|
@ -334,11 +341,55 @@
|
|||
this.tmrRefreshProgress.Interval = 500;
|
||||
this.tmrRefreshProgress.Tick += new System.EventHandler(this.tmrRefreshProgress_Tick);
|
||||
//
|
||||
// lbStatus
|
||||
//
|
||||
this.lbStatus.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.invisibleToolStripMenuItem,
|
||||
this.doNotDisturbToolStripMenuItem,
|
||||
this.doNotDenyToolStripMenuItem,
|
||||
this.onlineToolStripMenuItem});
|
||||
this.lbStatus.Name = "lbStatus";
|
||||
this.lbStatus.Size = new System.Drawing.Size(13, 20);
|
||||
this.lbStatus.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.toolStripDropDownButton1_DropDownItemClicked);
|
||||
//
|
||||
// onlineToolStripMenuItem
|
||||
//
|
||||
this.onlineToolStripMenuItem.Name = "onlineToolStripMenuItem";
|
||||
this.onlineToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.onlineToolStripMenuItem.Tag = "0";
|
||||
this.onlineToolStripMenuItem.Text = "Online";
|
||||
//
|
||||
// doNotDenyToolStripMenuItem
|
||||
//
|
||||
this.doNotDenyToolStripMenuItem.Name = "doNotDenyToolStripMenuItem";
|
||||
this.doNotDenyToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.doNotDenyToolStripMenuItem.Tag = "1";
|
||||
this.doNotDenyToolStripMenuItem.Text = "Idle";
|
||||
//
|
||||
// doNotDisturbToolStripMenuItem
|
||||
//
|
||||
this.doNotDisturbToolStripMenuItem.Name = "doNotDisturbToolStripMenuItem";
|
||||
this.doNotDisturbToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.doNotDisturbToolStripMenuItem.Tag = "2";
|
||||
this.doNotDisturbToolStripMenuItem.Text = "Do not disturb";
|
||||
//
|
||||
// invisibleToolStripMenuItem
|
||||
//
|
||||
this.invisibleToolStripMenuItem.Name = "invisibleToolStripMenuItem";
|
||||
this.invisibleToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.invisibleToolStripMenuItem.Tag = "3";
|
||||
this.invisibleToolStripMenuItem.Text = "Invisible";
|
||||
//
|
||||
// tmrTriggerRefresh
|
||||
//
|
||||
this.tmrTriggerRefresh.Interval = 5000;
|
||||
this.tmrTriggerRefresh.Tick += new System.EventHandler(this.tmrTriggerRefresh_Tick);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(553, 333);
|
||||
this.ClientSize = new System.Drawing.Size(690, 415);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.statusStrip);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
|
@ -391,5 +442,11 @@
|
|||
private System.Windows.Forms.ToolStripSplitButton btnDropDown;
|
||||
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem visitGithubToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripDropDownButton lbStatus;
|
||||
private System.Windows.Forms.ToolStripMenuItem invisibleToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem doNotDisturbToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem doNotDenyToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem onlineToolStripMenuItem;
|
||||
private System.Windows.Forms.Timer tmrTriggerRefresh;
|
||||
}
|
||||
}
|
|
@ -2,18 +2,30 @@
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using DML.AppCore.Classes;
|
||||
using DML.Application.Classes;
|
||||
using DML.Application.Classes.RPC;
|
||||
using DML.Client;
|
||||
using static SweetLib.Utils.Logger.Logger;
|
||||
|
||||
namespace DML.Application
|
||||
{
|
||||
enum OnlineState
|
||||
{
|
||||
Online,
|
||||
Idle,
|
||||
DoNotDisturb,
|
||||
Invisible
|
||||
}
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private bool IsInitialized { get; set; } = false;
|
||||
private DiscordRpc.RichPresence Presence { get; }
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -62,6 +74,8 @@ namespace DML.Application
|
|||
$"{FindServerById(job.GuildId)?.Name}:{FindChannelById(FindServerById(job.GuildId), job.ChannelId)?.Name}");
|
||||
}
|
||||
lbxJobs.SelectedIndex = oldIndex;
|
||||
|
||||
lbStatus.Text = DMLClient.Client.CurrentUser.Status.ToString();
|
||||
}
|
||||
|
||||
private void DoSomethingChanged(object sender, System.EventArgs e)
|
||||
|
@ -237,6 +251,18 @@ namespace DML.Application
|
|||
pgbProgress.Value = progress;
|
||||
|
||||
lbProgress.Text = $"Scanned: {scanned} Downloaded: {done} Open: {totalAttachments - done}";
|
||||
|
||||
if (Core.Settings.UseRPC)
|
||||
{
|
||||
Core.RpcPresence.details = "Downloading media files";
|
||||
Core.RpcPresence.state = $"{done} / {totalAttachments} ({pgbProgress.Value}%)";
|
||||
Core.RpcPresence.largeImageKey = "main";
|
||||
Core.RpcPresence.largeImageText = "Visit discordmedialoader.net";
|
||||
Core.RpcPresence.smallImageKey = "author";
|
||||
Core.RpcPresence.smallImageText = "Made by Serraniel";
|
||||
|
||||
Core.RpcUpdatePresence();
|
||||
}
|
||||
}
|
||||
|
||||
private void aboutToolStripMenuItem_Click(object sender, System.EventArgs e)
|
||||
|
@ -248,5 +274,35 @@ namespace DML.Application
|
|||
{
|
||||
Process.Start("https://github.com/Serraniel/DiscordMediaLoader/");
|
||||
}
|
||||
|
||||
private async void toolStripDropDownButton1_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
OnlineState state = (OnlineState)Convert.ToInt32(e.ClickedItem.Tag);
|
||||
|
||||
lbStatus.Text = state.ToString();
|
||||
tmrTriggerRefresh.Start();
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case OnlineState.Online:
|
||||
await DMLClient.Client.SetStatusAsync(UserStatus.Online);
|
||||
break;
|
||||
case OnlineState.Idle:
|
||||
await DMLClient.Client.SetStatusAsync(UserStatus.Idle);
|
||||
break;
|
||||
case OnlineState.DoNotDisturb:
|
||||
await DMLClient.Client.SetStatusAsync(UserStatus.DoNotDisturb);
|
||||
break;
|
||||
case OnlineState.Invisible:
|
||||
await DMLClient.Client.SetStatusAsync(UserStatus.Invisible);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void tmrTriggerRefresh_Tick(object sender, EventArgs e)
|
||||
{
|
||||
lbStatus.Text = DMLClient.Client.CurrentUser.Status.ToString();
|
||||
tmrTriggerRefresh.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,6 +123,9 @@
|
|||
<metadata name="tmrRefreshProgress.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>126, 17</value>
|
||||
</metadata>
|
||||
<metadata name="tmrTriggerRefresh.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>284, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
|
|
@ -31,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("1.0.2.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.2.0")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Discord_Media_Loader
|
|||
|
||||
private async void FrmSplash_Shown(object sender, EventArgs e)
|
||||
{
|
||||
#if !DEBUG
|
||||
UseWaitCursor = true;
|
||||
try
|
||||
{
|
||||
|
@ -52,6 +53,7 @@ namespace Discord_Media_Loader
|
|||
{
|
||||
UseWaitCursor = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
|
BIN
Discord Media Loader/bin/Debug/discord-rpc-win32.dll
Normal file
BIN
Discord Media Loader/bin/Debug/discord-rpc-win32.dll
Normal file
Binary file not shown.
Loading…
Reference in a new issue