125 lines
4.3 KiB
C#
125 lines
4.3 KiB
C#
using JianGongYun.TRTC.Components;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
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 JianGongYun.TRTC.Windows
|
|
{
|
|
public class ScrollingListBox : ListBox
|
|
{
|
|
protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
|
{
|
|
if (e.NewItems == null) return;
|
|
var newItemCount = e.NewItems.Count;
|
|
|
|
if (newItemCount > 0)
|
|
this.ScrollIntoView(e.NewItems[newItemCount - 1]);
|
|
|
|
base.OnItemsChanged(e);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// LiveWindowRightBottomBlock.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class LiveWindowRightBottomBlock : Window
|
|
{
|
|
LiveWindow LiveWindow { get; set; }
|
|
public LiveWindowRightBottomBlock(LiveWindow _liveWindow)
|
|
{
|
|
InitializeComponent();
|
|
this.Left = SystemParameters.WorkArea.Size.Width - this.Width - 20;
|
|
this.Top = SystemParameters.WorkArea.Size.Height - this.Height - 20;
|
|
LiveWindow = _liveWindow;
|
|
DataContext = LiveWindow.LiveWindowViewModel;
|
|
if (!LiveWindow.LiveWindowViewModel.CameraRunning)//没有开启摄像头
|
|
{
|
|
this.Height -= PreViewWrap.Height;
|
|
this.Top += PreViewWrap.Height;
|
|
PreViewWrap.Visibility = Visibility.Collapsed;
|
|
}
|
|
else
|
|
{
|
|
this.Height -= 100;
|
|
this.Top += 100;
|
|
Loaded += LiveWindowRightBottomBlock_Loaded;
|
|
}
|
|
|
|
Loaded += LiveWindowRightBottomBlock_Loaded1;
|
|
}
|
|
|
|
private void LiveWindowRightBottomBlock_Loaded1(object sender, RoutedEventArgs e)
|
|
{
|
|
if (ChatList.Items.Count > 0)
|
|
{
|
|
ChatList.ScrollIntoView(ChatList.Items[ChatList.Items.Count - 1]);
|
|
}
|
|
}
|
|
|
|
private void LiveWindowRightBottomBlock_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
//把主窗口的摄像头预览移到悬浮窗
|
|
if (LiveWindow.AfterLiveViewWrap.Children.Count == 1)
|
|
{
|
|
var view = LiveWindow.AfterLiveViewWrap.Children[0] as TXLiteAVVideoView;
|
|
BindingOperations.ClearBinding(view, TXLiteAVVideoView.WidthProperty);
|
|
BindingOperations.ClearBinding(view, TXLiteAVVideoView.HeightProperty);
|
|
view.Width = PreVideoWrap.Width;
|
|
view.Height = PreVideoWrap.Height;
|
|
LiveWindow.AfterLiveViewWrap.Children.Remove(view);
|
|
PreVideoWrap.Children.Add(view);
|
|
view.SetPause(false);
|
|
}
|
|
|
|
}
|
|
|
|
protected override void OnClosing(CancelEventArgs e)
|
|
{
|
|
//关闭前还原预览
|
|
if (PreVideoWrap.Children.Count == 1)
|
|
{
|
|
var view = PreVideoWrap.Children[0] as TXLiteAVVideoView;
|
|
view.SetPause(true);
|
|
view.Width = LiveWindow.AfterLiveViewWrap.ActualWidth;
|
|
view.Height = LiveWindow.AfterLiveViewWrap.ActualHeight;
|
|
view.SetBinding(TXLiteAVVideoView.WidthProperty, new Binding("ActualWidth") { Source = LiveWindow.AfterLiveViewWrap });
|
|
view.SetBinding(TXLiteAVVideoView.HeightProperty, new Binding("ActualHeight") { Source = LiveWindow.AfterLiveViewWrap });
|
|
PreVideoWrap.Children.Remove(view);
|
|
LiveWindow.AfterLiveViewWrap.Children.Add(view);
|
|
view.SetPause(false);
|
|
}
|
|
base.OnClosing(e);
|
|
}
|
|
|
|
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (e.ChangedButton == MouseButton.Left)
|
|
{
|
|
this.DragMove();
|
|
}
|
|
}
|
|
|
|
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
//输入框回车
|
|
if (e.Key == Key.Enter)
|
|
{
|
|
var text = (TextBox)sender;
|
|
LiveWindow.SendMsg(text);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|