Beispiel #1
0
        protected override void BindCommands()
        {
            SelectLocalCameraVideoSourceCommand = new RelayCommand(() =>
            {
                Status = ViewModelStatus.Initializing;
                CameraFilterModel.GetCameraFilters(GetCameraFiltersCallback);
            });
            SelectLocalAVIFileVideoSourceCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(new NotificationMessage(UIMessageType.DeviceConfiguration_SelectLocalAVIFileVideoSourceEvent));
            });
            SelectLocalDesktopVideoSourceCommand = new RelayCommand(() =>
            {
                Status = ViewModelStatus.Initializing;
                DesktopFilterModel.GetDesktopFilters(GetDesktopFiltersCallback);
            });
            SelectNetworkJPEGCameraVideoSourceCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(new NotificationMessage(UIMessageType.DeviceConfiguration_SelectNetworkJPEGVideoSourceEvent));
            });
            SelectNetworkMJPEGCameraVideoSourceCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(new NotificationMessage(UIMessageType.DeviceConfiguration_SelectNetworkMJPEGVideoSourceEvent));
            });

            CancelCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(new NotificationMessage(UIMessageType.DeviceConfiguration_CancelNavigateVideoSourceEvent));
            });
        }
Beispiel #2
0
        protected override void BindCommands()
        {
            OKCommand = new RelayCommand(() =>
            {
                Camera camera = MakeCamera();
                if (camera != null)
                {
                    Status = ViewModelStatus.Loading;
                    Model.CheckCameraName(camera, CheckCameraNameCallback);

                    // 异步顺序执行两个操作
                    AsyncWorkerHandle <bool> handle = AsyncWorkerHelper.DoWork <bool>(
                        delegate(object sender, DoWorkEventArgs e)
                    {
                        _syncWork.WaitOne(); // 等待上一个操作的完成

                        if (CheckCameraNameResult == CheckNameExistedResultType.NotExisted)
                        {
                            Status = ViewModelStatus.Saving;
                            Model.CreateCamera(camera, CreateCameraCallback);
                        }
                    });
                }
            });

            CancelCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(new NotificationMessage(UIMessageType.DeviceConfiguration_CancelCameraEvent));
            });

            CheckCameraNameCommand = new RelayCommand(() =>
            {
                Camera camera = MakeCheckedCamera();
                if (camera != null)
                {
                    Status = ViewModelStatus.Loading;
                    Model.CheckCameraName(camera, CheckCameraNameCallback);
                }
            });

            #region SelectVideoSourceCommand

            SelectVideoSourceCommand = new RelayCommand(() =>
            {
                if (this.SelectedVideoSourceDescription == null || string.IsNullOrEmpty(this.SelectedVideoSourceDescription.OriginalSourceString))
                {
                    Messenger.Default.Send(new NotificationMessage <VideoSourceDescription>(
                                               UIMessageType.DeviceConfiguration_NavigateVideoSourceEvent, null));
                }
                else
                {
                    switch (this.SelectedVideoSourceDescription.SourceType)
                    {
                    case VideoSourceType.Mock:
                        break;

                    case VideoSourceType.LocalCamera:
                        Status = ViewModelStatus.Initializing;
                        CameraFilterModel.GetCameraFilters(GetCameraFiltersCallback);
                        break;

                    case VideoSourceType.LocalAVIFile:
                        Messenger.Default.Send(new NotificationMessage <VideoSourceDescription>(
                                                   UIMessageType.DeviceConfiguration_UpdateLocalAVIFileVideoSourceEvent, this.SelectedVideoSourceDescription));
                        break;

                    case VideoSourceType.LocalDesktop:
                        Status = ViewModelStatus.Initializing;
                        DesktopFilterModel.GetDesktopFilters(GetDesktopFiltersCallback);
                        break;

                    case VideoSourceType.NetworkJPEG:
                        Messenger.Default.Send(new NotificationMessage <VideoSourceDescription>(
                                                   UIMessageType.DeviceConfiguration_UpdateNetworkJPEGVideoSourceEvent, this.SelectedVideoSourceDescription));
                        break;

                    case VideoSourceType.NetworkMJPEG:
                        Messenger.Default.Send(new NotificationMessage <VideoSourceDescription>(
                                                   UIMessageType.DeviceConfiguration_UpdateNetworkMJPEGVideoSourceEvent, this.SelectedVideoSourceDescription));
                        break;

                    default:
                        throw new NotSupportedException();
                    }
                }
            });

            #endregion
        }