示例#1
0
        private Control OnCreateActionLabel()
        {
            JetLinkLabel lbl = new JetLinkLabel();

            lbl.Click += LinksPaneActionManager.GetManager().OnActionLabelClick;
            lbl.Font   = _linkLabelFont;
            return(lbl);
        }
示例#2
0
 public static LinksPaneActionManager GetManager()
 {
     if (_theManager == null)
     {
         _theManager = new LinksPaneActionManager();
     }
     return(_theManager);
 }
示例#3
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();
        }
示例#4
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);
            }
        }