Exemplo n.º 1
0
        public TaxonNameDetails(int?taxonId, User user, Action <TaxonNameViewModel> successAction)  : base(user, "TaxonNameDetails::" + taxonId.Value)
        {
            _successAction = successAction;

            var   service = new TaxaService(user);
            Taxon taxon   = service.GetTaxon(taxonId.Value);

            _rank        = service.GetTaxonRank(taxon);
            _kingdomList = service.GetKingdomList();
            Kingdom kingdom = _kingdomList.Find((k) => k.KingdomCode.Equals(taxon.KingdomCode));

            _model = new TaxonNameViewModel(taxon, kingdom, _rank);

            _model.DataChanged += new DataChangedHandler(_model_DataChanged);

            InitializeComponent();

            cmbKingdom.ItemsSource = _kingdomList;

            this.chkChangedCombination.Visibility = (_rank != null && _rank.Category == "S" ? Visibility.Visible : Visibility.Hidden);

            if (taxon.AvailableName.ValueOrFalse() || taxon.LiteratureName.ValueOrFalse())
            {
                string phraseCategory = "ALN Name Status";
                chkChangedCombination.Visibility = System.Windows.Visibility.Hidden;
                if (taxon.AvailableName.ValueOrFalse())
                {
                    TaxonRank rank = service.GetTaxonRank(taxon);

                    if (rank != null)
                    {
                        switch (rank.Category.ToLower())
                        {
                        case "g": phraseCategory = "GAN Name Status";
                            break;

                        case "s": phraseCategory = "SAN Name Status";
                            break;
                        }
                    }
                }

                txtNameStatus.BindUser(PluginManager.Instance.User, PickListType.Phrase, phraseCategory, TraitCategoryType.Taxon);
            }
            else
            {
                txtNameStatus.Visibility = System.Windows.Visibility.Collapsed;
                lblNameStatus.Visibility = System.Windows.Visibility.Collapsed;
            }

            this.DataContext       = _model;
            this.ChangesCommitted += new PendingChangesCommittedHandler(TaxonNameDetails_ChangesCommitted);
        }
Exemplo n.º 2
0
        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++;
            }
        }