public bool WriteTableContent(TaskList tasks, HtmlTextWriter html) { // Top-level tasks var task = tasks.GetFirstTask(); if (task == null) { return(false); } if (m_Preview) { m_PreviewTaskCount = 0; } var custAttribs = HtmlReportUtils.GetCustomAttributes(tasks); var layout = m_Template.GetLayout(custAttribs); html.RenderBeginTag(HtmlTextWriterTag.Div); html.WriteLine(layout.StartHtml); WriteTask(task, layout, 1, html); // level '0' is used for leaf tasks html.WriteLine(layout.EndHtml); html.RenderEndTag(); // Div if (m_Preview && (m_PreviewTaskCount >= MaxNumPreviewTasks) && (tasks.GetTaskCount() > m_PreviewTaskCount)) { html.RenderBeginTag(HtmlTextWriterTag.P); html.WriteLine(m_Trans.Translate("(more tasks not shown...)")); html.RenderEndTag(); // P } return(true); }
public bool WriteTitleContent(TaskList tasks, Task task, HtmlTextWriter html) { if (!Enabled) { return(false); } #if DEBUG // Sanity check if (!ContainsTaskAttributes(tasks)) { return(false); } #endif if (SeparatePage) { html.AddAttribute("class", "title-page"); } String content = HtmlReportUtils.SubstituteReportDetails(tasks, Text); var custAttribs = HtmlReportUtils.GetCustomAttributes(tasks); content = HtmlReportUtils.ReplaceTaskAttributePlaceholders(content, custAttribs, task, 1, false); content = HtmlReportUtils.ReplaceTaskAttributePlaceholders(content, custAttribs, task, -1, false); html.RenderBeginTag(HtmlTextWriterTag.Div); html.Write(content); html.RenderEndTag(); // Div return(true); }
protected void OnAttributeLevelMenuClick(object sender, EventArgs args) { var menuItem = (sender as ToolStripMenuItem); if (menuItem != null) { var selText = GetTextRange(); string basePlaceholder; int level; if (HtmlReportUtils.ParsePlaceholder(selText, out basePlaceholder, out level, true)) { if (!Int32.TryParse(menuItem.Name, out level)) level = -1; selText.pasteHTML(HtmlReportUtils.FormatAtomicPlaceholderHtml(basePlaceholder, level)); } else if (HtmlReportUtils.ParsePlaceholder(selText, out basePlaceholder, out level)) // plain text { if (!Int32.TryParse(menuItem.Name, out level)) level = -1; selText.text = HtmlReportUtils.FormatPlaceholder(basePlaceholder, level); } } }
private void OnDocumentMouseOver(object sender, HtmlElementEventArgs e) { var element = e.ToElement; // Work our way up looking for one of our placeholders string placeholderText; while (element != null) { if (HtmlReportUtils.ParsePlaceholder(element, out placeholderText, true)) { String tooltip; if (GetPlaceholderTooltip(placeholderText, out tooltip) && !String.IsNullOrWhiteSpace(tooltip) && !tooltip.Equals(element.GetAttribute("title"))) { element.SetAttribute("title", tooltip); } break; // always } // else element = element.Parent; } }
protected override void OnSelectionChange() { base.OnSelectionChange(); if (m_ToolStripAttributeLevelMenu != null) { // Enable 'attribute level' if placeholder is selected var selText = GetTextRange(); string placeholderText; int level; if (HtmlReportUtils.ParsePlaceholder(selText, out placeholderText, out level) && !placeholderText.Equals("indent")) { m_ToolStripAttributeLevelMenu.Enabled = true; CommandHandling.ClearChecked(m_ToolStripAttributeLevelMenu.DropDownItems); ToolStripItem item = m_ToolStripAttributeLevelMenu.DropDownItems[level.ToString()]; if (item != null && item is ToolStripMenuItem) (item as ToolStripMenuItem).Checked = true; } else { m_ToolStripAttributeLevelMenu.Enabled = false; } } }
private String FormatHeader(String taskHtml) { var header = taskHtml; if (!String.IsNullOrWhiteSpace(header)) { foreach (var attrib in Attributes) { // Clear all placeholder except the 'root' one for (int d = 0; d <= 9; d++) { header = header.Replace(attrib.FormatPlaceholder(d), String.Empty); } header = header.Replace(attrib.FormatPlaceholder(), attrib.Label); } // Custom attributes foreach (var attrib in CustomAttributes) { // Clear all placeholder except the 'root' one for (int d = 0; d <= 9; d++) { header = header.Replace(HtmlReportUtils.FormatPlaceholder(attrib.Key, d), String.Empty); } header = header.Replace(HtmlReportUtils.FormatPlaceholder(attrib.Key), attrib.Value); } } return(header); }
private void WriteTask(Task task, Layout layout, int depth, bool andSiblings, HtmlTextWriter html) { if ((task == null) || !task.IsValid()) { return; } if (!String.IsNullOrWhiteSpace(EnabledText)) { var text = layout.FormatRow(task, depth); // Handle indent text = text.Replace("$(indent)", HtmlReportUtils.FormatDepthIndent(m_BaseIndent, depth)); html.WriteLine(text); } if (m_Preview && (++m_PreviewTaskCount >= MaxNumPreviewTasks)) { return; } // First subtask if (layout.Style != Layout.StyleType.Table) { html.WriteLine(layout.StartHtml); } WriteTask(task.GetFirstSubtask(), layout, depth + 1, true, // export siblings html); if (layout.Style != Layout.StyleType.Table) { html.WriteLine(layout.EndHtml); } // Sibling tasks WITHOUT recursion if (andSiblings) { task = task.GetNextTask(); while (task.IsValid()) { WriteTask(task, layout, depth, false, // DO NOT export siblings html); task = task.GetNextTask(); } } }
protected void OnAttributeMenuClick(object sender, EventArgs args) { var menuItem = (sender as ToolStripMenuItem); if (menuItem != null) { var selText = GetTextRange(); if (selText != null) selText.pasteHTML(HtmlReportUtils.FormatAtomicPlaceholderHtml(menuItem.Name)); } }
private bool ContainsNonTopLevelTaskAttributes(TaskList tasks) { for (int depth = 2; depth < 10; depth++) { if (HtmlReportUtils.ContentContainsTaskAttributePlaceholders(Text, tasks, depth)) { return(true); } } return(HtmlReportUtils.ContentContainsTaskAttributePlaceholders(Text, tasks, 0)); // leaf tasks }
//static String CommentsDoneColor = @"#808080"; //static String Endl = @"\n"; // ------------------------------------------------------------- public HtmlReportBuilder(Translator trans, TaskList tasks, Preferences prefs, HtmlReportTemplate template, bool preview) { m_Tasklist = tasks; m_Template = template; m_StrikeThruDone = prefs.GetProfileBool("Preferences", "StrikethroughDone", true); m_BodyFontStyle = HtmlReportUtils.FormatBodyFontStyle(prefs); Header = new HeaderTemplateReporter(template.Header, template.BackColor); Title = new TitleTemplateReporter(trans, template.Title); Footer = new FooterTemplateReporter(template.Footer, template.BackColor); var custAttribs = HtmlReportUtils.GetCustomAttributes(tasks); var baseIndent = HtmlReportUtils.FormatTaskBaseIndent(prefs); Tasks = new TaskTemplateReporter(trans, template.Task, baseIndent, preview); }
public bool WriteBodyDiv(TaskList tasks, HtmlTextWriter html) { if (!Enabled || (Height <= 0)) { return(false); } html.AddAttribute("class", "page-footer"); html.RenderBeginTag(HtmlTextWriterTag.Div); html.Write(HtmlReportUtils.SubstituteReportDetails(tasks, Text)); html.RenderEndTag(); // Div html.WriteLine(); return(true); }
protected void OnAttributeLevelMenuClick(object sender, EventArgs args) { var menuItem = (sender as ToolStripMenuItem); if (menuItem == null) { Debug.Assert(false); return; } var selText = GetTextRange(); if (selText == null) { Debug.Assert(false); return; } int level = -1; if (!Int32.TryParse(menuItem.Name, out level)) level = -1; string basePlaceholder; int unused; if (HtmlReportUtils.ParsePlaceholder(selText, out basePlaceholder, out unused, true)) // atomic { var element = selText.parentElement(); if (!HtmlReportUtils.IsPlaceholder(element)) { Debug.Assert(false); return; } element.innerText = HtmlReportUtils.FormatPlaceholder(basePlaceholder, level); } else if (HtmlReportUtils.ParsePlaceholder(selText, out basePlaceholder, out unused)) // plain text { selText.text = HtmlReportUtils.FormatPlaceholder(basePlaceholder, level); } OnSelectionChange(); }
protected override void OnSelectionChange() { base.OnSelectionChange(); // update menu check-state CommandHandling.ClearChecked(m_ToolStripAttributeMenu.DropDownItems); var selText = GetTextRange(); string basePlaceholder; int level; if (HtmlReportUtils.ParsePlaceholder(selText, out basePlaceholder, out level)) { ToolStripItem item = m_ToolStripAttributeMenu.DropDownItems[HtmlReportUtils.FormatPlaceholder(basePlaceholder)]; if ((item != null) && (item is ToolStripMenuItem)) (item as ToolStripMenuItem).Checked = true; } }
private Layout PreWriteContent(TaskList tasks, Task task, HtmlTextWriter html) { if ((task == null) || !task.IsValid()) { return(null); } if (m_Preview) { m_PreviewTaskCount = 0; } var custAttribs = HtmlReportUtils.GetCustomAttributes(tasks); var layout = m_Template.GetLayout(custAttribs); html.RenderBeginTag(HtmlTextWriterTag.Div); html.WriteLine(layout.StartHtml); return(layout); }
protected override bool GetPlaceholderTooltip(string placeHolder, out string tooltip) { string basePlaceholder; int level; if (!HtmlReportUtils.ParsePlaceholder(placeHolder, out basePlaceholder, out level)) { tooltip = String.Empty; return false; } if (!GetPlaceholderLabel(basePlaceholder, out tooltip)) return false; string levelLabel; if (GetLevelLabel(level, out levelLabel)) tooltip = String.Format("{0}\n{1}", tooltip, levelLabel); return true; }
public bool WriteTitleContent(TaskList tasks, HtmlTextWriter html) { if (!Enabled) { return(false); } if (ContainsNonTopLevelTaskAttributes(tasks)) { // Report an error html.AddStyleAttribute(HtmlTextWriterStyle.Color, "red"); html.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid"); html.RenderBeginTag(HtmlTextWriterTag.P); var message = m_Trans.Translate("Only top-level task attributes are allowed in the Title section."); html.WriteLine("** {0} **", message); html.RenderEndTag(); // P return(true); } #if DEBUG // Sanity check if (ContainsTaskAttributes(tasks)) { return(false); } #endif if (SeparatePage) { html.AddAttribute("class", "title-page"); } html.RenderBeginTag(HtmlTextWriterTag.Div); html.Write(HtmlReportUtils.SubstituteReportDetails(tasks, Text)); html.RenderEndTag(); // Div return(true); }
static String ReplacePlaceholder(String row, String attribVal, String defaultPlaceholderText, int depth, bool isLeafTask) { // Replace only the placeholder at the level specified String placeHolder = HtmlReportUtils.FormatPlaceholder(defaultPlaceholderText, depth); int placeHolderDepth = depth; // Note: Leaf tasks formats take precedence if (isLeafTask) { String leafPlaceHolder = HtmlReportUtils.FormatPlaceholder(defaultPlaceholderText, 0); if (row.IndexOf(leafPlaceHolder) != -1) { placeHolder = leafPlaceHolder; placeHolderDepth = 0; } } if (row.IndexOf(placeHolder) == -1) { // We didn't find it so use the default placeholder placeHolderDepth = -1; placeHolder = HtmlReportUtils.FormatPlaceholder(defaultPlaceholderText); } for (int d = -1; d <= 9; d++) { if (d == placeHolderDepth) { row = row.Replace(placeHolder, attribVal); } else { row = row.Replace(HtmlReportUtils.FormatPlaceholder(defaultPlaceholderText, d), String.Empty); } } return(row); }
public bool ContainsTaskAttributes(TaskList tasks) { // Must only contain '$(title)' or '$(title.1)' return(HtmlReportUtils.ContentContainsTaskAttributePlaceholders(Text, tasks) && !ContainsNonTopLevelTaskAttributes(tasks)); }
public static string FormatAtomicPlaceholderHtml(String basePlaceholder, int level) { return(HtmlReportUtils.FormatAtomicPlaceholderHtml(FormatPlaceholder(basePlaceholder, level))); }
protected void OnAttributeMenuClick(object sender, EventArgs args) { var menuItem = (sender as ToolStripMenuItem); if (menuItem == null) { Debug.Assert(false); return; } var selText = GetTextRange(); if (selText == null) { Debug.Assert(false); return; } string unused; int level; if (HtmlReportUtils.ParsePlaceholder(selText, out unused, out level, true)) // atomic { var element = selText.parentElement(); if (!HtmlReportUtils.IsPlaceholder(element)) { Debug.Assert(false); return; } element.innerText = HtmlReportUtils.FormatPlaceholder(menuItem.Name, level); } else if (HtmlReportUtils.ParsePlaceholder(selText, out unused, out level)) // plain text { selText.text = HtmlReportUtils.FormatPlaceholder(menuItem.Name, level); } else if (String.IsNullOrEmpty(selText.text)) // insertion point { // This is the trickiest bit because if we are // butted up against an atomic placeholder our // text can end up merged with that so we have to // do a bit of detective work and shift the selection // to a safer location // Look to the left var tempSel = selText.duplicate(); tempSel.moveStart("character", -1); bool placeHolderToLeft = ((tempSel.text != null) && tempSel.text.Equals(")")); // Look to the right tempSel = selText.duplicate(); tempSel.moveEnd("character", 1); bool placeHolderToRight = ((tempSel.text != null) && tempSel.text.Equals("$")); if (placeHolderToLeft) { selText.move("character", 1); } else if (placeHolderToRight) { selText.move("character", -1); } // if we have placeholders on both sides then we have to tell // the user to insert a space first and then try again if (placeHolderToLeft && placeHolderToRight) { MessageBox.Show(m_Trans.Translate("Please insert at least one space between the existing placeholders and then try again."), m_Trans.Translate("Report Builder"), MessageBoxButtons.OK, MessageBoxIcon.Information); Focus(); return; } selText.pasteHTML(HtmlReportUtils.FormatAtomicPlaceholderHtml(menuItem.Name, -1)); } else // some other text selected { selText.pasteHTML(HtmlReportUtils.FormatAtomicPlaceholderHtml(menuItem.Name, -1)); } OnSelectionChange(); }
public String FormatPlaceholderText(int depth = -1) { return(HtmlReportUtils.FormatPlaceholderText(BasePlaceholder, depth)); }
static String ReplacePlaceholder(String row, String attribVal, String defaultPlaceholderText, int depth, bool isLeafTask) { return(HtmlReportUtils.ReplaceTaskAttributePlaceholder(row, attribVal, defaultPlaceholderText, depth, isLeafTask)); }