Exemplo n.º 1
0
        public void HasChanged()
        {
            UndoMgr undomgr   = new UndoMgr(5);
            EventDB eventDB   = new EventDB(undomgr);
            long    changeNum = 0;

            Assert.IsTrue(changeNum < eventDB.ChangeNum);
            changeNum = eventDB.ChangeNum;

            undomgr.BeginCommand(61, "Command1");

            ControlPoint ctl1 = new ControlPoint(ControlPointKind.Start, null, new PointF(5, 0));

            ctl1.symbolIds[1] = "2.8";
            ctl1.symbolIds[2] = "8.5";
            eventDB.AddControlPoint(ctl1);

            undomgr.EndCommand(61);

            Assert.IsTrue(changeNum < eventDB.ChangeNum);
            changeNum = eventDB.ChangeNum;

            eventDB = new EventDB(undomgr);

            Assert.IsTrue(changeNum != eventDB.ChangeNum);
            changeNum = eventDB.ChangeNum;

            eventDB = new EventDB(undomgr);

            Assert.IsTrue(changeNum != eventDB.ChangeNum);
            changeNum = eventDB.ChangeNum;
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        public void Load()
        {
            UndoMgr undomgr = new UndoMgr(5);
            ObjectStore <TestObject> objstore = new ObjectStore <TestObject>(undomgr);

            string xmlText =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<testobjects>
  <testobject id=""2"" x=""8"" f=""9.4"">goodbye</testobject>
  <testobject id=""3"" x=""9"" f=""9.9"">bat</testobject>
  <testobject id=""4"" x=""11"" f=""1.4"">foo</testobject>
</testobjects>";

            XmlInput xmlinput = new XmlInput(new StringReader(xmlText), "testfile");

            xmlinput.CheckElement("testobjects");
            xmlinput.Read();

            objstore.Load(xmlinput);
            xmlinput.Dispose();

            TestUtil.TestEnumerableAnyOrder(objstore.AllPairs,
                                            new KeyValuePair <Id <TestObject>, TestObject>[] {
                new KeyValuePair <Id <TestObject>, TestObject>(new Id <TestObject>(3), new TestObject(9, "bat", 9.9F)),
                new KeyValuePair <Id <TestObject>, TestObject>(new Id <TestObject>(4), new TestObject(11, "foo", 1.4F)),
                new KeyValuePair <Id <TestObject>, TestObject>(new Id <TestObject>(2), new TestObject(8, "goodbye", 9.4F))
            });
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        // 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));
        }
Exemplo n.º 6
0
        public void UndoRedo()
        {
            UndoMgr undomgr = new UndoMgr(5);
            ObjectStore <TestObject> objstore = new ObjectStore <TestObject>(undomgr);

            undomgr.BeginCommand(57, "Command1");
            objstore.Add(new TestObject(5, "hello", 5.4F));
            objstore.Add(new TestObject(7, "hi", 3.4F));
            objstore.Add(new TestObject(9, "bat", 9.9F));
            undomgr.EndCommand(57);

            undomgr.BeginCommand(58, "Command2");
            objstore.Add(new TestObject(11, "foo", 1.4F));
            objstore.Replace(new Id <TestObject>(2), new TestObject(8, "goodbye", 9.4F));
            objstore.Remove(new Id <TestObject>(1));
            undomgr.EndCommand(58);

            TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(9, "bat", 9.9F), new TestObject(11, "foo", 1.4F), new TestObject(8, "goodbye", 9.4F) });

            undomgr.Undo();

            TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(5, "hello", 5.4F), new TestObject(7, "hi", 3.4F), new TestObject(9, "bat", 9.9F) });

            undomgr.Undo();

            TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { });

            undomgr.Redo();

            TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(5, "hello", 5.4F), new TestObject(7, "hi", 3.4F), new TestObject(9, "bat", 9.9F) });

            undomgr.Redo();

            TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(9, "bat", 9.9F), new TestObject(11, "foo", 1.4F), new TestObject(8, "goodbye", 9.4F) });
        }
Exemplo n.º 7
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, 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));
            }
        }
Exemplo n.º 8
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.");
        }
        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);
        }
