Skip to content

Commit

Permalink
Remove Bulk Launcher tab
Browse files Browse the repository at this point in the history
This tab is now in a separate branch.
  • Loading branch information
Mag-nus committed Jul 28, 2019
1 parent 44cce60 commit dbee8be
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 194 deletions.
Binary file removed Docs/Images/Bulk Launcher.png
Binary file not shown.
Binary file modified Docs/Images/Launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Docs/Images/Options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@

![Launcher](/Docs/Images/Launcher.png?raw=true)

![Launcher](/Docs/Images/Bulk%20Launcher.png?raw=true)

![Launcher](/Docs/Images/Options.png?raw=true)
14 changes: 1 addition & 13 deletions Source/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,8 @@
<setting name="InjectDecal" serializeAs="String">
<value>True</value>
</setting>
<setting name="BulkLaunchQuantity" serializeAs="String">
<value>1</value>
</setting>
<setting name="BulkLaunchStartIndex" serializeAs="String">
<value>0</value>
</setting>
<setting name="BulkLaunchUserNamePrefix" serializeAs="String">
<value>test_</value>
</setting>
<setting name="IntervalBetweenLaunches" serializeAs="String">
<value>2</value>
<value>6</value>
</setting>
<setting name="SelectedServer" serializeAs="String">
<value />
Expand All @@ -40,9 +31,6 @@
<setting name="WindowPositionTop" serializeAs="String">
<value>0</value>
</setting>
<setting name="BulkLaunchPassword" serializeAs="String">
<value />
</setting>
</Mag_ACClientLauncher.Properties.Settings>
</userSettings>
</configuration>
15 changes: 0 additions & 15 deletions Source/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,6 @@
<Button x:Name="cmdLaunchAll" Content="Launch All" HorizontalAlignment="Left" Margin="10,0,0,10" VerticalAlignment="Bottom" Width="85" Click="cmdLaunchAll_Click" HorizontalContentAlignment="Center"/>
</Grid>
</TabItem>
<TabItem Header="Bulk Launcher" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid Background="#FFE5E5E5">
<ComboBox x:Name="cboBulkLauncherServerList" Margin="10,10,114,0" VerticalAlignment="Top" SelectionChanged="cboBulkLauncherServerList_SelectionChanged"/>
<Label Content="Quantity to launch" HorizontalAlignment="Left" Margin="10,34,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtBulkLaunchQuantity" Margin="163,37,0,0" TextWrapping="Wrap" Height="23" VerticalAlignment="Top" HorizontalAlignment="Left" Width="53" RenderTransformOrigin="1.927,-3.718" Text="{Binding BulkLaunchQuantity, Mode=TwoWay, Source={x:Static p:Settings.Default}}" MaxLength="5" MaxLines="1"/>
<Label Content="Start launch at index" HorizontalAlignment="Left" Margin="10,62,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtBulkLaunchStartIndex" Margin="163,65,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" Width="53" RenderTransformOrigin="1.927,-3.718" Height="23" VerticalAlignment="Top" Text="{Binding BulkLaunchStartIndex, Mode=TwoWay, Source={x:Static p:Settings.Default}}" MaxLength="5" MaxLines="1"/>
<Label Content="User name prefix" HorizontalAlignment="Left" Margin="10,90,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtBulkLaunchUserNamePrefix" Margin="163,93,0,0" TextWrapping="Wrap" Height="23" VerticalAlignment="Top" HorizontalAlignment="Left" Width="53" RenderTransformOrigin="1.927,-3.718" Text="{Binding BulkLaunchUserNamePrefix, Mode=TwoWay, Source={x:Static p:Settings.Default}}" MaxLines="1"/>
<Button x:Name="cmdBulkLaunch" Content="Bulk Launch" Margin="226,95,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Center" RenderTransformOrigin="2.764,0.605" HorizontalAlignment="Left" Width="75" Click="cmdBulkLaunch_Click"/>
<TextBox x:Name="txtBulkLaunchStatus" Margin="10,149,10,10" TextWrapping="Wrap" RenderTransformOrigin="1.927,-3.718" VerticalScrollBarVisibility="Auto" FontSize="10" FontFamily="Consolas"/>
<Label Content="Password" HorizontalAlignment="Left" Margin="10,118,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtBulkLaunchPassword" Margin="163,121,0,0" TextWrapping="Wrap" Height="23" VerticalAlignment="Top" HorizontalAlignment="Left" Width="138" RenderTransformOrigin="1.927,-3.718" Text="{Binding BulkLaunchPassword, Mode=TwoWay, Source={x:Static p:Settings.Default}}" MaxLines="1"/>
</Grid>
</TabItem>
<TabItem Header="Options">
<Grid Background="#FFE5E5E5">
<TextBox x:Name="txtACClientLocation" HorizontalAlignment="Left" Height="23" Margin="10,36,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="300" IsReadOnly="True" Text="{Binding ACClientLocation, Mode=TwoWay, Source={x:Static p:Settings.Default}}" Grid.ColumnSpan="2"/>
Expand Down
102 changes: 1 addition & 101 deletions Source/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
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 @@ -20,17 +19,9 @@ public partial class MainWindow
{
public MainWindow()
{
if (String.IsNullOrWhiteSpace(Properties.Settings.Default.BulkLaunchPassword))
{
// Create a random password if one doesn't exist
var rand = new Random();
for (int i = 0; i < 16; i++)
Properties.Settings.Default.BulkLaunchPassword += Convert.ToChar(rand.Next(97, 122));
}

InitializeComponent();

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

if (Properties.Settings.Default.WindowPositionLeft != 0 && Properties.Settings.Default.WindowPositionTop != 0)
{
Expand Down Expand Up @@ -73,15 +64,12 @@ private void PopulateServerLists()

PopulateServerList(cboLauncherServerList, serversList);

PopulateServerList(cboBulkLauncherServerList, serversList);

cmdEditServer.IsEnabled = (serversList.Count > 0);
cmdDeleteServer.IsEnabled = (serversList.Count > 0);

cmdAddAccounts.IsEnabled = (serversList.Count > 0);

cmdLaunchAll.IsEnabled = (serversList.Count > 0);
cmdBulkLaunch.IsEnabled = (serversList.Count > 0);
}

private void PopulateServerList(ComboBox comboBox, ICollection<Server> servers)
Expand All @@ -107,16 +95,6 @@ private void SelectServer(Guid id)
break;
}
}

