本文整理汇总了C#中ReactiveList.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveList.Remove方法的具体用法?C# ReactiveList.Remove怎么用?C# ReactiveList.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReactiveList
的用法示例。
在下文中一共展示了ReactiveList.Remove方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AccountsViewModel
public AccountsViewModel(IAccountsService accountsService)
{
_accountsService = accountsService;
Accounts = new ReactiveList<IAccount>(accountsService);
LoginCommand = ReactiveCommand.Create();
GoToAddAccountCommand = ReactiveCommand.Create();
DeleteAccountCommand = ReactiveCommand.Create();
DeleteAccountCommand.OfType<IAccount>().Subscribe(x =>
{
if (Equals(accountsService.ActiveAccount, x))
ActiveAccount = null;
accountsService.Remove(x);
Accounts.Remove(x);
});
LoginCommand.OfType<IAccount>().Subscribe(x =>
{
if (Equals(accountsService.ActiveAccount, x))
DismissCommand.ExecuteIfCan();
else
{
ActiveAccount = x;
MessageBus.Current.SendMessage(new LogoutMessage());
DismissCommand.ExecuteIfCan();
}
});
GoToAddAccountCommand.Subscribe(_ => ShowViewModel(CreateViewModel<IAddAccountViewModel>()));
this.WhenActivated(d => Accounts.Reset(accountsService));
}
示例2: TrackingControlViewModel
public TrackingControlViewModel(ITrackPresenter TrackPresenter, IMappingService MappingService, TrackFormatterManager TrackFormatterManager)
{
_trackPresenter = TrackPresenter;
_trackFormatterManager = TrackFormatterManager;
_mappingService = MappingService;
_track = new ReactiveList<EarthPoint>();
_track.Changed
.Subscribe(_ => RefreshTrack());
LoadTrack = ReactiveCommand.CreateAsyncTask(LoadTrackImpl);
SaveTrack = ReactiveCommand.CreateAsyncTask(SaveTrackImpl);
ReactiveCommand<object> clearCommand = ReactiveCommand.Create(_track.IsEmptyChanged.Select(e => !e));
clearCommand.Subscribe(_ => _track.Clear());
ClearTrack = clearCommand;
IConnectableObservable<TrackPathRider> prp =
_track.Changed
.Select(_ => new TrackPathRider(new GpsTrack(_track.ToList())))
.Publish();
PathRider = prp;
prp.Connect();
_mappingService.Clicks
.Where(c => c.Action == MouseAction.LeftClick)
.Subscribe(c => AppendPointToTrack(c.Point));
_mappingService.Clicks
.Where(c => c.Action == MouseAction.RightClick)
.Subscribe(c => _track.Remove(_track.LastOrDefault()));
}
示例3: FileListViewModel
public FileListViewModel(IScreen host)
{
HostScreen = host;
Files = new ReactiveList<string>(new []
{
"c:/temp/foo.txt",
"c:/temp/bar.txt",
"c:/temp/baseball.dat",
"c:/temp/basketball.dat",
"c:/temp/handegg.dat"
});
var confirmDelete = new Interaction<Unit, string>();
DeleteFile = ReactiveCommand.CreateFromTask(
async () =>
{
var fileToDelete = SelectedFile;
var baseMessage = $"Do you really want to delete {fileToDelete}?";
var help = "\nConfirm by entering the full file name below.";
var message = baseMessage + help;
var abort = this
.WhenAnyValue(x => x.SelectedFile)
.Skip(1)
.Select(_ => Unit.Default);
ConfirmDeleteViewModel = new ConfirmEventViewModel(abort, confirmDelete)
{
Message = message
};
while (true)
{
var confirmation = await confirmDelete.Handle(Unit.Default);
if (confirmation == fileToDelete)
{
SelectedFile = null;
Files.Remove(fileToDelete);
ConfirmDeleteViewModel = null;
break;
}
if (confirmation == null)
{
ConfirmDeleteViewModel = null;
break;
}
ConfirmDeleteViewModel.Message = baseMessage + "\nYou didn't type the right thing." + help;
}
},
this.WhenAnyValue(vm => vm.SelectedFile).Select(s => s != null));
}
示例4: MainViewModel
public MainViewModel()
{
People = new ReactiveList<PersonViewModel>();
People.ActOnEveryObject(x => x.Delete.Subscribe(p => People.Remove((PersonViewModel) p)), _ => { });
People.AddRange(new[]
{
new PersonViewModel("Jerry", "Seinfeld"),
new PersonViewModel("George", "Costanza"),
new PersonViewModel("Elaine", "Something"),
new PersonViewModel("Newman", "Something"),
});
}
示例5: FavoriteViewModel
public FavoriteViewModel(Guid id, IEnumerable<FavoriteItemViewModel> favoriteItems) {
_id = id;
FavoriteItems = new ReactiveList<FavoriteItemViewModel>(favoriteItems);
Listen<ContentFavorited>()
.Select(x => x.Content.MapTo<FavoriteItemViewModel>())
.ObserveOnMainThread()
.Subscribe(FavoriteItems.Add);
Listen<ContentUnFavorited>()
.ObserveOnMainThread()
.Select(x => FavoriteItems.Find(x.Content.Id))
.Subscribe(x => FavoriteItems.Remove(x));
}
示例6: BaseMenuViewModel
protected BaseMenuViewModel(IAccountsService accountsService)
{
AccountsService = accountsService;
DeletePinnedRepositoryCommand = ReactiveCommand.Create();
PinnedRepositories = new ReactiveList<PinnedRepository>(AccountsService.ActiveAccount.PinnnedRepositories);
DeletePinnedRepositoryCommand.OfType<PinnedRepository>()
.Subscribe(x =>
{
AccountsService.ActiveAccount.PinnnedRepositories.Remove(x);
AccountsService.Update(AccountsService.ActiveAccount);
PinnedRepositories.Remove(x);
});
}
示例7: AccountsViewModel
public AccountsViewModel(IAccountsService accountsService)
{
_accountsService = accountsService;
_accounts = new ReactiveList<GitHubAccount>(accountsService.OrderBy(x => x.Username));
this.WhenActivated(d => _accounts.Reset(accountsService.OrderBy(x => x.Username)));
Accounts = _accounts.CreateDerivedCollection(CreateAccountItem);
this.WhenAnyValue(x => x.ActiveAccount)
.Subscribe(x =>
{
foreach (var account in Accounts)
account.Selected = Equals(account.Account, x);
});
DeleteAccountCommand = ReactiveCommand.Create();
DeleteAccountCommand.OfType<GitHubAccount>().Subscribe(x =>
{
if (Equals(accountsService.ActiveAccount, x))
ActiveAccount = null;
accountsService.Remove(x);
_accounts.Remove(x);
});
LoginCommand = ReactiveCommand.Create();
LoginCommand.OfType<GitHubAccount>().Subscribe(x =>
{
if (Equals(accountsService.ActiveAccount, x))
DismissCommand.ExecuteIfCan();
else
{
ActiveAccount = x;
MessageBus.Current.SendMessage(new LogoutMessage());
DismissCommand.ExecuteIfCan();
}
});
DismissCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.ActiveAccount).Select(x => x != null))
.WithSubscription(x => base.DismissCommand.ExecuteIfCan(x));
GoToAddAccountCommand = ReactiveCommand.Create()
.WithSubscription(_ => ShowViewModel(CreateViewModel<NewAccountViewModel>()));
}