示例#1
0
 private void _lvResources_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         e.Handled = true;
         IResourceStore store = Core.ResourceStore;
         if (_lvResources.GetSelectedResources().Count == _lvResources.JetListView.Nodes.Count)
         {
             ClipboardContents = store.EmptyResourceList;
         }
         else
         {
             IntArrayList ids = IntArrayListPool.Alloc();
             try
             {
                 ClipboardContents = _contents.Minus(_lvResources.GetSelectedResources());
             }
             finally
             {
                 IntArrayListPool.Dispose(ids);
             }
         }
     }
     else if (e.KeyData == (Keys.Control | Keys.A))
     {
         e.Handled = true;
         _lvResources.SelectAll();
     }
     else if (e.KeyData == Keys.Escape)
     {
         e.Handled = true;
         Close();
     }
 }
示例#2
0
        public override void OK()
        {
            IntArrayList uins = IntArrayListPool.Alloc();

            try
            {
                foreach (ListViewItem item in _UINsList.Items)
                {
                    if (item.Checked)
                    {
                        uins.Add((int)item.Tag);
                    }
                }
                uins.Sort();
                bool changed = (uins.Count != _uins.Count);
                if (!changed)
                {
                    for (int i = 0; i < uins.Count; ++i)
                    {
                        if (uins[i] != _uins[i])
                        {
                            changed = true;
                            break;
                        }
                    }
                }
                if (!IsStartupPane)
                {
                    ICQPlugin.SetBuildConverstionOnline(_indexOnlineCheckBox.Checked);
                    ICQPlugin.SetReverseMode(_reverseModeCheckBox.Checked);
                }
                if (!IsStartupPane && _convsTimeSpan.Value != _minutes)
                {
                    ICQPlugin.SetConversationTimeSpan(
                        new TimeSpan(((long)_convsTimeSpan.Value) * 60 * 10000000));
                    changed = true;
                }
                changed = changed ||
                          _importOnly2003bCheckbox.Checked != ICQPlugin.GetImportOnly2003b() ||
                          (_indexOnlineCheckBox.Checked &&
                           _indexOnlineCheckBox.Checked != ICQPlugin.GetBuildConverstionOnline());
                ICQPlugin.SetImportOnly2003b(_importOnly2003bCheckbox.Checked);
                // rebuild conversations if there were changes
                if (changed || IsStartupPane)
                {
                    ICQPlugin.SetUpdateDates(DateTime.MaxValue, DateTime.MinValue);
                    ICQPlugin.SaveUINs2BeIndexed(uins);
                    if (!IsStartupPane)
                    {
                        ICQPlugin.AsyncUpdateHistory();
                    }
                }
            }
            finally
            {
                IntArrayListPool.Dispose(uins);
            }
        }
示例#3
0
 public void Dispose()
 {
     if (_offsets != null)
     {
         IntArrayListPool.Dispose(_offsets);
         _offsets = null;
         Monitor.Exit(_table);
     }
 }
示例#4
0
        public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState)
        {
            if (data.GetDataPresent(typeof(IResourceList)))
            {
                // The resources we're dragging
                IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList));

                // Currently, only the Deleted Resources view has a drop handler
                if (!FilterRegistry.IsDeletedResourcesView(targetResource))
                {
                    return(DragDropEffects.None);
                }

                // Collect all the direct and indirect parents of the droptarget; then we'll check to avoid dropping parent on its children
                IntArrayList parentList = IntArrayListPool.Alloc();
                try
                {
                    IResource parent = targetResource;
                    while (parent != null)
                    {
                        parentList.Add(parent.Id);
                        parent = parent.GetLinkProp(Core.Props.Parent);
                    }

                    // Check
                    foreach (IResource res in dragResources)
                    {
                        // Dropping parent over its child?
                        if (parentList.IndexOf(res.Id) >= 0)
                        {
                            return(DragDropEffects.None);
                        }
                        // Cannot delete resource containers this way
                        if ((Core.ResourceStore.ResourceTypes[res.Type].Flags & ResourceTypeFlags.ResourceContainer) != 0)
                        {
                            return(DragDropEffects.None); // Cannot delete containers
                        }
                    }
                    return(DragDropEffects.Move);
                }
                finally
                {
                    IntArrayListPool.Dispose(parentList);
                }
            }
            else
            {
                return(DragDropEffects.None);
            }
        }
