This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
83 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
|
||
namespace ChatRoom; | ||
|
||
class ChatBoxHeightConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
double result = (double)value - 102; | ||
if (result < 0) | ||
{ | ||
return 0; | ||
} | ||
return result; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
|
||
namespace ChatRoom; | ||
|
||
class ChatBoxWidthConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
double result = (double)value - 20; | ||
if (result < 0) | ||
{ | ||
return 0; | ||
} | ||
return result; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
|
||
namespace ChatRoom; | ||
|
||
class InputBoxWidthConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
double result = (double)value - 125; | ||
if (result < 0) | ||
{ | ||
return 0; | ||
} | ||
return result; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
<Window x:Class="ChatRoom.MainWindow" | ||
<Window | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:ChatRoom" x:Class="ChatRoom.MainWindow" | ||
mc:Ignorable="d" | ||
Title="聊天室" Height="450" Width="800" FontFamily="Segoe UI Emoji" SizeChanged="WindowSizeChanged"> | ||
Title="聊天室" Height="450" Width="800" FontFamily="Segoe UI Emoji"> | ||
<Window.Resources> | ||
<local:ChatBoxHeightConverter x:Key="ChatBoxHeightConverter"/> | ||
<local:ChatBoxWidthConverter x:Key="ChatBoxWidthConverter"/> | ||
<local:InputBoxWidthConverter x:Key="InputBoxWidthConverter"/> | ||
</Window.Resources> | ||
<Grid> | ||
<Grid x:Name="LoginGrid"> | ||
<TextBox x:Name="IPBox" Height="24" Width="100" Margin="0,-35,0,0" HorizontalAlignment="Center" VerticalAlignment="Center"/> | ||
<Button Content="连接" Height="24" Width="50" Margin="0,35,0,0" Click="ConnectAsync" HorizontalAlignment="Center" VerticalAlignment="Center"/> | ||
</Grid> | ||
<Grid x:Name="RoomGrid" IsEnabled="False" Visibility="Hidden"> | ||
<TextBox x:Name="NameBox" Height="24" Width="100" Margin="10,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/> | ||
<TextBox x:Name="ChatBox" Height="310" Width="768" Margin="10,39,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" IsReadOnly="True" VerticalScrollBarVisibility="Auto"/> | ||
<TextBox x:Name="InputBox" Height="48" Width="675" Margin="0,0,115,10" KeyDown="EnterButtonDown" TextWrapping="Wrap" HorizontalAlignment="Right" VerticalAlignment="Bottom"/> | ||
<TextBox x:Name="ChatBox" Height="{Binding ActualHeight, Converter={StaticResource ChatBoxHeightConverter}, ElementName=RoomGrid, IsAsync=True, Mode=OneWay}" Width="{Binding ActualWidth, Converter={StaticResource ChatBoxWidthConverter}, ElementName=RoomGrid, IsAsync=True, Mode=OneWay}" Margin="10,39,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" IsReadOnly="True" VerticalScrollBarVisibility="Auto"/> | ||
<TextBox x:Name="InputBox" Height="48" Margin="0,0,115,10" KeyDown="EnterButtonDown" TextWrapping="Wrap" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="{Binding ActualWidth, Converter={StaticResource InputBoxWidthConverter}, ElementName=RoomGrid, IsAsync=True, Mode=OneWay}"/> | ||
<Button x:Name="SendButton" Content="发送" Height="48" Width="100" Margin="0,0,10,10" Click="Send" HorizontalAlignment="Right" VerticalAlignment="Bottom"/> | ||
</Grid> | ||
</Grid> | ||
</Window> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters