public VideoPreviewViewmodel()
 {
     View = new VideoPreviewView {
         DataContext = this
     };
     _videoSources         = new ObservableCollection <string>(new[] { Common.Properties.Resources._none_ });
     _videoSource          = _videoSources.FirstOrDefault();
     CommandRefreshSources = new UICommand
     {
         ExecuteDelegate    = RefreshSources,
         CanExecuteDelegate = o => _ndiFindInstance != IntPtr.Zero
     };
     CommandGotoNdiWebsite = new UICommand {
         ExecuteDelegate = GotoNdiWebsite
     };
     CommandShowPopup = new UICommand {
         ExecuteDelegate = o => DisplayPopup = true
     };
     CommandHidePopup = new UICommand {
         ExecuteDelegate = o => DisplayPopup = false
     };
     InitNdiFind();
     if (_ndiFindInstance != IntPtr.Zero)
     {
         Task.Run(() =>
         {
             if (Ndi.NDIlib_find_wait_for_sources(_ndiFindInstance, 5000))
             {
                 Thread.Sleep(3000);
                 Application.Current?.Dispatcher.BeginInvoke((Action) delegate { RefreshSources(null); });
             }
         });
     }
 }
Exemple #2
0
 public VideoPreviewViewmodel()
 {
     _videoSources         = new ObservableCollection <string>(new[] { Common.Properties.Resources._none_ });
     _videoSource          = _videoSources.FirstOrDefault();
     CommandRefreshSources = new UiCommand(RefreshSources, o => NdiFindInstance != IntPtr.Zero);
     CommandGotoNdiWebsite = new UiCommand(GotoNdiWebsite);
     CommandShowPopup      = new UiCommand(o => DisplayPopup = true);
     CommandHidePopup      = new UiCommand(o => DisplayPopup = false);
     SourceRefreshed      += OnSourceRefreshed;
     View = new VideoPreviewView {
         DataContext = this
     };
 }
Exemple #3
0
        public VideoPreviewViewmodel()
        {
            View = new VideoPreviewView {
                DataContext = this
            };
            _videoSources         = new ObservableCollection <string>(new[] { Common.Properties.Resources._none_ });
            _videoSource          = _videoSources.FirstOrDefault();
            CommandRefreshSources = new UICommand
            {
                ExecuteDelegate    = RefreshSources,
                CanExecuteDelegate = o => _ndiFindInstance != IntPtr.Zero
            };
            CommandGotoNdiWebsite = new UICommand {
                ExecuteDelegate = GotoNdiWebsite
            };
            CommandShowPopup = new UICommand {
                ExecuteDelegate = o => DisplayPopup = true
            };
            CommandHidePopup = new UICommand {
                ExecuteDelegate = o => DisplayPopup = false
            };
            InitNdiFind();
            var sourcesPoolThread = new Thread(() =>
            {
                while (_ndiFindInstance != IntPtr.Zero)
                {
                    if (Ndi.NDIlib_find_wait_for_sources(_ndiFindInstance, int.MaxValue))
                    {
                        OnUiThread(() => RefreshSources(null));
                    }
                }
            })
            {
                Name         = "NDI source list pooling thread",
                Priority     = ThreadPriority.BelowNormal,
                IsBackground = true
            };

            sourcesPoolThread.Start();
        }