示例#5
0
        public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState)
        {
            if (data.GetDataPresent(typeof(IResourceList)))
            {
                // The resources we're dragging
                IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList));

                // Check if really dropping over a view-folder
                if (!(targetResource.Type == FilterManagerProps.ViewFolderResName))
                {
                    return(DragDropEffects.None);
                }

                // Collect all the direct and indirect parents of the droptarget; then we'll check to avoid dropping parent on its children
                IntArrayList parentList = IntArrayListPool.Alloc();
                try
                {
                    IResource parent = targetResource;
                    while (parent != null)
                    {
                        parentList.Add(parent.Id);
                        parent = parent.GetLinkProp(Core.Props.Parent);
                    }

                    // Check
                    foreach (IResource res in dragResources)
                    {
                        // Dropping parent over its child?
                        if (parentList.IndexOf(res.Id) >= 0)
                        {
                            return(DragDropEffects.None);
                        }
                        // Can drop only views and view-folders on view-folders
                        if (!FilterRegistry.IsViewOrFolder(res))
                        {
                            return(DragDropEffects.None);
                        }
                    }
                    return(DragDropEffects.Move);
                }
                finally
                {
                    IntArrayListPool.Dispose(parentList);
                }
            }
            return(DragDropEffects.None);
        }
示例#6
0
        /**
         * Parses the specified property name string into an array of property IDs.
         */

        public int[] PropNamesToIDs(string[] propNames, bool ignoreErrors)
        {
            IntArrayList propIDs = IntArrayListPool.Alloc();

            try
            {
                for (int i = 0; i < propNames.Length; i++)
                {
                    string propName = propNames [i].Trim();

                    if (String.Compare(propName, "DisplayName", true, CultureInfo.InvariantCulture) == 0)
                    {
                        propIDs.Add(ResourceProps.DisplayName);
                    }
                    else if (String.Compare(propName, "Type", true, CultureInfo.InvariantCulture) == 0)
                    {
                        propIDs.Add(ResourceProps.Type);
                    }
                    else
                    {
                        int direction = 1;
                        if (propName.StartsWith("-"))
                        {
                            propName  = propName.Substring(1);
                            direction = -1;
                        }
                        try
                        {
                            propIDs.Add(Core.ResourceStore.GetPropId(propName) * direction);
                        }
                        catch (StorageException)
                        {
                            if (!ignoreErrors)
                            {
                                throw new ArgumentException("Invalid property name " + propName);
                            }
                        }
                    }
                }
                return(propIDs.ToArray());
            }
            finally
            {
                IntArrayListPool.Dispose(propIDs);
            }
        }
示例#7
0
        private static SortSettings LoadSortSettings(IResource res, DisplayColumnProps props)
        {
            IStringList  sortPropList = res.GetStringListProp(props.ColumnSortProps);
            IntArrayList sortProps    = IntArrayListPool.Alloc();

            try
            {
                for (int i = 0; i < sortPropList.Count; i++)
                {
                    string sortPropName = sortPropList [i];
                    if (sortPropName == "DisplayName")
                    {
                        sortProps.Add(ResourceProps.DisplayName);
                    }
                    else if (sortPropName == "Type")
                    {
                        sortProps.Add(ResourceProps.Type);
                    }
                    else if (sortPropName.StartsWith("-"))
                    {
                        sortPropName = sortPropName.Substring(1);
                        if (Core.ResourceStore.PropTypes.Exist(sortPropName))
                        {
                            sortProps.Add(-Core.ResourceStore.PropTypes [sortPropName].Id);
                        }
                    }
                    else
                    {
                        if (Core.ResourceStore.PropTypes.Exist(sortPropName))
                        {
                            sortProps.Add(Core.ResourceStore.PropTypes [sortPropName].Id);
                        }
                    }
                }

                bool sortAsc = res.HasProp(props.ColumnSortAsc);
                return(new SortSettings(sortProps.ToArray(), sortAsc));
            }
            finally
            {
                IntArrayListPool.Dispose(sortProps);
            }
        }
