0

I have a ipcamera SDK (surveillance) that work well on WinForms. Currently, I'm using WPF MVVM.

enter image description here

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.

enter image description here

I have 4 CCTVs need to be display on mainwindow. How do I point these CCTV stream to targetted ImageSource?

Luiey
  • 843
  • 2
  • 23
  • 50
  • I am not sure what the question is but there is only one HWND in a WPF window. – mm8 Sep 14 '22 at 12:01
  • Yes, that is my issue since WPF window have one HWND. The question targetting how do I display a CCTV stream to all image on WPF window as the SDK is require hWnd and it only show in WinForms. The target code is on ```NetSDK.NETClient.RealPlay```. It has callback, but I cannot view the image. – Luiey Sep 15 '22 at 01:39

0 Answers0