Beispiel #1
0
        private bool AddLinksFromSection(LinkSection section, ref int curX, int curY)
        {
            ResourceLinkLabel lastLabel = null;

            foreach (LinkItem linkItem in section.LinkItems)
            {
                ResourceLinkLabel lbl = AddResourceLabel(linkItem.Resource, linkItem.PropId,
                                                         ref curX, curY);
                if (curX >= Width - 20 && (!_verticalViewMode || lastLabel != null))
                {
                    if (lastLabel != null)
                    {
                        lastLabel.PostfixText = "...";
                        lastLabel.Width       = lastLabel.PreferredWidth;
                    }
                    _resourceLinkLabelPool.MoveControlToPool(lbl);
                    return(lastLabel != null);
                }
                if (lastLabel != null)
                {
                    lastLabel.PostfixText = ",";
                    lastLabel.Width       = lastLabel.PreferredWidth;
                }
                _toolTip.SetToolTip(lbl.NameLabel, linkItem.ToolTip);
                lastLabel = lbl;
            }
            return(true);
        }
Beispiel #2
0
        void s_AddGroup(object sender, AddGroupEventArgs e)
        {
            LinkSection ls = e.LinkSection;

            if (ls.Title == "SP SIN")
            {
                ls.Template_OtherControls = new FixTemplate();
            }
        }
Beispiel #3
0
 public LinkSection(string name, LinkSection prevSection)
 {
     _name = name;
     if (prevSection != null)
     {
         prevSection._nextSection = this;
         _prevSection             = prevSection;
     }
 }
Beispiel #4
0
        protected override void UpdateLinksPane()
        {
            if (Core.State == CoreState.ShuttingDown)
            {
                return;
            }
            if (_resourceList != null && _resourceList.Count == 1 && _resourceList [0].IsDeleting)
            {
                return;
            }

            RemoveAllControls();
            _borderPanel.AutoScrollPosition = new Point(0, 0);

            if (_resourceList != null && _resourceList.Count > 0)
            {
                int curX = 0;
                int curY = 4 - _scrollY;
                if (_resourceList.Count == 1)
                {
                    LinkSection section = BuildLinksForResource(_resourceList[0]);
                    ShowLinksFromSection(section, ref curX, ref curY);
                    ShowCustomPropertiesForResource(_resourceList[0], ref curX, ref curY);
                }
                else
                {
                    AddLinkTypeLabel(ref curX, ref curY, _resourceList.Count + " resources selected");
                    curY += 8;
                }

                LinksPaneActionItem[] actionItems = LinksPaneActionManager.GetManager().CreateActionLinks(_resourceList, _filter);
                if (actionItems.Length > 0)
                {
                    AddLinkTypeLabel(ref curX, ref curY, "Actions");
                    foreach (LinksPaneActionItem item in actionItems)
                    {
                        JetLinkLabel lbl = (JetLinkLabel)_actionLabelPool.GetControl();
                        lbl.AutoSize  = false;
                        lbl.Enabled   = item.Enabled;
                        lbl.Text      = item.Text;
                        lbl.Tag       = item.Action;
                        lbl.BackColor = Color.FromArgb(0, SystemColors.Control);
                        lbl.Bounds    = new Rectangle(_linkLabelX, curY, Width - _linkLabelX - 4, lbl.PreferredSize.Height);
                        curY         += 18;
                    }
                }

                UpdateLinkLabelTooltips();
            }

            DisposePooledControls();
            _borderPanel.Invalidate();
        }
Beispiel #5
0
        protected LinkSection BuildLinksForResource(IResource res)
        {
            IntArrayList linkTypes = new IntArrayList(res.GetLinkTypeIds());

            linkTypes.Sort();

            LinkSection lastSection = null;
            LinkSection groupStartSection;

            foreach (IntArrayList propIds in _linksPaneGroups)
            {
                groupStartSection = lastSection;
                foreach (int propId in propIds)
                {
                    int idx = linkTypes.IndexOf(propId);
                    if (idx >= 0)
                    {
                        lastSection = BuildLinksForType(lastSection, propId, res);
                        linkTypes.RemoveAt(idx);
                    }
                }
                if (groupStartSection != lastSection)
                {
                    lastSection.Separator = true;
                }
            }

            groupStartSection = lastSection;
            foreach (int linkType in linkTypes)
            {
                if (_store.PropTypes [linkType].HasFlag(PropTypeFlags.Internal))
                {
                    continue;
                }

                lastSection = BuildLinksForType(lastSection, linkType, res);
            }

            if (lastSection != groupStartSection)
            {
                lastSection.Separator = true;
            }

            if (lastSection != null)
            {
                while (lastSection.PrevSection != null)
                {
                    lastSection = lastSection.PrevSection;
                }
            }
            return(lastSection);
        }
