public List <HierarchicalViewModelBase> LoadModel(HierarchicalViewModelBase parent) { var list = new List <SiteExplorerNode>(); var service = new MaterialService(User); if (parent == null) { list.AddRange(service.GetTopLevelExplorerItems()); } else { var parentElem = parent as SiteExplorerNodeViewModel; list.AddRange(service.GetExplorerElementsForParent(parentElem.ElemID, parentElem.NodeType)); } if (Filter != null) { list.RemoveAll(Filter); } list.Sort((item1, item2) => { int compare = item1.ElemType.CompareTo(item2.ElemType); if (compare == 0) { return(item1.Name.CompareTo(item2.Name)); } return(compare); }); return(list.ConvertAll((model) => { var viewModel = (HierarchicalViewModelBase) new SiteExplorerNodeViewModel(model); viewModel.Parent = parent; return viewModel; })); }
public List <HierarchicalViewModelBase> LoadModel(HierarchicalViewModelBase parent) { var service = new TaxaService(User); List <Taxon> model = null; if (parent == null) { model = service.GetTopLevelTaxa(); } else { model = service.GetTaxaForParent((parent as TaxonViewModel).TaxaID.Value); } if (model != null) { var temp = model.Where((taxon) => { return(_options == LookupOptions.TaxonExcludeAvailableNames ? !taxon.AvailableName.ValueOrFalse() : true); }).Select((m) => { return(new TaxonViewModel(parent, m, _explorer.GenerateTaxonDisplayLabel)); }); var list = new List <HierarchicalViewModelBase>(temp); return(list); } return(null); }
public DatabaseCommand DeleteItem(HierarchicalViewModelBase selectedItem) { var item = selectedItem as SiteExplorerNodeViewModel; if (item != null) { return(new DeleteRegionCommand(item.ElemID)); } return(null); }
public int?GetElementIDForViewModel(HierarchicalViewModelBase item) { var viewmodel = item as SiteExplorerNodeViewModel; if (viewmodel != null) { return(viewmodel.ElemID); } return(null); }
public int?GetElementIDForViewModel(HierarchicalViewModelBase item) { var taxon = item as TaxonViewModel; if (taxon != null) { return(taxon.TaxaID); } return(-1); }
public TaxonViewModel(HierarchicalViewModelBase parent, Taxon taxon, TaxonLabelGenerator labelGenerator, bool isRoot = false) : base() { this.Parent = parent; this.Taxon = taxon; this.IsChanged = false; this.DataChanged += new DataChangedHandler(TaxonViewModel_DataChanged); _labelGenerator = labelGenerator; this.IsRootNode = isRoot; TaxonLabel = GenerateLabel(); }
public DatabaseCommand RenameItem(HierarchicalViewModelBase selectedItem, string newName) { var item = selectedItem as SiteExplorerNodeViewModel; if (item != null) { item.Name = newName; return(new RenameRegionCommand(item.Model)); } return(null); }
public ContextMenu GetContextMenu(HierarchicalViewModelBase selected) { if (selected is SiteExplorerNodeViewModel) { return(SiteExplorerMenuBuilder.Build(selected as SiteExplorerNodeViewModel, Explorer)); } else if (selected is SiteFavoriteViewModel) { var fav = selected as SiteFavoriteViewModel; return(SiteExplorerMenuBuilder.BuildForFavorite(fav, Explorer)); } return(null); }
public SelectionResult CreateSelectionResult(HierarchicalViewModelBase selectedItem) { var taxon = selectedItem as TaxonViewModel; if (taxon != null) { var result = new SelectionResult(); result.DataObject = taxon; result.ObjectID = taxon.TaxaID; result.Description = taxon.TaxaFullName; result.LookupType = LookupType.Taxon; return(result); } return(null); }
protected int FindIDOfParentType(SiteExplorerNodeViewModel node, SiteExplorerNodeType nodeType, int defaultId = -1) { HierarchicalViewModelBase p = node; while (p != null && (p as SiteExplorerNodeViewModel).NodeType != nodeType) { p = p.Parent; } if (p != null) { return((p as SiteExplorerNodeViewModel).ElemID); } return(defaultId); }
internal ContextMenu BuildFavoritesMenu(HierarchicalViewModelBase node) { int? favoriteId = null; bool isFavoriteGroup = false; if (node is TaxonFavoriteViewModel) { var fav = node as TaxonFavoriteViewModel; favoriteId = fav.FavoriteID; isFavoriteGroup = fav.IsGroup; } ContextMenuBuilder builder = new ContextMenuBuilder(FormatterFunc); builder.New("TaxonExplorer.menu.ShowInContents").Handler(() => { Explorer.ShowInExplorer(Taxon.TaxaID); }); MenuItem reports = CreateReportMenuItems(); if (reports != null && reports.HasItems) { builder.Separator(); builder.New("Distribution _Map").Handler(() => { Explorer.DistributionMap(Taxon); }).End(); builder.AddMenuItem(reports); } if (favoriteId != null && favoriteId.HasValue) { builder.Separator(); if (isFavoriteGroup) { builder.New("Rename group").Handler(() => { Explorer.RenameFavoriteGroup(node as TaxonFavoriteViewModel); }); builder.New("Add favorite group").Handler(() => { Explorer.AddFavoriteGroup(node); }).End(); } builder.New("Remove from favorites").Handler(() => { Explorer.RemoveFromFavorites(favoriteId.Value); }); } builder.Separator(); builder.New("_Pin to pin board").Handler(() => { PluginManager.Instance.PinObject(new PinnableObject(TaxaPlugin.TAXA_PLUGIN_NAME, LookupType.Taxon, Taxon.TaxaID.Value)); }); builder.Separator(); builder.New("_Permissions...").Handler(() => Explorer.EditBiotaPermissions(Taxon)).End(); builder.Separator(); builder.New("_Edit Name...").Handler(() => { Explorer.EditTaxonName(Taxon); }); builder.New("_Edit Details...").Handler(() => { Explorer.EditTaxonDetails(Taxon.TaxaID); }).End(); return(builder.ContextMenu); }
private void DeleteFavoriteGroup(HierarchicalViewModelBase model) { var favorite = model as TaxonFavoriteViewModel; if (favorite == null) { return; } if (favorite.IsDeleted) { return; } model.IsDeleted = true; RegisterUniquePendingChange(new DeleteFavoriteCommand(favorite.FavoriteID)); }
public SelectionResult CreateSelectionResult(HierarchicalViewModelBase selectedItem) { var item = selectedItem as SiteExplorerNodeViewModel; if (item == null) { return(null); } var result = new SelectionResult(); result.ObjectID = item.ElemID; result.Description = item.Name; result.DataObject = item.Model; result.LookupType = MaterialExplorer.GetLookupTypeFromNodeType(item.NodeType); return(result); }
void viewModel_LazyLoadChildren(HierarchicalViewModelBase item) { using (new OverrideCursor(Cursors.Wait)) { var parent = item as SiteExplorerNodeViewModel; if (parent != null) { parent.Children.Clear(); var service = new MaterialService(User); var list = service.GetExplorerElementsForParent(parent.ElemID, parent.ElemType); var viewModel = BuildExplorerModel(list, parent.IsFindViewModel); foreach (HierarchicalViewModelBase childViewModel in viewModel) { childViewModel.Parent = parent; parent.Children.Add(childViewModel); } } } }
public void ShowInContents(SiteExplorerNodeViewModel node) { if (node == null) { return; } var parentage = new MaterialService(User).GetSiteExplorerNodeParentage(node.ElemID, node.NodeType); var childlist = RegionsModel; tabMaterial.InvokeIfRequired(() => { tabMaterial.SelectedIndex = 0; // ensure contents tab is showing }); tvwMaterial.InvokeIfRequired(() => { tvwMaterial.Focus(); }); tvwMaterial.InvokeIfRequired(() => { HierarchicalViewModelBase child = null; foreach (SiteExplorerNode element in parentage) { child = childlist.FirstOrDefault((vm) => (vm.ObjectID.HasValue ? vm.ObjectID.Value : 0) == element.ElemID); if (child == null) { break; } if (child.Parent != null && !child.Parent.IsExpanded) { child.Parent.IsExpanded = true; } child.IsExpanded = true; childlist = child.Children; } if (child != null) { tvwMaterial.BringModelToView(child, regionsNode); child.IsSelected = true; } }); }
public bool CanSelectItem(HierarchicalViewModelBase candidate) { var item = candidate as SiteExplorerNodeViewModel; if (item == null) { return(false); } foreach (SiteExplorerNodeType nodeType in TargetTypes) { if (item.NodeType == nodeType) { return(true); } } return(false); }
private void BuildTaxaChildrenViewModel(HierarchicalViewModelBase item, int taxaID) { // The model node is a Taxon favorites, so we can get the 'real' taxon children for it... item.Children.Clear(); var taxaService = new TaxaService(User); List <Taxon> taxa = taxaService.GetTaxaForParent(taxaID); foreach (Taxon taxon in taxa) { TaxonViewModel child = new TaxonViewModel(item, taxon, null); if (child.NumChildren > 0) { child.LazyLoadChildren += new HierarchicalViewModelAction(viewModel_LazyLoadChildren); child.Children.Add(new ViewModelPlaceholder("Loading...")); } item.Children.Add(child); } }
private void BuildFavoritesModel(HierarchicalViewModelBase root, bool global) { var service = new SupportService(User); var list = service.GetTopTaxaFavorites(global); foreach (TaxonFavorite item in list) { var viewModel = new TaxonFavoriteViewModel(item); viewModel.Parent = root; if (item.NumChildren > 0) { viewModel.LazyLoadChildren += new HierarchicalViewModelAction(viewModel_LazyLoadChildren); viewModel.Children.Add(new ViewModelPlaceholder("Loading...")); } root.Children.Add(viewModel); root.IsExpanded = true; root.Tag = global; } }
public void LoadFavorites() { if (_model == null) { _model = new ObservableCollection <HierarchicalViewModelBase>(); _userRoot = new ViewModelPlaceholder("User Favorites"); _globalRoot = new ViewModelPlaceholder("Global Favorites"); BuildFavoritesModel(_userRoot, false); BuildFavoritesModel(_globalRoot, true); _model.Add(_userRoot); _model.Add(_globalRoot); tvwFavorites.ItemsSource = _model; btnCancel.IsEnabled = false; btnApply.IsEnabled = false; } }
private void AddViewModelByPath(ObservableCollection <HierarchicalViewModelBase> collection, TaxonDistribution model) { String[] bits = model.DistRegionFullPath.Split('\\'); var pCol = collection; HierarchicalViewModelBase parent = null; for (int i = 0; i < bits.Length; ++i) { string bit = bits[i]; var current = pCol.FirstOrDefault((candidate) => { return(candidate.DisplayLabel == bit); }); if (current == null) { if (i == bits.Length - 1) { current = new DistributionViewModel(model, bit); current.Parent = parent; current.DataChanged += new DataChangedHandler((d) => { RegisterUniquePendingChange(new SaveDistributionRegionsCommand(Taxon.Taxon, _model)); }); } else { current = new DistributionPlaceholder(bit); current.Parent = parent; parent = current; } pCol.Add(current); } else { parent = current; if (i == bits.Length - 1) { // This region exists already, but will be overridden by this one... (current as DistributionViewModel).Model = model; } } pCol = current.Children; } // return result; }
void vm_LazyLoadChildren(HierarchicalViewModelBase item) { var parent = item as DistributionRegionViewModel; if (parent != null) { using (new OverrideCursor(Cursors.Wait)) { var service = new SupportService(User); var list = service.GetDistributionRegions(parent.DistRegionID); parent.Children.Clear(); foreach (DistributionRegion region in list) { var childVm = new DistributionRegionViewModel(region); childVm.Parent = parent; childVm.LazyLoadChildren += new HierarchicalViewModelAction(vm_LazyLoadChildren); childVm.Children.Add(new ViewModelPlaceholder("Loading...")); parent.Children.Add(childVm); } } } }
public ContextMenu GetContextMenu(HierarchicalViewModelBase selected) { ContextMenuBuilder builder = new ContextMenuBuilder(null); int refId = -1; string refCode = null; if (selected is ReferenceFavoriteViewModel) { var fav = selected as ReferenceFavoriteViewModel; if (!fav.IsGroup) { refId = fav.RefID; refCode = fav.RefCode; } else { builder.New("Export favorite group").Handler(() => ExportReferenceFavorite(fav)).End(); } } else if (selected is ReferenceSearchResultViewModel) { var vm = selected as ReferenceSearchResultViewModel; refId = vm.RefID; refCode = vm.RefCode; } builder.New("Add New...").Handler(() => RefManager.Owner.AddNewReference()).End(); if (refId >= 0) { builder.Separator(); builder.New("Delete").Handler(() => RefManager.DeleteReference(refId, refCode)).End(); builder.Separator(); builder.New("Edit Details...").Handler(() => RefManager.Owner.EditReference(refId)).End(); } return(builder.ContextMenu); }
public Data.DatabaseCommand RenameItem(HierarchicalViewModelBase selectedItem, string newName) { var taxon = selectedItem as TaxonViewModel; if (taxon != null) { TaxonName name = TaxonNameParser.ParseName(taxon, newName); if (name != null) { taxon.Author = name.Author; taxon.Epithet = name.Epithet; taxon.YearOfPub = name.Year; taxon.ChgComb = name.ChangeCombination; return(new UpdateTaxonCommand(taxon.Taxon)); } else { ErrorMessage.Show("Please enter at least the epithet, with author and year where appropriate."); } } return(null); }
internal void AddFavoriteGroup(HierarchicalViewModelBase parent) { int parentGroupID = 0; if (parent == null) { return; } bool isGlobal = false; if (parent is ViewModelPlaceholder) { isGlobal = (bool)(parent as ViewModelPlaceholder).Tag; } else if (parent is TaxonFavoriteViewModel) { var parentViewModel = parent as TaxonFavoriteViewModel; isGlobal = parentViewModel.IsGlobal; parentGroupID = parentViewModel.FavoriteID; } TaxonFavorite model = new TaxonFavorite(); model.IsGroup = true; model.GroupName = "<New Folder>"; model.IsGlobal = isGlobal; model.FavoriteParentID = parentGroupID; TaxonFavoriteViewModel viewModel = new TaxonFavoriteViewModel(model); viewModel.Parent = parent; parent.Children.Add(viewModel); RegisterUniquePendingChange(new InsertFavoriteGroupCommand(model)); viewModel.IsRenaming = true; }
void vm_LazyLoadChildren(HierarchicalViewModelBase item) { using (new OverrideCursor(Cursors.Wait)) { var groupNode = item as GroupViewModel; if (groupNode != null) { item.Children.Clear(); var service = new SupportService(User); var permissions = service.GetPermissions(groupNode.GroupID); var permGroupNodes = new Dictionary <string, PermissionGroupViewModel>(); foreach (PermissionCategory perm in Enum.GetValues(typeof(PermissionCategory))) { String desc = PermissionGroups.GetDescriptionForPermission(perm); PermissionGroupViewModel permGroupNode = null; if (!permGroupNodes.ContainsKey(desc)) { permGroupNode = new PermissionGroupViewModel(desc); item.Children.Insert(0, permGroupNode); permGroupNodes[desc] = permGroupNode; } else { permGroupNode = permGroupNodes[desc]; } var permission = permissions.FirstOrDefault((p) => { return(p.PermissionID == (int)perm); }); var mask = permission == null ? 0 : permission.Mask1; permGroupNode.Children.Add(new PermissionViewModel(groupNode.GroupID, perm, mask)); } } } }
public DatabaseCommand AddNewItem(HierarchicalViewModelBase selectedItem) { var parent = selectedItem as SiteExplorerNodeViewModel; Debug.Assert(parent != null); var model = new SiteExplorerNode(); model.ElemID = -1; model.ElemType = "Region"; model.Name = "<New Region>"; model.ParentID = parent.ElemID; model.RegionID = parent.RegionID; var viewModel = new SiteExplorerNodeViewModel(model); parent.Children.Add(viewModel); viewModel.IsSelected = true; viewModel.IsRenaming = true; return(new InsertRegionCommand(viewModel.Model, viewModel)); }
void viewModel_LazyLoadChildren(HierarchicalViewModelBase item) { var vm = item as TaxonFavoriteViewModel; if (vm != null) { if (vm.IsGroup) { // Load the children of this favorites group... var service = new SupportService(User); var list = service.GetTaxaFavorites(vm.FavoriteID, vm.IsGlobal); vm.Children.Clear(); list.ForEach((tf) => { var viewModel = new TaxonFavoriteViewModel(tf); viewModel.Parent = item; if (tf.NumChildren > 0) { viewModel.LazyLoadChildren += new HierarchicalViewModelAction(viewModel_LazyLoadChildren); viewModel.Children.Add(new ViewModelPlaceholder("Loading...")); } vm.Children.Add(viewModel); }); } else { BuildTaxaChildrenViewModel(item, vm.TaxaID); } } else { if (item is TaxonViewModel) { var tvm = item as TaxonViewModel; BuildTaxaChildrenViewModel(item, tvm.TaxaID.Value); } } }
internal SiteExplorerNodeViewModel AddNewNode(HierarchicalViewModelBase parent, SiteExplorerNodeType nodeType, Func <SiteExplorerNodeViewModel, DatabaseCommand> commandFactoryFunction) { if (parent != null) { parent.IsExpanded = true; } var model = new SiteExplorerNode(); model.Name = string.Format("<New {0}>", nodeType.ToString()); if (parent is SiteExplorerNodeViewModel) { model.ParentID = (parent as SiteExplorerNodeViewModel).ElemID; } model.ElemType = nodeType.ToString(); model.ElemID = -1; model.RegionID = -1; var viewModel = new SiteExplorerNodeViewModel(model); if (parent != null) { viewModel.Parent = parent; parent.Children.Add(viewModel); } viewModel.IsSelected = true; viewModel.IsRenaming = true; if (commandFactoryFunction != null) { RegisterPendingChange(commandFactoryFunction(viewModel), this); } return(viewModel); }
private void BuildTaxaChildrenViewModel(HierarchicalViewModelBase item, int taxaID) { // The model node is a Taxon favorites, so we can get the 'real' taxon children for it... item.Children.Clear(); var taxaService = new TaxaService(User); List<Taxon> taxa = taxaService.GetTaxaForParent(taxaID); foreach (Taxon taxon in taxa) { TaxonViewModel child = new TaxonViewModel(item, taxon, null); if (child.NumChildren > 0) { child.LazyLoadChildren += new HierarchicalViewModelAction(viewModel_LazyLoadChildren); child.Children.Add(new ViewModelPlaceholder("Loading...")); } item.Children.Add(child); } }
public bool CanSelectItem(HierarchicalViewModelBase candidate) { var taxon = candidate as TaxonViewModel; return taxon != null; }
public Data.DatabaseCommand RenameItem(HierarchicalViewModelBase selectedItem, string newName) { var taxon = selectedItem as TaxonViewModel; if (taxon != null) { TaxonName name = TaxonNameParser.ParseName(taxon, newName); if (name != null) { taxon.Author = name.Author; taxon.Epithet = name.Epithet; taxon.YearOfPub = name.Year; taxon.ChgComb = name.ChangeCombination; return new UpdateTaxonCommand(taxon.Taxon); } else { ErrorMessage.Show("Please enter at least the epithet, with author and year where appropriate."); } } return null; }
public int? GetElementIDForViewModel(HierarchicalViewModelBase item) { var taxon = item as TaxonViewModel; if (taxon != null) { return taxon.TaxaID; } return -1; }
internal void CollapseChildren(HierarchicalViewModelBase taxon) { foreach (HierarchicalViewModelBase m in taxon.Children) { if (m.IsExpanded) { CollapseChildren(m); m.IsExpanded = false; } } }
private void MarkItemAsDeleted(HierarchicalViewModelBase taxon) { taxon.IsDeleted = true; // the alternate way, don'note strikethrough - just remove it, and mark the current as changed // taxon.Parent.IsChanged = true; // taxon.Parent.Children.Remove(taxon); // Although we don'note need to delete children explicitly from the database (the stored proc will take care of that for us), // we still need to mark each child as deleted in the UI foreach (HierarchicalViewModelBase child in taxon.Children) { MarkItemAsDeleted(child); } }
internal SiteExplorerNodeViewModel AddRegion(HierarchicalViewModelBase parent) { return AddNewNode(parent, SiteExplorerNodeType.Region, (viewModel) => { return new InsertRegionCommand(viewModel.Model, viewModel); }); }
public void ExpandParentages(HierarchicalViewModelBase rootNode, List<string> expanded) { if (expanded != null && expanded.Count > 0) { var todo = new Stack<HierarchicalViewModelBase>(rootNode.Children); while (todo.Count > 0) { var vm = todo.Pop(); if (vm is TaxonViewModel) { var tvm = vm as TaxonViewModel; string parentage = tvm.GetParentage(); if (expanded.Contains(parentage)) { tvm.IsExpanded = true; expanded.Remove(parentage); tvm.Children.ForEach(child => todo.Push(child)); } } } } }
public void LoadFavorites() { if (_model == null) { _model = new ObservableCollection<HierarchicalViewModelBase>(); _userRoot = new ViewModelPlaceholder("User Favorites"); _globalRoot = new ViewModelPlaceholder("Global Favorites"); BuildFavoritesModel(_userRoot, false); BuildFavoritesModel(_globalRoot, true); _model.Add(_userRoot); _model.Add(_globalRoot); tvwFavorites.ItemsSource = _model; btnCancel.IsEnabled = false; btnApply.IsEnabled = false; } }
void item_LazyLoadChildren(HierarchicalViewModelBase item) { using (new OverrideCursor(Cursors.Wait)) { item.Children.Clear(); if (item is TaxonViewModel) { TaxonViewModel tvm = item as TaxonViewModel; Debug.Assert(tvm.TaxaID.HasValue, "TaxonViewModel has no favorites id!"); List<Taxon> taxa = Service.GetTaxaForParent(tvm.TaxaID.Value); foreach (Taxon taxon in taxa) { TaxonViewModel child = new TaxonViewModel(tvm, taxon, GenerateTaxonDisplayLabel); if (child.NumChildren > 0) { child.LazyLoadChildren += new HierarchicalViewModelAction(item_LazyLoadChildren); child.Children.Add(new ViewModelPlaceholder("Loading...")); } item.Children.Add(child); } } } }
private void AddNewItem(HierarchicalViewModelBase parent) { var action = _content.AddNewItem(parent); if (action != null) { RegisterPendingChange(action, this); } }
private void ShowContextMenu(HierarchicalViewModelBase selected, FrameworkElement control) { ContextMenuBuilder builder = new ContextMenuBuilder(null); if (_content.CanAddNewItem) { builder.New("Add new").Handler(() => { AddNewItem(selected); }).End(); } if (_content.CanRenameItem) { builder.Separator(); builder.New("Rename").Handler(() => { RenameItem(selected); }).End(); } if (_content.CanDeleteItem) { builder.Separator(); builder.New("Delete").Handler(() => { DeleteItem(selected); }).End(); } if (builder.HasItems) { control.ContextMenu = builder.ContextMenu; } }
internal ContextMenu BuildFavoritesMenu(HierarchicalViewModelBase node) { int? favoriteId = null; bool isFavoriteGroup = false; if (node is TaxonFavoriteViewModel) { var fav = node as TaxonFavoriteViewModel; favoriteId = fav.FavoriteID; isFavoriteGroup = fav.IsGroup; } ContextMenuBuilder builder = new ContextMenuBuilder(FormatterFunc); builder.New("TaxonExplorer.menu.ShowInContents").Handler(() => { Explorer.ShowInExplorer(Taxon.TaxaID); }); MenuItem reports = CreateReportMenuItems(); if (reports != null && reports.HasItems) { builder.Separator(); builder.New("Distribution _Map").Handler(() => { Explorer.DistributionMap(Taxon); }).End(); builder.AddMenuItem(reports); } if (favoriteId != null && favoriteId.HasValue) { builder.Separator(); if (isFavoriteGroup) { builder.New("Rename group").Handler(() => { Explorer.RenameFavoriteGroup(node as TaxonFavoriteViewModel); }); builder.New("Add favorite group").Handler(() => { Explorer.AddFavoriteGroup(node); }).End(); } builder.New("Remove from favorites").Handler(() => { Explorer.RemoveFromFavorites(favoriteId.Value); }); } builder.Separator(); builder.New("_Pin to pin board").Handler(() => { PluginManager.Instance.PinObject(new PinnableObject(TaxaPlugin.TAXA_PLUGIN_NAME, LookupType.Taxon, Taxon.TaxaID.Value)); }); builder.Separator(); builder.New("_Permissions...").Handler(() => Explorer.EditBiotaPermissions(Taxon)).End(); builder.Separator(); builder.New("_Edit Name...").Handler(() => { Explorer.EditTaxonName(Taxon); }); builder.New("_Edit Details...").Handler(() => { Explorer.EditTaxonDetails(Taxon.TaxaID); }).End(); return builder.ContextMenu; }
private bool Select(HierarchicalViewModelBase selected) { SaveExpandedNodes(); if (_content != null) { var result = _content.CreateSelectionResult(selected); if (SelectedAction != null) { SelectedAction(result); return true; } } return false; }
public int Compare(HierarchicalViewModelBase x, HierarchicalViewModelBase y) { return(Compare(x as TaxonViewModel, y as TaxonViewModel)); }
public List<HierarchicalViewModelBase> LoadModel(HierarchicalViewModelBase parent) { var service = new TaxaService(User); List<Taxon> model = null; if (parent == null) { model = service.GetTopLevelTaxa(); } else { model = service.GetTaxaForParent((parent as TaxonViewModel).TaxaID.Value); } if (model != null) { var temp = model.Where((taxon) => { return _options == LookupOptions.TaxonExcludeAvailableNames ? !taxon.AvailableName.ValueOrFalse() : true; }).Select((m) => { return new TaxonViewModel(parent, m, _explorer.GenerateTaxonDisplayLabel); }); var list = new List<HierarchicalViewModelBase>(temp); return list; } return null; }
private void RenameItem(HierarchicalViewModelBase item) { if (item != null) { // This starts the rename, and the change is registered when the edit is complete. See EditableTextBlock_EditingComplete item.IsRenaming = true; } }
public Data.DatabaseCommand AddNewItem(HierarchicalViewModelBase selectedItem) { throw new NotImplementedException(); }
private ObservableCollection<HierarchicalViewModelBase> LoadModel(HierarchicalViewModelBase parent) { var model = new ObservableCollection<HierarchicalViewModelBase>(); if (_content != null) { var list = _content.LoadModel(parent); foreach (HierarchicalViewModelBase vm in list) { vm.Children.Add(new ViewModelPlaceholder("Loading...")); vm.LazyLoadChildren += new HierarchicalViewModelAction((p) => { using (new OverrideCursor(Cursors.Wait)) { p.Children.Clear(); var children = LoadModel(p); foreach (HierarchicalViewModelBase child in children) { p.Children.Add(child); } } }); } model = new ObservableCollection<HierarchicalViewModelBase>(list); } return model; }
public SelectionResult CreateSelectionResult(HierarchicalViewModelBase selectedItem) { var taxon = selectedItem as TaxonViewModel; if (taxon != null) { var result = new SelectionResult(); result.DataObject = taxon; result.ObjectID = taxon.TaxaID; result.Description = taxon.TaxaFullName; result.LookupType = LookupType.Taxon; return result; } return null; }
internal SiteExplorerNodeViewModel AddRegion(HierarchicalViewModelBase parent) { return(AddNewNode(parent, SiteExplorerNodeType.Region, (viewModel) => { return new InsertRegionCommand(viewModel.Model, viewModel); })); }
private string GetParentage(HierarchicalViewModelBase item) { if (item != null) { return GetParentage(item.Parent) + "/" + _content.GetElementIDForViewModel(item); } return ""; }
internal void AddFavoriteGroup(HierarchicalViewModelBase parent) { int parentGroupID = 0; if (parent == null) { return; } bool isGlobal = false; if (parent is ViewModelPlaceholder) { isGlobal = (bool) (parent as ViewModelPlaceholder).Tag; } else if (parent is TaxonFavoriteViewModel) { var parentViewModel = parent as TaxonFavoriteViewModel; isGlobal = parentViewModel.IsGlobal; parentGroupID = parentViewModel.FavoriteID; } TaxonFavorite model = new TaxonFavorite(); model.IsGroup = true; model.GroupName = "<New Folder>"; model.IsGlobal = isGlobal; model.FavoriteParentID = parentGroupID; TaxonFavoriteViewModel viewModel = new TaxonFavoriteViewModel(model); viewModel.Parent = parent; parent.Children.Add(viewModel); RegisterUniquePendingChange(new InsertFavoriteGroupCommand(model)); viewModel.IsRenaming = true; }
private void DeleteItem(HierarchicalViewModelBase item) { var action = _content.DeleteItem(item); if (action != null) { RegisterPendingChange(action, this); item.IsDeleted = true; } }
internal SiteExplorerNodeViewModel AddNewNode(HierarchicalViewModelBase parent, SiteExplorerNodeType nodeType, Func<SiteExplorerNodeViewModel, DatabaseCommand> commandFactoryFunction) { if (parent != null) { parent.IsExpanded = true; } var model = new SiteExplorerNode(); model.Name = string.Format("<New {0}>", nodeType.ToString()); if (parent is SiteExplorerNodeViewModel) { model.ParentID = (parent as SiteExplorerNodeViewModel).ElemID; } model.ElemType = nodeType.ToString(); model.ElemID = -1; model.RegionID = -1; var viewModel = new SiteExplorerNodeViewModel(model); if (parent != null) { viewModel.Parent = parent; parent.Children.Add(viewModel); } viewModel.IsSelected = true; viewModel.IsRenaming = true; if (commandFactoryFunction != null) { RegisterPendingChange(commandFactoryFunction(viewModel), this); } return viewModel; }
internal void AddFavoriteGroup(HierarchicalViewModelBase parentNode) { favorites.AddFavoriteGroup(parentNode); }