Skip to content

Commit

Permalink
Modified the 'Netplay Server Settings' module to be a datagrid, enabl…
Browse files Browse the repository at this point in the history
…ing as many custom servers as needed - #66
  • Loading branch information
Asnivor committed Feb 16, 2017
1 parent 00bffb4 commit 3e66bd7
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 279 deletions.
22 changes: 22 additions & 0 deletions MedLaunch.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,51 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6B1B4A85-5A13-4A5D-B551-1AC97CC53D38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B1B4A85-5A13-4A5D-B551-1AC97CC53D38}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B1B4A85-5A13-4A5D-B551-1AC97CC53D38}.Debug|x86.ActiveCfg = Debug|x86
{6B1B4A85-5A13-4A5D-B551-1AC97CC53D38}.Debug|x86.Build.0 = Debug|x86
{6B1B4A85-5A13-4A5D-B551-1AC97CC53D38}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B1B4A85-5A13-4A5D-B551-1AC97CC53D38}.Release|Any CPU.Build.0 = Release|Any CPU
{6B1B4A85-5A13-4A5D-B551-1AC97CC53D38}.Release|x86.ActiveCfg = Release|x86
{6B1B4A85-5A13-4A5D-B551-1AC97CC53D38}.Release|x86.Build.0 = Release|x86
{2E332847-6DF3-4BF4-92C2-42A5C6359CC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E332847-6DF3-4BF4-92C2-42A5C6359CC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E332847-6DF3-4BF4-92C2-42A5C6359CC1}.Debug|x86.ActiveCfg = Debug|Any CPU
{2E332847-6DF3-4BF4-92C2-42A5C6359CC1}.Debug|x86.Build.0 = Debug|Any CPU
{2E332847-6DF3-4BF4-92C2-42A5C6359CC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E332847-6DF3-4BF4-92C2-42A5C6359CC1}.Release|Any CPU.Build.0 = Release|Any CPU
{2E332847-6DF3-4BF4-92C2-42A5C6359CC1}.Release|x86.ActiveCfg = Release|Any CPU
{2E332847-6DF3-4BF4-92C2-42A5C6359CC1}.Release|x86.Build.0 = Release|Any CPU
{554A0A91-F3CD-4800-8A19-1575FB1CA8D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{554A0A91-F3CD-4800-8A19-1575FB1CA8D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{554A0A91-F3CD-4800-8A19-1575FB1CA8D1}.Debug|x86.ActiveCfg = Debug|Any CPU
{554A0A91-F3CD-4800-8A19-1575FB1CA8D1}.Debug|x86.Build.0 = Debug|Any CPU
{554A0A91-F3CD-4800-8A19-1575FB1CA8D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{554A0A91-F3CD-4800-8A19-1575FB1CA8D1}.Release|Any CPU.Build.0 = Release|Any CPU
{554A0A91-F3CD-4800-8A19-1575FB1CA8D1}.Release|x86.ActiveCfg = Release|Any CPU
{554A0A91-F3CD-4800-8A19-1575FB1CA8D1}.Release|x86.Build.0 = Release|Any CPU
{21B251C5-8C12-43CD-B256-AD55CB5D4B57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21B251C5-8C12-43CD-B256-AD55CB5D4B57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21B251C5-8C12-43CD-B256-AD55CB5D4B57}.Debug|x86.ActiveCfg = Debug|Any CPU
{21B251C5-8C12-43CD-B256-AD55CB5D4B57}.Debug|x86.Build.0 = Debug|Any CPU
{21B251C5-8C12-43CD-B256-AD55CB5D4B57}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21B251C5-8C12-43CD-B256-AD55CB5D4B57}.Release|Any CPU.Build.0 = Release|Any CPU
{21B251C5-8C12-43CD-B256-AD55CB5D4B57}.Release|x86.ActiveCfg = Release|Any CPU
{21B251C5-8C12-43CD-B256-AD55CB5D4B57}.Release|x86.Build.0 = Release|Any CPU
{11D05113-3DD4-4228-84F1-C81F12A2F89C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11D05113-3DD4-4228-84F1-C81F12A2F89C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11D05113-3DD4-4228-84F1-C81F12A2F89C}.Debug|x86.ActiveCfg = Debug|Any CPU
{11D05113-3DD4-4228-84F1-C81F12A2F89C}.Debug|x86.Build.0 = Debug|Any CPU
{11D05113-3DD4-4228-84F1-C81F12A2F89C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11D05113-3DD4-4228-84F1-C81F12A2F89C}.Release|Any CPU.Build.0 = Release|Any CPU
{11D05113-3DD4-4228-84F1-C81F12A2F89C}.Release|x86.ActiveCfg = Release|Any CPU
{11D05113-3DD4-4228-84F1-C81F12A2F89C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion MedLaunch/Classes/ConfigImport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ConfigImport()
// populate config info from database
_Paths = Paths.GetPaths();
_ConfigNetplaySettings = ConfigNetplaySettings.GetNetplay();
_ConfigServerSettings = ConfigServerSettings.GetServer(100);
_ConfigServerSettings = new ConfigServerSettings(); // ConfigServerSettings.GetServer(100);

_ConfigBaseSettings = ConfigBaseSettings.GetConfig(2000000000);

Expand Down
62 changes: 61 additions & 1 deletion MedLaunch/Classes/VisualHandlers/SettingsVisualHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using MedLaunch.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -148,6 +149,54 @@ where b.Name.Contains(brdName)
}
}

public static void PopulateServers(DataGrid lvServers)
{
// get all servers
var servers = ConfigServerSettings.GetServers();

// get selected server id
GlobalSettings gs = GlobalSettings.GetGlobals();
int sid = gs.serverSelected.Value;

List<ServersListView> list = new List<ServersListView>();

// populate list
foreach (var s in servers)
{
ServersListView srv = new ServersListView();
srv.ID = s.ConfigServerId;
srv.Name = s.ConfigServerDesc;
srv.Host = s.netplay__host;
srv.Port = s.netplay__port.Value;
srv.Password = s.netplay__password;
srv.Gamekey = s.netplay__gamekey;

if (sid == srv.ID)
{
srv.Selected = true;
}
else
{
srv.Selected = false;
}

list.Add(srv);
}

lvServers.ItemsSource = list;
}

public static void ServerSettingsInitialButtonHide()
{
MainWindow mw = Application.Current.Windows.OfType<MainWindow>().FirstOrDefault();
Button btnServersSelect = (Button)mw.FindName("btnServersSelect");
Button btnServersDelete = (Button)mw.FindName("btnServersDelete");
Button btnServersSaveEdit = (Button)mw.FindName("btnServersSaveEdit");
btnServersSelect.Visibility = Visibility.Collapsed;
btnServersDelete.Visibility = Visibility.Collapsed;
btnServersSaveEdit.Visibility = Visibility.Collapsed;
}


// Properties
public MainWindow MWindow { get; set; }
Expand All @@ -162,4 +211,15 @@ where b.Name.Contains(brdName)
public List<Border> Library { get; set; }
public List<Border> ScrapingSettings { get; set; }
}

