public void CalcEntryIndexTest() { var testSubject = new NoFuture.Timeline.Rule() { EndValue = 750, StartValue = 950 }; var testResult = testSubject.CalcEntryIndex(new Entry() {StartValue = 945, EndValue = 945}); Assert.AreNotEqual(-1, testResult.Item1); Assert.AreNotEqual(-1, testResult.Item2); System.Diagnostics.Debug.WriteLine("Start Index '{0}', End Index '{1}'", testResult.Item1, testResult.Item2); }
public void BlockToStringTest() { var testRuler = new NoFuture.Timeline.Rule() { EndValue = 20, StartValue = 90 }; var testSubjectB = new NoFuture.Timeline.Block() { EmptyChar = '.', EndValue = 26, Ruler = testRuler, StartValue = 80, Title = "Roman Republic" }; var testResult = testSubjectB.ToString(); Assert.IsNotNull(testResult); Assert.AreNotEqual(0, testResult); System.Diagnostics.Debug.WriteLine(testResult); }
public void CalcEntryIndexTestOob() { var testRuler = new Rule() { EndValue = 575, StartValue = 775 }; var testEntry = new Entry() { Text = "XXII Dyn. 935-725", StartValue = 935, EndValue = 725, Ruler = testRuler, Location = PrintLocation.Left }; System.Diagnostics.Debug.WriteLine(testEntry); System.Diagnostics.Debug.WriteLine(testEntry.CalcHeight()); var testResult = testRuler.CalcEntryIndex(testEntry); Assert.AreNotEqual(-1, testResult.Item1); Assert.AreNotEqual(-1, testResult.Item2); System.Diagnostics.Debug.WriteLine("Start Index '{0}', End Index '{1}'", testResult.Item1, testResult.Item2); }
public void MergeToTextCanvasTest() { var testRuler = new NoFuture.Timeline.Rule() { EndValue = 25, StartValue = 90 }; var testSubjectA = new NoFuture.Timeline.Entry { Ruler = testRuler, StartValue = 73, EndValue = 71, Text = "Slave revolt led by Spartacus" }; var testSubjectB = new NoFuture.Timeline.Entry { Ruler = testRuler, StartValue = 74, EndValue = 27, Text = "Collapse of Republic", Location = PrintLocation.Left }; var testResult = testSubjectA.ToTextCanvas(testRuler).Merge(testSubjectB.ToTextCanvas(testRuler), testRuler); Assert.IsNotNull(testResult); System.Diagnostics.Debug.WriteLine(testResult); }
public FastPlate(string plateTitle, int? dfWidth, params string[] blockNames) { if (dfWidth != null) Config.Numerics.DefaultWidth = dfWidth.Value; var ruler = new Rule {StartValue = 1, EndValue = 16, RuleLineSpacing = 3}; if (blockNames == null || blockNames.Length <= 0) throw new ArgumentNullException(nameof(blockNames)); Name = string.IsNullOrWhiteSpace(plateTitle) ? "Sequence Diagram" : plateTitle; Ruler = ruler; var c = 0; foreach (var blkNm in blockNames) { var blk = new Block { Ruler = ruler, Title = blkNm }; _blocks.Add(blk); _blockIdxName.Add(c, blkNm); c += 1; } }
public void RulePrintTestLowToHigh() { var testSubject = new NoFuture.Timeline.Rule() { EndValue = 25, StartValue = 90 }; var testResult = testSubject.ToString(); Assert.IsNotNull(testResult); System.Diagnostics.Debug.WriteLine(testResult); }
public void RuleGetIndexRuleTest() { var testSubject = new NoFuture.Timeline.Rule() { EndValue = 25, StartValue = 90 }; var testResult = testSubject.GetIndexRule(); Assert.IsNotNull(testResult); Assert.AreNotEqual(0,testResult.Count); var c = 0; foreach (var idx in testResult) { System.Diagnostics.Debug.WriteLine("Index '{0}', Value '{1}'",c, idx); c += 1; } }
public void PrintEntriesToCanvasWithInnerBlockTest() { var rule = new Rule() { StartValue = 2100, EndValue = 1500 }; var mesopotamia = new Block() { Ruler = rule, Title = "Mesopotamia" }; mesopotamia.AddEntry(new Entry() { StartValue = 2060, EndValue = 1950, Text = "Ur III" }); var assyria = new Block() { Ruler = rule, Title = "Assyria", StartValue = 1950 }; assyria.AddEntry(new Entry() { StartValue = 1900, Text = "Cappadocian Colonies" }); assyria.AddEntry(new Entry() { StartValue = 1750, Text = "Shamshi-Adad I" }); var mari = new Block() { Ruler = rule, Title = "Mari", StartValue = 1950, EndValue = 1700, Width = 16 }; mari.AddEntry(new Entry() { StartValue = 1750, Text = "The 'Mari Age'" }); var isin = new Block() { Ruler = rule, Title = "Isin", StartValue = 1950, EndValue = 1750, Width = 8 }; var larsa = new Block() { Ruler = rule, Title = "Larsa", StartValue = 1950, EndValue = 1700, Width = 16 }; larsa.AddEntry(new Entry() { StartValue = 1758, Text = "Rim-Sin I" }); var babylon = new Block() { Ruler = rule, Title = "Babylon", StartValue = 1830, EndValue = 1550, Width = 20 }; babylon.AddEntry(new Entry() { StartValue = 1700, Text = "Hammurabi" }); babylon.AddEntry(new Entry() { StartValue = 1630, Text = "Kassite Dyn." }); mesopotamia.AddInnerBlock(assyria); mesopotamia.AddInnerBlock(mari); mesopotamia.AddInnerBlock(isin); mesopotamia.AddInnerBlock(larsa); mesopotamia.AddInnerBlock(babylon); TextCanvas myInnerBlockCanvas = null; if (mesopotamia._innerBlocks.Count > 0) { myInnerBlockCanvas = mesopotamia._innerBlocks[0].PrintEntriesOnCanvas(); System.Diagnostics.Debug.WriteLine(myInnerBlockCanvas); for (var i = 1; i < mesopotamia._innerBlocks.Count; i++) { System.Diagnostics.Debug.WriteLine(myInnerBlockCanvas); myInnerBlockCanvas = myInnerBlockCanvas.Concat(mesopotamia._innerBlocks[i].PrintEntriesOnCanvas(), rule); } } System.Diagnostics.Debug.WriteLine(myInnerBlockCanvas); }
public void PlateSplitBlockTest() { var rule = new Rule() {StartValue = 2050, EndValue = 1500}; var mesopotamia = new Block() {Ruler = rule, Title = "Mesopotamia"}; mesopotamia.AddEntry(new Entry(){StartValue = 2060, EndValue = 1950, Text = "Ur III: ca. 2060-1950"}); var assyria = new Block(){Ruler = rule, StartValue = 1950, EndValue = 1550, Title = "Assyria"}; var babylon = new Block {Ruler = rule, StartValue = 1830, EndValue = 1530, Title = "I Babylon"}; var kassite = new Block {Ruler = rule, StartValue = 1650, EndValue = 1500, Title = "Kassite Dyn."}; mesopotamia.AddInnerBlock(assyria); mesopotamia.AddInnerBlock(babylon); mesopotamia.AddInnerBlock(kassite); mesopotamia.AddArrow(new Arrow(babylon,assyria) {StartValue = 1728,Text = "Hammurabi"}); var hittites = new Block {Ruler = rule, Title = "Hittites"}; var palestine = new Block() {Ruler = rule, Title = "Palestine"}; var egypt = new Block() {Ruler = rule, Title = "Egypt"}; var plate = new Plate() {Name = "Near East 2050-1500", Ruler = rule}; plate.AddBlock(mesopotamia); plate.AddBlock(hittites); plate.AddBlock(palestine); plate.AddBlock(egypt); var testResult = plate.ToString(); System.Diagnostics.Debug.WriteLine(testResult); }
public TextCanvas ComposeArrow(Rule ruler, TextCanvas tc) { if (ruler == null) throw new NoRuleSetException(); var arrowIdx = ruler.CalcEntryIndex(this); //find the line on the text canvas var ti = tc.Items.FirstOrDefault(t => t.Index == arrowIdx.Item1); if (ti == null) return tc; //scope in on the ranges for the located line var fromTr = ti.Ranges.FirstOrDefault(tr => tr.Id == FromBlock.Id); var toTr = ti.Ranges.FirstOrDefault(tr => tr.Id == ToBlock.Id); if (fromTr == null || toTr == null) return tc; var arrowText = new StringBuilder(); var arrowDirection = DetermineArrowDirection(fromTr.Id, toTr.Id, ti.Ranges); if (arrowDirection == PrintLocation.Left) { var leftTr = fromTr; var rightTr = toTr; var aPriorLen = String.IsNullOrWhiteSpace(ExcludedRangeId) ? GetLeftAPriorLen(leftTr.Id, ti.Ranges) : GetLeftAPriorLen(leftTr.Id, ti.Ranges, ExcludedRangeId); var betwixtLen = GetRangeLenBetwixt(leftTr.Id, rightTr.Id, ti.Ranges); arrowText = ComposeToRightArrow(betwixtLen, aPriorLen, leftTr.Length, Text, rightTr.Length); } else if (arrowDirection == PrintLocation.Right) { var leftTr = toTr; var rightTr = fromTr; var aPriorLen = String.IsNullOrWhiteSpace(ExcludedRangeId) ? GetLeftAPriorLen(leftTr.Id, ti.Ranges) : GetLeftAPriorLen(leftTr.Id, ti.Ranges, ExcludedRangeId); var betwixtLen = GetRangeLenBetwixt(leftTr.Id, rightTr.Id, ti.Ranges); arrowText = ComposeToLeftArrow(betwixtLen, aPriorLen, leftTr.Length, Text); } tc.Items.First(t => t.Index == arrowIdx.Item1).Text = Etc.MergeString(arrowText.ToString(), new string(tc.Items.First(t => t.Index == arrowIdx.Item1).Text.ToArray())).ToCharArray().ToList(); return tc; }
public Plate CE1700to1788() { var rule = new Rule {StartValue = 1700, EndValue = 1790, RuleLineSpacing = 7}; var amer = new Block {Ruler = rule, Title = "Americas"}; var col = new Block {StartValue = 1703, EndValue = 1783, Title = "Colonies", Ruler = rule}; col.AddEntry(1771, "Boston Massacre(1770)", PrintLocation.Left); col.AddEntry(1703, "Yale College (1700)"); col.AddEntry(1727, "[Bering] Bering straight(1728)"); col.AddEntry(1739, "Stono Rebellion(1739)"); col.AddEntry(1730, "Baltimore MA(1730)"); col.AddEntry(1764, "Mason Dixon survey(1764)"); col.AddEntry(1769, "[D.Boone]-Kentucky(1769)"); col.AddEntry(1773, "Boston Tea Party(1773)"); col.AddEntry(1704, 1713, "Queen Anne's War"); col.AddEntry(1754, 1763, "French Indian War"); col.AddEntry(1775, 1783, "American Rev.(1775-1783)", PrintLocation.Left); col.AddEntry(1777, "NY occupied(1776)"); col.AddEntry(1778, "Savannah occupied(1778)"); col.AddEntry(1780, "Charleston occupied(1780)"); var que = new Block {StartValue = 1703, EndValue = 1763, Title = "New France", Ruler = rule, Width = 22}; que.AddEntry(1703, "Fr.settle Mobile AL"); que.AddEntry(1718, "New Orleans LA(1718)"); var usa = new Block {StartValue = 1775, Title = "United States", Ruler = rule}; usa.AddEntry(1776, "Lafayette in PA(1777)"); usa.AddEntry(1781, "Cornwallis surrender(1781)"); usa.AddEntry(1783, "Peace of Paris(1783)"); usa.AddEntry(1787, "U.S.Constitution(1787)"); amer.AddInnerBlock(col); amer.AddInnerBlock(usa); amer.AddInnerBlock(que); amer.AddArrow(new Arrow(que, col) {StartValue = 1706, ArrowTail = "."}); amer.AddArrow(new Arrow(col, que) {StartValue = 1755, Text = "B. of the Monongahela"}); amer.AddArrow(new Arrow(que, col) {StartValue = 1757, Text = "massacre @ F.William Henry"}); var engd = new Block {Ruler = rule, Title = "United Kingdom"}; engd.AddEntry(1704, "[Anne 1702-1714]", PrintLocation.Left); engd.AddEntry(1720, "[George I 1714-1727]", PrintLocation.Left); engd.AddEntry(1727, "[George II 1727-1760]", PrintLocation.Left); engd.AddEntry(1730, "first railroad(1730)"); engd.AddEntry(1739, "Wesley/Whitefield[Methodism]"); engd.AddEntry(1745, "Jacobite Rebellion(1745)"); engd.AddEntry(1760, "[George III 1760-1820]", PrintLocation.Left); engd.AddEntry(1766, "H.Cavendish[hydrogen](1766)", PrintLocation.Right); engd.AddEntry(1776, "'Wealth of Nations' A.Smith(1776)", PrintLocation.Right); engd.AddEntry(1777, " 'Rise & Fall..Roman Empire'Gibbon(1777)", PrintLocation.Right); engd.AddEntry(1781, "1st Sunday-school(R.Raikes)(1781)", PrintLocation.Right); engd.AddEntry(1769, "J.Watt[steam engine](1769)", PrintLocation.Right); engd.AddEntry(1764, "J.Hargreaves[spinning jenny](1764)", PrintLocation.Right); engd.AddEntry(1782, "Lord North resigns as PM(1782)"); engd.AddEntry(1787, "Australia penal settlement(1788)"); engd.AddEntry(1789, "[Cook]Hawaiian Islands(1788)"); engd.AddEntry(1702, 1714, "Stuart(restored)", PrintLocation.Left); engd.AddEntry(1715, 1800, "Hanover", PrintLocation.Left); var fr = new Block {Ruler = rule, Title = "France"}; fr.AddEntry(1601, "[Louis XIV 1643-1715]", PrintLocation.Left); fr.AddEntry(1715, "[Louis XV 1715-1774]", PrintLocation.Left); fr.AddEntry(1774, "[Louis XVI 1774-1792]", PrintLocation.Left); fr.AddEntry(1720, "France bankrupt(1721)"); fr.AddEntry(1748, "'The Spirit of Laws' Montesquieu(1748)", PrintLocation.Right); fr.AddEntry(1761, "'Social Contract' Rousseau(1761)", PrintLocation.Right); fr.AddEntry(1756, "Diplomatic Revolution(1756)(c.)"); fr.AddEntry(1783, "1st hot-air ballon(1783)", PrintLocation.Right); fr.AddEntry(1702, 1790, "Capetian[Bourbon]", PrintLocation.Left); fr.AddEntry(1701, 1714, "War of Spanish Succ.(1701-1714)"); var de = new Block {Ruler = rule, Title = "Prussia"}; de.AddEntry(1702, "[Fredrick I 1701-1713]", PrintLocation.Left); de.AddEntry(1713, "[Fredrick William I 1713-1740]", PrintLocation.Left); de.AddEntry(1740, "[Fredrick the Great 1740-1786]", PrintLocation.Left); de.AddEntry(1786, "[Fredrick William II 1786-1797]", PrintLocation.Left); de.AddEntry(1781, "'Critique of Pure Reason' E.Kant(1781)", PrintLocation.Right); de.AddEntry(1715, "Fahrenheit[thermometer](1714)"); de.AddEntry(1730, "'Toccata Fugue' Bach(~1730s)"); de.AddEntry(1754, 1763, "Seven's Year War"); var aus = new Block {Ruler = rule, Title = "Austrian Empire"}; aus.AddEntry(1701, "[Leopold I 1640-1705]", PrintLocation.Left); aus.AddEntry(1705, "[Joseph I 1705-1711]", PrintLocation.Left); aus.AddEntry(1711, "[Charles III 1711-1740]", PrintLocation.Left); aus.AddEntry(1739, "[Maria Theresa 1740-1780]", PrintLocation.Left); aus.AddEntry(1780, "[Joseph II 1780-1790]", PrintLocation.Left); aus.AddEntry(1783, "Mozart in Vienna", PrintLocation.Right); aus.AddEntry(1741, 1748, "War of Austrian Succ.(1740-1748)"); var ott = new Block {Ruler = rule, Title = "Ottoman Empire"}; ott.AddEntry(1710, "[Ahmed III 1703-1730]", PrintLocation.Left); ott.AddEntry(1730, "[Mahmud I 1730-1754]", PrintLocation.Left); ott.AddEntry(1754, "[Osman III 1754-1757]", PrintLocation.Left); ott.AddEntry(1757, "[Mustafa III 1757-1774]", PrintLocation.Left); ott.AddEntry(1774, "[Abdulhamid I 1774-1789]", PrintLocation.Left); ott.AddEntry(1789, "[Selim III 1789-1807]", PrintLocation.Left); var rus = new Block {Ruler = rule, Title = "Imperial Russia", StartValue = 1721}; rus.AddEntry(1725, "[Peter the Great 1695-1725]"); rus.AddEntry(1727, 1760, "[internal intrigue]"); rus.AddEntry(1762, "[Catherine theGreat 1762-1796]"); rus.AddEntry(1783, "(+)Crimea(1783)"); rus.AddEntry(1768, 1774, "1st Russio-Turkish War", PrintLocation.Right); var plate = new Plate {Ruler = rule, Name = "Early Modern Age(2)"}; plate.AddBlock(amer); plate.AddBlock(engd); plate.AddBlock(fr); plate.AddBlock(de); plate.AddBlock(aus); plate.AddBlock(ott); plate.AddBlock(rus); plate.AddArrow(new Arrow(aus, fr) {StartValue = 1704, Text = "B. of Blenheim(1704)"}); plate.AddArrow(new Arrow(fr, de) {StartValue = 1706, Text = "B. of Ramilies(1706)"}); plate.AddArrow(new Arrow(fr, de) {StartValue = 1708, Text = "B. of Oudenarde(1708)"}); plate.AddArrow(new Arrow(engd, fr) {StartValue = 1709, Text = "B. of Malpaquet(1709)"}); plate.AddArrow(new Arrow(aus, ott) {StartValue = 1717, Text = "B. of Belgrad(1717)"}); plate.AddArrow(new Arrow(de, aus) {StartValue = 1740, Text = "invasion of Silesia(1740)"}); plate.AddArrow(new Arrow(engd, fr) {StartValue = 1743, Text = "B. of Dettingen(1743)(e.)"}); plate.AddArrow(new Arrow(de, aus) {StartValue = 1757, Text = "B. of Prague(1757)"}); plate.AddArrow(new Arrow(rus, ott) {StartValue = 1770, Text = "B.of Chesma & Kagus(1770)"}); plate.AddArrow(new Arrow(engd, aus) { StartValue = 1714, Text = "Peace of Ulrecht(1714)(a.)", ArrowTail = "[..........", FromLeftToRightArrowHead = "......]", }); plate.AddArrow(new Arrow(aus, de) { StartValue = 1748, Text = "Treaty of Aix-la-Chapelle(1748)", ArrowTail = "........]", FromRightToLeftArrowHead = "[.....", }); plate.AddArrow(new Arrow(engd, fr) { StartValue = 1763, Text = "Treaty of Paris(1763)(b.)", ArrowTail = "[..........", FromLeftToRightArrowHead = "......]", }); plate.AddArrow(new Arrow(de, aus) { StartValue = 1788, Text = "War of Bavarian Succ.(1778\\79)", ArrowTail = "[.........", FromLeftToRightArrowHead = "]", }); plate.AddArrow(new Arrow(engd, amer) { StartValue = 1771, Text = "B. of the Alamance(1771)", FromRightToLeftArrowHead = "<..............................." }); plate.AddArrow(new Arrow(engd, amer) { StartValue = 1775, Text = "B. of Lexington(1775)", FromRightToLeftArrowHead = "<........................", ArrowTail = "." }); plate.AddArrow(new Arrow(engd, amer) { StartValue = 1777, Text = "B. at Trenton(1777)", FromRightToLeftArrowHead = "<........................", ArrowTail = "." }); plate.Notes.Add("(a.)marks the end of Wars of Spanish Succession"); plate.Notes.Add("(b.)British supremacy in Canada and India"); plate.Notes.Add("(c.)England allies with Prussia - Austria with France."); plate.Notes.Add("(d.)start of Wars of Austrian Succ."); plate.Notes.Add("(e.)fought on German soil"); return plate; }
public Plate CE1788to1865() { var rule = new Rule {StartValue = 1785, EndValue = 1867, RuleLineSpacing = 7}; var usa = new Block {Ruler = rule, Title = "United States"}; usa.AddEntry(1787, "+DE,PA,NJ(1787)", PrintLocation.Right); usa.AddEntry(1788, "+GA,CT,MA,MD,SC,NH,VA,NY(1788)", PrintLocation.Right); usa.AddEntry(1789, "[Washington 1789-1797]", PrintLocation.Left); usa.AddEntry(1789, "+NC(1789)", PrintLocation.Right); usa.AddEntry(1790, "+RI(1790)", PrintLocation.Right); usa.AddEntry(1791, "+VT(1791)", PrintLocation.Right); usa.AddEntry(1792, "+KY(1792)", PrintLocation.Right); usa.AddEntry(1793, "E.Whitney[cottin gin](1793)(d.)"); usa.AddEntry(1796, "+TN(1796)", PrintLocation.Right); usa.AddEntry(1797, "[John Adams -1801]", PrintLocation.Left); usa.AddEntry(1801, "[T.Jefferson -1809]", PrintLocation.Left); usa.AddEntry(1802, "West Point founded(1802)"); usa.AddEntry(1803, "Louisiana Purchase(1803)"); usa.AddEntry(1803, "+OH(1803)", PrintLocation.Right); usa.AddEntry(1804, "Lewis & Clark Expedition(1804)"); usa.AddEntry(1809, "[James Madison -1817]", PrintLocation.Left); usa.AddEntry(1811, "B.of Tippecanoe(1811)(h.)"); usa.AddEntry(1812, "+LA(1812)", PrintLocation.Right); usa.AddEntry(1815, "failed Canadian conquest"); usa.AddEntry(1816, "+IN(1816)", PrintLocation.Right); usa.AddEntry(1816, "First Seminole War(1816-1819)"); usa.AddEntry(1817, "[James Monroe -1825]", PrintLocation.Left); usa.AddEntry(1817, "+MS(1817)", PrintLocation.Right); usa.AddEntry(1818, "+IL(1818)", PrintLocation.Right); usa.AddEntry(1819, "+AL(1819)", PrintLocation.Right); usa.AddEntry(1820, "+ME(1820)", PrintLocation.Right); usa.AddEntry(1821, "+MO(1821)", PrintLocation.Right); usa.AddEntry(1825, "[John Quincy Adams -1829]", PrintLocation.Left); usa.AddEntry(1826, "'Last of the Mohicans'J.F.Cooper(1826)"); usa.AddEntry(1829, "[Andrew Jackson -1837]", PrintLocation.Left); usa.AddEntry(1835, "Second Seminole War(1835-1842)"); usa.AddEntry(1836, "+AR(1836)", PrintLocation.Right); usa.AddEntry(1837, "[Martin Van Buren -1841]", PrintLocation.Left); usa.AddEntry(1839, "Morse[telegraph](1837)"); usa.AddEntry(1837, "+MI(1837)", PrintLocation.Right); usa.AddEntry(1841, "[William H Harrison -1841]", PrintLocation.Left); usa.AddEntry(1842, "[John Tyler -1845]", PrintLocation.Left); usa.AddEntry(1845, "[James K Polk -1849]", PrintLocation.Left); usa.AddEntry(1845, "+FL,TX(1845)", PrintLocation.Right); usa.AddEntry(1846, "+IA(1846)", PrintLocation.Right); usa.AddEntry(1844, "W.Morton[anesthesia](1846)"); usa.AddEntry(1847, "U.S.-Mexican War(1846-1848)"); usa.AddEntry(1848, "+WI(1848)", PrintLocation.Right); usa.AddEntry(1849, "[Zachary Taylor -1850]", PrintLocation.Left); usa.AddEntry(1849, "'The Scarlet Letter'N.Hawthorne'", PrintLocation.Right); usa.AddEntry(1850, "[Millard Fillmore -1853]", PrintLocation.Left); usa.AddEntry(1850, "+CA(1850)", PrintLocation.Right); usa.AddEntry(1851, "'Moby-Dick'H.Melville(1851)", PrintLocation.Left); usa.AddEntry(1851, "'Uncle Tom's Cabin'H.B.Stowe(1852)", PrintLocation.Right); usa.AddEntry(1852, "Perry Expedition to Japan(1852-54)"); usa.AddEntry(1853, "[Franklin Pierce -1857]", PrintLocation.Left); usa.AddEntry(1855, "Third Seminole War(1855-1858)"); usa.AddEntry(1857, "[James Buchanan -1861]", PrintLocation.Left); usa.AddEntry(1858, "+MN(1858)", PrintLocation.Right); usa.AddEntry(1859, "+OR(1859)", PrintLocation.Right); usa.AddEntry(1860, "[Abraham Lincoln -1865]", PrintLocation.Left); usa.AddEntry(1861, "+KS(1861)", PrintLocation.Right); usa.AddEntry(1861, "Ft.Sumter fired on(e.)", PrintLocation.Left); usa.AddEntry(1863, "Lee's invasion of PA,", PrintLocation.Left); usa.AddEntry(1863, "Siege of Vicksburg, +WV(1863)", PrintLocation.Right); usa.AddEntry(1864, "Siege of Petersburg,", PrintLocation.Left); usa.AddEntry(1864, "Atlanta falls, +NV(1864)", PrintLocation.Right); usa.AddEntry(1865, "Richmond falls,", PrintLocation.Left); usa.AddEntry(1865, "surrender @ Appomattox(1865)(f.)", PrintLocation.Right); usa.AddEntry(1866, "Lincoln assassinated(1865)"); usa.AddEntry(new ScienceAdvEntry("rotary press", "R.M.Hoe") {StartValue = 1843}); var engd = new Block {Ruler = rule, Title = "United Kingdom"}; engd.AddEntry(1798, "Jenner[vaccination](1798)", PrintLocation.Left); engd.AddEntry(1800, "Volta[battery](1800)"); engd.AddEntry(1801, "[William Pitt -1801\\-1806]", PrintLocation.Left); engd.AddEntry(1803, "Dalton[atomic theory](1803)"); engd.AddEntry(1804, "[Henry Addington -1804]", PrintLocation.Left); engd.AddEntry(1806, "[Baron Grenville -1807]", PrintLocation.Left); engd.AddEntry(1807, "[W. Cavendish-Bentinck -1809]", PrintLocation.Left); engd.AddEntry(1809, "[Spencer Perceval -1812]", PrintLocation.Left); engd.AddEntry(1812, "[R.B Jenkinson -1827]", PrintLocation.Left); engd.AddEntry(1813, "'Pride & Prejudice'J.Austen(1813)", PrintLocation.Right); engd.AddEntry(1826, "[G. Canning -1827]", PrintLocation.Left); engd.AddEntry(1827, "[Viscount Goderich -1828]", PrintLocation.Left); engd.AddEntry(1828, "[Arthur Wellesley -1830]", PrintLocation.Left); engd.AddEntry(1830, "[Charles Grey -1834]", PrintLocation.Left); engd.AddEntry(1831, "Faraday[law of induction](1831)"); engd.AddEntry(1836, "[R.Peel & W.Lamb(a.) -1846]", PrintLocation.Left); engd.AddEntry(1843, "J.P.Joule[1st law thermodyn](1843)"); engd.AddEntry(1844, "Franklin's lost expedition(1845)"); engd.AddEntry(1846, "[John Russel -1852]", PrintLocation.Left); engd.AddEntry(1847, "Kelvin[absolute zero](1848)"); engd.AddEntry(1848, "'Communist Manifesto'(1848)"); engd.AddEntry(1855, "[G. Hamilton-Gordon -1852-55]", PrintLocation.Left); engd.AddEntry(1858, "[E. Smith-Stanley -1852\\1858-59]", PrintLocation.Left); engd.AddEntry(1860, "[H. John Temple 1855-58\\59-65]", PrintLocation.Left); engd.AddEntry(1833, "'Principles of Geology' Lyell(1833)", PrintLocation.Right); engd.AddEntry(1834, "Abolition Act(1833)", PrintLocation.Right); engd.AddEntry(1838, "'Oliver Twist'Dickens(1838)"); engd.AddEntry(1859, "'Origin of Species' Darwin(1859)", PrintLocation.Right); engd.AddEntry(1861, "'Great Expectations'Dickens(1861)"); engd.AddEntry(new ScienceAdvEntry("electromag.", "Maxwell") {StartValue = 1864}); engd.AddEntry(1865, "First Subway(1864)"); engd.AddEntry(1840, 1860, "Industrial Revolution", PrintLocation.Right); engd.AddEntry(1839, 1866, "Queen Victoria (1837-1901)", PrintLocation.Left); var fr = new Block {Ruler = rule, Title = "France"}; fr.AddEntry(1789, "Estates-General meets(1789)(b.)", PrintLocation.Left); fr.AddEntry(1791, "Storming of the Bastille(1789)", PrintLocation.Left); fr.AddEntry(1792, "Louis XVI executed(1793)", PrintLocation.Left); fr.AddEntry(1793, "Reign of Terror(1793\\94)", PrintLocation.Left); fr.AddEntry(1794, "Robespierre executed(1794)", PrintLocation.Left); fr.AddEntry(1795, "Napolean quells insurrection(1795)", PrintLocation.Left); fr.AddEntry(1796, "Cuvier[extinction](1796)"); fr.AddEntry(1824, "Carnot[heat engine](1824)"); fr.AddEntry(1833, "A.Payen[enzymes](1833)"); fr.AddEntry(1845, "'Count of Monte Cristo'A.Dumas(1845)"); fr.AddEntry(1848, "revolution of 1848 & 2nd Republic "); fr.AddEntry(1861, "Pasteur[germ theory](1861)"); fr.AddEntry(1863, "'Les Miserables'V.Hugo(1862)"); fr.AddEntry(1787, 1792, "French Revolution", PrintLocation.Right); fr.AddEntry(1793, 1804, "1st Republic", PrintLocation.Right); fr.AddEntry(1804, 1814, "Napolean(French Empire)"); fr.AddEntry(1815, 1830, "Bourbon Restoration", PrintLocation.Right); fr.AddEntry(1831, 1848, "July Monarchy", PrintLocation.Right); fr.AddEntry(1852, 1866, "2nd French Empire", PrintLocation.Right); var de = new Block {Ruler = rule, Title = "Prussia"}; de.AddEntry(1848, "revolution of 1848"); de.AddEntry(1789, "[Frederick William II 1786-1797]", PrintLocation.Left); de.AddEntry(1795, "[Frederick William III 1797-1840]", PrintLocation.Left); de.AddEntry(1809, "'Faust'Goethe(1808)"); de.AddEntry(1820, "H.C.Orsted[electromagnetism](1820)"); de.AddEntry(1827, "Ohm[Ohm's law](1827)"); de.AddEntry(1834, "German free-trade zone(1834)"); de.AddEntry(1838, "M.Schleiden[plant cells](1838)"); de.AddEntry(1840, "[Frederick William IV 1840-1861]", PrintLocation.Left); de.AddEntry(1846, "Neptune discovered(1846)"); de.AddEntry(1862, "Otto V.Bismarck as PM(1862)"); de.AddEntry(1866, "'Capital' Marx(1867)"); de.AddEntry(1865, "Mendel[inheritance](1865)"); var aus = new Block {Ruler = rule, Title = "Austrian Empire", Width = 30}; aus.AddEntry(1788, "[Joseph II 1765-1790]", PrintLocation.Left); aus.AddEntry(1790, "[Leopold VII 1790-1792]", PrintLocation.Left); aus.AddEntry(1791, "[Francis II 1792-1804]", PrintLocation.Left); aus.AddEntry(1804, "[Francis I 1804-1835]", PrintLocation.Left); aus.AddEntry(1821, "K.V.Metternich PM(1821-1848)", PrintLocation.Left); aus.AddEntry(1835, "[Ferdinand I 1835-1848]", PrintLocation.Left); aus.AddEntry(1847, "[Francis Joseph 1848-1916]", PrintLocation.Left); aus.AddEntry(1815, "Congress of Vienna(1815)"); aus.AddEntry(1842, "Doppler[Doppler efct](1842)"); aus.AddEntry(1848, "revolution of 1848"); var ott = new Block {Ruler = rule, Title = "Ottoman Empire"}; ott.AddEntry(1789, "[Selim III 1789-1807]", PrintLocation.Left); ott.AddEntry(1807, "[Mustafa IV 1807/8]", PrintLocation.Left); ott.AddEntry(1809, "[Mahmud II 1808-1839]", PrintLocation.Left); ott.AddEntry(1839, "[Abdulmecid I 1839-1861]", PrintLocation.Left); ott.AddEntry(1852, "Epirus Revolt(1854)"); ott.AddEntry(1861, "[Abdulaziz I 1861-1876]", PrintLocation.Left); ott.AddEntry(1821, 1832, "Greek War of Independence"); var rus = new Block {Ruler = rule, Title = "Imperial Russia"}; rus.AddEntry(1796, "[Paul I 1796-1801]", PrintLocation.Left); rus.AddEntry(1801, "[Alexander I 1801-1825]", PrintLocation.Left); rus.AddEntry(1825, "Decembrist revolt(1825)"); rus.AddEntry(1824, "[Nicholas I 1825-1855]", PrintLocation.Left); rus.AddEntry(1830, "Lobachevsky[Non-Euclidean geo](1830)"); rus.AddEntry(1855, "[Alexander II 1855-1881]", PrintLocation.Left); rus.AddEntry(1860, "Vladivostok founded(1860)"); rus.AddEntry(1861, "serfs freed(1861)"); rus.AddEntry(1852, 1856, "Crimean War"); var plate = new Plate {Ruler = rule, Name = "Modern Age(1)"}; plate.AddBlock(usa); plate.AddBlock(engd); plate.AddBlock(fr); plate.AddBlock(de); plate.AddBlock(aus); plate.AddBlock(ott); plate.AddBlock(rus); plate.AddArrow(new Arrow(aus, ott) {Text = "B.of Focsani(1789)", StartValue = 1789}); plate.AddArrow(new Arrow(rus, ott) {StartValue = 1789, FromRightToLeftArrowHead = "<......"}); plate.AddArrow(new Arrow(aus, fr) {StartValue = 1792}); plate.AddArrow(new Arrow(de, fr) {StartValue = 1793}); plate.AddArrow(new Arrow(fr, aus) {StartValue = 1796, Text = "B.of Rivoli(1797)"}); plate.AddArrow(new Arrow(fr, ott) {Text = "B.of the Pryamids(1798)(c.)", StartValue = 1797}); plate.AddArrow(new Arrow(engd, fr) {Text = "B.of the Nile(1798)(g.)", StartValue = 1798}); plate.AddArrow(new Arrow(fr, aus) {Text = "B.of Marengo(1800)", StartValue = 1800}); plate.AddArrow(new Arrow(rus, fr) {Text = "B.of Leipzig(1813)", StartValue = 1813}); plate.AddArrow(new Arrow(engd, usa) { Text = "DC sacked(1814)", StartValue = 1814, ArrowTail = ".", FromRightToLeftArrowHead = "<...." }); plate.AddArrow(new Arrow(engd, fr) {Text = "Waterloo(1815)", StartValue = 1815}); plate.AddArrow(new Arrow(fr, rus) {StartValue = 1812}); plate.AddArrow(new Arrow(rus, ott) {StartValue = 1853, Text = "B.of Sinop(1853)"}); plate.AddArrow(new Arrow(engd, rus) {StartValue = 1854, Text = "B.of Balaclava(1854)"}); plate.Notes.Add("(a.) last Prime Minister dismissed by a king, (b.) last met in 1614"); plate.Notes.Add( "(c.) intended to cut England off from India, (d.) pop. of black slaves goes from 700 thousand to 3 million"); plate.Notes.Add("(e.) April 12, 1861, (f.) April 9, 1865 (est. 620,000 killed)"); plate.Notes.Add( "(g.) Napolean's Navy destroyed, (h.) Gen. Harrison defeats confederacy of Native Americans"); return plate; }
public static TextCanvas ToTextCanvas(this IRuleEntry entry, Rule ruler) { if(ruler == null) throw new NoRuleSetException(); var entryIndex = ruler.CalcEntryIndex(entry); var entryLines = entry.ToString().Split(Config.GraphChars.UNIX_NL_CHAR); var ruleIndex = ruler.GetIndexRule(); //iteration is on this difference so there needs to be at least that many lines in the string if (entryIndex.Item2 - entryIndex.Item1 > entryLines.Length) { throw new DrawingException( string.Format( "Entry is indexed at '{0}' to '{1}', a difference of '{2}' while the entry as a string is composed of '{3}' lines", entryIndex.Item1, entryIndex.Item2, (entryIndex.Item2 - entryIndex.Item1), entryLines.Length)); } var textCanvas = new TextCanvas { Ruler = ruler, Items = new List<TextItem>(), MinIndex = entryIndex.Item1, MaxIndex = entryIndex.Item2, StartValue = entry.StartValue, EndValue = entry.EndValue, Width = entry.Width, Id = entry.Id }; //single line entry if (entryIndex.Item2 == entryIndex.Item1) { if (entryIndex.Item1 < 0 || entryIndex.Item1 >= ruleIndex.Count) throw new DrawingException( string.Format( "The entry by ID '{0}' having the text value of '{1}' " + "is set to a position that is beyond the current ruler's max.", entry.Id, entry)); textCanvas.Items.Add(new TextItem { HashMarkValue = ruleIndex[entryIndex.Item1], Index = entryIndex.Item1, Text = entry.ToString().ToCharArray().ToList() }); return textCanvas; } //multiple line entry for (var i = entryIndex.Item1; i <= entryIndex.Item2; i++) { var hashMark = ruleIndex[i]; var text = entryLines[(i - entryIndex.Item1)]; if (string.IsNullOrEmpty(text)) continue; var nti = new TextItem { HashMarkValue = hashMark, Index = i, Text = text.ToCharArray().ToList() }; nti.Ranges.Add(new TextRange(){Id = entry.Id,Length = nti.Text.Count, StartIndex = 0}); textCanvas.Items.Add(nti); } return textCanvas; }
public static TextCanvas Merge(this TextCanvas entry1Tc, TextCanvas entry2Tc, Rule ruler) { //check for null args if (ruler == null || entry2Tc == null) throw new DrawingException("A merge requires a source, a candidate and a ruler"); //validate args have something to work with if(entry1Tc.IsEmptyItems() && entry2Tc.IsEmptyItems()) return new TextCanvas(); if (entry2Tc.IsEmptyItems() && !entry1Tc.IsEmptyItems()) return entry1Tc; if (entry1Tc.IsEmptyItems() && !entry2Tc.IsEmptyItems()) return entry2Tc; //determine total edges for the whole var entriesMin = entry1Tc.MinIndex < entry2Tc.MinIndex ? entry1Tc.MinIndex : entry2Tc.MinIndex; var entriesMax = entry1Tc.MaxIndex > entry2Tc.MaxIndex ? entry1Tc.MaxIndex : entry2Tc.MaxIndex; Func<TextItem, bool> tti = ti1 => ti1 != null && !ti1.IsEmptyText(); var textCanvas = new TextCanvas { Ruler = ruler, Items = new List<TextItem>(), MaxIndex = entriesMax, MinIndex = entriesMin, Width = entry1Tc.Width > entry2Tc.Width ? entry1Tc.Width : entry2Tc.Width }; for (var i = entriesMin; i <= entriesMax; i++) { var entry1i = entry1Tc.Items.FirstOrDefault(item => item.Index == i); var entry2i = entry2Tc.Items.FirstOrDefault(item => item.Index == i); if (entry1i == null && entry2i == null) continue; //merge line if (tti(entry1i) && tti(entry2i)) { var newEntry = entry1i.Copy(); newEntry.Ranges.AddRange(entry2i.Ranges); newEntry.Text = Etc.MergeString(new string(entry1i.Text.ToArray()), new string(entry2i.Text.ToArray())) .ToCharArray().Where(c => Convert.ToInt32(c) >= 0x20) .ToList(); textCanvas.Items.Add(newEntry); continue; } else if (tti(entry1i)) { textCanvas.Items.Add(entry1i.Copy()); continue; } textCanvas.Items.Add(entry2i.Copy()); } return textCanvas; }
public static TextCanvas Concat(this TextCanvas block1Tc, TextCanvas block2Tc, Rule ruler) { if(ruler == null) throw new NoRuleSetException(); if (block2Tc == null) { return block1Tc; } var minIndex = block1Tc.MinIndex < block2Tc.MinIndex ? block1Tc.MinIndex : block2Tc.MinIndex; var maxIndex = block1Tc.MaxIndex > block2Tc.MaxIndex ? block1Tc.MaxIndex : block2Tc.MaxIndex; var blockBarCount = 0; Func<char[], bool> printBar = c => new String(c).EndsWith(string.Format("{0}{1}", Config.GraphChars.Rail, Config.GraphChars.BarRailIntersect)); var tc = new TextCanvas() { MaxIndex = maxIndex, Ruler = ruler, MinIndex = minIndex, Id = block1Tc.Id + Config.GraphChars.IDSeparator + block2Tc.Id }; for (var i = minIndex; i <= maxIndex; i++) { var ti1 = block1Tc.GetTextOrEmpty(i, block1Tc.Width); var ti2 = block2Tc.GetTextOrEmpty(i, block2Tc.Width); if (ti1.Index < 0 || ti2.Index < 0) continue; var ntxt = new List<char>(ti1.Text); if (blockBarCount == 1 || block2Tc.MaxIndex >= i) ntxt.Add(Config.GraphChars.Bar); else ntxt.Add((char)0x20); if (printBar(ti1.Text.ToArray())) blockBarCount += 1; var txtRng = new TextRange() {Id = block2Tc.Id, Length = ti2.Text.Count, StartIndex = ntxt.Count}; ntxt.AddRange(ti2.Text); var nti = new TextItem() {HashMarkValue = ti1.HashMarkValue, Index = i, Text = ntxt}; nti.Ranges.AddRange(ti1.Ranges); nti.Ranges.Add(txtRng); tc.Items.Add(nti); if (ntxt.Count > tc.Width) tc.Width = ntxt.Count; } return tc; }
public void PlateConcatAllBlocksTest() { var ruler = new Rule { StartValue = 950, EndValue = 775 }; var egypt = new Block { Ruler = ruler, Title = "Egypt" }; var israel = new Block { Ruler = ruler, Title = "Israel" }; var damascus = new Block { Ruler = ruler, Title = "Damascus" }; var assyria = new Block { Ruler = ruler, Title = "Assyria" }; var northKingdom = new Block { StartValue = 922, EndValue = 775, Ruler = ruler, Title = "Israel" }; var southKingdom = new Block { StartValue = 922, EndValue = 775, Ruler = ruler, Title = "Judea" }; egypt.AddEntry(new Entry { StartValue = 935, Text = "XXII Dyn. 935-725", Location = PrintLocation.Left }); egypt.AddEntry(new Entry { StartValue = 935, EndValue = 914, Text = "Shishak 935-914", Location = PrintLocation.Right }); egypt.AddEntry(new Entry { StartValue = 914, EndValue = 874, Text = "Osorkon I 914-874" }); israel.AddEntry(new Entry { StartValue = 940, Text = "Solomon 961-922" }); southKingdom.AddEntry(new Entry { StartValue = 922, Text = "Rehoboam 922-915" }); southKingdom.AddEntry(new Entry { StartValue = 915, Text = "Abijah 915-913" }); northKingdom.AddEntry(new Entry { StartValue = 922, Text = "Jeroboam I 922-901" }); israel.AddInnerBlock(southKingdom); israel.AddInnerBlock(northKingdom); damascus.AddEntry(new Entry { StartValue = 930, Text = "Rezon" }); assyria.AddEntry(new Entry { StartValue = 935, Text = "Asshur-dan II 935-913" }); var testSubject = new Plate() { Name = "Near East", Ruler = ruler }; testSubject.AddBlock(egypt); testSubject.AddBlock(israel); testSubject.AddBlock(damascus); testSubject.AddBlock(assyria); var testResult = testSubject.ToTextCanvas(); Assert.IsNotNull(testResult); Assert.AreNotEqual(0, testResult.Items); foreach (var item in testResult.Items) { var itemText = new string(item.Text.ToArray()); foreach (var span in item.Ranges) { var subText = itemText.Substring(span.StartIndex, span.Length); System.Diagnostics.Debug.WriteLine("{0} {1} {2} {3} {4} '{5}'",item.Index, item.HashMarkValue,span.Id,span.StartIndex,span.Length, subText); } } }
public void PrintEntriesToCanvasTest() { var testRuler = new Rule() { EndValue = 575, StartValue = 775 }; var testBlock1 = new Block() { EndValue = 575, StartValue = 775, Title = "Judah", Ruler = testRuler }; var testEntry1 = new Entry() { EndValue = 687, StartValue = 732, Ruler = testRuler, Text = "(Isaiah)", Location = PrintLocation.Center }; var testEntry2 = new Entry() { EndValue = 702, StartValue = 733, Ruler = testRuler, Text = "(Micah)", Location = PrintLocation.Right }; var testEntry3 = new Entry() {EndValue = 735, StartValue = 735, Ruler = testRuler, Text = "Ahaz 735-715"}; var testEntry4 = new Entry() { EndValue = 715, StartValue = 715, Ruler = testRuler, Text = "Hezekiah 715-687" }; testBlock1.AddEntry(testEntry1); testBlock1.AddEntry(testEntry2); testBlock1.AddEntry(testEntry3); testBlock1.AddEntry(testEntry4); var testResult = testBlock1.PrintEntriesOnCanvas(); Assert.IsNotNull(testResult); System.Diagnostics.Debug.WriteLine(testResult); }
public void TestParseYearsRange() { var testSubject = new Rule { StartValue = 700, EndValue = 850 }; var testResult = testSubject.ParseYearsRange(@"789-97\804-16"); Assert.IsNotNull(testResult); var testList = testResult.ToList(); Assert.AreNotEqual(0, testList.Count); Assert.AreEqual(789,testList[0].Item1); Assert.AreEqual(797, testList[0].Item2); Assert.AreEqual(804, testList[1].Item1); Assert.AreEqual(816, testList[1].Item2); testSubject = new Rule { StartValue = 1788, EndValue = 1865 }; testResult = testSubject.ParseYearsRange("1797-1803"); Assert.IsNotNull(testResult); testList = testResult.ToList(); Assert.AreNotEqual(0, testList.Count); Assert.AreEqual(1797, testList[0].Item1); Assert.AreEqual(1803, testList[0].Item2); testSubject = new Rule { StartValue = 788, EndValue = 500 }; testResult = testSubject.ParseYearsRange("640-609"); Assert.IsNotNull(testResult); testList = testResult.ToList(); Assert.AreNotEqual(0, testList.Count); Assert.AreEqual(640, testList[0].Item1); Assert.AreEqual(609, testList[0].Item2); testSubject = new Rule { StartValue = 1488, EndValue = 1605 }; testResult = testSubject.ParseYearsRange("1588-"); Assert.IsNotNull(testResult); testList = testResult.ToList(); Assert.AreNotEqual(0, testList.Count); Assert.AreEqual(1588, testList[0].Item1); Assert.IsNull(testList[0].Item2); testResult = testSubject.ParseYearsRange("-1588"); Assert.IsNotNull(testResult); testList = testResult.ToList(); Assert.AreNotEqual(0, testList.Count); Assert.IsNull(testList[0].Item1); Assert.AreEqual(1588, testList[0].Item2); }
protected internal void AdjustRuler() { if (_lineCounter + 2 <= Ruler.EndValue) return; var nRule = new Rule { StartValue = Ruler.StartValue, EndValue = _lineCounter + 2, RuleLineSpacing = Ruler.RuleLineSpacing }; Ruler = nRule; foreach (var blk in _blocks) { blk.Ruler = nRule; } }
public void PlateToStringWithNotesTest() { var ruler = new Rule() {StartValue = 525, EndValue = 310}; var greece = new Block() {Ruler = ruler, Title = "Greece"}; greece.AddEntry(new Entry(){StartValue = 500, Text = "Ionian revolt", Location = PrintLocation.Right}); greece.AddEntry(new Entry() {StartValue = 490, Text = "Battle of Marathon"}); greece.AddEntry(new Entry(){StartValue = 480, Text = "Battle of Thermopyle / Salamis"}); greece.AddEntry(new Entry(){StartValue = 479, Text ="Battle of Plataea"}); greece.AddEntry(new Entry(){StartValue = 450, Text = "Peace of Callias"}); greece.AddEntry(new Entry(){StartValue = 440, Text = "Parthenon built"}); greece.AddEntry(new Entry(){StartValue = 431,EndValue = 404,Text = "Peloponnesian War"}); greece.AddEntry(new Entry(){StartValue = 400,Text = "Athens return of self-rule"}); greece.AddEntry(new Entry(){StartValue = 390,Text ="Corinthian War"}); greece.AddEntry(new Entry(){StartValue = 338, Text = "Battle of Chaeronea"}); greece.AddEntry(new Entry(){StartValue = 336, Text = "Phillip II rules all Greece"}); greece.AddEntry(new Entry() { StartValue = 460, EndValue = 429, Text = "Pericles" }); greece.AddEntry(new Entry(){StartValue = 323, Text = "Alexander & Fall of Persian Empire"}); greece.AddEntry(new Entry() { StartValue = 500, EndValue = 325, Text = "Classical Period", Location = PrintLocation.Left }); var plate = new Plate() {Name = "Classical Period", Ruler = ruler}; plate.AddBlock(greece); var testResult = plate.ToString(); Assert.IsNotNull(testResult); System.Diagnostics.Debug.WriteLine(testResult); }
public void EntryCalcHeightTest() { var testD00 = new NoFuture.Timeline.Rule() { EndValue = 750, StartValue = 950 }; var testSubject = new NoFuture.Timeline.Entry(); testSubject.Ruler = testD00; testSubject.StartValue = 902; testSubject.EndValue = 845; var testCtrl = testD00.CalcEntryIndex(testSubject); System.Diagnostics.Debug.WriteLine("Start Index '{0}', End Index '{1}'", testCtrl.Item1, testCtrl.Item2); var testResult = testSubject.CalcHeight(); Assert.AreNotEqual(0, testResult); System.Diagnostics.Debug.WriteLine("Test result calc height '{0}'",testResult); }
public void TestPrintYearsRange() { // ((789,797),(804,816)) as "789-97\804-16" // ((1797,1803)) as "1797-1803" // ((640, 609)) as "640-609" // ((1588,null)) as "1588-" var testSubject = new Rule {StartValue = 700, EndValue = 850}; var testResult = testSubject.PrintYearsRange(new List<Tuple<double?, double?>>() { new Tuple<double?, double?>(789, 797), new Tuple<double?, double?>(804, 816) }); Assert.AreEqual(@"789-97\804-16", testResult); testSubject = new Rule { StartValue = 1788, EndValue = 1865 }; testResult = testSubject.PrintYearsRange(new List<Tuple<double?, double?>>() { new Tuple<double?, double?>(1797, 1803) }); Assert.AreEqual("1797-1803", testResult); testSubject = new Rule { StartValue = 788, EndValue = 500 }; testResult = testSubject.PrintYearsRange(new List<Tuple<double?, double?>>() { new Tuple<double?, double?>(640, 609) }); Assert.AreEqual("640-609", testResult); testSubject = new Rule { StartValue = 1488, EndValue = 1605 }; testResult = testSubject.PrintYearsRange(new List<Tuple<double?, double?>>() { new Tuple<double?, double?>(1588, null) }); Assert.AreEqual("1588-", testResult); testResult = testSubject.PrintYearsRange(new List<Tuple<double?, double?>>() { new Tuple<double?, double?>(null, 1588) }); Assert.AreEqual("-1588", testResult); }
public void TextAfterBlockEnd() { var rule = new Rule() { StartValue = 780, EndValue = 500, RuleLineSpacing = 7 }; var judah = new Block() { Ruler = rule, Title = "Judah", StartValue = 780, EndValue = 587 }; judah.AddEntry(560, "Exile"); var plate = new Plate() { Ruler = rule, Name = "Mid-Eighth to Fifth Centuries BCE" }; plate.AddBlock(judah); System.Diagnostics.Debug.WriteLine(plate.ToString()); }
public void PrintPlateTest() { var testRuler = new Rule() { EndValue = 575, StartValue = 775 }; var testBlock1 = new Block() { EndValue = 575, StartValue = 775, Title = "Judah", Ruler = testRuler }; var testBlock2 = new Block() {EndValue = 575, StartValue = 775, Title = "Egypt", Ruler = testRuler}; testBlock1.AddEntry(new Entry() { Text = "Uzziah 783-742", StartValue = 765, EndValue = 765, }); testBlock1.AddEntry(new Entry() { Text = "(Jotham coregent 750)", StartValue = 750, EndValue = 750, Location = PrintLocation.Right }); testBlock1.AddEntry(new Entry() { Text = "Jotham 742-735", StartValue = 742, EndValue = 742, }); testBlock1.AddEntry(new Entry() { EndValue = 687, StartValue = 732, Text = "(Isaiah)", Location = PrintLocation.Center }); testBlock1.AddEntry(new Entry() { EndValue = 702, StartValue = 733, Text = "(Micah)", Location = PrintLocation.Right }); testBlock1.AddEntry(new Entry() { EndValue = 735, StartValue = 735, Text = "Ahaz 735-715" }); testBlock1.AddEntry(new Entry() { EndValue = 715, StartValue = 715, Text = "Hezekiah 715-687" }); testBlock2.AddEntry(new Entry() { Text = "XXII Dyn. 935-725", StartValue = 935, EndValue = 725, Location = PrintLocation.Left }); testBlock2.AddEntry(new Entry() { Text = "XXIV Dyn. 725-709", StartValue = 725, EndValue = 709, }); testBlock2.AddEntry(new Entry() {Text = "Neco II 610-594", StartValue = 610, EndValue = 610}); var testSubject = new Plate() {Ruler = testRuler, Name = "Near East"}; testSubject.AddBlock(testBlock1); testSubject.AddBlock(testBlock2); var testResult = testSubject.ToString(); Assert.IsNotNull(testResult); System.Diagnostics.Debug.WriteLine(testResult); }
public void ToTextCanvasTest() { var testD00 = new NoFuture.Timeline.Rule() { EndValue = 750, StartValue = 950 }; var testSubject = new NoFuture.Timeline.Entry(); testSubject.Ruler = testD00; testSubject.StartValue = 902; testSubject.EndValue = 845; testSubject.Text = "Late Republic"; var testResult = testSubject.ToTextCanvas(testSubject.Ruler); Assert.IsNotNull(testResult); Assert.IsNotNull(testResult.Items); Assert.AreNotEqual(0, testResult.Items.Count); foreach (var item in testResult.Items) { var text = new string(item.Text.ToArray()); var index = item.Index; var hashMark = item.HashMarkValue; System.Diagnostics.Debug.WriteLine("[{0}] - [{1,-18}] '{2}'",index, hashMark,text); } }
public void PrintPlateWithInnerPlatesTest() { var ruler = new Rule {StartValue = 950, EndValue = 775}; var egypt = new Block {Ruler = ruler, Title = "Egypt"}; var israel = new Block {Ruler = ruler, Title = "Israel"}; var damascus = new Block {Ruler = ruler, Title = "Damascus"}; var assyria = new Block {Ruler = ruler, Title = "Assyria"}; var northKingdom = new Block {StartValue = 922, EndValue = 775, Ruler = ruler, Title = "Israel"}; var southKingdom = new Block {StartValue = 922, EndValue = 775, Ruler = ruler, Title = "Judea"}; egypt.AddEntry(new Entry {StartValue = 935, Text = "XXII Dyn. 935-725",Location = PrintLocation.Left}); egypt.AddEntry(new Entry { StartValue = 935, EndValue = 914, Text = "Shishak 935-914",Location = PrintLocation.Right}); egypt.AddEntry(new Entry {StartValue = 914, EndValue = 874, Text = "Osorkon I 914-874"}); israel.AddEntry(new Entry {StartValue = 940,Text="Solomon 961-922"}); southKingdom.AddEntry(new Entry {StartValue = 922, Text = "Rehoboam 922-915"}); southKingdom.AddEntry(new Entry {StartValue = 915, Text = "Abijah 915-913"}); northKingdom.AddEntry(new Entry {StartValue = 922, Text = "Jeroboam I 922-901"}); israel.AddInnerBlock(southKingdom); israel.AddInnerBlock(northKingdom); damascus.AddEntry(new Entry {StartValue = 930, Text = "Rezon"}); assyria.AddEntry(new Entry {StartValue = 935, Text = "Asshur-dan II 935-913"}); var testSubject = new Plate() {Name = "Near East", Ruler = ruler}; testSubject.AddBlock(egypt); testSubject.AddBlock(israel); testSubject.AddBlock(damascus); testSubject.AddBlock(assyria); var testResult = testSubject.ToString(); System.Diagnostics.Debug.WriteLine(testResult); }
public void GetRequiredWidthTest() { var ruler = new Rule { StartValue = 950, EndValue = 775 }; var egypt = new Block { Ruler = ruler, Title = "Egypt" }; egypt.AddEntry(new Entry { StartValue = 935, Text = "XXII Dyn. 935-725", Location = PrintLocation.Left }); egypt.AddEntry(new Entry { StartValue = 935, EndValue = 914, Text = "Shishak 935-914", Location = PrintLocation.Right }); var testResult = egypt.GetRequiredWidth(); Assert.AreNotEqual(0, testResult); System.Diagnostics.Debug.WriteLine(testResult); }
public void RulePrintTestDivideUneven() { var ruler = new Rule { StartValue = 950, EndValue = 775 }; var testResult = ruler.ToString(); Assert.IsNotNull(testResult); System.Diagnostics.Debug.WriteLine(testResult); }
public void MergeBlockToEntryTest() { var testRuler = new NoFuture.Timeline.Rule() { EndValue = 20, StartValue = 90 }; var testSubjectB = new NoFuture.Timeline.Block() { EmptyChar = '.', EndValue = 26, Ruler = testRuler, StartValue = 90, Title = "Roman Republic" }; var testSubjectA = new NoFuture.Timeline.Entry {Ruler = testRuler, Text = "Ceaser assassinated", StartValue = 44, EndValue = 44}; var testResult = testSubjectA.ToTextCanvas(testRuler).Merge(testSubjectB.ToTextCanvas(testRuler), testRuler); System.Diagnostics.Debug.WriteLine(testResult); }
public void ConcatBlockTest() { var rule = new Rule() { StartValue = 2100, EndValue = 1500 }; var assyria = new Block() { Ruler = rule, Title = "Assyria", StartValue = 1950 }; var mari = new Block() { Ruler = rule, Title = "Mari", StartValue = 1950, EndValue = 1700, Width = 16 }; var isin = new Block() { Ruler = rule, Title = "Isin", StartValue = 1950, EndValue = 1750, Width = 8 }; var larsa = new Block() { Ruler = rule, Title = "Larsa", StartValue = 1950, EndValue = 1700, Width = 16 }; var babylon = new Block() { Ruler = rule, Title = "Babylon", StartValue = 1830, EndValue = 1550, Width = 20 }; var testResult = assyria.ToTextCanvas(rule).Concat(mari.ToTextCanvas(rule), rule); testResult = testResult.Concat(isin.ToTextCanvas(rule), rule); testResult = testResult.Concat(larsa.ToTextCanvas(rule), rule); testResult = testResult.Concat(babylon.ToTextCanvas(rule), rule); System.Diagnostics.Debug.WriteLine(testResult.ToString()); }
public Plate CE1700to1788() { var rule = new Rule { StartValue = 1700, EndValue = 1790, RuleLineSpacing = 7 }; var amer = new Block { Ruler = rule, Title = "Americas" }; var col = new Block { StartValue = 1703, EndValue = 1783, Title = "Colonies", Ruler = rule }; col.AddEntry(1771, "Boston Massacre(1770)", PrintLocation.Left); col.AddEntry(1703, "Yale College (1700)"); col.AddEntry(new ExplorerEntry("Bering", "Bering straight", 1728) { StartValue = 1727 }); col.AddEntry(1739, "Stono Rebellion(1739)"); col.AddEntry(1730, "Baltimore MA(1730)"); col.AddEntry(1764, "Mason Dixon survey(1764)"); col.AddEntry(new ExplorerEntry("D.Boone", "Kentucky", 1769)); col.AddEntry(1773, "Boston Tea Party(1773)"); col.AddEntry(1704, 1713, "Queen Anne's War"); col.AddEntry(1754, 1763, "French Indian War"); col.AddEntry(1775, 1783, "American Rev.(1775-1783)", PrintLocation.Left); col.AddEntry(1777, "NY occupied(1776)"); col.AddEntry(1778, "Savannah occupied(1778)"); col.AddEntry(1780, "Charleston occupied(1780)"); var que = new Block { StartValue = 1703, EndValue = 1763, Title = "New France", Ruler = rule, Width = 22 }; que.AddEntry(1703, "Fr.settle Mobile AL"); que.AddEntry(1718, "New Orleans LA(1718)"); var usa = new Block { StartValue = 1775, Title = "United States", Ruler = rule }; usa.AddEntry(1776, "Lafayette in PA(1777)"); usa.AddEntry(1781, "Cornwallis surrender(1781)"); usa.AddEntry(1783, "Peace of Paris(1783)"); usa.AddEntry(new LiteraryWorkEntry("U.S.Constitution", "", 1789) { StartValue = 1787 }); var engd = new Block { Ruler = rule, Title = "United Kingdom" }; engd.AddEntry(new LeaderEntry("Anne", new int?[, ] { { 1702, 1714 } }) { StartValue = 1704 }); engd.AddEntry(new LeaderEntry("George I", new int?[, ] { { 1714, 1727 } }) { StartValue = 1720 }); engd.AddEntry(new LeaderEntry("George II", new int?[, ] { { 1727, 1760 } })); engd.AddEntry(new ScienceAdvEntry("railroad", "", 1730)); engd.AddEntry(1739, "Wesley/Whitefield[Methodism]"); engd.AddEntry(1745, "Jacobite Rebellion(1745)"); engd.AddEntry(new LeaderEntry("George III", new int?[, ] { { 1760, 1820 } })); engd.AddEntry(new ScienceAdvEntry("hydrogen", "H.Cavendish", 1766)); engd.AddEntry(new LiteraryWorkEntry("Wealth of Nations", "A.Smith", 1776) { Location = PrintLocation.Right }); engd.AddEntry(new LiteraryWorkEntry("Rise & Fall..Roman Empire", "Gibbon", 1777) { Location = PrintLocation.Right }); engd.AddEntry(1781, "1st Sunday-school(R.Raikes)(1781)", PrintLocation.Right); engd.AddEntry(new ScienceAdvEntry("steam engine", "J.Watt", 1769)); engd.AddEntry(new ScienceAdvEntry("spinning jenny", "J.Hargreaves", 1764) { Location = PrintLocation.Right }); engd.AddEntry(1782, "Lord North resigns as PM(1782)"); engd.AddEntry(1787, "Australia penal settlement(1788)"); engd.AddEntry(new ExplorerEntry("Cook", "Hawaiian Islands", 1788) { StartValue = 1789 }); engd.AddEntry(1702, 1714, "Stuart(restored)", PrintLocation.Left); engd.AddEntry(1715, 1800, "Hanover", PrintLocation.Left); var fr = new Block { Ruler = rule, Title = "France" }; fr.AddEntry(new LeaderEntry("Louis XIV", new int?[, ] { { null, 1715 } }) { StartValue = 1704 }); fr.AddEntry(new LeaderEntry("Louis XV", new int?[, ] { { 1715, 1774 } }) { StartValue = 1715 }); fr.AddEntry(new LeaderEntry("Louis XVI", new int?[, ] { { 1774, 1792 } }) { StartValue = 1774 }); fr.AddEntry(1720, "France bankrupt(1721)"); fr.AddEntry(new LiteraryWorkEntry("The Spirit of Laws", "Montesquieu", 1748) { Location = PrintLocation.Right }); fr.AddEntry(new LiteraryWorkEntry("Social Contract", "Rousseau", 1761) { Location = PrintLocation.Right }); fr.AddEntry(1756, "Diplomatic Revolution(1756)(c.)"); fr.AddEntry(new ScienceAdvEntry("hot-air ballon", "", 1783) { Location = PrintLocation.Right }); fr.AddEntry(1702, 1790, "Capetian[Bourbon]", PrintLocation.Left); fr.AddEntry(1701, 1714, "War of Spanish Succ.(1701-1714)"); var de = new Block { Ruler = rule, Title = "Prussia" }; de.AddEntry(new LeaderEntry("Fredrick I", new int?[, ] { { 1701, 1713 } }) { StartValue = 1702 }); de.AddEntry(new LeaderEntry("Fredrick William I", new int?[, ] { { 1713, 1740 } })); de.AddEntry(new LeaderEntry("Fredrick the Great", new int?[, ] { { 1740, 1786 } })); de.AddEntry(new LeaderEntry("Fredrick William II", new int?[, ] { { 1786, 1797 } })); de.AddEntry(new LiteraryWorkEntry("Critique Pure Reason", "E.Kant", 1781)); de.AddEntry(new ScienceAdvEntry("thermometer", "Fahrenheit", 1714) { StartValue = 1715 }); de.AddEntry(1730, "'Toccata Fugue' Bach(~1730s)"); de.AddEntry(1754, 1763, "Seven's Year War"); var aus = new Block { Ruler = rule, Title = "Austrian Empire" }; aus.AddEntry(new LeaderEntry("Leopold I", new int?[, ] { { 1640, 1705 } }) { StartValue = 1701 }); aus.AddEntry(new LeaderEntry("Joseph I", new int?[, ] { { 1705, 1711 } })); aus.AddEntry(new LeaderEntry("Charles III", new int?[, ] { { 1711, 1740 } })); aus.AddEntry(new LeaderEntry("Maria Theresa", new int?[, ] { { 1740, 1780 } }) { StartValue = 1739 }); aus.AddEntry(new LeaderEntry("Joseph II", new int?[, ] { { 1780, 1790 } })); aus.AddEntry(1783, "Mozart in Vienna", PrintLocation.Right); aus.AddEntry(1741, 1748, "War of Austrian Succ.(1740-1748)"); var ott = new Block { Ruler = rule, Title = "Ottoman Empire" }; ott.AddEntry(new LeaderEntry("Ahmed III", new int?[, ] { { 1703, 1730 } }) { StartValue = 1710 }); ott.AddEntry(new LeaderEntry("Mahmud I", new int?[, ] { { 1730, 1754 } })); ott.AddEntry(new LeaderEntry("Osman III", new int?[, ] { { 1754, 1757 } })); ott.AddEntry(new LeaderEntry("Mustafa III", new int?[, ] { { 1757, 1774 } })); ott.AddEntry(new LeaderEntry("Abdulhamid I", new int?[, ] { { 1774, 1789 } })); ott.AddEntry(new LeaderEntry("Selim III", new int?[, ] { { 1789, 1807 } })); var rus = new Block { Ruler = rule, Title = "Imperial Russia", StartValue = 1721 }; rus.AddEntry(new LeaderEntry("Peter the Great", new int?[, ] { { 1695, 1725 } }) { StartValue = 1725 }); rus.AddEntry(1727, 1760, "[internal intrigue]"); rus.AddEntry(new LeaderEntry("[Catherine the Great", new int?[, ] { { 1762, 1796 } })); rus.AddEntry(new TerritoryEntry("Crimea") { StartValue = 1783 }); rus.AddEntry(1768, 1774, "1st Russio-Turkish War", PrintLocation.Right); amer.AddInnerBlock(col); amer.AddInnerBlock(usa); amer.AddInnerBlock(que); amer.AddArrow(new Arrow(que, col) { StartValue = 1706, ArrowTail = ".." }); amer.AddArrow(new Arrow(col, que) { StartValue = 1755, Text = "B. of the Monongahela", ArrowTail = ".." }); amer.AddArrow(new Arrow(que, col) { StartValue = 1757, Text = "massacre @ F.William Henry", ArrowTail = ".." }); var plate = new Plate { Ruler = rule, Name = "Early Modern Age" }; plate.AddBlock(amer); plate.AddBlock(engd); plate.AddBlock(fr); plate.AddBlock(de); plate.AddBlock(aus); plate.AddBlock(ott); plate.AddBlock(rus); plate.FileName = "16_CE1700_1788"; plate.AddArrow(new Arrow(aus, fr) { StartValue = 1704, Text = "B. of Blenheim(1704)" }); plate.AddArrow(new Arrow(fr, de) { StartValue = 1706, Text = "B. of Ramilies(1706)" }); plate.AddArrow(new Arrow(fr, de) { StartValue = 1708, Text = "B. of Oudenarde(1708)" }); plate.AddArrow(new Arrow(engd, fr) { StartValue = 1709, Text = "B. of Malpaquet(1709)" }); plate.AddArrow(new Arrow(aus, ott) { StartValue = 1717, Text = "B. of Belgrad(1717)" }); plate.AddArrow(new Arrow(de, aus) { StartValue = 1740, Text = "invasion of Silesia(1740)" }); plate.AddArrow(new Arrow(engd, fr) { StartValue = 1743, Text = "B. of Dettingen(1743)(e.)" }); plate.AddArrow(new Arrow(de, aus) { StartValue = 1757, Text = "B. of Prague(1757)" }); plate.AddArrow(new Arrow(rus, ott) { StartValue = 1770, Text = "B.of Chesma & Kagus(1770)" }); plate.AddArrow(new Arrow(engd, aus) { StartValue = 1714, Text = "Peace of Ulrecht(1714)(a.)", ArrowTail = "[..", FromLeftToRightArrowHead = "..]", }); plate.AddArrow(new Arrow(aus, de) { StartValue = 1748, Text = "Treaty of Aix-la-Chapelle(1748)", ArrowTail = "..]", FromRightToLeftArrowHead = "[..", }); plate.AddArrow(new Arrow(engd, fr) { StartValue = 1763, Text = "Treaty of Paris(1763)(b.)", ArrowTail = "[..", FromLeftToRightArrowHead = "..]", }); plate.AddArrow(new Arrow(de, aus) { StartValue = 1788, Text = "War of Bavarian Succ.(1778\\79)", ArrowTail = "[..", FromLeftToRightArrowHead = "..]", }); plate.AddArrow(new Arrow(engd, usa) { StartValue = 1771, Text = "B. of the Alamance(1771)" }); plate.AddArrow(new Arrow(engd, usa) { StartValue = 1775, Text = "B. of Lexington(1775)", }); plate.AddArrow(new Arrow(engd, usa) { StartValue = 1777, Text = "B. at Trenton(1777)", }); plate.Notes.Add("(a.)marks the end of Wars of Spanish Succession"); plate.Notes.Add("(b.)British supremacy in Canada and India"); plate.Notes.Add("(c.)England allies with Prussia - Austria with France."); plate.Notes.Add("(d.)start of Wars of Austrian Succ."); plate.Notes.Add("(e.)fought on German soil"); return(plate); }