Esempio n. 1
0
        void LoadChannel(ChannelDescription chan, SourcesArgs args, string proftoken = null)
        {
            //Create channel control
            DeviceChannelControl channControl = new DeviceChannelControl();

            //add control to controls dictionary
            channelControls.Add(chan.videoSource.token, channControl);

            //Display progress bar
            ShowLoadingProgress(channControl, chan.videoSource.token);

            //add control to parent UI panel
            parent.Children.Add(channControl);

            InitChannelControl(channControl, chan, args);

            //subscribe to profile changed event
            var subsToken = eventAggregator.GetEvent <ProfileChangedEvent>().Subscribe(evargs => {
                if (evargs.vsToken == chan.videoSource.token)
                {
                    //reload channel with new profile
                    InitChannelControl(channControl, chan, args, evargs.profToken);
                }
            }, false);

            disposables.Add(Disposable.Create(() => {
                eventAggregator.GetEvent <ProfileChangedEvent>().Unsubscribe(subsToken);
            }));
        }
		void InitChannelControl(DeviceChannelControl channControl, ChannelDescription chan, SourcesArgs args, string proftoken = null) {
			//try to remove and clear all needed data
			if (channControl.Content is IDisposable) {
				var disp = channControl.Content as IDisposable;
				//try to remove content from disposables collection
				if(disposables.Contains(disp))
					disposables.Remove(disp);
				//dispose existing control
				disp.Dispose();
			}

			//Begin load channels section
			disposables.Add(SourceView.Load(chan, args.capabilities, args.nvtSession, args.odmSession, proftoken)
				.ObserveOnCurrentDispatcher()
				.Subscribe(sourceArgs => {
					if (sourceArgs.selectedProfile != null)
						channControl.Title = sourceArgs.channelDescr.videoSource.token + ": " + sourceArgs.selectedProfile.name;
					else
						channControl.Title = sourceArgs.channelDescr.videoSource.token;

					SourceView sourceView = new SourceView(container);
					disposables.Add(sourceView);

					sourceView.Init(sourceArgs);
					channControl.Content = sourceView;
				}, err => {
					ErrorView errorView = new ErrorView(err);
					disposables.Add(errorView);

					channControl.Content = errorView;
				}
			));
		}
		public void Init(SourcesArgs args) {
			eventAggregator = container.Resolve<IEventAggregator>();

			args.channels.ForEach(chan => {
				LoadChannel(chan, args);
			});
		}
Esempio n. 4
0
        public void Init(SourcesArgs args)
        {
            eventAggregator = container.Resolve <IEventAggregator>();

            args.channels.ForEach(chan => {
                LoadChannel(chan, args);
            });
        }
Esempio n. 5
0
        void InitChannelControl(DeviceChannelControl channControl, ChannelDescription chan, SourcesArgs args, string proftoken = null)
        {
            //try to remove and clear all needed data
            if (channControl.Content is IDisposable)
            {
                var disp = channControl.Content as IDisposable;
                //try to remove content from disposables collection
                if (disposables.Contains(disp))
                {
                    disposables.Remove(disp);
                }
                //dispose existing control
                disp.Dispose();
            }

            //Begin load channels section
            disposables.Add(SourceView.Load(chan, args.capabilities, args.nvtSession, args.odmSession, proftoken)
                            .ObserveOnCurrentDispatcher()
                            .Subscribe(sourceArgs => {
                if (sourceArgs.selectedProfile != null)
                {
                    channControl.Title = sourceArgs.channelDescr.videoSource.token + ": " + sourceArgs.selectedProfile.name;
                }
                else
                {
                    channControl.Title = sourceArgs.channelDescr.videoSource.token;
                }

                SourceView sourceView = new SourceView(container);
                disposables.Add(sourceView);

                sourceView.Init(sourceArgs);
                channControl.Content = sourceView;
            }, err => {
                ErrorView errorView = new ErrorView(err);
                disposables.Add(errorView);

                channControl.Content = errorView;
            }
                                       ));
        }
		static IEnumerable<FSharpAsync<Unit>> LoadImpl(SourcesArgs args) {
			yield return args.odmSession.GetChannelDescriptions().Select(f => { args.channels = f; return (Unit)null; });
		}
		public static FSharpAsync<SourcesArgs> Load(INvtSession nvtSession, OdmSession odmSession, Capabilities capabilities) {
			SourcesArgs args = new SourcesArgs();
			args.odmSession = odmSession;
			args.capabilities = capabilities;
			args.nvtSession = nvtSession;

			return Apm.Iterate(LoadImpl(args)).Select(f => { return args; });
		}
		void LoadChannel(ChannelDescription chan, SourcesArgs args, string proftoken = null) {
			//Create channel control
			DeviceChannelControl channControl = new DeviceChannelControl();
			//add control to controls dictionary
			channelControls.Add(chan.videoSource.token, channControl);
			
			//Display progress bar
			ShowLoadingProgress(channControl, chan.videoSource.token);

			//add control to parent UI panel
			parent.Children.Add(channControl);

			InitChannelControl(channControl, chan, args);

			//subscribe to profile changed event
			var subsToken = eventAggregator.GetEvent<ProfileChangedEvent>().Subscribe(evargs => {
				if (evargs.vsToken == chan.videoSource.token) {
					//reload channel with new profile
					InitChannelControl(channControl, chan, args, evargs.profToken);
				}
			}, false);
			disposables.Add(Disposable.Create(() => {
				eventAggregator.GetEvent<ProfileChangedEvent>().Unsubscribe(subsToken);
			}));
		}