示例#8
0
        public MailInIndexEnum GetEnumerator()
        {
            IntArrayList ids = IntArrayListPool.Alloc();

            try
            {
                if (_ids != null)
                {
                    foreach (IntHashSet.Entry entry in _ids)
                    {
                        ids.Add(entry.Key);
                    }
                }
                return(new MailInIndexEnum(ids.ToArray()));
            }
            finally
            {
                IntArrayListPool.Dispose(ids);
            }
        }
示例#9
0
        ///<summary>
        ///  Fire the event that new portion of documents is merged to major or
        ///  incremental index chunk so that:
        /// <para>
        ///  - they are indexed successfully and there is no need to remember them
        ///    in "unflushed" pool;
        /// </para><para>
        ///  - they are available for searching or search-dependent rules completion.
        /// </para><para>
        ///  NB: though amount of submitted tokens may be zero, set of propagated
        ///      documents may be non-empty because of empty documents.
        /// </para>
        ///</summary>
        private void  PropagateIndexInformation()
        {
            if (_finishedDocsInBatch.Count > 0)
            {
                NotifyIndexLoaded();

                IntArrayList newDocsInChunk = IntArrayListPool.Alloc();
                try
                {
                    foreach (IntHashTableOfInt.Entry e in _finishedDocsInBatch)
                    {
                        newDocsInChunk.Add(e.Key);
                    }

                    PropagateSearchableDocuments(newDocsInChunk);
                }
                finally
                {
                    IntArrayListPool.Dispose(newDocsInChunk);
                }
            }
        }
示例#10
0
        private void _okButton_Click(object sender, System.EventArgs e)
        {
            IntArrayList uins = IntArrayListPool.Alloc();

            try
            {
                foreach (ListViewItem item in _UINsList.Items)
                {
                    int uin = (int)item.Tag;
                    if (item.Checked || ICQPlugin.IndexedUIN(uin))
                    {
                        uins.Add(uin);
                    }
                }
                ICQPlugin.SetUpdateDates(DateTime.MaxValue, DateTime.MinValue);
                ICQPlugin.SaveUINs2BeIndexed(uins);
                ICQPlugin.AsyncUpdateHistory();
            }
            finally
            {
                IntArrayListPool.Dispose(uins);
            }
        }
