Example #1
0
        public IActionResult Index(bool force = false)
        {
            LoadUsers();

            if (!string.IsNullOrEmpty(HttpContext.Request.Cookies["Done"]) && !force)
            {
                ViewData["Title"] = "Du har redan registrerat dina val...försöker du fuska, eller?";

                return(View("Done"));
            }

            var vm = new WizardViewModel
            {
                Users = _userViewModel.Select(x => new SelectListItem {
                    Value = x.Id.ToString(), Text = x.Name, Selected = x.Id == 0, Disabled = x.Id == 0
                }),
                Question1 = _dbContext.Questions.Single(x => x.Order == 1),
                Question2 = _dbContext.Questions.Single(x => x.Order == 2),
                Question3 = _dbContext.Questions.Single(x => x.Order == 3),
                Question4 = _dbContext.Questions.Single(x => x.Order == 4),
                Question5 = _dbContext.Questions.Single(x => x.Order == 5),
                Question6 = _dbContext.Questions.Single(x => x.Order == 6),
                Question7 = _dbContext.Questions.Single(x => x.Order == 7),
            };

            // Alternativ
            // ----------
            // Öland
            // Polen
            // Prag
            // Alicante/Spanien

            return(View(vm));
        }
Example #2
0
        private static void RegisterViewModels(ContainerBuilder builder)
        {
            builder.RegisterType <MainViewModel>().SingleInstance();
            builder.Register(x =>
            {
                var type  = typeof(IStepViewModel);
                var steps = AppDomain.CurrentDomain.GetAssemblies()
                            .SelectMany(t => t.GetTypes())
                            .Where(t => type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract)
                            .Select(t => Container.Resolve(t) as IStepViewModel)
                            .OrderBy(s => s.Index)
                            .ToList();

                var wizardViewModel = new WizardViewModel(steps)
                {
                    CancelAction = () => ServiceLocator.Current.GetInstance <MainViewModel>()
                                   .SetContent(ServiceLocator.Current.GetInstance <LoginControlViewModel>())
                };


                return(wizardViewModel);
            })
            .AsSelf();
            builder.RegisterType <HelloStepViewModel>();
            builder.RegisterType <PlaceRingStepViewModel>();
            builder.RegisterType <RemoveRingStepViewModel>();
            builder.RegisterType <SuccessfullyStepViewModel>();
            builder.RegisterType <LoginStepViewModel>();
            builder.RegisterType <FinishedStepViewModel>();
            builder.RegisterType <LoginControlViewModel>();

            builder.RegisterBuildCallback(x => x.Resolve <MainViewModel>().SetContent(x.Resolve <LoginControlViewModel>()));
        }
Example #3
0
        public ActionResult Proceed(WizardViewModel model)
        {
            var  wizard = WizardSigleton.Instance;
            bool answer;

            if (bool.TryParse(model.SelectedAnswer, out answer))
            {
                wizard.EnterData(answer);
                wizard.Proceed();
            }
            var viewModel = new WizardViewModel
            {
                Name     = wizard.CurrentState.Name,
                Question = wizard.CurrentState.Question,
            };

            var fs = wizard.CurrentState as FinalWizardPage;

            if (fs != null)
            {
                viewModel.Link   = fs.Link;
                viewModel.Result = fs.Result;
            }

            return(View("Index", viewModel));
        }
Example #4
0
 public SelectApplicationsPageViewModel(WizardViewModel wizardViewModel)
     : base(wizardViewModel)
 {
     this.CanCancel           = true;
     this.CanGoToPreviousPage = false;
     this.CanGoToNextPage     = true;
 }
Example #5
0
        private void OnAddProfile()
        {
            try
            {
                using (var container = SettingsController.GetChildContainer())
                {
                    container.Register <WizardController>().AsSingleton();

                    var wizard = new Wizard();

                    var steps = new WizardStepBase[]
                    {
                        new CreateProfileWizardStepViewModel(container),
                        new InstallationsWizardStepViewModel(container),
                    };

                    var viewModel = new WizardViewModel(container, steps);

                    wizard.DataContext = viewModel;
                    wizard.ShowDialog();
                }

                UpdateProfiles();
            }
            catch (Exception e)
            {
                GeneralExceptionHandler.Instance.OnError(e);
            }
        }
