[Addition] Added a chatbox function!
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Client
|
|||||||
public int Port = 5555;
|
public int Port = 5555;
|
||||||
public bool Connected = false;
|
public bool Connected = false;
|
||||||
//TODO send login packet to server with ClientServerUtil.createpayload(0x01,dynamic json with username)
|
//TODO send login packet to server with ClientServerUtil.createpayload(0x01,dynamic json with username)
|
||||||
public string username;
|
public string Username { get; }
|
||||||
|
|
||||||
public Client()
|
public Client()
|
||||||
{
|
{
|
||||||
@@ -81,6 +81,7 @@ namespace Client
|
|||||||
string textUsername = combo.Item1;
|
string textUsername = combo.Item1;
|
||||||
string textMsg = combo.Item2;
|
string textMsg = combo.Item2;
|
||||||
//TODO display username and message in chat window
|
//TODO display username and message in chat window
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x03:
|
case 0x03:
|
||||||
|
|||||||
@@ -12,12 +12,10 @@ namespace Client
|
|||||||
private int _numbers;
|
private int _numbers;
|
||||||
private bool _status;
|
private bool _status;
|
||||||
|
|
||||||
|
//Test code
|
||||||
public int Numbers
|
public int Numbers
|
||||||
{
|
{
|
||||||
get
|
get { return _numbers; }
|
||||||
{
|
|
||||||
return _numbers;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ namespace Client
|
|||||||
{
|
{
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ViewModel()
|
public ViewModel()
|
||||||
{
|
{
|
||||||
_model = new Model();
|
_model = new Model();
|
||||||
@@ -63,9 +61,5 @@ namespace Client
|
|||||||
get { return _lobbies; }
|
get { return _lobbies; }
|
||||||
set { _lobbies = value; }
|
set { _lobbies = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
using System;
|
using System.Collections.ObjectModel;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Client.ViewModels
|
namespace Client.ViewModels
|
||||||
{
|
{
|
||||||
class ViewModelGame : INotifyPropertyChanged
|
class ViewModelGame : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="200"/>
|
<ColumnDefinition Width="200"/>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition Width="799"/>
|
||||||
|
<ColumnDefinition Width="200"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
|
||||||
@@ -34,17 +35,22 @@
|
|||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Button Name="CanvasReset" Click="CanvasReset_Click" Grid.Row="0" Grid.Column="1" Margin="890,10,10,10" Content="RESET" />
|
<Button Name="CanvasReset" Click="CanvasReset_Click" Grid.Row="0" Grid.Column="2" Margin="84,10,10,10" Content="RESET"/>
|
||||||
|
|
||||||
<xctk:ColorPicker Name="ClrPcker_Background" SelectedColorChanged="ClrPcker_Background_SelectedColorChanged_1" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center"></xctk:ColorPicker>
|
<xctk:ColorPicker Name="ClrPcker_Background" SelectedColorChanged="ClrPcker_Background_SelectedColorChanged_1" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Height="22" Width="100"/>
|
||||||
|
|
||||||
<Border Grid.Row="1" Grid.Column="1" Margin ="10, 10, 10, 10" BorderBrush="Black" BorderThickness ="2.5">
|
<Border Grid.Row="1" Grid.Column="1" Margin ="10,10,10,10" BorderBrush="Black" BorderThickness ="2.5">
|
||||||
<Canvas Name="CanvasForPaint" MouseDown="CanvasForPaint_MouseDown" MouseMove="CanvasForPaint_MouseMove">
|
<Canvas Name="CanvasForPaint" MouseDown="CanvasForPaint_MouseDown" MouseMove="CanvasForPaint_MouseMove">
|
||||||
<Canvas.Background>
|
<Canvas.Background>
|
||||||
<SolidColorBrush Color="White" Opacity="0"/>
|
<SolidColorBrush Color="White" Opacity="0"/>
|
||||||
</Canvas.Background>
|
</Canvas.Background>
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
<Grid Grid.Column="2" Grid.Row="1">
|
||||||
|
<TextBox Name="SentMessage" IsReadOnly="True"/>
|
||||||
|
<TextBox x:Name="ChatBox" Keyboard.KeyDown="ChatBox_KeyDown" Width="200" Height="50" ToolTip="Message goes here" ToolTipService.IsEnabled="True" VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ namespace Client.Views
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class GameWindow : Window
|
public partial class GameWindow : Window
|
||||||
{
|
{
|
||||||
|
|
||||||
public GameWindow()
|
public GameWindow()
|
||||||
{
|
{
|
||||||
DataContext = new ViewModelGame();
|
DataContext = new ViewModelGame();
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
}
|
}
|
||||||
Point currentPoint = new Point();
|
Point currentPoint = new Point();
|
||||||
|
|
||||||
@@ -40,7 +42,7 @@ namespace Client.Views
|
|||||||
{
|
{
|
||||||
Line line = new Line();
|
Line line = new Line();
|
||||||
|
|
||||||
|
|
||||||
line.Stroke = new SolidColorBrush(color);
|
line.Stroke = new SolidColorBrush(color);
|
||||||
//line.Stroke = SystemColors.WindowFrameBrush;
|
//line.Stroke = SystemColors.WindowFrameBrush;
|
||||||
line.X1 = currentPoint.X;
|
line.X1 = currentPoint.X;
|
||||||
@@ -92,5 +94,24 @@ namespace Client.Views
|
|||||||
colorSelected.B = ClrPcker_Background.SelectedColor.Value.B;
|
colorSelected.B = ClrPcker_Background.SelectedColor.Value.B;
|
||||||
color = colorSelected;
|
color = colorSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ChatBox_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
//if enter then clear textbox and send message.
|
||||||
|
if (e.Key.Equals(Key.Enter))
|
||||||
|
{
|
||||||
|
WriteToChat(ChatBox.Text);
|
||||||
|
ChatBox.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Writes the current client's message to the chatbox.
|
||||||
|
*/
|
||||||
|
private void WriteToChat(string message)
|
||||||
|
{
|
||||||
|
string user = "Monkey";
|
||||||
|
SentMessage.AppendText($"{user}: {message}\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ namespace Client
|
|||||||
GameWindow window = new GameWindow();
|
GameWindow window = new GameWindow();
|
||||||
window.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
88
Eindproject/.idea/.idea.Eindproject/.idea/contentModel.xml
generated
Normal file
88
Eindproject/.idea/.idea.Eindproject/.idea/contentModel.xml
generated
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ContentModelStore">
|
||||||
|
<e p="C:\Users\doguk\AppData\Local\JetBrains\Rider2020.2\extResources" t="IncludeRecursive" />
|
||||||
|
<e p="C:\Users\doguk\AppData\Local\JetBrains\Rider2020.2\resharper-host\Local\Transient\Rider\v202\SolutionCaches\_Eindproject.984599145.00" t="ExcludeRecursive" />
|
||||||
|
<e p="C:\Users\doguk\Documents\C#-EindopdrachtP1J2\Csharp-eindproject\Client" t="IncludeRecursive">
|
||||||
|
<e p="App.xaml" t="Include" />
|
||||||
|
<e p="App.xaml.cs" t="Include" />
|
||||||
|
<e p="AssemblyInfo.cs" t="Include" />
|
||||||
|
<e p="bin" t="ExcludeRecursive" />
|
||||||
|
<e p="Client.cs" t="Include" />
|
||||||
|
<e p="Client.csproj" t="IncludeRecursive" />
|
||||||
|
<e p="FodyWeavers.xml" t="Include" />
|
||||||
|
<e p="Models" t="Include">
|
||||||
|
<e p="Model.cs" t="Include" />
|
||||||
|
</e>
|
||||||
|
<e p="obj" t="ExcludeRecursive">
|
||||||
|
<e p="Debug" t="Include">
|
||||||
|
<e p="netcoreapp3.1" t="Include">
|
||||||
|
<e p="App.g.cs" t="Include" />
|
||||||
|
<e p="Client.AssemblyInfo.cs" t="Include" />
|
||||||
|
<e p="Views" t="Include">
|
||||||
|
<e p="GameWindow.g.cs" t="Include" />
|
||||||
|
<e p="MainWindow.g.cs" t="Include" />
|
||||||
|
</e>
|
||||||
|
</e>
|
||||||
|
</e>
|
||||||
|
</e>
|
||||||
|
<e p="ViewModels" t="Include">
|
||||||
|
<e p="ViewModel.cs" t="Include" />
|
||||||
|
<e p="ViewModelGame.cs" t="Include" />
|
||||||
|
</e>
|
||||||
|
<e p="Views" t="Include">
|
||||||
|
<e p="GameWindow.xaml" t="Include" />
|
||||||
|
<e p="GameWindow.xaml.cs" t="Include" />
|
||||||
|
<e p="MainWindow.xaml" t="Include" />
|
||||||
|
<e p="MainWindow.xaml.cs" t="Include" />
|
||||||
|
</e>
|
||||||
|
</e>
|
||||||
|
<e p="C:\Users\doguk\Documents\C#-EindopdrachtP1J2\Csharp-eindproject\Eindproject" t="IncludeFlat">
|
||||||
|
<e p="Eindproject.sln" t="IncludeFlat" />
|
||||||
|
<e p="packages" t="ExcludeRecursive" />
|
||||||
|
</e>
|
||||||
|
<e p="C:\Users\doguk\Documents\C#-EindopdrachtP1J2\Csharp-eindproject\Server" t="IncludeRecursive">
|
||||||
|
<e p="App.xaml" t="Include" />
|
||||||
|
<e p="App.xaml.cs" t="Include" />
|
||||||
|
<e p="AssemblyInfo.cs" t="Include" />
|
||||||
|
<e p="bin" t="ExcludeRecursive" />
|
||||||
|
<e p="FodyWeavers.xml" t="Include" />
|
||||||
|
<e p="img" t="Include">
|
||||||
|
<e p="offline.png" t="Include" />
|
||||||
|
<e p="online.png" t="Include" />
|
||||||
|
</e>
|
||||||
|
<e p="Models" t="Include">
|
||||||
|
<e p="Information.cs" t="Include" />
|
||||||
|
<e p="ServerClient.cs" t="Include" />
|
||||||
|
<e p="ServerCommunication.cs" t="Include" />
|
||||||
|
</e>
|
||||||
|
<e p="obj" t="ExcludeRecursive">
|
||||||
|
<e p="Debug" t="Include">
|
||||||
|
<e p="netcoreapp3.1" t="Include">
|
||||||
|
<e p="App.g.cs" t="Include" />
|
||||||
|
<e p="Server.AssemblyInfo.cs" t="Include" />
|
||||||
|
<e p="Views" t="Include">
|
||||||
|
<e p="MainWindow.g.cs" t="Include" />
|
||||||
|
</e>
|
||||||
|
</e>
|
||||||
|
</e>
|
||||||
|
</e>
|
||||||
|
<e p="Server.csproj" t="IncludeRecursive" />
|
||||||
|
<e p="ViewModels" t="Include">
|
||||||
|
<e p="MainViewModel.cs" t="Include" />
|
||||||
|
</e>
|
||||||
|
<e p="Views" t="Include">
|
||||||
|
<e p="MainWindow.xaml" t="Include" />
|
||||||
|
<e p="MainWindow.xaml.cs" t="Include" />
|
||||||
|
</e>
|
||||||
|
</e>
|
||||||
|
<e p="C:\Users\doguk\Documents\C#-EindopdrachtP1J2\Csharp-eindproject\SharedClientServer" t="IncludeRecursive">
|
||||||
|
<e p="ClientServerUtil.cs" t="Include" />
|
||||||
|
<e p="JSONConvert.cs" t="Include" />
|
||||||
|
<e p="Lobby.cs" t="Include" />
|
||||||
|
<e p="ObservableObject.cs" t="Include" />
|
||||||
|
<e p="SharedClientServer.projitems" t="Include" />
|
||||||
|
<e p="SharedClientServer.shproj" t="IncludeRecursive" />
|
||||||
|
</e>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
Eindproject/.idea/.idea.Eindproject/.idea/indexLayout.xml
generated
Normal file
8
Eindproject/.idea/.idea.Eindproject/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ContentModelUserStore">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
41
Eindproject/.idea/.idea.Eindproject/.idea/workspace.xml
generated
Normal file
41
Eindproject/.idea/.idea.Eindproject/.idea/workspace.xml
generated
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AutoGeneratedRunConfigurationManager">
|
||||||
|
<projectFile>../Server/Server.csproj</projectFile>
|
||||||
|
<projectFile>../Client/Client.csproj</projectFile>
|
||||||
|
</component>
|
||||||
|
<component name="BranchesTreeState">
|
||||||
|
<expand>
|
||||||
|
<path>
|
||||||
|
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||||
|
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||||
|
</path>
|
||||||
|
<path>
|
||||||
|
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||||
|
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||||
|
</path>
|
||||||
|
<path>
|
||||||
|
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||||
|
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||||
|
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
||||||
|
</path>
|
||||||
|
</expand>
|
||||||
|
<select />
|
||||||
|
</component>
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="fef496e2-69d2-46b5-bf76-476954dce052" name="Default Changelist" comment="" />
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||||
|
<component name="TaskManager">
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="UnityProjectConfiguration" hasMinimizedUI="null" />
|
||||||
|
<component name="UnityUnitTestConfiguration" currentTestLauncher="EditMode" />
|
||||||
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
<option name="oldMeFiltersMigrated" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Reference in New Issue
Block a user