[Addition] Added a chatbox function!
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Client
|
||||
public int Port = 5555;
|
||||
public bool Connected = false;
|
||||
//TODO send login packet to server with ClientServerUtil.createpayload(0x01,dynamic json with username)
|
||||
public string username;
|
||||
public string Username { get; }
|
||||
|
||||
public Client()
|
||||
{
|
||||
@@ -81,6 +81,7 @@ namespace Client
|
||||
string textUsername = combo.Item1;
|
||||
string textMsg = combo.Item2;
|
||||
//TODO display username and message in chat window
|
||||
|
||||
break;
|
||||
|
||||
case 0x03:
|
||||
|
||||
@@ -12,12 +12,10 @@ namespace Client
|
||||
private int _numbers;
|
||||
private bool _status;
|
||||
|
||||
//Test code
|
||||
public int Numbers
|
||||
{
|
||||
get
|
||||
{
|
||||
return _numbers;
|
||||
}
|
||||
get { return _numbers; }
|
||||
|
||||
set
|
||||
{
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace Client
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
||||
|
||||
public ViewModel()
|
||||
{
|
||||
_model = new Model();
|
||||
@@ -63,9 +61,5 @@ namespace Client
|
||||
get { return _lobbies; }
|
||||
set { _lobbies = value; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace Client.ViewModels
|
||||
{
|
||||
class ViewModelGame : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="799"/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
@@ -34,17 +35,22 @@
|
||||
|
||||
</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.Background>
|
||||
<SolidColorBrush Color="White" Opacity="0"/>
|
||||
</Canvas.Background>
|
||||
</Canvas>
|
||||
</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>
|
||||
</Window>
|
||||
|
||||
@@ -18,10 +18,12 @@ namespace Client.Views
|
||||
/// </summary>
|
||||
public partial class GameWindow : Window
|
||||
{
|
||||
|
||||
public GameWindow()
|
||||
{
|
||||
DataContext = new ViewModelGame();
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
Point currentPoint = new Point();
|
||||
|
||||
@@ -40,7 +42,7 @@ namespace Client.Views
|
||||
{
|
||||
Line line = new Line();
|
||||
|
||||
|
||||
|
||||
line.Stroke = new SolidColorBrush(color);
|
||||
//line.Stroke = SystemColors.WindowFrameBrush;
|
||||
line.X1 = currentPoint.X;
|
||||
@@ -92,5 +94,24 @@ namespace Client.Views
|
||||
colorSelected.B = ClrPcker_Background.SelectedColor.Value.B;
|
||||
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();
|
||||
window.Show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user