Exemple #1
0
 public BuyViewModel(IStockService stockService, IBuyStockService buyStockService)
 {
     _stockService = stockService;
     _buyStockService = buyStockService;
     SearchSymbolCommand = new RelayCommand<string>((s) => SearchSymbolCmd(s));
     BuyStockCommand = new RelayCommand(BuyStockCmd);
 }
Exemple #2
0
        public void InitializeCommands(bool IsWarning)
        {
            isWarning = IsWarning;

            CancelCommand  = new RelayCommand(e => Close());
            ProceedCommand = new RelayCommand(e => Proceed());
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public UndoRedoStack()
            : base()
        {
            this.UndoCommand = new RelayCommand(() => {
                if (UndoStack.Count > 0)
                {
                    var cmd = UndoStack.Pop();
                    RedoStack.Push(cmd);
                    cmd.Undo();
                    CanExecuteChanged();
                }
            },
                                                () => UndoStack.Count > 0);

            this.RedoCommand = new RelayCommand(() => {
                if (RedoStack.Count > 0)
                {
                    var cmd = RedoStack.Pop();
                    UndoStack.Push(cmd);
                    cmd.Redo();
                    CanExecuteChanged();
                }
            },
                                                () => RedoStack.Count > 0);

            this.AddSavePointCommand        = new RelayCommand <string>(AddSavePoint, text => this.UndoStack.Count > 0 && !this.UndoStack.First().IsSavePoint);
            this.RollbackToSavePointCommand = new RelayCommand(RollbackSavePoint, () => {
                return(this.UndoStack.Any(cmd => cmd.IsSavePoint)
                    ? this.UndoStack.Multiple(c => c.IsSavePoint) ? true : !this.UndoStack.First().IsSavePoint
                    : false);
            });
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowViewModelBase"/> class
        /// with the specified window.
        /// </summary>
        /// <param name="window">The window that this view model controls.</param>
        public WindowViewModelBase(Window window)
        {
            mWindow = window;

            MinimizeCommand = new RelayCommand(p => mWindow.WindowState = WindowState.Minimized);
            CloseCommand    = new RelayCommand(p => mWindow.Close());
        }
Exemple #5
0
        public CoursePageViewModel()
        {
            this.CategoryCourseList = new ObservableCollection <CategoryItem>
            {
                new CategoryItem("全部", true),
                new CategoryItem("课程1", false),
                new CategoryItem("课程2", false),
                new CategoryItem("课程3", false),
                new CategoryItem("课程4", false),
            };
            this.CategoryskillList = new ObservableCollection <CategoryItem>
            {
                new CategoryItem("全部", true),
                new CategoryItem("技术1", false),
                new CategoryItem("技术2", false),
                new CategoryItem("技术3", false),
                new CategoryItem("技术4", false),
            };

            // 取出所有的老师名称
            IUserSevice userSvc = new UserSevice();

            this.CategoryTeacherList = new ObservableCollection <CategoryItem>();
            CategoryTeacherList.Add(new CategoryItem("全部", true));
            foreach (var name in userSvc.GetTeacher())
            {
                CategoryTeacherList.Add(new CategoryItem(name, false));
            }

            InitCourseList();

            this.TeacherFilter = new RelayCommand <object>(o => DoTeacherFilterCmd(o));
        }
Exemple #6
0
 /// <summary>
 /// Invokes <see cref="IRelayCommand.NotifyCanExecuteChanged"/> when a requery is requested.
 /// </summary>
 /// <param name="command">The target <see cref="IRelayCommand"/> instance.</param>
 /// <param name="dummy">The dummy object used to intercept mutual invocation.</param>
 private static void CommandManager_RequerySuggested(IRelayCommand command, object dummy)
 {
     lock (dummy)
     {
         command.NotifyCanExecuteChanged();
     }
 }
        public MainViewModel(IEventBus eventBus, IVersionProvider versionProvider, IProjectService projectService,
                             INewProjectDialogViewModelFactory newProjectDialogViewModelFactory, IEnumerable <Tool> tools, ICompositeDocumentFactory compositeDocumentFactory)
        {
            _versionProvider = versionProvider;
            _projectService  = projectService;
            _newProjectDialogViewModelFactory = newProjectDialogViewModelFactory;
            _compositeDocumentFactory         = compositeDocumentFactory;

            foreach (var tool in tools)
            {
                ToolsViewModels.Add(tool.CreateViewModel());
            }

            _currentProjectName = CreateProperty <string>(nameof(CurrentProjectName));
            _applicationTitle   = CreateComputedProperty(nameof(ApplicationTitle), _currentProjectName, currentProjectName =>
            {
                var prefix = string.IsNullOrEmpty(currentProjectName) ? string.Empty : $"{CurrentProjectName} - ";
                return($"{prefix}Geisha Editor {ApplicationVersion}");
            });

            NewProjectCommand    = RelayCommand.Create(NewProject);
            OpenProjectCommand   = RelayCommand.Create(OpenProject);
            _closeProjectCommand = RelayCommand.Create(CloseProject, CanCloseProject);
            SaveCommand          = RelayCommand.Create(Save);
            ExitCommand          = RelayCommand.Create(Exit);

            _projectService.CurrentProjectChanged += ProjectServiceOnCurrentProjectChanged;

            eventBus.RegisterEventHandler <OpenFileEditorRequestedEvent>(OpenFileEditorRequestedEventHandler);
        }
Exemple #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ModalBase"/> class.
        /// </summary>
        public ModalBase()
        {
            mDialogWindow = new ModalWindow();

            // Create the default close command by marking the modal as confirmed
            CloseCommand = new RelayCommand(p => mDialogWindow.DialogResult = true);
        }
Exemple #9
0
 public BookViewModel(IContactDataService dataService, IDialogService dialogService)
 {
     _dataService         = dataService;
     _dialogService       = dialogService;
     this.ContactsVM      = new ContactsViewModel(dataService, dialogService);
     LoadContactsCommand  = new RelayCommand(LoadContacts);
     LoadFavoritesCommand = new RelayCommand(LoadFavorites);
 }
Exemple #10
0
 public MainViewModel()
 {
     this.UserInfo       = new User();
     TabSwitchCommand    = new RelayCommand <string>((text) => TabSwitchCmd(text));
     SiderbarShowCommand = new RelayCommand(SiderbarShowCmd);
     // 程序加载时, 直接载入首页
     TabSwitchCmd("HomePageView");
 }
Exemple #11
0
 private void SetupCommands()
 {
     AddColorCommand    = RelayCommandFactory.CreateRelayCommand(ExecuteAddColorCommand);
     RemoveColorCommand = RelayCommandFactory.CreateRelayCommand(ExecuteRemoveColorCommand);
     MoveUpCommand      = RelayCommandFactory.CreateRelayCommand(ExecuteMoveUpCommand);
     MoveDownCommand    = RelayCommandFactory.CreateRelayCommand(ExecuteMoveDownCommand);
     OkCommand          = RelayCommandFactory.CreateRelayCommand(ExecuteOkCommand);
 }
        public Game1(IRelayCommand MainProcess)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            if (MainProcess == null)
                throw new NullReferenceException("Game was not called by the controller");

            this.MainProcess = MainProcess;
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }
 public AddChildViewModel()
 {
     AddChildCommand               = new RelayCommand <Child>(AddChild);
     LoadImageFromFileCommand      = new RelayCommand(LoadImageFromFile);
     CaptureImageFromCameraCommand = new RelayCommand(CaptureImageFromCamera);
     OpenImageChoosingCommand      = new RelayCommand(OpenImageChoosing);
     RemoveImageCommand            = new RelayCommand(RemoveImage);
     ChooseParentCommand           = new RelayCommand <Parents>(ChooseParent);
     DetachParentCommand           = new RelayCommand <Parents>(DetachParent);
 }
Exemple #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TileViewModel"/> class
        /// with the specified row, column and state.
        /// </summary>
        /// <param name="row">The row in which this tile is in.</param>
        /// <param name="column">The column in which this tile is in.</param>
        /// <param name="state">The state of this tile.</param>
        public TileViewModel(int row, int column, int adjacentBombs, TileState state)
        {
            Row           = row;
            Column        = column;
            AdjacentBombs = adjacentBombs;
            State         = state;

            UncoverCommand    = new RelayCommand(p => OnTileUncovering());
            ToggleMarkCommand = new RelayCommand(p => OnTileToggledMark());
        }
Exemple #15
0
 public StartWindowViewModel(IWindowsManager windowsManager,
                             IFileSystemViewModelFactory fileSystemViewModelFactory,
                             IRelayCommandFactory commandFactory)
     : base(windowsManager)
 {
     _fileSystemViewModelFactory = fileSystemViewModelFactory;
     CreateDriveCommand          = commandFactory.Create(createDriveExec);
     OpenDriveCommand            = commandFactory.Create(openDriveExec);
     ExitCommand = commandFactory.Create(exitExec);
 }
Exemple #16
0
 public LoginViewModel()
 {
     // 传过来的参数是window对象
     CloseWindowsCommand = new RelayCommand <object>(o => CloseWindowsCmd(o));
     LoginCommand        = new RelayCommand <object>(o => DoLogin(o));
     this.Login          = new User
     {
         UserName = "******",
         Password = "******"
     };
 }
Exemple #17
0
        public MyScreenLogic(IService service, IViewBox viewBox)
        {
            _service = service;
            _viewBox = viewBox;
            Title    = "My screen";

            BrowseCommand = new RelayCommand(ExecuteBrowseCommand)
            {
                Name = "..."
            };
        }
 public ContactsViewModel(IContactDataService dataService, IDialogService dialogService)
 {
     _dataService       = dataService;
     _dialogService     = dialogService;
     AddCommand         = new RelayCommand(Add);
     EditCommand        = new RelayCommand(Edit);
     DeleteCommand      = new RelayCommand(Delete);
     UpdateCommand      = new RelayCommand(Update);
     SaveCommand        = new RelayCommand(Save);
     BrowseImageCommand = new RelayCommand(BrowseImage);
 }
Exemple #19
0
 /// <summary>
 /// Creates a new <see cref="SubscriptionData"/> instance with the specified parameters.
 /// </summary>
 /// <param name="command">The <see cref="IRelayCommand"/> instance in use.</param>
 /// <param name="dummy">T</param>
 /// <param name="commandManagerHandler">The <see cref="EventHandler"/> for <see cref="CommandManager"/>.</param>
 /// <param name="commandHandler">The <see cref="EventHandler"/> for <see cref="IRelayCommand"/>.</param>
 public SubscriptionData(
     IRelayCommand command,
     object dummy,
     EventHandler commandManagerHandler,
     EventHandler commandHandler)
 {
     Command = command;
     Dummy   = dummy;
     CommandManagerHandler = commandManagerHandler;
     CommandHandler        = commandHandler;
 }
Exemple #20
0
 public SetupPage()
 {
     InitializeComponent();
     SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
     if (ViewHelper.IsIot)
     {
         GoBack = new RelayCommand(NavigateBack);
     }
     SaveAsDefault = new RelayCommand(async() => await ExecuteSaveAsDefault());
     _viewModel    = new SetupViewModel(this);
     DataContext   = _viewModel;
 }
Exemple #21
0
 // Constructor
 public ConfigurationViewModel()
 {
     _alarmRepository            = new AlarmRepository();
     _panelsRepository           = new PanelRepository();
     _alarmMapping               = _alarmRepository.GetAllAlarmMapping().ToObservableCollection();
     ConfigureConnectionsCommand = new RelayCommand(ConfigureConnections, CanConfigure);
     AlarmMapCommand             = new RelayCommand(MapAlarm, CanMapAlarm);
     RemoveAlarmMapCommand       = new RelayCommand(RemoveAlarmMap);
     SaveCommand   = new RelayCommand(SaveAlarmMapping);
     dialogService = new DialogService();
     LoadData();
 }
        public MonitorPage()
        {
            InitializeComponent();
            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
            if (ViewHelper.IsIot)
            {
                GoBack = new RelayCommand(NavigateBack);
            }

            if (DesignMode.DesignMode2Enabled)
            {
                ViewModel = new MonitorViewModelDesignData();
                DataContext = ViewModel;
            }
        }
 public ActiveTrackViewModel(
     Sound s,
     IRelayCommand <Sound> removeCommand,
     IMixMediaPlayerService player,
     IUserSettings userSettings)
 {
     Guard.IsNotNull(s, nameof(s));
     Guard.IsNotNull(player, nameof(player));
     Guard.IsNotNull(removeCommand, nameof(removeCommand));
     Guard.IsNotNull(userSettings, nameof(userSettings));
     _userSettings = userSettings;
     Sound         = s;
     _player       = player;
     RemoveCommand = removeCommand;
     Volume        = _userSettings.Get($"{Sound.Id}:volume", 100d);
 }
        public DirectoryCleaner()
        {
            directoriesToRemove = new ObservableCollection <string>
            {
                "bin",
                "obj"
            };

            removedDirectories = new ObservableCollection <string>();

            SelectCommand = new RelayCommand(() => SelectDirectory());
            AddDirectoryToRemoveCommand = new RelayCommand <string>((t) => AddDirectoryToRemove(t));

            CleanCommand = new RelayCommand(() => Clean(), () => BaseDirectory != null)
                           .ObserveProperty(() => BaseDirectory);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationViewModel"/> class.
        /// </summary>
        public ApplicationViewModel()
        {
            // Listen for user settings changed
            UserSettings.PropertyChanged += (o, e) =>
            {
                // If the application theme was changed, make sure to update it across the application
                if (e.PropertyName.Equals(nameof(UserSettingsViewModel.Theme)))
                {
                    OnThemeChanged(UserSettings.Theme);
                }
            };

            ChangeThemeCommand = new RelayCommand(p =>
            {
                // Change to the non-current theme
                UserSettings.Theme = UserSettings.Theme == ApplicationTheme.Light ? ApplicationTheme.Dark : ApplicationTheme.Light;
            });
        }
Exemple #26
0
        public TeamStatisticsViewModel(ITeamClient teamClient, IStatisticsClient statisticsClient, ITimerService timerService, IEventAggregator eventAggregator, ICacheService cacheService)
        {
            _teamClient = teamClient;
            _statisticsClient = statisticsClient;
            timerService.Start(TimeSpan.FromSeconds(10), OnRefresh);
            _eventAggregator = eventAggregator;
            _cacheService = cacheService;

            Func<Boolean> canExecute = () =>
            {
                var password = new NetworkCredential(string.Empty, TeamPassword).Password;
                return !String.IsNullOrWhiteSpace(TeamName) && !TeamName.Contains(" ") &&
                       !String.IsNullOrWhiteSpace(password) && !password.Contains(" ");
            };

            AcceptExistingTeamCommand = new RelayCommand(OnAcceptExistingTeam, canExecute);
            CreateNewTeamCommand = new RelayCommand(OnCreateNewTeam, canExecute);
        }
Exemple #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GamePageViewModel"/> class with
        /// the specified game settings.
        /// </summary>
        /// <param name="parameter">The game settings.</param>
        public GamePageViewModel(GameSettings gameSettings)
        {
            // Initialize the stopwatch and run the timer that will update the time every second
            mStopWatch      = new Stopwatch();
            mTimer          = new Timer(1000);
            mTimer.Elapsed += (o, e) => ElapsedTime = mStopWatch.Elapsed;

            // Create the game field and listen for when the game is started and is over
            GameField              = new GameFieldViewModel(gameSettings);
            GameField.GameStarted += (o, e) =>
            {
                // Start measuring the time when the game starts
                mStopWatch.Start();
                mTimer.Start();
            };
            GameField.GameOver += async(o, e) =>
            {
                // Stop measuring the time when the game is over
                mStopWatch.Stop();
                mTimer.Stop();

                // Show a modal with content based on the game result
                ConfirmModalViewModel modalViewModel;
                if (e.PlayerWon)
                {
                    modalViewModel = new ConfirmModalViewModel("Congratulations", "You successfully finished the game", "OK");
                }
                else
                {
                    modalViewModel = new ConfirmModalViewModel("Game Over", "You clicked on a bomb", "OK");
                }

                // And wait until the modal is exited
                var modalService = IoC.Get <IModalService>();
                await modalService.ShowConfirmModal(modalViewModel);

                // Handle game over
                OnGameOver();
            };

            ExitCommand = new RelayCommand(p => OnGameOver());
        }
Exemple #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StartPageViewModel"/> class.
        /// </summary>
        public StartPageViewModel()
        {
            // Set up the commands
            DecreaseWidthCommand  = new RelayCommand(p => GameSettingsViewModel.FieldWidth--);
            IncreaseWidthCommand  = new RelayCommand(p => GameSettingsViewModel.FieldWidth++);
            DecreaseHeightCommand = new RelayCommand(p => GameSettingsViewModel.FieldHeight--);
            IncreaseHeightCommand = new RelayCommand(p => GameSettingsViewModel.FieldHeight++);

            BeginnerDifficultyCommand     = new RelayCommand(p => GameSettingsViewModel = GameSettingsViewModel.BeginnerDifficulty);
            IntermediateDifficultyCommand = new RelayCommand(p => GameSettingsViewModel = GameSettingsViewModel.IntermediateDifficulty);
            ExpertDifficultyCommand       = new RelayCommand(p => GameSettingsViewModel = GameSettingsViewModel.ExpertDifficulty);

            PlayCommand = new RelayCommand(p =>
            {
                var router   = IoC.Get <IRouter>();
                var argument = new GameSettings(GameSettingsViewModel.FieldWidth, GameSettingsViewModel.FieldHeight, GameSettingsViewModel.NumberOfBombs);

                router.NavigateTo(Routes.GamePageRoute, argument);
            });
        }
        public BotDeploymentViewModel(IArenaClient arenaClient, IBotClient botClient, IDeploymentClient deploymentClient, IScriptClient scriptClient, IEventAggregator eventAggregator, IFileExplorerService fileExplorerService, IFileService fileService, ITimerService timerService, ICacheService cacheService)
        {
            _arenaClient         = arenaClient;
            _botClient           = botClient;
            _deploymentClient    = deploymentClient;
            _scriptClient        = scriptClient;
            _eventAggregator     = eventAggregator;
            _fileExplorerService = fileExplorerService;
            _fileService         = fileService;
            _cacheService        = cacheService;

            timerService.Start(TimeSpan.FromSeconds(5), RefreshArenas);

            SubscribeEvents(eventAggregator);

            SaveScriptCommand        = new RelayCommand(OnSaveScript);
            LoadScriptCommand        = new RelayCommand(OnLoadScript);
            ValidateBotScriptCommand = new RelayCommand(OnValidateBotScript);
            DeployBotCommand         = new RelayCommand(OnDeployBot,
                                                        () => SelectedArena != null && ScriptValid && (TimeUntilNextAllowedDeployment <= TimeSpan.Zero && (BotPhysicalHealth + BotStamina <= SelectedArena.MaximumPoints) /*|| CurrentTeam.Predator*/));
        }
Exemple #30
0
        public ButtonBinder(Button button, IRelayCommand command,
                            Func <object> getParameter = null, bool bindName      = true,
                            ToolTip toolTip            = null, string toolTipText = null)
        {
            _button       = button;
            _command      = command;
            _getParameter = getParameter;
            _bindName     = bindName;
            _toolTip      = toolTip;
            _toolTipText  = toolTipText;

            _button.Enabled = _command.CanExecute(getParameter?.Invoke());
            if (_bindName)
            {
                _button.Text = _command.Name;
            }
            toolTip?.SetToolTip(_button, toolTipText ?? _command.Name);

            _button.Click += OnButtonClick;
            _command.CanExecuteChanged += OnCommandCanExecuteChanged;
            _command.PropertyChanged   += OnCommandPropertyChanged;
            _button.Disposed           += OnButtonDisposed;
        }
 public ViewModel()
 {
     this.EnterCommand = new RelayCommand(EnterCommandExecuted, CanExecuteEnterCommand);
     this.MyList       = new ObservableCollection <string>();
 }
Exemple #32
0
 public IDialogBoxLauncherCommand Action(Action act, Func<bool> canExecute)
 {
     OnActionField = new RelayCommand(act, canExecute);
     return this;
 }
 private void RegisterCommands()
 {
     CloseCommand = new RelayCommand(p => Close());
     CheckinCommand = new RelayCommand(p => Checkin(), p => CanCheckin);
     CheckoutCommand = new RelayCommand(p => Checkout(), p => CanCheckout);
     StartProcessCommand = new RelayCommand(p => StartProcess(), p => CanStartProcess);
 }