コード例 #1
0
ファイル: DayPilotScheduler.cs プロジェクト: kantorn/toacs
        private void RenderEvent(Day d, Event p, HtmlTextWriter output)
        {
            BeforeEventRenderEventArgs ea = new BeforeEventRenderEventArgs(p);
            ea.InnerHTML = p.Name;
            ea.ToolTip = p.Name;
            ea.EventClickEnabled = EventClickHandling != EventClickHandlingEnum.Disabled;
            if (!CssOnly)
            {
                ea.DurationBarColor = ColorTranslator.ToHtml(DurationBarColor);
                ea.BackgroundColor = ColorTranslator.ToHtml(EventBackColor);
            }

            DoBeforeEventRender(ea);

            int max = CellCount*CellWidth;

            int left = (int)Math.Floor((p.BoxStart - d.Start).TotalMinutes * CellWidth / CellDuration);
            int top = p.Column.Number * EventHeight - 1;
            int width = (int)Math.Floor((p.BoxEnd - p.BoxStart).TotalMinutes * CellWidth / CellDuration) - 2;
            int height = EventHeight - 1;

            int startDelta = (int)Math.Floor((p.Start - p.BoxStart).TotalMinutes * CellWidth / CellDuration - 1);
            int realWidth = (int)Math.Floor((p.End - p.Start).TotalMinutes * CellWidth / CellDuration);
            realWidth = realWidth == 0 ? 1 : realWidth;

            // adjustments
            if (left > max) // don't render
            {
                return;
            }
            if (left + width > max - 2)
            {
                width = max - left - 2;
            }
            if (left < 0)
            {
                width += left;
                left = 0;
            }

            width = Math.Max(width, 2);

            if (!CssOnly)
            {
                output.AddAttribute("unselectable", "on");

                output.AddStyleAttribute("position", "absolute");
                output.AddStyleAttribute("left", left + "px");
                output.AddStyleAttribute("top", top + "px");
                output.AddStyleAttribute("width", width + "px");
                output.AddStyleAttribute("height", height + "px");
                output.AddStyleAttribute("overflow", "hidden");
                output.AddStyleAttribute("border", "1px solid " + ColorTranslator.ToHtml(EventBorderColor));
                output.AddStyleAttribute("background-color", ea.BackgroundColor);
                output.AddStyleAttribute("white-space", "nowrap");
                output.AddStyleAttribute("font-family", EventFontFamily);
                output.AddStyleAttribute("font-size", EventFontSize);

                if (ea.EventClickEnabled && EventClickHandling != EventClickHandlingEnum.Disabled)
                {
                    if (EventClickHandling == EventClickHandlingEnum.PostBack)
                    {
                        output.AddAttribute("onclick", "javascript:event.cancelBubble=true;" + Page.ClientScript.GetPostBackEventReference(this, "PK:" + p.PK));
                    }
                    else
                    {
                        output.AddAttribute("onclick", "javascript:event.cancelBubble=true;" + String.Format(EventClickJavaScript, p.PK));
                    }

                    output.AddStyleAttribute("cursor", "pointer");
                }
                else
                {
                    output.AddStyleAttribute("cursor", "default");
                }

                output.RenderBeginTag("div");

                if (DurationBarVisible)
                {
                    output.Write("<div unselectable='on' style='width:" + realWidth + "px; margin-left: " + startDelta + "px; height:2px; background-color:" + ea.DurationBarColor + "; font-size:1px; position:relative;' ></div>");
                    output.Write("<div unselectable='on' style='width:" + width + "px; height:1px; background-color:" + ColorTranslator.ToHtml(EventBorderColor) + "; font-size:1px; position:relative;' ></div>");
                }

                output.AddStyleAttribute("display", "block");
                output.AddStyleAttribute("padding-left", "1px");
                output.AddAttribute("unselectable", "on");
                output.RenderBeginTag("div");
                output.Write(ea.InnerHTML);
                output.RenderEndTag();
                output.RenderEndTag();
            }
            else
            {
                output.AddAttribute("unselectable", "on");

                output.AddStyleAttribute("position", "absolute");
                output.AddStyleAttribute("left", left + "px");
                output.AddStyleAttribute("top", top + "px");
                output.AddStyleAttribute("width", width + "px");
                output.AddStyleAttribute("height", height + "px");
                output.AddStyleAttribute("overflow", "hidden");
                output.AddAttribute("class", PrefixCssClass("_event"));

                if (ea.EventClickEnabled && EventClickHandling != EventClickHandlingEnum.Disabled)
                {
                    if (EventClickHandling == EventClickHandlingEnum.PostBack)
                    {
                        output.AddAttribute("onclick", "javascript:event.cancelBubble=true;" + Page.ClientScript.GetPostBackEventReference(this, "PK:" + p.PK));
                    }
                    else
                    {
                        output.AddAttribute("onclick", "javascript:event.cancelBubble=true;" + String.Format(EventClickJavaScript, p.PK));
                    }

                    output.AddStyleAttribute("cursor", "pointer");
                }
                else
                {
                    output.AddStyleAttribute("cursor", "default");
                }

                output.RenderBeginTag("div");

                output.AddStyleAttribute("display", "block");
                output.AddAttribute("unselectable", "on");
                output.AddAttribute("class", PrefixCssClass("_event_inner"));

                if (!String.IsNullOrEmpty(ea.BackgroundColor))
                {
                    output.AddStyleAttribute("background", ea.BackgroundColor);
                }

                output.RenderBeginTag("div");
                output.Write(ea.InnerHTML);
                output.RenderEndTag();

                if (DurationBarVisible)
                {
                    output.AddStyleAttribute("position", "absolute");
                    output.AddAttribute("unselectable", "on");
                    output.AddAttribute("class", PrefixCssClass("_event_bar"));
                    output.RenderBeginTag("div");

                    double barLeft = 100.0 * startDelta / width;
                    double barWidth = 100.0 * realWidth / width;

                    output.AddAttribute("class", PrefixCssClass("_event_bar_inner"));
                    output.AddStyleAttribute("left", barLeft + "%");
                    output.AddStyleAttribute("width", barWidth + "%");
                    if (!String.IsNullOrEmpty(ea.DurationBarColor))
                    {
                        output.AddStyleAttribute("background", ea.DurationBarColor);
                    }
                    output.RenderBeginTag("div");
                    output.RenderEndTag();

                    output.RenderEndTag();
                    //output.Write("<div unselectable='on' style='width:" + realWidth + "px; margin-left: " + startDelta + "px; height:2px; background-color:" + ea.DurationBarColor + "; font-size:1px; position:relative;' ></div>");
                    //output.Write("<div unselectable='on' style='width:" + width + "px; height:1px; background-color:" + ColorTranslator.ToHtml(EventBorderColor) + "; font-size:1px; position:relative;' ></div>");
                }

                output.RenderEndTag();

            }
        }
コード例 #2
0
ファイル: DayPilotScheduler.cs プロジェクト: kantorn/toacs
 private void DoBeforeEventRender(BeforeEventRenderEventArgs args)
 {
     if (BeforeEventRender != null)
     {
         BeforeEventRender(this, args);
     }
 }