public PropertyCompounder(IPropertyModel model, ViewModelFactory factory) { UsePlugin = true; this.model = model; router = new ViewModelRouter(factory); CompoundOnChangedObservable = Observable.Empty <Unit>(); }
public void Initialize() { var propFactory = new PropertyFactory(); var classProp = new ClassProperty(typeof(Fuga), propFactory); var vmFactory = new ViewModelFactory(propFactory); ClassVm = new ClassViewModel(classProp, vmFactory); Router = new ViewModelRouter(vmFactory); }
public void Initialize() { // set up App to handle exceptions EventAggregator.SubscribeOnDispatcher((App)Application.Current); // route the view models ViewModelRouter.RouteViewModelForView(Globals.VIEWMODEL_MAIN, Globals.VIEW_MAINPAGE); ViewModelRouter.RouteViewModelForView(Globals.VIEWMODEL_RED, Globals.VIEW_RED); ViewModelRouter.RouteViewModelForView(Globals.VIEWMODEL_BLUE, Globals.VIEW_BLUE); Initialized = true; }
public void RoutingTest() { var factory = new PropertyFactory(); var model = (ClassProperty)factory.Create(typeof(Hoge), "Hoge"); var xProp = (IntProperty)model.Members.First(x => x.PropertyInfo.Name == "X"); var fugaProp = (ClassProperty)model.Members.First(x => x.PropertyInfo.Name == "Fuga"); var yProp = (IntProperty)fugaProp.Members.First(x => x.PropertyInfo.Name == "Y"); var fooProp = (ClassProperty)fugaProp.Members.First(x => x.PropertyInfo.Name == "Foo"); var zProp = (IntProperty)fooProp.Members.First(x => x.PropertyInfo.Name == "Z"); xProp.IntValue.Value = 16; yProp.IntValue.Value = 64; zProp.IntValue.Value = 256; var router = new ViewModelRouter(new ViewModelFactory(factory)); Assert.AreEqual(xProp.IntValue.Value, router.GetIntProperty(model, "X").Value); Assert.AreEqual(yProp.IntValue.Value, router.GetIntProperty(model, "Fuga.Y").Value); Assert.AreEqual(zProp.IntValue.Value, router.GetIntProperty(model, "Fuga.Foo.Z").Value); }
/// <summary> /// Hook into navigation event /// </summary> /// <param name="e">View navigation args</param> public void HandleEvent(ViewNavigationArgs e) { if (e.Deactivate) { ViewModelRouter.DeactivateView(e.ViewType); EventAggregator.Publish(new ViewNavigatedArgs(e.ViewType) { Deactivate = true }); return; } // does a view location exist? var viewLocation = (from location in _fluentRoutes where location.ViewName.Equals(e.ViewType, StringComparison.InvariantCultureIgnoreCase) select location).FirstOrDefault() ?? (from location in ViewLocations where location.ViewName.Equals(e.ViewType, StringComparison.InvariantCultureIgnoreCase) select location).FirstOrDefault(); // if so, try to load the dll, then activate the view if (viewLocation != null) { DeploymentService.RequestModule(viewLocation.View, exception => { if (exception != null) { throw exception; } _ActivateView(e.ViewType, e.ViewParameters); }); } else { // just activate the view directly _ActivateView(e.ViewType, e.ViewParameters); } }
/// <summary> /// Activate the view /// </summary> /// <param name="viewName">The name of the view</param> /// <param name="parameters">Parameters for the view</param> private void _ActivateView(string viewName, IDictionary <string, object> parameters) { ViewModelRouter.ActivateView(viewName, parameters); EventAggregator.Publish(new ViewNavigatedArgs(viewName)); }