Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 private string RankKey(TaxonRank rank)
 {
     return RankKey(rank.KingdomCode, rank.Code);
 }
Ejemplo n.º 6
0
 public ConvertingMoveDropAction(TaxonDropContext context, TaxonRank RankToConvertTo)
     : base(context)
 {
     this.ConvertRank = RankToConvertTo;
 }