public class ServersListView
{
public int ID { get; set; }
public string Name { get; set; }
public string Host { get; set; }
public int Port { get; set; }
public string Password { get; set; }
public string Gamekey { get; set; }
public bool Selected { get; set; }
}
}
62 changes: 37 additions & 25 deletions MedLaunch/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10659,9 +10659,8 @@


<StackPanel x:Name="spServerSettings" Grid.Column="2">
<Grid Margin="0">


<Grid Margin="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
Expand All @@ -10682,50 +10681,63 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!--
<ComboBox x:Name="cbServers" Grid.ColumnSpan="2" Margin="20" DataContext="ServersDataObject" ItemsSource="{Binding ListOfServers}"></ComboBox>
-->

<RadioButton Name="rbSrv01" Margin="10" GroupName="Servers" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Checked="rbSrv01_Checked" />
<RadioButton Name="rbSrv02" Margin="10" GroupName="Servers" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2" Checked="rbSrv02_Checked" />
<RadioButton Name="rbSrv03" Margin="10" GroupName="Servers" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="3" Checked="rbSrv03_Checked" />
<RadioButton Name="rbSrv04" Margin="10" GroupName="Servers" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="4" Checked="rbSrv04_Checked" />
<RadioButton Name="rbSrvCustom" Margin="10" GroupName="Servers" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="5" Checked="rbSrvCustom_Checked" Unchecked="rbSrvCustom_UnChecked" Content="Custom:" />
<DataGrid Grid.ColumnSpan="2" Grid.Row="0" Margin="5" Name="lvServers" MaxHeight="275" IsReadOnly="True" SelectionMode="Single" AutoGenerateColumns="False"
SelectionChanged="lvServers_SelectionChanged">
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="Selected" Binding="{Binding Selected}" />
<DataGridTextColumn Header="ID" Binding="{Binding ID}" />
<DataGridTextColumn Header="Name" Binding="{Binding Name}" />
<DataGridTextColumn Header="Host" Binding="{Binding Host}" />
<DataGridTextColumn Header="Port" Binding="{Binding Port}" />
<DataGridTextColumn Header="Password" Binding="{Binding Password}" />
<DataGridTextColumn Header="Gamekey" Binding="{Binding Gamekey}" />
</DataGrid.Columns>
</DataGrid>

