Esempio n. 1
0
        public ClientViewModel(LinkedList <INavigableViewModel> navigation, ClientEntity clientEntity, LinkedListNode <INavigableViewModel> prevNode = null)
        {
            _pcs          = new PropertyChangeSupport(this);
            _navigation   = navigation;
            _clientEntity = clientEntity;
            _clientEntity.PropertyChanged += _clientChanged;
            _clientMode  = prevNode == null;
            _bookingMode = !_clientMode;

            if (_bookingMode)
            {
                _currentBookingVM = prevNode.Value as BookingViewModel;
            }

            _sumUpCommand      = new DelegateCommand <ClientViewModel>(_sumUp);
            _bookingCommand    = new DelegateCommand <ClientViewModel>(_booking);
            _saveClientCommand = new DelegateCommandAsync <ClientViewModel>(_saveClient);

            _unlockSaveAndSumUpIfNeeded();

            if (!_bookingMode)
            {
                _navigation.AddLast(this);
            }
            else
            {
                _navigation.AddAfter(prevNode, this);
            }
        }
        public MainPageViewModel(IOrdersService ordersService)
        {
            _ordersService = ordersService;

            LoadDataCommand = new DelegateCommandAsync(LoadData);
            Orders          = new ObservableCollection <GroupedOrder>();
        }
        public PurchaseTicketsViewModel() : base()
        {
            // TODO move this
            Task.Run(async() =>
            {
                var votePrefs = await FetchWalletVotingPreferences();
                VoteVersion   = votePrefs.Item1;
                AgendaChoices = votePrefs.Item2;
            }).Wait();

            var synchronizer = ViewModelLocator.SynchronizerViewModel as SynchronizerViewModel;

            if (synchronizer != null)
            {
                SelectedSourceAccount = synchronizer.Accounts[0];
            }

            ConfiguredStakePools = new ObservableCollection <IStakePoolSelection>(new List <IStakePoolSelection>
            {
                new NoStakePool(),
                new ManualStakePool(),
            });
            _selectedStakePool = ConfiguredStakePools[0];

            ManageStakePools            = new DelegateCommandAsync(ManageStakePoolsActionAsync);
            ManageStakePools.Executable = false; // Set true after pool listing is downloaded and configs are read.

            _purchaseTickets            = new DelegateCommand(PurchaseTicketsAction);
            _purchaseTickets.Executable = false;
        }
 public AuthorizationViewModel(IAuthorizationService authorizationService, IWindowFactory windowFactory, IDialogService dialogService)
 {
     _authorizationService = authorizationService;
     _windowFactory        = windowFactory;
     _dialogService        = dialogService;
     LogInCommand          = new DelegateCommandAsync(ExecutePrintResultAuthorization);
 }
        public BindingDemoViewModel(IMessageBoxService messageBoxService)
        {
            this._messageBoxService = messageBoxService;

            GreetCommand = new DelegateCommandAsync(
                new Func <object, Task>(GreetCommandImpl), () => !string.IsNullOrEmpty(GuestName));
        }
Esempio n. 6
0
        public BookingViewModel(LinkedList <INavigableViewModel> navigation, Booking booking, LinkedListNode <INavigableViewModel> prevNode = null)
        {
            _pcs                         = new PropertyChangeSupport(this);
            _navigation                  = navigation;
            _parameters                  = new BookingParametersViewModel(booking);
            _parameters.Defined         += _parameters_defined;
            _parameters.PropertyChanged += _parametersChanged;
            _parametersValidated         = false;
            _booking                     = booking;
            _clientEntity                = new ClientEntity(_booking.Client);
            _bookingEntity               = new BookingEntity(_booking);
            _clientEntity.Bookings.Add(_bookingEntity);
            _computeTitle(_clientEntity);
            _clientEntity.PropertyChanged += _clientChanged;

            _searchClientCommand    = new DelegateCommandAsync <BookingViewModel>(_searchClient, false);
            _newClientCommand       = new DelegateCommandAsync <BookingViewModel>(_newClient, false);
            _validateBookingCommand = new DelegateCommandAsync <BookingViewModel>(_validateBooking, false);

            if (prevNode == null)
            {
                _navigation.AddLast(this);
            }
            else
            {
                _navigation.AddAfter(prevNode, this);
            }
        }
        public async void PropertyChangedIsExecuting()
        {
            var cmd = new DelegateCommandAsync(executeMethod, canExecuteMethod);
            await Assert.PropertyChangedAsync(cmd, nameof(cmd.IsExecuting), () => cmd.ExecuteAsync());

            Assert.False(cmd.IsExecuting);
        }