Example #6
0
        public ActionResult Setup(WizardViewModel model)
        {
            var user = db.Users.Find(User.Identity.GetUserId());

            if (ModelState.IsValid)
            {
                //Add and save Bank Account
                model.BankAccount.Created = DateTime.Now;
                model.BankAccount.OwnerId = User.Identity.GetUserId();
                db.BankAccounts.Add(model.BankAccount);
                db.SaveChanges();

                //Add and save Budget
                model.Budget.Created     = DateTime.Now;
                model.Budget.HouseholdId = (int)user.HouseholdId;
                db.SaveChanges();


                //Add and save BudgetItem
                model.BudgetItem.Created  = DateTime.Now;
                model.BudgetItem.BudgetId = model.Budget.Id;
                db.SaveChanges();
                //return RedirectToAction("Dashboard", "Households", new {ho);
                return(RedirectToAction("Details", "Households", new { id = user.HouseholdId }));
            }
            return(View(model));
        }
        public FinishPageViewModel(WizardViewModel wizardViewModel) : base(wizardViewModel)
        {
            var restartRequired = wizardViewModel.RestartRequired;

            this.BackButtonText = Localisation.FinishPage_ExitButtonText;
            this.NextButtonText = restartRequired
                ? Localisation.FinishPage_RebootButtonText
                : wizardViewModel.IsInstalled == false ? Localisation.FinishPage_StartMicrosoftOutlook : Localisation.FinishPage_ExitButtonText;
            this.NextPageCommand = new SimpleCommand(_ =>
            {
                if (restartRequired)
                {
                    wizardViewModel.RestartConfirmed = true;
                    wizardViewModel.Bootstrapper.Engine.Quit(wizardViewModel.Status);
                    return;
                }

                if (wizardViewModel.IsInstalled == false)
                {
                    System.Diagnostics.Process.Start("OUTLOOK.EXE");
                }

                this.Bootstrapper.Engine.Quit(wizardViewModel.Status);
            }, _ => true);
            this.PreviousPageCommand = new SimpleCommand(
                _ => { this.Bootstrapper.Engine.Quit(wizardViewModel.Status); }, _ => restartRequired);
            this.CanCancel           = false;
            this.CanGoToPreviousPage = restartRequired;
            this.CanGoToNextPage     = true;
        }
Example #8
0
 public BootstrapperUpdateCheckPageViewModel(WizardViewModel wizardViewModel)
     : base(wizardViewModel)
 {
     this.CanCancel           = false;
     this.CanGoToPreviousPage = false;
     this.CanGoToNextPage     = false;
 }
Example #9
0
        private void CheckFirstUse()
        {
            var settingsService        = _container.Resolve <ISettingsService>();
            var profileSettingsService = _container.Resolve <IProfileSettingsService>();

            if (profileSettingsService.SelectedProfile == null)
            {
                using (var container = _container.GetChildContainer())
                {
                    container.Register <WizardController>().AsSingleton();

                    var wizard = new Wizard();

                    var steps = new WizardStepBase[]
                    {
                        new FirstUseWelcomeStepViewModel(container),
                        new InstallationsWizardStepViewModel(container),
                        new CreateProfileWizardStepViewModel(container),
                    };

                    var viewModel = new WizardViewModel(container, steps);

                    Current.MainWindow = wizard;

                    _splashScreen.Hide();

                    wizard.DataContext = viewModel;
                    wizard.ShowDialog();

                    _splashScreen.Show();
                }

                settingsService.SetValue(SettingsCategories.Launcher, SettingsKeys.IsFirstUseComplete, true);
            }
        }
Example #10
0
 private void RemoveValidationRulesFromOtherSteps(WizardViewModel model)
 {
     foreach (var validationRuleFromOtherStep in ModelState.Where(m => !m.Key.StartsWith("Step" + (model.StepIndex))).ToList())
     {
         ModelState.Remove(validationRuleFromOtherStep.Key);
     }
 }
Example #11
0
        public void GivenThreeStepWizard_ItShouldStartOnTheFirstButNotLastStep()
        {
            var wiz = new WizardViewModel();

            wiz.IsOnFirstStep.Should().BeTrue();
            wiz.IsOnLastStep.Should().BeFalse();
        }
Example #12
0
        protected PageViewModel(WizardViewModel wizardViewModel)
            : base(wizardViewModel.Bootstrapper)
        {
            this.WizardViewModel = wizardViewModel;
            this.CancelCommand   = new SimpleCommand(_ => this.WizardViewModel.RequestCancellation(),
                                                     _ => this.CanCancel && !wizardViewModel.CancelButtonPressed && !wizardViewModel.ShouldCancel);
            this.NextPageCommand     = new SimpleCommand(_ => this.BeginNextPhase(), _ => this.CanGoToNextPage);
            this.PreviousPageCommand = new SimpleCommand(_ => this.GoToPreviousPage(), _ => this.CanGoToPreviousPage);

            switch (this.WizardViewModel.CurrentPageType)
            {
            case PageType.ReadyToInstallPage:
                this.NextButtonText = Localisation.Wizard_InstallButtonText;
                break;

            case PageType.UninstallPage:
                this.NextButtonText = Localisation.Wizard_UninstallButtonText;
                break;

            case PageType.UpgradePage:
                this.NextButtonText = Localisation.Wizard_UpgradeButtonText;
                break;

            default:
                this.NextButtonText = Localisation.Wizard_NextButtonText;
                break;
            }

            this.BackButtonText   = Localisation.Wizard_BackButtonText;
            this.CancelButtonText = Localisation.Wizard_CancelButtonText;
        }
