Exemplo n.º 1
0
 /// <summary>
 /// Adds a CalendarItem to the collection.
 /// </summary>
 /// <param name="item">The CalendarItem to add.</param>
 public void Add(CalendarItem item)
 {
     if (!Contains(item))
     {
         List.Add(item);
     }
 }
Exemplo n.º 2
0
        private int AddWorkWeekMultiDayItemAttributes(HtmlTextWriter writer, DateTime cycleDate, CalendarItem item)
        {
            int colSpan = 0;
            for(DateTime date = cycleDate.Date; date<=Dates[Dates.Count-1]; date=date.AddDays(1))
            {
                if(Dates.Contains(date))
                {
                    // Jun 16 2004: added method AddTicks(-1)
                    if(item.StartDate.Date <= date && item.AdjustedEndDate.Date >= date)
                        colSpan++;
                }
            }

            if(colSpan==0)
                colSpan++;
            /*
            //TimeSpan spanTime = item.EndDate - item.StartDate;
            int colSpan = (Helper.GetDaySpan(item.StartDate, item.EndDate) + 1);

            // detect if events spans from previous week
            if(item.StartDate.Date<cycleDate.Date)
            {
                // Calculate span from current date
                //TimeSpan spanTime2 = item.EndDate - cycleDate.Date;
                colSpan = (Helper.GetDaySpan(cycleDate.Date, item.EndDate) + 1);
            }

            // ERROR: change this!!!
            // detect if event spans to next week
            if(colSpan>(5 - (int)cycleDate.DayOfWeek))
            {
                colSpan = (5 - (int)cycleDate.DayOfWeek) + 1;
            }
            */

            //writer.AddAttribute("colspan", colSpan.ToString());
            //AddMonthCellAttributes(writer, cycleDate);

            CalendarHeaderStyle.AddAttributesToRender(writer);
            RenderPaletteColor(writer, HtmlTextWriterStyle.BackgroundColor, CalendarHeaderStyle.BackColor, CalendarColorConstants.SubHeaderBackColor);
            RenderPaletteColor(writer, HtmlTextWriterStyle.Color, CalendarHeaderStyle.ForeColor, CalendarColorConstants.SubHeaderForeColor);

            //RenderPaletteColor(writer, HtmlTextWriterStyle.BackgroundColor, CalendarItemInactiveStyle.BackColor, CalendarColorConstants.ItemDefaultBackColor);
            //RenderPaletteColor(writer, HtmlTextWriterStyle.Color, CalendarItemInactiveStyle.ForeColor, CalendarColorConstants.ItemDefaultForeColor);

            writer.AddAttribute(HtmlTextWriterAttribute.Height, "18");
            return colSpan;
        }
Exemplo n.º 3
0
        private int AddWeekItemAttributes(HtmlTextWriter writer, DateTime cycleDate, CalendarItem item)
        {
            //TimeSpan spanTime = item.EndDate - item.StartDate;
            int colSpan = (Helper.GetDaySpan(item.StartDate, item.EndDate) + 1);

            // detect if events spans from previous week
            if(item.StartDate.Date<cycleDate.Date)
            {
                // Calculate span from current date
                //TimeSpan spanTime2 = item.EndDate - cycleDate;
                colSpan = (Helper.GetDaySpan(cycleDate, item.EndDate) + 1);
            }

            // detect if event spans to next week
            if(this.ViewType == CalendarViewType.WeekView)
            {
                if(colSpan>(7 - cycleDate.DayOfWeek.GetHashCode()))
                    colSpan = (7 - cycleDate.DayOfWeek.GetHashCode()) + 1;
            }
            else
            {
                if(colSpan>1)
                    colSpan = 1;
            }
            // [13/1/2005] - Begin
            if(colSpan>0) // [13/1/2005] - End
                writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, colSpan.ToString());
            //AddMonthCellAttributes(writer, cycleDate);
            return colSpan;
        }
