void TaxonTooltipContent_Loaded(object sender, RoutedEventArgs e) { var service = new TaxaService(PluginManager.Instance.User); var Model = service.GetTaxon(TaxonID); if (Model == null) { return; } var elementRank = service.GetTaxonRank(Model); var header = Model.TaxaFullName; if (Model.AvailableName.ValueOrFalse()) { header += " (Available name)"; } else if (Model.LiteratureName.ValueOrFalse()) { header += " (Literature name)"; } lblHeader.Content = header; var rankName = (elementRank == null ? "Unranked" : elementRank.LongName + (Model.AvailableName.ValueOrFalse() ? " Available Name" : "")); var kingdom = string.IsNullOrEmpty(Model.KingdomCode) ? "No Kingdom" : Model.KingdomCode; lblSystem.Content = string.Format("[{0}] {1} <{2}> Last updated: {3:g} by {4}", Model.TaxaID.Value, rankName, kingdom, Model.DateLastUpdated, Model.WhoLastUpdated); imgIcon.Source = TaxonViewModel.ConstructIcon(Model.AvailableName.ValueOrFalse() || Model.LiteratureName.ValueOrFalse(), Model.ElemType, false); // Ancestry var bits = Model.Parentage.Split('\\'); int i = bits.Length - 1; int j = 0; var parents = new Stack<Taxon>(); while (--i >= 0 && j++ < 3) { if (!string.IsNullOrEmpty(bits[i])) { var parentId = Int32.Parse(bits[i]); var parent = service.GetTaxon(parentId); parents.Push(parent); } } i = 0; grdAncestry.Children.Clear(); foreach (Taxon t in parents) { var parentPanel = new StackPanel() { Orientation = Orientation.Horizontal, Margin = new Thickness(i * 15, i * 25, 0, 0) }; var parentIcon = new Image() { VerticalAlignment = System.Windows.VerticalAlignment.Top, UseLayoutRounding = true, SnapsToDevicePixels = true, Stretch = Stretch.None, Margin = new Thickness(6, 0, 6, 0) }; parentIcon.Source = TaxonViewModel.ConstructIcon(t.AvailableName.ValueOrFalse() || t.LiteratureName.ValueOrFalse(), t.ElemType, false); parentPanel.Children.Add(parentIcon); var rank = service.GetTaxonRank(t); rankName = (rank == null ? "Unranked" : rank.LongName); var txt = new TextBlock() {VerticalAlignment = System.Windows.VerticalAlignment.Top, Text = string.Format("{1} ({0})", rankName, t.TaxaFullName) }; parentPanel.Children.Add(txt); grdAncestry.Children.Add(parentPanel); i++; } }
public XMLExportOptions(User user, List<int> taxonIds) { InitializeComponent(); TaxonIDs = taxonIds; this.User = user; var lastFile = Config.GetUser(User, "XMLIOExport.LastExportFile", ""); if (!string.IsNullOrEmpty(lastFile)) { if (taxonIds.Count == 1) { var service = new TaxaService(user); var taxon = service.GetTaxon(taxonIds[0]); if (taxon != null) { var f = new FileInfo(lastFile); var directory = f.DirectoryName; var taxaName = taxon.TaxaFullName == null ? "Unnamed" : taxon.TaxaFullName; txtFilename.Text = System.IO.Path.Combine(f.DirectoryName, SystemUtils.StripIllegalFilenameChars(taxaName) + ".xml"); } } else { txtFilename.Text = lastFile; } } }