예제 #1
0
        /// <summary>
        /// Adds a CalendarItem to the running slot list
        /// </summary>
        /// <param name="item">CalendarItem to add</param>
        /// <param name="n">Slot level to add the item to</param>
        /// <returns>The added slot item</returns>
        public SlotItem AddColumnSlot(CalendarItem item, int n)
        {
            // Add a new SlotItem list if we have exceeded
            // the current list count

            if (n >= _SList.Count)
                _SList.Add(new List<SlotItem>());

            // Determine whether this item can fit in the
            // the slot list at the current level

            SlotItem si = GetColumnSlot(item, n);

            if (si != null)
            {
                // The item will fit, so add it to the list

                si.AddPeerSlot(
                    AddColumnSlot(item, n + 1), n + 1);
            }
            else
            {
                // The item won't fit, so allocate a new slot
                // item and add it to the list

                si = new SlotItem(item);

                _SList[n].Add(si);

                // Look ahead to see it we have a peer slot
                // in a future slot list

                while (n + 1 < _SList.Count)
                {
                    n++;

                    SlotItem ni = GetColumnSlot(item, n);

                    if (ni != null)
                    {
                        si.AddPeerSlot(ni, n);
                        break;
                    }
                }
            }

            // Return the added slot item

            return (si);
        }
예제 #2
0
        /// <summary>
        /// Sets all column entry counts to the given
        /// count
        /// </summary>
        /// <param name="si">Initial SlotItem</param>
        /// <param name="count">Count</param>
        private void SetColumnCount(SlotItem si, int count)
        {
            if (si.SList != null)
            {
                for (int i = 0; i < si.SList.Count; i++)
                    SetColumnCount(si.SList[i], count);
            }

            if (si.Count == 0)
                si.Count = count;
        }
예제 #3
0
        /// <summary>
        /// Adds a slot to the peer SlotItem list
        /// </summary>
        /// <param name="si">SlotItem to add</param>
        /// <param name="column">Slot column</param>
        public void AddPeerSlot(SlotItem si, int column)
        {
            if (si != null)
            {
                if (_SList == null)
                    _SList = new List<SlotItem>();

                if (_SList.Contains(si) == false)
                {
                    si.Column = column;

                    _SList.Add(si);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Gets the max column count from all
        /// zero level slot paths
        /// </summary>
        /// <param name="si">Initial SlotItem</param>
        /// <param name="count">Running level count</param>
        /// <returns></returns>
        private int GetColumnCount(SlotItem si, int count)
        {
            if (si.Count > 0)
                return (si.Count);

            int maxCount = count;

            if (si.SList != null)
            {
                for (int i = 0; i < si.SList.Count; i++)
                {
                    int c = GetColumnCount(si.SList[i], count + 1);

                    if (c > maxCount)
                        maxCount = c;
                }
            }

            return (maxCount);
        }