Esempio n. 8
0
 public EmployeeListViewModel(IEmployeeService employeeService, IMapperWrapper mapperWrapper, IDepartmentService departmentService, IResourceManagerService resourceManagerService)
 {
     _employeeService        = employeeService;
     _mapperWrapper          = mapperWrapper;
     _departmentService      = departmentService;
     _resourceManagerService = resourceManagerService;
     CreateEmployeeCommand   = new DelegateCommandAsync(ExecuteCreateEmployee);
 }
Esempio n. 9
0
 public PassphraseDialogViewModel(ShellViewModel shell, string header, string buttonText, Func <string, Task <bool> > executeWithPassphrase)
     : base(shell)
 {
     Header      = header;
     ExecuteText = buttonText;
     _execute    = executeWithPassphrase;
     Execute     = new DelegateCommandAsync(ExecuteAction);
 }
        public async void ShouldCancel()
        {
            var cmd = new DelegateCommandAsync(executeMethod, canExecuteMethod);

            cmd.ExecuteAsync();
            cmd.Cancel();
            Assert.True(cmd.ObservableTask.IsCanceled);
        }
Esempio n. 11
0
        public LoginViewModel()
        {
            _pcs         = new PropertyChangeSupport(this);
            _loginResult = "";
            _resultReady = false;
            _title       = "Resotel - Login";

            _loadCommand  = new DelegateCommand <IUITimer>(_load);
            _loginCommand = new DelegateCommandAsync <object>(_loginCmd);
        }
Esempio n. 12
0
        public MainViewModel(IMessageBoxService messageBoxService)
        {
            _messageBoxService = messageBoxService;

            GoToBindingDemoCommand = new DelegateCommandAsync(new Func <object, Task>(GoToBindingDemo));
            GoToHomeCommand        = new DelegateCommandAsync(new Func <object, Task>(GoToHome));

            HomeVM           = new HomeViewModel();
            CurrentViewModel = HomeVM;
        }
Esempio n. 13
0
 public TrayViewModel(IAuthorizationService authorizationService, IWindowFactory windowFactory, IApplicationService applicationService, IWindowService windowService)
 {
     _authorizationService            = authorizationService;
     _windowFactory                   = windowFactory;
     _applicationService              = applicationService;
     _windowService                   = windowService;
     TransitionToMainCommand          = new DelegateCommandAsync(ExecuteTransitionToMainAsync);
     TransitionToAuthorizationCommand = new DelegateCommand.DelegateCommand(ExecuteTransitionToAuthorization);
     TransitionToExitCommand          = new DelegateCommand.DelegateCommand(ExecuteTransitionToExit);
 }
        public ServiceAccountingSettingsViewModel(AppSettings settings, IMainRegionService mainRegionService, IFileDialogService fileDialogService, IDialogService dialogService)
        {
            Settings = settings;
            this.fileDialogService = fileDialogService;
            MainRegionService      = mainRegionService;

            MainRegionService.Header = "Настройки учета услуг";

            SelectFileCommand = new DelegateCommandAsync(SelectFileExecute);
        }