Exemplo n.º 4
0
        private int AddTaskItemAttributes(HtmlTextWriter writer, DateTime cycleDate, CalendarItem item)
        {
            //TimeSpan spanTime = item.EndDate - item.StartDate;
            int colSpan = (Helper.GetDaySpan(item.StartDate, item.AdjustedEndDate) + 1);

            // detect if events spans from previous period
            if(item.StartDate.Date<cycleDate.Date)
            {
                // Calculate span from current date
                colSpan = (Helper.GetDaySpan(cycleDate.Date, item.AdjustedEndDate) + 1);
            }

            // detect if event spans to next week
            /*
            int total = (int)((TimeSpan)(TimescaleEndDate - TimescaleStartDate)).TotalDays;
            if(colSpan>total)
                colSpan = total;
            */
            int total = (int)((TimeSpan)(TimescaleEndDate - TimescaleStartDate)).TotalDays;
            if(colSpan>total - (int)((TimeSpan)(cycleDate - TimescaleStartDate)).TotalDays)
                colSpan = (int)((TimeSpan)(TimescaleEndDate - cycleDate)).TotalDays + 1;

            // [13/1/2005] - Begin
            if(colSpan>0) // [13/1/2005] - End
                writer.AddAttribute(HtmlTextWriterAttribute.Colspan, colSpan.ToString());
            AddTaskCellAttributes(writer, cycleDate);

            RenderPaletteColor(writer, HtmlTextWriterStyle.BackgroundColor, CalendarItemInactiveStyle.BackColor, CalendarColorConstants.ItemDefaultBackColor);
            RenderPaletteColor(writer, HtmlTextWriterStyle.Color, CalendarItemInactiveStyle.ForeColor, CalendarColorConstants.ItemDefaultForeColor);

            writer.AddAttribute(HtmlTextWriterAttribute.Height, "18");
            return colSpan;
        }
Exemplo n.º 5
0
        // June 16 04: added .AddTicks(-1) method call to endDate to allow filter events that end at 0:00
        private int AddMonthItemAttributes(HtmlTextWriter writer, DateTime cycleDate, CalendarItem item)
        {
            int colSpan = 1;

            colSpan = (Helper.GetDaySpan(item.StartDate, item.AdjustedEndDate) + 1);

            // detect if events spans from previous week
            if(item.StartDate.Date<cycleDate.Date)
            {
                // Calculate span from current date
                colSpan = (Helper.GetDaySpan(cycleDate.Date, item.AdjustedEndDate) + 1);
            }

            // detect if event spans to next week
            if(colSpan>(7 - Helper.LocalizedDayOfWeek(cycleDate.DayOfWeek, this.FirstDayOfWeek)))
            {
                colSpan = (7 - Helper.LocalizedDayOfWeek(cycleDate.DayOfWeek, this.FirstDayOfWeek));
            }

            if(item.getRenderStyle() == CalendarItemRenderStyle.Box)
            {
                CalendarItemDefaultStyle.AddAttributesToRender(writer);
                RenderPaletteColor(writer, HtmlTextWriterStyle.BackgroundColor, CalendarItemDefaultStyle.BackColor, CalendarColorConstants.ItemDefaultBackColor);
                RenderPaletteColor(writer, HtmlTextWriterStyle.Color, CalendarItemDefaultStyle.ForeColor, CalendarColorConstants.ItemDefaultForeColor);
            }
            else
                AddMonthCellColorAttributes(writer, cycleDate);
            // [13/1/2005] - Begin
            if(colSpan>0) // [13/1/2005] - End
                writer.AddAttribute("colspan", colSpan.ToString());
            writer.AddAttribute(HtmlTextWriterAttribute.Height, ItemHeight.ToString());
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            return colSpan;
        }
