Exemple #1
0
        public IActionContext GetContext(ActionContextKind kind)
        {
            ActionContext context = new ActionContext(kind, this, _resourceTree.GetSelectedResources());

            context.SetCommandProcessor(this);
            return(context);
        }
Exemple #2
0
        public override void UpdateSelection()
        {
            if (_selectorMode)
            {
                return;
            }

            IResourceList selection = _listContacts.GetSelectedResources();

            if (selection == null || selection.Count == 0)
            {
                Core.UserInterfaceAP.RunJob(new DisplayResDlgt(DisplayResourcesInUI),
                                            null, Core.ResourceStore.EmptyResourceList, string.Empty);
            }
            else
            {
                string caption = "Correspondence with " + selection[0].DisplayName;
                if (selection.Count == 1)
                {
                    //---------------------------------------------------------
                    //  Keep the optimization for the case of repeatable selection
                    //  of single items - when the selection is not changed,
                    //  give previous result.
                    //---------------------------------------------------------
                    if (_lastCorrespondent == null || selection[0].Id != _lastCorrespondent.Id)
                    {
                        _lastCorrespondent = selection[0];
                        _lastResourceList  = ContactManager.LinkedCorrespondence(selection[0]);
                        _lastResourceList.Sort(new SortSettings(Core.Props.Date, true));
                    }
                }
                else
                {
                    _lastResourceList = ContactManager.LinkedCorrespondence(selection[0]);
                    for (int i = 1; i < selection.Count; i++)
                    {
                        _lastResourceList = _lastResourceList.Union(ContactManager.LinkedCorrespondence(selection[i]), true);
                        caption           = caption + ", " + selection[i].DisplayName;
                    }
                    _lastResourceList.Sort(new SortSettings(Core.Props.Date, true));
                    _lastCorrespondent = null;
                }
                Core.UserInterfaceAP.RunJob(new DisplayResDlgt(DisplayResourcesInUI),
                                            selection[0], _lastResourceList, caption);
            }
        }