Esempio n. 15
0
        public MacroViewModel(
            ILoggerService loggerService,
            IMonitorDialog monitorDialog,
            IFileService fileService,
            IMacroService macroService)
        {
            IsRunning   = false;
            SavedMacros = new ObservableCollection <IMacro>();

            _loggerService = loggerService;
            _monitorDialog = monitorDialog;
            _fileService   = fileService;
            _macroService  = macroService;

            Recorders = _macroService.CreateRecorders();

            Record = new DelegateCommandAsync(() =>
            {
                _runningRecordSession = _macroService.CreateSession(SelectedRecorder);
                _runningRecordSession?.Start();
                Stop.RaiseCanExecuteChanged();
                Record.RaiseCanExecuteChanged();
            },
                                              () => SelectedRecorder != null && _runningRecordSession == null);

            Stop = new DelegateCommandAsync(() =>
            {
                var macro             = _runningRecordSession.Stop();
                _runningRecordSession = null;
                SavedMacros.Add(macro);
                Stop.RaiseCanExecuteChanged();
                Record.RaiseCanExecuteChanged();
                Build.RaiseCanExecuteChanged();
            },
                                            () => _runningRecordSession != null);

            Build = new DelegateCommandAsync(async() =>
            {
                var macro = SavedMacros.First();
                SavedMacros.RemoveAt(0);

                Build.RaiseCanExecuteChanged();

                var saveResult = _monitorDialog.SaveFileDialog("Save script", "test_script.cs", "Monitor Script (*.cs)|*.cs;|All files (*.*)|*.*", null);
                if (saveResult.Success)
                {
                    using (var stream = _fileService.CreateNewFileStream(saveResult.FileName))
                    {
                        await macro.Serialize(stream);
                        _loggerService.LogMessage(this, $"Script built & saved '{saveResult.FileName}'!", Severity.Info);
                    }
                }
            },
                                             () => SavedMacros.Any());
        }
        public CommonSettingsViewModel(AppSettings settings, IMainRegionService mainRegionService)
        {
            Settings          = settings;
            MainRegionService = mainRegionService;

            MainRegionService.Header = "Общие настройки";

            TestCommand       = new DelegateCommandAsync(TestExecute);
            SetDefaultCommand = new DelegateCommand(SetDefaultExecute);
            MigrateDBCommand  = new DelegateCommandAsync(MigrateDBExecute);
        }
Esempio n. 17
0
        public MainViewModel()
        {
            _client           = new TraktClient(Constants.TraktId);
            SearchSuggestions = new OptimizedObservableCollection <TraktShow>();
            TrendyShows       = new OptimizedObservableCollection <TraktShow>();
            PopularShows      = new OptimizedObservableCollection <TraktShow>();
            Shows             = new OptimizedObservableCollection <TraktShow>();

            PullSearchSuggestionsCommand = new DelegateCommandAsync <bool>(PullSearchSuggestionAsync);
            PerformSearchQueryCommand    = new DelegateCommandAsync <TraktShow>(PerformSearchQueryAsync);
        }
Esempio n. 18
0
        public SyncableObject()
        {
            _modifiedProperties = new HashSet <string>();
            _resetCommands      = new Dictionary <string, IResetAction>();
            IsSynced            = true;

            PropertyChanged += OnPropertyChanged;

            SyncCommand      = new DelegateCommandAsync(Sync, () => !IsSynced);
            RevertAllCommand = new DelegateCommand(RevertAll, () => !IsSynced);
        }
 public EmployeeDetailsViewModel(IEmployeeService employeeService, IDepartmentService departmentService, IMapperWrapper mapperWrapper)
 {
     _employeeService            = employeeService;
     _departmentService          = departmentService;
     _mapperWrapper              = mapperWrapper;
     EditCommand                 = new DelegateCommand.DelegateCommand(ExecuteEditEmployee);
     CancelCommand               = new DelegateCommand.DelegateCommand(ExecuteCancel);
     SaveCommand                 = new DelegateCommandAsync(ExecuteSaveEmployee);
     OpenDeletePopupCommand      = new DelegateCommand.DelegateCommand(ExecuteOpenDeletePopup);
     DeleteEmployeeCommand       = new DelegateCommandAsync(ExecuteDeleteEmployee);
     CancelToListEmployeeCommand = new DelegateCommand.DelegateCommand(ExecuteCancelTolistEmployee);
 }
        public ManageStakePoolsDialogViewModel(ShellViewModelBase shell) : base(shell)
        {
            var synchronizer = ViewModelLocator.SynchronizerViewModel as SynchronizerViewModel;

            if (synchronizer != null)
            {
                SelectedVotingAccount = synchronizer.Accounts[0];
            }

            _saveCommand            = new DelegateCommandAsync(SaveCommandActionAsync);
            _saveCommand.Executable = false;
        }
        public async void IsExecutingTrueAndFalse()
        {
            var cmd = new DelegateCommandAsync(executeMethod, canExecuteMethod);

            Assert.False(cmd.IsExecuting);
            var t = cmd.ExecuteAsync();

            Assert.True(cmd.IsExecuting);
            await t;

            Assert.False(cmd.IsExecuting);
        }