Exemplo n.º 6
0
 private int AddDayItemAttributes(HtmlTextWriter writer, DateTime cycleDate, CalendarItem item)
 {
     int colSpan = Helper.GetHourSpan(cycleDate, item);
     // 1/13/2005  - Begin
     if (colSpan>0)// 1/13/2005 - End
         writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, colSpan.ToString());
     return colSpan;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Determines zero-based index of a CalendarItem within the collection.
 /// </summary>
 /// <param name="item">The CalendarItem to locate within the collection.</param>
 /// <returns>The zero-based index.</returns>
 public int IndexOf(CalendarItem item)
 {
     return List.IndexOf(item);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of a CalendarItemEventArgs object.
 /// </summary>
 /// <param name="item">CalendarItem object</param>
 public CalendarItemEventArgs(CalendarItem item)
     : base(new CommandEventArgs("ItemCreate", ""))
 {
     _Item = item;
 }
Exemplo n.º 9
0
 public IncorrectDatesException(CalendarItem item, Exception  innerException)
     : base(String.Format("End Date '{1}' must be greater than Start Date '{0}'.", item.StartDate, item.EndDate), innerException)
 {
 }
Exemplo n.º 10
0
        /// <summary>
        /// Called when the Add Event menu item is clicked.
        /// </summary>
        /// <param name="sender">The source object</param>
        /// <param name="e">Event arguments</param>
        private void OnAddEvent(object sender, EventArgs e)
        {
            Calendar cal = (Calendar)Component;
            PropertyDescriptor itemsDesc = DesignUtil.GetPropertyDescriptor(cal, "Items");
            if (itemsDesc != null)
            {
                // Tell the designer that we're changing the property
                RaiseComponentChanging(itemsDesc);

                // Do the change
                CalendarItem calItem = new CalendarItem(0, "CalendarItem", DateTime.Now, "http://www.mediachase.com", "some desc");
                cal.Items.Add(calItem);

                // Tell the designer that we've changed the property
                RaiseComponentChanged(itemsDesc, null, null);
                UpdateDesignTimeHtml();
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Adds a CalendarItem to the collection at a specific index.
 /// </summary>
 /// <param name="index">The index at which to add the item.</param>
 /// <param name="item">The CalendarItem to add.</param>
 public void AddAt(int index, CalendarItem item)
 {
     if (!Contains(item))
     {
         List.Insert(index, item);
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Sets properties of the CalendarItem before being added.
 /// </summary>
 /// <param name="item">The CalendarItem to be set.</param>
 private void SetItemProperties(CalendarItem item)
 {
     item.SetParentCalendar(ParentCalendar);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Removes a CalendarItem from the collection.
 /// </summary>
 /// <param name="item">The CalendarItem to remove.</param>
 public void Remove(CalendarItem item)
 {
     List.Remove(item);
 }
Exemplo n.º 14
0
        private CalendarItem CreateItem(int itemIndex, bool dataBind, object dataItem)
        {
            String label = null;
            String link = null;
            String description = null;
            String color = null;
            String owner = null;
            DateTime startDate = DateTime.Now.Date;
            DateTime endDate = DateTime.MinValue;

            if (DataTextField != String.Empty)
                label = DataBinder.GetPropertyValue(dataItem, DataTextField, null);
            if (DataLinkField != String.Empty)
            {
                if (DataLinkFormat != String.Empty) // apply formatting
                    link = String.Format(DataLinkFormat, DataBinder.GetPropertyValue(dataItem, DataLinkField, null));
                else
                    link = DataBinder.GetPropertyValue(dataItem, DataLinkField, null);
            }

            if (DataStartDateField != String.Empty)
                startDate = DateTime.Parse(DataBinder.GetPropertyValue(dataItem, DataStartDateField, null));
            if (DataEndDateField != String.Empty)
                endDate = DateTime.Parse(DataBinder.GetPropertyValue(dataItem, DataEndDateField, null));
            if (DataDescriptionField != String.Empty)
                description = DataBinder.GetPropertyValue(dataItem, DataDescriptionField, null);
            if (DataColorField != String.Empty)
                color = DataBinder.GetPropertyValue(dataItem, DataColorField, null);
            if (DataOwnerField != String.Empty)
                owner = DataBinder.GetPropertyValue(dataItem, DataOwnerField, null);

            CalendarItem item = null;

            //CalendarItem item = new CalendarItem(itemIndex);

            if(endDate==DateTime.MinValue)
                item = new CalendarItem(itemIndex, label, startDate, startDate, link, description);
            else
                item = new CalendarItem(itemIndex, label, startDate, endDate, link, description);

            if(color!=null)
                item.LabelColor = Color.FromName(color);

            if(owner!=null)
                item.Owner = owner;

            CalendarItemEventArgs e = new CalendarItemEventArgs(item);

            if (dataBind)
            {
                item.DataItem = dataItem;
            }
            OnItemCreated(e);

            Items.Add(item);

            item.Initialize();
            item.ValidateItem();

            // REMOVED v1.4:
            Controls.Add(item);

            if (dataBind)
            {
                item.DataBind();
                OnItemDataBound(e);

                //item.DataItem = null;
            }

            return item;
        }
Exemplo n.º 15
0
 /// <summary>
 /// Creates a new object that is a copy of the current instance.
 /// </summary>
 /// <returns>A new object that is a copy of this instance.</returns>
 public override object Clone()
 {
     //CalendarItem copy = (CalendarItem)base.Clone();
     CalendarItem copy = new CalendarItem(this.itemIndex, this.DataItem);
     copy.SetParentCalendar(this.ParentCalendar);
     copy.DataItem = this.DataItem;
     copy.Label = this.Label;
     copy.Description = this.Description;
     copy.Link = this.Link;
     return copy;
 }
Exemplo n.º 16
0
        private void PopulateMatrix(CalendarItem item, DateTime cycleDate, ref IMatrix matrix, ref int rowIndex, int columnIndex, MatrixSpan period)
        {
            // Don't overwright spanning items, write into next row(column?) instead
            while(matrix[rowIndex, columnIndex] == (int)MatrixConstants.SpanField)
                rowIndex++;

            // Check if Maximum number of rows is reached
            /*
            if(this.ViewType!=CalendarViewType.DayView || this.ViewType!=CalendarViewType.TaskView)
            if(this.MaxDisplayedItems < rowIndex)
            {
                // reached maximum number of items we can display in current view
                matrix[rowIndex, columnIndex] = (int)MatrixConstants.MoreElementsField; // -3 = more items available
                break;
            }
            */

            matrix[rowIndex, columnIndex] = Items.IndexOf(item);

            // Repopulate item till the end
            int span = 0;

            // Init variables
            DateTime startSpanDate = item.StartDate;
            DateTime endSpanDate = item.AdjustedEndDate;

            // detect if events spans from previous element
            if(item.StartDate<cycleDate)
            {
                // Calculate span from current date
                startSpanDate = cycleDate;
            }

            switch(period)
            {
                case MatrixSpan.WeekHourSpan:
                case MatrixSpan.HourSpan:
                    //span = (int)System.Math.Ceiling((Helper.GetHourDate(item.EndDate)
                    //	- Helper.GetHourStartDate(item.StartDate)).TotalMinutes/60*2) - 1;
                    span = Helper.GetHourSpan(cycleDate, item) - 1; // -1 cause matrix starts with 0
                    break;
                case MatrixSpan.WeekDaySpan:
                case MatrixSpan.DaySpan:
                    span = Helper.GetDaySpan(startSpanDate, endSpanDate);
                    break;
                case MatrixSpan.MonthSpan:
                    span = endSpanDate.Month - startSpanDate.Month;
                    break;
            }

            for(int index=1;index<=span;index++)
                if(columnIndex+index<matrix.Columns)
                    matrix[rowIndex, columnIndex+index] = (int)MatrixConstants.SpanField;

            rowIndex++;
        }
Exemplo n.º 17
0
        /*
        /// <summary>
        /// Returns date formatted for current hour half,
        /// can be 0 and 30 minutes. Used for comparing with cycle date
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        internal static DateTime GetHourCycleDate(DateTime date)
        {
            int minutes = 0;
            int seconds = 0;
            if(date.Minute>30)
            {
                minutes = 30;
            }
            return new DateTime(date.Year, date.Month, date.Day, date.Hour, minutes, seconds);
        }
        */
        public static int GetHourSpan(DateTime now, CalendarItem item)
        {
            TimeSpan spanTime = Helper.GetHourDate(item.EndDate) - Helper.GetHourStartDate(item.StartDate);
            int colSpan = (int)System.Math.Ceiling(spanTime.TotalMinutes/60*2);

            // detect if events spans from previous week
            if(item.StartDate.Date<now.Date)
            {
                // Calculate span from current date
                TimeSpan spanTime2 = Helper.GetHourDate(item.EndDate) - now;
                colSpan = (int)Math.Ceiling(spanTime2.TotalHours*2);
            }

            // detect if event spans to next week
            if(colSpan>(47 - now.Hour.GetHashCode()*2))
            {
                colSpan = (47 - now.Hour*2)+1;
            }

            return colSpan;
        }
Exemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of a CalendarItemEventArgs object.
 /// </summary>
 /// <param name="item"></param>
 public CalendarItemEventArgs(CalendarItem item, object commandSource, CommandEventArgs originalArgs)
     : base(originalArgs)
 {
     _Item = item;
     _cmdSrc = commandSource;
 }
Exemplo n.º 19
0
 /// <summary>
 /// Determines if a CalendarItem is in the collection.
 /// </summary>
 /// <param name="item">The CalendarItem to search for.</param>
 /// <returns>true if the CalendarItem exists within the collection. false otherwise.</returns>
 public bool Contains(CalendarItem item)
 {
     return List.Contains(item);
 }