Exemplo n.º 10
0
        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.");
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        public void ActiveTab()
        {
            bool success = controller.LoadInitialFile(TestUtil.GetTestFile("selectionmgr\\sampleevent1.coursescribe"), true);

            Assert.IsTrue(success);

            Assert.AreEqual(7, selectionMgr.TabCount);
            Assert.AreEqual(0, selectionMgr.ActiveTab);

            selectionMgr.ActiveTab = 5;
            Assert.AreEqual(5, selectionMgr.ActiveTab);

            UndoMgr undoMgr = controller.GetUndoMgr();
            EventDB eventDB = controller.GetEventDB();

            undoMgr.BeginCommand(197, "Add course");
            eventDB.AddCourse(new Course(CourseKind.Normal, "AAA", 15000, 1));
            undoMgr.EndCommand(197);

            Assert.AreEqual(6, selectionMgr.ActiveTab);

            undoMgr.BeginCommand(198, "Remove courses");
            eventDB.RemoveCourse(CourseId(1));
            undoMgr.EndCommand(198);

            Assert.AreEqual(0, selectionMgr.ActiveTab);
        }
Exemplo n.º 13
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();
 }
Exemplo n.º 14
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();
 }
Exemplo n.º 15
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();
 }
Exemplo n.º 16
0
        public void ValidateSampleEvent1()
        {
            UndoMgr undomgr = new UndoMgr(5);
            EventDB eventDB = new EventDB(undomgr);

            eventDB.Load(TestUtil.GetTestFile("eventdb\\sampleevent1.coursescribe"));
            eventDB.Validate();
        }
Exemplo n.º 17
0
        public void ValidateVariations1()
        {
            UndoMgr undomgr = new UndoMgr(5);
            EventDB eventDB = new EventDB(undomgr);

            eventDB.Load(TestUtil.GetTestFile("queryevent\\variations.ppen"));
            eventDB.Validate();
        }
Exemplo n.º 18
0
        public void Setup(string basename)
        {
            undomgr = new UndoMgr(10);
            eventDB = new EventDB(undomgr);

            eventDB.Load(TestUtil.GetTestFile(basename));
            eventDB.Validate();
        }
Exemplo n.º 19
0
        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));
        }
Exemplo n.º 20
0
        public void LoadModifySave()
        {
            Id <TestObject>          id;
            UndoMgr                  undomgr  = new UndoMgr(5);
            ObjectStore <TestObject> objstore = new ObjectStore <TestObject>(undomgr);

            string xmlText =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<testobjects>
  <testobject id=""2"" x=""8"" f=""9.4"">goodbye</testobject>
  <testobject id=""4"" x=""11"" f=""1.4"">foo</testobject>
</testobjects>";

            XmlInput xmlinput = new XmlInput(new StringReader(xmlText), "testfile");

            xmlinput.CheckElement("testobjects");
            xmlinput.Read();

            objstore.Load(xmlinput);
            xmlinput.Dispose();

            undomgr.BeginCommand(57, "Command1");
            id = objstore.Add(new TestObject(5, "hello", 5.4F));
            Assert.AreEqual(5, id.id);
            id = objstore.Add(new TestObject(9, "bat", 9.9F));
            Assert.AreEqual(6, id.id);
            undomgr.EndCommand(57);

            undomgr.BeginCommand(58, "Command2");
            objstore.Replace(new Id <TestObject>(2), new TestObject(-9, "elvis", 9.1F));
            objstore.Remove(new Id <TestObject>(4));
            undomgr.EndCommand(58);

            TextWriter    writer    = new StringWriter();
            XmlTextWriter xmloutput = new XmlTextWriter(writer);

            xmloutput.Formatting = Formatting.Indented;
            xmloutput.Namespaces = false;

            xmloutput.WriteStartDocument();
            xmloutput.WriteStartElement("testobjects");

            objstore.Save(xmloutput);

            xmloutput.WriteEndElement();
            xmloutput.WriteEndDocument();
            xmloutput.Close();

            Assert.AreEqual(
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<testobjects>
  <testobject id=""2"" x=""-9"" f=""9.1"">elvis</testobject>
  <testobject id=""5"" x=""5"" f=""5.4"">hello</testobject>
  <testobject id=""6"" x=""9"" f=""9.9"">bat</testobject>
</testobjects>",
                writer.ToString());
        }
Exemplo n.º 21
0
 public AddRectangleMode(Controller controller, UndoMgr undoMgr, SelectionMgr selectionMgr, EventDB eventDB, float aspectRatio, Func <RectangleF, CourseObj> createCourseObj, Func <RectangleF, Id <Special> > createSpecial)
 {
     this.controller      = controller;
     this.undoMgr         = undoMgr;
     this.selectionMgr    = selectionMgr;
     this.eventDB         = eventDB;
     this.aspectRatio     = aspectRatio;
     this.createCourseObj = createCourseObj;
     this.createSpecial   = createSpecial;
 }
