public CollectionBindingViewModel(IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(messagePresenter, nameof(messagePresenter));
     _messagePresenter = messagePresenter;
     AddCommand        = new RelayCommand(Add);
     RemoveCommand     = RelayCommandBase.FromAsyncHandler <CollectionItemModel>(Remove, CanRemove, this);
 }
Пример #2
0
 private Result AssertStartMatchesClock(IMessagePresenter presenter)
 {
     _jobRun.Start.Should().Be(_clock.CurrentInstant);
     _clock.AddToCurrentInstant(Duration.FromMinutes(5));
     _actionRan = true;
     return(Result.Successful());
 }
 public ParentViewModel(IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _messagePresenter          = messagePresenter;
     CanOpenChildViewModel      = true;
     _openChildViewModelCommand = new RelayCommand(OpenChildViewModel, CanExecuteOpenChildViewModel, this);
 }
Пример #4
0
 private Result AssertIsRunning(IMessagePresenter presenter)
 {
     _jobRun.IsRunning.Should().BeTrue("because the task is in the middle of running");
     _jobRun.IsFinishedRunning.Should().BeFalse("because the task is not yet finished running");
     _actionRan = true;
     return(Result.Successful());
 }
 public CollectionBindingViewModel(IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _messagePresenter = messagePresenter;
     AddCommand = new RelayCommand(Add);
     RemoveCommand = RelayCommandBase.FromAsyncHandler<CollectionItemModel>(Remove, CanRemove, this);
 }
Пример #6
0
 public SchedulerWaiter(Func <IJobServer> jobServerProvider, IAutoResetEvent autoResetEvent,
                        ITimerFactory timerFactory, IMessagePresenter messagePresenter)
     : base("status", autoResetEvent, timerFactory)
 {
     _jobServerProvider = jobServerProvider;
     _messagePresenter  = messagePresenter;
 }
 public PageViewModel(IMessagePresenter messagePresenter, IToastPresenter toastPresenter) : base(messagePresenter)
 {
     _toastPresenter   = toastPresenter;
     Text              = "Page view model " + Interlocked.Increment(ref _counter);
     DisplayName       = Text;
     ToNextPageCommand = new AsyncRelayCommand(ToNextPageAsync, false);
 }
 public TabViewModel(IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _messagePresenter = messagePresenter;
     AddCommand = new RelayCommand(Add);
     InsertCommand = new RelayCommand(Insert, CanInsert, this);
     RemoveCommand = new RelayCommand(Remove, CanRemove, this);
 }
 public static void TraceNavigation(this IViewModel viewModel, INavigationContext ctx,
                                    IMessagePresenter messagePresenter, [CallerMemberName] string method = "")
 {
     //messagePresenter.ShowAsync(
     Debug.WriteLine(string.Format("Source “{0}”, method “{1}”, from “{2}” to “{3}”, mode “{4}”",
                                   GetName(viewModel), method, GetName(ctx.ViewModelFrom), GetName(ctx.ViewModelTo), ctx.NavigationMode),
                     "Navigation trace");
 }
 public ChildViewModel(IMessagePresenter messagePresenter)
 {
     if (messagePresenter == null)
     {
         throw new ArgumentNullException("messagePresenter");
     }
     _messagePresenter = messagePresenter;
 }
Пример #11
0
 public TabViewModel(IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _messagePresenter = messagePresenter;
     AddCommand        = new RelayCommand(Add);
     InsertCommand     = new RelayCommand(Insert, CanInsert, this);
     RemoveCommand     = new RelayCommand(Remove, CanRemove, this);
 }
 public SnackbarViewModel(IToastPresenter toastPresenter, IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(toastPresenter, "toastPresenter");
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _toastPresenter           = toastPresenter;
     _messagePresenter         = messagePresenter;
     ShowSnackbarCommand       = new RelayCommand(ShowSnackbar);
     ShowSnackbarActionCommand = new RelayCommand(ShowSnackbarAction);
 }
 public TableViewModel(IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _messagePresenter      = messagePresenter;
     AddCommand             = new RelayCommand(Add);
     ItemClickCommand       = new RelayCommand <TableItemModel>(ItemClick);
     RemoveCommand          = new RelayCommand <TableItemModel>(Remove, CanRemove, this);
     InvertSelectionCommand = new RelayCommand(InvertSelection);
 }
 public SnackbarViewModel(IToastPresenter toastPresenter, IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(toastPresenter, "toastPresenter");
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _toastPresenter = toastPresenter;
     _messagePresenter = messagePresenter;
     ShowSnackbarCommand = new RelayCommand(ShowSnackbar);
     ShowSnackbarActionCommand = new RelayCommand(ShowSnackbarAction);
 }
 public TableViewModel(IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _messagePresenter = messagePresenter;
     AddCommand = new RelayCommand(Add);
     ItemClickCommand = new RelayCommand<TableItemModel>(ItemClick);
     RemoveCommand = new RelayCommand<TableItemModel>(Remove, CanRemove, this);
     InvertSelectionCommand = new RelayCommand(InvertSelection);
 }
        public UserWorkspaceViewModel(IUserRepository userRepository, IMessagePresenter messagePresenter)
        {
            Should.NotBeNull(userRepository, "userRepository");
            Should.NotBeNull(messagePresenter, "messagePresenter");
            _userRepository   = userRepository;
            _messagePresenter = messagePresenter;

            AddUserCommand    = new RelayCommand(AddUser, CanAddUser, this);
            RemoveUserCommand = new RelayCommand(RemoveUser, CanRemoveUser, this);
        }
