// Render the given course id (0 = all controls) and kind to a map, and compare it to the saved version. internal void CheckRenderMapStandardChange(string filename, Id <Course> id, DescriptionKind kind, string newDescStandard) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; eventDB.Load(filename); symbolDB.Standard = eventDB.GetEvent().descriptionStandard; eventDB.Validate(); courseView = CourseView.CreateViewingCourseView(eventDB, DesignatorFromCourseId(eventDB, id)); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting); DescriptionLine[] description = descFormatter.CreateDescription(kind == DescriptionKind.Symbols); Bitmap bmNew = RenderToMapThenToBitmap(symbolDB, description, kind, 1); TestUtil.CheckBitmapsBase(bmNew, DescriptionBrowser.GetBitmapFileName(eventDB, id, "_std_default", kind)); undomgr.BeginCommand(71231, "change standard"); symbolDB.Standard = newDescStandard; ChangeEvent.UpdateDescriptionToMatchStandard(eventDB, symbolDB); undomgr.EndCommand(71231); description = descFormatter.CreateDescription(kind == DescriptionKind.Symbols); bmNew = RenderToMapThenToBitmap(symbolDB, description, kind, 1); TestUtil.CheckBitmapsBase(bmNew, DescriptionBrowser.GetBitmapFileName(eventDB, id, "_std_" + newDescStandard, kind)); }
public void DisplayAllCourseViews() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent1.coursescribe")); eventDB.Validate(); foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB)) { CourseDesignator designator; if (QueryEvent.HasVariations(eventDB, courseId)) { var variationInfo = QueryEvent.GetAllVariations(eventDB, courseId).First(); designator = new CourseDesignator(courseId, variationInfo); } else { designator = new CourseDesignator(courseId); } CourseView courseView = CourseView.CreateViewingCourseView(eventDB, designator); DumpCourseView(courseView, Console.Out); Console.WriteLine(); } }
public void ClearTextAndSymbols() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual, expected; eventDB.Load(TestUtil.GetTestFile("descformatter\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(4))); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting); DescriptionLine[] description = descFormatter.CreateDescription(false); DescriptionFormatter.ClearTextAndSymbols(description); DescriptionFormatter.DumpDescription(symbolDB, description, writer); actual = writer.ToString(); expected = @" | | | | | | ( 1) | | | | | | | | | ( 11) | | | | | | | | | ( 22) | : | ( 4) | | | | | | | | | ( 15) | : | ( 5) | | | | | | | | | ( 18) | | | | | | | | | ( 6) | : | "; Assert.AreEqual(expected, actual); }
public void SpecialLegs() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual, expected; eventDB.Load(TestUtil.GetTestFile("courseview\\speciallegs.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(1))); DumpCourseView(courseView, writer); actual = writer.ToString(); expected = @"Name='Leggy', Kind='Normal', CourseId=1 Total Length=2242.8 Part Length=2242.8 Total Climb=-1 ScoreColumn=-1 Total Score=0 Total Controls=4 0: [ 0] Ids: 1, 1 Legs: (Next:1,Id:0,length:515.84) 1: [ 1] Ids: 2, 2 Legs: (Next:2,Id:2,length:420.12) 2: [ 2] Ids: 3, 3 Legs: (Next:3,Id:3,length:377.54) 3: [ 3] Ids: 4, 4 Legs: (Next:4,Id:4,length:518.8) 4: [ 4] Ids: 5, 5 Legs: (Next:5,Id:0,length:410.45) 5: [-1] Ids: 6, 6 "; Assert.AreEqual(expected, actual); }
public void AllControlsEquals() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView, courseView2; CourseLayout course, course2; eventDB.Load(TestUtil.GetTestFile("courselayout\\marymoor1.coursescribe")); eventDB.Validate(); // Create the all controls course courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); course = new CourseLayout(); course.SetLayerColor(CourseLayer.Descriptions, 0, "Black", 0, 0, 0, 1F, false); course.SetLayerColor(CourseLayer.MainCourse, 12, "Purple", 0.2F, 1, 0, 0.1F, false); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, CourseLayer.MainCourse); // Create the all controls course again courseView2 = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); course2 = new CourseLayout(); course2.SetLayerColor(CourseLayer.Descriptions, 0, "Black", 0, 0, 0, 1F, false); course2.SetLayerColor(CourseLayer.MainCourse, 12, "Purple", 0.2F, 1, 0, 0.1F, false); CourseFormatter.FormatCourseToLayout(symbolDB, courseView2, defaultCourseAppearance, course2, CourseLayer.MainCourse); // Make sure that they are equal. Assert.AreEqual(course, course, "CourseLayouts that are equivalent should compare equal."); Assert.AreEqual(course, course2, "CourseLayouts that are equivalent should compare equal."); }
// Render the given course id (0 = all controls) and kind to a bitmap, and compare it to the saved version. internal void CheckRenderBitmap(string filename, Id <Course> id, DescriptionKind kind, int numColumns = 1) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; eventDB.Load(filename); eventDB.Validate(); courseView = CourseView.CreateViewingCourseView(eventDB, DesignatorFromCourseId(eventDB, id)); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting); DescriptionLine[] description = descFormatter.CreateDescription(kind == DescriptionKind.Symbols); Bitmap bmNew = DescriptionBrowser.RenderToBitmap(symbolDB, description, kind, numColumns); if (numColumns > 1) { TestUtil.CheckBitmapsBase(bmNew, DescriptionBrowser.GetBitmapFileName(eventDB, id, "_" + numColumns + "col", kind)); } else { TestUtil.CheckBitmapsBase(bmNew, DescriptionBrowser.GetBitmapFileName(eventDB, id, "", kind)); } }
public void CourseEquals() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView, courseView2; CourseLayout course, course2; eventDB.Load(TestUtil.GetTestFile("courselayout\\marymoor1.coursescribe")); eventDB.Validate(); // Create the a course view and layout courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(3))); course = new CourseLayout(); course.SetLayerColor(CourseLayer.Descriptions, 0, "Black", 0, 0, 0, 1F, false); course.SetLayerColor(CourseLayer.MainCourse, 12, "Purple", 0.2F, 1, 0, 0.1F, false); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, CourseLayer.MainCourse); // Create it again courseView2 = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(3))); course2 = new CourseLayout(); course2.SetLayerColor(CourseLayer.Descriptions, 0, "Black", 0, 0, 0, 1F, false); course2.SetLayerColor(CourseLayer.MainCourse, 12, "Purple", 0.2F, 1, 0, 0.1F, false); CourseFormatter.FormatCourseToLayout(symbolDB, courseView2, defaultCourseAppearance, course2, CourseLayer.MainCourse); // Make sure that they are equal. Assert.AreEqual(course, course, "CourseLayouts that are equivalent should compare equal."); Assert.AreEqual(course, course2, "CourseLayouts that are equivalent should compare equal."); }
public void Setup(string basename) { undomgr = new UndoMgr(10); eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile(basename)); eventDB.Validate(); }
public void ValidateSampleEvent1() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("eventdb\\sampleevent1.coursescribe")); eventDB.Validate(); }
// Sets up with special symbols.xml that has fake polish text in it, to test case agreement stuff. public void SetupWithPolish() { undomgr = new UndoMgr(5); eventDB = new EventDB(undomgr); symbolDB = new SymbolDB(TestUtil.GetTestFile("textifier\\pl-symbols.xml")); eventDB.Load(TestUtil.GetTestFile("textifier\\PolishTest.ppen")); eventDB.Validate(); }
// Sets up with special symbols.xml that has fake german text in it, to test gender/plural stuff. public void SetupWithGerman() { undomgr = new UndoMgr(5); eventDB = new EventDB(undomgr); symbolDB = new SymbolDB(TestUtil.GetTestFile("textifier\\de_symbols.xml")); eventDB.Load(TestUtil.GetTestFile("textifier\\sampleevent2.coursescribe")); eventDB.Validate(); }
public void ValidateVariations1() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("queryevent\\variations.ppen")); eventDB.Validate(); }
public void Setup() { undomgr = new UndoMgr(5); eventDB = new EventDB(undomgr); symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); eventDB.Load(TestUtil.GetTestFile("textifier\\sampleevent1.coursescribe")); eventDB.Validate(); }
public void HitTestRegular() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("descriptions\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(4))); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting); DescriptionLine[] description = descFormatter.CreateDescription(false); DescriptionRenderer descriptionRenderer = new DescriptionRenderer(symbolDB); descriptionRenderer.Description = description; descriptionRenderer.CellSize = 40; descriptionRenderer.Margin = 5; descriptionRenderer.DescriptionKind = DescriptionKind.Symbols; CheckHitTest(descriptionRenderer, new Point(201, 36), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(79, 50), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(145, 80), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(289, 60), HitTestKind.Header, 1, 1, 2, new RectangleF(245, 45, 80, 40)); CheckHitTest(descriptionRenderer, new Point(175, 216), HitTestKind.NormalBox, 5, 5, 4, new RectangleF(165, 205, 40, 40)); CheckHitTest(descriptionRenderer, new Point(285, 365), HitTestKind.NormalBox, 9, 9, 7, new RectangleF(285, 365, 40, 40)); CheckHitTest(descriptionRenderer, new Point(81, 193), HitTestKind.Directive, 4, 4, 0, new RectangleF(5, 165, 320, 40)); CheckHitTest(descriptionRenderer, new Point(328, 147), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(255, 427), HitTestKind.OtherTextLine, 10, 10, 0, new RectangleF(5, 405, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.Text; CheckHitTest(descriptionRenderer, new Point(201, 36), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(79, 50), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(145, 80), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(289, 60), HitTestKind.Header, 1, 1, 2, new RectangleF(245, 45, 80, 40)); CheckHitTest(descriptionRenderer, new Point(175, 216), HitTestKind.NormalText, 5, 5, -1, new RectangleF(85, 205, 240, 40)); CheckHitTest(descriptionRenderer, new Point(285, 365), HitTestKind.NormalText, 9, 9, -1, new RectangleF(85, 365, 240, 40)); CheckHitTest(descriptionRenderer, new Point(59, 302), HitTestKind.NormalBox, 7, 7, 1, new RectangleF(45, 285, 40, 40)); CheckHitTest(descriptionRenderer, new Point(81, 193), HitTestKind.DirectiveText, 4, 4, -1, new RectangleF(5, 165, 320, 40)); CheckHitTest(descriptionRenderer, new Point(328, 147), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(255, 427), HitTestKind.OtherTextLine, 10, 10, 0, new RectangleF(5, 405, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.SymbolsAndText; CheckHitTest(descriptionRenderer, new Point(201, 36), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 520, 40)); CheckHitTest(descriptionRenderer, new Point(79, 50), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(145, 80), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(289, 60), HitTestKind.Header, 1, 1, 2, new RectangleF(245, 45, 80, 40)); CheckHitTest(descriptionRenderer, new Point(175, 216), HitTestKind.NormalBox, 5, 5, 4, new RectangleF(165, 205, 40, 40)); CheckHitTest(descriptionRenderer, new Point(285, 365), HitTestKind.NormalBox, 9, 9, 7, new RectangleF(285, 365, 40, 40)); CheckHitTest(descriptionRenderer, new Point(81, 193), HitTestKind.Directive, 4, 4, 0, new RectangleF(5, 165, 320, 40)); CheckHitTest(descriptionRenderer, new Point(431, 56), HitTestKind.None, 1, 1, -1, new RectangleF(325, 45, 200, 40)); CheckHitTest(descriptionRenderer, new Point(333, 131), HitTestKind.NormalText, 3, 3, -1, new RectangleF(325, 125, 200, 40)); CheckHitTest(descriptionRenderer, new Point(491, 252), HitTestKind.DirectiveText, 6, 6, -1, new RectangleF(325, 245, 200, 40)); CheckHitTest(descriptionRenderer, new Point(527, 433), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(255, 427), HitTestKind.OtherTextLine, 10, 10, 0, new RectangleF(5, 405, 520, 40)); }
public void HitTestAllControls() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("descriptions\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting); DescriptionLine[] description = descFormatter.CreateDescription(false); DescriptionRenderer descriptionRenderer = new DescriptionRenderer(symbolDB); descriptionRenderer.Description = description; descriptionRenderer.CellSize = 40; descriptionRenderer.Margin = 5; descriptionRenderer.DescriptionKind = DescriptionKind.Symbols; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(116, 53), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(259, 78), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38, 97), HitTestKind.NormalBox, 2, 2, 0, new RectangleF(5, 85, 40, 40)); CheckHitTest(descriptionRenderer, new Point(226, 260), HitTestKind.NormalBox, 6, 6, 5, new RectangleF(205, 245, 40, 40)); CheckHitTest(descriptionRenderer, new Point(68, 999), HitTestKind.Directive, 24, 24, 0, new RectangleF(5, 965, 320, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(262, 745), HitTestKind.OtherTextLine, 18, 18, 0, new RectangleF(5, 725, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.Text; CheckHitTest(descriptionRenderer, new Point(311, 12), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(16, 82), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(178, 76), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38, 97), HitTestKind.NormalBox, 2, 2, 0, new RectangleF(5, 85, 40, 40)); CheckHitTest(descriptionRenderer, new Point(182, 234), HitTestKind.NormalText, 5, 5, -1, new RectangleF(85, 205, 240, 40)); CheckHitTest(descriptionRenderer, new Point(60, 942), HitTestKind.DirectiveText, 23, 23, -1, new RectangleF(5, 925, 320, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(262, 745), HitTestKind.OtherTextLine, 18, 18, 0, new RectangleF(5, 725, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.SymbolsAndText; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 520, 40)); CheckHitTest(descriptionRenderer, new Point(434, 25), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 520, 40)); CheckHitTest(descriptionRenderer, new Point(116, 53), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(259, 78), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 200, 40)); CheckHitTest(descriptionRenderer, new Point(380, 76), HitTestKind.None, 1, 1, -1, new RectangleF(325, 45, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38, 97), HitTestKind.NormalBox, 2, 2, 0, new RectangleF(5, 85, 40, 40)); CheckHitTest(descriptionRenderer, new Point(226, 260), HitTestKind.NormalBox, 6, 6, 5, new RectangleF(205, 245, 40, 40)); CheckHitTest(descriptionRenderer, new Point(68, 999), HitTestKind.Directive, 24, 24, 0, new RectangleF(5, 965, 320, 40)); CheckHitTest(descriptionRenderer, new Point(398, 554), HitTestKind.NormalText, 13, 13, -1, new RectangleF(325, 525, 200, 40)); CheckHitTest(descriptionRenderer, new Point(401, 934), HitTestKind.DirectiveText, 23, 23, -1, new RectangleF(325, 925, 200, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(262, 745), HitTestKind.OtherTextLine, 18, 18, 0, new RectangleF(5, 725, 520, 40)); }
public void HitTestScore() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("descriptions\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(5))); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting); DescriptionLine[] description = descFormatter.CreateDescription(false); DescriptionRenderer descriptionRenderer = new DescriptionRenderer(symbolDB); descriptionRenderer.Description = description; descriptionRenderer.CellSize = 40; descriptionRenderer.Margin = 5; descriptionRenderer.DescriptionKind = DescriptionKind.Symbols; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(178, 51), HitTestKind.SecondaryTitle, 1, 1, 0, new RectangleF(5, 45, 320, 40)); CheckHitTest(descriptionRenderer, new Point(116, 93), HitTestKind.Header, 2, 2, 0, new RectangleF(5, 85, 120, 40)); CheckHitTest(descriptionRenderer, new Point(259, 118), HitTestKind.Header, 2, 2, 1, new RectangleF(125, 85, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38, 137), HitTestKind.NormalBox, 3, 3, 0, new RectangleF(5, 125, 40, 40)); CheckHitTest(descriptionRenderer, new Point(226, 260), HitTestKind.NormalBox, 6, 6, 5, new RectangleF(205, 245, 40, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(228, 534), HitTestKind.OtherTextLine, 13, 13, 0, new RectangleF(5, 525, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.Text; CheckHitTest(descriptionRenderer, new Point(311, 12), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(178, 51), HitTestKind.SecondaryTitle, 1, 1, 0, new RectangleF(5, 45, 320, 40)); CheckHitTest(descriptionRenderer, new Point(16, 112), HitTestKind.Header, 2, 2, 0, new RectangleF(5, 85, 120, 40)); CheckHitTest(descriptionRenderer, new Point(178, 116), HitTestKind.Header, 2, 2, 1, new RectangleF(125, 85, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38, 137), HitTestKind.NormalBox, 3, 3, 0, new RectangleF(5, 125, 40, 40)); CheckHitTest(descriptionRenderer, new Point(182, 234), HitTestKind.NormalText, 5, 5, -1, new RectangleF(85, 205, 240, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(228, 534), HitTestKind.OtherTextLine, 13, 13, 0, new RectangleF(5, 525, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.SymbolsAndText; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 520, 40)); CheckHitTest(descriptionRenderer, new Point(178, 51), HitTestKind.SecondaryTitle, 1, 1, 0, new RectangleF(5, 45, 520, 40)); CheckHitTest(descriptionRenderer, new Point(434, 25), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 520, 40)); CheckHitTest(descriptionRenderer, new Point(116, 93), HitTestKind.Header, 2, 2, 0, new RectangleF(5, 85, 120, 40)); CheckHitTest(descriptionRenderer, new Point(259, 118), HitTestKind.Header, 2, 2, 1, new RectangleF(125, 85, 200, 40)); CheckHitTest(descriptionRenderer, new Point(380, 116), HitTestKind.None, 2, 2, -1, new RectangleF(325, 85, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38, 137), HitTestKind.NormalBox, 3, 3, 0, new RectangleF(5, 125, 40, 40)); CheckHitTest(descriptionRenderer, new Point(226, 260), HitTestKind.NormalBox, 6, 6, 5, new RectangleF(205, 245, 40, 40)); CheckHitTest(descriptionRenderer, new Point(398, 594), HitTestKind.NormalText, 14, 14, -1, new RectangleF(325, 565, 200, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(451, 534), HitTestKind.OtherTextLine, 13, 13, 0, new RectangleF(5, 525, 520, 40)); }
void CheckCourse(string filename, CourseDesignator courseDesignator, bool addAllControls, string testName, RectangleF rect, CourseAppearance appearance) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; CourseLayout course; eventDB.Load(TestUtil.GetTestFile(filename)); eventDB.Validate(); // Create the course courseView = CourseView.CreateViewingCourseView(eventDB, courseDesignator); course = new CourseLayout(); course.SetLayerColor(CourseLayer.Descriptions, 0, "Black", 0, 0, 0, 1F, false); course.SetLayerColor(CourseLayer.MainCourse, 11, "Purple", 0.2F, 1.0F, 0.0F, 0.07F, false); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, appearance, course, CourseLayer.MainCourse); // Add all controls if requested. if (addAllControls && courseDesignator.IsNotAllControls) { courseView = CourseView.CreateFilteredAllControlsView(eventDB, new CourseDesignator[] { courseDesignator }, ControlPointKind.None, new CourseViewOptions() { showNonDescriptionSpecials = false, showDescriptionSpecials = true }); course.SetLayerColor(CourseLayer.AllControls, 12, "LightPurple", 0.1F, 0.5F, 0.0F, 0.0F, false); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, appearance, course, CourseLayer.AllControls); } // Render to a map Map map = course.RenderToMap(new CourseLayout.MapRenderOptions()); // Render map to the graphics. Bitmap bm = new Bitmap(1000, 1000); using (Graphics g = Graphics.FromImage(bm)) { RenderOptions options = new RenderOptions(); options.usePatternBitmaps = true; options.minResolution = (float)(rect.Width / bm.Width); options.renderTemplates = RenderTemplateOption.MapAndTemplates; g.ScaleTransform((float)(bm.Width / rect.Width), -(float)(bm.Height / rect.Height)); g.TranslateTransform(-rect.Left, -rect.Top - rect.Height); g.Clear(Color.White); using (map.Read()) map.Draw(new GDIPlus_GraphicsTarget(g), rect, options, null); } TestUtil.CheckBitmapsBase(bm, "courserenderer\\" + testName); }
public void HitTest() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; CourseLayout course; eventDB.Load(TestUtil.GetTestFile("courselayout\\marymoor1.coursescribe")); eventDB.Validate(); // Create the all controls course courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); CheckHitTest(course, new PointF(9.0F, 12.4F), 0, null, "Water: special:1 scale:1 location:(7.996275,12.34392)"); CheckHitTest(course, new PointF(54.7F, 12.2F), 0, null, null); CheckHitTest(course, new PointF(0.5F, 9.0F), 0, null, "Control: control:72 scale:1 location:(-0.7,10.3) gaps:"); CheckHitTest(course, new PointF(58.5F, -9.2F), 0, null, "Start: control:1 scale:1 location:(56.8,-8.7) orientation:0"); CheckHitTest(course, new PointF(46.6F, -15.9F), 0, null, @"Code: control:52 scale:1 text:52 top-left:(45.56,-12.18) font-name:Roboto Condensed font-style:Bold font-height:4.18"); // Create course 3 courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(3))); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); CheckHitTest(course, new PointF(-3.5F, 10.3F), 0, null, "Control: control:72 course-control:305 scale:1 location:(-0.7,10.3) gaps:"); CheckHitTest(course, new PointF(35.6F, 17.7F), 0, null, null); CheckHitTest(course, new PointF(59.2F, 18.5F), 0, null, "Leg: control:71 course-control:307 scale:1 course-control2:308 path:N(42.92,17.55)--N(71.88,19.05)"); CheckHitTest(course, new PointF(72.1F, 33.5F), 0, null, @"ControlNumber: control:75 course-control:311 scale:1 text:10 top-left:(66.57,37.12) font-name:Roboto font-style:Regular font-height:5.57"); CheckHitTest(course, new PointF(50.2F, -2.9F), 0, null, @"Finish: control:2 course-control:315 scale:1 location:(53.2,-2.8) gaps:"); // Add in all controls. Test with true and false for all Layers. courseView = CourseView.CreateFilteredAllControlsView(eventDB, new CourseDesignator[] { Designator(3) }, ControlPointKind.Normal, new CourseViewOptions() { showNonDescriptionSpecials = false, showDescriptionSpecials = true }); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, CourseLayer.AllControls); CheckHitTest(course, new PointF(5.1F, -5.1F), CourseLayer.All, null, @"Control: layer:12 control:76 scale:1 location:(5.6,-5.7) gaps:"); CheckHitTest(course, new PointF(5.1F, -5.1F), CourseLayer.MainCourse, null, null); // Test the type filter CheckHitTest(course, new PointF(59.2F, 18.5F), CourseLayer.MainCourse, (co => co is LegCourseObj), "Leg: control:71 course-control:307 scale:1 course-control2:308 path:N(42.92,17.55)--N(71.88,19.05)"); CheckHitTest(course, new PointF(59.2F, 18.5F), CourseLayer.MainCourse, (co => co is PointCourseObj), null); CheckHitTest(course, new PointF(-3.5F, 10.3F), CourseLayer.MainCourse, (co => co is PointCourseObj), "Control: control:72 course-control:305 scale:1 location:(-0.7,10.3) gaps:"); CheckHitTest(course, new PointF(-3.5F, 10.3F), CourseLayer.MainCourse, (co => co is LineCourseObj), null); }
public void AllControlsCourseView() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual, expected; eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); DumpCourseView(courseView, writer); actual = writer.ToString(); expected = @"Name='All controls', Kind='AllControls', CourseId=0 Total Length=0 Part Length=0 Total Climb=-1 ScoreColumn=-1 Total Score=0 Total Controls=17 0: [-1] Ids: 1, 0 1: [-1] Ids: 23, 0 2: [-1] Ids: 2, 0 3: [-1] Ids: 4, 0 4: [-1] Ids: 12, 0 5: [-1] Ids: 7, 0 6: [-1] Ids: 10, 0 7: [-1] Ids: 11, 0 8: [-1] Ids: 8, 0 9: [-1] Ids: 9, 0 10: [-1] Ids: 13, 0 11: [-1] Ids: 14, 0 12: [-1] Ids: 16, 0 13: [-1] Ids: 17, 0 14: [-1] Ids: 18, 0 15: [-1] Ids: 19, 0 16: [-1] Ids: 20, 0 17: [-1] Ids: 21, 0 18: [-1] Ids: 5, 0 19: [-1] Ids: 6, 0 20: [-1] Ids: 24, 0 21: [-1] Ids: 3, 0 22: [-1] Ids: 15, 0 23: [-1] Ids: 22, 0 Special 1 (FirstAid) Special 2 (OptCrossing) Special 4 (OOB) "; Assert.AreEqual(expected, actual); }
// Render the given course id (0 = all controls) and kind to a bitmap, and compare it to the saved version. internal void CheckRenderBitmap(string filename, Id <Course> id, PunchcardFormat format) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; eventDB.Load(filename); eventDB.Validate(); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(id)); Bitmap bmNew = RenderToBitmap(eventDB, courseView, format); TestUtil.CheckBitmapsBase(bmNew, GetBitmapFileName(eventDB, id, "")); }
public void HitTestMultiLine() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("descriptions\\sampleevent6.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, DesignatorFromCourseId(eventDB, CourseId(1))); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting); DescriptionLine[] description = descFormatter.CreateDescription(false); DescriptionRenderer descriptionRenderer = new DescriptionRenderer(symbolDB); descriptionRenderer.Description = description; descriptionRenderer.CellSize = 40; descriptionRenderer.Margin = 5; descriptionRenderer.DescriptionKind = DescriptionKind.Symbols; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 320, 80)); CheckHitTest(descriptionRenderer, new Point(13, 51), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 320, 80)); CheckHitTest(descriptionRenderer, new Point(178, 101), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(178, 141), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(178, 181), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(116, 213), HitTestKind.Header, 5, 5, 0, new RectangleF(5, 205, 120, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.Text; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 320, 80)); CheckHitTest(descriptionRenderer, new Point(13, 51), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 320, 80)); CheckHitTest(descriptionRenderer, new Point(178, 101), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(178, 141), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(178, 181), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(116, 213), HitTestKind.Header, 5, 5, 0, new RectangleF(5, 205, 120, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.SymbolsAndText; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 520, 80)); CheckHitTest(descriptionRenderer, new Point(13, 51), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 520, 80)); CheckHitTest(descriptionRenderer, new Point(178, 101), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 520, 120)); CheckHitTest(descriptionRenderer, new Point(178, 141), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 520, 120)); CheckHitTest(descriptionRenderer, new Point(178, 181), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 520, 120)); CheckHitTest(descriptionRenderer, new Point(116, 213), HitTestKind.Header, 5, 5, 0, new RectangleF(5, 205, 120, 40)); }
public void HideVariationCode() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("courserenderer\\Fake Relay.ppen")); eventDB.Validate(); VariationInfo[] variationInfos = QueryEvent.GetAllVariations(eventDB, CourseId(3)).ToArray(); CourseDesignator courseDesignator = new CourseDesignator(CourseId(3), variationInfos.First(vi => vi.CodeString == "BD")); CheckCourseBothAppearances("courserenderer\\Fake Relay.ppen", courseDesignator, false, "relayvariations_hidecode_1", RectangleF.FromLTRB(-80, -160, 180, 100)); variationInfos = QueryEvent.GetAllVariations(eventDB, CourseId(2)).ToArray(); courseDesignator = new CourseDesignator(CourseId(2), variationInfos.First(vi => vi.CodeString == "BD")); CheckCourseBothAppearances("courserenderer\\Fake Relay.ppen", courseDesignator, false, "relayvariations_hidecode_2", RectangleF.FromLTRB(-80, -160, 180, 100)); }
public void BoundingRect() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; CourseLayout course; eventDB.Load(TestUtil.GetTestFile("courselayout\\marymoor1.coursescribe")); eventDB.Validate(); // Create the all controls course courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); RectangleF bounding = course.BoundingRect(); RectangleF expected = new RectangleF(-16.41F, -34.3F, 152.17F, 79.95F); TestUtil.AssertEqualRect(expected, bounding, 0.01F, "Bounding rect all controls"); // Try course 1 courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(1))); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); bounding = course.BoundingRect(); expected = new RectangleF(-2.11F, -32.9F, 64.73F, 60.43F); TestUtil.AssertEqualRect(expected, bounding, 0.1F, "Bounding rect course 1"); // Try course with control descriptions on it. courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(10))); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); bounding = course.BoundingRect(); expected = new RectangleF(6.0F, -40.1F, 121.94F, 77.22F); TestUtil.AssertEqualRect(expected, bounding, 0.1F, "Bounding rect course 10"); // Do an empty course courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(11))); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); bounding = course.BoundingRect(); expected = RectangleF.FromLTRB(0, 0, 0, 0); TestUtil.AssertEqualRect(expected, bounding, 0.001F, "Bounding rect blank course"); }
public void DontUpdateCircleGapsForItemScaling() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("eventdb\\CircleGapScaling_MapScale_new.ppen")); eventDB.Validate(); ControlPoint control; control = eventDB.GetControl(ControlId(4)); Assert.IsTrue(control.gaps.Count == 1 && control.gaps.ContainsKey(5000)); control = eventDB.GetControl(ControlId(5)); Assert.IsTrue(control.gaps.Count == 1 && control.gaps.ContainsKey(10000)); control = eventDB.GetControl(ControlId(6)); Assert.IsTrue(control.gaps.Count == 1 && control.gaps.ContainsKey(15000)); }
public void ScoreCourseView() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual, expected; eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(5))); DumpCourseView(courseView, writer); actual = writer.ToString(); expected = @"Name='Score 4', Kind='Score', CourseId=5 Total Length=0 Part Length=0 Total Climb=-1 ScoreColumn=0 Total Score=155 Total Controls=11 0: [-1] Ids: 1,101 1: [-1] Ids: 17,109 2: [-1] Ids: 2,113 3: [-1] Ids: 7,114 4: [-1] Ids: 11,102 5: [-1] Ids: 8,115 6: [-1] Ids: 20,112 7: [-1] Ids: 5,107 8: [-1] Ids: 4,105 9: [-1] Ids: 16,108 10: [-1] Ids: 18,110 11: [-1] Ids: 19,111 12: [-1] Ids: 6,116 13: [-1] Ids: 3,104 14: [-1] Ids: 15,106 15: [-1] Ids: 22,103 Special 1 (FirstAid) Special 3 (Boundary) Special 4 (OOB) "; Assert.AreEqual(expected, actual); }
// Render the given course id (0 = all controls) and kind to a bitmap, and compare it to the saved version. internal void CheckRenderBitmapPixelAtATime(Id <Course> id, DescriptionKind kind) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; eventDB.Load(TestUtil.GetTestFile("descriptions\\sampleevent1.coursescribe")); eventDB.Validate(); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(id)); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting); DescriptionLine[] description = descFormatter.CreateDescription(false); Bitmap bmNew = RenderToBitmapPixelAtATime(symbolDB, description, kind); TestUtil.CheckBitmapsBase(bmNew, DescriptionBrowser.GetBitmapFileName(eventDB, id, "", kind)); }
public void StandardCourseViewWithCustomFirstNumber() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual, expected; eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent2.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, Designator(4)); DumpCourseView(courseView, writer); actual = writer.ToString(); expected = @"Name='SampleCourse4', Kind='Normal', CourseId=4 Total Length=4667.3 Part Length=4667.3 Total Climb=173 ScoreColumn=-1 Total Score=0 Total Controls=4 0: [ 0] Ids: 1, 11 Legs: (Next:1,Id:0,length:340.1) 1: [ 3] Ids: 11, 12 Legs: (Next:2,Id:0,length:537.76) 2: [-1] Ids: 22, 13 Legs: (Next:3,Id:0,length:245.73) 3: [-1] Ids: 3, 14 Legs: (Next:4,Id:0,length:112.54) 4: [ 4] Ids: 4, 15 Legs: (Next:5,Id:0,length:280.23) 5: [-1] Ids: 15, 16 Legs: (Next:6,Id:0,length:287.06) 6: [ 5] Ids: 5, 17 Legs: (Next:7,Id:0,length:1440) 7: [ 6] Ids: 18, 18 Legs: (Next:8,Id:0,length:1423.9) 8: [-1] Ids: 6, 19 Special 1 (FirstAid) Special 4 (OOB) Description 6 (Course 4) "; Assert.AreEqual(expected, actual); }
public void GetViewBounds() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); RectangleF bounds = courseView.GetViewBounds(); Assert.AreEqual(-51.4F, bounds.Left); Assert.AreEqual(-47.8F, bounds.Top); Assert.AreEqual(106.9F, bounds.Width); Assert.AreEqual(92.9F, bounds.Height, 0.0001); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(4))); Assert.AreEqual(new RectangleF(-51.4F, -39F, 96.8F, 84.1F), courseView.GetViewBounds()); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(5))); Assert.AreEqual(new RectangleF(-51.4F, -39F, 106.9F, 84.1F), courseView.GetViewBounds()); }
// Test the course description formatter with a given file and course private void TestCourseFormatter(string testFileName, CourseDesignator courseDesignator, bool createKey, string expected) { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual; eventDB.Load(TestUtil.GetTestFile(testFileName)); eventDB.Validate(); CourseView courseView; courseView = CourseView.CreateViewingCourseView(eventDB, courseDesignator); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting); DescriptionLine[] description = descFormatter.CreateDescription(createKey); DescriptionFormatter.DumpDescription(symbolDB, description, writer); actual = writer.ToString(); Assert.AreEqual(expected, actual); }
public void FilteredAllControlsCourseView() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual, expected; eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateFilteredAllControlsView(eventDB, new CourseDesignator[] { Designator(3), Designator(4) }, ControlPointKind.Normal, new CourseViewOptions() { showNonDescriptionSpecials = false, showDescriptionSpecials = true }); DumpCourseView(courseView, writer); actual = writer.ToString(); expected = @"Name='All controls', Kind='AllControls', CourseId=0 Total Length=0 Part Length=0 Total Climb=-1 ScoreColumn=-1 Total Score=0 Total Controls=12 0: [-1] Ids: 2, 0 1: [-1] Ids: 12, 0 2: [-1] Ids: 7, 0 3: [-1] Ids: 10, 0 4: [-1] Ids: 8, 0 5: [-1] Ids: 9, 0 6: [-1] Ids: 13, 0 7: [-1] Ids: 14, 0 8: [-1] Ids: 17, 0 9: [-1] Ids: 19, 0 10: [-1] Ids: 20, 0 11: [-1] Ids: 21, 0 "; Assert.AreEqual(expected, actual); }
public void DisplayAllCourses() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); CourseView courseView; DescriptionFormatter descFormatter; DescriptionLine[] description; eventDB.Load(TestUtil.GetTestFile("descformatter\\sampleevent1.coursescribe")); eventDB.Validate(); foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB)) { CourseDesignator designator; if (QueryEvent.HasVariations(eventDB, courseId)) { var variationInfo = QueryEvent.GetAllVariations(eventDB, courseId).First(); designator = new CourseDesignator(courseId, variationInfo); } else { designator = new CourseDesignator(courseId); } courseView = CourseView.CreateViewingCourseView(eventDB, designator); descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting); description = descFormatter.CreateDescription(false); DescriptionFormatter.DumpDescription(symbolDB, description, Console.Out); Console.WriteLine(); } courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting); description = descFormatter.CreateDescription(false); DescriptionFormatter.DumpDescription(symbolDB, description, Console.Out); }
public void ScoreCourseViewWithOrdinals() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual, expected; eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent3.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, Designator(5)); DumpCourseView(courseView, writer); actual = writer.ToString(); expected = @"Name='Score 4', Kind='Score', CourseId=5 Total Length=0 Part Length=0 Total Climb=-1 ScoreColumn=1 Total Score=155 Total Controls=11 0: [-1] Ids: 1,101 1: [ 1] Ids: 17,109 2: [ 2] Ids: 2,113 3: [ 3] Ids: 7,114 4: [ 4] Ids: 11,102 5: [ 5] Ids: 8,115 6: [ 6] Ids: 20,112 7: [ 7] Ids: 5,107 8: [ 8] Ids: 4,105 9: [ 9] Ids: 16,108 10: [10] Ids: 18,110 11: [11] Ids: 19,111 12: [-1] Ids: 6,116 13: [-1] Ids: 3,104 14: [-1] Ids: 15,106 15: [-1] Ids: 22,103 Special 1 (FirstAid) Special 3 (Boundary) Special 4 (OOB) "; Assert.AreEqual(expected, actual); }
public void HitTest() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; CourseLayout course; eventDB.Load(TestUtil.GetTestFile("courselayout\\marymoor1.coursescribe")); eventDB.Validate(); // Create the all controls course courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); CheckHitTest(course, new PointF(9.0F, 12.4F), 0, null, "Water: special:1 scale:1 location:(7.996275,12.34392)"); CheckHitTest(course, new PointF(54.7F, 12.2F), 0, null, null); CheckHitTest(course, new PointF(0.5F, 9.0F), 0, null, "Control: control:72 scale:1 location:(-0.7,10.3) gaps:"); CheckHitTest(course, new PointF(58.5F, -9.2F), 0, null, "Start: control:1 scale:1 location:(56.8,-8.7) orientation:0"); CheckHitTest(course, new PointF(46.6F, -15.9F), 0, null, @"Code: control:52 scale:1 text:52 top-left:(45.66,-12.22) font-name:Arial Narrow font-style:Bold font-height:4.18"); // Create course 3 courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(3))); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); CheckHitTest(course, new PointF(-3.5F, 10.3F), 0, null, "Control: control:72 course-control:305 scale:1 location:(-0.7,10.3) gaps:"); CheckHitTest(course, new PointF(35.6F, 17.7F), 0, null, null); CheckHitTest(course, new PointF(59.2F, 18.5F), 0, null, "Leg: control:71 course-control:307 scale:1 course-control2:308 path:N(42.92,17.55)--N(71.88,19.05)"); CheckHitTest(course, new PointF(72.1F, 33.5F), 0, null, @"ControlNumber: control:75 course-control:311 scale:1 text:10 top-left:(66.61,36.87) font-name:Arial font-style:Regular font-height:5.57"); CheckHitTest(course, new PointF(50.2F, -2.9F), 0, null, @"Finish: control:2 course-control:315 scale:1 location:(53.2,-2.8) gaps:"); // Add in all controls. Test with true and false for all Layers. courseView = CourseView.CreateFilteredAllControlsView(eventDB, new CourseDesignator[] { Designator(3) }, ControlPointKind.Normal, false, true); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, CourseLayer.AllControls); CheckHitTest(course, new PointF(5.1F, -5.1F), CourseLayer.All, null, @"Control: layer:2 control:76 scale:1 location:(5.6,-5.7) gaps:"); CheckHitTest(course, new PointF(5.1F, -5.1F), CourseLayer.MainCourse, null, null); // Test the type filter CheckHitTest(course, new PointF(59.2F, 18.5F), CourseLayer.MainCourse, (co => co is LegCourseObj), "Leg: control:71 course-control:307 scale:1 course-control2:308 path:N(42.92,17.55)--N(71.88,19.05)"); CheckHitTest(course, new PointF(59.2F, 18.5F), CourseLayer.MainCourse, (co => co is PointCourseObj), null); CheckHitTest(course, new PointF(-3.5F, 10.3F), CourseLayer.MainCourse, (co => co is PointCourseObj), "Control: control:72 course-control:305 scale:1 location:(-0.7,10.3) gaps:"); CheckHitTest(course, new PointF(-3.5F, 10.3F), CourseLayer.MainCourse, (co => co is LineCourseObj), null); }
// Render the given course id (0 = all controls) and kind to a bitmap, and compare it to the saved version. internal void CheckRenderBitmap(string filename, Id<Course> id, PunchcardFormat format) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; eventDB.Load(filename); eventDB.Validate(); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(id)); Bitmap bmNew = RenderToBitmap(eventDB, courseView, format); TestUtil.CheckBitmapsBase(bmNew, GetBitmapFileName(eventDB, id, "")); }
public void ExpandTextMapExchange() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; // Map Exchange eventDB.Load(TestUtil.GetTestFile("courseformat\\mapexchange1.ppen")); eventDB.Validate(); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(6))); string result; result = CourseFormatter.ExpandText(eventDB, courseView, "$(CourseName)"); Assert.AreEqual("Course 5", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CoursePart)"); Assert.AreEqual("", result); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(6), 0)); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CourseName)"); Assert.AreEqual("Course 5", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CoursePart)"); Assert.AreEqual("1", result); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(6), 3)); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CourseName)"); Assert.AreEqual("Course 5", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CoursePart)"); Assert.AreEqual("4", result); }
void CheckCourse(string testfileName, Id<Course> courseId, CourseLayer layer, string expected) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; CourseLayout course; eventDB.Load(TestUtil.GetTestFile(testfileName)); eventDB.Validate(); // Create the course courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(courseId)); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, layer); // Dump it to a string. StringWriter writer = new StringWriter(); course.Dump(writer); // Check that the string is correct. string actual = writer.ToString(); if (expected != actual) { for (int i = 0; i < Math.Min(expected.Length, actual.Length); ++i) if (actual[i] != expected[i]) { Console.WriteLine("Difference at -->{0}", actual.Substring(i, 30)); break; } } Assert.AreEqual(expected, writer.ToString()); }
// Render the given course id (0 = all controls) and kind to a bitmap, and compare it to the saved version. internal void CheckRenderBitmapPixelAtATime(Id<Course> id, DescriptionKind kind) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; eventDB.Load(TestUtil.GetTestFile("descriptions\\sampleevent1.coursescribe")); eventDB.Validate(); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(id)); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB); DescriptionLine[] description = descFormatter.CreateDescription(false); Bitmap bmNew = RenderToBitmapPixelAtATime(symbolDB, description, kind); TestUtil.CheckBitmapsBase(bmNew, DescriptionBrowser.GetBitmapFileName(eventDB, id, "", kind)); }
public void DisplayAllCourses() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; CourseLayout course; eventDB.Load(TestUtil.GetTestFile("courseformat\\marymoor1.coursescribe")); eventDB.Validate(); foreach (Id<Course> courseId in QueryEvent.SortedCourseIds(eventDB)) { courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(courseId)); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); course.Dump(Console.Out); Console.WriteLine(); } courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); course.Dump(Console.Out); }
public void HitTestRegular() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("descriptions\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(4))); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB); DescriptionLine[] description = descFormatter.CreateDescription(false); DescriptionRenderer descriptionRenderer = new DescriptionRenderer(symbolDB); descriptionRenderer.Description = description; descriptionRenderer.CellSize = 40; descriptionRenderer.Margin = 5; descriptionRenderer.DescriptionKind = DescriptionKind.Symbols; CheckHitTest(descriptionRenderer, new Point(201,36), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(79,50), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(145,80), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(289, 60), HitTestKind.Header, 1, 1, 2, new RectangleF(245, 45, 80, 40)); CheckHitTest(descriptionRenderer, new Point(175,216), HitTestKind.NormalBox, 5, 5,4, new RectangleF(165,205, 40, 40)); CheckHitTest(descriptionRenderer, new Point(285,365), HitTestKind.NormalBox, 9, 9,7, new RectangleF(285, 365, 40, 40)); CheckHitTest(descriptionRenderer, new Point(81,193), HitTestKind.Directive, 4, 4,0, new RectangleF(5,165, 320, 40)); CheckHitTest(descriptionRenderer, new Point(328,147), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(255, 427), HitTestKind.OtherTextLine, 10, 10, 0, new RectangleF(5, 405, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.Text; CheckHitTest(descriptionRenderer, new Point(201, 36), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(79, 50), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(145, 80), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(289, 60), HitTestKind.Header, 1, 1, 2, new RectangleF(245, 45, 80, 40)); CheckHitTest(descriptionRenderer, new Point(175, 216), HitTestKind.NormalText, 5, 5, -1, new RectangleF(85, 205, 240, 40)); CheckHitTest(descriptionRenderer, new Point(285, 365), HitTestKind.NormalText, 9, 9, -1, new RectangleF(85, 365, 240, 40)); CheckHitTest(descriptionRenderer, new Point(59, 302), HitTestKind.NormalBox, 7, 7, 1, new RectangleF(45,285, 40, 40)); CheckHitTest(descriptionRenderer, new Point(81, 193), HitTestKind.DirectiveText, 4, 4, -1, new RectangleF(5, 165, 320, 40)); CheckHitTest(descriptionRenderer, new Point(328, 147), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(255, 427), HitTestKind.OtherTextLine, 10, 10, 0, new RectangleF(5, 405, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.SymbolsAndText; CheckHitTest(descriptionRenderer, new Point(201, 36), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 520, 40)); CheckHitTest(descriptionRenderer, new Point(79, 50), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(145, 80), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(289, 60), HitTestKind.Header, 1, 1, 2, new RectangleF(245, 45, 80, 40)); CheckHitTest(descriptionRenderer, new Point(175, 216), HitTestKind.NormalBox, 5, 5, 4, new RectangleF(165, 205, 40, 40)); CheckHitTest(descriptionRenderer, new Point(285, 365), HitTestKind.NormalBox, 9, 9, 7, new RectangleF(285, 365, 40, 40)); CheckHitTest(descriptionRenderer, new Point(81, 193), HitTestKind.Directive, 4, 4, 0, new RectangleF(5, 165, 320, 40)); CheckHitTest(descriptionRenderer, new Point(431, 56), HitTestKind.None, 1, 1, -1, new RectangleF(325, 45, 200, 40)); CheckHitTest(descriptionRenderer, new Point(333, 131), HitTestKind.NormalText, 3, 3, -1, new RectangleF(325, 125, 200, 40)); CheckHitTest(descriptionRenderer, new Point(491,252), HitTestKind.DirectiveText, 6, 6, -1, new RectangleF(325, 245, 200, 40)); CheckHitTest(descriptionRenderer, new Point(527,433), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(255, 427), HitTestKind.OtherTextLine, 10, 10, 0, new RectangleF(5, 405, 520, 40)); }
public void BoundingRect() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; CourseLayout course; eventDB.Load(TestUtil.GetTestFile("courselayout\\marymoor1.coursescribe")); eventDB.Validate(); // Create the all controls course courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); RectangleF bounding = course.BoundingRect(); RectangleF expected = new RectangleF(-16.05F, -34.22F, 151.44F, 79.67F); TestUtil.AssertEqualRect(expected, bounding, 0.01F, "Bounding rect all controls"); // Try course 1 courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(1))); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); bounding = course.BoundingRect(); expected = RectangleF.FromLTRB(-2.1F, -32.6F, 62.6F, 27.3F); TestUtil.AssertEqualRect(expected, bounding, 0.1F, "Bounding rect course 1"); // Try course with control descriptions on it. courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(10))); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); bounding = course.BoundingRect(); expected = RectangleF.FromLTRB(6.0F, -40.1F, 127.9F, 36.9F); TestUtil.AssertEqualRect(expected, bounding, 0.1F, "Bounding rect course 10"); // Do an empty course courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(11))); course = new CourseLayout(); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, defaultCourseAppearance, course, 0); bounding = course.BoundingRect(); expected = RectangleF.FromLTRB(0,0,0,0); TestUtil.AssertEqualRect(expected, bounding, 0.001F, "Bounding rect blank course"); }
public void ClearTextAndSymbols() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual, expected; eventDB.Load(TestUtil.GetTestFile("descformatter\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(4))); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB); DescriptionLine[] description = descFormatter.CreateDescription(false); DescriptionFormatter.ClearTextAndSymbols(description); DescriptionFormatter.DumpDescription(symbolDB, description, writer); actual = writer.ToString(); expected = @" | | | | | | ( 1) | | | | | | | | | ( 11) | | | | | | | | | ( 22) | : | ( 4) | | | | | | | | | ( 15) | : | ( 5) | | | | | | | | | ( 18) | | | | | | | | | ( 6) | : | "; Assert.AreEqual(expected, actual); }
// Test the course description formatter with a given file and course private void TestCourseFormatter(string testFileName, CourseDesignator courseDesignator, bool createKey, string expected) { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual; eventDB.Load(TestUtil.GetTestFile(testFileName)); eventDB.Validate(); CourseView courseView; courseView = CourseView.CreateViewingCourseView(eventDB, courseDesignator); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB); DescriptionLine[] description = descFormatter.CreateDescription(createKey); DescriptionFormatter.DumpDescription(symbolDB, description, writer); actual = writer.ToString(); Assert.AreEqual(expected, actual); }
public void ScoreCourseFormatterNoScore() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual, expected; eventDB.Load(TestUtil.GetTestFile("descformatter\\sampleevent5.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, Designator(5)); DescriptionLine[] description = new DescriptionFormatter(courseView, symbolDB).CreateDescription(false); DescriptionFormatter.DumpDescription(symbolDB, description, writer); actual = writer.ToString(); expected = @" | Sample Event 1 | [Sample Event 1] | Score more! | [Score more!] |Score 4 |155 points | [155 points] ( 1) |start| | | 2.8| 8.5| | | | [Start: open bare rock] ( 17) | 1| 302| | 1.14| | |11.1S| | [S side of pit] ( 2) | 2| 31| 0.3| 2.4| | 2m| | | [Upper boulder, 2m high] ( 7) | 3| 189| | 1.8| 1.8| 10.2| | | [Small gully junction] ( 11) | 4| 191| | 5.2| 5.2| 10.1|11.15| | [Between path crossings] ( 8) | 5| 210| | 5.11| 5.20| |11.15| | [Between building and statue] ( 20) | 6| 305| | 2.7| | 6x7| | 12.4| [Stony ground, 6m by 7m (manned)] ( 5) | 7| GO| 0.1N| 5.5| 5.2| 10.1|11.1N| 12.3| [N side of N power line and path crossing (radio)] ( 4) | 8| 32| | 3.7| | | | 12.1| [very marshy spot] ( 16) | 9| 301| | 1.14| 8.4| 3.0| | | [Overgrown pit, 3m deep] ( 18) | 10| 303| | 1.3| | 4| | | [Reentrant, 4m deep] ( 19) | 11| 304| 0.1S| | 8.5| | | | [S ] "; Assert.AreEqual(expected, actual); }
public void HitTestScore() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("descriptions\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(5))); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB); DescriptionLine[] description = descFormatter.CreateDescription(false); DescriptionRenderer descriptionRenderer = new DescriptionRenderer(symbolDB); descriptionRenderer.Description = description; descriptionRenderer.CellSize = 40; descriptionRenderer.Margin = 5; descriptionRenderer.DescriptionKind = DescriptionKind.Symbols; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(178,51), HitTestKind.SecondaryTitle, 1, 1, 0, new RectangleF(5, 45, 320, 40)); CheckHitTest(descriptionRenderer, new Point(116, 93), HitTestKind.Header, 2, 2, 0, new RectangleF(5, 85, 120, 40)); CheckHitTest(descriptionRenderer, new Point(259, 118), HitTestKind.Header, 2, 2, 1, new RectangleF(125, 85, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38, 137), HitTestKind.NormalBox, 3, 3, 0, new RectangleF(5, 125, 40, 40)); CheckHitTest(descriptionRenderer, new Point(226, 260), HitTestKind.NormalBox, 6, 6, 5, new RectangleF(205, 245, 40, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(228,534), HitTestKind.OtherTextLine, 13, 13,0, new RectangleF(5, 525, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.Text; CheckHitTest(descriptionRenderer, new Point(311, 12), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(178, 51), HitTestKind.SecondaryTitle, 1, 1, 0, new RectangleF(5, 45, 320, 40)); CheckHitTest(descriptionRenderer, new Point(16, 112), HitTestKind.Header, 2, 2, 0, new RectangleF(5, 85, 120, 40)); CheckHitTest(descriptionRenderer, new Point(178, 116), HitTestKind.Header, 2, 2, 1, new RectangleF(125, 85, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38, 137), HitTestKind.NormalBox, 3, 3, 0, new RectangleF(5, 125, 40, 40)); CheckHitTest(descriptionRenderer, new Point(182, 234), HitTestKind.NormalText, 5, 5, -1, new RectangleF(85, 205, 240, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(228, 534), HitTestKind.OtherTextLine, 13, 13, 0, new RectangleF(5, 525, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.SymbolsAndText; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 520, 40)); CheckHitTest(descriptionRenderer, new Point(178, 51), HitTestKind.SecondaryTitle, 1, 1, 0, new RectangleF(5, 45, 520, 40)); CheckHitTest(descriptionRenderer, new Point(434, 25), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 520, 40)); CheckHitTest(descriptionRenderer, new Point(116, 93), HitTestKind.Header, 2, 2, 0, new RectangleF(5, 85, 120, 40)); CheckHitTest(descriptionRenderer, new Point(259, 118), HitTestKind.Header, 2, 2, 1, new RectangleF(125, 85, 200, 40)); CheckHitTest(descriptionRenderer, new Point(380, 116), HitTestKind.None, 2, 2, -1, new RectangleF(325, 85, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38, 137), HitTestKind.NormalBox, 3, 3, 0, new RectangleF(5, 125, 40, 40)); CheckHitTest(descriptionRenderer, new Point(226, 260), HitTestKind.NormalBox, 6, 6, 5, new RectangleF(205, 245, 40, 40)); CheckHitTest(descriptionRenderer, new Point(398, 594), HitTestKind.NormalText, 14, 14, -1, new RectangleF(325, 565, 200, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(451, 534), HitTestKind.OtherTextLine, 13, 13, 0, new RectangleF(5, 525, 520, 40)); }
// Render the given course id (0 = all controls) and kind to a map, and compare it to the saved version. internal void CheckRenderMap(string filename, Id<Course> id, DescriptionKind kind, int numColumns = 1) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; eventDB.Load(filename); eventDB.Validate(); courseView = CourseView.CreateViewingCourseView(eventDB, DesignatorFromCourseId(eventDB, id)); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB); DescriptionLine[] description = descFormatter.CreateDescription(kind == DescriptionKind.Symbols); Bitmap bmNew = RenderToMapThenToBitmap(symbolDB, description, kind, numColumns); if (numColumns > 1) TestUtil.CheckBitmapsBase(bmNew, DescriptionBrowser.GetBitmapFileName(eventDB, id, "_ocad_" + numColumns + "col", kind)); else TestUtil.CheckBitmapsBase(bmNew, DescriptionBrowser.GetBitmapFileName(eventDB, id, "_ocad", kind)); }
public void ExpandText() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; eventDB.Load(TestUtil.GetTestFile("courseformat\\marymoor6.coursescribe")); eventDB.Validate(); // Use course 1 courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(1))); string result; result = CourseFormatter.ExpandText(eventDB, courseView, "Simple text"); Assert.AreEqual("Simple text", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$10 bill < $20 bill"); Assert.AreEqual("$10 bill < $20 bill", result); result = CourseFormatter.ExpandText(eventDB, courseView, ""); Assert.AreEqual("", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CourseName)"); Assert.AreEqual("Course 1", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CoursePart)"); Assert.AreEqual("", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(EventTitle): $(CourseName)"); Assert.AreEqual("Marymoor WIOL 2 The remake: Course 1", result); result = CourseFormatter.ExpandText(eventDB, courseView, "Course: $(CourseName) Length: $(CourseLength) km Scale: $(PrintScale)"); Assert.AreEqual("Course: Course 1 Length: 1.5 km Scale: 1:7,500", result); result = CourseFormatter.ExpandText(eventDB, courseView, "Course: $(CourseName) Climb: $(CourseClimb) m"); Assert.AreEqual("Course: Course 1 Climb: 20 m", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CourseName) / $(ClassList)"); Assert.AreEqual("Course 1 / This is cool very cool", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(Variation)"); Assert.AreEqual("", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(RelayTeam)"); Assert.AreEqual("--", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(RelayLeg)"); Assert.AreEqual("-", result); // All Controls courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); result = CourseFormatter.ExpandText(eventDB, courseView, "Course: $(CourseName) Length: $(CourseLength) km Scale: $(PrintScale)"); Assert.AreEqual("Course: All controls Length: 0.0 km Scale: 1:10,000", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CourseName) / $(ClassList)"); Assert.AreEqual("All controls / ", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CoursePart)"); Assert.AreEqual("", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(Variation)"); Assert.AreEqual("", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(RelayTeam)"); Assert.AreEqual("--", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(RelayLeg)"); Assert.AreEqual("-", result); }
public void ExpandTextRelay() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; string result; eventDB.Load(TestUtil.GetTestFile("queryevent\\variations.ppen")); eventDB.Validate(); // Use course 1 List<VariationInfo> variations = QueryEvent.GetAllVariations(eventDB, CourseId(1)).ToList(); courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(1), variations[0])); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CourseName)"); Assert.AreEqual("Course 1", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(Variation)"); Assert.AreEqual("ACDEFH", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(RelayTeam)"); Assert.AreEqual("--", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(RelayLeg)"); Assert.AreEqual("-", result); CourseDesignator designator = QueryEvent.EnumerateCourseDesignators(eventDB, new[] { CourseId(1) }, new Dictionary<Id<Course>, VariationChoices>() { { CourseId(1), new VariationChoices() { Kind = VariationChoices.VariationChoicesKind.ChosenTeams, FirstTeam = 4, LastTeam = 6 } } }, true).Skip(1).First(); courseView = CourseView.CreateViewingCourseView(eventDB, designator); result = CourseFormatter.ExpandText(eventDB, courseView, "$(CourseName)"); Assert.AreEqual("Course 1", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(Variation)"); Assert.AreEqual("ADEFCH", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(RelayTeam)"); Assert.AreEqual("4", result); result = CourseFormatter.ExpandText(eventDB, courseView, "$(RelayLeg)"); Assert.AreEqual("2", result); }
public void SingleVariation() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("queryevent\\variations.ppen")); eventDB.Validate(); VariationInfo.VariationPath variationPath = new VariationInfo.VariationPath(new[] { CourseControlId(2), CourseControlId(27), CourseControlId(30), CourseControlId(26), CourseControlId(25), CourseControlId(4), CourseControlId(28), }); VariationInfo variationInfo = new VariationInfo("AEFDCI", variationPath); CourseDesignator courseDesignator = new CourseDesignator(CourseId(1), variationInfo); CheckCourseBothAppearances("queryevent\\variations.ppen", courseDesignator, false, "singlevariation", new RectangleF(-15, -100, 230, 230)); }
public void AllControlsCourseView() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual, expected; eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); DumpCourseView(courseView, writer); actual = writer.ToString(); expected = @"Name='All controls', Kind='AllControls', CourseId=0 Total Length=0 Part Length=0 Total Climb=-1 ScoreColumn=-1 Total Score=0 Total Controls=17 0: [-1] Ids: 1, 0 1: [-1] Ids: 23, 0 2: [-1] Ids: 2, 0 3: [-1] Ids: 4, 0 4: [-1] Ids: 12, 0 5: [-1] Ids: 7, 0 6: [-1] Ids: 10, 0 7: [-1] Ids: 11, 0 8: [-1] Ids: 8, 0 9: [-1] Ids: 9, 0 10: [-1] Ids: 13, 0 11: [-1] Ids: 14, 0 12: [-1] Ids: 16, 0 13: [-1] Ids: 17, 0 14: [-1] Ids: 18, 0 15: [-1] Ids: 19, 0 16: [-1] Ids: 20, 0 17: [-1] Ids: 21, 0 18: [-1] Ids: 5, 0 19: [-1] Ids: 6, 0 20: [-1] Ids: 24, 0 21: [-1] Ids: 3, 0 22: [-1] Ids: 15, 0 23: [-1] Ids: 22, 0 Special 1 (FirstAid) Special 2 (OptCrossing) Special 3 (Boundary) Special 4 (OOB) Special 5 (Text) "; Assert.AreEqual(expected, actual); }
void CheckCourse(string filename, CourseDesignator courseDesignator, bool addAllControls, string testName, RectangleF rect, CourseAppearance appearance) { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); CourseView courseView; CourseLayout course; eventDB.Load(TestUtil.GetTestFile(filename)); eventDB.Validate(); // Create the course courseView = CourseView.CreateViewingCourseView(eventDB, courseDesignator); course = new CourseLayout(); course.SetLayerColor(CourseLayer.Descriptions, 0, "Black", 0, 0, 0, 1F, false); course.SetLayerColor(CourseLayer.MainCourse, 11, "Purple", 0.2F, 1.0F, 0.0F, 0.07F, false); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, appearance, course, CourseLayer.MainCourse); // Add all controls if requested. if (addAllControls && courseDesignator.IsNotAllControls) { courseView = CourseView.CreateFilteredAllControlsView(eventDB, new CourseDesignator[] { courseDesignator }, ControlPointKind.None, false, true); course.SetLayerColor(CourseLayer.AllControls, 12, "LightPurple", 0.1F, 0.5F, 0.0F, 0.0F, false); CourseFormatter.FormatCourseToLayout(symbolDB, courseView, appearance, course, CourseLayer.AllControls); } // Render to a map Map map = course.RenderToMap(); // Render map to the graphics. Bitmap bm = new Bitmap(1000,1000); using (Graphics g = Graphics.FromImage(bm)) { RenderOptions options = new RenderOptions(); options.usePatternBitmaps = true; options.minResolution = (float) (rect.Width / bm.Width); options.renderTemplates = RenderTemplateOption.MapAndTemplates; g.ScaleTransform((float) (bm.Width / rect.Width), - (float) (bm.Height / rect.Height)); g.TranslateTransform(-rect.Left, -rect.Top-rect.Height); g.Clear(Color.White); using (map.Read()) map.Draw(new GDIPlus_GraphicsTarget(g), rect, options, null); } TestUtil.CheckBitmapsBase(bm, "courserenderer\\" + testName); }
public void HitTestAllControls() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("descriptions\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB); DescriptionLine[] description = descFormatter.CreateDescription(false); DescriptionRenderer descriptionRenderer = new DescriptionRenderer(symbolDB); descriptionRenderer.Description = description; descriptionRenderer.CellSize = 40; descriptionRenderer.Margin = 5; descriptionRenderer.DescriptionKind = DescriptionKind.Symbols; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(116, 53), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(259,78), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38,97), HitTestKind.NormalBox, 2, 2, 0, new RectangleF(5,85, 40, 40)); CheckHitTest(descriptionRenderer, new Point(226,260), HitTestKind.NormalBox, 6, 6, 5, new RectangleF(205,245, 40, 40)); CheckHitTest(descriptionRenderer, new Point(68,999), HitTestKind.Directive, 24, 24, 0, new RectangleF(5, 965, 320, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(262,745), HitTestKind.OtherTextLine, 18, 18,0, new RectangleF(5, 725, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.Text; CheckHitTest(descriptionRenderer, new Point(311,12), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 320, 40)); CheckHitTest(descriptionRenderer, new Point(16,82), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(178,76), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38, 97), HitTestKind.NormalBox, 2, 2, 0, new RectangleF(5, 85, 40, 40)); CheckHitTest(descriptionRenderer, new Point(182,234), HitTestKind.NormalText, 5, 5, -1, new RectangleF(85,205, 240, 40)); CheckHitTest(descriptionRenderer, new Point(60,942), HitTestKind.DirectiveText, 23, 23,-1, new RectangleF(5,925, 320, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(262,745), HitTestKind.OtherTextLine, 18, 18,0, new RectangleF(5, 725, 320, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.SymbolsAndText; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 520, 40)); CheckHitTest(descriptionRenderer, new Point(434, 25), HitTestKind.Title, 0, 0, 0, new RectangleF(5, 5, 520, 40)); CheckHitTest(descriptionRenderer, new Point(116, 53), HitTestKind.Header, 1, 1, 0, new RectangleF(5, 45, 120, 40)); CheckHitTest(descriptionRenderer, new Point(259, 78), HitTestKind.Header, 1, 1, 1, new RectangleF(125, 45, 200, 40)); CheckHitTest(descriptionRenderer, new Point(380, 76), HitTestKind.None, 1, 1, -1, new RectangleF(325,45, 200, 40)); CheckHitTest(descriptionRenderer, new Point(38, 97), HitTestKind.NormalBox, 2, 2, 0, new RectangleF(5, 85, 40, 40)); CheckHitTest(descriptionRenderer, new Point(226, 260), HitTestKind.NormalBox, 6, 6, 5, new RectangleF(205, 245, 40, 40)); CheckHitTest(descriptionRenderer, new Point(68, 999), HitTestKind.Directive, 24, 24, 0, new RectangleF(5, 965, 320, 40)); CheckHitTest(descriptionRenderer, new Point(398,554), HitTestKind.NormalText, 13, 13, -1, new RectangleF(325,525, 200, 40)); CheckHitTest(descriptionRenderer, new Point(401, 934), HitTestKind.DirectiveText, 23, 23, -1, new RectangleF(325, 925, 200, 40)); CheckHitTest(descriptionRenderer, new Point(3, 184), HitTestKind.None, -1, -1, -1, new RectangleF(0, 0, 0, 0)); CheckHitTest(descriptionRenderer, new Point(262,745), HitTestKind.OtherTextLine, 18, 18,0, new RectangleF(5, 725, 520, 40)); }
public void ScoreDescriptionSpecialsOnly() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); StringWriter writer = new StringWriter(); string actual, expected; eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent1.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreatePositioningCourseView(eventDB, new CourseDesignator(CourseId(5))); DumpCourseView(courseView, writer); actual = writer.ToString(); expected = @"Name='Score 4', Kind='Score', CourseId=5 Total Length=0 Part Length=0 Total Climb=-1 ScoreColumn=0 Total Score=155 Total Controls=11 0: [-1] Ids: 1,101 1: [-1] Ids: 17,109 2: [-1] Ids: 2,113 3: [-1] Ids: 7,114 4: [-1] Ids: 11,102 5: [-1] Ids: 8,115 6: [-1] Ids: 20,112 7: [-1] Ids: 5,107 8: [-1] Ids: 4,105 9: [-1] Ids: 16,108 10: [-1] Ids: 18,110 11: [-1] Ids: 19,111 12: [-1] Ids: 6,116 13: [-1] Ids: 3,104 14: [-1] Ids: 15,106 15: [-1] Ids: 22,103 "; Assert.AreEqual(expected, actual); }
public void HitTestMultiLine() { SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("descriptions\\sampleevent6.coursescribe")); eventDB.Validate(); CourseView courseView = CourseView.CreateViewingCourseView(eventDB, DesignatorFromCourseId(eventDB, CourseId(1))); DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB); DescriptionLine[] description = descFormatter.CreateDescription(false); DescriptionRenderer descriptionRenderer = new DescriptionRenderer(symbolDB); descriptionRenderer.Description = description; descriptionRenderer.CellSize = 40; descriptionRenderer.Margin = 5; descriptionRenderer.DescriptionKind = DescriptionKind.Symbols; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 320, 80)); CheckHitTest(descriptionRenderer, new Point(13, 51), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 320, 80)); CheckHitTest(descriptionRenderer, new Point(178, 101), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(178, 141), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(178, 181), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(116, 213), HitTestKind.Header, 5, 5, 0, new RectangleF(5, 205, 120, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.Text; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 320, 80)); CheckHitTest(descriptionRenderer, new Point(13, 51), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 320, 80)); CheckHitTest(descriptionRenderer, new Point(178, 101), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(178, 141), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(178, 181), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 320, 120)); CheckHitTest(descriptionRenderer, new Point(116, 213), HitTestKind.Header, 5, 5, 0, new RectangleF(5, 205, 120, 40)); descriptionRenderer.DescriptionKind = DescriptionKind.SymbolsAndText; CheckHitTest(descriptionRenderer, new Point(143, 22), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 520, 80)); CheckHitTest(descriptionRenderer, new Point(13, 51), HitTestKind.Title, 0, 1, 0, new RectangleF(5, 5, 520, 80)); CheckHitTest(descriptionRenderer, new Point(178, 101), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 520, 120)); CheckHitTest(descriptionRenderer, new Point(178, 141), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 520, 120)); CheckHitTest(descriptionRenderer, new Point(178, 181), HitTestKind.SecondaryTitle, 2, 4, 0, new RectangleF(5, 85, 520, 120)); CheckHitTest(descriptionRenderer, new Point(116, 213), HitTestKind.Header, 5, 5, 0, new RectangleF(5, 205, 120, 40)); }
public void DisplayAllCourses() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml")); CourseView courseView; DescriptionFormatter descFormatter; DescriptionLine[] description; eventDB.Load(TestUtil.GetTestFile("descformatter\\sampleevent1.coursescribe")); eventDB.Validate(); foreach (Id<Course> courseId in QueryEvent.SortedCourseIds(eventDB)) { CourseDesignator designator; if (QueryEvent.HasVariations(eventDB, courseId)) { var variationInfo = QueryEvent.GetAllVariations(eventDB, courseId).First(); designator = new CourseDesignator(courseId, variationInfo); } else { designator = new CourseDesignator(courseId); } courseView = CourseView.CreateViewingCourseView(eventDB, designator); descFormatter = new DescriptionFormatter(courseView, symbolDB); description = descFormatter.CreateDescription(false); DescriptionFormatter.DumpDescription(symbolDB, description, Console.Out); Console.WriteLine(); } courseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls); descFormatter = new DescriptionFormatter(courseView, symbolDB); description = descFormatter.CreateDescription(false); DescriptionFormatter.DumpDescription(symbolDB, description, Console.Out); }