Exemplo n.º 22
0
        PointCourseObj highlight;    // the highlight we are creating.

        public AddPointSpecialMode(Controller controller, SelectionMgr selectionMgr, UndoMgr undoMgr, EventDB eventDB, SpecialKind specialKind)
        {
            this.controller     = controller;
            this.selectionMgr   = selectionMgr;
            this.undoMgr        = undoMgr;
            this.eventDB        = eventDB;
            this.specialKind    = specialKind;
            this.appearance     = controller.GetCourseAppearance();
            this.courseObjRatio = selectionMgr.ActiveCourseView.CourseObjRatio(appearance);
        }
Exemplo n.º 23
0
 public AddRectangleMode(Controller controller, UndoMgr undoMgr, SelectionMgr selectionMgr, EventDB eventDB, float aspectRatio, Func<RectangleF, CourseObj> createCourseObj, Func<RectangleF, Id<Special>> createSpecial)
 {
     this.controller = controller;
     this.undoMgr = undoMgr;
     this.selectionMgr = selectionMgr;
     this.eventDB = eventDB;
     this.aspectRatio = aspectRatio;
     this.createCourseObj = createCourseObj;
     this.createSpecial = createSpecial;
 }
Exemplo n.º 24
0
        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));
        }
Exemplo n.º 25
0
 public AddDescriptionMode(Controller controller, UndoMgr undoMgr, SelectionMgr selectionMgr, EventDB eventDB, SymbolDB symbolDB, CourseDesignator courseDesignator, DescriptionLine[] description, DescriptionKind kind)
 {
     this.controller = controller;
     this.undoMgr = undoMgr;
     this.selectionMgr = selectionMgr;
     this.symbolDB = symbolDB;
     this.eventDB = eventDB;
     this.courseDesignator = courseDesignator;
     this.description = description;
     this.kind = kind;
 }
Exemplo n.º 26
0
        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));
        }
Exemplo n.º 27
0
 public AddDescriptionMode(Controller controller, UndoMgr undoMgr, SelectionMgr selectionMgr, EventDB eventDB, SymbolDB symbolDB, CourseDesignator courseDesignator, DescriptionLine[] description, DescriptionKind kind)
 {
     this.controller       = controller;
     this.undoMgr          = undoMgr;
     this.selectionMgr     = selectionMgr;
     this.symbolDB         = symbolDB;
     this.eventDB          = eventDB;
     this.courseDesignator = courseDesignator;
     this.description      = description;
     this.kind             = kind;
 }
Exemplo n.º 28
0
        BoundaryCourseObj highlight;                 // the highlight of the path we are creating.

        public AddLineAreaSpecialMode(Controller controller, SelectionMgr selectionMgr, UndoMgr undoMgr, EventDB eventDB, Func <PointF[], Id <Special> > createObject, bool isArea)
        {
            this.controller     = controller;
            this.selectionMgr   = selectionMgr;
            this.undoMgr        = undoMgr;
            this.eventDB        = eventDB;
            this.createObject   = createObject;
            this.isArea         = isArea;
            this.appearance     = controller.GetCourseAppearance();
            this.courseObjRatio = selectionMgr.ActiveCourseView.CourseObjRatio(appearance);
        }
Exemplo n.º 29
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,
                                                                      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);
        }
Exemplo n.º 30
0
        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);
        }
Exemplo n.º 31
0
 public AddTextMode(Controller controller, UndoMgr undoMgr, SelectionMgr selectionMgr, EventDB eventDB, string text, string fontName, bool fontBold, bool fontItalic, SpecialColor fontColor)
 {
     this.controller = controller;
     this.undoMgr = undoMgr;
     this.selectionMgr = selectionMgr;
     this.eventDB = eventDB;
     this.text = text;
     this.fontName = fontName;
     this.fontBold = fontBold;
     this.fontItalic = fontItalic;
     this.fontColor = fontColor;
     this.displayText = CourseFormatter.ExpandText(eventDB, selectionMgr.ActiveCourseView, text);
 }
