コード例 #1
0
ファイル: TocHelper.cs プロジェクト: nbl852003/iudico
        /// <summary>
        /// Write TOC Html elements for the table of contents
        /// </summary>
        /// <returns></returns>
        public void TocElementsHtml(HttpRequest Request, string AssignmentGradingViewName)
        {
            // If there was an error on page load, do nothing here.
            if (m_session == null)
            {
                return;
            }

            TableOfContentsElement toc = m_session.GetTableOfContents(true);    // get toc without sequencing information

            using (HtmlStringWriter sw = new HtmlStringWriter(Response.Output))
            {
                sw.Indent = 2;  // start at table level 2, since that's where we are

                WriteTocEntry(sw, toc);

                string SLKView = Request.QueryString["SlkView"];

                // Write the TOC entry to submit the training, only in Execute view or RandomAccess (SLK only) views

                if ((m_session.View == SessionView.Execute) ||
                    ((m_session.View == SessionView.Review) && (SLKView.ToLower() == AssignmentGradingViewName.ToLower())))
                {
                    WriteSubmitPageEntry(sw);
                }
            }
        }
コード例 #2
0
        // this does too much work to be a property
        protected string GetTocStates()
        {
            StringBuilder          sb   = new StringBuilder(1000);
            TableOfContentsElement root = this.Session.GetTableOfContents(true);

            this.GetTocNodeState(sb, root);

            return(sb.ToString());
        }
コード例 #3
0
        /// <summary>
        /// Recursive function to append toc state to the buffer.
        /// </summary>
        private void GetTocNodeState(StringBuilder buffer, TableOfContentsElement element)
        {
            if (element.IsVisible)
            {
                buffer.AppendFormat("{0},{1};", XmlConvert.ToString(element.ActivityId), element.IsValidChoiceNavigationDestination ? "true" : "false");
            }

            foreach (TableOfContentsElement child in element.Children)
            {
                GetTocNodeState(buffer, child);
            }
        }
コード例 #4
0
ファイル: TocHelper.cs プロジェクト: nbl852003/iudico
        /// <summary>
        /// Returns true if this node should be rendered. This indicates nothing about whether or not children of the node should
        /// be rendered.
        /// </summary>
        private static bool RenderThisNode(TableOfContentsElement element)
        {
            // If this element is visible, then return true
            if (element.IsVisible)
            {
                return(true);
            }

            // If this element is a leaf node, the node will be rendered (but not visible)
            if (element.Children.Count == 0)
            {
                return(true);
            }

            // In all other cases, don't render this element
            return(false);
        }
コード例 #5
0
ファイル: TocHelper.cs プロジェクト: nbl852003/iudico
        /// <summary>
        /// Write TOC Html elements for the table of contents
        /// </summary>
        /// <returns></returns>
        ///
        public void TocElementsHtml()
        {
            // If there was an error on page load, do nothing here.
            if (this.mSession == null)
            {
                return;
            }

            TableOfContentsElement toc = this.mSession.GetTableOfContents(true);

            // get toc without sequencing information
            using (HtmlStringWriter sw = new HtmlStringWriter(this.Response.Output))
            {
                sw.Indent = 2; // start at table level 2, since that's where we are

                this.WriteTocEntry(sw, toc);

                // Write the TOC entry to submit the training, only in Execute view or RandomAccess (SLK only) views
                if ((this.mSession.View == SessionView.Execute) || (this.mSession.View == SessionView.RandomAccess))
                {
                    this.WriteSubmitPageEntry(sw);
                }
            }
        }
