public PropertyCompounder(IPropertyModel model, ViewModelFactory factory)
 {
     UsePlugin  = true;
     this.model = model;
     router     = new ViewModelRouter(factory);
     CompoundOnChangedObservable = Observable.Empty <Unit>();
 }
示例#2
0
        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);
        }
示例#3
0
        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;
        }
示例#4
0
        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);
        }
示例#5
0
        /// <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);
            }
        }
示例#6
0
 /// <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));
 }