Exemplo n.º 32
0
 public AddControlMode(Controller controller, SelectionMgr selectionMgr, UndoMgr undoMgr, EventDB eventDB, SymbolDB symbolDB, bool allControls, ControlPointKind controlKind, bool exchangeAtControl)
 {
     this.controller = controller;
     this.selectionMgr = selectionMgr;
     this.undoMgr = undoMgr;
     this.eventDB = eventDB;
     this.symbolDB = symbolDB;
     this.allControls = allControls;
     this.controlKind = controlKind;
     this.exchangeAtControl = exchangeAtControl;
     this.scaleRatio = selectionMgr.ActiveCourseView.ScaleRatio;
     this.appearance = controller.GetCourseAppearance();
 }
Exemplo n.º 33
0
 public AddTextMode(Controller controller, UndoMgr undoMgr, SelectionMgr selectionMgr, EventDB eventDB, string text, string fontName, bool fontBold, bool fontItalic, SpecialColor fontColor, float fontHeight)
 {
     this.controller   = controller;
     this.undoMgr      = undoMgr;
     this.selectionMgr = selectionMgr;
     this.eventDB      = eventDB;
     this.text         = text;
     this.fontName     = fontName;
     this.fontBold     = fontBold;
     this.fontItalic   = fontItalic;
     this.fontColor    = fontColor;
     this.fontHeight   = fontHeight;
     this.displayText  = CourseFormatter.ExpandText(eventDB, selectionMgr.ActiveCourseView, text);
 }
Exemplo n.º 34
0
        CourseObj[] additionalHighlights; // additional highlights to show also.

        public AddControlMode(Controller controller, SelectionMgr selectionMgr, UndoMgr undoMgr, EventDB eventDB, SymbolDB symbolDB, bool allControls, ControlPointKind controlKind, bool exchangeAtControl, MapIssueKind mapIssueKind)
        {
            this.controller        = controller;
            this.selectionMgr      = selectionMgr;
            this.undoMgr           = undoMgr;
            this.eventDB           = eventDB;
            this.symbolDB          = symbolDB;
            this.allControls       = allControls;
            this.controlKind       = controlKind;
            this.exchangeAtControl = exchangeAtControl;
            this.mapIssueKind      = mapIssueKind;
            this.appearance        = controller.GetCourseAppearance();
            this.courseObjRatio    = selectionMgr.ActiveCourseView.CourseObjRatio(appearance);
        }
Exemplo n.º 35
0
        public void AddRemove()
        {
            Id <TestObject>          id;
            TestObject               o, p;
            UndoMgr                  undomgr  = new UndoMgr(5);
            ObjectStore <TestObject> objstore = new ObjectStore <TestObject>(undomgr);

            undomgr.BeginCommand(57, "Command1");

            o  = new TestObject(5, "hello", 5.4F);
            id = objstore.Add(o);
            Assert.AreEqual(1, id.id);
            Assert.IsTrue(objstore.IsPresent(new Id <TestObject>(1)));
            p = objstore[new Id <TestObject>(1)];
            Assert.AreEqual(o, p);
            Assert.IsFalse(o == p);

            o  = new TestObject(6, "hi", 5.4F);
            id = objstore.Add(o);
            Assert.AreEqual(2, id.id);
            Assert.IsTrue(objstore.IsPresent(new Id <TestObject>(2)));
            p = objstore[new Id <TestObject>(2)];
            Assert.AreEqual(o, p);
            Assert.IsFalse(o == p);

            objstore.Remove(new Id <TestObject>(1));
            Assert.IsFalse(objstore.IsPresent(new Id <TestObject>(1)));

            o  = new TestObject(7, "xx", 1.1F);
            id = objstore.Add(o);
            Assert.AreEqual(3, id.id);
            Assert.IsTrue(objstore.IsPresent(new Id <TestObject>(3)));
            p = objstore[new Id <TestObject>(3)];
            Assert.AreEqual(o, p);
            Assert.IsFalse(o == p);

            objstore.Remove(new Id <TestObject>(3));

            int count = 0;

            foreach (TestObject x in objstore.All)
            {
                Assert.AreEqual(x, new TestObject(6, "hi", 5.4F));
                ++count;
            }
            Assert.AreEqual(1, count);

            undomgr.EndCommand(57);
        }
Exemplo n.º 36
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);
        }