Пример #17
0
 public MainViewModel(IToastPresenter toastPresenter, IMessagePresenter messagePresenter)
 {
     _toastPresenter       = toastPresenter;
     _messagePresenter     = messagePresenter;
     ShowDialogCommand     = new AsyncRelayCommand(ShowDialogAsync);
     ShowPageCommand       = new AsyncRelayCommand(ShowPageAsync);
     ShowBackgroundCommand = new AsyncRelayCommand(ShowBackgroundAsync);
     ShowTabsCommand       = new AsyncRelayCommand(ShowTabsAsync);
     ShowResultCommand     = new AsyncRelayCommand(ShowResultAsync);
 }
        public UserWorkspaceViewModel(IUserRepository userRepository, IMessagePresenter messagePresenter)
        {
            Should.NotBeNull(userRepository, nameof(userRepository));
            Should.NotBeNull(messagePresenter, nameof(messagePresenter));
            _userRepository   = userRepository;
            _messagePresenter = messagePresenter;

            AddUserCommand    = new RelayCommand(AddUser, CanAddUser, this);
            RemoveUserCommand = RelayCommandBase.FromAsyncHandler(RemoveUser, CanRemoveUser, this);
        }
Пример #19
0
        public SensorHistoryVm(ICurrentWeatherDataProvider currentWeatherDataProvider, IToastPresenter toastPresenter, IMessagePresenter messagePresenter)
        {
            _currentWeatherDataProvider = currentWeatherDataProvider;
            _toastPresenter             = toastPresenter;
            _messagePresenter           = messagePresenter;

            RefreshCommand       = new RelayCommand(Refresh);
            LoadMoreItemsCommand = new RelayCommand(LoadMoreItems);
            Items = new SynchronizedNotifiableCollection <SensorHistoryData>();
        }
        public UserWorkspaceViewModel(IUserRepository userRepository, IMessagePresenter messagePresenter)
        {
            Should.NotBeNull(userRepository, "userRepository");
            Should.NotBeNull(messagePresenter, "messagePresenter");
            _userRepository = userRepository;
            _messagePresenter = messagePresenter;

            AddUserCommand = new RelayCommand(AddUser, CanAddUser, this);
            RemoveUserCommand = RelayCommandBase.FromAsyncHandler(RemoveUser, CanRemoveUser, this);
        }
Пример #21
0
 public ChildViewModel(IMessagePresenter messagePresenter)
 {
     if (messagePresenter == null)
     {
         throw new ArgumentNullException("messagePresenter");
     }
     _messagePresenter = messagePresenter;
     _applyCommand     = new MvxCommand(Apply, CanApply);
     _closeCommand     = new MvxCommand(Close);
 }
Пример #22
0
        IEnumerator CameraShakeCoroutine(IMessagePresenter messagePresenter)
        {
            messagePresenter.Interactable = false;
            cameraShakeAnimator.Play("CameraShake");
            while (cameraShakeAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1.0f)
            {
                yield return(null);
            }

            messagePresenter.Interactable = true;
        }
