void InitEngineControl(DeviceEngineControl engineControl, AnalyticsEngine engine, AnalyticsArgs args, string ctrltoken = null) {
			//try to remove and clear all needed data
			if (engineControl.Content is IDisposable) {
				var disp = engineControl.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(EnginesView.Load(engine, args.capabilities, args.nvtSession, args.odmSession, ctrltoken)
				.ObserveOnCurrentDispatcher()
				.Subscribe(ctrlArgs => {
					if (ctrlArgs.selectedEngineControl != null)
						engineControl.Title = ctrlArgs.engine.name + ": " + ctrlArgs.selectedEngineControl.name;
					else
						engineControl.Title = ctrlArgs.engine.name;

					EnginesView enginesView = new EnginesView(container);
					disposables.Add(enginesView);

					enginesView.Init(ctrlArgs);
					engineControl.Content = enginesView;
				}, err => {

					ErrorView errorView = new ErrorView(err);
					disposables.Add(errorView);

					engineControl.Content = errorView;
				}
			));
		}
		public static FSharpAsync<EngineViewArgs> Load(AnalyticsEngine engine,
														Capabilities capabilities,
														INvtSession nvtSession,
														OdmSession odmsession,
														string ctrl = null) {
			EngineViewArgs args = new EngineViewArgs();
			args.nvtSession = nvtSession;
			args.odmSession = odmsession;
			args.capabilities = capabilities;
			args.engine = engine;
			args.selectedEngineControlToken = ctrl;

			return Apm.Iterate(LoadImpl(args)).Select(f => { return args; });
		}
Exemplo n.º 3
0
		public NVASettingsButton(IEventAggregator eventAggregator, INvtSession session, AnalyticsEngine engine, AnalyticsEngineControl control, Account currentAccount, IVideoInfo videoInfo = null)
			: base(eventAggregator, session, currentAccount, engine, control, videoInfo) {
			Init();
		}
Exemplo n.º 4
0
		public NVAButtonBase(IEventAggregator eventAggregator, INvtSession session, Account currentAccount, AnalyticsEngine engine, AnalyticsEngineControl control, IVideoInfo videoInfo = null)
            : base(eventAggregator, session, currentAccount) {
            this.engine = engine;
            this.control = control;
            this.videoInfo = videoInfo;
	    }
		void LoadEngine(AnalyticsEngine engine, AnalyticsArgs args) {
			try {
				//Create engine control
				DeviceEngineControl engineControl = new DeviceEngineControl();

				//add control to controls dictionary
				//if (engine.token == null) {
				//    throw new ArgumentNullException("Analytics engine token can not be null");
				//}
				engineControls.Add(new KeyValuePair<string, DeviceEngineControl>(engine.token, engineControl));

				//Display progress bar
				ShowLoadingProgress(engineControl, engine.token);

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

				InitEngineControl(engineControl, engine, args);

				//subscribe to control changed event
				var subsToken = eventAggregator.GetEvent<ControlChangedEvent>().Subscribe(evargs => {
					if (evargs.engine.token == engine.token) {
						//reload channel with new profile
						InitEngineControl(engineControl, engine, args, evargs.controlToken);
					}
				}, false);
				disposables.Add(Disposable.Create(() => {
					eventAggregator.GetEvent<ControlChangedEvent>().Unsubscribe(subsToken);
				}));
			} catch (Exception err) {
				ErrorView errorView = new ErrorView(err);
				disposables.Add(errorView);
				parent.Children.Add(errorView); 
			}
		}