You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
3.7 KiB
134 lines
3.7 KiB
using EC.Entity.Video;
|
|
using EC.Utils.Config;
|
|
using ECMonitor.Code;
|
|
using ECMonitor.Manager;
|
|
using ECMonitor.UC.Videos;
|
|
using Prism.Events;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
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 ECMonitor.Views
|
|
{
|
|
/// <summary>
|
|
/// FrmVideoPlayer.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class FrmVideoPlayer : Window
|
|
{
|
|
IEventAggregator _ea;
|
|
VideoPlayManager _videoPlayManager { get; set; } = new VideoPlayManager();
|
|
IUCPlayer _ucFFmpegPlayer;
|
|
public FrmVideoPlayer(IEventAggregator ea)
|
|
{
|
|
InitializeComponent();
|
|
_ea = ea;
|
|
if (ConfigHelper.VideoAIDetection()==true)
|
|
{
|
|
_ucFFmpegPlayer = _videoPlayManager.CreateVideoAI(600, 400, 0, false);
|
|
}
|
|
else
|
|
{
|
|
_ucFFmpegPlayer = _videoPlayManager.CreateVideo(_ea,800, 530, 0, false);
|
|
}
|
|
|
|
|
|
this.planMain.Children.Add(_ucFFmpegPlayer.GetControl());
|
|
|
|
}
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
//double x1 = SystemParameters.PrimaryScreenWidth;//得到屏幕整体宽度
|
|
//double y1 = SystemParameters.PrimaryScreenHeight;//得到屏幕整体高度
|
|
|
|
//x1 = x1 * 0.5;
|
|
//y1 = y1 * 0.5;
|
|
//this.Width = x1;
|
|
//this.Height = y1;
|
|
SizeChange();
|
|
}
|
|
|
|
private void SizeChange()
|
|
{
|
|
double x1 = this.ActualWidth - 4;//得到窗体整体宽度
|
|
double y1 = this.ActualHeight - 4;//得到窗体整体高度
|
|
|
|
_ucFFmpegPlayer.ReSetSize(x1, y1);//Margin="1,1,1,1"
|
|
}
|
|
|
|
public void Play(string cameraIp) {
|
|
MonitorCamera camera = CameraManager.GetCamera(cameraIp);
|
|
if (camera == null) {
|
|
_ucFFmpegPlayer.ShowMsg("相机不存在IP=" + cameraIp);
|
|
}
|
|
else
|
|
{
|
|
_ucFFmpegPlayer.Play(camera);
|
|
}
|
|
ShowAndActive();
|
|
}
|
|
public void ShowAndActive()
|
|
{
|
|
this.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
this.Show();
|
|
this.Activate();
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (this.WindowState == WindowState.Maximized)
|
|
{
|
|
this.WindowState = WindowState.Normal;
|
|
}
|
|
else
|
|
{
|
|
this.WindowState = WindowState.Maximized;
|
|
}
|
|
}
|
|
|
|
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
{
|
|
SizeChange();
|
|
}
|
|
|
|
private void Window_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if(e.Key== Key.Escape)
|
|
{
|
|
if (this.WindowState == WindowState.Maximized)
|
|
{
|
|
this.WindowState = WindowState.Normal;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btnClose_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
_ucFFmpegPlayer.Stop();
|
|
this.Hide();
|
|
}
|
|
|
|
private void Window_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
if (e.LeftButton == MouseButtonState.Pressed)
|
|
{
|
|
this.DragMove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|