Пример #23
0
        public Result InstallOrUpgrade(string version, IMessagePresenter presenter)
        {
            if (!_installer.IsStaged(version))
            {
                var errorMessage = $"Could not install {_name} {version} because it is not yet staged. Stage it first, then install it.";
                presenter.ShowMessage(errorMessage);
                return(Result.Failure(errorMessage));
            }
            var  productInstallerMetaData = FindProductInstallationMetaData();
            bool isInstalled = productInstallerMetaData != null;

            if (isInstalled)
            {
                if (VersionMatcher.DoVersionsMatch(version, InstalledVersion.ToString()))
                {
                    presenter.ShowMessage($"Since {productInstallerMetaData.DisplayName} is already installed at the same version, we won't install it");
                    return(Result.Successful());
                }
                presenter.ShowMessage(
                    $"Since {productInstallerMetaData.DisplayName} is already installed, uninstalling it");
                var uninstallResult = _installer.Uninstall(ProductCode);
                if (uninstallResult.IsFailed)
                {
                    presenter.ShowMessage($"Uninstall failed, so {_name} cannot be installed on this machine");
                    return(uninstallResult);
                }
                if (IsInstalled)
                {
                    presenter.ShowMessage(
                        $"{_name} is still installed on this machine after the uninstall, so we cannot install");
                    return(Result.Failure($"Uninstall of {_name} failed"));
                }
            }
            else
            {
                presenter.ShowMessage($"{_name} is not installed, so installing it for the first time");
            }
            presenter.ShowMessage($"Installing {_name} {version}");
            var result = _installer.Install(version);

            if (result.IsFailed)
            {
                Logger.Info($"Could not install {_name} {version} because of an error: {result}");
                presenter.ShowMessage($"Could not install {_name} {version}. Make sure your server is running as an administrator");
            }
            else if (!IsInstalled)
            {
                presenter.ShowMessage($"Installer for {_name} {version} ran successfully, but it is still not installed. Make sure your server has rights to install {_name} for all users (Administrator rights).");
                return(Result.Failure(
                           $"Expecting {_name} to be installed after running the installer, but it is not installed"));
            }
            Logger.Info($"Result of install {_name} {version} is {result}");
            return(result);
        }
Пример #24
0
 public void CameraShake(IMessagePresenter messagePresenter, bool wait)
 {
     if (wait)
     {
         StartCoroutine(CameraShakeCoroutine(messagePresenter));
     }
     else
     {
         cameraShakeAnimator.Play("CameraShake");
     }
 }
Пример #25
0
        private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            var mvm = AppContext.Current.GetServiceViaLocator <MainVModel>();
            IMessagePresenter statusUi = mvm.Status;

            if ((mvm.ActiveWorkspace != null) && (mvm.ActiveWorkspace.Status != null))
            {
                statusUi = mvm.ActiveWorkspace.Status;
            }
            statusUi.SetError(e.Exception.ToShortMsg(), e.Exception);
            e.Handled = true;
        }
        public CompositeViewModel(IMessagePresenter messagePresenter)
        {
            Should.NotBeNull(messagePresenter, "messagePresenter");
            _messagePresenter = messagePresenter;

            _firstNestedViewModel             = GetViewModel <CompositeNestedViewModel>();
            _firstNestedViewModel.DisplayName = "First nested view model";

            _secondNestedViewModel = GetViewModel(container => new CompositeNestedViewModel {
                DisplayName = "Second nested view model"
            });

            _thirdNestedViewModel = new CompositeNestedViewModel {
                DisplayName = "Third nested view model"
            };
            ViewModelProvider.InitializeViewModel(_thirdNestedViewModel, DataContext.Empty);
        }
        public ProductWorkspaceViewModel(IRepository repository, IMessagePresenter messagePresenter,
            IToastPresenter toastPresenter)
        {
            Should.NotBeNull(repository, "repository");
            Should.NotBeNull(messagePresenter, "messagePresenter");
            Should.NotBeNull(toastPresenter, "toastPresenter");
            _repository = repository;
            _messagePresenter = messagePresenter;
            _toastPresenter = toastPresenter;
            _trackingCollection = new TrackingCollection(new CompositeEqualityComparer().AddComparer(ProductModel.KeyComparer));

            SaveChangesCommand = RelayCommandBase.FromAsyncHandler(SaveChanges, CanSaveChanges, this);
            AddProductCommand = RelayCommandBase.FromAsyncHandler(AddProduct);
            EditProductCommand = RelayCommandBase.FromAsyncHandler<ProductModel>(EditProduct, CanEditProduct, this);
            RemoveProductCommand = RelayCommandBase.FromAsyncHandler<ProductModel>(RemoveProduct, CanRemoveProduct, this);
            DisplayName = UiResources.ProductWorkspaceName;
        }
Пример #28
0
        IEnumerator ShakeActorCoroutine(IMessagePresenter messagePresenter, IActor actor)
        {
            messagePresenter.Interactable = false;
            actor.Shake();

            while (!actor.PlayingAnimationIsName("ActorShake"))
            {
                yield return(null);
            }

            while (actor.isPlayingShakeAnimation)
            {
                yield return(null);
            }

            messagePresenter.Interactable = true;
        }
