Compare commits

...

10 commits

Author SHA1 Message Date
Serraniel 49b8d4eaa3 Merge branch 'support/1.1' 2018-06-15 19:05:40 +02:00
Serraniel 145a5eb0ca Build 2018-06-15 19:04:32 +02:00
Serraniel 033cb203b0 Revert "Merge branch 'bugfix/UI-improvments' into support/1.1"
This reverts commit 33474c2dab, reversing
changes made to 6b2fc74a9e.
2018-06-15 18:59:34 +02:00
Serraniel 33474c2dab Merge branch 'bugfix/UI-improvments' into support/1.1
* bugfix/UI-improvments:
  Changed combobox style of guild and channel selection to suggest elements from its data lists
2018-06-15 18:52:59 +02:00
Serraniel 6b2fc74a9e Merge branch 'bugfix/18-multiple-channels-same-name' into support/1.1
* bugfix/18-multiple-channels-same-name:
  Switched joblist to IdentifiedString objects
  Added implementation for guild and channel selection with identified strings
  Added class for identified strings
2018-06-15 18:52:44 +02:00
Serraniel 8c7253dfcc Changed combobox style of guild and channel selection to suggest elements from its data lists 2018-06-15 18:51:16 +02:00
Serraniel 5c93684164 Switched joblist to IdentifiedString objects 2018-06-15 18:46:44 +02:00
Serraniel 5e940c09bd Added implementation for guild and channel selection with identified strings 2018-06-15 18:33:00 +02:00
Serraniel 801a0da615 Added class for identified strings 2018-06-15 18:32:18 +02:00
Serraniel 786c5eea87 Merge branch 'support/1.1'
* support/1.1:
  Build
  Fixed an error which issued an exception on startup if a guild is temporary not available
  Fixed nuget referencing to SweetLib and maintained code so it will compile with current SweetLib Version
2018-06-12 18:15:11 +02:00
4 changed files with 45 additions and 29 deletions

View file

@ -179,6 +179,7 @@
<Compile Include="FrmInternalSplash.Designer.cs"> <Compile Include="FrmInternalSplash.Designer.cs">
<DependentUpon>FrmInternalSplash.cs</DependentUpon> <DependentUpon>FrmInternalSplash.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Helper\IdentifiedString.cs" />
<Compile Include="MainForm.cs"> <Compile Include="MainForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>