コード例 #6
0
ファイル: TocHelper.cs プロジェクト: nbl852003/iudico
        [SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]    // parameter is validated
        private void WriteTocEntry(HtmlStringWriter sw, TableOfContentsElement currentElement)
        {
            FramesetUtil.ValidateNonNullParameter("sw", sw);
            FramesetUtil.ValidateNonNullParameter("currentElement", currentElement);

            string     activityId         = FramesetUtil.GetStringInvariant(currentElement.ActivityId);
            bool       elementHasChildren = currentElement.Children.Count > 0;
            HtmlString activityIdHtml     = new PlainTextString(activityId).ToHtmlString();
            HtmlString titleHtml          = new PlainTextString(currentElement.Title).ToHtmlString();

            // If the current element is visible or is an invisible leaf node, then render it. (If it's an
            // invisible leaf node, the node will exist but not be visible.)
            if (RenderThisNode(currentElement))
            {
                sw.AddAttribute(HtmlTextWriterAttribute.Class, new PlainTextString("NodeParent"));
                sw.AddAttribute("activityId", activityIdHtml);
                sw.AddAttribute("isValidChoice", (currentElement.IsValidChoiceNavigationDestination ? "true" : "false"));
                sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("div{0}", activityIdHtml));
                sw.RenderBeginTag(HtmlTextWriterTag.Div);   // #Div1

                if (currentElement.IsVisible)
                {
                    sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("icon{0}", activityIdHtml));
                    if (currentElement.HasVisibleChildren)
                    {
                        sw.AddAttribute(HtmlTextWriterAttribute.Src, "Theme/MinusBtn.gif");
                    }
                    else
                    {
                        sw.AddAttribute(HtmlTextWriterAttribute.Src, "Theme/Leaf.gif");
                    }
                    sw.AddAttribute(HtmlTextWriterAttribute.Align, "absMiddle");
                    sw.RenderBeginTag(HtmlTextWriterTag.Img);
                    sw.RenderEndTag();

                    sw.AddAttribute(HtmlTextWriterAttribute.Src, "Theme/1px.gif");
                    sw.AddAttribute(HtmlTextWriterAttribute.Align, "absMiddle");
                    sw.RenderBeginTag(HtmlTextWriterTag.Img);
                    sw.RenderEndTag();
                    sw.WriteLine();

                    sw.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)");
                    sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("a{0}", activityIdHtml));
                    if (!currentElement.IsValidChoiceNavigationDestination)
                    {
                        sw.AddAttribute(HtmlTextWriterAttribute.Disabled, "true");
                        sw.AddAttribute("class", "disable");
                    }

                    sw.AddAttribute(HtmlTextWriterAttribute.Style,
                                    ResHelper.FormatInvariant("FONT-WEIGHT: normal;visibility:{0}", (currentElement.IsVisible ? "visible" : "hidden")));
                    sw.AddAttribute(HtmlTextWriterAttribute.Title, titleHtml);
                    sw.RenderBeginTag(HtmlTextWriterTag.A);
                    sw.WriteHtml(titleHtml);
                    sw.RenderEndTag();
                }
            }

            // Write sub-elements (regardless of whether or not this node is rendered)
            if (elementHasChildren)
            {
                sw.WriteLine();
                bool clusterStarted = false;
                if (currentElement.IsVisible)
                {
                    sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("divCluster{0}", activityIdHtml));
                    sw.AddAttribute(HtmlTextWriterAttribute.Style, "MARGIN-TOP: 5px; DISPLAY: block; MARGIN-LEFT: 18px;");
                    sw.RenderBeginTag(HtmlTextWriterTag.Div);
                    clusterStarted = true;
                }

                foreach (TableOfContentsElement childElement in currentElement.Children)
                {
                    WriteTocEntry(sw, childElement);
                }

                if (clusterStarted)
                {
                    sw.RenderEndTag(); // end div
                    sw.WriteLine();
                }
            }

            if (RenderThisNode(currentElement))
            {
                sw.RenderEndTag();  // div (see #Div1, above)
                sw.WriteLine();
            }
        }
コード例 #7
0
ファイル: TocHelper.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Returns true if this node should be rendered. This indicates nothing about whether or not children of the node should 
        /// be rendered.
        /// </summary>
        private static bool RenderThisNode(TableOfContentsElement element)
        {
            // If this element is visible, then return true
            if (element.IsVisible)
                return true;

            // If this element is a leaf node, the node will be rendered (but not visible)
            if (element.Children.Count == 0)
                return true;

            // In all other cases, don't render this element
            return false;
        }