Пример #29
0
        public Result Run(IMessagePresenter presenter, IChefBootstrapper chefBootstrapper)
        {
            presenter.ShowMessage($"Running chef {chefBootstrapper}");
            chefBootstrapper.PrepareEnvironmentForChefRun();
            var process = _processCreator();

            process.LogEntryReceived += (sender, entry) =>
            {
                presenter.ShowMessage(entry.Entry);
                entry.Log();
            };
            var argumentsForChefRun = chefBootstrapper.ArgumentsForChefRun();
            var result = process.Run(argumentsForChefRun);

            presenter.ShowMessage($"Finished running chef with result: {result}");
            return(result);
        }
        public ProductWorkspaceViewModel(IRepository repository, IMessagePresenter messagePresenter,
                                         IToastPresenter toastPresenter)
        {
            Should.NotBeNull(repository, "repository");
            Should.NotBeNull(messagePresenter, "messagePresenter");
            Should.NotBeNull(toastPresenter, "toastPresenter");
            _repository         = repository;
            _messagePresenter   = messagePresenter;
            _toastPresenter     = toastPresenter;
            _trackingCollection = new TrackingCollection(new CompositeEqualityComparer().AddComparer(ProductModel.KeyComparer));

            SaveChangesCommand   = RelayCommandBase.FromAsyncHandler(SaveChanges, CanSaveChanges, this);
            AddProductCommand    = RelayCommandBase.FromAsyncHandler(AddProduct);
            EditProductCommand   = RelayCommandBase.FromAsyncHandler <ProductModel>(EditProduct, CanEditProduct, this);
            RemoveProductCommand = RelayCommandBase.FromAsyncHandler <ProductModel>(RemoveProduct, CanRemoveProduct, this);
            DisplayName          = UiResources.ProductWorkspaceName;
        }
        public ProductWorkspaceViewModel(IRepository repository, IMessagePresenter messagePresenter,
                                         IToastPresenter toastPresenter)
        {
            Should.NotBeNull(repository, "repository");
            Should.NotBeNull(messagePresenter, "messagePresenter");
            Should.NotBeNull(toastPresenter, "toastPresenter");
            _repository         = repository;
            _messagePresenter   = messagePresenter;
            _toastPresenter     = toastPresenter;
            _trackingCollection = new TrackingCollection();

            SaveChangesCommand   = new RelayCommand(SaveChanges, CanSaveChanges, this);
            AddProductCommand    = new RelayCommand(AddProduct);
            EditProductCommand   = new RelayCommand <ProductModel>(EditProduct, CanEditProduct, this);
            RemoveProductCommand = new RelayCommand <ProductModel>(RemoveProduct, CanRemoveProduct, this);
            DisplayName          = UiResources.ProductWorkspaceName;
        }
Пример #32
0
        public Result InstallOrUpgrade(string version, IMessagePresenter presenter)
        {
            string cafeStaging = Path.Combine(_updaterDirectory, "staging");
            var    installer   = _resolver.FullPathToStagedInstaller(version);

            if (!_commands.FileExists(installer))
            {
                Logger.Error("File is not staged at {installer}. Run download first");
                return(Result.Failure(
                           $"Could not install cafe {version} because there is no installer staged at {installer}. Run download first."));
            }
            Logger.Info($"Copying {installer} to {cafeStaging} to be processed by the updater");
            File.Copy(installer, Path.Combine(cafeStaging, Path.GetFileName(installer)));

            Logger.Info($"This service will stop soon and be updated to version {version}");
            return(Result.Successful());
        }
Пример #33
0
        public Result Run(IMessagePresenter presenter, IRunChefPolicy runChefPolicy)
        {
            presenter.ShowMessage($"Running chef {runChefPolicy}");
            runChefPolicy.PrepareEnvironmentForChefRun();
            var process = _processCreator();

            process.LogEntryReceived += (sender, entry) =>
            {
                Logger.Debug($"Received log message from chef run: {entry.Entry}");
                presenter.ShowMessage(entry.Entry);
                entry.Log();
            };
            var argumentsForChefRun = runChefPolicy.ArgumentsForChefRun();
            var result = process.Run(argumentsForChefRun);

            presenter.ShowMessage($"Finished running chef with result: {result}");
            return(result);
        }