Esempio n. 22
0
        public ClientBookingsViewModel(ClientEntity clientEntity)
        {
            _pcs = new PropertyChangeSupport(this);
            _clientEntity = clientEntity;
            _clientBookingsSource = CollectionViewProvider.Provider(clientEntity.Bookings);
            _clientBookingsView = _clientBookingsSource.View;
            Booking booking = default(Booking);
            _clientBookingsView.SortDescriptions.Add(new SortDescription($"{nameof(booking.Dates)}.{nameof(booking.Dates.Start)}", ListSortDirection.Ascending));
            _clientBookingsView.CurrentChanged += _clientBookingsView_currentChanged;

            _selectBookingCommand = new DelegateCommand<object>(_selectBooking);
            _cancelBookingCommand = new DelegateCommandAsync<object>(_cancelBooking);

            _clientBookingsView.Filter = _mustShowBooking;
        }
Esempio n. 23
0
        public ClientBookingsViewModel(ClientEntity clientEntity)
        {
            _pcs                  = new PropertyChangeSupport(this);
            _clientEntity         = clientEntity;
            _clientBookingsSource = CollectionViewProvider.Provider(clientEntity.Bookings);
            _clientBookingsView   = _clientBookingsSource.View;
            Booking booking = default(Booking);

            _clientBookingsView.SortDescriptions.Add(new SortDescription($"{nameof(booking.Dates)}.{nameof(booking.Dates.Start)}", ListSortDirection.Ascending));
            _clientBookingsView.CurrentChanged += _clientBookingsView_currentChanged;

            _selectBookingCommand = new DelegateCommand <object>(_selectBooking);
            _cancelBookingCommand = new DelegateCommandAsync <object>(_cancelBooking);

            _clientBookingsView.Filter = _mustShowBooking;
        }
Esempio n. 24
0
        public MainViewModel(AltitudeAngelService altitudeAngelService)
        {
            _altitudeAngelService = altitudeAngelService;
            SignInCommand         = new DelegateCommandAsync <object>(ExecuteConnect, true);
            DisconnectCommand     = new DelegateCommandAsync <object>(ExecuteDisconnect, true);
            SignInState           = new ObservableProperty <SignInStates>(SignInStates.NotSignedIn);
            PermitStatus          = new ObservableProperty <PermitStates>(PermitStates.NoPermit);
            TelemetryPulse        = new ObservableProperty <bool>();


            _altitudeAngelService.IsSignedIn
            .Subscribe(UpdateSignInState);

            _altitudeAngelService.WeatherReport
            .Subscribe(WeatherChanged);

            _altitudeAngelService.SentTelemetry
            .Subscribe(i => NewTelemetry());
        }
Esempio n. 25
0
        public MainWindowViewModel(UserEntity user)
        {
            Logger.Log("=Initialisation Fenêtre principale (post login)=");
            _pcs             = new PropertyChangeSupport(this);
            _user            = user;
            _currentEntities = new ObservableCollection <INavigableViewModel>();
            _title           = "Resotel - Facturation";
            _navigation      = new LinkedList <INavigableViewModel>();

            _addBookingCommand    = new DelegateCommand <object>(_addBooking);
            _closeBookingCommand  = new DelegateCommand <IEntity>(_closeBooking);
            _addClientCommand     = new DelegateCommand <object>(_addClient);
            _searchBookingCommand = new DelegateCommandAsync <object>(_searchBooking);
            _searchClientCommand  = new DelegateCommandAsync <object>(_searchClient);
            _logoutCommand        = new DelegateCommand <object>(_logOut);
            _nextCommand          = new DelegateCommand <BookingViewModel>(_next);
            _prevCommand          = new DelegateCommand <BookingViewModel>(_prev);
            Logger.Log("=fenêtre principale initialisée (post login)=");
        }