コード例 #8
0
ファイル: TocHelper.cs プロジェクト: supermuk/iudico
        [SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]    // parameter is validated
        private void WriteTocEntry(HtmlStringWriter sw, TableOfContentsElement currentElement)
        {
            FramesetUtil.ValidateNonNullParameter("sw", sw);
            FramesetUtil.ValidateNonNullParameter("currentElement", currentElement);

            string activityId = FramesetUtil.GetStringInvariant(currentElement.ActivityId);
            bool elementHasChildren = currentElement.Children.Count > 0;
            HtmlString activityIdHtml = new PlainTextString(activityId).ToHtmlString();
            HtmlString titleHtml = new PlainTextString(currentElement.Title).ToHtmlString();

            // If the current element is visible or is an invisible leaf node, then render it. (If it's an 
            // invisible leaf node, the node will exist but not be visible.)
            if (RenderThisNode(currentElement))
            {
                sw.AddAttribute(HtmlTextWriterAttribute.Class, new PlainTextString("NodeParent"));
                sw.AddAttribute("activityId", activityIdHtml);
                sw.AddAttribute("isValidChoice", (currentElement.IsValidChoiceNavigationDestination ? "true" : "false"));
                sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("div{0}", activityIdHtml));
                sw.RenderBeginTag(HtmlTextWriterTag.Div);   // #Div1

                if (currentElement.IsVisible)
                {
                    sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("icon{0}", activityIdHtml));
                    if (currentElement.HasVisibleChildren)
                        sw.AddAttribute(HtmlTextWriterAttribute.Src, "Theme/MinusBtn.gif");
                    else
                        sw.AddAttribute(HtmlTextWriterAttribute.Src, "Theme/Leaf.gif");
                    sw.AddAttribute(HtmlTextWriterAttribute.Align, "absMiddle");
                    sw.RenderBeginTag(HtmlTextWriterTag.Img);
                    sw.RenderEndTag();

                    sw.AddAttribute(HtmlTextWriterAttribute.Src, "Theme/1px.gif");
                    sw.AddAttribute(HtmlTextWriterAttribute.Align, "absMiddle");
                    sw.RenderBeginTag(HtmlTextWriterTag.Img);
                    sw.RenderEndTag();
                    sw.WriteLine();

                    sw.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)");
                    sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("a{0}", activityIdHtml));
                    if (!currentElement.IsValidChoiceNavigationDestination)
                    {
                        sw.AddAttribute(HtmlTextWriterAttribute.Disabled, "true");
                        sw.AddAttribute("class", "disable");
                    }

                    sw.AddAttribute(HtmlTextWriterAttribute.Style,
                                        ResHelper.FormatInvariant("FONT-WEIGHT: normal;visibility:{0}", (currentElement.IsVisible ? "visible" : "hidden")));
                    sw.AddAttribute(HtmlTextWriterAttribute.Title, titleHtml);
                    sw.RenderBeginTag(HtmlTextWriterTag.A);
                    sw.WriteHtml(titleHtml);
                    sw.RenderEndTag();
                }
            }

            // Write sub-elements (regardless of whether or not this node is rendered)
            if (elementHasChildren)
            {
                sw.WriteLine();
                bool clusterStarted = false;
                if (currentElement.IsVisible)
                {
                    sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("divCluster{0}", activityIdHtml));
                    sw.AddAttribute(HtmlTextWriterAttribute.Style, "MARGIN-TOP: 5px; DISPLAY: block; MARGIN-LEFT: 18px;");
                    sw.RenderBeginTag(HtmlTextWriterTag.Div);
                    clusterStarted = true;
                }

                foreach (TableOfContentsElement childElement in currentElement.Children)
                {
                    WriteTocEntry(sw, childElement);
                }

                if (clusterStarted)
                {
                    sw.RenderEndTag(); // end div
                    sw.WriteLine();
                }
            }

            if (RenderThisNode(currentElement))
            {
                sw.RenderEndTag();  // div (see #Div1, above)
                sw.WriteLine();
            }
        }