Ejemplo n.º 1
0
        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.");
        }
Ejemplo n.º 2
0
 public CourseSelectorTestForm(EventDB eventDB)
 {
     InitializeComponent();
     this.courseSelector1.EventDB = eventDB;
     this.courseSelector1.ShowAllControls = true;
     this.courseSelector1.SelectedCourseDesignators = new CourseDesignator[] { CourseDesignator.AllControls, new CourseDesignator(new Id<Course>(2), 1), new CourseDesignator(new Id<Course>(3)), new CourseDesignator(new Id<Course>(6)) };
 }
Ejemplo n.º 3
0
	public DBManager(){
		mainDB = new MainDB ();
		supervillainsDB = new SupervillainsDB ();
		schoolClassDB = new SchoolClassDB ();
		buildingDB = new BuildingDB (schoolClassDB);
		researchDB = new ResearchDB ();
		superHeroesDB = new SuperheroesDB ();
		superPowersDB = new SuperPowersDB();
		eventDB = new EventDB();
	}
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public void Initialize(EventDB eventDB, SymbolDB symbolDB)
        {
            eventDB.Validate();

            this.eventDB = eventDB;
            this.symbolDB = symbolDB;
            descriptionControl1.SymbolDB = symbolDB;

            listBoxCourses.Items.Add(new CourseItem(eventDB, Id<Course>.None));
            foreach (Id<Course> courseId in QueryEvent.SortedCourseIds(eventDB)) {
                listBoxCourses.Items.Add(new CourseItem(eventDB, courseId));
            }

            listBoxCourses.SelectedIndex = 0;
        }
Ejemplo n.º 6
0
        // Get the file name for a bitmap description for testing purposes. CourseID == 0 means all controls. Extra
        // is an extra string to suffix to the base name. Does not end in .png unless specified in extra.
        public static string GetBitmapFileName(EventDB eventDB, Id<Course> courseId, string extra, DescriptionKind kind)
        {
            Course course = null;
            string name;

            if (courseId.IsNotNone)
                course = eventDB.GetCourse(courseId);

            if (course != null)
                name = course.name;
            else
                name = "Allcontrols";

            name = "descriptions\\" + name + "_" + kind.ToString() + extra;

            return name;
        }
Ejemplo n.º 7
0
        public void Event()
        {
            UndoMgr undomgr = new UndoMgr(5);
            EventDB eventDB = new EventDB(undomgr);

            Event e = eventDB.GetEvent();
            Assert.AreEqual(e.title, "");
            Assert.AreEqual(e.notes, null);
            Assert.AreEqual(e.mapType, MapType.None);

            Event e2 = new Event();
            e2.title = "Hello";
            e2.notes = "These are my notes";
            e2.mapType = MapType.OCAD;
            e2.mapFileName = "C:\\hello.ocad";

            undomgr.BeginCommand(198, "change event");
            eventDB.ChangeEvent(e2);
            undomgr.EndCommand(198);

            e = eventDB.GetEvent();
            Assert.AreEqual(e2, e);
        }
        // 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));
        }
Ejemplo n.º 9
0
        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 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 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));
        }
Ejemplo n.º 12
0
        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 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));
        }
Ejemplo n.º 14
0
        // 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, ""));
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
 // 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();
 }
Ejemplo n.º 17
0
        // Get the file name for a bitmap description for testing purposes. CourseID == 0 means all controls. Extra
        // is an extra string to suffix to the base name. Does not end in .png unless specified in extra.
        internal static string GetBitmapFileName(EventDB eventDB, Id<Course> courseId, string extra)
        {
            Course course = null;
            string name;

            if (courseId.IsNotNone)
                course = eventDB.GetCourse(courseId);

            if (course != null)
                name = course.name;
            else
                name = "Allcontrols";

            name = "punchcards\\" + name + extra;

            return name;
        }
Ejemplo n.º 18
0
 // 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();
 }
Ejemplo n.º 19
0
 public CourseItem(EventDB eventDB, Id<Course> id)
 {
     this.eventDB = eventDB;
     this.id = id;
 }
Ejemplo n.º 20
0
        public void Initialize(EventDB eventDB, SymbolDB symbolDB)
        {
            this.symbolDB = symbolDB;
            this.eventDB = eventDB;
            eventDB.Validate();

            popup = new SymbolPopup(symbolDB, 26);
            popup.Selected += PopupSelected;
            popup.Canceled += PopupCanceled;
            descriptionRenderer = new DescriptionRenderer(symbolDB);

            listBoxCourses.Items.Add(new CourseItem(eventDB, Id<Course>.None));
            foreach (Id<Course> courseId in QueryEvent.SortedCourseIds(eventDB)) {
                listBoxCourses.Items.Add(new CourseItem(eventDB, courseId));
            }

            comboBoxKind.SelectedIndex = 0;
            listBoxCourses.SelectedIndex = 0;
        }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
 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();
 }
Ejemplo n.º 23
0
        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);
        }
        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));
        }
Ejemplo n.º 25
0
        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());
        }
Ejemplo n.º 26
0
        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));
        }
Ejemplo n.º 27
0
        // Render a description to a bitmap for testing purposes. Hardcoded 70 pixel box size.
        internal static Bitmap RenderToBitmap(EventDB eventDB, CourseView courseView, PunchcardFormat format)
        {
            PunchesRenderer punchesRenderer = new PunchesRenderer(eventDB);
            punchesRenderer.CourseView = courseView;
            punchesRenderer.PunchcardFormat = format;
            punchesRenderer.CellSize = 70;
            punchesRenderer.Margin = 4;

            SizeF size = punchesRenderer.Measure();

            Bitmap bm = new Bitmap((int) size.Width, (int) size.Height);
            Graphics g = Graphics.FromImage(bm);

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

            g.Clear(Color.White);
            punchesRenderer.Draw(g, 0, 0, 0, punchesRenderer.Boxes.Height);

            g.Dispose();

            return bm;
        }
 public CourseDesignator DesignatorFromCourseId(EventDB eventDB, Id<Course> courseId)
 {
     CourseDesignator designator;
     if (QueryEvent.HasVariations(eventDB, courseId)) {
         var variationInfo = QueryEvent.GetAllVariations(eventDB, courseId).First();
         designator = new CourseDesignator(courseId, variationInfo);
     }
     else {
         designator = new CourseDesignator(courseId);
     }
     return designator;
 }
Ejemplo n.º 29
0
        public void Setup(string filename)
        {
            ui = TestUI.Create();
            controller = ui.controller;
            eventDB = controller.GetEventDB();

            string fileName = TestUtil.GetTestFile(filename);

            bool success = controller.LoadInitialFile(fileName, true);
            Assert.IsTrue(success);
        }
        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));
        }