internal string GetCode() { this.sb = new StringBuilder(); string val = "null"; if (this._calendar.HeightSpec != HeightSpecEnum.Full && this._calendar.HeightSpec != HeightSpecEnum.BusinessHoursNoScroll) { if (this._calendar.ScrollPos == -1) { val = Convert.ToString(this._calendar.CellHeight * (this._calendar.ScrollPositionHour - this._calendar.DayBeginsHour) * 60 / this._calendar.CellDuration); } else { val = this._calendar.ScrollPos.ToString(); } } List <Hashtable> events = this._calendar.GetEvents(); this.sb.AppendLine("<script type='text/javascript'>"); this.sb.AppendLine(string.Format("/* HMSPro: {0} */", Assembly.GetExecutingAssembly().FullName)); this.sb.AppendLine("function " + this._calendar.ClientObjectName + "_Init() {"); this.sb.AppendLine("var v = new HMS.Calendar('" + this._calendar.ClientID + "');"); base.appendProp("allDayEnd", this._calendar.AllDayEnd); base.appendProp("api", 1); base.appendProp("allDayEventBorderColor", this._calendar.AllDayEventBorderColor); base.appendProp("allDayEventFontFamily", this._calendar.AllDayEventFontFamily); base.appendProp("allDayEventFontSize", this._calendar.AllDayEventFontSize); base.appendProp("allDayEventFontColor", this._calendar.AllDayEventFontColor); base.appendProp("allDayEventHeight", this._calendar.AllDayEventHeight); base.appendProp("allowEventOverlap", this._calendar.AllowEventOverlap); base.appendProp("allowMultiSelect", this._calendar.AllowMultiSelect); base.appendProp("autoRefreshCommand", this._calendar.AutoRefreshCommand); base.appendProp("autoRefreshEnabled", this._calendar.AutoRefreshEnabled); base.appendProp("autoRefreshInterval", this._calendar.AutoRefreshInterval); base.appendProp("autoRefreshMaxCount", this._calendar.AutoRefreshMaxCount); base.appendProp("borderColor", this._calendar.BorderColor); base.appendProp("businessBeginsHour", this._calendar.BusinessBeginsHour); base.appendProp("businessEndsHour", this._calendar.BusinessEndsHour); base.appendProp("clientName", this._calendar.ClientObjectName); base.appendProp("cellBackColor", this._calendar.BackColor); base.appendProp("cellBackColorNonBusiness", this._calendar.NonBusinessBackColor); base.appendProp("cellBorderColor", this._calendar.CellBorderColor); base.appendProp("cellHeight", this._calendar.CellHeight); base.appendProp("cellDuration", this._calendar.CellDuration); base.appendProp("columnMarginRight", this._calendar.ColumnMarginRight); base.appendProp("columnWidthSpec", this._calendar.ColumnWidthSpec, true); base.appendProp("columnWidth", this._calendar.ColumnWidth); base.appendProp("crosshairColor", this._calendar.CrosshairColor); base.appendProp("crosshairOpacity", this._calendar.CrosshairOpacity); base.appendProp("crosshairType", this._calendar.Crosshair, true); base.appendProp("theme", this._calendar.Theme); base.appendProp("cssOnly", this._calendar.CssOnly); base.appendProp("deleteImageUrl", this._calendar.GetResourceUrl("Images/Delete10x10.gif"), true); base.appendProp("scrollDownUrl", this._calendar.GetResourceUrl("Images/Down.png"), true); base.appendProp("scrollUpUrl", this._calendar.GetResourceUrl("Images/Up.png"), true); base.appendProp("dayBeginsHour", this._calendar.DayBeginsHour); base.appendProp("dayEndsHour", this._calendar.DayEndsHour); base.appendProp("days", this._calendar.Days); base.appendProp("doubleClickTimeout", this._calendar.DoubleClickTimeout); base.appendProp("durationBarColor", this._calendar.DurationBarColor); base.appendProp("durationBarVisible", this._calendar.DurationBarVisible); base.appendProp("durationBarWidth", this._calendar.DurationBarWidth); base.appendProp("durationBarImageUrl", this._calendar.DurationBarImageUrl); base.appendProp("eventArrangement", this._calendar.EventArrangement); base.appendProp("eventBackColor", this._calendar.EventBackColor); base.appendProp("eventBorderColor", this._calendar.EventBorderColor); base.appendProp("eventFontFamily", this._calendar.EventFontFamily); base.appendProp("eventFontSize", this._calendar.EventFontSize); base.appendProp("eventFontColor", this._calendar.EventFontColor); base.appendProp("eventHeaderFontSize", this._calendar.EventHeaderFontSize); base.appendProp("eventHeaderFontColor", this._calendar.EventHeaderFontColor); base.appendProp("eventHeaderHeight", this._calendar.EventHeaderHeight); base.appendProp("eventHeaderVisible", this._calendar.EventHeaderVisible); base.appendProp("eventSelectColor", this._calendar.EventSelectColor); base.appendProp("headerFontSize", this._calendar.HeaderFontSize); base.appendProp("headerFontFamily", this._calendar.HeaderFontFamily); base.appendProp("headerFontColor", this._calendar.HeaderFontColor); base.appendProp("headerHeight", this._calendar.HeaderHeight); base.appendProp("headerHeightAutoFit", this._calendar.HeaderHeightAutoFit); base.appendProp("headerLevels", this._calendar.HeaderLevels); base.appendProp("height", this._calendar.Height); base.appendProp("heightSpec", this._calendar.HeightSpec); base.appendProp("hideFreeCells", this._calendar.HideFreeCells); base.appendProp("hourHalfBorderColor", this._calendar.HourHalfBorderColor); base.appendProp("hourBorderColor", this._calendar.HourBorderColor); base.appendProp("hourFontColor", this._calendar.HourFontColor); base.appendProp("hourFontFamily", this._calendar.HourFontFamily); base.appendProp("hourFontSize", this._calendar.HourFontSize); base.appendProp("hourNameBackColor", this._calendar.HourNameBackColor); base.appendProp("hourNameBorderColor", this._calendar.HourNameBorderColor); base.appendProp("hourWidth", this._calendar.HourWidth); base.appendProp("initScrollPos", val); base.appendProp("loadingLabelText", this._calendar.LoadingLabelText); base.appendProp("loadingLabelVisible", this._calendar.LoadingLabelVisible); base.appendProp("loadingLabelFontSize", this._calendar.LoadingLabelFontSize); base.appendProp("loadingLabelFontFamily", this._calendar.LoadingLabelFontFamily); base.appendProp("loadingLabelFontColor", this._calendar.LoadingLabelFontColor); base.appendProp("loadingLabelBackColor", this._calendar.LoadingLabelBackColor); if (!string.IsNullOrEmpty(this._calendar.CallBackMessage)) { base.appendProp("messageHTML", this._calendar.CallBackMessage); } base.appendProp("messageHideAfter", this._calendar.MessageHideAfter); base.appendProp("moveBy", this._calendar.MoveBy, true); base.appendProp("notifyCommit", this._calendar.NotifyCommit, true); base.appendProp("numberFormat", Assembly.GetExecutingAssembly().FullName.Contains(".1,") ? "0.00" : null); base.appendProp("roundedCorners", this._calendar.EventCorners == CornerShape.Rounded); base.appendProp("rtl", this._calendar.IsRtl()); base.appendProp("scrollLabelsVisible", this._calendar.ScrollLabelsVisible); base.appendProp("selectedColor", this._calendar.CellSelectColor); base.appendProp("shadow", this._calendar.Shadow.ToString(), true); base.appendProp("showToolTip", this._calendar.ShowToolTip); base.appendProp("showAllDayEvents", this._calendar.ShowAllDayEvents); base.appendProp("showAllDayEventStartEnd", this._calendar.ShowAllDayEventStartEnd); base.appendProp("showCurrentTime", this._calendar.ShowCurrentTime); base.appendProp("showHeader", this._calendar.ShowHeader); base.appendProp("showHours", this._calendar.ShowHours); base.appendSerialized("sortDirections", this._calendar.SortFields.Directions); base.appendProp("startDate", this._calendar.StartDate.ToString("s"), true); base.appendProp("timeFormat", Hour.DetectTimeFormat(this._calendar.TimeFormat).ToString(), true); base.appendProp("timeHeaderCellDuration", this._calendar.TimeHeaderCellDuration); base.appendProp("uniqueID", this._calendar.UniqueID); base.appendProp("useEventBoxes", this._calendar.UseEventBoxes, true); base.appendProp("useEventSelectionBars", this._calendar.UseEventSelectionBars); base.appendProp("viewType", this._calendar.ViewType.ToString()); base.appendProp("visible", this._calendar.Visible); base.appendProp("weekStarts", this._calendar.WeekStartInt); base.appendProp("widthUnit", this.GetWidthUnitType()); if (this._calendar.Width != Unit.Empty) { base.appendProp("width", this._calendar.Width, true); } if (this._calendar.TagFields != null) { base.appendProp("tagFields", SimpleJsonSerializer.Serialize(this._calendar.TagFields), false); } base.appendProp("cornerHTML", this._calendar.CornerHtml); base.appendProp("cornerBackColor", this._calendar.CornerBackColor); if (this._calendar.ContextMenu != null) { base.appendProp("contextMenu", this._calendar.ContextMenu.ClientObjectName, false); } if (this._calendar.ContextMenuSelection != null) { base.appendProp("contextMenuSelection", this._calendar.ContextMenuSelection.ClientObjectName, false); } if (this._calendar.Bubble != null) { base.appendProp("bubble", this._calendar.Bubble.ClientObjectName, false); } if (this._calendar.CellBubble != null) { base.appendProp("cellBubble", this._calendar.CellBubble.ClientObjectName, false); } if (this._calendar.ColumnBubble != null) { base.appendProp("columnBubble", this._calendar.ColumnBubble.ClientObjectName, false); } this._calendar.Page.ClientScript.GetCallbackEventReference(this._calendar, null, null, null, null, true); base.appendProp("eventTapAndHoldHandling", this._calendar.EventTapAndHoldHandling, true); base.appendProp("timeRangeTapAndHoldHandling", this._calendar.TimeRangeTapAndHoldHandling, true); base.appendProp("afterEventRender", "function(e, div) {" + this._calendar.AfterEventRenderJavaScript + "}", false); base.appendProp("afterRender", "function(data, isCallBack) {" + this._calendar.AfterRenderJavaScript + "}", false); base.appendProp("eventClickHandling", this._calendar.EventClickHandling, true); base.appendProp("onEventClick", "function(e) {" + this._calendar.EventClickJavaScript + "}", false); base.appendProp("eventDoubleClickHandling", this._calendar.EventDoubleClickHandling, true); base.appendProp("onEventDoubleClick", "function(e) {" + this._calendar.EventDoubleClickJavaScript + "}", false); base.appendProp("eventHoverHandling", this._calendar.EventHoverHandling, true); base.appendProp("eventSelectHandling", this._calendar.EventSelectHandling, true); base.appendProp("onEventSelect", "function(e, change) {" + this._calendar.EventSelectJavaScript + "}", false); base.appendProp("eventRightClickHandling", this._calendar.EventRightClickHandling, true); base.appendProp("onEventRightClick", "function(e) {" + this._calendar.EventRightClickJavaScript + "}", false); base.appendProp("eventDeleteHandling", this._calendar.EventDeleteHandling, true); base.appendProp("onEventDelete", "function(e) {" + this._calendar.EventDeleteJavaScript + "}", false); base.appendProp("headerClickHandling", this._calendar.HeaderClickHandling, true); base.appendProp("onHeaderClick", "function(c) {" + this._calendar.HeaderClickJavaScript + "}", false); base.appendProp("eventResizeHandling", this._calendar.EventResizeHandling, true); base.appendProp("onEventResize", "function(e, newStart, newEnd) { " + this._calendar.EventResizeJavaScript + "}", false); base.appendProp("eventMoveHandling", this._calendar.EventMoveHandling, true); base.appendProp("onEventMove", "function(e, newStart, newEnd, newResource, external, ctrl, shift) { var newColumn = newResource; var oldColumn = e.resource(); " + this._calendar.EventMoveJavaScript + "}", false); base.appendProp("timeRangeSelectedHandling", this._calendar.TimeRangeSelectedHandling, true); base.appendProp("onTimeRangeSelected", "function(start, end, column) { var resource = column; " + this._calendar.TimeRangeSelectedJavaScript + "}", false); base.appendProp("timeRangeDoubleClickHandling", this._calendar.TimeRangeDoubleClickHandling, true); base.appendProp("onTimeRangeDoubleClick", "function(start, end, column) { var resource = column; " + this._calendar.TimeRangeDoubleClickJavaScript + "}", false); base.appendProp("eventEditHandling", this._calendar.EventEditHandling, true); base.appendProp("onEventEdit", "function(e, newText) {" + this._calendar.EventEditJavaScript + "}", false); if (!string.IsNullOrEmpty(this._calendar.CallBackErrorJavaScript)) { base.appendProp("callbackError", "function(result, context) { " + this._calendar.CallBackErrorJavaScript + " }", false); } CellTable cellTable = new CellTable(this._calendar); cellTable.Process(); base.appendSerialized("cellProperties", cellTable.GetProperties()); base.appendSerialized("cellConfig", cellTable.GetConfig()); List <Hashtable> columns = this._calendar.GetColumns(); List <Hashtable> hours = this._calendar.GetHours(); base.appendProp("events.list", SimpleJsonSerializer.Serialize(events), false); base.appendProp("hours", SimpleJsonSerializer.Serialize(hours), false); base.appendProp("columns", SimpleJsonSerializer.Serialize(columns), false); Hashtable hashtable = new Hashtable(); hashtable["callBack"] = this._calendar.CallBack.GetHash(); hashtable["colors"] = cellTable.GetHash(); hashtable["columns"] = this._calendar.Hash(columns); hashtable["corner"] = this._calendar.CornerHash(this._calendar.CornerHtml, this._calendar.CornerBackColor); hashtable["events"] = this._calendar.Hash(events); hashtable["hours"] = this._calendar.Hash(hours); base.appendSerialized("hashes", hashtable); this.sb.AppendLine("v.init();"); this.sb.AppendLine("return v.internal.initialized() ? v : null;"); this.sb.AppendLine("}"); this.sb.AppendLine(string.Concat(new string[] { "var ", this._calendar.ClientObjectName, " = ", this._calendar.ClientObjectName, "_Init() || ", this._calendar.ClientObjectName, ";" })); this.sb.AppendLine("</script>"); return(this.sb.ToString()); }
internal string GetCode() { this.sb = new StringBuilder(); string scrollPos = "null"; if (_calendar.HeightSpec != HeightSpecEnum.Full) { if (_calendar.ScrollPos == -1) { scrollPos = Convert.ToString(_calendar.CellHeight * (_calendar.ScrollPositionHour) * 2); } else { scrollPos = _calendar.ScrollPos.ToString(); } } List <Hashtable> events = _calendar.GetEvents(); sb.AppendLine("<script type='text/javascript'>"); sb.AppendLine(String.Format("/* DayPilotLite: {0} */", Assembly.GetExecutingAssembly().FullName)); sb.AppendLine("function " + _calendar.ClientObjectName + "_Init() {"); sb.AppendLine("var " + tempVar + " = new DayPilot.Calendar('" + _calendar.ClientID + "');"); appendProp("api", 1); appendProp("businessBeginsHour", _calendar.BusinessBeginsHour); appendProp("businessEndsHour", _calendar.BusinessEndsHour); appendProp("clientName", _calendar.ClientObjectName); appendProp("cellHeight", _calendar.CellHeight); appendProp("columnMarginRight", _calendar.ColumnMarginRight); appendProp("theme", _calendar.Theme); appendProp("days", _calendar.Days); #if (DEBUG) appendProp("debuggingEnabled", true); #endif appendProp("durationBarVisible", _calendar.DurationBarVisible); appendProp("headerDateFormat", _calendar.ResolvedHeaderDateFormat); appendProp("headerHeight", _calendar.HeaderHeight); appendProp("height", _calendar.Height); appendProp("heightSpec", _calendar.HeightSpec); appendProp("hourWidth", _calendar.HourWidth); appendProp("initScrollPos", scrollPos); appendProp("showToolTip", _calendar.ShowToolTip); appendProp("startDate", _calendar.StartDate.ToString("s"), true); appendProp("timeFormat", Hour.DetectTimeFormat(_calendar.TimeFormat).ToString(), true); appendProp("uniqueID", _calendar.UniqueID); appendProp("viewType", _calendar.ViewType.ToString()); appendProp("widthUnit", GetWidthUnitType()); if (_calendar.Width != Unit.Empty) { appendProp("width", _calendar.Width, true); } // ensure WebForm_DoCallBack is available _calendar.Page.ClientScript.GetCallbackEventReference(_calendar, null, null, null, null, true); appendProp("eventClickHandling", _calendar.EventClickHandling, true); appendProp("onEventClick", "function(e) {" + _calendar.EventClickJavaScript + "}", false); appendProp("eventResizeHandling", _calendar.EventResizeHandling, true); appendProp("onEventResize", "function(e, newStart, newEnd) { " + _calendar.EventResizeJavaScript + "}", false); appendProp("eventMoveHandling", _calendar.EventMoveHandling, true); appendProp("onEventMove", "function(e, newStart, newEnd, newResource, external, ctrl, shift) { var newColumn = newResource; var oldColumn = e.resource(); " + _calendar.EventMoveJavaScript + "}", false); appendProp("timeRangeSelectedHandling", _calendar.TimeRangeSelectedHandling, true); appendProp("onTimeRangeSelected", "function(start, end, column) { var resource = column; " + _calendar.TimeRangeSelectedJavaScript + "}", false); // if (!String.IsNullOrEmpty(_calendar.CallBackErrorJavaScript)) // { // appendProp("callbackError", "function(result, context) { " + _calendar.CallBackErrorJavaScript + " }", false); // } appendProp("events.list", SimpleJsonSerializer.Serialize(events), false); Hashtable hashes = new Hashtable(); hashes["callBack"] = _calendar.CallBack.GetHash(); hashes["events"] = _calendar.Hash(events); appendSerialized("hashes", hashes); sb.AppendLine(tempVar + ".init();"); sb.AppendLine("return " + tempVar + ".initialized ? " + tempVar + " : null;"); sb.AppendLine("}"); sb.AppendLine("var " + _calendar.ClientObjectName + " = " + _calendar.ClientObjectName + "_Init() || " + _calendar.ClientObjectName + ";"); sb.AppendLine("</script>"); return(sb.ToString()); }
public static MvcHtmlString DayPilotCalendar(this HtmlHelper helper, string id, DayPilotCalendarConfig cfg) { if (id == null) { throw new ArgumentException("The 'id' argument is required."); } if (cfg == null) { cfg = new DayPilotCalendarConfig(); } string scrollPos = "null"; if (cfg.HeightSpec != HeightSpec.Full) { scrollPos = Convert.ToString(cfg.CellHeight * cfg.ScrollPositionHour * 2 + 1); } var builder = new InitBuilder(); builder.Open("DayPilot.Calendar", id); builder.AppendProp("api", 1); builder.AppendProp("borderColor", cfg.BorderColor); builder.AppendProp("businessBeginsHour", cfg.BusinessBeginsHour); builder.AppendProp("businessEndsHour", cfg.BusinessEndsHour); builder.AppendProp("cellBackColor", cfg.CellBackColor); builder.AppendProp("cellBorderColor", cfg.CellBorderColor); builder.AppendProp("cellHeight", cfg.CellHeight); builder.AppendProp("columnMarginRight", cfg.ColumnMarginRight); builder.AppendProp("cornerBackColor", cfg.CornerBackColor); builder.AppendProp("cssOnly", cfg.CssOnly); builder.AppendProp("durationBarVisible", cfg.DurationBarVisible); builder.AppendProp("theme", cfg.Theme); builder.AppendProp("days", cfg.Days); builder.AppendProp("eventBackColor", cfg.EventBackColor); builder.AppendProp("eventBorderColor", cfg.EventBorderColor); builder.AppendProp("eventFontFamily", cfg.EventFontFamily); builder.AppendProp("eventFontSize", cfg.EventFontSize); builder.AppendProp("eventFontColor", cfg.EventFontColor); builder.AppendProp("eventHeaderFontSize", cfg.EventHeaderFontSize); builder.AppendProp("eventHeaderFontColor", cfg.EventHeaderFontColor); builder.AppendProp("eventHeaderHeight", cfg.EventHeaderHeight); builder.AppendProp("eventHeaderVisible", cfg.EventHeaderVisible); builder.AppendProp("headerFontSize", cfg.HeaderFontSize); builder.AppendProp("headerFontFamily", cfg.HeaderFontFamily); builder.AppendProp("headerFontColor", cfg.HeaderFontColor); builder.AppendProp("headerHeight", cfg.HeaderHeight); builder.AppendProp("heightSpec", cfg.HeightSpec); builder.AppendProp("hourHalfBorderColor", cfg.HourHalfBorderColor); builder.AppendProp("hourBorderColor", cfg.HourBorderColor); builder.AppendProp("hourFontColor", cfg.HourFontColor); builder.AppendProp("hourFontFamily", cfg.HourFontFamily); builder.AppendProp("hourNameBackColor", cfg.HourNameBackColor); builder.AppendProp("hourNameBorderColor", cfg.HourNameBorderColor); builder.AppendProp("hourWidth", cfg.HourWidth); builder.AppendProp("initScrollPos", scrollPos); builder.AppendProp("loadingLabelText", cfg.LoadingLabelText); builder.AppendProp("loadingLabelVisible", cfg.LoadingLabelVisible); builder.AppendProp("loadingLabelFontSize", cfg.LoadingLabelFontSize); builder.AppendProp("loadingLabelFontFamily", cfg.LoadingLabelFontFamily); builder.AppendProp("loadingLabelFontColor", cfg.LoadingLabelFontColor); builder.AppendProp("loadingLabelBackColor", cfg.LoadingLabelBackColor); builder.AppendProp("locale", Thread.CurrentThread.CurrentCulture.Name.ToLower()); builder.AppendProp("showToolTip", cfg.ShowToolTip); builder.AppendProp("startDate", cfg.StartDate.ToString("s")); builder.AppendProp("timeFormat", Hour.DetectTimeFormat(cfg.TimeFormat)); builder.AppendProp("viewType", cfg.ViewType); builder.AppendProp("width", cfg.Width); builder.AppendProp("backendUrl", cfg.BackendUrl); builder.AppendProp("ajaxError", "function(req) { if (DayPilot.Modal) { new DayPilot.Modal().showHtml(req.responseText); } else { alert('AJAX callback error (500)'); } }", false); // event handling types builder.AppendProp("eventClickHandling", cfg.EventClickHandling); builder.AppendProp("eventMoveHandling", cfg.EventMoveHandling); builder.AppendProp("eventResizeHandling", cfg.EventResizeHandling); builder.AppendProp("timeRangeSelectedHandling", cfg.TimeRangeSelectedHandling); // JavaScript event handlers builder.AppendProp("onEventClick", String.Format("function(e) {{ {0}; }}", cfg.EventClickJavaScript), false); builder.AppendProp("onEventMove", String.Format("function(e, newStart, newEnd) {{ var newColumn = newResource; {0}; }}", cfg.EventMoveJavaScript), false); builder.AppendProp("onEventResize", String.Format("function(e, newStart, newEnd) {{ {0}; }}", cfg.EventResizeJavaScript), false); builder.AppendProp("onTimeRangeSelected", String.Format("function(start, end, resource) {{ {0}; }}", cfg.TimeRangeSelectedJavaScript), false); builder.AppendSerialized("columns", cfg.GetColumns()); builder.InjectString(Locale.RegistrationString(Thread.CurrentThread.CurrentCulture.Name.ToLower())); builder.Close(); return(MvcHtmlString.Create(builder.ToString())); }