public ViewModelBase GetViewModel(PinnableObject pinnable)
 {
     if (pinnable != null)
     {
         return(GetViewModel(pinnable.LookupType, pinnable.ObjectID));
     }
     return(null);
 }
 public bool AcceptDroppedPinnable(PinnableObject pinnable)
 {
     if (pinnable.LookupType == LookupType.Material || pinnable.LookupType == LookupType.Taxon)
     {
         return(true);
     }
     return(false);
 }
        public LinkedMultimediaItemsControl(MultimediaLinkViewModel viewModel)
        {
            InitializeComponent();
            this.DataContext = viewModel;

            this.MultimediaID = viewModel.MultimediaID;
            var service = new SupportService(User);

            var mm = service.GetMultimedia(MultimediaID);

            var items = service.ListItemsLinkedToMultimedia(MultimediaID);
            var model = new ObservableCollection <ViewModelBase>();

            foreach (MultimediaLinkedItem item in items)
            {
                if (!string.IsNullOrWhiteSpace(item.CategoryName))
                {
                    LookupType t;
                    if (Enum.TryParse <LookupType>(item.CategoryName, out t))
                    {
                        var vm = PluginManager.Instance.GetViewModel(t, item.IntraCatID);
                        if (vm != null)
                        {
                            model.Add(vm);
                            vm.Tag = t;
                        }
                    }
                }
            }

            lvw.MouseRightButtonUp += new MouseButtonEventHandler(lvw_MouseRightButtonUp);

            ListViewDragHelper.Bind(lvw, (dragged) => {
                if (dragged.Tag is LookupType)
                {
                    var lookupType = (LookupType)dragged.Tag;
                    var plugin     = PluginManager.Instance.GetLookupTypeOwner(lookupType);

                    if (plugin != null)
                    {
                        var data     = new DataObject("Pinnable", dragged);
                        var pinnable = new PinnableObject(plugin.Name, lookupType, dragged.ObjectID.Value);
                        data.SetData(PinnableObject.DRAG_FORMAT_NAME, pinnable);
                        data.SetData(DataFormats.Text, dragged.DisplayLabel);
                        return(data);
                    }
                }
                return(null);
            });

            lvw.ItemsSource = model;
            CollectionView myView = (CollectionView)CollectionViewSource.GetDefaultView(lvw.ItemsSource);

            myView.SortDescriptions.Add(new SortDescription("Tag", ListSortDirection.Ascending));
            myView.SortDescriptions.Add(new SortDescription("DisplayLabel", ListSortDirection.Ascending));

            myView.GroupDescriptions.Add(new LinkedItemGroupDescription());
        }
示例#4
0
 public void Pin(PinnableObject pinnable)
 {
     this.InvokeIfRequired(() => {
         ViewModelBase model = GetViewModelForPinnable(pinnable);
         if (model != null)
         {
             model.Tag = pinnable;
             _model.Add(model);
         }
     });
 }
        public PinnableObject GetPinnableForLookupType(LookupType lookupType, int?objectId)
        {
            var plugin = GetLookupTypeOwner(lookupType);

            if (plugin != null && objectId.HasValue)
            {
                var pinnable = new PinnableObject(plugin.Name, lookupType, objectId.Value);
                return(pinnable);
            }
            return(null);
        }
 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();
     }
 }
示例#7
0
 public static Func <ViewModelBase, DataObject> CreatePinnableGenerator(string pluginName, LookupType lookupType)
 {
     return(new Func <ViewModelBase, DataObject>((selected) => {
         var data = new DataObject("Pinnable", selected);
         var pinnable = new PinnableObject(pluginName, lookupType, selected.ObjectID.GetValueOrDefault(0));
         data.SetData(PinnableObject.DRAG_FORMAT_NAME, pinnable);
         data.SetData(DataFormats.Text, selected.DisplayLabel);
         data.SetData(DataFormats.UnicodeText, selected.DisplayLabel);
         data.SetData(DataFormats.StringFormat, selected.DisplayLabel);
         return data;
     }));
 }
示例#8
0
        private ViewModelBase GetViewModelForPinnable(PinnableObject pinnable)
        {
            IBioLinkPlugin plugin = PluginManager.Instance.PluginByName(pinnable.PluginID);

            if (plugin != null)
            {
                return(plugin.CreatePinnableViewModel(pinnable));
            }
            else
            {
                throw new Exception("Could not find a plugin with the name " + pinnable.PluginID);
            }
        }
        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;
                }
            }
        }
        public ViewModelBase GetViewModel(LookupType t, int objectId)
        {
            var candidates = new List <ViewModelBase>();

            TraversePlugins((plugin) => {
                if (plugin.CanEditObjectType(t))
                {
                    var pinnable = new PinnableObject(plugin.Name, t, objectId);
                    candidates.Add(plugin.CreatePinnableViewModel(pinnable));
                }
            });

            if (candidates.Count > 0)
            {
                return(candidates[0]);
            }
            return(null);
        }
        public object CreateTooltip()
        {
            if (ObjectID.HasValue && ObjectID.Value > 0)
            {
                var plugin = PluginManager.Instance.GetLookupTypeOwner(LookupType);
                if (plugin != null)
                {
                    var pinnable = new PinnableObject(plugin.Name, LookupType, ObjectID.Value);
                    var vm       = PluginManager.Instance.GetViewModel(pinnable);
                    if (vm != null)
                    {
                        return(vm.TooltipContent);
                    }
                }
            }

            return(ToolTip);
        }
        public T FindAdaptorForPinnable <T>(PinnableObject pinnable)
        {
            List <T> candidates = new List <T>();

            TraversePlugins((plugin) => {
                var candidate = plugin.GetAdaptorForPinnable <T>(pinnable);
                if (candidate != null)
                {
                    candidates.Add(candidate);
                }
            });

            if (candidates.Count > 0)
            {
                return(candidates[0]);
            }

            return(default(T));
        }
示例#13
0
 internal void PinObject(PinnableObject pinnable)
 {
     this._pinboard.ContentControl.Pin(pinnable);
 }
示例#14
0
 public virtual ViewModelBase CreatePinnableViewModel(PinnableObject pinnable)
 {
     return(null);
 }
示例#15
0
 public virtual T GetAdaptorForPinnable <T>(PinnableObject pinnable)
 {
     return(default(T));
 }
        public void PinObject(PinnableObject pinnable)
        {
            BioLinkCorePlugin core = GetExtensionsOfType <BioLinkCorePlugin>()[0];

            core.PinObject(pinnable);
        }
 public virtual void PopulateFromPinnable(ViewModelBase viewModel, PinnableObject pinnable)
 {
     throw new NotImplementedException();
 }
 public virtual bool AcceptDroppedPinnable(PinnableObject pinnable)
 {
     return(false);
 }