本文整理汇总了C#中ReactiveCommand.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveCommand.OfType方法的具体用法?C# ReactiveCommand.OfType怎么用?C# ReactiveCommand.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReactiveCommand
的用法示例。
在下文中一共展示了ReactiveCommand.OfType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OrderViewModel
public OrderViewModel()
{
this.DisplayName = "Add/Edit Order";
context = new LittleTravellerDataContext();
var CanSave = this.Changed.Select(_ => ValidateFields()).StartWith(false);
SaveCommand = new ReactiveCommand(CanSave);
SaveCommand.Subscribe(_ => SaveOrder());
NewOrderNumCommand = new ReactiveCommand();
NewOrderNumCommand.Subscribe(_ => NewOrderNum());
CloseTabCommand = new ReactiveCommand();
CloseTabCommand.Subscribe(_ => TabClosing());
SaveCommand.Subscribe(_ => SaveOrder());
var CanAddItem = this.Changed.Select(_ => CanAddItemValidate()).StartWith(false);
AddItemCommand = new ReactiveCommand(CanAddItem);
AddItemCommand.Subscribe(_ => AddItem());
DeleteItemCommand = new ReactiveCommand();
DeleteItemCommand.OfType<ItemOptionsClass>().Subscribe(item => DeleteItem(item));
CustomerOptions = (from cs in context.Customers select cs.CompanyName).ToList();
SeasonOptions = context.Seasons.ToList();
SizeTypeOptions = context.SizeTypes.ToList();
ItemOptions = new ReactiveCollection<ItemOptionsClass>();
_orderItems = new ObservableCollection<ItemOptionsClass>();
AllSeasonsChecked = true;
AllSizeTypesChecked = true;
FillItemOptions();
}
示例2: BaseEventsViewModel
protected BaseEventsViewModel(IApplicationService applicationService)
{
ApplicationService = applicationService;
Events = new ReactiveCollection<Tuple<EventModel, EventBlock>>();
ReportRepository = true;
GoToRepositoryCommand = new ReactiveCommand();
GoToRepositoryCommand.OfType<EventModel.RepoModel>().Subscribe(x =>
{
var repoId = new RepositoryIdentifier(x.Name);
var vm = CreateViewModel<RepositoryViewModel>();
vm.RepositoryOwner = repoId.Owner;
vm.RepositoryName = repoId.Name;
ShowViewModel(vm);
});
GoToGistCommand = new ReactiveCommand();
GoToGistCommand.OfType<EventModel.GistEvent>().Subscribe(x =>
{
var vm = CreateViewModel<GistViewModel>();
vm.Id = x.Gist.Id;
vm.Gist = x.Gist;
ShowViewModel(vm);
});
LoadCommand.RegisterAsyncTask(t =>
this.RequestModel(CreateRequest(0, 100), t as bool?, response =>
{
this.CreateMore(response, m => Events.MoreTask = m, d => Events.AddRange(CreateDataFromLoad(d)));
Events.Reset(CreateDataFromLoad(response.Data));
}));
}
示例3: MapViewModel
public MapViewModel()
{
//MapCenter = new EarthPoint(new Degree(56.8779), new Degree(60.5905));
MapCenter = new EarthPoint(new Degree(55.729959), new Degree(37.540420));
ZoomLevel = 14;
_mapClickedCommand = ReactiveCommand.Create();
Clicks = _mapClickedCommand.OfType<MapMouseActionEventArgs>();
}
示例4: FillItemsGrid
private void FillItemsGrid()
{
List<Customer> ItemsLst = context.Customers.ToList<Customer>();
CustsGrid = new ReactiveCollection<Customer>();
foreach (Customer cgv in ItemsLst)
{
CustsGrid.Add(cgv);
}
DeleteCustomerCommand = new ReactiveCommand();
DeleteCustomerCommand.OfType<Customer>().Subscribe(customer => DeleteCustomer(customer));
}
示例5: FillItemsGrid
private void FillItemsGrid()
{
List<AllItemsGridView> ItemsLst = context.AllItemsGridViews.ToList<AllItemsGridView>();
ItemsGrid = new ReactiveCollection<AllItemsGridView>();
foreach (AllItemsGridView igv in ItemsLst)
{
ItemsGrid.Add(igv);
}
DeleteItemCommand = new ReactiveCommand();
DeleteItemCommand.OfType<AllItemsGridView>().Subscribe(item => DeleteItem(item));
}
示例6: ChangesetViewModel
public ChangesetViewModel(IApplicationService applicationService)
{
_applicationService = applicationService;
Comments = new ReactiveCollection<CommentModel>();
GoToHtmlUrlCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Commit, x => x != null));
GoToHtmlUrlCommand.Select(x => Commit).Subscribe(GoToUrlCommand.ExecuteIfCan);
GoToRepositoryCommand = new ReactiveCommand();
GoToRepositoryCommand.Subscribe(_ =>
{
var vm = CreateViewModel<RepositoryViewModel>();
vm.RepositoryOwner = RepositoryOwner;
vm.RepositoryName = RepositoryName;
ShowViewModel(vm);
});
GoToFileCommand = new ReactiveCommand();
GoToFileCommand.OfType<CommitModel.CommitFileModel>().Subscribe(x =>
{
if (x.Patch == null)
{
var vm = CreateViewModel<SourceViewModel>();
// vm.GitUrl = x.ContentsUrl;
// vm.HtmlUrl = x.BlobUrl;
// vm.Name = x.Filename;
// vm.Path = x.Filename;
// vm.ForceBinary = true;
ShowViewModel(vm);
}
else
{
var vm = CreateViewModel<ChangesetDiffViewModel>();
vm.Username = RepositoryOwner;
vm.Repository = RepositoryName;
vm.Branch = Commit.Sha;
vm.HtmlUrl = x.BlobUrl;
ShowViewModel(vm);
}
});
LoadCommand.RegisterAsyncTask(t =>
{
var forceCacheInvalidation = t as bool?;
var t1 = this.RequestModel(_applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Commits[Node].Get(), forceCacheInvalidation, response => Commit = response.Data);
Comments.SimpleCollectionLoad(_applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Commits[Node].Comments.GetAll(), forceCacheInvalidation).FireAndForget();
return t1;
});
}
示例7: NotificationViewModel
public NotificationViewModel(NotificationEntry notificationEntry, NotificationSettingsViewModel parent)
{
_notificationEntry = notificationEntry;
_parent = parent;
Triggers = new ReactiveCollection<TriggerViewModel>();
foreach (var trigger in notificationEntry.Triggers)
{
Triggers.Add(new TriggerViewModel(trigger));
}
Actions = new ReactiveCollection<ActionViewModel>();
foreach (var notificationAction in notificationEntry.Actions)
{
Actions.Add(new ActionViewModel(notificationAction));
}
AddNewTriggerCommand = new ReactiveCommand();
AddNewTriggerCommand.Subscribe(_ =>
{
Triggers.Add(new TriggerViewModel(new NotificationTrigger()));
SelectedTrigger = Triggers.Last();
_parent.ToggleEditCommand.Execute(Triggers.Last());
});
AddNewActionCommand = new ReactiveCommand();
AddNewActionCommand.Subscribe(_ =>
{
Actions.Add(new ActionViewModel(new FlashTaskBarNotificationAction()));
SelectedAction = Actions.Last();
_parent.ToggleEditCommand.Execute(Actions.Last());
});
DeleteItemCommand = new ReactiveCommand();
DeleteItemCommand.OfType<TriggerViewModel>().Subscribe(t => Triggers.Remove(t));
DeleteItemCommand.OfType<ActionViewModel>().Subscribe(a => Actions.Remove(a));
}
示例8: CommitsViewModel
protected CommitsViewModel()
{
Commits = new ReactiveCollection<CommitModel>();
GoToChangesetCommand = new ReactiveCommand();
GoToChangesetCommand.OfType<CommitModel>().Subscribe(x =>
{
var vm = CreateViewModel<ChangesetViewModel>();
vm.RepositoryOwner = RepositoryOwner;
vm.RepositoryName = RepositoryName;
vm.Node = x.Sha;
ShowViewModel(vm);
});
LoadCommand.RegisterAsyncTask(x => Commits.SimpleCollectionLoad(GetRequest(), x as bool?));
}
示例9: TaskBoardViewModel
public TaskBoardViewModel(IRepositoryProvider repositoryProvider, IEventAggregator bus, ICommandResolver commandResolver)
{
_repositoryProvider = repositoryProvider;
_bus = bus;
_commandResolver = commandResolver;
Tasks = new SortableReactiveCollection<TaskViewModel>();
Tasks.ItemChanged
.Throttle(TimeSpan.FromSeconds(5))
.Select(c => c.Sender)
.Where(c => _repository != null)
.Where(task => !task.IsEditing)
.SubscribeOn(RxApp.DeferredScheduler)
.Subscribe(_ => OnSaveAllTasks(null));
Tasks.ItemChanged
.Where(c => c.PropertyName == "IsSelected")
.SubscribeOn(RxApp.DeferredScheduler)
.Select(c => c.Sender)
.Subscribe(IsSelectedChanged);
Tasks.ItemChanged
.Where(c => c.PropertyName == "State")
.SubscribeOn(RxApp.DeferredScheduler)
.Select(c => c.Sender)
.Subscribe(StateChanged);
Tasks.ChangeTrackingEnabled = true;
_bus.ListenOnScheduler<DatabaseChanged>(OnDatabaseChanged);
_bus.ListenOnScheduler<CreateNewTask>(OnCreateNewTask);
_bus.ListenOnScheduler<CreateNewSubTask>(OnCreateNewSubTask);
_bus.ListenOnScheduler<SaveAllTasks>(OnSaveAllTasks);
_bus.ListenOnScheduler<ReloadAllTasks>(evt => Reload());
_bus.ListenOnScheduler<ReSort>(evt => Reorder());
_bus.ListenOnScheduler<CollapseAll>(evt => OnCollapseAll());
_bus.AddSource(Tasks.PropertyOnAnyChanged(vm => vm.State)
.Select(_ => new TaskStateChanged()));
DragCommand = new ReactiveCommand();
DragCommand.OfType<DragCommandArgs>().Subscribe(OnNext);
}
示例10: ReadmeViewModel
public ReadmeViewModel(IApplicationService applicationService, IMarkdownService markdownService, IShareService shareService)
{
ShareCommand = new ReactiveCommand(this.WhenAnyValue(x => x.ContentModel, x => x != null));
ShareCommand.Subscribe(_ => shareService.ShareUrl(ContentModel.HtmlUrl));
GoToGitHubCommand = new ReactiveCommand(this.WhenAnyValue(x => x.ContentModel, x => x != null));
GoToGitHubCommand.Subscribe(_ => GoToUrlCommand.ExecuteIfCan(ContentModel.HtmlUrl));
GoToLinkCommand = new ReactiveCommand();
GoToLinkCommand.OfType<string>().Subscribe(x => GoToUrlCommand.ExecuteIfCan(x));
LoadCommand.RegisterAsyncTask(x =>
this.RequestModel(applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetReadme(), x as bool?, r =>
{
ContentModel = r.Data;
ContentText = markdownService.Convert(Encoding.UTF8.GetString(Convert.FromBase64String(ContentModel.Content)));
}));
}
示例11: NotificationSettingsViewModel
public NotificationSettingsViewModel(NotificationSettings notification)
{
_notification = notification;
Notifications = new ReactiveCollection<NotificationViewModel>();
foreach (var notificationEntry in notification.Notifications)
{
Notifications.Add(new NotificationViewModel(notificationEntry, this));
}
AddNotificationCommand = new ReactiveCommand();
AddNotificationCommand.Subscribe(_ =>
{
Notifications.Add(new NotificationViewModel(
new NotificationEntry
{
Triggers = new[] {new NotificationTrigger()},
Actions = new[] {new NotificationAction()}
},
this));
Notifications.Last().Actions.First().IsEditing = true;
Notifications.Last().Triggers.First().IsEditing = true;
});
DeleteNotificationCommand = new ReactiveCommand();
DeleteNotificationCommand.OfType<NotificationViewModel>().Subscribe(n => Notifications.Remove(n));
(ToggleEditCommand = new ReactiveCommand()).Do(_ => Trace.WriteLine(_)).OfType<IToggleEdit>().Subscribe(editable =>
{
bool valueToSet = !editable.IsEditing;
foreach (var notificationViewModel in Notifications)
{
notificationViewModel.CollapseAll();
}
editable.IsEditing = valueToSet;
});
}
示例12: RepositoriesExploreViewModel
public RepositoriesExploreViewModel(IApplicationService applicationService, INetworkActivityService networkActivityService)
{
_applicationService = applicationService;
Repositories = new ReactiveCollection<RepositorySearchModel.RepositoryModel>();
SearchCommand = new ReactiveCommand(this.WhenAnyValue(x => x.SearchText, x => !string.IsNullOrEmpty(x)));
SearchCommand.IsExecuting.Skip(1).Subscribe(x =>
{
if (x)
networkActivityService.PushNetworkActive();
else
networkActivityService.PopNetworkActive();
});
SearchCommand.RegisterAsyncTask(async t =>
{
try
{
var request = applicationService.Client.Repositories.SearchRepositories(new[] { SearchText }, new string[] { });
request.UseCache = false;
var response = await applicationService.Client.ExecuteAsync(request);
Repositories.Reset(response.Data.Items);
}
catch (Exception e)
{
throw new Exception("Unable to search for repositories. Please try again.", e);
}
});
GoToRepositoryCommand = new ReactiveCommand();
GoToRepositoryCommand.OfType<RepositorySearchModel.RepositoryModel>().Subscribe(x =>
{
var vm = CreateViewModel<RepositoryViewModel>();
vm.RepositoryOwner = x.Owner.Login;
vm.RepositoryName = x.Name;
ShowViewModel(vm);
});
}
示例13: MainCampfireViewModel
public MainCampfireViewModel(ILobbyModule lobbyModule, ILogModule logModule, IMessageBus bus,
IModuleCreator creator, IGlobalCommands globalCommands)
{
_lobbyModule = lobbyModule;
_logModule = logModule;
_bus = bus;
_creator = creator;
Modules = new ReactiveCollection<IModule>{_lobbyModule, _logModule};
_bus.Listen<ActivateModuleMessage>().Where(msg => msg.ParentModule == ModuleNames.MainCampfireView)
.SubscribeUI(msg =>
{
CurrentModules = Modules.CreateDerivedCollection(module => new ModuleViewModel(module, bus));
});
bus.RegisterMessageSource(bus.Listen<ModuleLoaded>().Where(msg => msg.ModuleName == ModuleNames.MainCampfireView)
.Select(_ => new ActivateModuleMessage(ModuleNames.MainCampfireView, _lobbyModule)));
_activeModule = _lobbyModule;
bus.Listen<RoomPresenceMessage>().SubscribeUI(SyncModuleList);
_bus.Listen<ActivateModuleByIdMessage>().Where(msg => msg.ParentModule == ModuleNames.MainCampfireView)
.SubscribeUI(HandleActivateModuleById);
_bus.Listen<ModuleActivatedMessage>().Where(msg => msg.ParentModule == ModuleNames.MainCampfireView)
.SubscribeUI(msg => ActiveModule = msg.Module);
_bus.Listen<RequestLeaveRoomMessage>().SubscribeUI(OnRequestLeaveRoomMessage);
ActivateModuleCommand = new ReactiveCommand();
ActivateModuleCommand.OfType<ModuleViewModel>().Subscribe(HandleActivateModule);
globalCommands.NextModuleCommand.Subscribe(OnNextModuleCommand);
globalCommands.PreviousModuleCommand.Subscribe(OnPreviousModuleCommand);
}
示例14: SourceTreeViewModel
public SourceTreeViewModel(IApplicationService applicationService)
{
Filter = applicationService.Account.Filters.GetFilter<SourceFilterModel>("SourceViewModel");
Content = new ReactiveCollection<ContentModel>();
GoToSubmoduleCommand = new ReactiveCommand();
GoToSubmoduleCommand.OfType<ContentModel>().Subscribe(x =>
{
var nameAndSlug = x.GitUrl.Substring(x.GitUrl.IndexOf("/repos/", StringComparison.OrdinalIgnoreCase) + 7);
var repoId = new RepositoryIdentifier(nameAndSlug.Substring(0, nameAndSlug.IndexOf("/git", StringComparison.OrdinalIgnoreCase)));
var vm = CreateViewModel<SourceTreeViewModel>();
vm.Username = repoId.Owner;
vm.Repository = repoId.Name;
vm.Branch = x.Sha;
ShowViewModel(vm);
});
GoToSourceCommand = new ReactiveCommand();
GoToSourceCommand.OfType<ContentModel>().Subscribe(x =>
{
var otherFiles = Content
.Where(y => string.Equals(y.Type, "file", StringComparison.OrdinalIgnoreCase))
.Where(y => y.Size.HasValue && y.Size.Value > 0)
.Select(y => new SourceViewModel.SourceItemModel
{
Name = y.Name,
Path = y.Path,
HtmlUrl = y.HtmlUrl,
GitUrl = y.GitUrl
}).ToArray();
var navObject = new SourceViewModel.NavObject
{
Branch = Branch,
Username = Username,
Repository = Repository,
TrueBranch = TrueBranch,
Items = otherFiles,
CurrentItemIndex = Array.FindIndex(otherFiles, f => string.Equals(f.GitUrl, x.GitUrl, StringComparison.OrdinalIgnoreCase))
};
var vm = CreateViewModel<SourceViewModel>(navObject);
ShowViewModel(vm);
});
GoToSourceTreeCommand = new ReactiveCommand();
GoToSourceTreeCommand.OfType<ContentModel>().Subscribe(x =>
{
var vm = CreateViewModel<SourceTreeViewModel>();
vm.Username = Username;
vm.Branch = Branch;
vm.Repository = Repository;
vm.TrueBranch = TrueBranch;
vm.Path = x.Path;
ShowViewModel(vm);
});
this.WhenAnyValue(x => x.Filter).Subscribe(filter =>
{
if (filter == null)
{
Content.OrderFunc = null;
}
else
{
Content.OrderFunc = x =>
{
switch (filter.OrderBy)
{
case SourceFilterModel.Order.FoldersThenFiles:
x = x.OrderBy(y => y.Type).ThenBy(y => y.Name);
break;
default:
x = x.OrderBy(y => y.Name);
break;
}
return filter.Ascending ? x : x.Reverse();
};
}
});
LoadCommand.RegisterAsyncTask(t =>
Content.SimpleCollectionLoad(
applicationService.Client.Users[Username].Repositories[Repository].GetContent(
Path ?? string.Empty, Branch ?? "master"), t as bool?));
}
示例15: GistViewModel
public GistViewModel(IApplicationService applicationService, IShareService shareService)
{
_applicationService = applicationService;
Comments = new ReactiveCollection<GistCommentModel>();
ShareCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Gist, x => x != null));
ShareCommand.Subscribe(_ => shareService.ShareUrl(Gist.HtmlUrl));
ToggleStarCommand = new ReactiveCommand(this.WhenAnyValue(x => x.IsStarred, x => x.HasValue));
ToggleStarCommand.RegisterAsyncTask(async t =>
{
try
{
if (!IsStarred.HasValue) return;
var request = IsStarred.Value ? _applicationService.Client.Gists[Id].Unstar() : _applicationService.Client.Gists[Id].Star();
await _applicationService.Client.ExecuteAsync(request);
IsStarred = !IsStarred.Value;
}
catch (Exception e)
{
throw new Exception("Unable to start gist. Please try again.", e);
}
});
ForkCommand = new ReactiveCommand();
ForkCommand.RegisterAsyncTask(async t =>
{
var data =
await _applicationService.Client.ExecuteAsync(_applicationService.Client.Gists[Id].ForkGist());
var forkedGist = data.Data;
var vm = CreateViewModel<GistViewModel>();
vm.Id = forkedGist.Id;
vm.Gist = forkedGist;
ShowViewModel(vm);
});
GoToViewableFileCommand = new ReactiveCommand();
GoToViewableFileCommand.OfType<GistFileModel>().Subscribe(x =>
{
var vm = CreateViewModel<GistViewableFileViewModel>();
vm.GistFile = x;
ShowViewModel(vm);
});
GoToHtmlUrlCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Gist, x => x != null && !string.IsNullOrEmpty(x.HtmlUrl)));
GoToHtmlUrlCommand.Subscribe(_ => GoToUrlCommand.ExecuteIfCan(Gist.HtmlUrl));
GoToFileSourceCommand = new ReactiveCommand();
GoToFileSourceCommand.OfType<GistFileModel>().Subscribe(x =>
{
var vm = CreateViewModel<GistFileViewModel>();
vm.Id = Id;
vm.GistFile = x;
vm.Filename = x.Filename;
ShowViewModel(vm);
});
GoToUserCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Gist, x => x != null));
GoToUserCommand.Subscribe(x =>
{
var vm = CreateViewModel<ProfileViewModel>();
vm.Username = Gist.Owner.Login;
ShowViewModel(vm);
});
GoToForksCommand = new ReactiveCommand();
LoadCommand.RegisterAsyncTask(t =>
{
var forceCacheInvalidation = t as bool?;
var t1 = this.RequestModel(_applicationService.Client.Gists[Id].Get(), forceCacheInvalidation, response => Gist = response.Data);
this.RequestModel(_applicationService.Client.Gists[Id].IsGistStarred(), forceCacheInvalidation, response => IsStarred = response.Data).FireAndForget();
Comments.SimpleCollectionLoad(_applicationService.Client.Gists[Id].GetComments(), forceCacheInvalidation).FireAndForget();
return t1;
});
}