123123
This commit is contained in:
parent
eccc26c6c4
commit
ba5f72c73e
|
@ -19,6 +19,7 @@ namespace JianGongYun.TRTC.ViewModels
|
||||||
{
|
{
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
#region 直播窗口
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 教室信息
|
/// 教室信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -317,6 +318,7 @@ namespace JianGongYun.TRTC.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 只有摄像头,则画面放大并居中
|
#region 只有摄像头,则画面放大并居中
|
||||||
public Style MainBigWrapStyle
|
public Style MainBigWrapStyle
|
||||||
|
@ -350,5 +352,27 @@ namespace JianGongYun.TRTC.ViewModels
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 聊天窗口
|
||||||
|
/// <summary>
|
||||||
|
/// 消息集合
|
||||||
|
/// </summary>
|
||||||
|
private ObservableCollection<string> _Chats = new ObservableCollection<string>() { "1", "2" };
|
||||||
|
public ObservableCollection<string> Chats
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_Chats = value;
|
||||||
|
if (PropertyChanged != null)
|
||||||
|
{
|
||||||
|
PropertyChanged(this, new PropertyChangedEventArgs("Chats"));//对StudentCount进行监听
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _Chats;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,41 @@
|
||||||
MouseDown="Window_MouseDown"
|
MouseDown="Window_MouseDown"
|
||||||
Title="" Height="600" Width="200">
|
Title="" Height="600" Width="200">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
|
<Style x:Key="placeHolder" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||||
|
<Grid>
|
||||||
|
<TextBox Padding="14,0,14,0" VerticalContentAlignment="Center" Text="{Binding Path=Text,
|
||||||
|
RelativeSource={RelativeSource TemplatedParent},
|
||||||
|
Mode=TwoWay,
|
||||||
|
UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
x:Name="textSource"
|
||||||
|
Background="Transparent"
|
||||||
|
Foreground="White"
|
||||||
|
Panel.ZIndex="2" />
|
||||||
|
<TextBox Padding="14,0,14,0" VerticalContentAlignment="Center" Text="{TemplateBinding Tag}" Background="{TemplateBinding Background}" Panel.ZIndex="1">
|
||||||
|
<TextBox.Style>
|
||||||
|
<Style TargetType="{x:Type TextBox}">
|
||||||
|
<Setter Property="Foreground" Value="Transparent"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding Path=Text, Source={x:Reference textSource}}" Value="">
|
||||||
|
<Setter Property="Foreground" Value="#fff"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</TextBox.Style>
|
||||||
|
</TextBox>
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
<BooleanToVisibilityConverter x:Key="VisibilityOfBool" />
|
<BooleanToVisibilityConverter x:Key="VisibilityOfBool" />
|
||||||
|
<!--自定义ListBox项样式-->
|
||||||
|
<DataTemplate x:Key="cusItem">
|
||||||
|
<TextBlock Foreground="White" Text="{Binding}"></TextBlock>
|
||||||
|
</DataTemplate>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<!--预览框-->
|
<!--预览框-->
|
||||||
|
@ -29,6 +63,14 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
<!--聊天版面-->
|
<!--聊天版面-->
|
||||||
<Grid Background="#33000000">
|
<Grid Background="#33000000">
|
||||||
|
<DockPanel>
|
||||||
|
<!--输入框-->
|
||||||
|
<DockPanel DockPanel.Dock="Bottom" Height="30">
|
||||||
|
<TextBox Background="Transparent" Foreground="White" Style="{StaticResource placeHolder}" PreviewKeyDown="TextBox_PreviewKeyDown" Tag="输入"></TextBox>
|
||||||
|
</DockPanel>
|
||||||
|
<!--消息列表-->
|
||||||
|
<ListBox ItemTemplate="{StaticResource cusItem}" ItemsSource="{Binding Chats}" Background="Transparent"></ListBox>
|
||||||
|
</DockPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
@ -84,5 +84,16 @@ namespace JianGongYun.TRTC.Windows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
//输入框回车
|
||||||
|
if (e.Key == Key.Enter)
|
||||||
|
{
|
||||||
|
var text = (TextBox)sender;
|
||||||
|
//socket.send(text.Text);
|
||||||
|
LiveWindow.LiveWindowViewModel.Chats.Add(text.Text);//往Chats集合添加数据会自动更新到界面上
|
||||||
|
text.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue