void PestHostAssociateControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var selected = this.DataContext as AssociateViewModel;

            if (selected != null)
            {
                if (selected.RelativeCatID == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Taxon) || selected.RelativeCatID == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Material))
                {
                    // txtAssociate.Text = selected.AssocName;
                    var lookupType = TraitCategoryTypeHelper.GetLookupTypeFromCategoryID(selected.RelativeCatID.Value);
                    lblAssociateType.Content = lookupType.ToString();
                }
                else
                {
                    // txtAssociate.Text = selected.AssocDescription;
                    lblAssociateType.Content = "Description";
                }

                _manualSet = true;
                if (selected.RelativeRelationFromTo.Equals("host", StringComparison.CurrentCultureIgnoreCase))
                {
                    optPest.IsChecked = true;
                }
                else
                {
                    optHost.IsChecked = true;
                }
                _manualSet = false;
            }
        }
Esempio n. 2
0
        public static int GetCategoryIDFromLookupType(LookupType l)
        {
            switch (l)
            {
            case LookupType.Material:
                return(TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Material));

            case LookupType.Taxon:
                return(TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Taxon));

            default:
                return(-1);
            }
        }
Esempio n. 3
0
 internal LookupType GetLookupTypeFromAssociateCategoryId(int catId)
 {
     if (catId == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Material))
     {
         return(LookupType.Material);
     }
     else if (catId == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Taxon))
     {
         return(LookupType.Taxon);
     }
     else
     {
         return(LookupType.Unknown);
     }
 }
Esempio n. 4
0
 private void EditAssociatedItem(int catId, int intraCatId)
 {
     if (catId == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Material))
     {
         PluginManager.Instance.EditLookupObject(LookupType.Material, intraCatId);
     }
     else if (catId == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Taxon))
     {
         PluginManager.Instance.EditLookupObject(LookupType.Taxon, intraCatId);
     }
     else
     {
         // Don't think this should ever happen!
         ErrorMessage.Show("Error!");
     }
 }
Esempio n. 5
0
        protected string CategoryIDToString(int?catId)
        {
            if (!catId.HasValue)
            {
                return("");
            }

            if (catId.Value == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Material))
            {
                return("Material");
            }

            if (catId.Value == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Taxon))
            {
                return("Taxon");
            }

            return("");
        }
Esempio n. 6
0
        private void PinAssociatedItem(int catId, int intraCatId)
        {
            LookupType     type   = LookupType.Unknown;
            IBioLinkPlugin plugin = null;

            if (catId == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Material))
            {
                type   = LookupType.Material;
                plugin = PluginManager.Instance.GetLookupTypeOwner(LookupType.Material);
            }
            else if (catId == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Taxon))
            {
                type   = LookupType.Taxon;
                plugin = PluginManager.Instance.GetLookupTypeOwner(LookupType.Taxon);
            }

            if (plugin != null)
            {
                PluginManager.Instance.PinObject(new PinnableObject(plugin.Name, type, intraCatId));
            }
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var str = value as string;

            if (str != null)
            {
                switch (str)
                {
                case "Description":
                    return(null);

                case "Taxon":
                    return(TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Taxon));

                case "Material":
                    return(TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Material));

                default:
                    throw new Exception("Unhandled Associate Type: " + str);
                }
            }

            return(null);
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var toCatID = value as int?;

            if (toCatID != null && toCatID.HasValue && toCatID.Value > 0)
            {
                if (toCatID == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Material))
                {
                    return(TraitCategoryType.Material.ToString());
                }
                if (toCatID == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Taxon))
                {
                    return(TraitCategoryType.Taxon.ToString());
                }
                else
                {
                    throw new Exception("Unhandled Associate Type: " + toCatID);
                }
            }
            else
            {
                return("Description");
            }
        }