예제 #1
0
        public NewEntityViewModel(IDataService <TEntity> service, IDialogService dialogService)
        {
            this.Create = ReactiveCommand.CreateFromTask(() => service.Add(this.CreateEntity()));
            this.Create.Subscribe(entity => dialogService.Close(entity));

            this.Cancel = ReactiveCommand.Create(() => dialogService.Close());
        }
예제 #2
0
        /// <summary>
        /// Initializes the specified torrent entity task.
        /// </summary>
        /// <param name="torrentEntityTask">The torrent entity task.</param>
        /// <param name="torrents">The torrents.</param>
        public async void Initialize(Task <TorrentEntity> torrentEntityTask, ObservableCollection <TorrentEntity> torrents)
        {
            try
            {
                _torrentTask = torrentEntityTask;
                Torrent      = null;
                IsWorking    = true;
                InfoText     = Res.LoadingTorrentMetadata;

                Torrent = await torrentEntityTask;

                IsWorking = false;
                InfoText  = string.Empty;

                if (Torrent == null)
                {
                    Torrent = null;
                    _dialogService.ShowMessageBox(Res.InvalidTorrent, messageBoxImage: MessageBoxImage.Error);
                }
                else if (torrents.Any(t => t.TorrentUri.Equals(_torrent.TorrentUri)))
                {
                    Torrent = null;
                    _dialogService.ShowMessageBox(Res.TorrentAlreadyExist, messageBoxImage: MessageBoxImage.Error);
                }
            }
            catch (Exception)
            {
                Torrent   = null;
                InfoText  = string.Empty;
                IsWorking = false;
                _dialogService.ShowMessageBox(Res.InvalidTorrent, messageBoxImage: MessageBoxImage.Error);
                _dialogService.Close(this);
            }
        }
예제 #3
0
        public EditEntityViewModel(IDataService <TEntity> dataService, IDialogService dialogService)
        {
            this.DataService = dataService;
            this.Apply       = ReactiveCommand.CreateFromTask(() => dataService.Update(this.Entity));
            this.Apply.Subscribe(_ => dialogService.Close(this.Entity));

            this.Cancel = ReactiveCommand.Create(() => dialogService.Close());

            this.WhenAnyValue(o => o.Value).
            Where(entity => entity != null).
            Subscribe(async entity => this.Entity = await dataService.GetById(entity.Id));
        }
        private void Close()
        {
            dialogService.Close(dialogViewModel);
            dialogViewModel = null;

            ShowCommand.RaiseCanExecuteChanged();
            CloseCommand.RaiseCanExecuteChanged();
        }
예제 #5
0
 private void finish(bool changeNote)
 {
     if (changeNote)
     {
         _changed   = true;
         _note.Text = _text;
     }
     _dialogService.Close(this);
 }
예제 #6
0
        /// <summary>
        /// Saves the and close.
        /// </summary>
        public void SaveAndClose()
        {
            var settings = new ApplicationSettings
            {
                DownloadFolderPath       = DownloadFolderPath,
                StopTorrentsWhenFinished = StopTorrentsWhenFinished,
                TurtleModeUploadLimit    = UploadLimit.Equals("Unlimited")
                    ? 0
                    : int.Parse(UploadLimit) * 1000,
                TurtleModeDownloadLimit = DownloadLimit.Equals("Unlimited")
                    ? 0
                    : int.Parse(DownloadLimit) * 1000
            };

            _appSettingsService.ApplyNewValues(settings);
            _appSettingsService.SaveChanges();
            _dialogService.Close(this);
        }
예제 #7
0
        public DialogViewModel(IDialogService dialogService)
        {
            this.DialogService = dialogService;

            this.Close = ReactiveCommand.Create(() => dialogService.Close());
        }
예제 #8
0
 private void Close()
 {
     dialogService.Close(dialogViewModel);
     dialogViewModel = null;
 }
예제 #9
0
 public void Close()
 {
     _dialogService.Close(this);
 }
예제 #10
0
 public void ForceToCloseDialog()
 {
     dialogService.Result = true;
     dialogService.Close();
 }
 private void CancelCommandExecute()
 {
     dialogService.Close();
 }
 private void ButtonClose_Click(object sender, RoutedEventArgs e)
 {
     dialogService.Close();
 }
예제 #13
0
 private void finish(bool confirm)
 {
     _accepted = confirm;
     _dialogService.Close(this);
 }
예제 #14
0
 private void finish()
 {
     _dialogService.Close(this);
 }
예제 #15
0
 private void finish(bool createTab)
 {
     _createTab = createTab;
     _dialogService.Close(this);
 }