本文整理汇总了C#中ObservableCollection.CollectionChangedAsObservable方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.CollectionChangedAsObservable方法的具体用法?C# ObservableCollection.CollectionChangedAsObservable怎么用?C# ObservableCollection.CollectionChangedAsObservable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.CollectionChangedAsObservable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ActionsEditViewModel
public ActionsEditViewModel(FolderReactionModel reactionModel, PageManager pageManager, IAppPolicyManager appPolicyManager)
: base(pageManager, reactionModel)
{
_AppPolicyManager = appPolicyManager;
Reaction.ObserveProperty(x => x.IsActionsValid)
.Subscribe(x => IsValid.Value = x)
.AddTo(_CompositeDisposable);
// TODO: CollectionChangedをマージしてReactiveCollectionにする方法を使ってまとめる
// Note: AppLaunchActionViewModelをAppOptionValueInstance1つずつに対して作成している
Actions = new ObservableCollection<AppLaunchActionViewModel>(
Reaction.Actions.Select(
x =>
{
var appLaunchAction = x as AppLaunchReactiveAction;
return new AppLaunchActionViewModel(this, Reaction, appLaunchAction);
}
)
);
Actions.CollectionChangedAsObservable()
.Subscribe(itemPair =>
{
var onceRemoveItems = Reaction.Actions.ToArray();
foreach (var onceRemoveItem in onceRemoveItems)
{
Reaction.RemoveAction(onceRemoveItem);
}
foreach(var reAdditem in Actions)
{
Reaction.AddAction(reAdditem.Action);
}
});
IsActionsEmpty = Actions.ObserveProperty(x => x.Count)
.Select(x => x == 0)
.ToReactiveProperty();
IsActionsEmpty.Subscribe();
}
示例2: HistoryPageViewModel
public HistoryPageViewModel(IHistoryManager histroyManager, PageManager pageManager, IFolderReactionMonitorModel monitor, IInstantActionManager instantActionManager)
: base(pageManager)
{
HistoryManager = histroyManager;
Monitor = monitor;
InstantActionManager = instantActionManager;
ShowHistoryVMs = new ObservableCollection<HistoryDataViewModel>();
HistoryFileInfoList = new List<FileInfo>();
CanIncrementalLoad = ShowHistoryVMs.CollectionChangedAsObservable()
.Select(_ => HistoryFileInfoList.Count > ShowHistoryVMs.Count)
.ToReactiveProperty();
IncrementalLoadHistoryCommand = CanIncrementalLoad
.ToReactiveCommand();
IncrementalLoadHistoryCommand.Subscribe(_ => IncrementalLoadHistoryItems());
}
示例3: FolderReactionManagePageViewModel
public FolderReactionManagePageViewModel(PageManager pageManager, IFolderReactionMonitorModel monitor, IEventAggregator ea, IAppPolicyManager appPolicyManager, IHistoryManager historyManager, IReactiveFolderSettings settings)
: base(pageManager)
{
Monitor = monitor;
_EventAggregator = ea;
AppPolicyManager = appPolicyManager;
HistoryManager = historyManager;
Settings = settings;
CurrentFolder = new ReactiveProperty<ReactionManageFolderViewModel>();
FolderStack = new ObservableCollection<ReactionManageFolderViewModel>();
FolderStack.CollectionChangedAsObservable()
.Subscribe(x =>
{
CurrentFolder.Value = FolderStack.Last();
});
FolderStack.Add(new ReactionManageFolderViewModel(this, Monitor.RootFolder));
}
示例4: WipCommitVm
public WipCommitVm(RepositoryVm repos, TwoPaneLayoutVm twoPaneLayout)
{
Debug.Assert(repos != null);
_repos = repos;
TwoPaneLayout = twoPaneLayout ?? new TwoPaneLayoutVm().AddTo(MultipleDisposable);
SelectedWipFiles = new ObservableCollection<WipFileVm>();
SelectedWipFiles.CollectionChangedAsObservable()
.Subscribe(_ =>
{
var count = SelectedWipFiles.Count;
if (count == 0)
DiffFileViewSource = WipFiles.Value.FirstOrDefault();
else if (count == 1)
DiffFileViewSource = SelectedWipFiles.FirstOrDefault();
else
DiffFileViewSource = SelectedWipFiles;
})
.AddTo(MultipleDisposable);
SummaryRemaining =
this.ObserveProperty(x => x.Summary)
.Select(x => 80 - x.Length)
.ToReadOnlyReactiveProperty()
.AddTo(MultipleDisposable);
SummaryRemainingBrush = SummaryRemaining
.Select(x =>
{
if (x < 0)
return Brushes.Red;
if (x < 20)
return Brushes.DarkRed;
return Brushes.Gray;
})
.ToReadOnlyReactiveProperty()
.AddTo(MultipleDisposable);
CommitCommand =
this.ObserveProperty(x => x.Summary)
.Select(x => string.IsNullOrWhiteSpace(x) == false)
.ToReactiveCommand()
.AddTo(MultipleDisposable);
CommitCommand.Subscribe(_ => repos.Commit((Summary + "\n\n" + Description).Trim()))
.AddTo(MultipleDisposable);
DiscardChangesCommand = SelectedWipFiles.CollectionChangedAsObservable()
.Select(x => SelectedWipFiles.Any())
.ToReactiveCommand()
.AddTo(MultipleDisposable);
DiscardChangesCommand.Subscribe(_ =>
repos.DiscardChanges(SelectedWipFiles.Select(x => x.Path.Value))
).AddTo(MultipleDisposable);
// IsAllSelected 関係
{
IsAllSelected = new ReactiveProperty<bool?>().AddTo(MultipleDisposable);
IsAllSelected.Subscribe(i =>
{
// UI からの操作では on/off のどちらかに設定する
if (_isInUpdateIsAllSelected == false)
{
if (i.HasValue == false)
{
IsAllSelected.Value = false;
return;
}
}
if (i.HasValue == false)
return;
WipFiles.Value.ForEach(x => x.IsInStaging.Value = i.Value);
}).AddTo(MultipleDisposable);
this.ObserveProperty(x => x.WipFiles)
.Subscribe(x =>
{
_isInStageingDisposer?.Dispose();
_isInStageingDisposer = new MultipleDisposable();
x.Value.ForEach(y =>
y.IsInStaging.Subscribe(_ => UpdateIsAllSelected()).AddTo(_isInStageingDisposer));
})
.AddTo(MultipleDisposable);
MultipleDisposable.Add(() => _isInStageingDisposer?.Dispose());
}
}