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); }
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); } } }
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; } }
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 String FormatPlaceholder(int depth = -1) { return(HtmlReportUtils.FormatPlaceholder(BasePlaceholder, depth)); }
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(); }