Exemplo n.º 37
0
        public void AddRemove()
        {
            Id<TestObject> id;
            TestObject o, p;
            UndoMgr undomgr = new UndoMgr(5);
            ObjectStore<TestObject> objstore = new ObjectStore<TestObject>(undomgr);

            undomgr.BeginCommand(57, "Command1");

            o = new TestObject(5, "hello", 5.4F);
            id = objstore.Add(o);
            Assert.AreEqual(1, id.id);
            Assert.IsTrue(objstore.IsPresent(new Id<TestObject>(1)));
            p = objstore[new Id<TestObject>(1)];
            Assert.AreEqual(o, p);
            Assert.IsFalse(o == p);

            o = new TestObject(6, "hi", 5.4F);
            id = objstore.Add(o);
            Assert.AreEqual(2, id.id);
            Assert.IsTrue(objstore.IsPresent(new Id<TestObject>(2)));
            p = objstore[new Id<TestObject>(2)];
            Assert.AreEqual(o, p);
            Assert.IsFalse(o == p);

            objstore.Remove(new Id<TestObject>(1));
            Assert.IsFalse(objstore.IsPresent(new Id<TestObject>(1)));

            o = new TestObject(7, "xx", 1.1F);
            id = objstore.Add(o);
            Assert.AreEqual(3, id.id);
            Assert.IsTrue(objstore.IsPresent(new Id<TestObject>(3)));
            p = objstore[new Id<TestObject>(3)];
            Assert.AreEqual(o, p);
            Assert.IsFalse(o == p);

            objstore.Remove(new Id<TestObject>(3));

            int count = 0;
            foreach (TestObject x in objstore.All) {
                Assert.AreEqual(x, new TestObject(6, "hi", 5.4F));
                ++count;
            }
            Assert.AreEqual(1, count);

            undomgr.EndCommand(57);
        }
Exemplo n.º 38
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);
        }
        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));
        }
Exemplo n.º 40
0
        public void Save()
        {
            UndoMgr undomgr = new UndoMgr(5);
            ObjectStore<TestObject> objstore = new ObjectStore<TestObject>(undomgr);

            undomgr.BeginCommand(57, "Command1");
            objstore.Add(new TestObject(5, "hello", 5.4F));
            objstore.Add(new TestObject(7, "hi", 3.4F));
            objstore.Add(new TestObject(9, "bat", 9.9F));
            undomgr.EndCommand(57);

            undomgr.BeginCommand(58, "Command2");
            objstore.Add(new TestObject(11, "foo", 1.4F));
            objstore.Replace(new Id<TestObject>(2), new TestObject(8, "goodbye", 9.4F));
            objstore.Remove(new Id<TestObject>(1));
            undomgr.EndCommand(58);

            TextWriter writer = new StringWriter();
            XmlTextWriter xmloutput = new XmlTextWriter(writer);
            xmloutput.Formatting = Formatting.Indented;
            xmloutput.Namespaces = false;

            xmloutput.WriteStartDocument();
            xmloutput.WriteStartElement("testobjects");

            objstore.Save(xmloutput);

            xmloutput.WriteEndElement();
            xmloutput.WriteEndDocument();
            xmloutput.Close();

            Assert.AreEqual(
            @"<?xml version=""1.0"" encoding=""utf-16""?>
            <testobjects>
              <testobject id=""2"" x=""8"" f=""9.4"">goodbye</testobject>
              <testobject id=""3"" x=""9"" f=""9.9"">bat</testobject>
              <testobject id=""4"" x=""11"" f=""1.4"">foo</testobject>
            </testobjects>",
            writer.ToString());
        }
Exemplo n.º 41
0
        public void UndoRedo()
        {
            UndoMgr undomgr = new UndoMgr(5);
            ObjectStore<TestObject> objstore = new ObjectStore<TestObject>(undomgr);

            undomgr.BeginCommand(57, "Command1");
            objstore.Add(new TestObject(5, "hello", 5.4F));
            objstore.Add(new TestObject(7, "hi", 3.4F));
            objstore.Add(new TestObject(9, "bat", 9.9F));
            undomgr.EndCommand(57);

            undomgr.BeginCommand(58, "Command2");
            objstore.Add(new TestObject(11, "foo", 1.4F));
            objstore.Replace(new Id<TestObject>(2), new TestObject(8, "goodbye", 9.4F));
            objstore.Remove(new Id<TestObject>(1));
            undomgr.EndCommand(58);

            TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(9, "bat", 9.9F), new TestObject(11, "foo", 1.4F), new TestObject(8, "goodbye", 9.4F) });

            undomgr.Undo();

            TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(5, "hello", 5.4F), new TestObject(7, "hi", 3.4F), new TestObject(9, "bat", 9.9F) });

            undomgr.Undo();

            TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { });

            undomgr.Redo();

            TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(5, "hello", 5.4F), new TestObject(7, "hi", 3.4F), new TestObject(9, "bat", 9.9F) });

            undomgr.Redo();

            TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(9, "bat", 9.9F), new TestObject(11, "foo", 1.4F), new TestObject(8, "goodbye", 9.4F) });
        }
