protected override void Dispose(bool isnotFromFinalizer) { if (isnotFromFinalizer) { if (this.recentCollection != null) { this.recentCollection.CollectionChanged -= this.recentCollection_CollectionChanged; } this.recentCollection = null; } base.Dispose(isnotFromFinalizer); }
/// <summary>Weak subscription on <see cref="System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged"/> event.</summary> /// <returns>Weak event subscription instance.</returns> /// <param name="eventSource">The source of the event.</param> /// <param name="eventHandler">Represents the method that will handle the <see cref="System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged"/> event.</param> /// <exception cref="ArgumentNullException"><paramref name="eventSource" /> is null.-or-<paramref name="eventHandler" /> is null.</exception> public static IDisposable CollectionChangedWeakSubscribe( this System.Collections.Specialized.INotifyCollectionChanged eventSource, EventHandler <System.Collections.Specialized.NotifyCollectionChangedEventArgs> eventHandler) { if (eventSource == null) { throw new ArgumentNullException(nameof(eventSource)); } if (eventHandler == null) { throw new ArgumentNullException(nameof(eventHandler)); } return(new NotifyCollectionChangedEventHandlerWeakEventSubscription <System.Collections.Specialized.INotifyCollectionChanged>( eventSource, (source, handler) => source.CollectionChanged += handler, (source, handler) => source.CollectionChanged -= handler, eventHandler)); }
public void UnregisterCollection(System.Collections.Specialized.INotifyCollectionChanged collection) { }
public void RegisterCollection(System.Collections.Specialized.INotifyCollectionChanged collection, object tag = null) { }
public CollectionObserver(System.Collections.Specialized.INotifyCollectionChanged collection, object tag = null, Orc.Memento.IMementoService mementoService = null) { }
/// <summary>元のViewModelからテンプレート一覧を作る</summary> /// <param name="projectCreationViewModel"></param> /// <returns></returns> private bool BuildTemplateNodes(object projectCreationViewModel) { this.TemplateNodes.Clear(); this.Tags.Clear(); Type t = projectCreationViewModel.GetType(); var extensions = projectCreationViewModel.GetType() .GetProperty("Extensions")? .GetValue(projectCreationViewModel) as System.Collections.IEnumerable; if (extensions == null) { return(false); } //"その他"に対応する文字列を調べる IEnumerable <TreeNodeTemplateItem> converter(bool forTest) => extensions.Cast <object>().Select(o_ext => CreateTreeNodeItemFromExtension(o_ext, forTest)).OfType <TreeNodeTemplateItem>(); var tagOther = converter(true).SelectMany(n => n.Tags.Where(_ => _.Id?.ToString() == "other")).FirstOrDefault(); if (tagOther != null) { this.header_other = tagOther.Value ?? "Other"; } this.Tags.Clear(); int nodeOrderIndex = 0; foreach (TreeNodeTemplateItem node in converter(false)) { node.OrderIndex = nodeOrderIndex++; this.TemplateNodes.Add(node); } //ユーザーテンプレートに言語タグが付いていないので他の言語と比較して設定 TreeNodeTemplateItem[] noLanguageTemplates = this.TemplateNodes.Where(_ => _.LanguageTags.Count() == 1 && _.LanguageTags.First().IsOther).ToArray(); Tag[] languageTags = this.Tags.Where(_ => _.Type == TagTypeKey.Language && !_.IsOther).ToArray(); foreach (Tag languageTag in languageTags) { var languages = this.TemplateNodes.Where(_ => _.Tags.Contains(languageTag)).Select(_ => new TemplateWrapper(_).ProjectType).Distinct().ToArray(); if (languages.Length == 1) { string language = languages[0]; foreach (TreeNodeTemplateItem nolanguage in noLanguageTemplates.Where(_ => _.TemplateWrapper.ProjectType == language)) { int index = nolanguage.RemoveTag(nolanguage.LanguageTags.First()); nolanguage.insertTag(index, languageTag); } } } foreach (TreeNodeTemplateItem userTemplate in this.TemplateNodes.Where(_ => _.TemplateWrapper.IsUserTemplate)) { userTemplate.OrderIndex -= 10000; } //最近使ったテンプレートの一覧用 this.recentNode = new TreeNodeItem() { Header = header_recent, IsExpanded = true, IsVisible = true }; var mruvm = projectCreationViewModel.GetType().GetProperty("MruNewProjectsListViewModel")?.GetValue(projectCreationViewModel); if (mruvm != null) { var recents = mruvm?.GetType().GetProperty("RecentTemplates")?.GetValue(mruvm) as System.Collections.IEnumerable; UpdateRecentNode(recents); this.recentCollection = recents as System.Collections.Specialized.INotifyCollectionChanged; if (this.recentCollection != null) { this.recentCollection.CollectionChanged += recentCollection_CollectionChanged; } } //2017にはあるオンラインテンプレートの検索はマーケットプレイスのページを表示させる var link = new Hyperlink(new Run("Online")) { NavigateUri = new Uri("https://marketplace.visualstudio.com/search?sortBy=Downloads&category=Templates&target=VS&vsVersion=vs2019") }; System.Windows.Controls.TextBlock onlineHeader = new System.Windows.Controls.TextBlock(); onlineHeader.Inlines.Add(link); onlineHeader.ToolTip = "Open Marketplace"; link.RequestNavigate += (s, e) => { if (e.Uri != null) { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(e.Uri.AbsoluteUri)); link.NavigateUri = null; Window.GetWindow(onlineHeader)?.Close(); } }; this.onlineNode = new TreeNodeItem() { Header = onlineHeader, IsExpanded = true, IsVisible = true }; foreach (Tag tag in Tags.Where(_ => _.IsOther).ToArray()) { this.Tags.Remove(tag); this.Tags.Add(tag); } return(true); }
public static TCommand UpdateOn <TCommand>(this TCommand command, INotifyCollectionChanged property) where TCommand : ICanExecuteChange { property.CollectionChanged += (s, a) => command.OnCanExecuteChanged(); return(command); }