示例#1
0
        internal void Add(Event e)
        {
            if (e.Column != null)
                throw new ApplicationException("This Event was already placed into a Column.");

            events.Add(e);
            e.Column = this;
        }
示例#2
0
 internal bool CanAdd(Event e)
 {
     foreach (Event ev in events)
     {
         if (ev.OverlapsWith(e))
             return false;
     }
     return true;
 }
示例#3
0
        internal bool OverlapsWith(Event e)
        {
            if (events.Count == 0)
                return false;

            return (this.BoxStart < e.BoxEnd && this.BoxEnd > e.BoxStart);
        }
示例#4
0
 internal void Add(Event ev)
 {
     events.Add(ev);
     arrangeColumns();
 }
示例#5
0
        private void stripAndAddEvent(Event e)
        {
            // the event happens before this day
            if (e.Start < date && e.End <= date)
                return;

            // the event happens after this day
            if (e.Start >= date.AddDays(1) && e.End >= date.AddDays(1))
                return;

            // this is invalid event that does have no duration
            if (e.Start >= e.End)
                return;

            // fix the starting time
            if (e.Start < date)
                e.Start = date;

            // fix the ending time
            if (e.End > date.AddDays(1))
                e.End = date.AddDays(1);

            Events.Add(e);
        }
示例#6
0
 /// <summary>
 /// Returns true if this box overlaps with e's box.
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 public bool OverlapsWith(Event e)
 {
     return (this.BoxStart < e.BoxEnd && this.BoxEnd > e.Start);
 }
