public void Add(ProjectSetting p) { tv_ProjectSettingViewModel tvp = new tv_ProjectSettingViewModel(p); _listProjectSettings.Add(tvp); ParentTreeView.treeView.Items.Refresh(); }
public tv_BSCViewModel(List <ProjectSetting> projects, TreeViewModelControl.TreeViewControl tree) { ParentTreeView = tree; foreach (ProjectSetting p in projects) { tv_ProjectSettingViewModel tvp = new tv_ProjectSettingViewModel(p); _listProjectSettings.Add(tvp); } }
public void Refresh(EditedEntity editedEnity) { bool breakAll = false; Boolean itemFound = false; switch (editedEnity.BSCEntity.GetType().Name) { case "ProjectSetting": ProjectSetting editedProjectSetting = (ProjectSetting)editedEnity.BSCEntity; foreach (TreeViewItemViewModel tvi in treeView.Items) { tv_ProjectSettingViewModel psvm = (tv_ProjectSettingViewModel)tvi; if (psvm._projectSetting.ProjectID == editedProjectSetting.ProjectID) { itemFound = true; if (editedEnity.EditAction == EditAction.Delete) { } else if (editedEnity.EditAction == EditAction.Update) { psvm.Edit(editedProjectSetting); } break; } } if (!itemFound && editedEnity.EditAction == EditAction.Add) { _bscViewModel.Add(editedProjectSetting); } treeView.Items.Refresh(); break; case "Sampling": Sampling sampling = (Sampling)editedEnity.BSCEntity; if (editedEnity.EditAction == EditAction.Add) { foreach (TreeViewItemViewModel projectItem in treeView.Items) { if (projectItem.IsExpanded) { foreach (TreeViewItemViewModel landingSiteItem in projectItem.Children) { if (sampling.LandingSite.LandingSiteID == ((tv_LandingSiteViewModel)landingSiteItem)._landingSite.LandingSiteID) { itemFound = true; if (landingSiteItem.IsExpanded) { itemFound = false; foreach (TreeViewItemViewModel gearItem in landingSiteItem.Children) { if (((tv_GearViewModel)gearItem)._gear.GearName == sampling.Gear.GearName) { itemFound = true; if (gearItem.IsExpanded) { itemFound = false; foreach (TreeViewItemViewModel monthItem in gearItem.Children) { tv_MonthFishingViewModel month = (tv_MonthFishingViewModel)monthItem; if (month.MonthName == sampling.DateTimeSampled.ToString("MMM-yyyy")) { itemFound = true; breakAll = true; break; } } //month not found in gear if (!itemFound && editedEnity.EditAction == EditAction.Add) { ((tv_GearViewModel)gearItem).Refresh(); itemFound = true; breakAll = true; break; } } } } //gear was not found under landing site if (!itemFound && editedEnity.EditAction == EditAction.Add) { ((tv_LandingSiteViewModel)landingSiteItem).Add(sampling.Gear); breakAll = true; itemFound = true; break; } } } } //landing site was not found under project in the tree if (!itemFound) { ((tv_ProjectSettingViewModel)projectItem).Add(sampling.LandingSite); itemFound = true; breakAll = true; break; } } if (breakAll) { break; } } } break; } }
public tv_LandingSiteViewModel(LandingSite landingSite, tv_ProjectSettingViewModel parent) : base(parent, true) { _landingSite = landingSite; _projectSetting = parent._projectSetting; }