public TaxonRank ShowChooseConversion(TaxonRank sourceRank, List<TaxonRank> choices) { // Prepare the form... grid.RowDefinitions[0].Height = Zero; grid.RowDefinitions[1].Height = Forty; grid.RowDefinitions[2].Height = Forty; optConvert.Content = _owner.GetCaption("DragDropOptions.lblConvert", sourceRank.LongName); optConvert.IsChecked = true; cmbRanks.ItemsSource = choices; cmbRanks.SelectedIndex = 0; if (ShowDialog().GetValueOrDefault(false)) { return cmbRanks.SelectedItem as TaxonRank; } return null; }
internal TaxonViewModel AddNewTaxon(TaxonViewModel parent, TaxonRank rank, bool unplaced = false) { return AddNewTaxon(parent, rank.Code, (taxon) => { taxon.Unplaced = unplaced; string parentChildElemType = GetChildElementType(parent); if (!String.IsNullOrEmpty(parentChildElemType) && taxon.ElemType != parentChildElemType) { TaxonRank parentChildRank = Service.GetTaxonRank(parentChildElemType, parent.KingdomCode); if (!Service.IsValidChild(parentChildRank, rank)) { throw new Exception("Cannot insert an " + rank.LongName + " entry because this entry cannot be a valid current for the current children."); } else { // Create a new unplaced to hold the existing children TaxonViewModel newUnplaced = AddNewTaxon(parent, rank.Code, (t) => { t.Unplaced = true; }, false, false); foreach (HierarchicalViewModelBase vm in parent.Children) { // Don'note add the new child as a child of itself! Its already been added to children collection by the other AddNewTaxon method if (vm != newUnplaced) { TaxonViewModel child = vm as TaxonViewModel; newUnplaced.Children.Add(child); child.TaxaParentID = newUnplaced.TaxaID; child.Parent = newUnplaced; RegisterPendingChange(new MoveTaxonDatabaseCommand(child, newUnplaced), this); } } parent.Children.Clear(); parent.Children.Add(newUnplaced); newUnplaced.IsExpanded = true; } } }, true); }
public bool IsValidChild(TaxonRank src, TaxonRank dest) { if (dest != null) { ISet<string> valid = SplitCSV(dest.ValidChildList); return valid.Contains(src.Code, StringComparer.OrdinalIgnoreCase); } return false; }
public List<TaxonRank> GetChildRanks(TaxonRank targetRank) { var map = GetTaxonRankMap(); string[] valid = targetRank.ValidChildList.Split(','); List<TaxonRank> result = new List<TaxonRank>(); foreach (string child in valid) { string elemType = child; if (child.StartsWith("'") && child.EndsWith("'")) { elemType = child.Substring(1, child.Length - 2); } string key = RankKey(targetRank.KingdomCode, elemType); if (map.ContainsKey(key)) { result.Add(map[key]); } } return result; }
private string RankKey(TaxonRank rank) { return RankKey(rank.KingdomCode, rank.Code); }
public ConvertingMoveDropAction(TaxonDropContext context, TaxonRank RankToConvertTo) : base(context) { this.ConvertRank = RankToConvertTo; }