Example #13
0
 public PlanPageViewModel(WizardViewModel wizardViewModel)
     : base(wizardViewModel)
 {
     this.CanCancel           = true;
     this.CanGoToPreviousPage = false;
     this.CanGoToNextPage     = false;
 }
Example #14
0
 public ConfigurationPageViewModel(WizardViewModel wizardViewModel)
     : base(wizardViewModel)
 {
     this.CanCancel           = true;
     this.CanGoToPreviousPage = true;
     this.CanGoToNextPage     = true;
 }
Example #15
0
        public virtual JsonResult NextWizardStep(/*[ModelBinder(typeof(WizardModelBinder))]*/ [Deserialize] WizardViewModel model, FormCollection form)
        {
            var state = ViewModelSessionState;

            model.SetStepIndex(state != null ? state.StepIndex : 0);
            RemoveValidationRulesFromOtherSteps(model);

            if (Validate(ModelState, model))
            {
                model.Errors = null;
                model.NextStep();

                try
                {
                    ProcessToNext(model);
                }
                catch (ValidationException valEx)
                {
                    // Catch custom exceptions so decrease the stepindex
                    model.PreviousStep();

                    // Return the errors to the client
                    model.Errors = new List <WizardValidationResult>();
                    model.Errors.Add(new WizardValidationResult {
                        MemberName = string.Empty, Message = valEx.ValidationResult.ErrorMessage
                    });
                }
            }

            ViewModelSessionState = model;
            return(Json(model.StepIndex));
        }
Example #16
0
 public UninstallPageViewModel(WizardViewModel wizardViewModel)
     : base(wizardViewModel)
 {
     this.CanCancel           = true;
     this.CanGoToPreviousPage = true;
     this.CanGoToNextPage     = true;
 }
Example #17
0
        public ActionResult AddPOS()
        {
            var wizard = new WizardViewModel();

            wizard.Initialize();
            return(View(wizard));
        }
Example #18
0
        public ActionResult AddPOS(
            [Deserialize] WizardViewModel wizard,
            IStepViewModel step
            )
        {
            wizard.Steps[wizard.CurrentStepIndex] = step;
            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(Request["next"]))
                {
                    wizard.CurrentStepIndex++;
                }
                else if (!string.IsNullOrEmpty(Request["prev"]))
                {
                    wizard.CurrentStepIndex--;
                }
                else
                {
                    // TODO: we have finished: all the step partial
                    // view models have passed validation => map them
                    // back to the domain model and do some processing with
                    // the results

                    return(Content("thanks for filling this form", "text/plain"));
                }
            }
            else if (!string.IsNullOrEmpty(Request["prev"]))
            {
                // Even if validation failed we allow the user to
                // navigate to previous steps
                wizard.CurrentStepIndex--;
            }
            return(View(wizard));
        }
Example #19
0
        public void GivenThreeStepWizard_CanAdvanceToSecondStep()
        {
            var wiz = new WizardViewModel();

            wiz.Advance();
            wiz.CurrentStepNumber.Should().Be(2);
        }
        public SelectApplicationsPageViewModel(WizardViewModel wizardViewModel)
            : base(wizardViewModel)
        {
            this.CanCancel           = true;
            this.CanGoToPreviousPage = false; // TODO Allow if doing modify.
            this.CanGoToNextPage     = true;

            // TODO: From WelcomePage in original, which Install button
            // clicked. Correct to do it this way?
            wizardViewModel.LaunchAction = LaunchAction.Install;
            // TODO Need this? Or put in ReadyToInstall? this.BeginNextPhase();

            this._selectAppsFolderHelper = new WixVariableHelper(wizardViewModel.Bootstrapper, "InstallDir");
            this._dialogTitle            = string.Format(Localisation.Wizard_WindowTitle,
                                                         Bootstrapper.Engine.StringVariables["WixBundleName"],
                                                         Bootstrapper.Engine.StringVariables["TitleBarRelease"]);

            this.SelectAppsFolderBrowseCommand = new SimpleCommand(_ =>
            {
                var folderBrowserDialog = new FolderBrowserDialog
                {
                    DialogTitle    = this._dialogTitle,
                    SelectedFolder = ApplicationsFolder
                };
                // If user clicks OK then Value is true, so we know to save the selected folder.
                if (folderBrowserDialog.ShowDialog().Value)
                {
                    this.ApplicationsFolder = folderBrowserDialog.SelectedFolder;
                }
            }, _ => true);
        }
 public ChoosePublisherForReferencePageViewModel(WizardViewModel parent, List<Institution> institutions, List<Publisher> publishers)
     : base(parent)
 {
     _standardViewModel = new ChooseInstitiutionAndPublisherPageViewModel(parent, institutions, publishers);
     _externalViewModel = new ChooseExternalPublisherViewModel(parent);
     SelectedPublisherType = _standardViewModel;
 }
