private static void CompareEqualTabularsTest(string s) { Tabular left = Tabular.Parse(s); Tabular right = Tabular.Parse(s.GetBytes()); Assert.IsTrue(left.Equals(right)); Assert.IsTrue(left == right); Assert.AreEqual(left.GetHashCode(), right.GetHashCode()); Assert.IsFalse(left != right); }
private static void CompareNonEqualTabularsTest(string a, string b) { Tabular left = Tabular.Parse(a); Tabular right = Tabular.Parse(b); Assert.IsFalse(left.Equals(right)); Assert.IsFalse(left == right); Assert.AreNotEqual(left.GetHashCode(), right.GetHashCode()); Assert.IsTrue(left != right); }
public void AddElement_DefaultConfiguration_ThrowIncompatibleNumberOfColumns() { var tabular = new Tabular(); var row = new TabularRow <ILatexElement>(); var emptyRow = new TabularRow <ILatexElement>(); row.AddElement(new SimpleText("New element")); tabular.AddElement(row); Assert.Throws <IncompatibleNumberOfColumnsException>(() => tabular.AddElement(emptyRow)); }
public void AddLaufen(Tabular t) { Tabular a = new Tabular(2); a.addRow(); a[0, 0] = GetText("Anfangen:"); a[0, 1] = GetText("____ Felder"); a.addRow(); a[1, 0] = GetText("Weiter:"); a[1, 1] = GetText("____ Felder"); AddEntry(t, GetText(@"\dLaufen\d"), a); }
public void AddEntry(Tabular t, DrawBox Titel, DrawBox Content) { int n = t.Rows; t.addRow(); t.addRow(); t.addRow(); t.setRowPen(n, Line); t.setRowPen(n + 1, HalbLine); t.setRowPen(n + 2, Line); t[n + 1, 0] = Titel; t[n + 2, 0] = Content.Geometry(2); }
public void AddAngriff(Tabular t) { Tabular a = new Tabular(2); a.addRow(); a[0, 0] = GetText("Angriffe:"); a[0, 1] = GetText("W20 + "); a.addRow(); a[1, 0] = GetText("2 bis ____:"); a.addRow(); a[2, 0] = GetText("____ bis 20:"); AddEntry(t, GetText(@"\dAngriff\d mit _____________________________________________"), a); }
public void CompareTabularsTest() { CompareEqualTabularsTest(""); CompareEqualTabularsTest("1 2 4| 5 4 7"); CompareEqualTabularsTest("xyz"); CompareEqualTabularsTest(@"1 2 3|4 5 6|7 hello\ world | 8"); Assert.AreEqual(Tabular.Parse("1 2 3 | 4 5 6 | 7 "), Tabular.Parse("1 2 3|4 5 6|7".GetBytes())); CompareNonEqualTabularsTest("a", "b"); CompareNonEqualTabularsTest("1 2 3|4 5 6|7 a 99", "1 2 3|4 5 6|7 a 99|1 1 1"); CompareNonEqualTabularsTest("1 2 3|4 5 6|7 a 99", "1 2 3|4 5 6|7 b 99"); }
public void AddElement_CustomConfiguration_ThrowIncompatibleNumberOfColumns() { var configuration = new List <Alligment>() { Alligment.Left, Alligment.Right }; var tabular = new Tabular(configuration); var row = new TabularRow <ILatexElement>(); row.AddElement(new SimpleText("New element")); Assert.Throws <IncompatibleNumberOfColumnsException>(() => tabular.AddElement(row)); }
public void GetLatex_TabularWithSingleRow_CorrectGenerateLatexCode() { var tabular = new Tabular(); var row = new TabularRow <ILatexElement>(); row.AddElement(new SimpleText("New element")); tabular.AddElement(row); AssertExtensions.CompareLatex(tabular.GetLatex(), @"\begin{tabular}{|c|} \hline New element \\ \hline \end{tabular}"); }
private static Tabular ParseTabularTest(string s, int rows, int columns) { Tabular tabular = Tabular.Parse(s); AssertPropertyValues(tabular); tabular = Tabular.Parse(s.GetBytes()); AssertPropertyValues(tabular); void AssertPropertyValues(Tabular tabular) { Assert.AreEqual(rows, tabular.Rows); Assert.AreEqual(columns, tabular.Columns); Assert.AreEqual(s, tabular.ToString()); } return(tabular); }
public void WriteQuarterTest() { var quarter = CreateQuarter(ticker, period, properties, descriptions); var tabular = new Tabular <Quarter>().Add(quarter); var fileName = "CsvFileWriterWriteQuarterTest.csv"; var fileInfo = new FileInfo(fileName); // at first, the file is not created Assert.IsFalse(fileInfo.Exists); using (var writer = new CsvFileTabularWriter <Quarter>(fileInfo.Create(), Encoding.UTF8)) { writer.Write(tabular); } // after writing records, check size fileInfo.Refresh(); Assert.IsTrue(fileInfo.Length > 0); fileInfo.Delete(); }
public void GetLatex_TabularWithMultipleColumn_DefaultConfiguration() { var tabular = new Tabular(); var row = new TabularRow <ILatexElement>(); row.AddElement(new SimpleText("New element v1")); row.AddElement(new SimpleText("New element v2")); tabular.AddElement(row); tabular.AddElement(row); AssertExtensions.CompareLatex(tabular.GetLatex(), @"\begin{tabular}{|c|c|} \hline New element v1 & New element v2 \\ \hline New element v1 & New element v2 \\ \hline \end{tabular}"); }
public void QuarterTest() { var quarter = CreateQuarter(ticker, period, properties, descriptions); var csvOutput = new Tabular <Quarter>(); var rows = csvOutput.Add(quarter).ToRows().ToArray(); var header = rows[0]; var firstDataRow = rows[1]; Assert.AreEqual("キー", header.Key); Assert.AreEqual("項目名", header.Name); Assert.AreEqual("単位", header.Unit); Assert.AreEqual(1, header.Values.Count); Assert.AreEqual(period.ToString(), header.Values[0]); Assert.AreEqual(key, firstDataRow.Key); Assert.AreEqual(label, firstDataRow.Name); Assert.AreEqual(unit, firstDataRow.Unit); Assert.AreEqual(1, firstDataRow.Values.Count); Assert.AreEqual(value, firstDataRow.Values[0]); }
public static string ToLatex <T>(this IEnumerable <T> collection) { var latexTable = new Table(); var latexTabular = new Tabular(); foreach (var element in collection) { var latexRow = new TabularRow <ILatexElement>(); foreach (var property in typeof(T).GetProperties()) { var latexElement = new SimpleText(property.GetValue(element).ToString()); latexRow.AddElement(latexElement); } latexTabular.AddElement(latexRow); } latexTable.AddElement(latexTabular); return(latexTable.GetLatex()); }
public void AddVerteidigung(Tabular t, CharakterMan cm) { Tabular a = new Tabular(2); a.addRow(); a[0, 0] = GetText("Akrobatik:"); a[0, 1] = GetText("W20 + " + cm.Statisch.Fertigkeiten.FinalWert.Value()[Universe.Fertigkeiten.GetElement("Akrobatik")] + " + Boni:____ = W20 + ____"); a.addRow(); a[1, 0] = GetText("RK:"); a[1, 1] = GetText("10 + Rüstung:____ * " + (cm.Statisch.Fertigkeiten.FinalWert.Value()[Universe.Fertigkeiten.GetElement("Rüstung")] / 20f).ToString("P0") + " + Boni:____ = ____" ); a.addRow(); a[2, 0] = GetText("FK:"); a[2, 1] = GetText("RK:____ + " + cm.Statisch.Fertigkeiten.FinalWert.Value()[Universe.Fertigkeiten.GetElement("Verstecken")] + " + Boni:____ = ____" ); AddEntry(t, GetText(@"\dVerteidigung\d"), a); }
public void ParseTabularTest() { ParseTabularTest("1 2 3|4 5 6|7 a 99", 3, 3); ParseTabularTest("1 3|4 5 6", 2, 3); Tabular tabular = ParseTabularTest(@"1 hello\ world 3|4 5 6", 2, 3); Assert.AreEqual(@"hello\ world", tabular.GetData(0, 1).ToString()); tabular = ParseTabularTest(@"abcd hello\ wor\|\|ld 3|4 6", 2, 3); Assert.AreEqual(@"hello\ wor\|\|ld", tabular.GetData(0, 1).ToString()); Assert.AreEqual(ReadOnlyMemory <char> .Empty, tabular.GetData(1, 1)); tabular = ParseTabularTest(@"1 2 3 4|4 5 6", 2, 4); Assert.AreEqual(ReadOnlyMemory <char> .Empty, tabular.GetData(1, 3)); tabular = Tabular.Parse(@"1 2 3 4|4 5 6 "); Assert.AreEqual(@"1 2 3 4|4 5 6 ", tabular.ToString()); tabular = ParseTabularTest(@"1 \\ 3|4 5 6", 2, 3); Assert.AreEqual(@"\\", tabular.GetData(0, 1).ToString()); tabular = Tabular.Parse("1 2 3 | 4 5 6 | 7 "); Assert.AreEqual("4", tabular.GetData(1, 0).ToString()); Assert.AreEqual("7", tabular.GetData(2, 0).ToString()); Assert.AreEqual("1 2 3|4 5 6|7", tabular.ToString()); tabular = Tabular.Parse(@"1 2 3 | 4 5 6 | 7 some\ long\ sentence"); Assert.AreEqual(3, tabular.Rows); Assert.AreEqual(3, tabular.Columns); Assert.AreEqual(@"some\ long\ sentence", tabular.GetData(2, 1).ToString()); ParseTabularTest(@"1 2 3 4\ 5\6", 1, 4); ParseTabularTest(@"xyz", 1, 1); tabular = Tabular.Parse(@"xyz\|\||"); Assert.AreEqual(1, tabular.Rows); Assert.AreEqual(1, tabular.Columns); Assert.AreEqual(@"xyz\|\|", tabular.ToString()); }
// If you want test worksheet, comment in // On GitHub Actions, we can't use Windows Office now // [TestMethod()] public void WorksheetTabularWriterTest() { var quarter = CreateQuarter(ticker, period, properties, descriptions); var tabular = new Tabular <Quarter>().Add(quarter); var excel = new Application(); excel.SheetsInNewWorkbook = 1; excel.Visible = true; Workbook workbook = excel.Workbooks.Add(); Worksheet worksheet = workbook.Worksheets.Add(); using (var writer = new WorksheetTabularWriter <Quarter>(worksheet)) { writer.Write(tabular); } Assert.AreEqual("キー", GetSheetCellValve(worksheet, 1, 1)); Assert.AreEqual("項目名", GetSheetCellValve(worksheet, 1, 2)); Assert.AreEqual("単位", GetSheetCellValve(worksheet, 1, 3)); worksheet.Delete(); workbook.Close(0); excel.Quit(); }
public OpenDynamic() { _tabularType = Tabular.Type("Table", "Table") .WithIndexColumn("ID", "UniqueID").TypedAs(SimpleType.Integer) .WithColumn("Name", "Name").TypedAs(SimpleType.String); _tabularValue = new TabularDataSupport(_tabularType); _outerTabularType = Tabular.Type("Outer table", "Outer table") .WithIndexColumn("ID", "Unique ID").TypedAs(SimpleType.Integer) .WithColumn("Value", "Tabular value").TypedAs( Tabular.Type("Inner table", "Inner table") .WithIndexColumn("ID", "Unique ID").TypedAs(SimpleType.Integer) .WithColumn("Name", "Name").TypedAs(SimpleType.String) .WithColumn("CompositeValue", "Composite Value").TypedAs( Composite.Type("Composite value", "Composite value") .WithItem("Item1", "Item 2").TypedAs(SimpleType.Integer) .WithItem("Item2", "Item 2").TypedAs(SimpleType.Boolean) .WithItem("Item3", "Item 3").TypedAs( Composite.Type("Nested", "Nested composite") .WithItem("NestedItem1", "NestedItem1").TypedAs(SimpleType.String) .WithItem("NestedItem2", "NestedItem2").TypedAs(SimpleType.Double)))); _nestedTabularValue = new TabularDataSupport(_outerTabularType); _beanInfoGetter = MBean.Info <OpenDynamic>("Sample dynamic MBean") .WithAttributes( MBean.WritableAttribute("Attribute", "Sample attribute").TypedAs(TabularType), MBean.WritableAttribute("NestedTableAttribute", "Nested Table Attribute").TypedAs(NestedTabularType) ) .WithOperations( MBean.MutatorOperation("DoSomething", "Does somthing").WithParameters( MBean.Parameter("First", "First parameter").TypedAs(SimpleType.Double), MBean.Parameter("Second", "Second parameter").TypedAs(TabularType) ).Returning(SimpleType.Void) ) .AndNothingElse(); }
public void GetLatex_TabularWithMultipleColumn_CustomConfiguration() { var configuration = new List <Alligment>() { Alligment.Left, Alligment.Right }; var tabular = new Tabular(configuration); var row = new TabularRow <ILatexElement>(); row.AddElement(new SimpleText("New element v1")); row.AddElement(new SimpleText("New element v2")); tabular.AddElement(row); tabular.AddElement(row); AssertExtensions.CompareLatex(tabular.GetLatex(), @"\begin{tabular}{|l|r|} \hline New element v1 & New element v2 \\ \hline New element v1 & New element v2 \\ \hline \end{tabular}"); }
public Tabular Tabelle(xFont font, int[] fert, int[] attribute) { ZVektor<Fertigkeit> GW = Charakter.GrundwerteFertigkeiten(); ZVektor<Attribut> GWA = Charakter.Charakter.Super.Attribute.Attribute; Tabular Fertigkeiten = new Tabular(3); Fertigkeiten.addRow(19); Fertigkeiten[0, 1] = new Word("GW ", Brushes.Black, font, 0, Pens.Black); Fertigkeiten[0, 2] = new Word("MW", Brushes.Black, font, 0, Pens.Black); int[] zeilen = new int[]{ 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30 }; for (int i = 0; i < fert.Length; i++) { Fertigkeit f = Universe.Fertigkeiten.Menge[fert[i]]; Fertigkeiten[zeilen[i], 0] = new Word(" " + f.SchreibName, Brushes.Black, font, 0, Pens.Black); Fertigkeiten[zeilen[i], 1] = new Word( GW[f] != 0 ? GW[f] + "" : "", Brushes.Black, font, 0, Pens.Black); Fertigkeiten[zeilen[i], 2] = new Word( Charakter.Statisch.Fertigkeiten.FinalWert.Value().Get(f) != 0 ? Charakter.Statisch.Fertigkeiten.FinalWert.Value().Get(f) + "" : "", Brushes.Black, font, 0, Pens.Black); } zeilen = new int[] { 1, 7, 13, 19, 25 }; for (int i = 0; i < attribute.Length; i++) { Attribut a = Universe.Attribute.Menge[attribute[i]]; Fertigkeiten[zeilen[i], 0] = new Word(a.SchreibName, Brushes.Black, font, 0, Pens.Black); Fertigkeiten[zeilen[i], 1] = new Word( GWA[a] != 0 ? GWA[a] + "" : "" , Brushes.Black, font, 0, Pens.Black); Fertigkeiten[zeilen[i], 2] = new Word( Charakter.Statisch.Attribute.FinalWert.Value().Get(a) != 0 ? Charakter.Statisch.Attribute.FinalWert.Value().Get(a) + "" : "", Brushes.Black, font, 0, Pens.Black); Fertigkeiten.setRowPen(zeilen[i], Pens.Black); if (zeilen[i] == 1) Fertigkeiten.setRowPen(zeilen[i] - 1, Pens.Black); else Fertigkeiten[zeilen[i] - 1, 0] += new Whitespace(0, 50, false); } return Fertigkeiten; }
public DrawBox Aktionen(CharakterMan cm) { Tabular t = new Tabular(1); t.columnPens[0] = t.columnPens[1] = base.Line; AddLaufen(t); AddAngriff(t); AddAngriff(t); AddVerteidigung(t, cm); AddZaubern(t); return t; }
public void AddZaubern(Tabular t) { AddEntry(t, GetText(@"\dZaubern\d"), GetText("|\n|\n|")); }
public void RenderTabularReport(string dateFrom, string dateTo) { Tabular loadTab = new Tabular((string)Session["id"], Convert.ToDateTime(dateFrom), Convert.ToDateTime(dateTo)); Context.Response.Write(js.Serialize(loadTab.RenderReport())); }
public override DrawBox MakeBogen(CharakterMan Charakter) { Charakter.Update(); float seite = 400; CString Haupt = new CString(); CString Oben = new CString(); CString Unten = new CString(); Haupt.add(new Word("Alsland-Personenakte", Schrift, Germanica, 0, Line)); Haupt.addAbsatz(); Haupt.add(Oben); Haupt.addAbsatz(); Haupt.add(Unten); Haupt.alignment = Oben.alignment = Unten.alignment = 0.5f; Tabular Splitter = new Tabular(2); CString Left = new CString(); CString Right = new CString(); Assistment.Texts.Text Name = base.GetName(Charakter); Oben.add(Splitter); Splitter.addRow(); Splitter[0, 0] = Left; Splitter[0, 1] = Right; Tabular Talente = GetTalente(Charakter, seite); //if (Talente.Rows > 0) // Talente.setRowPen(Talente.Rows - 1, Pens.Black); //Talente.addRow(); //Talente[Talente.Rows - 1, 0] = this.GetHarte(Charakter); Right.add(Talente.Geometry(5)); Right.alignment = 0.5f; Left.alignment = 0.5f; Left.addWhitespace(seite); Left.addAbsatz(); Left.add(Name.Geometry(30)); Left.addAbsatz(); #region Porträt try { Image img = Image.FromFile(Charakter.Charakter.Super.RP.Portrait); Left.add(new DynamicImageBox(img, 100, 100, 400, 400)); } catch (Exception) { } #endregion ab = 18; Title = new FontMeasurer("Calibri", 16); Normal = new FontMeasurer("Calibri", 14); Tabular t = new Tabular(3); t.addRow(2); t[0, 0] = GetAttributFertigkeitenTabelle(Charakter, Universe.Attribute.GetElement("Stärke")).Geometry(ab); t[0, 1] = GetAttributFertigkeitenTabelle(Charakter, Universe.Attribute.GetElement("Geschick")).Geometry(ab); t[0, 2] = GetAttributFertigkeitenTabelle(Charakter, Universe.Attribute.GetElement("Charisma")).Geometry(ab); t[1, 0] = GetAttributFertigkeitenTabelle(Charakter, Universe.Attribute.GetElement("Intelligenz")).Geometry(ab); t[1, 1] = GetAttributFertigkeitenTabelle(Charakter, Universe.Attribute.GetElement("Intuition")).Geometry(ab); t[1, 2] = GetAttributFertigkeitenTabelle(Charakter, Universe.Attribute.GetElement("Wahrnehmung")).Geometry(ab); Unten.add(t); Title = new FontMeasurer("Calibri", 12); Normal = new FontMeasurer("Calibri", 11); ab = 5; return Haupt.Geometry(rand); }
public Tabular Resistenzen() { Tabular t = new Tabular(4); t.addRow(5, Line); for (int i = 0; i <= t.Columns; i++) t.columnPens[i] = Line; t[1, 0] = GetText("Stich", Color.Gold); t[2, 0] = GetText("Hieb", Color.SandyBrown); t[3, 0] = GetText("Wucht", Color.LightGray); t[0, 1] = new Whitespace(100, 0, false); t[0, 3] = new Whitespace(100, 0, false); t[1, 2] = GetText("Feuer", Color.Red); t[2, 2] = GetText("Kälte", Color.LightBlue); t[3, 2] = GetText("Säure", Color.GreenYellow); t[4, 2] = GetText("Elektro", Color.Blue); return t; }
public override DrawBox MakeBogen(CharakterMan Charakter) { this.ab = 2; Charakter.Update(); float seite = 400; CString Haupt = new CString(); Tabular Splitter = new Tabular(2); CString Left = new CString(); CString Right = new CString(); Assistment.Texts.Text Name = GetName(Charakter, GetLP(Charakter)); Haupt.add(new Word("Alsland-Personenakte", Schrift, Germanica, 0, Line)); Haupt.addAbsatz(); Haupt.add(Splitter); Haupt.alignment = 0.5f; Splitter.addRow(); Splitter[0, 0] = Left; Splitter[0, 1] = Right; Right.addWhitespace(seite); Right.add(base.GetBemerkungen(Charakter.Charakter.Super.Bemerkungen).Geometry(5)); Right.alignment = 0.5f; Right.add(new Whitespace(300, 50, true)); Right.add(Resistenzen()); Left.alignment = 0.5f; Left.addWhitespace(seite); Left.addAbsatz(); Left.add(Name.Geometry(30)); Left.addAbsatz(); #region Porträt try { Image img = Image.FromFile(Charakter.Charakter.Super.RP.Portrait); Left.add(new DynamicImageBox(img, 100, 100, 400, 400)); Left.addAbsatz(); } catch (Exception) { } #endregion Tabular leftTab = new Tabular(2); leftTab.addRow(); CString AttRett = new CString(); AttRett.add(GetEigenschaftenTabelleMitModif("Attribute", Charakter, Charakter.Statisch.Attribute, (a => (int)Math.Floor((a - 10f) / 2)), Universe.Attribute.Where(x => !x.Hidden)).Geometry(5)); AttRett.add(GetEigenschaftenTabelle("Rettungswürfe", Charakter, Charakter.Statisch.Fertigkeiten, Universe.Fertigkeiten.Menge.Where(x => x.Rettungswurf)).Geometry(5)); leftTab[0, 0] = AttRett; leftTab[0, 1] = GetEigenschaftenTabelle("Fertigkeiten", Charakter, Charakter.Statisch.Fertigkeiten, Universe.Fertigkeiten.Menge.Where(x => !x.Rettungswurf)).Geometry(5); Left.add(leftTab); Left.add(new Whitespace(300, 10, true)); Left.add(Aktionen(Charakter)); return Haupt.Geometry(rand); }
public Tabular GetTabelle(CharakterMan Charakter) { Abbildung<Attribut, int> w0 = Charakter.Charakter.Super.Attribute.Attribute; Abbildung<Attribut, int> w = Charakter.Statisch.Attribute.FinalWert.Value(); Abbildung<Fertigkeit, int> f0 = Charakter.Charakter.Super.GetGrundwerteFertigkeiten(Charakter.Stufe); Tabular t = new Tabular(9); bool Master = Charakter.Stufe > Universe.CharakterDaten.StufenBachelor; IEnumerable<Fertigkeit> z = Charakter.Charakter.Super.Fertigkeiten.GetGelernteFertigkeiten(Master, Universe.CharakterDaten); Pen p = Pens.Black; int n = 0; int l = 0; int m = 0; Fertigkeit[][] fert = new Fertigkeit[3][]; Attribut[] att = Universe.Attribute.GetElemente("Stärke", "Geschick", "Charisma"); fert.CountMap(i => { IEnumerable<Fertigkeit> y = z.Where(x => x.Attribut == att[i]); n = Math.Max(n, y.Count()); return y.ToArray(); }); t.addRow(n + 1, p); for (int c = 0; c < 3; c++) { t[m, c * 3 + 0] = att[c].SchreibName; t[m, c * 3 + 1] = w0[att[c]] + ""; t[m, c * 3 + 2] = w[att[c]] + ""; } for (m = 1; m < n + 1; m++) for (int c = 0; c < 3; c++) if (m < fert[c].Length) { Fertigkeit f = fert[c][m]; t[m, c * 3 + 0] = f.SchreibName; t[m, c * 3 + 1] = f0[f] + ""; t[m, c * 3 + 2] = Charakter.FertigkeitsWert(f) + ""; } m = n + 1; att = Universe.Attribute.GetElemente("Intelligenz", "Intuition", "Wahrnehmung"); fert.CountMap(i => { IEnumerable<Fertigkeit> y = z.Where(x => x.Attribut == att[i]); l = Math.Max(l, y.Count()); return y.ToArray(); }); t.addRow(l + 1, p); for (int c = 0; c < 3; c++) { t[m, c * 3 + 0] = att[c].SchreibName; t[m, c * 3 + 1] = w[att[c]] + ""; t[m, c * 3 + 2] = w0[att[c]] + ""; } for (m = n + 2; m < n + l + 2; m++) for (int c = 0; c < 3; c++) if (m < fert[c].Length) { Fertigkeit f = fert[c].ElementAt(m); t[m, c * 3 + 0] = f.SchreibName; t[m, c * 3 + 1] = Charakter.FertigkeitsWert(f) + ""; t[m, c * 3 + 2] = f0[f] + ""; } return t; }