Beispiel #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);
        }
Beispiel #2
0
        /// <summary>
        /// Sets the current selected item
        /// </summary>
        /// <param name="pci">Previous CalendarItem</param>
        /// <param name="nci">New CalendarItem</param>
        /// <returns>New selected CalendarItem</returns>
        protected override CalendarItem SetSelectedItem(CalendarItem pci, CalendarItem nci)
        {
            if (nci != null)
                nci.IsSelected = true;

            else if (pci != null)
                pci.IsSelected = false;

            return (nci);
        }
Beispiel #3
0
        private void SetNewDragItem(TimeLineView pv, CalendarItem view)
        {
            _LastBounds = pv._LastBounds;
            _LastMovePoint = pv._LastMovePoint;
            _LastPointOffset = pv._LastPointOffset;

            int dx = _LastPointOffset.X - _LastBounds.X;

            CalendarView.CalendarPanel.InternalMouseMove(new
                MouseEventArgs(MouseButtons.None, 0, view.Bounds.X + dx, view.Bounds.Y, 0));

            MouseEventArgs args = new
                MouseEventArgs(MouseButtons.Left, 1, view.Bounds.X + dx, view.Bounds.Y, 0);

            IsMoving = true;

            InternalMouseMove(args);
            CalendarView.CalendarPanel.InternalMouseDown(args);

            SelectedItem = view;

            IsCopyDrag = true;
        }
Beispiel #4
0
        private void GetCondensedCustomItems(List<CalendarItem> items)
        {
            for (int i = 0; i < CalendarView.CustomItems.Count; i++)
            {
                CustomCalendarItem item = CalendarView.CustomItems[i];

                if (IsCustomItemVisible(item) == true &&
                    (item.StartTime < EndDate && item.EndTime > StartDate))
                {
                    CalendarItem ci = new CalendarItem();

                    ci.StartTime = item.StartTime;
                    ci.EndTime = item.EndTime;
                    ci.ModelItem = item;

                    items.Add(ci);
                }
            }
        }
Beispiel #5
0
        private void GetCondensedAppts(List<CalendarItem> items)
        {
            AppointmentSubsetCollection appts =
                ((ModelTimeLineViewConnector)Connector).Appts;

            if (appts != null && appts.Count > 0)
            {
                int n = Math.Min(appts.Count, 500);
                n = Math.Max(appts.Count / n, 1);

                for (int i = 0; i < appts.Count; i += n)
                {
                    if (IsAppointmentVisible(appts[i]) == true)
                    {
                        CalendarItem ci = new CalendarItem();

                        ci.StartTime = appts[i].StartTime;
                        ci.EndTime = appts[i].EndTime;
                        ci.ModelItem = appts[i];

                        items.Add(ci);
                    }
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Get the RowHeight for the given CalendarItem
        /// </summary>
        /// <param name="item">CalendarItem</param>
        /// <param name="height">Calculated height</param>
        /// <returns></returns>
        private int GetRowHeight(CalendarItem item, int height)
        {
            TimeLineGetRowHeightEventArgs e =
                new TimeLineGetRowHeightEventArgs(item, height);

            CalendarView.DoTimeLineGetRowHeight(e);

            return (e.Height);
        }
Beispiel #7
0
        /// <summary>
        /// Returns copy of the item.
        /// </summary>
        public override BaseItem Copy()
        {
            CalendarItem objCopy = new CalendarItem();
            CopyToItem(objCopy);

            return (objCopy);
        }
Beispiel #8
0
        /// <summary>
        /// Gets the starting day index for the given appointment
        /// </summary>
        /// <returns>Day of week index (0-6)</returns>
        private int GetDayIndex(CalendarItem item)
        {
            DateTime date = _WeekDayView.DayColumns[0].Date;

            for (int i = 0; i < _WeekDayView.DayColumns.Length; i++)
            {
                date = date.AddDays(1);

                if (date > item.StartTime)
                    return (i);
            }

            return (0);
        }
Beispiel #9
0
        /// <summary>
        /// Calculates the display bounds for the AppointmentView
        /// </summary>
        /// <param name="item">CalendarItem</param>
        /// <param name="acc">Row accumulator</param>
        private void CalcAppointmentBounds(CalendarItem item, ref int[] acc)
        {
            // Determine the starting day index for
            // the given appointment

            int ns = GetDayIndex(item);

            // Calculate the top and height for the item

            Rectangle r = _WeekDayView.DayColumns[ns].Bounds;

            r.X += 2;
            r.Width -= 3;

            r.Y = _WeekDayView.ClientRect.Y + _WeekDayView.DayOfWeekHeaderHeight + _VScrollPos + 2;
            r.Height = _WeekDayView.AppointmentHeight;

            // Check to see if the appointment spans
            // multiple days

            if (item.StartTime.Day != item.EndTime.Day ||
                (item.EndTime - item.StartTime).TotalDays > 1)
            {
                // Determine the ending day index

                DateTime st = _WeekDayView.DayColumns[ns].Date;

                int ne = ns + (item.EndTime - st).Days;

                if (item.EndTime.Hour > 0 || item.EndTime.Minute > 0 || item.EndTime.Second > 0)
                    ne++;

                if (ne > acc.Length)
                    ne = acc.Length;

                // Loop through each covered day, accumulating
                // the day width and max key slot height

                int maxAcc = acc[ns];

                for (int i = ns + 1; i < ne; i++)
                {
                    r.Width += _WeekDayView.DayColumns[i].Bounds.Width;

                    if (acc[i] > maxAcc)
                        maxAcc = acc[i];
                }

                // Set the top of this item to the calculated
                // slot height

                r.Y += maxAcc;

                // Loop through each effected slot and adjust it's
                // accumulated values accordingly

                maxAcc += _WeekDayView.AppointmentHeight;

                for (int i = ns; i < ne; i++)
                    acc[i] = maxAcc;
            }
            else
            {
                // This is a single day appointment, so set and
                // adjust it's values accordingly

                r.Y += acc[ns];
                acc[ns] += _WeekDayView.AppointmentHeight;
            }

            // Now that we have calculated the items height and
            // width, invoke a Recalc on the item

            item.WidthInternal = r.Width;
            item.HeightInternal = r.Height - 1;

            item.RecalcSize();

            // Set our bounds for the item

            r.Width = item.WidthInternal;
            r.Height = item.HeightInternal;

            item.Bounds = r;

            // Set it's display state

            item.Displayed = true;
        }
Beispiel #10
0
        /// <summary>
        /// Returns the SlotItem (if present) in the given list for
        /// the CalendarItem in question
        /// </summary>
        /// <param name="item">CalendarItem</param>
        /// <param name="n">Slot level to scan</param>
        /// <returns>SlotItem, if found</returns>
        private SlotItem GetColumnSlot(CalendarItem item, int n)
        {
            if (n < _SList.Count)
            {
                // Loop through each SlotItem at the given
                // level, looking for an intersection with the
                // given CalendarItem

                List<SlotItem> list = _SList[n];

                for (int i = 0; i < list.Count; i++)
                {
                    SlotItem si = list[i];

                    DateTime start = item.StartTime > si.CItem.StartTime ? item.StartTime : si.CItem.StartTime;
                    DateTime end = item.EndTime < si.CItem.EndTime ? item.EndTime : si.CItem.EndTime;

                    // If we found an item, return it

                    if (start < end)
                        return (si);
                }
            }

            // Nothing currently at that slot

            return (null);
        }
Beispiel #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="cItem">CalendarItem</param>
 public SlotItem(CalendarItem cItem)
 {
     _CItem = cItem;
 }