Пример #34
0
        public Result Download(string version, IMessagePresenter messagePresenter)
        {
            messagePresenter.ShowMessage("Ensuring staging directory exists");
            _fileSystem.EnsureDirectoryExists(StagingDirectory);
            var destination = FullPathToStagedInstaller(version, _prefix);

            if (_fileSystem.FileExists(destination))
            {
                messagePresenter.ShowMessage($"Download msi already exists, so not downloading again");
                return(Result.Successful());
            }
            var downloadLink = DownloadUriFor(version, _product, _prefix, _target);

            messagePresenter.ShowMessage($"Downloading {_product} {version} from {downloadLink}");
            var result = _fileDownloader.Download(downloadLink, destination);

            messagePresenter.ShowMessage($"Finished downloading {_product} {version} from {downloadLink}");
            Logger.Info(result);
            return(result.TranslateIfFailed($"Installer for {_product} {version} could not be found at {downloadLink}"));
        }
        public MainViewModel(IViewModelPresenter viewModelPresenter, IToastPresenter toastPresenter, IMessagePresenter messagePresenter)
        {
            Should.NotBeNull(viewModelPresenter, "viewModelPresenter");
            Should.NotBeNull(toastPresenter, "toastPresenter");
            Should.NotBeNull(messagePresenter, "messagePresenter");
            _viewModelPresenter = viewModelPresenter;
            _toastPresenter = toastPresenter;
            _messagePresenter = messagePresenter;
            ShowFirstWindowCommand = RelayCommandBase.FromAsyncHandler(ShowFirstWindow);
            ShowSecondWindowCommand = RelayCommandBase.FromAsyncHandler(ShowSecondWindow);
            ShowFirstTabCommand = RelayCommandBase.FromAsyncHandler(ShowFirstTab);
            ShowSecondTabCommand = RelayCommandBase.FromAsyncHandler(ShowSecondTab);
            ShowFirstPageCommand = RelayCommandBase.FromAsyncHandler(ShowFirstPage);
            ShowSecondPageCommand = RelayCommandBase.FromAsyncHandler(ShowSecondPage);
            ShowBackStackPageCommand = RelayCommandBase.FromAsyncHandler(ShowBackStackPage);

            //NOTE The DynamicMultiViewModelPresenter allows to use the current view model as presenter.
            _presenter = new DynamicMultiViewModelPresenter(this);
            viewModelPresenter.DynamicPresenters.Add(_presenter);
        }
Пример #36
0
        public CookPresenter(
            IOperation operation,
            ICookView view,
            IMessagePresenter messagePresenter)
        {
            if (operation == null)
            {
                throw new ArgumentNullException("operation");
            }
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            this.Operation        = operation;
            this.View             = view;
            this.MessagePresenter = messagePresenter;

            this.View.BuyDrinkClicked += View_DrinkClicked;
        }
        public MainViewModel(IViewModelPresenter viewModelPresenter, IToastPresenter toastPresenter, IMessagePresenter messagePresenter)
        {
            Should.NotBeNull(viewModelPresenter, "viewModelPresenter");
            Should.NotBeNull(toastPresenter, "toastPresenter");
            Should.NotBeNull(messagePresenter, "messagePresenter");
            _viewModelPresenter      = viewModelPresenter;
            _toastPresenter          = toastPresenter;
            _messagePresenter        = messagePresenter;
            ShowFirstWindowCommand   = RelayCommandBase.FromAsyncHandler(ShowFirstWindow);
            ShowSecondWindowCommand  = RelayCommandBase.FromAsyncHandler(ShowSecondWindow);
            ShowFirstTabCommand      = RelayCommandBase.FromAsyncHandler(ShowFirstTab);
            ShowSecondTabCommand     = RelayCommandBase.FromAsyncHandler(ShowSecondTab);
            ShowFirstPageCommand     = RelayCommandBase.FromAsyncHandler(ShowFirstPage);
            ShowSecondPageCommand    = RelayCommandBase.FromAsyncHandler(ShowSecondPage);
            ShowBackStackPageCommand = RelayCommandBase.FromAsyncHandler(ShowBackStackPage);

            //NOTE The DynamicMultiViewModelPresenter allows to use the current view model as presenter.
            _presenter = new DynamicMultiViewModelPresenter(this);
            viewModelPresenter.DynamicPresenters.Add(_presenter);
        }
Пример #38
0
        public CookPresenter(
            IOperation operation,
            ICookView view,
            IMessagePresenter messagePresenter)
        {
            if(operation == null)
            {
                throw new ArgumentNullException("operation");
            }
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            this.Operation = operation;
            this.View = view;
            this.MessagePresenter = messagePresenter;

            this.View.BuyDrinkClicked += View_DrinkClicked;
        }
 public SecondViewModel(IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _messagePresenter = messagePresenter;
     DisplayName = "Second view model";
 }
 public FirstViewModel(IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _messagePresenter = messagePresenter;
     DisplayName = "First view model";
 }
 public ModalViewModel(IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _messagePresenter = messagePresenter;
     NavigateCommand = new RelayCommand(Navigate);
 }