public static RTFBuilder Strike(RTFBuilder text) { return(new RTFBuilder() { InternalStr = "{\\strike " + text.ToString() + "\\strike0}" }); }
public void Debugging() { offsetsText.Text = null; byte[] bytes; string str = startHex.Text.Substring(startHex.Text.Length - 1, 1); if (!"0".Equals(str)) { startHex.Text = startHex.Text.Remove(startHex.Text.Length - 1, 1) + "0"; } uint offset = Convert.ToUInt32(startHex.Text, 0x10); RTFBuilderbase builderbase = new RTFBuilder(); builderbase.Font(RTFFont.CourierNew); builderbase.FontSize(22f); bytes = PS3.Extension.ReadBytes(offset, 800); for (int i = 0; i < bytes.Length; i++) { builderbase.Font(RTFFont.CourierNew); builderbase.FontSize(22f); if (oldBytes != null) { if (bytes.Length == oldBytes.Length) { if (bytes[i] == oldBytes[i]) { builderbase.Append(bytes[i].ToString("X2") + " "); } else { builderbase.ForeColor(KnownColor.LimeGreen).Append(bytes[i].ToString("X2") + " "); } } else { builderbase.Append(bytes[i].ToString("X2") + " "); } } else { builderbase.Append(bytes[i].ToString("X2") + " "); } } oldBytes = bytes; string str2 = builderbase.ToString(); hexCode.Rtf = str2; string str3 = SpliceText(Encoding.Default.GetString(bytes).Replace("\0", ".").Replace("\a", ".").Replace("\v", ".").Replace("\r", ".").Replace(" ", ".").Replace("\t", ".").Replace("\n", ".").Replace("\b", ".").Replace("\f", "."), 0x10); asciiText.Text = str3; uint num3 = offset; int num4 = (hexCode.Text.Length / 0x30) + 1; for (int j = 0; j < num4; j++) { offsetsText.Text = offsetsText.Text + "0x" + Convert.ToString((long)num3, 0x10).ToUpper() + Environment.NewLine; num3 += 0x10; } }
public static RTFBuilder Italic(RTFBuilder text) { return(new RTFBuilder() { InternalStr = "{\\i " + text.ToString() + "\\i0}" }); }
private void T_Tick(object sender, EventArgs e) { if (!edited) { return; } edited = false; RTFBuilder res = new RTFBuilder(); for (int i = 0; i < RTFBs.Count; i++) { res.Append(RTFBs[i]); res.AppendLine(); } bool canSelect = richTextBox1.SelectionLength <= 0; SuspendLayout(); richTextBox1.Rtf = res.FinalOutput(16); if (CanSelect) { richTextBox1.Select(richTextBox1.Rtf.Length - 1, 1); richTextBox1.ScrollToCaret(); } ResumeLayout(); }
public static RTFBuilder Bold(RTFBuilder text) { return(new RTFBuilder() { InternalStr = "{\\b " + text.ToString() + "\\b0}" }); }
public RTFBuilder Replace(string text, RTFBuilder res) { return(new RTFBuilder() { Internal = new StringBuilder(Internal.ToString().Replace(text, res.ToString())) }); }
public static void GetFormattedHeader(this Record rec, RTFBuilder rb) { rb.FontStyle(FontStyle.Bold).FontSize(rb.DefaultFontSize + 4).ForeColor(KnownColor.DarkGray).AppendLine("[Record]"); rb.Append("Type: ").FontStyle(FontStyle.Bold).FontSize(rb.DefaultFontSize + 2).AppendFormat("{0}", rec.Name).AppendLine(); rb.Append("FormID: ").FontStyle(FontStyle.Bold).FontSize(rb.DefaultFontSize + 2).ForeColor(KnownColor.DarkRed).AppendFormat("{0:X8}", rec.FormID).AppendLine(); if (rec.Flags1 != 0) { rb.AppendLineFormat("Flags 1: {0:X8} : ({1} : Level = {2})", rec.Flags1, FlagDefs.GetRecFlags1Desc(rec.Flags1), rec.CompressionLevel.ToString()); } else { rb.AppendLineFormat("Flags 1: {0:X8}", rec.Flags1); } //rb.AppendLineFormat("OLD --> Flags 3: \t{0:X8}", rec.Flags3); rb.AppendLineFormat("Version Control Info: {0:X8}", rec.Flags2); //rb.AppendLineFormat("OLD --> Flags 3: \t{0:X8}", rec.Flags3); rb.AppendLineFormat("Flags 2: {0:X4}", (rec.Flags3 >> 16)); rb.AppendLineFormat("Form Version: {0:X4} : {1}", ((rec.Flags3 << 16) >> 16), ((rec.Flags3 << 16) >> 16)); rb.AppendLineFormat("Size: {0:N0}", rec.Size); rb.AppendLineFormat("Subrecords: {0}", rec.SubRecords.Count); rb.AppendPara(); }
public void Colorize(int start, int end, string text, List <ColorChangeInfo> color_changes, ref ColorTable color_table) { Debug.Assert(text.Length == end - start); if (!m_Colorized) { return; } if (color_changes.Count < 2) { return; } PausePainting(); SaveSelectionAndScrollPos(); try { int length = end - start; RTFBuilder rtf_builder = new RTFBuilder(Font, text, 0, color_changes, ref color_table); Select(start, length); SelectedRtf = rtf_builder.RTF; } finally { RestoreSelectionAndScrollPos(); ResumePainting(); } }
// The color info of last item of color_changes isn't used, the last item is there only to provide the end iterator of the affected text. public void Colorize(List <ColorChangeInfo> color_changes, ref ColorTable color_table) { if (!m_Colorized) { return; } if (color_changes.Count < 2) { return; } PausePainting(); SaveSelectionAndScrollPos(); try { int start = color_changes[0].text_index; int end = color_changes[color_changes.Count - 1].text_index; int length = end - start; string text = GetTextRange(start, end); RTFBuilder rtf_builder = new RTFBuilder(Font, text, -start, color_changes, ref color_table); Select(start, length); SelectedRtf = rtf_builder.RTF; } finally { RestoreSelectionAndScrollPos(); ResumePainting(); } }
public override void GetFormattedData(RTFBuilder rb) { try { rb.FontStyle(FontStyle.Bold).FontSize(rb.DefaultFontSize).ForeColor(KnownColor.DarkGray).AppendLine( "[Formatted information]"); rb.Reset(); RecordStructure rec; if (!RecordStructure.Records.TryGetValue(Name, out rec)) { return; } rb.FontStyle(FontStyle.Bold).ForeColor(KnownColor.DarkBlue).FontSize(rb.DefaultFontSize + 4).AppendLine( rec.description); foreach (var subrec in SubRecords) { if (subrec.Structure == null || subrec.Structure.elements == null || subrec.Structure.notininfo) { continue; } rb.AppendLine(); subrec.GetFormattedData(rb); } } catch { rb.ForeColor(KnownColor.Red).Append( "Warning: An error occurred while processing the record. It may not conform to the structure defined in RecordStructure.xml"); } }
public static RTFBuilder Colored(RTFBuilder text, int color) { return(new RTFBuilder() { InternalStr = "{\\cf" + ((int)color).ToString() + " " + text.ToString() + "\\cf0}" }); }
public static RTFBuilder Underline(RTFBuilder text) { return(new RTFBuilder() { InternalStr = "{\\ul " + text.ToString() + "\\ul0}" }); }
protected override void DoWork(TranslateContext context) { var service = context.Service; int batchWait = 0; var batchWorkingList = new List <ChattingLine>(); while (!WorkingThreadStopping) { if (batchWorkingList.Count > BatchThreshold || (batchWait > 1 && batchWorkingList.Count > 0)) { batchWait = 0; // Invoke translate service try { context.Provider.Translate(batchWorkingList); // TODO: Set color and label var finalResultBuilder = new RTFBuilder(); foreach (var line in batchWorkingList) { var settings = service._plugin.GetChannelSettings(line.EventCode); finalResultBuilder.ForeColor(settings.DisplayColor).AppendLine( $"{TextProcessor.BuildQuote(line, settings.ShowLabel)}{line.TranslatedContent}"); } service._controller.NotifyOverlayContentUpdated(false, finalResultBuilder.ToString()); } catch (Exception ex) { service._controller.NotifyLogMessageAppend(false, ex + "\n"); } finally { batchWorkingList.Clear(); } } else { lock (service._mainLock) { if (service._pendingLines.Count > 0) { batchWait = 0; batchWorkingList.AddRange(service._pendingLines); service._pendingLines.Clear(); } else { if (batchWorkingList.Count > 0) { batchWait++; } Monitor.Wait(service._mainLock, 500); } } } } }
public void Debugging(ulong address) { string adjustment = address.ToString("X"); adjustment = adjustment.Remove(adjustment.Length - 1, 1) + "0"; ulong _address = _a(adjustment); offsetsText.Text = null; byte[] bytes; RTFBuilderbase builderbase = new RTFBuilder(); builderbase.Font(RTFFont.CourierNew); builderbase.FontSize(22f); bytes = PS4.ReadMemory(PID, _address, 500); for (int i = 0; i < bytes.Length; i++) { builderbase.Font(RTFFont.CourierNew); builderbase.FontSize(22f); if (oldBytes != null) { if (bytes.Length == oldBytes.Length) { if (bytes[i] == oldBytes[i]) { builderbase.Append(bytes[i].ToString("X2") + " "); } else { builderbase.ForeColor(KnownColor.ForestGreen).Append(bytes[i].ToString("X2") + " "); } } else { builderbase.Append(bytes[i].ToString("X2") + " "); } } else { builderbase.Append(bytes[i].ToString("X2") + " "); } } oldBytes = bytes; string str2 = builderbase.ToString(); hexCode.Rtf = str2; string str3 = SpliceText(Encoding.Default.GetString(bytes).Replace("\0", ".").Replace("\a", ".").Replace("\v", ".").Replace("\r", ".").Replace(" ", ".").Replace("\t", ".").Replace("\n", ".").Replace("\b", ".").Replace("\f", "."), 0x10); asciiText.Text = str3; uint num3 = (uint)_address; int num4 = (hexCode.Text.Length / 0x30) + 1; for (int j = 0; j < num4; j++) { offsetsText.Text = $"{offsetsText.Text}0x{_address.ToString("X")}\n"; _address += 0x10; } }
private static void ConstantWrite() { bool sleep = false; while (true) { if (cWrite == 1) { try { byte[] bytes; RTFBuilderbase builderbase = new RTFBuilder(); builderbase.Font(RTFFont.CourierNew); builderbase.FontSize(22f); bytes = PS3.Extension.ReadBytes(dOffset, 800); for (int i = 0; i < bytes.Length; i++) { builderbase.Font(RTFFont.CourierNew); builderbase.FontSize(22f); if (oldBytes != null) { if (bytes.Length == oldBytes.Length) { if (bytes[i] == oldBytes[i]) { builderbase.Append(bytes[i].ToString("X2") + " "); } else { builderbase.ForeColor(KnownColor.LimeGreen).Append(bytes[i].ToString("X2") + " "); } } else { builderbase.Append(bytes[i].ToString("X2") + " "); } } else { builderbase.Append(bytes[i].ToString("X2") + " "); } } oldBytes = bytes; str2 = builderbase.ToString(); str3 = SpliceText(Encoding.Default.GetString(bytes).Replace("\0", ".").Replace("\a", ".").Replace("\v", ".").Replace("\r", ".").Replace(" ", ".").Replace("\t", ".").Replace("\n", ".").Replace("\b", ".").Replace("\f", "."), 0x10); } catch { } if (!sleep) { Thread.Sleep(10); } } } }
public void Send_New_Designed_EMail() { RTFBuilderbase sb = new RTFBuilder(); BuilderCode(sb); this.richTextBox1.Rtf = sb.ToString(); }
public static RTFBuilder BackColored(RTFBuilder text, int color) { return(new RTFBuilder() { InternalStr = "{\\chcbpat" + ((int)color).ToString() + "\\cb" + ((int)color).ToString() + "\\highlight" + ((int)color).ToString() + " " + text.ToString() + "\\chcbpat0\\cb0\\hightlight0}" }); }
public static void GetFormattedHeader(this BaseRecord rec, RTFBuilder rb) { if (rec is Record) { ((Record)rec).GetFormattedHeader(rb); } else if (rec is SubRecord) { ((SubRecord)rec).GetFormattedHeader(rb); } }
public void RefreshDisplayData() { if (notifierInstance != null && notifierInstance.Alerts != null) { RTFBuilder rtfBuilder = new RTFBuilder(); if (notifierInstance.Alerts.Count == 0) { } else { if (lastAlert != null && lastAlert.RaisedTime == notifierInstance.Alerts[notifierInstance.Alerts.Count - 1].RaisedTime) { return; } else if (notifierInstance.Alerts.Count > 0) { lastAlert = notifierInstance.Alerts[notifierInstance.Alerts.Count - 1]; } for (int i = notifierInstance.Alerts.Count - 1; i >= 0; i--) { AlertRaised alertRaised = notifierInstance.Alerts[i]; rtfBuilder.Append(string.Format("{0}:", alertRaised.RaisedTime.ToString("yyyy-MM-dd HH:mm:ss"))).FontStyle(FontStyle.Bold); if (alertRaised.Level == AlertLevel.Error) { rtfBuilder.ForeColor(Color.DarkRed); } else if (alertRaised.Level == AlertLevel.Warning) { rtfBuilder.ForeColor(Color.DarkOrange); } rtfBuilder.Append(string.Format(" {0}", alertRaised.Level)); rtfBuilder.FontStyle(FontStyle.Regular).ForeColor(SystemColors.ControlText); string viaHost = ""; if (alertRaised.RaisedFor.OverrideRemoteAgentHost) { viaHost = string.Format("(via {0}:{1})", alertRaised.RaisedFor.OverrideRemoteAgentHostAddress, alertRaised.RaisedFor.OverrideRemoteAgentHostPort); } else if (alertRaised.RaisedFor.EnableRemoteExecute) { viaHost = string.Format("(via {0}:{1})", alertRaised.RaisedFor.RemoteAgentHostAddress, alertRaised.RaisedFor.RemoteAgentHostPort); } rtfBuilder.Append(string.Format("\t{0} {1}\r\n{2}", alertRaised.RaisedFor, viaHost, alertRaised.State.RawDetails)); rtfBuilder.AppendLine(); } } alertsRichTextBox.Rtf = rtfBuilder.ToString(); } }
private void DisplaySelectedItemDetails() { string oldStatusText = toolStripStatusLabelDetails.Text; RTFBuilder rtfBuilder = new RTFBuilder(); string logName = ""; if (lvwEntries2.SelectedItems.Count > 0 && lvwEntries2.SelectedItems[0].Tag is EventLogCollectorEntry) { logName = ((EventLogCollectorEntry)lvwEntries2.SelectedItems[0].Tag).EventLog; } if (lvwDetails.SelectedItems.Count > MAXPREVIEWDISPLAYCOUNT) { Cursor.Current = Cursors.WaitCursor; } //have to limit the maximum number of selected items foreach (ListViewItem lvi in (from ListViewItem l in lvwDetails.SelectedItems select l).Take(MAXPREVIEWDISPLAYCOUNT)) { if (lvi.Tag is EventLogEntryEx) { EventLogEntryEx ev = (EventLogEntryEx)lvi.Tag; rtfBuilder.FontStyle(FontStyle.Bold).Append("Date time: ").AppendLine(ev.TimeGenerated.ToString("yyyy-MM-dd HH:mm:ss")); rtfBuilder.FontStyle(FontStyle.Bold).Append("Type: ").AppendLine(ev.EntryType.ToString()); rtfBuilder.FontStyle(FontStyle.Bold).Append("Computer: ").AppendLine(ev.MachineName); rtfBuilder.FontStyle(FontStyle.Bold).Append("Event log: ").AppendLine(ev.LogName); rtfBuilder.FontStyle(FontStyle.Bold).Append("Source: ").AppendLine(ev.Source); rtfBuilder.FontStyle(FontStyle.Bold).Append("Event ID: ").AppendLine(ev.EventId.ToString()); rtfBuilder.FontStyle(FontStyle.Bold).Append("Message: ").AppendLine(); rtfBuilder.Append(ev.Message.Replace("\r\n", "\r\n\t")).AppendLine(); rtfBuilder.FontStyle(FontStyle.Underline).AppendLine(new String(' ', 250)); rtfBuilder.AppendLine(); } } if (lvwDetails.SelectedItems.Count > MAXPREVIEWDISPLAYCOUNT) { rtfBuilder.FontStyle(FontStyle.Bold).AppendLine(string.Format("Only first {0} entries shown...", MAXPREVIEWDISPLAYCOUNT)); } else if (lvwDetails.SelectedItems.Count == 0) { rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("No entries selected"); } else { rtfBuilder.FontStyle(FontStyle.Bold).AppendLine(string.Format("{0} entry(s)", lvwDetails.SelectedItems.Count)); } rtxDetails.Rtf = rtfBuilder.ToString(); rtxDetails.SelectionStart = 0; rtxDetails.SelectionLength = 0; rtxDetails.ScrollToCaret(); Cursor.Current = Cursors.Default; toolStripStatusLabelDetails.Text = oldStatusText; }
private void DisplaySelectedItemDetails() { string oldStatusText = toolStripStatusLabelDetails.Text; try { RTFBuilder rtfBuilder = new RTFBuilder(); //avoid cursor flickering when only a few items are selected //if (lvwDetails.SelectedItems.Count > MAXPREVIEWDISPLAYCOUNT) Cursor.Current = Cursors.WaitCursor; //have to limit the maximum number of selected items foreach (ListViewItem lvi in (from ListViewItem l in lvwDetails.SelectedItems select l).Take(MAXPREVIEWDISPLAYCOUNT)) { for (int i = 0; i < lvwDetails.Columns.Count; i++) { rtfBuilder.FontStyle(FontStyle.Bold).Append(lvwDetails.Columns[i].Text + ": ").AppendLine(lvi.SubItems[i].Text); } rtfBuilder.FontStyle(FontStyle.Underline).AppendLine(new String(' ', 250)); rtfBuilder.AppendLine(); } if (lvwDetails.SelectedItems.Count > MAXPREVIEWDISPLAYCOUNT) { rtfBuilder.FontStyle(FontStyle.Bold).AppendLine(string.Format("Only first {0} entries shown...", MAXPREVIEWDISPLAYCOUNT)); } else if (lvwDetails.SelectedItems.Count == 0) { rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("No entries selected"); } else { rtfBuilder.FontStyle(FontStyle.Bold).AppendLine(string.Format("{0} entry(s)", lvwDetails.SelectedItems.Count)); } rtxDetails.Rtf = rtfBuilder.ToString(); rtxDetails.SelectionStart = 0; rtxDetails.SelectionLength = 0; rtxDetails.ScrollToCaret(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor.Current = Cursors.Default; toolStripStatusLabelDetails.Text = oldStatusText; } }
public static void GetFormattedData(this BaseRecord rec, RTFBuilder rb) { if (rec is Record) { ((Record)rec).GetFormattedData(rb); } else if (rec is SubRecord) { ((SubRecord)rec).GetFormattedData(rb); } else { rb.Append(rec.GetDesc()); } }
private void lvwHistory_SelectedIndexChanged(object sender, EventArgs e) { try { RTFBuilder rtfBuilder = new RTFBuilder(); ListViewEx currentListView; currentListView = lvwHistory; if (currentListView.SelectedItems.Count > 0) { foreach (ListViewItem lvi in currentListView.SelectedItems) { if (lvi.Tag is MonitorState) { MonitorState historyItem = (MonitorState)lvi.Tag; rtfBuilder.FontStyle(FontStyle.Bold).Append("Time: "); rtfBuilder.AppendLine(lvi.Text); rtfBuilder.FontStyle(FontStyle.Bold).Append("State: "); rtfBuilder.AppendLine(lvi.SubItems[1].Text); rtfBuilder.FontStyle(FontStyle.Bold).Append("Duration: "); rtfBuilder.AppendLine(lvi.SubItems[2].Text + " ms"); rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("Details: "); rtfBuilder.AppendLine(lvi.SubItems[3].Text.TrimEnd('\r', '\n')); rtfBuilder.FontStyle(FontStyle.Bold).Append("Executed by: "); rtfBuilder.AppendLine(lvi.SubItems[4].Text); if (historyItem.AlertsRaised.Count > 0) { rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("Alerts: "); foreach (string alertEntry in historyItem.AlertsRaised) { rtfBuilder.AppendLine(" " + alertEntry); } } rtfBuilder.AppendLine(new string('-', 80)); } } } rtxDetails.Rtf = rtfBuilder.ToString(); rtxDetails.SelectionStart = 0; rtxDetails.SelectionLength = 0; rtxDetails.ScrollToCaret(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DisplaySelectedItemDetails(int maxSelection) { string oldStatusText = toolStripStatusLabelDetails.Text; RTFBuilder rtfBuilder = new RTFBuilder(); //avoid cursor flickering when only a few items are selected if (lvwMessages.SelectedItems.Count > MAXPREVIEWDISPLAYCOUNT) { Cursor.Current = Cursors.WaitCursor; } //have to limit the maximum number of selected items foreach (ListViewItem lvi in (from ListViewItem l in lvwMessages.SelectedItems select l).Take(maxSelection)) { AlertMessage entry = (AlertMessage)lvi.Tag; rtfBuilder.FontStyle(FontStyle.Bold).Append("Insert time: ").AppendLine(entry.InsertDate.ToShortDateString() + " " + entry.InsertDate.ToShortTimeString()); rtfBuilder.FontStyle(FontStyle.Bold).Append("Level: ").AppendLine(entry.AlertLevel.ToString()); rtfBuilder.FontStyle(FontStyle.Bold).Append("Collector type: ").AppendLine(entry.CollectorType); rtfBuilder.FontStyle(FontStyle.Bold).Append("Category: ").AppendLine(entry.Category); rtfBuilder.FontStyle(FontStyle.Bold).Append("Previous state: ").AppendLine(entry.PreviousState.ToString()); rtfBuilder.FontStyle(FontStyle.Bold).Append("Current state: ").AppendLine(entry.CurrentState.ToString()); rtfBuilder.FontStyle(FontStyle.Bold).Append("Details:"); rtfBuilder.AppendPara().LineIndent(500).AppendLine(entry.Details); rtfBuilder.FontStyle(FontStyle.Underline).AppendLine(new String(' ', 250)); rtfBuilder.AppendLine(); } if (lvwMessages.SelectedItems.Count > maxSelection) { rtfBuilder.FontStyle(FontStyle.Bold).AppendLine(string.Format("Only first {0} entries shown... Use 'Show details for all selected items' to display all", maxSelection)); } else if (lvwMessages.SelectedItems.Count == 0) { rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("No entries selected"); } else { rtfBuilder.FontStyle(FontStyle.Bold).AppendLine(string.Format("{0} entry(s)", lvwMessages.SelectedItems.Count)); } rtxDetails.Rtf = rtfBuilder.ToString(); rtxDetails.SelectionStart = 0; rtxDetails.SelectionLength = 0; rtxDetails.ScrollToCaret(); Cursor.Current = Cursors.Default; toolStripStatusLabelDetails.Text = oldStatusText; }
private void lvwProperties_SelectedIndexChanged(object sender, EventArgs e) { try { RTFBuilder rtfBuilder = new RTFBuilder(); ListViewEx currentListView; //if (tabControl1.SelectedIndex == 0) currentListView = lvwProperties; //else // currentListView = lvwHistory; if (currentListView.SelectedItems.Count > 0) { int maxlen = 35; foreach (ListViewItem lvi in currentListView.Items) { if (lvi.Text.Length + 2 > maxlen) { maxlen = lvi.Text.Length + 2; } } foreach (ListViewItem lvi in currentListView.SelectedItems) { rtfBuilder.FontStyle(FontStyle.Bold).Append((lvi.Text + ":").PadRight(maxlen)); if (lvi.SubItems[1].Text.Contains("\r")) { rtfBuilder.AppendLine(""); } else { rtfBuilder.Append("\t"); } rtfBuilder.AppendLine(lvi.SubItems[1].Text.Trim('\r', '\n')); } } rtxDetails.Rtf = rtfBuilder.ToString(); rtxDetails.SelectionStart = 0; rtxDetails.SelectionLength = 0; rtxDetails.ScrollToCaret(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public override void GetFormattedHeader(RTFBuilder rb) { rb.FontStyle(FontStyle.Bold).FontSize(rb.DefaultFontSize + 4).ForeColor(KnownColor.DarkGray).AppendLine("[Record]"); rb.Append("Type: \t").FontStyle(FontStyle.Bold).FontSize(rb.DefaultFontSize + 2).AppendFormat("{0}", Name).AppendLine(); rb.Append("FormID: \t").FontStyle(FontStyle.Bold).FontSize(rb.DefaultFontSize + 2).ForeColor(KnownColor.DarkRed).AppendFormat("{0:X8}", this.FormID).AppendLine(); rb.AppendLineFormat("Flags 1: \t{0:X8}", this.Flags1); if (this.Flags1 != 0) { rb.AppendLineFormat(" ({0})", FlagDefs.GetRecFlags1Desc(this.Flags1)); } rb.AppendLineFormat("Flags 2: \t{0:X8}", this.Flags2); rb.AppendLineFormat("Flags 3: \t{0:X8}", this.Flags3); rb.AppendLineFormat("Size: \t{0:N0}", this.Size); rb.AppendLineFormat("Subrecords:\t{0}", this.SubRecords.Count); rb.AppendPara(); }
public void UpdateRecord(BaseRecord sc) { if (sc == null) { UpdateText(""); return; } FontLangInfo defLang; if (!Encoding.TryGetFontInfo(Properties.Settings.Default.LocalizationName, out defLang)) { defLang = new FontLangInfo(1252, 1033, 0); } var rb = new RTFBuilder(RTFFont.Arial, 16, defLang.lcid, defLang.charset); sc.GetFormattedHeader(rb); sc.GetFormattedData(rb); this.rtfInfo.Rtf = rb.ToString(); }
public static string BuildRTF( FFXIVTranslatePlugin plugin, bool addTimestamp, bool timestamp24Hour, IEnumerable <ChattingLine> chattingLines) { var finalResultBuilder = new RTFBuilder(); foreach (var line in chattingLines) { if (addTimestamp) { finalResultBuilder.ForeColor(Color.White); string formattedTime; if (timestamp24Hour) { formattedTime = $"[{line.Timestamp:HH:mm}]"; } else { formattedTime = string.Format("[{0}]", line.Timestamp.ToString( line.Timestamp.Hour > 11 ? strings.timeFormat12HourPM : strings.timeFormat12HourAM, strings.Culture)); } finalResultBuilder.Append(formattedTime); } var settings = plugin.GetChannelSettings(line.EventCode); finalResultBuilder.ForeColor(settings.DisplayColor); finalResultBuilder.AppendLine( $"{TextProcessor.BuildQuote(line, settings.ShowLabel)}{line.TranslatedContent}"); } return(finalResultBuilder.ToString()); }
public void Colorize(int start, int end, string text, List<ColorChangeInfo> color_changes, ref ColorTable color_table) { Debug.Assert(text.Length == end - start); if (!m_Colorized) return; if (color_changes.Count < 2) return; PausePainting(); SaveSelectionAndScrollPos(); try { int length = end - start; RTFBuilder rtf_builder = new RTFBuilder(Font, text, 0, color_changes, ref color_table); Select(start, length); SelectedRtf = rtf_builder.RTF; } finally { RestoreSelectionAndScrollPos(); ResumePainting(); } }
// The color info of last item of color_changes isn't used, the last item is there only to provide the end iterator of the affected text. public void Colorize(List<ColorChangeInfo> color_changes, ref ColorTable color_table) { if (!m_Colorized) return; if (color_changes.Count < 2) return; PausePainting(); SaveSelectionAndScrollPos(); try { int start = color_changes[0].text_index; int end = color_changes[color_changes.Count - 1].text_index; int length = end - start; string text = GetTextRange(start, end); RTFBuilder rtf_builder = new RTFBuilder(Font, text, -start, color_changes, ref color_table); Select(start, length); SelectedRtf = rtf_builder.RTF; } finally { RestoreSelectionAndScrollPos(); ResumePainting(); } }
public void Clear() { //output.Clear(); output = new RTFBuilder(); }
public virtual void GetFormattedHeader(RTFBuilder rb) { }