Esempio n. 26
0
        public MainViewModel(AltitudeAngelService altitudeAngelService)
        {
            _altitudeAngelService = altitudeAngelService;
            SignInCommand = new DelegateCommandAsync<object>(ExecuteConnect, true);
            DisconnectCommand = new DelegateCommandAsync<object>(ExecuteDisconnect, true);
            SignInState = new ObservableProperty<SignInStates>(SignInStates.NotSignedIn);
            PermitStatus = new ObservableProperty<PermitStates>(PermitStates.NoPermit);
            TelemetryPulse = new ObservableProperty<bool>();


            _altitudeAngelService.IsSignedIn
                                 .Subscribe(UpdateSignInState);

            _altitudeAngelService.WeatherReport
                                 .ObserveOnDispatcher()
                                 .Subscribe(WeatherChanged);

            _altitudeAngelService.SentTelemetry
                                 .Subscribe(i => NewTelemetry());
        }
Esempio n. 27
0
        public QueryVM(ServerConnection connection, string dbName)
        {
            Exec = new ExecQuery(connection, dbName);

            RunCommand = new DelegateCommandAsync(
                o => !IsRunning,
                ro =>
            {
                return(RunCmd());
            }
                );

            CancelCommand = new DelegateCommand(
                o => IsRunning,
                ro =>
            {
                Exec.Cancel();
                IsRunning = false;
            }
                );
        }
 public ImportScriptDialogViewModel(ShellViewModel shell) : base(shell)
 {
     _importScript            = new DelegateCommandAsync(ImportScriptAsync);
     _importScript.Executable = false;
 }
        public void CancelCommandShouldNotBeNull()
        {
            var cmd = new DelegateCommandAsync(executeMethod, canExecuteMethod);

            Assert.NotNull(cmd.CancelCommand);
        }
        public void IsExecutingShouldBeFalse()
        {
            var cmd = new DelegateCommandAsync(executeMethod, canExecuteMethod);

            Assert.False(cmd.IsExecuting);
        }
Esempio n. 31
0
 public MainViewModel()
 {
     SaveImageCommand = new DelegateCommandAsync<object>(SaveImageCommandDelegate);
 }
Esempio n. 32
0
        public BookingViewModel(LinkedList<INavigableViewModel> navigation, Booking booking, LinkedListNode<INavigableViewModel> prevNode = null)
        {
            _pcs = new PropertyChangeSupport(this);
            _navigation = navigation;
            _parameters = new BookingParametersViewModel(booking);
            _parameters.Defined += _parameters_defined;
            _parameters.PropertyChanged += _parametersChanged;
            _parametersValidated = false;
            _booking = booking;
            _clientEntity = new ClientEntity(_booking.Client);
            _bookingEntity = new BookingEntity(_booking);
            _clientEntity.Bookings.Add(_bookingEntity);
            _computeTitle(_clientEntity);
            _clientEntity.PropertyChanged += _clientChanged;

            _searchClientCommand = new DelegateCommandAsync<BookingViewModel>(_searchClient, false);
            _newClientCommand = new DelegateCommandAsync<BookingViewModel>(_newClient, false);
            _validateBookingCommand = new DelegateCommandAsync<BookingViewModel>(_validateBooking, false);

            if (prevNode == null)
            {
                _navigation.AddLast(this);
            }
            else
            {
                _navigation.AddAfter(prevNode, this);
            }
        }
