Ejemplo n.º 1
0
        public override void EditResource(IResource res)
        {
            IResourceList accounts = res.GetLinksOfType(null, Props.MirandaAcct);

            accounts.Sort(new SortSettings(ResourceProps.Type, true));
            int curY = 4;

            _typeLabelPool.MoveControlsToPool();
            _valueLabelPool.MoveControlsToPool();

            foreach (IResource acct in accounts)
            {
                string acctType;
                switch (acct.Type)
                {
                case ResourceTypes.MirandaICQAccount:    acctType = "ICQ";    break;

                case ResourceTypes.MirandaAIMAccount:    acctType = "AIM";    break;

                case ResourceTypes.MirandaJabberAccount: acctType = "Jabber"; break;

                case ResourceTypes.MirandaYahooAccount:  acctType = "Yahoo";  break;

                default: acctType = "Other"; break;
                }

                Label lblType = (Label)_typeLabelPool.GetControl();
                lblType.Text     = acctType + ":";
                lblType.Location = new Point(4, curY);

                JetTextBox lblValue = (JetTextBox)_valueLabelPool.GetControl();
                if (acct.Type == ResourceTypes.MirandaICQAccount)
                {
                    lblValue.Text = acct.GetPropText("UIN");
                }
                else
                {
                    lblValue.Text = acct.DisplayName;
                }

                lblValue.Location = new Point(88, curY);
                lblValue.Width    = Width - 96;

                curY += 20;
            }

            _typeLabelPool.RemovePooledControls();
            _valueLabelPool.RemovePooledControls();

            Height = curY + 4;
        }
Ejemplo n.º 2
0
        /**
         * Moves to the pool or disposes the controls added to the links pane.
         */

        private void RemoveAllControls()
        {
            _linkTypeLabelPool.MoveControlsToPool();
            _resourceLinkLabelPool.MoveControlsToPool();
            _actionLabelPool.MoveControlsToPool();
            _separatorPool.MoveControlsToPool();
            for (int i = _borderPanel.Controls.Count - 1; i >= 0; i--)
            {
                Control ctl = _borderPanel.Controls [i];
                if (!_linkTypeLabelPool.IsPooledControl(ctl) && !_resourceLinkLabelPool.IsPooledControl(ctl) &&
                    !_actionLabelPool.IsPooledControl(ctl) && !_separatorPool.IsPooledControl(ctl))
                {
                    _borderPanel.Controls.RemoveAt(i);
                    ctl.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
        /**
         * Rebuilds the links bar.
         */

        protected override void UpdateLinksPane()
        {
            if (Core.State == CoreState.ShuttingDown)
            {
                return;
            }

            _linkTypeLabelPool.MoveControlsToPool();
            _resourceLinkLabelPool.MoveControlsToPool();
            _actionLabelPool.MoveControlsToPool();

            if (_resource != null)
            {
                FillLinkedThumb(_resource);
                FillLinksBar(_resource);
            }
            _resourceLinkLabelPool.RemovePooledControls();
            _linkTypeLabelPool.RemovePooledControls();
            _actionLabelPool.RemovePooledControls();
        }
Ejemplo n.º 4
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);
            }
        }