internal ProjectAdapter(Project target, bool isNewProject) { Target = target; OutputInformation = new MonitoredCollection <ProjectOutputAdapter>(); ActualDependants = new MonitoredCollection <ProjectAdapter>(); ActualDependencies = new MonitoredCollection <ProjectAdapter>(); if (isNewProject && Target.Outputs.Count == 0) { Target.Outputs.Add(new Output()); } foreach (var pOut in Target.Outputs) { OutputInformation.Add(new ProjectOutputAdapter(pOut)); } IsDirty = false; OutputInformation.ListChanged += OutputInformation_ListChanged; ActualDependants.BeforeRemoveItem += ActualDependants_BeforeRemoveItem; ActualDependants.ListChanged += ActualDependants_CollectionChanged; ActualDependencies.BeforeRemoveItem += ActualDependencies_BeforeRemoveItem; ActualDependencies.ListChanged += ActualDependencies_CollectionChanged; }
public ProjectOutputAdapter(Output pOut) { ActualOutput = pOut; PathList = new MonitoredCollection <string>(ActualOutput.PathList); PathList.ListChanged += ObservablePathListCollectionChanged; }
public MonitoredCollection <ProjectAdapter> FilterProjects(string text) { var lst = new MonitoredCollection <ProjectAdapter>(); lock (this) foreach (var p in Projects) { if (p.Name.ToLower().Contains(text.ToLower())) { lst.Add(p); } } return(lst); }
public MonitoredCollection <ProjectAdapter> FilterDuplicateProjects() { var lst = new MonitoredCollection <ProjectAdapter>(); lock (this) foreach (var keyVal in _hash) { if (keyVal.Value.Count > 1) { foreach (var val in keyVal.Value) { lst.Add(val); } } } return(lst); }
private void SwitchToFilteredSource(MonitoredCollection <ProjectAdapter> dataSource) { if (dataSource == null) { return; } var obj = new BuildFileCompatibleCollection(dataSource); projectsSource.EndEdit(); _bFilteredMode = true; //lstProjects.BeginUpdate(); projectsSource.SuspendBinding(); projectsSource.DataSource = obj; projectsSource.ResetBindings(true); projectsSource.ResumeBinding(); //lstProjects.EndUpdate(); }
/// <summary> /// Creates a new Model-View synchronizer. /// </summary> /// <param name="model">The Model that can change on its own accord.</param> /// <param name="view">The View that is to be automatically updated to reflect changes in the Model.</param> public ModelViewSync([NotNull] MonitoredCollection <TModel> model, [NotNull] ICollection <TView> view) { _model = model ?? throw new ArgumentNullException(nameof(model)); _view = view ?? throw new ArgumentNullException(nameof(view)); }
// ReSharper restore UnusedAutoPropertyAccessor.Local // ReSharper restore MemberCanBePrivate.Local public BuildFileCompatibleCollection(MonitoredCollection <ProjectAdapter> dataSource) { Projects = dataSource; }
/// <summary> /// Makes <paramref name="listBox"/> mirror the contents of <paramref name="collection"/>. /// </summary> private static void ConnectCollectionToListBox <T>(MonitoredCollection <T> collection, ListBox listBox) { collection.Added += entry => listBox.Items.Add(entry); collection.Removing += entry => listBox.Items.Remove(entry); }