/// <summary> /// Creates various string properties that are merged into the output template. /// Creates the tabs and the associated script code. /// </summary> private void RenderTabs() { if (_Tabs != null) { // ActivateTab script code StringBuilder Script = new StringBuilder(); // ShowTabPage script code StringBuilder Script2 = new StringBuilder(); // HtmlTextWriter to handle output generation for the HTML StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); HtmlTextWriter tabWriter = new HtmlTextWriter(sw); tabWriter.WriteLine("<table border='0' cellspacing='0'><tr>"); int count = -1; foreach (TabPage tab in _Tabs) { bool isPageSelected = false; isPageSelected = _Tabs.Count % 1 == 0; if (!string.IsNullOrEmpty(tab.TabPageClientId) && tab.TabPageClientId == _SelectedTab) { isPageSelected = true; } count++; string id = ClientID + "_" + count.ToString(); tabWriter.WriteBeginTag("td"); if (!string.IsNullOrEmpty(tab.Style) && !tab.Style.EndsWith(";")) { StringUtils.TerminateString(tab.Style, ";"); } if (!TabHeight.IsEmpty) { tab.Style += "height:" + TabHeight.ToString() + ";"; } if (!TabWidth.IsEmpty) { tab.Style += "width:" + TabWidth.ToString() + ";"; } tabWriter.WriteAttribute("id", id); string ActionLink = FixupActionLink(tab); if (ActionLink != "" && tab.Enabled) { tabWriter.WriteAttribute("onclick", ActionLink); } if (_Tabs == null) { return; } if (tab.TabPageClientId != "" && tab.TabPageClientId == _SelectedTab) { tabWriter.WriteAttribute("class", SelectedTabCssClass); } else { tabWriter.WriteAttribute("class", TabCssClass); } if (tab.Style != "") { tabWriter.WriteAttribute("style", tab.Style); } tabWriter.Write(HtmlTextWriter.TagRightChar); if (tab.TabImage != "") { tabWriter.Write("<img src='" + ResolveUrl(tab.TabImage) + "' style='margin: 0px 5px 0px 7px;' align='left' />\r\n"); } tabWriter.Write(tab.Caption); tabWriter.WriteEndTag("td"); tabWriter.Write("\r\n"); } tabWriter.Write("</tr>"); if (TabstripSeparatorHeight != Unit.Empty && TabstripSeparatorHeight.Value > 0.00) { tabWriter.Write( @"<tr> <td class='" + TabStripSeparatorCssClass + @"' colspan='" + TabPages.Count.ToString() + "' style='padding: 0px;height: " + TabstripSeparatorHeight.ToString() + @";'></td> </tr>"); } tabWriter.Write("</table>\r\n"); TabOutput = sb.ToString(); tabWriter.Close(); } }
public ConversionOptions GetConfiguration() { var options = new ConversionOptions(); if (Path.HasValue()) { options.Paths = Path.Values; } if (File.HasValue()) { options.Files = File.Values; } if (List.HasValue()) { options.ListFile = List.Value(); } if (options.Paths.Count == 0 && options.Files.Count == 0 && String.IsNullOrEmpty(options.ListFile)) { throw new ConfigurationException("Nothing to process, must specify one of --path, --file or --list"); } if (IndentStyle.HasValue()) { var style = IndentStyle.Value().ToLower(); if (style == "tabs") { options.Indentation = IndentationStyle.Tabs; } else if (style == "spaces") { options.Indentation = IndentationStyle.Spaces; } else if (style == "leave") { options.Indentation = IndentationStyle.Leave; } else { throw new ConfigurationException($"'{style}' is an invalid indentation style"); } } if (LineEndings.HasValue()) { var lineEndingStyle = LineEndings.Value().ToLower(); if (lineEndingStyle == "crlf") { options.LineEndingStyle = LineEnding.CRLF; } else if (lineEndingStyle == "lf") { options.LineEndingStyle = LineEnding.LF; } else { throw new ConfigurationException("Line Endings must be crlf or lf"); } } options.StripTrailingSpaces = StripTrailingSpaces.HasValue(); // no point going any further if one of the change options isn't actually specified if (options.StripTrailingSpaces == false && options.Indentation == IndentationStyle.Leave && options.LineEndingStyle == LineEnding.Leave) { throw new ConfigurationException("Nothing to do, you must specify one of --strip-trailing-spaces, --line-endings or --indent"); } if (TabWidth.HasValue()) { if (!Int32.TryParse(TabWidth.Value(), out int tabWidth)) { throw new ConfigurationException("tabwidth must be a valid number"); } options.TabWidth = tabWidth; } if (IncludeExtensions.HasValue()) { options.IncludeExtensions = ParseFileExtensionsOption(IncludeExtensions.Values); } if (ExcludeExtensions.HasValue()) { options.ExcludeExtensions = ParseFileExtensionsOption(ExcludeExtensions.Values); } if (ExcludeFolders.HasValue()) { options.ExcludeFolders = ExcludeFolders.Values; } // the presence of recurse|dryrun means it's on, there is no value options.Recurse = Recurse.HasValue(); options.DryRun = DryRun.HasValue(); options.Verbose = Verbose.HasValue(); return(options); }