Example #22
0
        public FinishPageViewModel(WizardViewModel wizardViewModel) : base(wizardViewModel)
        {
            // Product URLs have a product version in the URL. It's set
            // at build time so we can have the correct version.
            string urlVersion = Bootstrapper.Engine.StringVariables["URLVersion"];

            ReleaseNotesURL           = string.Format(Localisation.FinishPage_ReleaseNotesURL, urlVersion);
            TechnicalDocumentationURL = string.Format(Localisation.FinishPage_TechnicalDocumentationURL, urlVersion);
            LicenseURL = string.Format(Localisation.FinishPage_LicenseURL, urlVersion);
            bool restartRequired     = wizardViewModel.RestartRequired;
            bool needExplorerRestart = wizardViewModel.LaunchAction != LaunchAction.Uninstall;

            // Don't have a cancel button. Instead use "Exit".
            this.CanCancel = false;

            // Back button is always "Exit".
            this.BackButtonText      = Localisation.FinishPage_ExitButtonText;
            this.PreviousPageCommand = new SimpleCommand(
                _ => {
                if (restartRequired)
                {
                    MessageBox.Show(Localisation.FinishPage_RememberToRestartSystem);
                }
                else if (needExplorerRestart)     // Else since don't show if reminding to restart system.
                {
                    MessageBox.Show(Localisation.FinishPage_RememberToRestartExplorer);
                }
                this.Bootstrapper.Engine.Quit(wizardViewModel.Status);
            }, _ => true);
            this.CanGoToPreviousPage = true;

            this.CanGoToNextPage = false; // Assume only an Exit button.

            // Next button is either "Reboot now" if restart required,
            // or "Restart Explorer" if need an explorer restart.
            if (restartRequired)
            {
                this.CanGoToNextPage = true;
                this.NextButtonText  = Localisation.FinishPage_RestartButtonText;
                this.NextPageCommand = new SimpleCommand(_ =>
                {
                    wizardViewModel.RestartConfirmed = true;
                    this.Bootstrapper.Engine.Quit(wizardViewModel.Status);
                }, _ => true);
            }
            else
            {
                if (needExplorerRestart)
                {
                    this.CanGoToNextPage = true;
                    this.NextButtonText  = Localisation.FinishPage_RestartExplorerText;
                    this.NextPageCommand = new SimpleCommand(_ =>
                    {
                        RestartFileExplorer();
                        this.Bootstrapper.Engine.Quit(wizardViewModel.Status);
                    }, _ => true);
                }
            }
        }
Example #23
0
        public MainWindow()
        {
            this.InitializeComponent();

            this._WizardViewModel = new WizardViewModel();
            this._WizardViewModel.RequestClose += this.OnViewModelRequestClose;
            this.DataContext = this._WizardViewModel;
        }
Example #24
0
        public void GivenThreeStepWizard_CanGoBack()
        {
            var wiz = new WizardViewModel();

            wiz.Advance();
            wiz.GoBack();
            wiz.CurrentStepNumber.Should().Be(1);
        }
Example #25
0
        public void GivenThreeStepWizard_AfterAdvanceToSecondStep_ShouldNotBeFirstNorLast()
        {
            var wiz = new WizardViewModel();

            wiz.Advance();
            wiz.IsOnFirstStep.Should().BeFalse();
            wiz.IsOnLastStep.Should().BeFalse();
        }
Example #26
0
 void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (!e.Cancelled)
     {
         ((ViewModels.InstallPageViewModel)PageViewModel).IsComplete = true;
     }
     WizardViewModel.PageCompleted();
 }
