Example #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

            // Setup controllers
            var controllerFactory = new AsyncControllerFactory();
            controllerFactory.Register("Home", () => new HomeController());
            controllerFactory.Register("Phone", () => new PhoneController(new InMemoryContactRepository()));
            controllerFactory.Register("Mail", () => new MailController());
            controllerFactory.Register("Settings", () => new SettingsController());

            // Setup transitions
            NavigationTransitions.Table.Add("Back", "Forward", () => new SlideTransition(SlideDirection.Back));
            NavigationTransitions.Table.Add("Forward", "Back", () => new SlideTransition(SlideDirection.Forward));
            NavigationTransitions.Table.Add("ZoomIn", "ZoomOut", () => new ZoomInTransition());
            NavigationTransitions.Table.Add("ZoomOut", "ZoomIn", () => new ZoomOutTransition());

            // Setup routes
            var routes = new ControllerRouteCatalog(controllerFactory);
            routes.MapRoute("{controller}/{action}");

            // Show the main window
            var main = new MainWindow();

            var navigation = new NavigatorFactory(routes);
            var navigator = navigation.CreateNavigator(main.Frame);
            main.Navigator = navigator;

            main.Show();

            base.OnStartup(e);
        }
        public MainWindow(NavigatorFactory navFactory)
        {
            InitializeComponent();
            _navFactory = navFactory;
            Model = new MainWindowViewModel(new ReflectionBasedControllerActionVerifier(), new DefaultControllerActionParser());

            Messenger.Default.Register<AddDocumentMessage>(
                this,
                args =>
                {
                    AddDocument(args.Content.Controller, args.Content.Action);
                }
            );

            Messenger.Default.Register<ModalMessage>(
                this,
                args =>
                {
                    var win = new NavHostWindow(_navFactory);
                    win.Navigate(args.Controller, args.Action);
                    win.Owner = this;
                    win.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                    win.ShowDialog();
                }
            );
        }
Example #3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Tax settings
            var taxes = new TaxEstimatorSelector();
            taxes.AddTaxRate(
                TaxPeriod.FY2009,
                new TaxEstimator(
                    new TaxBracketSelector(
                        new TaxBracket(-1, 6000M, 0, 0),
                        new TaxBracket(6000M, 35000M, 0, 0.15M),
                        new TaxBracket(35000M, 80000M, 4350, 0.30M),
                        new TaxBracket(80000M, 180000M, 17850, 0.38M),
                        new TaxBracket(180000M, decimal.MaxValue, 55850, 0.45M)
                        ),
                    new MedicareLevy(70000, 0.015M))
                );
            taxes.AddTaxRate(
                TaxPeriod.FY2010,
                new TaxEstimator(
                    new TaxBracketSelector(
                        new TaxBracket(-1, 6000M, 0, 0),
                        new TaxBracket(6000M, 37000M, 0, 0.15M),
                        new TaxBracket(37000M, 80000M, 4650, 0.30M),
                        new TaxBracket(80000M, 180000M, 17550, 0.37M),
                        new TaxBracket(180000M, decimal.MaxValue, 54550, 0.45M)
                        ),
                    new MedicareLevy(70000, 0.015M))
                );

            // Configure Magellan
            var controllerFactory = new AsyncControllerFactory();
            controllerFactory.Register("Home", () => new HomeController());
            controllerFactory.Register("Tax", () => new TaxController(taxes));

            var routes = new ControllerRouteCatalog(controllerFactory);
            routes.MapRoute("{controller}/{action}/{id}", new {controller = "Home", action = "Index", id = ""});

            var factory = new NavigatorFactory("tax", routes);
            var mainWindow = new MainWindow(factory);
            mainWindow.MainNavigator.Navigate<HomeController>(x => x.Index());
            mainWindow.Show();
        }
Example #4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var views = new ViewModelFactory();
            views.Register("Search", () => new SearchView(), () => new SearchViewModel(new SearchService()));
            views.Register("Details", () => new DetailsView(), () => new DetailsViewModel(new DetailsService()));

            var routes = new ViewModelRouteCatalog(views);
            routes.MapRoute("views/details/{id}", new { viewModel = "Details" });
            routes.MapRoute("views/{viewModel}");

            var shell = new ShellWindow();
            var navigation = new NavigatorFactory(routes);
            var navigator = navigation.CreateNavigator(shell.MainContent);
            shell.Show();

            navigator.Navigate("views/Search");
        }
Example #5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            NavigationTransitions.Table.Add("Backward", "Forward", () => new SlideTransition(SlideDirection.Back));
            NavigationTransitions.Table.Add("Forward", "Backward", () => new SlideTransition(SlideDirection.Forward));

            RegisterTypes(_container);
            //Make sure all types registered before the next line.
            TypeResolver.Initialize(_container);

            var controllers = new WindsorControllerFactory(_container);

            var routes = new Magellan.ControllerRouteCatalog(controllers);
            routes.MapRoute("{controller}/{action}");

            var navFactory = new NavigatorFactory(routes);
            var mainWindow = new MainWindow(navFactory);
            mainWindow.Show();
            base.OnStartup(e);
        }
Example #6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var controllers = new AsyncControllerFactory();
            controllers.Register("Wizard", () => new WizardController());

            var routes = new ControllerRouteCatalog(controllers);
            routes.MapRoute("wizard/{action}", new { controller = "Wizard"});

            var navigation = new NavigatorFactory(routes);

            var main = new MainWindow();
            navigation.ProgressListeners.Add(main);
            main.Show();

            var navigator = navigation.CreateNavigator(main.MainFrame);
            navigator.Navigate<WizardController>(x => x.Welcome());

            DispatcherUnhandledException += OnDispatcherUnhandledException;
            base.OnStartup(e);

            Magellan.Diagnostics.TraceSources.MagellanSource.Switch.Level = SourceLevels.Verbose;
        }
Example #7
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            DispatcherUnhandledException += (x, y) => MessageBox.Show(y.Exception.Message);

            NavigationTransitions.Table.Add("Backward", "Forward", () => new SlideTransition(SlideDirection.Back));
            NavigationTransitions.Table.Add("Forward", "Backward", () => new SlideTransition(SlideDirection.Forward));

            var controllers = new ControllerFactory();
            controllers.Register("Home", () => new HomeController());

            var routes = new ControllerRouteCatalog(controllers);
            routes.MapRoute("{controller}/{action}");

            var navigation = new NavigatorFactory(routes);
            var mainWindow = new MainWindow();
            var navigator = navigation.CreateNavigator(mainWindow.MainFrame);
            mainWindow.Show();

            navigator.NavigateWithTransition("Home", "Index", "Forward");
        }
 public void InitializeNavigator(NavigatorFactory navFactory)
 {
     _navigator = navFactory.CreateNavigator(mainFrame);
     RegisterMessageHandlers();
 }
 public NavHostControl(NavigatorFactory navFactory)
 {
     InitializeComponent();
     InitializeNavigator(navFactory);
 }
 public NavHostWindow(NavigatorFactory navFactory)
 {
     InitializeComponent();
     navHost.InitializeNavigator(navFactory);
 }