Skip to content

Commit

Permalink
Fix bulk launch cancel, add icon, verison 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mag-nus committed Jan 1, 2019
1 parent 85d9330 commit 2031691
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
Binary file added 2207.ico
Binary file not shown.
7 changes: 6 additions & 1 deletion Mag-ACClientLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>2207.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationFramework" />
<Reference Include="System" />
Expand Down Expand Up @@ -112,6 +115,8 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Resource Include="2207.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
23 changes: 19 additions & 4 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -21,6 +22,8 @@ public MainWindow()
{
InitializeComponent();

Title += " 1.1"; // Update line 55 in AssemblyInfo.cs

if (Properties.Settings.Default.WindowPositionLeft != 0 && Properties.Settings.Default.WindowPositionTop != 0)
{
Left = Properties.Settings.Default.WindowPositionLeft;
Expand Down Expand Up @@ -359,10 +362,18 @@ private void cboBulkLauncherServerList_SelectionChanged(object sender, Selection
SelectServer(server.Id);
}

CancellationTokenSource bulkLaunchCTS;

private async void cmdBulkLaunch_Click(object sender, RoutedEventArgs e)
{
if (cmdBulkLaunch.Content.ToString() == "Cancel")
{
if (bulkLaunchCTS != null)
{
bulkLaunchCTS.Cancel();
bulkLaunchCTS = null;
}

cmdBulkLaunch.Content = "Bulk Launch";
return;
}
Expand All @@ -372,19 +383,23 @@ private async void cmdBulkLaunch_Click(object sender, RoutedEventArgs e)
try
{
if (cboBulkLauncherServerList.SelectedItem is Server server)
await DoBulkLaunch(Properties.Settings.Default.BulkLaunchQuantity, Properties.Settings.Default.BulkLaunchStartIndex, Properties.Settings.Default.BulkLaunchUserNamePrefix, TimeSpan.FromSeconds(Properties.Settings.Default.IntervalBetweenLaunches), server);
{
bulkLaunchCTS = new CancellationTokenSource();

await DoBulkLaunch(Properties.Settings.Default.BulkLaunchQuantity, Properties.Settings.Default.BulkLaunchStartIndex, Properties.Settings.Default.BulkLaunchUserNamePrefix, TimeSpan.FromSeconds(Properties.Settings.Default.IntervalBetweenLaunches), server, bulkLaunchCTS.Token);
}
}
finally
{
cmdBulkLaunch.Content = "Bulk Launch";
}
}

private async Task DoBulkLaunch(int launchQuantity, int startIndex, string userNamePrefix, TimeSpan interval, Server server)
private async Task DoBulkLaunch(int launchQuantity, int startIndex, string userNamePrefix, TimeSpan interval, Server server, CancellationToken token)
{
for (int i = startIndex; i < (startIndex + launchQuantity); i++)
{
if (cmdBulkLaunch.Content.ToString() == "Bulk Launch")
if (token.IsCancellationRequested)
return;

var userName = userNamePrefix + i.ToString("00000");
Expand All @@ -401,7 +416,7 @@ private async Task DoBulkLaunch(int launchQuantity, int startIndex, string userN
break;
}

if (cmdBulkLaunch.Content.ToString() == "Bulk Launch")
if (token.IsCancellationRequested)
return;

await Task.Delay(interval);
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.1")] // Update line 25 in MainWindow.xaml.cs

0 comments on commit 2031691

Please sign in to comment.