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;
            }
        }
        public void Dispose(Boolean disposing)
        {
            if (disposing)
            {
                var frm = new ShutdownProgess();
                try {
                    frm.Show();
                    Logger.Debug("Disposing the Plugin Manager");
                    List <ControlHostWindow> temp = new List <ControlHostWindow>(_hostWindows);

                    var itemCount = temp.Count + _extensions.Count;
                    frm.progressBar.Maximum = itemCount;
                    frm.progressBar.Value   = 0;
                    foreach (ControlHostWindow window in temp)
                    {
                        Logger.Debug("Disposing control host window '{0}'...", window.Title);
                        frm.StatusMessage("Closing window " + window.Title);
                        DoEvents();
                        try {
                            window.Close();
                            window.Dispose();
                        } catch (Exception ex) {
                            Logger.Warn("Exception occured whilst disposing host window '{0}' : {1}", window.Title, ex);
                        }

                        frm.progressBar.Value += 1;
                        DoEvents();
                    }

                    _extensions.ForEach((ext) => {
                        Logger.Debug("Disposing extension '{0}'", ext);
                        frm.StatusMessage("Unloading extension " + ext.Name);
                        DoEvents();
                        try {
                            ext.Dispose();
                        } catch (Exception ex) {
                            Logger.Warn("Exception occured whilst disposing plugin '{0}' : {1}", ext, ex);
                        }
                        frm.progressBar.Value += 1;
                        DoEvents();
                    });
                    _extensions.Clear();
                    frm.StatusMessage("Cleaning up temporary files...");
                    DoEvents();
                    Logger.Debug("Cleaning up resource temp files...");
                    _resourceTempFiles.CleanUp();
                    // Purge any temporary files that were created during the session
                    Logger.Debug("Cleaning up generic temp files...");
                    TempFileManager.CleanUp();

                    TraitCategoryTypeHelper.Reset();
                } finally {
                    frm.Close();
                }
            }
        }
 private void SetFromPinnable(AssociateViewModel associate, PinnableObject pinnable)
 {
     if (pinnable != null && associate != null)
     {
         var viewModel = PluginManager.Instance.GetViewModel(pinnable);
         associate.RelativeCatID      = TraitCategoryTypeHelper.GetCategoryIDFromLookupType(pinnable.LookupType);
         associate.RelativeIntraCatID = pinnable.ObjectID;
         associate.NameOrDescription  = viewModel.DisplayLabel;
         SetRelationships(associate);
         lblAssociateType.Content = pinnable.LookupType.ToString();
     }
 }
Esempio n. 4
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);
            }
        }
        public void PopulateFromPinnable(ViewModelBase viewModel, PinnableObject pinnable)
        {
            var associate = viewModel as AssociateViewModel;

            if (associate != null)
            {
                var pinnableViewModel = PluginManager.Instance.GetViewModel(pinnable);
                if (pinnableViewModel != null)
                {
                    associate.AssocName          = pinnableViewModel.DisplayLabel;
                    associate.RelativeCatID      = TraitCategoryTypeHelper.GetCategoryIDFromLookupType(pinnable.LookupType);
                    associate.RelativeIntraCatID = pinnable.ObjectID;
                }
            }
        }
Esempio n. 6
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);
     }
 }
        private void btnEditSelected_Click(object sender, RoutedEventArgs e)
        {
            var selected = DataContext as AssociateViewModel;

            if (selected != null)
            {
                if (selected.RelativeCatID.HasValue)
                {
                    var lookupType = TraitCategoryTypeHelper.GetLookupTypeFromCategoryID(selected.RelativeCatID.Value);
                    if (lookupType != LookupType.Unknown && selected.RelativeIntraCatID.HasValue)
                    {
                        PluginManager.Instance.EditLookupObject(lookupType, selected.RelativeIntraCatID.Value);
                    }
                }
            }
        }
Esempio n. 8
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!");
     }
 }
        private void GenericLookup <T>()
        {
            PluginManager.Instance.StartSelect <T>((result) => {
                var associate = this.DataContext as AssociateViewModel;
                _manualSet    = true;
                // txtAssociate.Text = result.Description;

                lblAssociateType.Content         = result.LookupType.ToString();
                associate.RelativeIntraCatID     = result.ObjectID;
                associate.RelativeCatID          = TraitCategoryTypeHelper.GetCategoryIDFromLookupType(result.LookupType);
                associate.RelativeRelationFromTo = optPest.IsChecked.ValueOrFalse() ? "Pest" : "Host";
                associate.RelativeRelationToFrom = optPest.IsChecked.ValueOrFalse() ? "Host" : "Pest";
                associate.NameOrDescription      = result.Description;

                _manualSet = false;
            }, LookupOptions.None);
        }
Esempio n. 10
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. 11
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");
            }
        }