Exemplo n.º 42
0
        public void Present()
        {
            Id<TestObject> id;
            TestObject o;
            UndoMgr undomgr = new UndoMgr(5);
            ObjectStore<TestObject> objstore = new ObjectStore<TestObject>(undomgr);

            undomgr.BeginCommand(57, "Command1");

            o = new TestObject(5, "hello", 5.4F);
            id = objstore.Add(o);
            Assert.AreEqual(1, id.id);

            Assert.IsTrue(objstore.IsPresent(new Id<TestObject>(1)));
            Assert.IsFalse(objstore.IsPresent(new Id<TestObject>(2)));

            objstore.CheckPresent(new Id<TestObject>(1));
            try {
                objstore.IsPresent(new Id<TestObject>(2));
                Assert.Fail("should throw");
            }
            catch { }
        }
Exemplo n.º 43
0
        public void Replace()
        {
            Id<TestObject> id;
            TestObject o, p;
            UndoMgr undomgr = new UndoMgr(5);
            ObjectStore<TestObject> objstore = new ObjectStore<TestObject>(undomgr);

            undomgr.BeginCommand(57, "Command1");

            o = new TestObject(5, "hello", 5.4F);
            id = objstore.Add(o);
            Assert.AreEqual(1, id.id);
            Assert.IsTrue(objstore.IsPresent(new Id<TestObject>(1)));
            p = objstore[new Id<TestObject>(1)];
            Assert.AreEqual(o, p);
            Assert.IsFalse(o == p);

            o = new TestObject(6, "hi", 5.4F);
            id = objstore.Add(o);
            Assert.AreEqual(2, id.id);
            Assert.IsTrue(objstore.IsPresent(new Id<TestObject>(2)));
            p = objstore[new Id<TestObject>(2)];
            Assert.AreEqual(o, p);
            Assert.IsFalse(o == p);

            o = new TestObject(11, "mr ed", 9.7F);
            objstore.Replace(new Id<TestObject>(1), o);
            Assert.IsTrue(objstore.IsPresent(new Id<TestObject>(1)));
            p = objstore[new Id<TestObject>(1)];
            Assert.AreEqual(o, p);
            Assert.IsFalse(o == p);

            o = new TestObject(13, "baz", 2.4F);
            objstore.Replace(new Id<TestObject>(2), o);
            Assert.IsTrue(objstore.IsPresent(new Id<TestObject>(2)));
            p = objstore[new Id<TestObject>(2)];
            Assert.AreEqual(o, p);
            Assert.IsFalse(o == p);

            TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(11, "mr ed", 9.7F), new TestObject(13, "baz", 2.4F) });
        }
        // 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));
        }
Exemplo n.º 45
0
        public void LoadModifySave()
        {
            Id<TestObject> id;
            UndoMgr undomgr = new UndoMgr(5);
            ObjectStore<TestObject> objstore = new ObjectStore<TestObject>(undomgr);

            string xmlText =
            @"<?xml version=""1.0"" encoding=""utf-16""?>
            <testobjects>
              <testobject id=""2"" x=""8"" f=""9.4"">goodbye</testobject>
              <testobject id=""4"" x=""11"" f=""1.4"">foo</testobject>
            </testobjects>";

            XmlInput xmlinput = new XmlInput(new StringReader(xmlText), "testfile");

            xmlinput.CheckElement("testobjects");
            xmlinput.Read();

            objstore.Load(xmlinput);
            xmlinput.Dispose();

            undomgr.BeginCommand(57, "Command1");
            id = objstore.Add(new TestObject(5, "hello", 5.4F));
            Assert.AreEqual(5, id.id);
            id = objstore.Add(new TestObject(9, "bat", 9.9F));
            Assert.AreEqual(6, id.id);
            undomgr.EndCommand(57);

            undomgr.BeginCommand(58, "Command2");
            objstore.Replace(new Id<TestObject>(2), new TestObject(-9, "elvis", 9.1F));
            objstore.Remove(new Id<TestObject>(4));
            undomgr.EndCommand(58);

            TextWriter writer = new StringWriter();
            XmlTextWriter xmloutput = new XmlTextWriter(writer);
            xmloutput.Formatting = Formatting.Indented;
            xmloutput.Namespaces = false;

            xmloutput.WriteStartDocument();
            xmloutput.WriteStartElement("testobjects");

            objstore.Save(xmloutput);

            xmloutput.WriteEndElement();
            xmloutput.WriteEndDocument();
            xmloutput.Close();

            Assert.AreEqual(
            @"<?xml version=""1.0"" encoding=""utf-16""?>
            <testobjects>
              <testobject id=""2"" x=""-9"" f=""9.1"">elvis</testobject>
              <testobject id=""5"" x=""5"" f=""5.4"">hello</testobject>
              <testobject id=""6"" x=""9"" f=""9.9"">bat</testobject>
            </testobjects>",
            writer.ToString());
        }
