public bool CanDropResources(IResource targetResource, IResourceList dragResources) { bool allContacts = dragResources.AllResourcesOfType("Contact"), allCategs = dragResources.AllResourcesOfType("Category"); return(allCategs || (allContacts && !targetResource.HasProp("IsNonExportable"))); }
public void Update(IActionContext context, ref ActionPresentation presentation) { IResourceList resources = context.SelectedResources.Minus( Core.ResourceStore.FindResources(null, TasksPlugin._propStatus, (int)TaskStatuses.Completed)); presentation.Visible = resources.Count > 0 && resources.AllResourcesOfType("Task"); }
public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState) { if (data.GetDataPresent(typeof(IResourceList))) // Dragging resources over { // The resources we're dragging IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList)); if (ListOfMailsOrLinkedAttachments(dragResources)) { return(DragDropEffects.Move); } if (!dragResources.AllResourcesOfType(STR.MAPIFolder)) { return(DragDropEffects.None); } foreach (IResource folder in dragResources.ValidResources) { // A default folder cannot be moved, so it can be dropped // only to its own parent for the sake of reordering if ((Folder.IsDefault(folder)) && (Folder.GetParent(folder) != targetResource)) { return(DragDropEffects.None); } // Don't allow dropping to self and own children if ((folder == targetResource) || (Folder.IsAncestor(targetResource, folder))) { return(DragDropEffects.None); } } return(DragDropEffects.Move); } return(DragDropEffects.None); }
public LinksPaneActionItem[] CreateActionLinks(IResourceList resList, ILinksPaneFilter filter) { _lastContext = new ActionContext(ActionContextKind.LinksPane, null, resList); IResource res = (resList.Count == 1) ? resList [0] : null; ArrayList result = new ArrayList(); CreateActionLinks(result, "", filter, res); if (resList.Count > 0 && resList.AllResourcesOfType(resList [0].Type)) { CreateActionLinks(result, resList [0].Type, filter, res); } return((LinksPaneActionItem[])result.ToArray(typeof(LinksPaneActionItem))); }
public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState) { if (targetResource.HasProp(PROP.Imported)) { IResourceList dragResources = data.GetData(typeof(IResourceList)) as IResourceList; if (dragResources.AllResourcesOfType("Contact")) { foreach (IResource resource in dragResources.ValidResources) { if (resource.HasProp(PROP.EntryID)) { return(DragDropEffects.Copy); } } } } return(parentHandler.DragOver(targetResource, data, allowedEffect, keyState)); }
public void Drop(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState) { if (data.GetDataPresent(typeof(IResourceList))) // Dragging resources over { // The resources we're dragging IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList)); if (targetResource != null && dragResources != null && dragResources.Count > 0) { if (ListOfMailsOrLinkedAttachments(dragResources)) { IResourceList mailsOnly = ResourceTypeHelper.ExtractListForType(dragResources, STR.Email); _moveAction.DoMove(targetResource, mailsOnly); } else if (dragResources.AllResourcesOfType(STR.MAPIFolder)) { _moveFolderAction.DoMove(targetResource, dragResources); } } } }
public override void Execute(IActionContext context) { IResourceStore store = Core.ResourceStore; IResourceList articles = store.GetAllResources("Article").Minus( store.FindResourcesWithProp(null, Core.Props.IsDeleted)); IResourceList resources = context.SelectedResources; if (!resources.AllResourcesOfType("NewsGroup")) { resources = null; } IStatusWriter writer = Core.UIManager.GetStatusWriter(this, StatusPane.UI); try { HashMap readers = new HashMap(); int i = 0; int percent = -1; foreach (IResource article in articles) { int p = (i++ *100) / articles.Count; if (p > percent) { percent = p; writer.ShowStatus("Looking through news articles: " + percent.ToString() + "%"); Application.DoEvents(); } if (resources != null && article.GetLinksOfType("NewsGroup", "Newsgroups").Intersect(resources).Count == 0) { continue; } string[] headers = article.GetPropText("MessageHeaders").Split('\n'); string reader = null; foreach (string headerLine in headers) { if (headerLine.StartsWith("X-Newsreader: ")) { reader = headerLine.Substring("X-Newsreader: ".Length).TrimEnd('\r', '\n'); } else if (headerLine.StartsWith("User-Agent: ")) { reader = headerLine.Substring("User-Agent: ".Length).TrimEnd('\r', '\n'); } if (reader != null) { for (int j = 1; j < reader.Length; ++j) { if (Char.IsDigit(reader[j])) { reader = reader.Substring(0, j - 1); break; } } reader = reader.Trim(); if (reader.Length == 0) { break; } HashMap.Entry entry = readers.GetEntry(reader); if (entry == null) { readers[reader] = 1; } else { entry.Value = ((int)entry.Value) + 1; } break; } } } PriorityQueue queue = new PriorityQueue(); foreach (HashMap.Entry e in readers) { queue.Push((int)e.Value, e.Key); } StringBuilder readersStat = new StringBuilder(); foreach (PriorityQueue.QueueEntry e in queue) { readersStat.Append("\r\n"); readersStat.Append(e.Value); readersStat.Append(": "); readersStat.Append(e.Key); } MessageBox.Show(readersStat.ToString(), "News Readers Statistics", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { writer.ClearStatus(); } }