示例#11
0
        /// <summary>
        /// Shows the "See also" links for every resource type that is found in the
        /// specified resource list but not included in the specified array of resource types.
        /// </summary>
        public void ShowLinks(IResource ownerResource, IResourceList resList,
                              string[] excludeResTypes, int excludeLinkPropId)
        {
            #region Preconditions
            if (!Core.UserInterfaceAP.IsOwnerThread)
            {
                throw new InvalidOperationException("See Also bar must be shown from the UI thread");
            }
            #endregion Preconditions

            CountedSet countByTab = new CountedSet();

            IntArrayList sourceLinkTypes = IntArrayListPool.Alloc();
            try
            {
                foreach (IPropType propType in Core.ResourceStore.PropTypes)
                {
                    if (propType.HasFlag(PropTypeFlags.SourceLink))
                    {
                        sourceLinkTypes.Add(propType.Id);
                    }
                }

                WorkspaceManager wspMgr          = Core.WorkspaceManager as WorkspaceManager;
                IResource        activeWorkspace = Core.WorkspaceManager.ActiveWorkspace;

                bool filterViewsExclusive = false;
                if (ownerResource.Type == "SearchView" && !ownerResource.HasProp("ShowInAllTabs"))
                {
                    filterViewsExclusive = true;
                }

                int outsideWorkspaceCount = 0, unfoundCount = 0;

                IResourceList actualRcs = resList;
                lock ( actualRcs )
                {
                    foreach (IResource res in actualRcs.ValidResources)
                    {
                        string resType = res.Type;
                        if (resType == "Fragment")
                        {
                            resType = res.GetStringProp(Core.Props.ContentType);
                            // guard for broken DB (OM-12080)
                            if (resType == null || !Core.ResourceStore.ResourceTypes.Exist(resType))
                            {
                                continue;
                            }
                        }

                        if (activeWorkspace != null && !activeWorkspace.HasLink(wspMgr.Props.WorkspaceVisible, res))
                        {
                            outsideWorkspaceCount++;
                            continue;
                        }

                        if (excludeResTypes != null && IsTabType(resType, excludeResTypes))
                        {
                            continue;
                        }

                        if (excludeLinkPropId >= 0 && res.HasProp(excludeLinkPropId))
                        {
                            continue;
                        }

                        if (filterViewsExclusive && Core.ResourceTreeManager.AreViewsExclusive(resType))
                        {
                            continue;
                        }

                        bool found = false;
                        if (Core.ResourceStore.ResourceTypes[resType].HasFlag(ResourceTypeFlags.FileFormat))
                        {
                            foreach (int sourceLinkType in sourceLinkTypes)
                            {
                                if (res.HasProp(sourceLinkType))
                                {
                                    string tabId = Core.TabManager.FindLinkPropTab(sourceLinkType);
                                    if (tabId != null)
                                    {
                                        countByTab.Add(tabId);
                                    }

                                    found = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            string resourceTabId = Core.TabManager.FindResourceTypeTab(resType);
                            if (resourceTabId != null)
                            {
                                countByTab.Add(resourceTabId);
                                found = true;
                            }
                        }

                        if (!found)
                        {
                            unfoundCount++;
                        }
                    }
                }

                if (countByTab.Count == 0 && unfoundCount == 0 && outsideWorkspaceCount == 0)
                {
                    Visible = false;
                    return;
                }

                _iconPool.MoveControlsToPool();
                _linkLabelPool.MoveControlsToPool();

                int x = _title.Right + 4;

                int labelCount = 0;
                for (int i = 0; i < Core.TabManager.Tabs.Count; i++)
                {
                    string tabId = Core.TabManager.Tabs[i].Id;
                    int    count = countByTab[tabId];
                    if (count > 0)
                    {
                        string text = Core.TabManager.Tabs[i].Name + " (" + count.ToString() + ")";
                        AddLinkLabel(tabId, text, ref x);
                        labelCount++;
                    }
                }

                if ((labelCount > 1 || unfoundCount > 0) && (excludeResTypes != null || excludeLinkPropId >= 0))
                {
                    AddLinkLabel("", "All Results (" + (resList.Count - outsideWorkspaceCount) + ")", ref x);
                }

                if (outsideWorkspaceCount > 0)
                {
                    string sDefaultWspName = ((WorkspaceManager)Core.WorkspaceManager).Props.DefaultWorkspaceName;
                    AddLinkLabel("<Main>", String.Format("{0} Workspace ({1})", sDefaultWspName, resList.Count), ref x);
                }

                _iconPool.RemovePooledControls();
                _linkLabelPool.RemovePooledControls();
                Visible = true;
            }
            finally
            {
                IntArrayListPool.Dispose(sourceLinkTypes);
            }
        }
示例#12
0
        private void BuildVerticalViewLinks(LinkSection section)
        {
            int curY     = _cStartLinkY;
            int maxWidth = 0;
            int lines    = 0;
            int curX     = _contactThumb.Visible ? 4 + _contactThumb.Width : 4;

            LinksPaneActionItem[] actionItems   = null;
            IntArrayList          customPropIds = null;

            if (_verticalViewExpanded)
            {
                actionItems = LinksPaneActionManager.GetManager().CreateActionLinks(_resourceList, _filter);
                try
                {
                    foreach (IResource propTypeRes in ResourceTypeHelper.GetCustomProperties())
                    {
                        int propID = propTypeRes.GetIntProp("ID");
                        if (_resourceList [0].HasProp(propID))
                        {
                            if (customPropIds == null)
                            {
                                customPropIds = IntArrayListPool.Alloc();
                            }
                            customPropIds.Add(propID);
                        }
                    }
                }
                finally
                {
                    if (customPropIds != null)
                    {
                        IntArrayListPool.Dispose(customPropIds);
                    }
                }
            }

            LinkSection startSection = section;

            while (section != null)
            {
                AddLinkTypeLabel(ref curX, ref curY, section.Name, ref maxWidth);
                if (_verticalViewExpanded && section.Separator)
                {
                    curY += 24;
                }
                else
                {
                    curY += 16;
                }

                section = section.NextSection;
                lines++;
                if (!_verticalViewExpanded && lines == _defltVerticalViewLines)
                {
                    break;
                }
            }

            if (_verticalViewExpanded)
            {
                if (customPropIds != null)
                {
                    foreach (int propId in customPropIds)
                    {
                        AddLinkTypeLabel(ref curX, ref curY, Core.ResourceStore.PropTypes [propId].DisplayName, ref maxWidth);
                        curY += 16;
                    }
                    if (actionItems.Length > 0)
                    {
                        curY += 8;
                    }
                }
                if (actionItems.Length > 0)
                {
                    AddLinkTypeLabel(ref curX, ref curY, "Actions", ref maxWidth);
                }
            }

            maxWidth += _contactThumb.Visible ? _contactThumb.Width : 0;
            curY      = _cStartLinkY;
            section   = startSection;

            lines = 0;
            while (section != null)
            {
                curX = maxWidth + 20;
                AddLinksFromSection(section, ref curX, curY);
                if (_verticalViewExpanded && section.Separator)
                {
                    curY += 24;
                }
                else
                {
                    curY += 16;
                }
                section = section.NextSection;
                lines++;
                if (!_verticalViewExpanded && lines == _defltVerticalViewLines)
                {
                    break;
                }
            }

            if (_verticalViewExpanded)
            {
                if (customPropIds != null || actionItems.Length > 0)
                {
                    curY += 2;       // 2 is delta in AddLinkTypeLabel()
                }

                if (customPropIds != null)
                {
                    curX = maxWidth + 20;
                    foreach (int propId in customPropIds)
                    {
                        AddCustomPropertyLabel(curX, curY, GetCustomPropText(_resourceList [0], propId));
                        curY += 16;
                    }
                    if (actionItems.Length > 0)
                    {
                        curY += 8;
                    }
                }
                if (actionItems.Length > 0)
                {
                    curX = maxWidth + 20;
                    int midX = curX + (Width - curX) / 2;
                    for (int i = 0; i < actionItems.Length; i += 2)
                    {
                        AddActionLabel(actionItems[i], curX, curY);
                        if (i + 1 < actionItems.Length)
                        {
                            AddActionLabel(actionItems[i + 1], midX, curY);
                        }
                        curY += 16;
                    }
                }
            }

            if (curY > 16)
            {
                Height = curY + 6;
            }
            else
            {
                // make sure the expand/collapse button is visible when the links bar is empty
                Height = 22;
            }
            //  Update height if the amount of links is small (1 or 2).
            if (_contactThumb.Visible)
            {
                Height = Math.Max(Height, _contactThumb.Height + 8);
            }
        }