<UniformGrid Columns="4" Grid.ColumnSpan="2" Grid.Row="1">
<Button Name="btnServersSelect" Padding="5" Margin="5" Click="btnServersSelect_Click">
Use Selected Server
</Button>

<Button Name="btnServersAdd" Padding="5" Margin="5" Click="btnServersAdd_Click">
Add Server
</Button>

<Button Name="btnServersSaveEdit" Padding="5" Margin="5" Click="btnServersSaveEdit_Click">
Save Edit
</Button>

<Button Name="btnServersDelete" Padding="5" Margin="5" Click="btnServersDelete_Click">
Delete Selected Server
</Button>
</UniformGrid>

<Label Name="lblServerDesc" Grid.Row="6" Grid.Column="0" VerticalContentAlignment="Center" VerticalAlignment="Center">Server Description</Label>
<TextBox x:Name="tbServerDesc" Grid.Row="6" Grid.Column="1" Margin="10" TextChanged="tbSettings_Server_TextChanged" />
<TextBox x:Name="tbServerDesc" Grid.Row="6" Grid.Column="1" Margin="10"/>

<Label Name="lblHostname" Grid.Row="7" Grid.Column="0" VerticalContentAlignment="Center" VerticalAlignment="Center">Host/IP</Label>
<TextBox x:Name="tbHostname" Grid.Row="7" Grid.Column="1" Margin="10" TextChanged="tbSettings_Server_TextChanged" />
<TextBox x:Name="tbHostname" Grid.Row="7" Grid.Column="1" Margin="10" />

<DockPanel Grid.ColumnSpan="2" Grid.Row="8" VerticalAlignment="Center" Margin="10">
<Label Name="lblServerPort" DockPanel.Dock="Top" VerticalAlignment="Top" HorizontalAlignment="Center">Port</Label>
<TextBox Name="lblServerPortTxt" Text="{Binding ElementName=slServerPort, Path=Value, UpdateSourceTrigger=PropertyChanged}" DockPanel.Dock="Right" TextAlignment="Right" Width="40" TextChanged="tbSettings_Server_TextChanged" />
<TextBox Name="lblServerPortTxt" Text="{Binding ElementName=slServerPort, Path=Value, UpdateSourceTrigger=PropertyChanged}" DockPanel.Dock="Right" TextAlignment="Right" Width="40" />
<Slider Maximum="65535" Minimum="1" TickPlacement="BottomRight" TickFrequency="1" IsSnapToTickEnabled="True"
Name="slServerPort" />
</DockPanel>

<Label Name="lblPassword" Grid.Row="9" Grid.Column="0" VerticalContentAlignment="Center" VerticalAlignment="Center">Password</Label>
<TextBox x:Name="tbPassword" Grid.Row="9" Grid.Column="1" Margin="10" TextChanged="tbSettings_Server_TextChanged" />
<TextBox x:Name="tbPassword" Grid.Row="9" Grid.Column="1" Margin="10" />

<Label Name="lblGamekey" Grid.Row="10" Grid.Column="0" VerticalContentAlignment="Center" VerticalAlignment="Center">GameKey</Label>
<TextBox x:Name="tbGameKey" Grid.Row="10" Grid.Column="1" Margin="10" TextChanged="tbSettings_Server_TextChanged" />

<TextBox x:Name="tbGameKey" Grid.Row="10" Grid.Column="1" Margin="10" />





<StackPanel Grid.ColumnSpan="2" Grid.Row="11">
<Button x:Name="btnServerSaveChanges" Content="Save Changes" Background="{DynamicResource AccentColorBrush}" Click="btnServerSaveChanges_Click" ></Button>
<Button x:Name="btnServerCancelChanges" Content="Cancel Changes" Background="Red" Click="btnServerCancelChanges_Click" ></Button>
<Label x:Name="lblServerSettingsSave" HorizontalContentAlignment="Center"></Label>
</StackPanel>

</Grid>
</StackPanel>

Expand Down
Loading

0 comments on commit 3e66bd7

Please sign in to comment.