Exemple #1
0
        public int CompareTo(object AObject)
        {
            BarItemComparer LOther         = (BarItemComparer)AObject;
            int             LOtherPriority = Int32.MaxValue;

            if (LOther.GetPriority != null)
            {
                LOtherPriority = LOther.GetPriority(LOther.Item);
            }
            int LThisPriority = Int32.MaxValue;

            if (GetPriority != null)
            {
                LThisPriority = GetPriority(Item);
            }

            if (LOtherPriority == LThisPriority)
            {
                return(Item.GetHashCode().CompareTo(LOther.Item.GetHashCode()));                // don't allow ties, arbitrarily distinuish them
            }
            else
            {
                return(LThisPriority.CompareTo(LOtherPriority));
            }
        }
Exemple #2
0
        public virtual void AddBarItem(IWindowsBarItem item, GetPriorityHandler getPriority)
        {
            // Add the item to the sorted list
            BarItemComparer newBarItemComparer = new BarItemComparer(item, getPriority);

            _sortedBarItems.Add(newBarItemComparer, item);
            int index = _sortedBarItems.IndexOfKey(newBarItemComparer) + _reservedItems;

            if (index > _items.Count)
            {
                _items.Add(((IToolStripItemContainer)item).Item);
            }
            else
            {
                _items.Insert(index, ((IToolStripItemContainer)item).Item);
            }
        }