Interaction-without-Interac.../FrontEnd/StreamWindow.xaml.cs

57 lines
1.4 KiB
C#
Raw Normal View History

2019-06-06 21:30:30 +00:00
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 FrontEnd
{
/// <summary>
/// Interaction logic for StreamWindow.xaml
/// </summary>
public partial class StreamWindow : Window
{
2019-06-07 18:03:39 +00:00
private Cam _cam = null;
private bool _processed;
2019-06-06 21:30:30 +00:00
private StreamWindow()
{
InitializeComponent();
}
2019-06-07 18:03:39 +00:00
public StreamWindow(Cam cam, bool processed) : this()
2019-06-06 21:30:30 +00:00
{
2019-06-07 18:03:39 +00:00
_cam = cam;
_processed = processed;
2019-06-06 21:30:30 +00:00
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
2019-06-07 18:03:39 +00:00
if (_processed)
{
_ = Task.Run(async () =>
{
var img = await Communicator.GetProcessedCameraImage(_cam);
_ = imgStream.Dispatcher.Invoke(() => { imgStream.Source = img; });
});
}
else
{
_ = SimpleMJPEGDecoder.StartAsync((BitmapImage img) =>
{
imgStream.Dispatcher.Invoke(() => { imgStream.Source = img; });
2019-06-06 21:30:30 +00:00
2019-06-07 18:03:39 +00:00
}, _cam.Ip);
}
2019-06-06 21:30:30 +00:00
}
}
}