public void Initialize() { using (new PerformanceTrace("new Workspace")) { workspace = new ScriptingWorkspace(CreateHostServices()); workspace.WorkspaceChanged += WorkspaceChanged; } PropertyChangedEventManager.AddHandler(documentService, DocumentServicePropertyChanged, ""); CollectionChangedEventManager.AddHandler(documentService.DocumentFiles, DocumentsCollectionChanged); foreach (var documentFile in documentService.DocumentFiles) { AddProject(documentFile); } ShellViewModel.StartCommand = startCommand; ShellViewModel.StopCommand = stopCommand; ShellViewModel.FormatDocumentCommand = formatDocumentCommand; ShellViewModel.ErrorListView = ErrorListViewModel.View; ShellViewModel.OutputView = OutputViewModel.View; ShellViewModel.IsErrorListViewVisible = true; }
public TransposedItemsSource(IEnumerable source) { this.source = new WeakReference(source); var type = source.GetElementType(); this.Properties = TypeDescriptor.GetProperties(type); this.rows = this.Properties.OfType <PropertyDescriptor>() .Select(x => new TransposedRow(this, x)) .ToList(); this.IsReadOnly = this.Properties.OfType <PropertyDescriptor>() .Any(x => !x.IsReadOnly); if (source is INotifyCollectionChanged incc) { CollectionChangedEventManager.AddListener(incc, this); } foreach (var inpc in this.Source.OfType <INotifyPropertyChanged>()) { PropertyChangedEventManager.AddListener(inpc, this, string.Empty); } }
private void OnItemsSourceChanged(IEnumerable oldItemsSource, IEnumerable newItemsSource) { //Unsubscribe from the old list changed event, if any. if (oldItemsSource != null) { var oldNotifyCollectionChanged = oldItemsSource as INotifyCollectionChanged; if (oldNotifyCollectionChanged != null) { CollectionChangedEventManager.RemoveListener(oldNotifyCollectionChanged, this); } else { var oldBindingList = oldItemsSource as IBindingList; if (oldBindingList != null && oldBindingList.SupportsChangeNotification) { ListChangedEventManager.RemoveListener(oldBindingList, this); } } } //Subscribe from to the new list changed event, if any. if (newItemsSource != null) { var newNotifyCollectionChanged = newItemsSource as INotifyCollectionChanged; if (newNotifyCollectionChanged != null) { CollectionChangedEventManager.AddListener(newNotifyCollectionChanged, this); } else { var newBindingList = newItemsSource as IBindingList; if (newBindingList != null && newBindingList.SupportsChangeNotification) { ListChangedEventManager.AddListener(newBindingList, this); } } } }
// Token: 0x06001A5F RID: 6751 RVA: 0x0007D89C File Offset: 0x0007BA9C private void HookUpToCollection(IEnumerable newCollection, bool shouldRaiseChangeEvent) { this._viewList = null; if (this.View != null) { CollectionChangedEventManager.RemoveHandler(this.View, new EventHandler <NotifyCollectionChangedEventArgs>(this.OnCollectionChanged)); if (this._traceLog != null) { this._traceLog.Add("Unsubscribe to CollectionChange from {0}", new object[] { TraceLog.IdFor(this.View) }); } } if (newCollection != null) { this._view = CollectionViewSource.GetDefaultCollectionView(newCollection, this, null); } else { this._view = null; } if (this.View != null) { CollectionChangedEventManager.AddHandler(this.View, new EventHandler <NotifyCollectionChangedEventArgs>(this.OnCollectionChanged)); if (this._traceLog != null) { this._traceLog.Add("Subscribe to CollectionChange from {0}", new object[] { TraceLog.IdFor(this.View) }); } } if (shouldRaiseChangeEvent) { this.OnContainedCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } }
/// <summary> /// Initializes a new instance of the <see cref="WallpaperCategoryVM" /> class. /// </summary> /// <param name="category"> /// The <see cref="WallpaperManager.Models.Wallpaper" /> which should be wrapped by this View Model. /// </param> /// <param name="wallpaperChangerVM"> /// The <see cref="ViewModels.WallpaperChangerVM" /> instance used to control cycle operations /// performed by this View Model. /// </param> /// <param name="requestConfigureSelected"> /// The delegate invoked to request the configuration of the selected <see cref="WallpaperVM" /> instances. /// </param> /// <param name="requestConfigureDefaultSettings"> /// The delegate invoked to request the configuration of the <see cref="WallpaperDefaultSettings" />. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="category" /> or <paramref name="wallpaperChangerVM" /> or /// <paramref name="requestConfigureSelected" /> or <paramref name="requestConfigureDefaultSettings" /> is <c>null</c>. /// </exception> /// <commondoc select='ViewModels/General/seealso' /> public WallpaperCategoryVM( WallpaperCategory category, WallpaperChangerVM wallpaperChangerVM, Action <WallpaperCategoryVM> requestConfigureSelected, Action <WallpaperCategoryVM> requestConfigureDefaultSettings) { this.Category = category; this.WallpaperChangerVM = wallpaperChangerVM; this.RequestConfigureSelected = requestConfigureSelected; this.RequestConfigureDefaultSettings = requestConfigureDefaultSettings; CollectionChangedEventManager.AddListener(category, this); // Simulate adding of all wallpapers to the category so that a WallpaperVM is created for any Wallpaper instance. this.handleCategoryCollectionChanged = true; this.Category_CollectionChanged( this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, category)); this.selectedWallpaperVMs = new ReadOnlyCollection <WallpaperVM>(new List <WallpaperVM>()); PropertyChangedEventManager.AddListener(wallpaperChangerVM, this, string.Empty); this.WallpaperChangerVM_PropertyChanged(this, new PropertyChangedEventArgs("ActiveWallpapers")); }
public static IObservable <IReadOnlyList <T> > ObserveAll <T>(this IActiveList <T> list) { var subject = new Subject <IReadOnlyList <T> >(); var handler = new EventHandler <NotifyCollectionChangedEventArgs>((o, e) => { var count = list.Count; var array = new T[count]; for (int i = 0; i < count; ++i) { array[i] = list[i]; } subject.OnNext(array); }); CollectionChangedEventManager.AddHandler(list, handler); subject.Subscribe(_ => { }, () => CollectionChangedEventManager.RemoveHandler(list, handler)); return(subject); }
private void FirstTimeLoadedHandler(object sender, RoutedEventArgs e) { Loaded -= FirstTimeLoadedHandler; transcodeItemsCollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(ViewModel.TranscodingManager.TranscodeItems); transcodeItemsCollectionView.IsLiveSorting = true; transcodeItemsCollectionView.LiveSortingProperties.Add(nameof(TranscodeItem.TranscodeStatus)); var statusSortDescription = new SortDescription(nameof(TranscodeItem.TranscodeStatus), ListSortDirection.Ascending); transcodeItemsCollectionView.SortDescriptions.Add(statusSortDescription); transcodeItemsCollectionView.IsLiveGrouping = true; transcodeItemsCollectionView.LiveGroupingProperties.Add(nameof(TranscodeItem.TranscodeStatus)); var statusGroupDescription = new PropertyGroupDescription(nameof(TranscodeItem.TranscodeStatus)); transcodeItemsCollectionView.GroupDescriptions.Add(statusGroupDescription); foreach (var item in ViewModel.TranscodingManager.TranscodeItems) { PropertyChangedEventManager.AddHandler(item, TranscodeItemPropertyChanged, ""); } CollectionChangedEventManager.AddHandler(ViewModel.TranscodingManager.TranscodeItems, TranscodeItemsCollectionChanged); }
/// <summary>Called when the ItemsSource property changes.</summary> /// <param name="oldValue">Old value of the ItemsSource property.</param> /// <param name="newValue">New value of the ItemsSource property.</param> protected override void OnItemsSourceChanged(IEnumerable oldValue, IEnumerable newValue) { base.OnItemsSourceChanged(oldValue, newValue); INotifyCollectionChanged notifyCollectionChanged = oldValue as INotifyCollectionChanged; INotifyCollectionChanged notifyCollectionChanged2 = newValue as INotifyCollectionChanged; if (notifyCollectionChanged != null) { CollectionChangedEventManager.RemoveListener(notifyCollectionChanged, this); } if (notifyCollectionChanged2 != null) { CollectionChangedEventManager.AddListener(notifyCollectionChanged2, this); } if (base.IsInitialized) { if (!VirtualizingStackPanel.GetIsVirtualizing((DependencyObject)this) || (VirtualizingStackPanel.GetIsVirtualizing((DependencyObject)this) && newValue != null)) { RemoveUnavailableSelectedItems(); } UpdateSelectedMemberPathValuesBindings(); UpdateValueMemberPathValuesBindings(); } }
public PolyLineVerticesAdorner(IPolyLineCanvasItem adornedObject) : base(adornedObject) { CollectionChangedEventManager.AddHandler(adornedObject.Points, (sender, e) => { switch (e.Action) { case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Reset: ResetThumbs(); break; case NotifyCollectionChangedAction.Move: case NotifyCollectionChangedAction.Replace: Debug.Assert(e.NewItems.Count == 1); //Debug.Print("Load VT {0} -- {1}", vertexThumbs.GetHashCode(), vertexThumbs.Count); if (vertexThumbs.Count > e.OldStartingIndex) { vertexThumbs[e.OldStartingIndex].RefreshPosition(); } break; } }); }
internal void Invalidate() { ClearAllCaches(); // only track changes if source collection isn't already of type IList if (List == null) { if (Enumerable is INotifyCollectionChanged icc) { #if NET45 CollectionChangedEventManager.RemoveHandler(icc, OnCollectionChanged); #elif NET40 CollectionChangedEventManager.RemoveListener(icc, this); #endif } } _enumerable = null; DisposeEnumerator(ref _enumerator); DisposeEnumerator(ref _changeTracker); _collection = null; _list = null; _filterCallback = null; }
private void Observe(INotifyCollectionChanged source) { CollectionChangedEventManager.AddHandler(source, OnCollectionChanged); }
public ChampionshipsView() { InitializeComponent(); DataContext = this; CollectionChangedEventManager.AddListener(ChampionshipsReposidory.Instance, this); }
public CustomerGroupsViewModel(IBAWindow parentView) { this.parentView = parentView; updateButtons(); CollectionChangedEventManager.AddListener(CustomerGroupsReposidory.Instance, this); }
/// <summary> /// Initializes a new instance of the <see cref="QueryObservableResult{TSource, TResult}"/> class. /// </summary> /// <param name="source">The source collection.</param> protected QueryObservableResult(IReadOnlyObservableCollection <TSource> source) { Source = source; CollectionChangedEventManager.AddListener(source, this); }
public RemindersViewModel(IBAWindow parentView) { this.parentView = parentView; updateButtons(); CollectionChangedEventManager.AddListener(ReminderItemsReposidory.Instance, this); }
public void OnDeactivated() { CollectionChangedEventManager.RemoveListener(NotificationsReposidory.Instance, this); }
public MvvmCommand <TParam> AddListener <TEntity>(INotifyCollectionChanged source) { CollectionChangedEventManager.AddListener(source, weakCollectionChangedEventListener); return(this); }
protected virtual void raiseCollectionChanged(NotifyCollectionChangedEventArgs e) { CollectionChangedEventManager.DeliverEvent(this, e); }
private void OnItemPropertyCollectionChanged(DataGridItemPropertyCollection collection, NotifyCollectionChangedEventArgs e) { var rootCollection = ItemsSourceHelper.GetRootCollection(collection); if (rootCollection == null) { return; } if (rootCollection == m_masterItemProperties) { if (e.Action == NotifyCollectionChangedAction.Reset) { throw new NotSupportedException(); } if (e.Action == NotifyCollectionChangedAction.Move) { return; } using (this.DeferMappingChanged()) { if (e.OldItems != null) { foreach (DataGridItemPropertyBase itemProperty in e.OldItems) { this.UnregisterItemProperty(itemProperty); this.UnmapMasterItemProperty(itemProperty); } } if (e.NewItems != null) { foreach (DataGridItemPropertyBase itemProperty in e.NewItems) { this.RegisterItemProperty(itemProperty); this.MapMasterItemProperty(itemProperty); } } } } else if (rootCollection == m_detailItemProperties) { if (e.Action == NotifyCollectionChangedAction.Reset) { throw new NotSupportedException(); } if (e.Action == NotifyCollectionChangedAction.Move) { return; } using (this.DeferMappingChanged()) { if (e.OldItems != null) { foreach (DataGridItemPropertyBase itemProperty in e.OldItems) { this.UnregisterItemProperty(itemProperty); this.UnmapDetailItemProperty(itemProperty); } } if (e.NewItems != null) { foreach (DataGridItemPropertyBase itemProperty in e.NewItems) { this.RegisterItemProperty(itemProperty); this.MapDetailItemProperty(itemProperty); } } } } else { Debug.Fail("The collection should have been either for the master or the detail item properties."); CollectionChangedEventManager.RemoveListener(collection, this); } }
private void timeline_TimelineReady(object sender, EventArgs e) { timeline.ResetEvents(Resource.Monet); CollectionChangedEventManager.AddListener(timeline.SelectedTimelineEvents, this); }
// Token: 0x06001B49 RID: 6985 RVA: 0x00080688 File Offset: 0x0007E888 private void RemoveCollectionContainer(CollectionContainer cc) { CollectionChangedEventManager.RemoveHandler(cc, new EventHandler <NotifyCollectionChangedEventArgs>(this.OnContainedCollectionChanged)); }
/// <summary> /// Used to restore a folder from persistance. /// </summary> public Folder(StoreItemMetaInfo <FolderId> meta) : base(meta) { myEntries = new ObservableCollection <IStoreItem>(); CollectionChangedEventManager.AddHandler(myEntries, OnCollectionChanged); }
public usrUserInfo() { InitializeComponent(); txtProfileStatus.MaxLength = Constants.ProfileStatusColumnLength; CollectionChangedEventManager.AddListener(MessagesReposidory.Instance, this); }
public usrUserRemindersViewModel() { CollectionChangedEventManager.AddListener(NotificationsReposidory.Instance, this); }
private void RegisterNodeCollectionChanged(INotifyCollectionChanged source, NotifyCollectionChangedEventHandler handler) { m_nodesCollectionChangedEventHandlers.Add(source, handler); CollectionChangedEventManager.AddListener(source, this); }
public usrMessagesBoard() { InitializeComponent(); CollectionChangedEventManager.AddListener(MessagesReposidory.Instance, this); //usrMessageView1.Visible = false; }
protected DocumentController(IFileService fileService) { this.fileService = fileService ?? throw new ArgumentNullException(nameof(fileService)); PropertyChangedEventManager.AddHandler(fileService, FileServicePropertyChanged, ""); CollectionChangedEventManager.AddHandler(fileService.Documents, DocumentsCollectionChanged); }
public void Initialize() { CollectionChangedEventManager.AddHandler(LogViewModel.AppliedFilterList, OnFilterChanged); }
public override void Fill() { _myPlacesCache = MyPlacesReposidory.GetCache(PageContext != null?PageContext.User.GlobalId:(Guid?)null); CollectionChangedEventManager.AddListener(_myPlacesCache, this); FillItems(); }
public void Shutdown() { CollectionChangedEventManager.RemoveHandler(LogViewModel.AppliedFilterList, OnFilterChanged); }