I have a ipcamera SDK (surveillance) that work well on WinForms. Currently, I'm using WPF MVVM.
I have try using <WindowsFormsHost>
and using PictureBox
, and it's shows but as I search, these are actually explained why my overlay textblock is not viewing. I had try airspace but got error and massive DLL are installed with AirSpaceFixer. I had to opt out.
Below are original design from WPF without WindowsFormsHost: MainWindow.xaml:
<Grid>
<Image
x:Name="MainCamera"
Source="{Binding MAINCAMERASOURCE}"/>
<TextBlock
Text="Camera 255.255.255.255 Offline"/>
<Grid>
ViewModel:
internal void OnWindowHandleAvailable(IntPtr handleCameraMain)
{
CameraMain_Handle = handleCameraMain;
}
private IntPtr StartRealPlayCamera
{
IntPtr RealPayID = NetSDK.NETClient.RealPlay(LoginID, ChannelID, CameraMain_Handle, EM_RealPlayType.Realplay);
}
MainWindow.xaml.cs:
private void GiveWindowHandleToViewModel()
{
var viewModel = this.DataContext as ViewModel.MainMenuViewModel;
if (viewModel == null)
return;
var windowHandle = this.GetWindowHandle();
if (windowHandle == IntPtr.Zero)
return;
viewModel.OnWindowHandleAvailable(windowHandle);
}
private IntPtr GetWindowHandle()
{
var window = Window.GetWindow(this);
return new System.Windows.Interop.WindowInteropHelper(window).EnsureHandle();
}
I pass the hWnd of window to viewmodel to be use while calling the camera SDK. But the result, the camera is showing using the whole window since I have pass the Window handler.
I have 4 CCTVs need to be display on mainwindow. How do I point these CCTV stream to targetted ImageSource?