Exemple #1
0
        public void DescriptionSpecialsOnly()
        {
            UndoMgr      undomgr = new UndoMgr(5);
            EventDB      eventDB = new EventDB(undomgr);
            SymbolDB     symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml"));
            StringWriter writer = new StringWriter();
            string       actual, expected;

            eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent1.coursescribe"));
            eventDB.Validate();

            CourseView courseView = CourseView.CreatePositioningCourseView(eventDB, new CourseDesignator(CourseId(4)));

            DumpCourseView(courseView, writer);
            actual   = writer.ToString();
            expected =
                @"Name='SampleCourse4', Kind='Normal', CourseId=4
Total Length=4667.3  Part Length=4667.3  Total Climb=173  ScoreColumn=-1  Total Score=0  Total Controls=4
 0: [ 0] Ids:  1, 11
    Legs: (Next:1,Id:0,length:340.1)  
 1: [ 1] Ids: 11, 12
    Legs: (Next:2,Id:0,length:537.76)  
 2: [-1] Ids: 22, 13
    Legs: (Next:3,Id:0,length:245.73)  
 3: [-1] Ids:  3, 14
    Legs: (Next:4,Id:0,length:112.54)  
 4: [ 2] Ids:  4, 15
    Legs: (Next:5,Id:0,length:280.23)  
 5: [-1] Ids: 15, 16
    Legs: (Next:6,Id:0,length:287.06)  
 6: [ 3] Ids:  5, 17
    Legs: (Next:7,Id:0,length:1440)  
 7: [ 4] Ids: 18, 18
    Legs: (Next:8,Id:0,length:1423.9)  
 8: [-1] Ids:  6, 19
Description 6 (Course 4)
";
            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        public void ScoreDescriptionSpecialsOnly()
        {
            UndoMgr      undomgr = new UndoMgr(5);
            EventDB      eventDB = new EventDB(undomgr);
            SymbolDB     symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml"));
            StringWriter writer = new StringWriter();
            string       actual, expected;

            eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent1.coursescribe"));
            eventDB.Validate();

            CourseView courseView = CourseView.CreatePositioningCourseView(eventDB, new CourseDesignator(CourseId(5)));

            DumpCourseView(courseView, writer);
            actual   = writer.ToString();
            expected =
                @"Name='Score 4', Kind='Score', CourseId=5
Total Length=0  Part Length=0  Total Climb=-1  ScoreColumn=0  Total Score=155  Total Controls=11
 0: [-1] Ids:  1,101
 1: [-1] Ids: 17,109
 2: [-1] Ids:  2,113
 3: [-1] Ids:  7,114
 4: [-1] Ids: 11,102
 5: [-1] Ids:  8,115
 6: [-1] Ids: 20,112
 7: [-1] Ids:  5,107
 8: [-1] Ids:  4,105
 9: [-1] Ids: 16,108
10: [-1] Ids: 18,110
11: [-1] Ids: 19,111
12: [-1] Ids:  6,116
13: [-1] Ids:  3,104
14: [-1] Ids: 15,106
15: [-1] Ids: 22,103
";
            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        // Get the area of the map we want to print, in map coordinates, and the print scale.
        // if the courseId is None, do all controls.
        // If asked for, crop to a single page size.
        RectangleF GetPrintAreaForCourse(CourseDesignator courseDesignator, out bool landscape, out PaperSize paperSize, out int margins, out float scaleRatio, out string description)
        {
            // Get the course view to get the scale ratio.
            CourseView courseView = CourseView.CreatePositioningCourseView(eventDB, courseDesignator);

            scaleRatio  = courseView.ScaleRatio;
            description = courseView.CourseFullName;

            RectangleF printRectangle = controller.GetCurrentPrintAreaRectangle(courseDesignator);
            PrintArea  printArea      = controller.GetCurrentPrintArea(courseDesignator);

            landscape = printArea.pageLandscape;
            paperSize = new PaperSize("", printArea.pageWidth, printArea.pageHeight);
            margins   = printArea.pageMargins;

            if (cropLargePrintArea)
            {
                // Crop the print area to a single page, portrait or landscape.
                // Try to keep CourseObjects in view as much as possible.
                CourseLayout layout = new CourseLayout();
                CourseFormatter.FormatCourseToLayout(symbolDB, courseView, appearance, layout, 0);
                RectangleF courseObjectsArea = layout.BoundingRect();
                courseObjectsArea.Intersect(printRectangle);

                // We may need to crop the print area to fit.
                float      areaCovered;
                RectangleF printableArea    = GetPrintablePageArea(landscape, paperSize, margins);
                RectangleF croppedRectangle = CropPrintArea(printRectangle, courseObjectsArea, GetScaledPrintableSizeInMapUnits(printableArea, scaleRatio), out areaCovered);

                return(croppedRectangle);
            }
            else
            {
                return(printRectangle);
            }
        }