Esempio n. 33
0
        public MainVM()
        {
            StartCommand = new DelegateCommandAsync(
                o => Settings.Connections.CurrentConnection != null && Status.Status == AppStatusCodes.Ready,
                o =>
            {
                // show server menu when we need a password or connection
                if ((o as bool?) != true && Settings.Connections.CurrentConnection?.RawPassword == null)
                {
                    ServersCommand.Execute(null);
                    return(Task.FromResult <object>(null));
                }

                return(StartTraceAsync());
            }
                );

            StopCommand = new DelegateCommandAsync(
                o => Status.Status != AppStatusCodes.Ready,
                o => StopTraceAsync()
                );

            ServersCommand = new DelegateCommand(
                o => Status.Status == AppStatusCodes.Ready,
                o => new ConnectWindow(Settings.Connections, () => StartCommand.Execute(true)).Show()
                );

            ClearEventsCommand = new DelegateCommand(
                o => true,
                o => Events.Clear()
                );

            SelectColumnsCommand = new DelegateCommand(
                o => true,
                o =>
            {
                new ColumnSelectorWindow(
                    Settings.Columns,
                    (result) =>
                {
                    EventGrid.BuildColumns(result, Events);
                    Settings.Columns = result.ToList();
                    OnPropertyChanged(nameof(Settings));
                }
                    ).Show();
            }
                );

            CopySqlCommand = new DelegateCommand(
                o => true,
                o => SqlPreview.CopyToClipboard()
                );

            UserSettingsCommand = new DelegateCommand(
                o => true,
                o => new UserSettingsWindow(Settings).Show()
                );

            AboutCommand = new DelegateCommand(
                o => true,
                o => new AboutWindow().Show()
                );

            CheckUpdatesCommand = new DelegateCommandAsync(
                o => true,
                o => CheckForUpdates()
                );

            ExitCommand = new DelegateCommand(
                o => true,
                o => OnExit()
                );

            RunCommand = new DelegateCommand(
                o => Status.Status == AppStatusCodes.Running && SelectedEvent?.EventType != EventClassType.Custom && SqlPreview?.GetText() != null,
                o => RunSqlCode()
                );

            RunBackgroundSqlCommand = new DelegateCommandAsync(
                o => Status.Status == AppStatusCodes.Running && SelectedEvent?.EventType != EventClassType.Custom && SqlPreview?.GetText() != null,
                o =>
            {
                var exec = new ExecQuery((ServerConnection)Status.ActiveConnection.Clone(), CurrentDatabaseName);
                return(exec.ExecSqlAsync(SqlPreview.GetText()));
            }
                );

            // capture new events
            Traces.OnEvent += (status, ev) =>
            {
                if (status == ProfilerEventStatus.NewEvent && !ev.IsInternal)
                {
                    Events.Add(ev);
                }
            };

            // update canExecute() for each command when status changes
            Status.PropertyChanged += (ee, ss) => StatusChanged();
        }
Esempio n. 34
0
 private void _defineCommands(bool canSave)
 {
     _editBookingCommand = new DelegateCommandAsync<SumUpViewModel>(_editBooking);
     _saveBookingCommand = new DelegateCommandAsync<SumUpViewModel>(_saveBooking, canSave);
     _printBookingCommand = new DelegateCommand<XpsDocument>(_printBooking);
 }
Esempio n. 35
0
        public MainWindowViewModel(UserEntity user)
        {
            Logger.Log("=Initialisation Fenêtre principale (post login)=");
            _pcs = new PropertyChangeSupport(this);
            _user = user;
            _currentEntities = new ObservableCollection<INavigableViewModel>();
            _title = "Resotel - Facturation";
            _navigation = new LinkedList<INavigableViewModel>();

            _addBookingCommand = new DelegateCommand<object>(_addBooking);
            _closeBookingCommand = new DelegateCommand<IEntity>(_closeBooking);
            _addClientCommand = new DelegateCommand<object>(_addClient);
            _searchBookingCommand = new DelegateCommandAsync<object>(_searchBooking);
            _searchClientCommand = new DelegateCommandAsync<object>(_searchClient);
            _logoutCommand = new DelegateCommand<object>(_logOut);
            _nextCommand = new DelegateCommand<BookingViewModel>(_next);
            _prevCommand = new DelegateCommand<BookingViewModel>(_prev);
            Logger.Log("=fenêtre principale initialisée (post login)=");
        }
Esempio n. 36
0
 private void _defineCommands(bool canSave)
 {
     _editBookingCommand  = new DelegateCommandAsync <SumUpViewModel>(_editBooking);
     _saveBookingCommand  = new DelegateCommandAsync <SumUpViewModel>(_saveBooking, canSave);
     _printBookingCommand = new DelegateCommand <XpsDocument>(_printBooking);
 }
Esempio n. 37
0
        public MainViewModel()
        {

            ChooseNewPhotoCommand = new DelegateCommandAsync(ChooseNewPhotoCommandExecute);
        }
Esempio n. 38
0
        public LoginViewModel()
        {
            _pcs = new PropertyChangeSupport(this);
            _loginResult = "";
            _resultReady = false;
            _title = "Resotel - Login";

            _loadCommand = new DelegateCommand<IUITimer>(_load);
            _loginCommand = new DelegateCommandAsync<object>(_loginCmd);
        }