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

60 lines
1.6 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-07-18 18:37:56 +00:00
// Check if we want the original or processed stream.
2019-06-27 15:45:36 +00:00
string steamAddr = _processed ? Communicator.GetProcessedCameraAddress(_cam) : _cam.Ip;
2019-07-18 18:37:56 +00:00
// // retrieve single image
2019-06-27 15:45:36 +00:00
//if (_processed)
//{
// _ = Task.Run(async () =>
// {
// var img = await Communicator.GetProcessedCameraImage(_cam);
// imgStream.Dispatcher.Invoke(() => { imgStream.Source = img; });
// });
//}
//else
2019-07-18 18:37:56 +00:00
// Show stream in image control.
2019-06-27 15:45:36 +00:00
_ = SimpleMJPEGDecoder.StartAsync((BitmapImage img) =>
2019-06-07 18:03:39 +00:00
{
2019-06-27 15:45:36 +00:00
imgStream.Dispatcher.Invoke(() => { imgStream.Source = img; });
2019-06-06 21:30:30 +00:00
2019-06-27 15:45:36 +00:00
}, steamAddr);
2019-06-06 21:30:30 +00:00
}
}
}