Exemplo n.º 46
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);
        }
Exemplo n.º 47
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();
 }
        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));
        }
        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));
        }
Exemplo n.º 50
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());
        }
Exemplo n.º 51
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);
        }
        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));
        }
Exemplo n.º 53
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);
        }
Exemplo n.º 54
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);
        }
Exemplo n.º 55
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, ""));
        }
Exemplo n.º 56
0
        public void ChangeNum()
        {
            int changeNum;

            Id<TestObject> id;
            TestObject o;
            UndoMgr undomgr = new UndoMgr(5);
            ObjectStore<TestObject> objstore = new ObjectStore<TestObject>(undomgr);

            changeNum = objstore.ChangeNum;
            undomgr.BeginCommand(57, "Command1");

            o = new TestObject(5, "hello", 5.4F);
            id = objstore.Add(o);
            Assert.IsTrue(changeNum < objstore.ChangeNum);
            changeNum = objstore.ChangeNum;

            objstore.Remove(new Id<TestObject>(1));
            Assert.IsTrue(changeNum < objstore.ChangeNum);
            changeNum = objstore.ChangeNum;

            id = objstore.Add(o);
            Assert.IsTrue(changeNum < objstore.ChangeNum);
            changeNum = objstore.ChangeNum;

            objstore.Replace(new Id<TestObject>(2), o);
            Assert.IsTrue(changeNum < objstore.ChangeNum);
            changeNum = objstore.ChangeNum;

            undomgr.EndCommand(57);

            undomgr.Undo();
            Assert.IsTrue(changeNum < objstore.ChangeNum);
            changeNum = objstore.ChangeNum;

            undomgr.Redo();
            Assert.IsTrue(changeNum < objstore.ChangeNum);
            changeNum = objstore.ChangeNum;
        }
Exemplo n.º 57
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));
        }
Exemplo n.º 58
0
        public void Load()
        {
            UndoMgr undomgr = new UndoMgr(5);
            ObjectStore<TestObject> objstore = new ObjectStore<TestObject>(undomgr);

            string xmlText =
            @"<?xml version=""1.0"" encoding=""utf-16""?>
            <testobjects>
              <testobject id=""2"" x=""8"" f=""9.4"">goodbye</testobject>
              <testobject id=""3"" x=""9"" f=""9.9"">bat</testobject>
              <testobject id=""4"" x=""11"" f=""1.4"">foo</testobject>
            </testobjects>";

            XmlInput xmlinput = new XmlInput(new StringReader(xmlText), "testfile");

            xmlinput.CheckElement("testobjects");
            xmlinput.Read();

            objstore.Load(xmlinput);
            xmlinput.Dispose();

            TestUtil.TestEnumerableAnyOrder(objstore.AllPairs,
                                        new KeyValuePair<Id<TestObject>, TestObject>[] {
                                        new KeyValuePair<Id<TestObject>, TestObject>(new Id<TestObject>(3), new TestObject(9, "bat", 9.9F)),
                                        new KeyValuePair<Id<TestObject>, TestObject>(new Id<TestObject>(4), new TestObject(11, "foo", 1.4F)),
                                        new KeyValuePair<Id<TestObject>, TestObject>(new Id<TestObject>(2), new TestObject(8, "goodbye", 9.4F)) });
        }
Exemplo n.º 59
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);
        }
        // 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));
        }