示例#7
0
        private void renderEvent(HtmlTextWriter output, Event e, Day d)
        {
            string displayTime = e.booking.Startdatetime.ToShortTimeString() + " - " + e.booking.Enddatetime.ToShortTimeString();
            string displayTitle = " " + e.booking.Title;
            string displayPersonnumber = " " + e.booking.Personnumber;
            string displayType = " (" + e.booking.Bookingtype + ")";
            string displayNote = " " + e.booking.Note ;

            string displayMobilephone = " ";
            if (!String.IsNullOrEmpty(e.booking.Mobilephone))
                displayMobilephone += "tel: " + e.booking.Mobilephone;
            else if (!String.IsNullOrEmpty(e.booking.Homephone))
                displayMobilephone += "tel: " + e.booking.Homephone;
            else if (!String.IsNullOrEmpty(e.booking.Workphone))
                displayMobilephone += "tel: " + e.booking.Workphone;
            else
                displayMobilephone += "tel: -";

            string displayFreecarddate = " F: " + e.booking.Freecarddate;

            Color eventLeftBarColor = EventLeftBarColor;
            Color eventBackColor = EventBackColor;
            Color eventFreecardExpiredColor = Color.Black;
            Color eventCancellednoteColor = Color.Red;

            try
            {
                DateTime freecarddate = DateTime.Parse(e.booking.Freecarddate);
                if ((freecarddate == DateTime.MinValue) || (freecarddate == DateTime.MaxValue))
                    throw new Exception("Frikortsdatumet existerar inte eller är inte giltigt");
                if ((freecarddate < e.booking.Startdatetime) && (!e.booking.Cancelled))
                {
                    eventLeftBarColor = EventFreecardExpiredBackColor;
                    eventFreecardExpiredColor = EventFreecardExpiredBackColor;
                }
            }
            catch (Exception exception)
            {
            }

            if (e.booking.Arrived)
                eventLeftBarColor = EventArrivedBackColor;
            if (e.booking.Notshown)
                eventLeftBarColor = EventNotShownBackColor;
            if (e.booking.Cancelled)
            {
                eventBackColor = Color.LightGray;
                eventLeftBarColor = Color.Black;
                displayNote = " Återbud:" + e.booking.Cancellednote;
            }

            // real box dimensions and position
            DateTime dayVisibleStart = new DateTime(d.date.Year, d.date.Month, d.date.Day, visibleStart.Hour, 0, 0);
            DateTime realBoxStart = e.BoxStart < dayVisibleStart ? dayVisibleStart : e.BoxStart;

            DateTime dayVisibleEnd;
            if (visibleEnd.Day == 1)
                dayVisibleEnd = new DateTime(d.date.Year, d.date.Month, d.date.Day, visibleEnd.Hour, 0, 0);
            else if (visibleEnd.Day == 2)
                dayVisibleEnd = new DateTime(d.date.Year, d.date.Month, d.date.Day, visibleEnd.Hour, 0, 0).AddDays(1);
            else
                throw new ArgumentOutOfRangeException("Unexpected time for dayVisibleEnd.");

            DateTime realBoxEnd = e.BoxEnd > dayVisibleEnd ? dayVisibleEnd : e.BoxEnd;

            // top
            double top = (realBoxStart - dayVisibleStart).TotalHours * HourHeight + 1;
            if (ShowHeader)
                top += this.HeaderHeight;

            // height
            double height = ((realBoxEnd - realBoxStart).TotalHours * HourHeight - 2);

            // It's outside of visible area (for NonBusinessHours set to Hide).
            // Don't draw it in that case.
            if (height <= 0)
            {
                return;
            }

            // MAIN BOX
            output.AddAttribute("onselectstart", "return false;"); // prevent text selection in IE

            if (EventClickHandling == UserActionHandling.PostBack)
            {
                output.AddAttribute("onclick", "javascript:event.cancelBubble=true;" + Page.ClientScript.GetPostBackEventReference(this, "PK:" + e.PK));
            }
            else
            {
                output.AddAttribute("onclick", "javascript:event.cancelBubble=true;" + String.Format(JavaScriptEventAction, e.PK));
            }

            //To get some more space to the right
            int newColumnWidth = e.Column.WidthPct - 1;

            output.AddStyleAttribute("-moz-user-select", "none"); // prevent text selection in FF
            output.AddStyleAttribute("-khtml-user-select", "none"); // prevent text selection
            output.AddStyleAttribute("user-select", "none"); // prevent text selection
            output.AddStyleAttribute("cursor", "pointer");
            //output.AddStyleAttribute("cursor", "hand");
            output.AddStyleAttribute("position", "absolute");
            output.AddStyleAttribute("font-family", EventFontFamily);
            output.AddStyleAttribute("font-size", EventFontSize);
            output.AddStyleAttribute("white-space", "no-wrap");
            output.AddStyleAttribute("left", e.Column.StartsAtPct + "%");
            output.AddStyleAttribute("top", top + "px");
            output.AddStyleAttribute("width", newColumnWidth + "%");
            output.AddStyleAttribute("height", (realBoxEnd - realBoxStart).TotalHours * HourHeight + "px");
            output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(EventBorderColor));

            output.RenderBeginTag("div");
            //output.Write(divMain.BeginTag());

            // FIX BOX - to fix the outer/inner box differences in Mozilla/IE (to create border)
            //            DivWriter divFix = new DivWriter();
            output.AddAttribute("onmouseover", "this.style.backgroundColor='" + ColorTranslator.ToHtml(EventHoverColor) + "';event.cancelBubble=true;");
            output.AddAttribute("onmouseout", "this.style.backgroundColor='" + ColorTranslator.ToHtml(eventBackColor) + "';event.cancelBubble=true;");

            if (ShowToolTip)
            {
                output.AddAttribute("title", displayTime + displayTitle + displayType +displayNote + "( " + displayMobilephone + displayFreecarddate + " )");
            }

            output.AddStyleAttribute("margin-top", "1px");
            output.AddStyleAttribute("display", "block");
            output.AddStyleAttribute("height", height + "px");
            output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(eventBackColor));
            output.AddStyleAttribute("border-left", "1px solid " + ColorTranslator.ToHtml(EventBorderColor));
            output.AddStyleAttribute("border-right", "1px solid " + ColorTranslator.ToHtml(EventBorderColor));
            output.AddStyleAttribute("overflow", "hidden");
            output.RenderBeginTag("div");
            //            output.Write(divFix.BeginTag());

            // blue column
            if (e.Start > realBoxStart)
            {

            }

            int startDelta = (int) Math.Floor((e.Start - realBoxStart).TotalHours * HourHeight);
            int endDelta = (int) Math.Floor((realBoxEnd - e.End).TotalHours * HourHeight);

            //            DivWriter divBlue = new DivWriter();
            output.AddStyleAttribute("float", "left");
            output.AddStyleAttribute("width", "7px");
            output.AddStyleAttribute("height", height - startDelta - endDelta + "px");
            output.AddStyleAttribute("margin-top", startDelta + "px");
            output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(eventLeftBarColor));
            output.AddStyleAttribute("font-size", "1px");
            output.RenderBeginTag("div");
            output.RenderEndTag();
            //            output.Write(divBlue.BeginTag());
            //            output.Write(divBlue.EndTag());

            // right border of blue column
            //            DivWriter divBorder = new DivWriter();
            output.AddStyleAttribute("float", "left");
            output.AddStyleAttribute("width", "1px");
            output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(EventBorderColor));
            output.AddStyleAttribute("height", "100%");
            output.RenderBeginTag("div");
            output.RenderEndTag();
            //            output.Write(divBorder.BeginTag());
            //            output.Write(divBorder.EndTag());

            // space
            //            DivWriter divSpace = new DivWriter();
            output.AddStyleAttribute("float", "left");
            output.AddStyleAttribute("width", "2px");
            output.AddStyleAttribute("height", "100%");
            output.RenderBeginTag("div");
            output.RenderEndTag();
            //            output.Write(divSpace.BeginTag());
            //            output.Write(divSpace.EndTag());

            // PADDING BOX
            //            DivWriter divPadding = new DivWriter();
            output.AddStyleAttribute("padding", "1px");
            output.RenderBeginTag("div");
            //            output.Write(divPadding.BeginTag());

            if (Days < 5)
            {
                //output.Write("<div id='sensitivePartOne'>");
                output.Write("<span id='sensitiveTitle' style='font-weight:bold; '>" + displayTitle + "</span>");
                output.Write("<span id='sensitivePersonnumber'>" + displayPersonnumber + "</span>");
                //output.Write("</div>");

                output.Write(displayType);

                //output.Write("<div id='sensitivePartTwo'>");
                if (e.booking.Cancelled)
                    output.Write("<span id='sensitiveNote' style='color:" + ColorTranslator.ToHtml(eventCancellednoteColor) + ";font-weight:bold; '>" + displayNote + "</span>");
                else
                    output.Write("<span id='sensitiveNote' style='font-weight:bold; '>" + displayNote + "</span>");

                output.Write("<span id='sensitiveMobilephone' style='font-size:12px;font-family:" + EventFontFamily + "; '>" + " (" + displayMobilephone + "</span>");

                output.Write("<span id='sensitiveFreecarddate' style='color:" + ColorTranslator.ToHtml(eventFreecardExpiredColor) + ";font-size:12px;font-family:" + EventFontFamily + "; '>" + displayFreecarddate + "</span>");

                output.Write("<span id='sensitiveEnd' style='font-size:12px;font-family:" + EventFontFamily + "; '>" + ")" + "</span>");
                //output.Write("</div>");
            }
            else
            {
                output.Write("<span id='sensitiveTitle' style='font-size:10px;font-family:" + EventFontFamily + "; '>" + displayTitle + "</span>");

                output.Write("<span style='font-size:10px;font-family:" + EventFontFamily + "; '>" + displayType + "</span>");
            }

            // closing the PADDING BOX
            output.RenderEndTag();
            //            output.Write(divPadding.EndTag());

            // closing the FIX BOX
            output.RenderEndTag();
            //            output.Write(divFix.EndTag());

            // closing the MAIN BOX
            //            output.Write(divMain.EndTag());
            output.RenderEndTag();
        }