Beispiel #6
0
 private LinkSection BuildLinksForType(LinkSection lastSection, int linkType, IResource res)
 {
     if (_store.PropTypes [linkType].HasFlag(PropTypeFlags.DirectedLink))
     {
         lastSection = BuildLinkSection(lastSection, res, linkType, 1);
         lastSection = BuildLinkSection(lastSection, res, linkType, -1);
     }
     else
     {
         lastSection = BuildLinkSection(lastSection, res, linkType, 0);
     }
     return(lastSection);
 }
Beispiel #7
0
        /**
         * Creates the link type and link labels for the specified resource.
         */

        private void FillLinksBar(IResource res)
        {
            LinkSection section = BuildLinksForResource(res);

            if (_verticalViewMode)
            {
                BuildVerticalViewLinks(section);
            }
            else
            {
                BuildHorizontalViewLinks(section);
            }
        }
Beispiel #8
0
        /**
         * Shows the link type labels for the specified resource.
         */

        private LinkSection BuildLinkSection(LinkSection lastSection, IResource res, int linkType, int direction)
        {
            IResourceList resList;

            switch (direction)
            {
            case 0:  resList = res.GetLinksOfType(null, linkType);  break;

            case 1:  resList = res.GetLinksFrom(null, linkType);  break;

            case -1: resList = res.GetLinksTo(null, linkType);  break;

            default: throw new System.ArgumentException("Invalid direction parameter");
            }
            if (resList.Count == 0)
            {
                return(lastSection);
            }

            int    propId       = (direction == -1) ? -linkType : linkType;
            string linkTypeName = Core.ResourceStore.PropTypes.GetPropDisplayName(propId);

            if (_filter != null)
            {
                if (!_filter.AcceptLinkType(res, propId, ref linkTypeName))
                {
                    return(lastSection);
                }
            }

            foreach (IResource linkRes in resList.ValidResources)
            {
                string linkToolTip = null;
                if (!CheckLinkVisible(res, propId, linkRes, ref linkToolTip))
                {
                    continue;
                }

                if (lastSection == null || lastSection.Name != linkTypeName)
                {
                    lastSection = new LinkSection(linkTypeName, lastSection);
                }

                lastSection.AddResource(linkRes, propId, linkToolTip);
            }
            return(lastSection);
        }
Beispiel #9
0
        private void ShowLinksFromSection(LinkSection section, ref int curX, ref int curY)
        {
            while (section != null)
            {
                AddLinkTypeLabel(ref curX, ref curY, section.Name);

                LinkItem lastLinkItem = null;
                for (int i = 0; i < 5 && i < section.LinkItems.Count; i++)
                {
                    LinkItem item = (LinkItem)section.LinkItems [i];
                    Control  ctl  = AddResourceLabel(item.Resource, item.PropId, _resourceList [0], curY);
                    ctl.Tag      = item.ToolTip;
                    curY        += ctl.Height;
                    lastLinkItem = item;
                }
                if (section.LinkItems.Count > 5)
                {
                    JetLinkLabel seeAllLabel = AddLinkLabel(new Rectangle(_linkLabelX, curY, Width - _linkLabelX, 16),
                                                            "See All (" + section.LinkItems.Count + ")...");
                    seeAllLabel.Tag    = lastLinkItem.PropId;
                    seeAllLabel.Click += OnSeeAllClick;
                    curY += 18;
                }
                else
                {
                    curY += 2;
                }

                if (section.Separator)
                {
                    AddLinkGroupSeparator(ref curY);
                }

                section = section.NextSection;
            }
        }
Beispiel #10
0
        private void BuildHorizontalViewLinks(LinkSection section)
        {
            int curX = 4, curY = 0;

            while (section != null)
            {
                int   maxWidth  = 0;
                Label typeLabel = AddLinkTypeLabel(ref curX, ref curY, section.Name, ref maxWidth);
                if (curX > Width)
                {
                    typeLabel.Visible = false;
                    break;
                }

                if (!AddLinksFromSection(section, ref curX, curY))
                {
                    typeLabel.Visible = false;
                    break;
                }
                curX += 12;

                section = section.NextSection;
            }
        }
Beispiel #11
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);
            }
        }