internal BubbleMatrixViewModel(int rowCount, int columnCount) { RowCount = rowCount; ColumnCount = columnCount; _bubblesInternal = new ReactiveList <BubbleViewModel>(); this.Bubbles = _bubblesInternal.CreateDerivedCollection(x => x); this.TaskManager = new BubbleTaskManager(this); _bubbleGroupHelper = new BubbleGroupHelper(this.Bubbles); _bubbleGroupSizeStack = new Stack <int>(); _isIdle = true; var canUndo = this.WhenAny(x => x.IsIdle, x => x.TaskManager.CanUndo, (i, cu) => i.Value && cu.Value); UndoCommand = new ReactiveCommand(canUndo); UndoCommand.Subscribe(x => Undo()); this.WhenAnyObservable(t => t.TaskManager.PendingTaskGroups).Subscribe(tg => ExecuteTaskGroup(tg)); this.WhenAnyValue(t => t.FocusedBubble).Subscribe(b => ActivateBubbleGroup(b)); }
public PullRequestsViewModel(ISessionService sessionService) { _sessionService = sessionService; Title = "Pull Requests"; PullRequests = _pullRequests.CreateDerivedCollection(x => { var vm = new PullRequestItemViewModel(x); vm.GoToCommand.Subscribe(_ => { var prViewModel = this.CreateViewModel <PullRequestViewModel>(); prViewModel.Init(RepositoryOwner, RepositoryName, x.Number, x); NavigateTo(prViewModel); prViewModel.WhenAnyValue(y => y.Issue.State) .DistinctUntilChanged() .Skip(1) .Subscribe(y => LoadCommand.ExecuteIfCan()); }); return(vm); }, filter: x => x.Title.ContainsKeyword(SearchKeyword), signalReset: this.WhenAnyValue(x => x.SearchKeyword)); LoadCommand = ReactiveCommand.CreateAsyncTask(async t => { _pullRequests.Reset(await RetrievePullRequests()); }); this.WhenAnyValue(x => x.SelectedFilter).Skip(1).Subscribe(_ => { _pullRequests.Clear(); LoadCommand.ExecuteIfCan(); }); }
public CommitFilesViewModel() { Files = _files.CreateDerivedCollection(x => new CommitedFileItemViewModel(x, y => { if (x.Patch == null) { var vm = this.CreateViewModel <SourceViewModel>(); vm.RepositoryOwner = RepositoryOwner; vm.RepositoryName = RepositoryName; vm.Branch = y.Ref; vm.Name = y.Name; vm.Path = x.Filename; vm.GitUrl = x.ContentsUrl; vm.HtmlUrl = x.BlobUrl; vm.ForceBinary = true; NavigateTo(vm); } else { var vm = this.CreateViewModel <ChangesetDiffViewModel>(); vm.Username = RepositoryOwner; vm.Repository = RepositoryName; vm.Branch = CommitSha; vm.Filename = x.Filename; NavigateTo(vm); } })); }
public FaveGroupViewModel( Func <Article, FeedItemViewModel> factory, IGrouping <string, Article> grouping) { _factory = factory; _grouping = grouping; _source = new ReactiveList <FeedItemViewModel> { ChangeTrackingEnabled = true }; Items = _source.CreateDerivedCollection(x => x, x => x.Fave); _source.AddRange(_grouping.Select(_factory)); }
public PublicGistsViewModel(ISessionService sessionService) { _sessionService = sessionService; Title = "Public Gists"; Gists = _gists.CreateDerivedCollection(x => CreateGistItemViewModel(x)); LoadCommand = ReactiveCommand.CreateAsyncTask(async t => { _gists.Reset(await RetrieveGists()); }); }
public FeedGroupViewModel( Func <Article, FeedItemViewModel> factory, INavigationService navigationService, IFeedStoreService feedStoreService, ISettingManager settingManager, Category category) { _source = new ReactiveList <FeedItemViewModel> { ChangeTrackingEnabled = true }; _navigationService = navigationService; _feedStoreService = feedStoreService; _settingManager = settingManager; _category = category; _factory = factory; Modify = ReactiveCommand.CreateFromTask(_navigationService.Navigate <ChannelViewModel>); Fetch = ReactiveCommand.CreateFromTask(() => _feedStoreService.Load(_category.Channels)); Items = _source.CreateDerivedCollection(x => x, x => !(!ShowRead && x.Read)); Fetch.Select(articles => articles.Select(_factory)) .ObserveOn(RxApp.MainThreadScheduler) .Do(articles => _source.Clear()) .Subscribe(_source.AddRange); Items.IsEmptyChanged .Subscribe(x => IsEmpty = x); Fetch.IsExecuting.Skip(1) .Subscribe(x => IsLoading = x); Fetch.IsExecuting .Where(executing => executing) .SelectMany(x => _settingManager.Read()) .Select(settings => settings.Read) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => ShowRead = x); Fetch.IsExecuting .Where(executing => executing) .Select(executing => false) .Subscribe(x => HasErrors = x); Fetch.ThrownExceptions .Select(exception => true) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => HasErrors = x); Activator = new ViewModelActivator(); this.WhenActivated((CompositeDisposable disposables) => Fetch.Execute().Subscribe()); }
protected BaseCommitsViewModel(ISessionService sessionService) { SessionService = sessionService; Title = "Commits"; Commits = _commits.CreateDerivedCollection( x => x, x => x.Description.ContainsKeyword(SearchKeyword) || x.Name.ContainsKeyword(SearchKeyword), signalReset: this.WhenAnyValue(x => x.SearchKeyword)); LoadCommand = ReactiveCommand.CreateAsyncTask(async t => { var ret = await RetrieveCommits(); _commits.Reset(ret.Select(x => new CommitItemViewModel(x, GoToCommit))); }); }
public FeedGroupViewModel( Func <Article, FeedItemViewModel> factory, INavigationService navigationService, IFeedStoreService feedStoreService, ISettingManager settingManager, Category category) { _source = new ReactiveList <FeedItemViewModel> { ChangeTrackingEnabled = true }; _navigationService = navigationService; _feedStoreService = feedStoreService; _settingManager = settingManager; _category = category; _factory = factory; Modify = ReactiveCommand.CreateFromTask(_navigationService.Navigate <ChannelViewModel>); Fetch = ReactiveCommand.CreateFromTask(() => _feedStoreService.Load(_category.Channels)); Items = _source.CreateDerivedCollection(x => x, x => !(!ShowRead && x.Read)); Fetch.Select(articles => articles.Select(_factory)) .ObserveOn(RxApp.MainThreadScheduler) .Do(articles => _source.Clear()) .Subscribe(_source.AddRange); Fetch.IsExecuting .Where(executing => executing) .SelectMany(x => _settingManager.Read()) .Select(settings => settings.Read) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => ShowRead = x); Items.IsEmptyChanged .Subscribe(x => IsEmpty = x); Fetch.IsExecuting .Skip(1) .Subscribe(x => IsLoading = x); Error = new Interaction <Exception, bool>(); Fetch.ThrownExceptions .ObserveOn(RxApp.MainThreadScheduler) .SelectMany(Error.Handle) .Where(retry => retry) .Select(x => Unit.Default) .InvokeCommand(Fetch); }
protected BaseIssuesViewModel(ISessionService sessionService) { _sessionService = sessionService; Issues = IssuesBacking.CreateDerivedCollection( x => CreateItemViewModel(x), filter: IssueFilter, signalReset: this.WhenAnyValue(x => x.SearchKeyword)); Issues.Changed.Subscribe(_ => { GroupedIssues = Issues.GroupBy(x => x.RepositoryFullName) .Select(x => new IssueGroupViewModel(x.Key, x)).ToList(); }); LoadCommand = ReactiveCommand.CreateAsyncTask(async t => { IssuesBacking.Reset(await RetrieveIssues()); }); }
protected BaseIssuesViewModel() { Issues = IssuesBacking.CreateDerivedCollection( x => CreateItemViewModel(x), filter: x => x.Title.ContainsKeyword(SearchKeyword), signalReset: this.WhenAnyValue(x => x.SearchKeyword)); Issues.Changed.Subscribe(_ => { GroupedIssues = Issues.GroupBy(x => x.RepositoryFullName) .Select(x => new IssueGroupViewModel(x.Key, x)).ToList(); }); LoadCommand = ReactiveCommand.CreateAsyncTask(t => { return(IssuesBacking.SimpleCollectionLoad(CreateRequest(), t as bool?, x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x()))); }); }
protected BaseIssuesViewModel() { var gotoIssueCommand = ReactiveCommand.Create(); gotoIssueCommand.OfType <IssueItemViewModel>().Where(x => x.IsPullRequest).Subscribe(x => { var vm = this.CreateViewModel <PullRequestViewModel>(); vm.RepositoryOwner = x.RepositoryOwner; vm.RepositoryName = x.RepositoryName; vm.Id = x.Number; NavigateTo(vm); }); gotoIssueCommand.OfType <IssueItemViewModel>().Where(x => !x.IsPullRequest).Subscribe(x => { var vm = this.CreateViewModel <IssueViewModel>(); vm.RepositoryOwner = x.RepositoryOwner; vm.RepositoryName = x.RepositoryName; vm.Id = x.Number; NavigateTo(vm); }); gotoIssueCommand.CanExecuteObservable.Subscribe(x => { System.Diagnostics.Debug.WriteLine("OH SHIT {0}", x); }); Issues = IssuesBacking.CreateDerivedCollection( x => new IssueItemViewModel(x, gotoIssueCommand), filter: x => x.Title.ContainsKeyword(SearchKeyword), signalReset: this.WhenAnyValue(x => x.SearchKeyword)); Issues.Changed.Subscribe(_ => { GroupedIssues = Issues.GroupBy(x => x.RepositoryFullName) .Select(x => new IssueGroupViewModel(x.Key, x)).ToList(); }); LoadCommand = ReactiveCommand.CreateAsyncTask(t => { return(IssuesBacking.SimpleCollectionLoad(CreateRequest(), t as bool?, x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x()))); }); }
/// <summary> /// Constructor method. /// </summary> public ProcessesManagerViewModel(IProcessRepository processesRepository = null, IValidator <IProcessViewModel> processViewModelaValidator = null) { _processesRepository = processesRepository ?? Locator.CurrentMutable.GetService <IProcessRepository>(); _formDataValidator = processViewModelaValidator ?? Locator.CurrentMutable.GetService <IValidator <IProcessViewModel> >(); // Lists _processesSource = new ReactiveList <ProcessEntity>() { ChangeTrackingEnabled = true }; _processesList = _processesSource.CreateDerivedCollection( selector: entity => Mapper.Map <IProcessViewModel>(entity), filter: entity => FilterEntity(entity), signalReset: this.ObservableForProperty(@this => @this.FilterText).Throttle(TimeSpan.FromMilliseconds(175), RxApp.MainThreadScheduler) ); // Add _addProcessCommand = ReactiveCommand.Create(() => AddProcessCommandAction()); // Edit this.WhenAnyValue(viewModel => viewModel.SelectedProcess) .Where(option => option != null) .Subscribe(process => EditProcessCommandAction(process)); // Save _saveProcessCommand = ReactiveCommand.Create(() => SaveProcessAction()); // Cancel _cancelFormCommand = ReactiveCommand.Create(() => CancelFormCommandAction()); // Delete _deleteProcessCommand = ReactiveCommand.Create(() => DeleteProcessCommandAction()); // Load Processess _loadProcessesCommand = ReactiveCommand.CreateFromTask(async() => await LoadProcessesCommandAction()); _loadProcessesCommand.IsExecuting.BindTo(this, @this => @this.IsLoadingProcesses); _loadProcessesCommand.Subscribe(entities => LoadProcessesCommandHandler(entities)); }
/// <summary> /// Constructor method. /// </summary> public ConsolesPanelViewModel( IAppState appState = null, IProcessFactory processFactory = null, IProcessesTracker processesTracker = null, IProcessRepository processesRepository = null, IProcessesInteropAgent consolesInteropAgent = null, ISnackbarMessageQueue snackbarMessageQueue = null) { _appState = appState ?? Locator.CurrentMutable.GetService <IAppState>(); _processFactory = processFactory ?? Locator.CurrentMutable.GetService <IProcessFactory>(); _processesTracker = processesTracker ?? Locator.CurrentMutable.GetService <IProcessesTracker>(); _processesRepository = processesRepository ?? Locator.CurrentMutable.GetService <IProcessRepository>(); _consolesInteropAgent = consolesInteropAgent ?? Locator.CurrentMutable.GetService <IProcessesInteropAgent>(); _snackbarMessageQueue = snackbarMessageQueue ?? Locator.CurrentMutable.GetService <ISnackbarMessageQueue>(); // Lists _consoleProcessEntities = new ReactiveList <ProcessEntity>() { ChangeTrackingEnabled = false }; _consolesList = _consoleProcessEntities.CreateDerivedCollection( selector: process => Mapper.Map <IProcessViewModel>(process) ); // Load Processess _loadConsolesCommand = ReactiveCommand.CreateFromTask(async() => await LoadConsolesCommandAction()); _loadConsolesCommand.IsExecuting.BindTo(this, @this => @this.IsLoadingConsoles); _loadConsolesCommand.Subscribe(entities => LoadConsolesCommandHandler(entities)); // Create Instances _startConsoleProcessCommandFactory = () => { var command = ReactiveCommand.CreateFromTask <IProcessViewModel, IProcessInstanceViewModel>(async(option) => await StartConsoleProcessCommandAction(option)); command.ThrownExceptions.Subscribe(@exception => StartConsoleProcessCommandError(@exception)); command.Subscribe(instance => StartConsoleProcessCommandHandler(instance)); return(command); }; }
public FeedGroupViewModel( Func <Article, FeedItemViewModel> factory, INavigationService navigationService, IFeedStoreService feedStoreService, ISettingManager settingManager, Category category) { _navigationService = navigationService; _feedStoreService = feedStoreService; _settingManager = settingManager; _category = category; _factory = factory; _source = new ReactiveList <FeedItemViewModel> { ChangeTrackingEnabled = true }; Items = _source.CreateDerivedCollection(x => x, x => !(!ShowRead && x.Read)); Modify = ReactiveCommand.CreateFromTask( () => _navigationService.Navigate <ChannelViewModel>() ); Fetch = ReactiveCommand.CreateFromTask(DoFetch); Fetch.IsExecuting.Skip(1) .Subscribe(x => IsLoading = x); Items.CountChanged .Select(count => count == 0) .Subscribe(x => IsEmpty = x); Error = new Interaction <Exception, bool>(); Fetch.ThrownExceptions .ObserveOn(RxApp.MainThreadScheduler) .SelectMany(error => Error.Handle(error)) .Where(retryRequested => retryRequested) .Select(x => Unit.Default) .InvokeCommand(Fetch); }