View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DML.Application.Helper
{
internal class IdentifiedString<T>
{
internal T Id { get; set; }
internal string Caption { get; set; }
internal IdentifiedString(T id, string caption)
{
Id = id;
Caption = caption;
}
public override string ToString() => Caption;
}
}

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -8,7 +9,9 @@ using Discord;
using Discord.WebSocket; using Discord.WebSocket;
using DML.AppCore.Classes; using DML.AppCore.Classes;
using DML.Application.Classes; using DML.Application.Classes;
using DML.Application.Helper;
using DML.Client; using DML.Client;
using static DML.Client.DMLClient;
using static SweetLib.Utils.Logger.Logger; using static SweetLib.Utils.Logger.Logger;
namespace DML.Application namespace DML.Application
@ -57,7 +60,9 @@ namespace DML.Application
if (cbGuild.Items.Count == 0) if (cbGuild.Items.Count == 0)
{ {
Trace("Adding guilds to component..."); Trace("Adding guilds to component...");
cbGuild.Items.AddRange(DMLClient.Client.Guilds.Where(g => g.Name != null).OrderBy(g => g.Name).Select(g => g.Name).ToArray());
cbGuild.Items.AddRange(DMLClient.Client.Guilds.Where(g => g.Name != null).OrderBy(g => g.Name).Select(g => new IdentifiedString<ulong>(g.Id, g.Name)).ToArray());
cbGuild.SelectedIndex = 0; cbGuild.SelectedIndex = 0;
Trace("Guild component initialized."); Trace("Guild component initialized.");
} }
@ -67,8 +72,7 @@ namespace DML.Application
lbxJobs.Items.Clear(); lbxJobs.Items.Clear();
foreach (var job in Core.Scheduler.JobList) foreach (var job in Core.Scheduler.JobList)
{ {
lbxJobs.Items.Add( lbxJobs.Items.Add(new IdentifiedString<int>(job.Id, $"{FindServerById(job.GuildId)?.Name}:{FindChannelById(FindServerById(job.GuildId), job.ChannelId)?.Name}"));
$"{FindServerById(job.GuildId)?.Name}:{FindChannelById(FindServerById(job.GuildId), job.ChannelId)?.Name}");
} }
lbxJobs.SelectedIndex = oldIndex; lbxJobs.SelectedIndex = oldIndex;
@ -153,7 +157,7 @@ namespace DML.Application
UseWaitCursor = true; UseWaitCursor = true;
try try
{ {
var guild = FindServerByName(cbGuild.Text); var guild = FindServerById(((IdentifiedString<ulong>)cbGuild.SelectedItem).Id);
if (guild != null) if (guild != null)
{ {
@ -161,7 +165,9 @@ namespace DML.Application
cbChannel.Items.Clear(); cbChannel.Items.Clear();
Trace("Adding new channels..."); Trace("Adding new channels...");
cbChannel.Items.AddRange(guild.TextChannels.OrderBy(c => c.Position).Select(c => c.Name).ToArray());
cbChannel.Items.AddRange(guild.TextChannels.OrderBy(c => c.Position).Select(c => new IdentifiedString<ulong>(c.Id, c.Name)).ToArray());
Trace($"Added {cbChannel.Items.Count} channels."); Trace($"Added {cbChannel.Items.Count} channels.");
cbChannel.SelectedIndex = 0; cbChannel.SelectedIndex = 0;
@ -183,8 +189,8 @@ namespace DML.Application
{ {
var job = new Job var job = new Job
{ {
GuildId = FindServerByName(cbGuild.Text).Id, GuildId = ((IdentifiedString<ulong>)cbGuild.SelectedItem).Id,
ChannelId = FindChannelByName(FindServerByName(cbGuild.Text), cbChannel.Text).Id ChannelId = ((IdentifiedString<ulong>)cbChannel.SelectedItem).Id
}; };
if (!(from j in Core.Scheduler.JobList if (!(from j in Core.Scheduler.JobList
@ -208,28 +214,15 @@ namespace DML.Application
MessageBox.Show("No job has been seleted.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("No job has been seleted.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
var jobNameData = lbxJobs.SelectedItem.ToString().Split(':'); var jobId = ((IdentifiedString<int>)lbxJobs.SelectedItem).Id;
var guildName = ""; var job = Core.Scheduler.JobList.FirstOrDefault(j => j.Id == jobId);
for (var i = 0; i < jobNameData.Length - 1; i++) if (job != null)
guildName += jobNameData[i] + ":";
guildName = guildName.Substring(0, guildName.Length - 1);
var channelName = jobNameData[jobNameData.Length - 1];
var guild = FindServerByName(guildName);
var channel = FindChannelByName(guild, channelName);
foreach (var job in Core.Scheduler.JobList)
{
if (job.GuildId == guild.Id && job.ChannelId == channel.Id)
{ {
Core.Scheduler.JobList.Remove(job); Core.Scheduler.JobList.Remove(job);
Core.Scheduler.RunningJobs.Remove(job.Id); Core.Scheduler.RunningJobs.Remove(job.Id);
job.Stop(); job.Stop();
job.Delete(); job.Delete();
break;
}
} }
lbxJobs.SelectedIndex = -1; lbxJobs.SelectedIndex = -1;

View file

@ -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("1.1.1.0")] [assembly: AssemblyVersion("1.1.2.0")]
[assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyFileVersion("1.1.2.0")]