/// <summary> /// Write an element in to the TOC that allows submitting the attempt. /// </summary> /// <param name="sw">The string writer to write the toc entry to.</param> private void WriteSubmitPageEntry(HtmlStringWriter sw) { string activityId = "SUBMIT"; HtmlString activityIdHtml = new PlainTextString(activityId).ToHtmlString(); HtmlString titleHtml = new PlainTextString(m_submitPageLinkText).ToHtmlString(); sw.AddAttribute(HtmlTextWriterAttribute.Class, new PlainTextString("NodeParent")); sw.AddAttribute("activityId", activityIdHtml); sw.AddAttribute("isValidChoice", "true"); sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("div{0}", activityIdHtml)); sw.RenderBeginTag(HtmlTextWriterTag.Div); // #Div1 sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("icon{0}", activityIdHtml)); 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, ""); sw.AddAttribute(HtmlTextWriterAttribute.Id, ResHelper.FormatInvariant("a{0}", activityIdHtml)); sw.AddAttribute(HtmlTextWriterAttribute.Style, "FONT-WEIGHT: normal;visibility:visible"); sw.AddAttribute(HtmlTextWriterAttribute.Title, titleHtml); sw.RenderBeginTag(HtmlTextWriterTag.A); sw.WriteHtml(titleHtml); sw.RenderEndTag(); sw.RenderEndTag(); // div (see #Div1, above) sw.WriteLine(); }
[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(); } }