Example #27
0
 public JsonResult Cancel(WizardViewModel wizardViewModel)
 {
     if (!wizardViewModel.AllowCancel)
     {
         throw new ArgumentException("not allowed to cancel");
     }
     return(Json(new { newLocation = Url.Action("Index", "Home") }));
 }
 public ReadyToInstallPageViewModel(WizardViewModel wizardViewModel)
     : base(wizardViewModel)
 {
     this.CanCancel           = true;
     this.CanGoToPreviousPage = true;
     this.CanGoToNextPage     = true;
     this.NextButtonText      = Localisation.Wizard_InstallButtonText;
 }
        public DynamicRequestManagementWindow(WizardViewModel wizardViewModel)
        {
            InitializeComponent();

            Wizard.AddStep(0, new RequestProperties(wizardViewModel.Request));
            Wizard.AddStep(1, new ViewProperties(wizardViewModel.ViewProperties));
            Wizard.AddStep(2, new Accessorsparameters(wizardViewModel.AccessorsParameters));
        }
Example #30
0
 public UpgradePageViewModel(WizardViewModel wizardViewModel)
     : base(wizardViewModel)
 {
     this.CanCancel               = true;
     this.CanGoToPreviousPage     = false;
     this.CanGoToNextPage         = true;
     wizardViewModel.LaunchAction = LaunchAction.Install; // If don't do this, old install not removed.
 }
Example #31
0
        public WizardWindow()
        {
            InitializeComponent();
            viewModel        = new WizardViewModel();
            this.DataContext = viewModel;

            ContentRendered += WizardWindow_ContentRendered;
        }
 private void CreateView()
 {
     _viewmodel = new WizardViewModel<OrderProcessFlow>();
     _viewmodel.WizardCancel += new EventHandler(WizardReset);
     _viewmodel.WizardFinish += new EventHandler(WizardReset);
     _viewmodel.ProvideSteps(CreateRouteChangingSteps(_viewmodel.BusinessObject));
     WizardView view = new WizardView() { DataContext = _viewmodel };
     wizardHost.Content = view;
 }
        public AddArticleWithReferencesPageViewModel(WizardViewModel parent)
            : base(parent)
        {
            AddArticleDataContext = new AddArticleViewModel(parent);

            IEnumerable<Article> articles = CentralRepository.Instance.GetArticles();
            ArticlesToChooseFrom = CollectionViewSource.GetDefaultView(articles);

            _selectedArticles = new ObservableCollection<Article>();
            SelectedArticles = CollectionViewSource.GetDefaultView(_selectedArticles);

            MoveReferenceUpCommand = new DelegateCommand(MoveReferenceUp);
            MoveReferenceDownCommand = new DelegateCommand(MoveReferenceDown);
            RemoveReferenceCommand = new DelegateCommand(RemoveReference);

            ShouldExportToInvenio = false;

            AddArticleDataContext.EditedArticleChanged += AddArticleDataContext_EditedArticleChanged;
        }
        public ChooseInstitiutionAndPublisherPageViewModel(WizardViewModel parent, List<Institution> institutions, List<Publisher> publishers)
            : base(parent)
        {
            _institutions = new SearchableCollectionViewWrapper<Institution>(
                new CollectionViewSource { Source = institutions }.View,
                institution => institution.Name);
            _selectedInstitutionIsNull = true;
            Institutions.MoveCurrentTo(null);
            Institutions.CurrentChanged += new EventHandler(Institutions_CurrentChanged);

            _publishers = new SearchableCollectionViewWrapper<Publisher>(
                new CollectionViewSource { Source = publishers }.View,
                publisher => publisher.Title,
                publisher =>
                {
                    //filter out publishers not belonging to the currently selected institution.
                    //If no institution is selected, show all publishers.
                    var institution = Institutions.CurrentItem as Institution;
                    return institution == null || publisher.InstitutionId == institution.Id;
                });
            Publishers.CurrentChanged += new EventHandler(Publishers_CurrentChanged);
            Publishers.MoveCurrentTo(null);
        }
 public ChooseExternalPublisherViewModel(WizardViewModel parent)
     : base(parent)
 {
 }
Example #36
0
 public WizardWindow(WizardViewModel viewModel)
     : base(viewModel, DataWindowMode.Custom, infoBarMessageControlGenerationMode: InfoBarMessageControlGenerationMode.Overlay)
 {
     InitializeComponent();
 }
 public WizardControlViewModelBase(WizardViewModel parent)
 {
     WizardViewModel = parent;
 }
Example #38
0
 public void Start()
 {
     WindowManager windowManager = new WindowManager();
     _w = new WizardViewModel();
     windowManager.ShowWindow( _w, null, null );
 }