[ADDED] the inlog screen and a data singleton for the client
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Client.Views
|
||||
/// </summary>
|
||||
public partial class GameWindow : Window
|
||||
{
|
||||
|
||||
ClientData data = ClientData.Instance;
|
||||
public GameWindow()
|
||||
{
|
||||
DataContext = new ViewModelGame();
|
||||
@@ -110,7 +110,7 @@ namespace Client.Views
|
||||
*/
|
||||
private void WriteToChat(string message)
|
||||
{
|
||||
string user = "Monkey";
|
||||
string user = data.User.Username;
|
||||
SentMessage.AppendText($"{user}: {message}\n");
|
||||
}
|
||||
}
|
||||
|
||||
29
Client/Views/LoginScreen.xaml
Normal file
29
Client/Views/LoginScreen.xaml
Normal file
@@ -0,0 +1,29 @@
|
||||
<Window x:Class="Client.Views.LoginScreen"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Client.Views"
|
||||
mc:Ignorable="d"
|
||||
Title="LoginScreen" Height="450" Width="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Grid.Row="0" FontSize="40" Content="Welcome to Scrubl.io"/>
|
||||
<Label Grid.Row="1" FontSize="30" Content="Enter a username:"/>
|
||||
<Label Grid.Row="2" FontSize="15" Content="(max amount of characters for the username is 10)"/>
|
||||
|
||||
<TextBox Name="usernameTextbox" Grid.Row="1" Grid.Column="1" MaxLength="10" FontSize="30" VerticalAlignment="Center" HorizontalAlignment="Left" Width="250"/>
|
||||
<Button Content="ENTER" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Width="100" Height="40" Click="Button_EnterUsername"/>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
40
Client/Views/LoginScreen.xaml.cs
Normal file
40
Client/Views/LoginScreen.xaml.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using SharedClientServer;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Client.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for LoginScreen.xaml
|
||||
/// </summary>
|
||||
public partial class LoginScreen : Window
|
||||
{
|
||||
ClientData data = ClientData.Instance;
|
||||
public LoginScreen()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Button_EnterUsername(object sender, RoutedEventArgs e)
|
||||
{
|
||||
User user = new User(usernameTextbox.Text, 0, false);
|
||||
Client client = new Client();
|
||||
|
||||
data.User = user;
|
||||
data.Client = client;
|
||||
|
||||
MainWindow startWindow = new MainWindow();
|
||||
startWindow.Show();
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,13 @@ namespace Client
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
ClientData data = ClientData.Instance;
|
||||
public MainWindow()
|
||||
{
|
||||
this.DataContext = new ViewModel();
|
||||
InitializeComponent();
|
||||
|
||||
usernameTextbox.Text = data.User.Username;
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user