foreach (var item in cboBulkLauncherServerList.Items)
{
if (item is Server server && server.Id == id)
{
cboBulkLauncherServerList.SelectedItem = item;

break;
}
}
}

private void SetListAccountsSource(IList<Account> accounts)
Expand Down Expand Up @@ -360,84 +338,6 @@ private async void cmdLaunchAll_Click(object sender, RoutedEventArgs e)
}


// =====================================
// ========== BULK LAUNCH TAB ==========
// =====================================

private void cboBulkLauncherServerList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cboBulkLauncherServerList.SelectedItem is Server server)
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;
}

cmdBulkLaunch.Content = "Cancel";

try
{
if (cboBulkLauncherServerList.SelectedItem is Server server)
{
bulkLaunchCTS = new CancellationTokenSource();

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

private async Task DoBulkLaunch(int launchQuantity, int startIndex, string userNamePrefix, string password, TimeSpan interval, Server server, CancellationToken token)
{
if (String.IsNullOrWhiteSpace(password))
{
MessageBox.Show("Password cannot be empty", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}

for (int i = startIndex; i < (startIndex + launchQuantity); i++)
{
if (token.IsCancellationRequested)
return;

var userName = userNamePrefix + i.ToString("00000");

txtBulkLaunchStatus.Text += $"{DateTime.Now}: Launching user {userName}, connection {(i - startIndex) + 1} of {launchQuantity}" + Environment.NewLine;
txtBulkLaunchStatus.ScrollToEnd();

var account = new Account {UserName = userName, Password = password };

if (!DoLaunch(server, account))
{
txtBulkLaunchStatus.Text += $"{DateTime.Now}: Launching user {userName}, connection {(i - startIndex) + 1} of {launchQuantity} FAILED" + Environment.NewLine;
txtBulkLaunchStatus.ScrollToEnd();
break;
}

if (token.IsCancellationRequested)
return;

await Task.Delay(interval);
}
}


// =================================
// ========== OPTIONS TAB ==========
// =================================
Expand Down
2 changes: 1 addition & 1 deletion Source/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.1")] // Update line 25 in MainWindow.xaml.cs
[assembly: AssemblyFileVersion("1.2")] // Update line 25 in MainWindow.xaml.cs
50 changes: 1 addition & 49 deletions Source/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions Source/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
<Setting Name="InjectDecal" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="BulkLaunchQuantity" Type="System.Int32" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="BulkLaunchStartIndex" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="BulkLaunchUserNamePrefix" Type="System.String" Scope="User">
<Value Profile="(Default)">test_</Value>
</Setting>
<Setting Name="IntervalBetweenLaunches" Type="System.Int32" Scope="User">
<Value Profile="(Default)">2</Value>
<Value Profile="(Default)">6</Value>
</Setting>
<Setting Name="SelectedServer" Type="System.String" Scope="User">
<Value Profile="(Default)" />
Expand All @@ -32,8 +23,5 @@
<Setting Name="WindowPositionTop" Type="System.Double" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="BulkLaunchPassword" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

0 comments on commit dbee8be

Please sign in to comment.