public Test(string[] args) { if (args.Length == 0) { throw new Exception("Program needs path to rtf file as argument"); } FileStream stream; RTF rtf; text = new TextMap(); TextMap.SetupStandardTable(text.Table); stream = new FileStream(@"../test.rtf", FileMode.Open); rtf = new RTF(stream); skip_width = 0; skip_count = 0; rtf.ClassCallback[TokenClass.Text] = new ClassDelegate(HandleText); rtf.ClassCallback[TokenClass.Control] = new ClassDelegate(HandleControl); rtf.Read(); stream.Close(); }
public void TestParse() { var rtf = new RTF(ByteUtils.AsAsciiStream(RtfTestData.WordGame)); rtf.ClassCallback[TokenClass.Control] = r => { if (r.Major == Major.CharAttr) { if (r.Minor == Minor.FontSize) { Trace.Write(string.Format("FontSize {0} ", r.Param)); return; } } }; var t = new StringBuilder(); rtf.ClassCallback[TokenClass.Text] = r => { t.Append(r.EncodedText); }; rtf.Read(); Trace.WriteLine(""); Trace.WriteLine(t.ToString()); }
void lstSets_SelectedIndexChanged(object sender, EventArgs e) { if (this.lstSets.SelectedItems.Count < 1) { return; } this.rtxtInfo.Rtf = RTF.StartRTF() + EnhancementSetCollection.GetSetInfoLongRTF(Conversions.ToInteger(this.lstSets.SelectedItems[0].Tag), Conversions.ToInteger(this.lstSets.SelectedItems[0].SubItems[2].Text)) + RTF.EndRTF(); }
public static string EndRTF() { StringBuilder stringBuilder = new StringBuilder(RTF.Size(RTF.SizeID.Regular)); stringBuilder.Append(RTF.Color(RTF.ElementID.Text)); stringBuilder.Append(RTF.GetFooter()); return(stringBuilder.ToString()); }
static public Style GetStyle(RTF rtf, int style_number) { Style s; lock (rtf) { s = GetStyle(rtf.Styles, style_number); } return(s); }
static public Color GetColor(RTF rtf, int color_number) { Color c; lock (rtf) { c = GetColor(rtf.Colors, color_number); } return(c); }
public RtfToHtml(RTF parser) { this.parser = parser; parser.ClassCallback [TokenClass.Text] = new ClassDelegate(HandleText); parser.ClassCallback [TokenClass.Control] = new ClassDelegate(HandleControl); text_buffer = new StringBuilder(); }
public void TestEmptyDoc() { RTF parser = new RTF(TextStream("{\\rtf1}")); RtfToHtml r = new RtfToHtml(parser); r.Run(); Assert.AreEqual(String.Empty, r.GetText(), "emptydoc-1"); }
private string ParsedText(string text) { RTF parser = new RTF(TextStream(text)); RtfToHtml r = new RtfToHtml(parser); r.Run(); return(r.GetText()); }
static public Font GetFont(RTF rtf, int font_number) { Font f; lock (rtf) { f = GetFont(rtf.Fonts, font_number); } return(f); }
override protected void DoClose() { sb.Length = 0; sb = null; group_stack.Clear(); group_stack = null; rtf = null; }
public static string StartRTF() { StringBuilder stringBuilder = new StringBuilder("{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}{\\f1\\fnil\\fcharset2 Symbol;}}"); stringBuilder.Append(Environment.NewLine); stringBuilder.Append(RTF.GetColorTable()); stringBuilder.Append(Environment.NewLine); stringBuilder.Append(RTF.GetInitialLine()); return(stringBuilder.ToString()); }
static string GetInitialLine() { StringBuilder stringBuilder = new StringBuilder("{\\*\\generator MHD_RTFClass;}\\viewkind4\\uc1\\pard\\f0\\fs"); stringBuilder.Append(MidsContext.Config.RtFont.RTFBase); stringBuilder.Append(" "); stringBuilder.Append(RTF.Color(RTF.ElementID.Text)); if (MidsContext.Config.RtFont.RTFBold) { stringBuilder.Append("\\b "); } return(stringBuilder.ToString()); }
public static string GetSetInfoLongRTF(int iSet, int enhCount = -1) { string str1; if (iSet <0 | iSet> DatabaseAPI.Database.EnhancementSets.Count - 1) { str1 = string.Empty; } else { string str2; if (DatabaseAPI.Database.EnhancementSets[iSet].LevelMin == DatabaseAPI.Database.EnhancementSets[iSet].LevelMax) { str2 = RTF.Color(RTF.ElementID.Invention) + RTF.Bold(RTF.Underline(DatabaseAPI.Database.EnhancementSets[iSet].DisplayName + " (" + DatabaseAPI.Database.EnhancementSets[iSet].LevelMin + 1 + "): ")); } else { str2 = RTF.Color(RTF.ElementID.Invention) + RTF.Bold(RTF.Underline(DatabaseAPI.Database.EnhancementSets[iSet].DisplayName + " (" + (DatabaseAPI.Database.EnhancementSets[iSet].LevelMin + 1) + "-" + (DatabaseAPI.Database.EnhancementSets[iSet].LevelMax + 1) + "): ")); } string str3 = str2 + RTF.Color(RTF.ElementID.Text); for (int index = 0; index <= DatabaseAPI.Database.EnhancementSets[iSet].Bonus.Length - 1; ++index) { string effectString = DatabaseAPI.Database.EnhancementSets[iSet].GetEffectString(index, false, false); if (!string.IsNullOrEmpty(effectString)) { if (DatabaseAPI.Database.EnhancementSets[iSet].Bonus[index].PvMode == Enums.ePvX.PvP) { effectString += "(PvP)"; } if (enhCount >= DatabaseAPI.Database.EnhancementSets[iSet].Bonus[index].Slotted & (MidsContext.Config.Inc.PvE & DatabaseAPI.Database.EnhancementSets[iSet].Bonus[index].PvMode == Enums.ePvX.PvE | !MidsContext.Config.Inc.PvE & DatabaseAPI.Database.EnhancementSets[iSet].Bonus[index].PvMode == Enums.ePvX.PvP | DatabaseAPI.Database.EnhancementSets[iSet].Bonus[index].PvMode == Enums.ePvX.Any)) { str3 = str3 + RTF.Crlf() + RTF.Bold(RTF.Color(RTF.ElementID.Text) + " " + DatabaseAPI.Database.EnhancementSets[iSet].Bonus[index].Slotted + " Slotted: ") + RTF.Color(RTF.ElementID.Invention) + effectString + RTF.Color(RTF.ElementID.Text); } else { str3 = str3 + RTF.Crlf() + RTF.Bold(RTF.Color(RTF.ElementID.Text) + " " + DatabaseAPI.Database.EnhancementSets[iSet].Bonus[index].Slotted + " Slotted: ") + RTF.Color(RTF.ElementID.Faded) + effectString + RTF.Color(RTF.ElementID.Text); } } } for (int index = 0; index <= DatabaseAPI.Database.EnhancementSets[iSet].SpecialBonus.Length - 1; ++index) { string effectString = DatabaseAPI.Database.EnhancementSets[iSet].GetEffectString(index, true, false); if (!string.IsNullOrEmpty(effectString)) { str3 = str3 + RTF.Crlf() + RTF.Color(RTF.ElementID.Enhancement) + RTF.Bold(" " + DatabaseAPI.Database.Enhancements[DatabaseAPI.Database.EnhancementSets[iSet].Enhancements[index]].Name + ": ") + RTF.Color(RTF.ElementID.Faded) + effectString + RTF.Color(RTF.ElementID.Text); } } str1 = str3; } return(str1); }
private void FlushText(RTF rtf, bool newline) { var length = _line.Length; if (!newline && (length == 0)) { document.Add(null, null, 0, newline); return; } if (_style.FontName == null) { // First font in table is default _style.FontName = global::Limaki.Common.Text.RTF.Parser.Font.GetFont(rtf, 0).Name; } var font = XD.Font.FromName(_style.FontName + " " + _style.FontSize.ToString()); if (_style.Color == XD.Colors.Black) { // First color in table is default var color = Color.GetColor(rtf, 0); if ((color == null) || (color.Red == -1 && color.Green == -1 && color.Blue == -1)) { _style.Color = SystemColors.WindowText; } else { _style.Color = XD.Color.FromBytes((byte)color.Red, (byte)color.Green, (byte)color.Blue); } } _charCount += _line.Length; document.Add(_line.ToString(), _style, _cursorX, newline); if (newline) { _cursorX = 0; _cursorY++; } else { _cursorX += length; } _line.Length = 0; // Empty line }
public Font(RTF rtf) { this.rtf = rtf; num = -1; name = String.Empty; lock (rtf) { if (rtf.Fonts == null) rtf.Fonts = this; else { Font f = rtf.Fonts; while (f.next != null) f = f.next; f.next = this; } } }
public Color(RTF rtf) { red = -1; green = -1; blue = -1; num = -1; lock (rtf) { if (rtf.Colors == null) { rtf.Colors = this; } else { Color c = rtf.Colors; while (c.next != null) c = c.next; c.next = this; } } }
public Style(RTF rtf) { num = -1; type = StyleType.Paragraph; based_on = NoStyleNum; next_par = -1; lock (rtf) { if (rtf.Styles == null) { rtf.Styles = this; } else { Style s = rtf.Styles; while (s.next != null) s = s.next; s.next = this; } } }
void HandleGroup(RTF rtf) { switch (rtf.Major) { case Major.BeginGroup: if (reading_properties) { info_group = (info_group > 0 ? info_group + 1 : info_group); } if (debug) { Console.WriteLine("[new group] {0}", info_group); } group_stack.Push(current_is_hot); current_is_hot = false; break; case Major.EndGroup: FlushText(); if (current_is_hot) { if (debug) { Console.WriteLine("[end hot]"); } HotDown(); } try { current_is_hot = group_stack.Pop(); } catch { current_is_hot = false; } if (reading_properties) { info_group = (info_group > 0 ? info_group - 1 : info_group); } if (debug) { Console.WriteLine("[end new group] {0}", info_group); } break; } }
void Init() { rtf = new RTF(Stream); if (text_map == null) { text_map = new TextMap(); TextMap.SetupStandardTable(text_map.Table); } sb = new StringBuilder(); sb.Length = 0; group_stack = new Stack <bool> (); current_is_hot = false; skip_width = 0; skip_count = 0; }
ConfigData(string iFilename = "") { this.DamageMath.Calculate = ConfigData.EDamageMath.Average; this.DamageMath.ReturnValue = ConfigData.EDamageReturn.Numeric; this.Inc.PvE = true; this.I9.DefaultIOLevel = 49; this.I9.DisplayIOLevels = true; this.I9.CalculateEnahncementFX = true; this.I9.CalculateSetBonusFX = true; this.I9.PrintIOLevels = true; this.I9.ExportIOLevels = false; this.I9.ExportCompress = true; this.I9.ExportDataChunk = true; this.I9.ExportStripEnh = false; this.I9.ExportStripSetNames = false; this.I9.ExportExtraSep = false; this.UpdatePath = ""; this.DefaultSaveFolder = OS.GetDefaultSaveFolder(); this.RtFont.SetDefault(); this.Tips = new Tips(); this.Export = new ExportConfig(); this.CompOverride = new Enums.CompOverride[0]; this.RTF = new RTF(); if (!string.IsNullOrEmpty(iFilename)) { try { this.Load(iFilename); } catch (Exception ex) { MessageBox.Show(ex.Message); } } this.RelocateSaveFolder(false); try { this.LoadOverrides(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void updateColours() { ConfigData.FontSettings iFs = new ConfigData.FontSettings(); this.csHero.BackColor = this.myFS.ColorBackgroundHero; this.csVillain.BackColor = this.myFS.ColorBackgroundVillain; this.csText.BackColor = this.myFS.ColorText; this.csInv.BackColor = this.myFS.ColorInvention; this.csInvInv.BackColor = this.myFS.ColorInventionInv; this.csFade.BackColor = this.myFS.ColorFaded; this.csEnh.BackColor = this.myFS.ColorEnhancement; this.csAlert.BackColor = this.myFS.ColorWarning; this.csValue.BackColor = this.myFS.ColorPlName; this.csSpecial.BackColor = this.myFS.ColorPlSpecial; iFs.Assign(MidsContext.Config.RtFont); MidsContext.Config.RtFont.Assign(this.myFS); this.rtPreview.BackColor = this.myFS.ColorBackgroundHero; MidsContext.Config.RtFont.ColorBackgroundHero = this.myFS.ColorPlName; MidsContext.Config.RtFont.ColorBackgroundVillain = this.myFS.ColorPlSpecial; RTF rtf = MidsContext.Config.RTF; this.rtPreview.Rtf = RTF.StartRTF() + RTF.Color(RTF.ElementID.Invention) + RTF.Underline("Invention Name") + RTF.Crlf() + RTF.Color(RTF.ElementID.Enhancement) + RTF.Italic("Enhancement Text") + RTF.Color(RTF.ElementID.Warning) + " (Alert)" + RTF.Crlf() + RTF.Color(RTF.ElementID.Text) + " Regular Text" + RTF.Crlf() + RTF.Color(RTF.ElementID.Text) + " Regular Text" + RTF.Crlf() + RTF.Color(RTF.ElementID.Faded) + " Faded Text" + RTF.Crlf() + RTF.Crlf() + RTF.Color(RTF.ElementID.BackgroundHero) + RTF.Bold("Value Name: ") + RTF.Color(RTF.ElementID.Text) + "Normal Text" + RTF.Crlf() + RTF.Color(RTF.ElementID.BackgroundHero) + RTF.Bold("Value Name: ") + RTF.Color(RTF.ElementID.BackgroundVillain) + "Special Case" + RTF.Crlf() + RTF.Color(RTF.ElementID.BackgroundHero) + RTF.Bold("Value Name: ") + RTF.Color(RTF.ElementID.Enhancement) + "Enahnced value" + RTF.Crlf() + RTF.Color(RTF.ElementID.BackgroundHero) + RTF.Bold("Value Name: ") + RTF.Color(RTF.ElementID.Invention) + "Invention Effect" + RTF.Crlf() + RTF.EndRTF(); this.Listlabel1.SuspendRedraw = true; this.Listlabel1.ClearItems(); this.Listlabel1.AddItem(new ListLabelV2.ListLabelItemV2("Available Power", ListLabelV2.LLItemState.Enabled, -1, -1, -1, "", ListLabelV2.LLFontFlags.Normal, ListLabelV2.LLTextAlign.Left)); this.Listlabel1.AddItem(new ListLabelV2.ListLabelItemV2("Taken Power", ListLabelV2.LLItemState.Selected, -1, -1, -1, "", ListLabelV2.LLFontFlags.Normal, ListLabelV2.LLTextAlign.Left)); this.Listlabel1.AddItem(new ListLabelV2.ListLabelItemV2("Taken Power (Dark)", ListLabelV2.LLItemState.SelectedDisabled, -1, -1, -1, "", ListLabelV2.LLFontFlags.Normal, ListLabelV2.LLTextAlign.Left)); this.Listlabel1.AddItem(new ListLabelV2.ListLabelItemV2("Unavailable Power", ListLabelV2.LLItemState.Disabled, -1, -1, -1, "", ListLabelV2.LLFontFlags.Normal, ListLabelV2.LLTextAlign.Left)); this.Listlabel1.AddItem(new ListLabelV2.ListLabelItemV2("Highlight Colour", ListLabelV2.LLItemState.Enabled, -1, -1, -1, "", ListLabelV2.LLFontFlags.Normal, ListLabelV2.LLTextAlign.Left)); this.Listlabel1.HoverColor = this.myFS.ColorPowerHighlight; this.Listlabel1.UpdateTextColors(ListLabelV2.LLItemState.Enabled, this.myFS.ColorPowerAvailable); this.Listlabel1.UpdateTextColors(ListLabelV2.LLItemState.Selected, this.myFS.ColorPowerTaken); this.Listlabel1.UpdateTextColors(ListLabelV2.LLItemState.SelectedDisabled, this.myFS.ColorPowerTakenDark); this.Listlabel1.UpdateTextColors(ListLabelV2.LLItemState.Disabled, this.myFS.ColorPowerDisabled); this.Listlabel1.Font = new System.Drawing.Font(this.Listlabel1.Font.FontFamily, MidsContext.Config.RtFont.PairedBase); int num = this.Listlabel1.Items.Length - 1; for (int index = 0; index <= num; ++index) { this.Listlabel1.Items[index].Bold = MidsContext.Config.RtFont.PairedBold; } this.Listlabel1.SuspendRedraw = false; this.Listlabel1.Refresh(); MidsContext.Config.RtFont.Assign(iFs); }
void SpecialChar(RTF rtf) { switch (rtf.Minor) { case Minor.Page: case Minor.Sect: case Minor.Row: case Minor.Line: case Minor.Par: //Console.Write("\n"); FlushText(); AppendStructuralBreak(); break; case Minor.Cell: //Console.Write(" "); AppendWhiteSpace(); break; case Minor.NoBrkSpace: //Console.Write(" "); AppendWhiteSpace(); break; case Minor.Tab: //Console.Write("\t"); AppendWhiteSpace(); break; case Minor.NoBrkHyphen: //Console.Write("-"); AppendTextSmartly('-'); break; case Minor.Bullet: //Console.Write("*"); AppendTextSmartly('*'); break; default: SkipGroup(rtf); break; } }
public Font(RTF rtf) { this.rtf = rtf; num = -1; name = String.Empty; lock (rtf) { if (rtf.Fonts == null) { rtf.Fonts = this; } else { Font f = rtf.Fonts; while (f.next != null) { f = f.next; } f.next = this; } } }
public Style(RTF rtf) { num = -1; type = StyleType.Paragraph; based_on = NoStyleNum; next_par = -1; lock (rtf) { if (rtf.Styles == null) { rtf.Styles = this; } else { Style s = rtf.Styles; while (s.next != null) { s = s.next; } s.next = this; } } }
void HandleText(RTF rtf) { if (skip_count > 0) { skip_count--; return; } if ((StandardCharCode)rtf.Minor != StandardCharCode.nothing) { Console.Write("{0}", text[(StandardCharCode)rtf.Minor]); } else { if ((int)rtf.Major > 31 && (int)rtf.Major < 128) { Console.Write("{0}", (char)rtf.Major); } else { Console.Write("[Literal:0x{0:X2}]", (int)rtf.Major); } } }
public Color(RTF rtf) { red = -1; green = -1; blue = -1; num = -1; lock (rtf) { if (rtf.Colors == null) { rtf.Colors = this; } else { Color c = rtf.Colors; while (c.next != null) { c = c.next; } c.next = this; } } }
static public bool DeleteFont(RTF rtf, int font_number) { Font f; Font prev; lock (rtf) { f = rtf.Fonts; prev = null; while ((f != null) && (f.num != font_number)) { prev = f; f = f.next; } if (f != null) { if (f == rtf.Fonts) { rtf.Fonts = f.next; } else { if (prev != null) { prev.next = f.next; } else { rtf.Fonts = f.next; } } return(true); } } return(false); }
private void DisplayBonusText() { var str1 = RTF.StartRTF(); var num1 = mySet.Bonus.Length - 1; for (var index1 = 0; index1 <= num1; ++index1) { switch (index1) { case 0: mySet.Bonus[index1].Slotted = 2; if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold(Convert.ToString(mySet.Bonus[index1].Slotted) + " Enhancements: "); } break; case 1: mySet.Bonus[index1].Slotted = 2; if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold(Convert.ToString(mySet.Bonus[index1].Slotted) + " Enhancements: "); } break; case 2: mySet.Bonus[index1].Slotted = 3; if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold(Convert.ToString(mySet.Bonus[index1].Slotted) + " Enhancements: "); } break; case 3: mySet.Bonus[index1].Slotted = 3; if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold(Convert.ToString(mySet.Bonus[index1].Slotted) + " Enhancements: "); } break; case 4: mySet.Bonus[index1].Slotted = 4; if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold(Convert.ToString(mySet.Bonus[index1].Slotted) + " Enhancements: "); } break; case 5: mySet.Bonus[index1].Slotted = 4; if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold(Convert.ToString(mySet.Bonus[index1].Slotted) + " Enhancements: "); } break; case 6: mySet.Bonus[index1].Slotted = 5; if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold(Convert.ToString(mySet.Bonus[index1].Slotted) + " Enhancements: "); } break; case 7: mySet.Bonus[index1].Slotted = 5; if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold(Convert.ToString(mySet.Bonus[index1].Slotted) + " Enhancements: "); } break; case 8: mySet.Bonus[index1].Slotted = 6; if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold(Convert.ToString(mySet.Bonus[index1].Slotted) + " Enhancements: "); } break; case 9: mySet.Bonus[index1].Slotted = 6; if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold(Convert.ToString(mySet.Bonus[index1].Slotted) + " Enhancements: "); } break; } var num2 = mySet.Bonus[index1].Index.Length - 1; for (var index2 = 0; index2 <= num2; ++index2) { if (mySet.Bonus[index1].Index[index2] <= -1) { continue; } if (index2 > 0) { str1 += ", "; } str1 = str1 + RTF.Color(RTF.ElementID.InventionInvert) + DatabaseAPI.Database.Power[mySet.Bonus[index1].Index[index2]].PowerName; } if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Crlf() + " " + RTF.Italic(mySet.GetEffectString(index1, false)); } if (mySet.Bonus[index1].PvMode == Enums.ePvX.PvP) { str1 += " (PvP)"; } if (mySet.Bonus[index1].Index.Length > 0) { str1 += RTF.Crlf(); } } var num3 = mySet.SpecialBonus.Length - 1; for (var index1 = 0; index1 <= num3; ++index1) { if (mySet.SpecialBonus[index1].Special > -1) { var str2 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold("Special Case Enhancement: ") + RTF.Color(RTF.ElementID.InventionInvert); if (mySet.Enhancements[mySet.SpecialBonus[index1].Special] > -1) { str2 += DatabaseAPI.Database .Enhancements[mySet.Enhancements[mySet.SpecialBonus[index1].Special]].Name; } var str3 = str2 + RTF.Crlf(); var num2 = mySet.SpecialBonus[index1].Index.Length - 1; for (var index2 = 0; index2 <= num2; ++index2) { if (mySet.SpecialBonus[index1].Index[index2] <= -1) { continue; } if (index2 > 0) { str3 += ", "; } str3 = str3 + RTF.Color(RTF.ElementID.InventionInvert) + DatabaseAPI.Database.Power[mySet.SpecialBonus[index1].Index[index2]].PowerName; } str1 = str3 + RTF.Crlf() + " " + RTF.Italic(mySet.GetEffectString(index1, true)) + RTF.Crlf(); } if (mySet.SpecialBonus[index1].Index.Length > 0) { str1 += RTF.Crlf(); } } rtbBonus.Rtf = str1 + RTF.EndRTF(); }
public void DisplayBonusText() { string str1 = RTF.StartRTF(); int num1 = mySet.Bonus.Length - 1; for (int index1 = 0; index1 <= num1; ++index1) { if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold(Convert.ToString(mySet.Bonus[index1].Slotted) + " Enhancements: "); } int num2 = mySet.Bonus[index1].Index.Length - 1; for (int index2 = 0; index2 <= num2; ++index2) { if (mySet.Bonus[index1].Index[index2] > -1) { if (index2 > 0) { str1 += ", "; } str1 = str1 + RTF.Color(RTF.ElementID.InentionInvert) + DatabaseAPI.Database.Power[mySet.Bonus[index1].Index[index2]].PowerName; } } if (mySet.Bonus[index1].Index.Length > 0) { str1 = str1 + RTF.Crlf() + " " + RTF.Italic(mySet.GetEffectString(index1, false, false)); } if (mySet.Bonus[index1].PvMode == Enums.ePvX.PvP) { str1 += "(PvP)"; } if (mySet.Bonus[index1].Index.Length > 0) { str1 += RTF.Crlf(); } } int num3 = mySet.SpecialBonus.Length - 1; for (int index1 = 0; index1 <= num3; ++index1) { if (mySet.SpecialBonus[index1].Special > -1) { string str2 = str1 + RTF.Color(RTF.ElementID.Black) + RTF.Bold("Special Case Enhancement: ") + RTF.Color(RTF.ElementID.InentionInvert); if (mySet.Enhancements[mySet.SpecialBonus[index1].Special] > -1) { str2 += DatabaseAPI.Database.Enhancements[mySet.Enhancements[mySet.SpecialBonus[index1].Special]].Name; } string str3 = str2 + RTF.Crlf(); int num2 = mySet.SpecialBonus[index1].Index.Length - 1; for (int index2 = 0; index2 <= num2; ++index2) { if (mySet.SpecialBonus[index1].Index[index2] > -1) { if (index2 > 0) { str3 += ", "; } str3 = str3 + RTF.Color(RTF.ElementID.InentionInvert) + DatabaseAPI.Database.Power[mySet.SpecialBonus[index1].Index[index2]].PowerName; } } str1 = str3 + RTF.Crlf() + " " + RTF.Italic(mySet.GetEffectString(index1, true, false)) + RTF.Crlf(); } if (mySet.SpecialBonus[index1].Index.Length > 0) { str1 += RTF.Crlf(); } } rtbBonus.Rtf = str1 + RTF.EndRTF(); }
static public bool DeleteFont(RTF rtf, int font_number) { Font f; Font prev; lock (rtf) { f = rtf.Fonts; prev = null; while ((f != null) && (f.num != font_number)) { prev = f; f = f.next; } if (f != null) { if (f == rtf.Fonts) { rtf.Fonts = f.next; } else { if (prev != null) { prev.next = f.next; } else { rtf.Fonts = f.next; } } return true; } } return false; }
static public Style GetStyle(RTF rtf, int style_number) { Style s; lock (rtf) { s = GetStyle(rtf.Styles, style_number); } return s; }
public void Expand(RTF rtf) { StyleElement se; if (num == -1) { return; } if (expanding) { throw new Exception("Recursive style expansion"); } expanding = true; if (num != based_on) { rtf.SetToken(TokenClass.Control, Major.ParAttr, Minor.StyleNum, based_on, "\\s"); rtf.RouteToken(); } se = elements; while (se != null) { rtf.TokenClass = se.TokenClass; rtf.Major = se.Major; rtf.Minor = se.Minor; rtf.Param = se.Param; rtf.Text = se.Text; rtf.RouteToken(); } expanding = false; }
static public Font GetFont(RTF rtf, int font_number) { Font f; lock (rtf) { f = GetFont(rtf.Fonts, font_number); } return f; }
static public Color GetColor(RTF rtf, int color_number) { Color c; lock (rtf) { c = GetColor(rtf.Colors, color_number); } return c; }
void SkipGroup(RTF rtf) { rtf.SkipGroup(); rtf.RouteToken(); }
void HandleControl(RTF rtf) { switch (rtf.Major) { case Major.Unicode: { switch (rtf.Minor) { case Minor.UnicodeCharBytes: { skip_width = rtf.Param; break; } case Minor.UnicodeChar: { if (debug) { Console.Write("[Unicode {0:X4}]", rtf.Param); } skip_count += skip_width; break; } } break; } case Major.Destination: { HandleInfo(rtf); break; } case Major.CharAttr: { switch (rtf.Minor) { case Minor.Plain: if (debug) { Console.Write("[Normal]"); } GroupIsNotHot(); break; case Minor.Bold: if (rtf.Param == RTF.NoParam) { if (debug) { Console.Write("[Bold]"); } GroupIsHot(); } else { if (debug) { Console.Write("[NoBold]"); } GroupIsNotHot(); } break; case Minor.Italic: if (rtf.Param == RTF.NoParam) { if (debug) { Console.Write("[Italic]"); } GroupIsHot(); } else { if (debug) { Console.Write("[NoItalic]"); } GroupIsNotHot(); } break; case Minor.Underline: { if (rtf.Param == RTF.NoParam) { if (debug) { Console.Write("[Underline]"); } GroupIsHot(); } else { if (debug) { Console.Write("[NoUnderline]"); } GroupIsNotHot(); } break; } default: break; } break; } case Major.SpecialChar: { SpecialChar(rtf); break; } } }
void HandleInfo(RTF rtf) { switch (rtf.Minor) { case Minor.HeaderLeft: SkipGroup(rtf); break; case Minor.HeaderRight: SkipGroup(rtf); break; case Minor.HeaderFirst: SkipGroup(rtf); break; case Minor.FooterLeft: SkipGroup(rtf); break; case Minor.FooterRight: SkipGroup(rtf); break; case Minor.FooterFirst: SkipGroup(rtf); break; case Minor.FieldInst: SkipGroup(rtf); break; case Minor.Info: if (debug) { Console.WriteLine("[Info started]"); } info_group = 1; break; case Minor.ITitle: AddRTFInfo(rtf, "dc:title", false); break; case Minor.ISubject: AddRTFInfo(rtf, "dc:subject", false); break; case Minor.IAuthor: AddRTFInfo(rtf, "dc:author", false); break; case Minor.IOperator: AddRTFInfo(rtf, "dc:operator", false); break; case Minor.IKeywords: AddRTFInfo(rtf, "dc:keywords", true); break; case Minor.IComment: AddRTFInfo(rtf, "dc:comment", false); break; case Minor.IVerscomm: SkipGroup(rtf); break; case Minor.IDoccomm: SkipGroup(rtf); break; } }