コード例 #1
0
ファイル: PdfCourseTests.cs プロジェクト: osorensen/PurplePen
        public void Files_Relay_SingleFile()
        {
            EventDB  eventDB  = controller.GetEventDB();
            SymbolDB symbolDB = ui.symbolDB;

            CoursePdfSettings settings = new CoursePdfSettings();

            settings.mapDirectory              = settings.fileDirectory = false;
            settings.outputDirectory           = TestUtil.GetTestFile("controller\\pdf_create1");
            settings.CourseIds                 = new Id <Course>[] { CourseId(2), Id <Course> .None };
            settings.ColorModel                = ColorModel.CMYK;
            settings.CropLargePrintArea        = true;
            settings.FileCreation              = CoursePdfSettings.PdfFileCreation.SingleFile;
            settings.PrintMapExchangesOnOneMap = false;

            bool success = controller.LoadInitialFile(TestUtil.GetTestFile("controller\\variations.ppen"), true);

            Assert.IsTrue(success);

            var coursePdf     = new CoursePdf(eventDB, symbolDB, controller, controller.MapDisplay, settings, new CourseAppearance());
            var filesToCreate = coursePdf.GetFilesToCreate();

            VariationInfo[] relayVariations = QueryEvent.GetAllVariations(eventDB, CourseId(2)).ToArray();

            Assert.AreEqual(1, filesToCreate.Count);

            Assert.AreEqual(TestUtil.GetTestFile("controller\\pdf_create1\\variations.pdf"), filesToCreate[0].First);
            CollectionAssert.AreEqual(new CourseDesignator[] {
                new CourseDesignator(CourseId(2), relayVariations[0]),
                new CourseDesignator(CourseId(2), relayVariations[1]),
                new CourseDesignator(CourseId(2), relayVariations[2]),
                new CourseDesignator(CourseId(2), relayVariations[3]),
                CourseDesignator.AllControls
            }, filesToCreate[0].Second.ToList());
        }
コード例 #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();
            }
        }
コード例 #3
0
 private void UpdateVariationList()
 {
     if (!variationListUpdated)
     {
         checkedListBoxVariations.BeginUpdate();
         checkedListBoxVariations.Items.Clear();
         string[] variations = (from vi in QueryEvent.GetAllVariations(eventDB, courseId) select vi.CodeString).ToArray();
         checkedListBoxVariations.Items.AddRange(variations);
         checkedListBoxVariations.EndUpdate();
         variationListUpdated = true;
     }
 }
コード例 #4
0
        public CourseDesignator DesignatorFromCourseId(EventDB eventDB, Id <Course> courseId)
        {
            CourseDesignator designator;

            if (QueryEvent.HasVariations(eventDB, courseId))
            {
                var variationInfo = QueryEvent.GetAllVariations(eventDB, courseId).First();
                designator = new CourseDesignator(courseId, variationInfo);
            }
            else
            {
                designator = new CourseDesignator(courseId);
            }
            return(designator);
        }
コード例 #5
0
 void WriteCourseVariations(Id <Course> courseId, string courseName, int courseNumber, string[] classNames, bool isScore)
 {
     if (QueryEvent.HasVariations(eventDB, courseId))
     {
         VariationInfo[] variations = QueryEvent.GetAllVariations(eventDB, courseId).ToArray();
         for (int variationNumber = 0; variationNumber < variations.Length; ++variationNumber)
         {
             WriteSingleCourseVariation(new CourseDesignator(courseId, variations[variationNumber]), courseName, courseNumber, classNames, isScore, variationNumber, variations[variationNumber]);
         }
     }
     else
     {
         // No variations.
         WriteSingleCourseVariation(new CourseDesignator(courseId), courseName, courseNumber, classNames, isScore, 0, null);
     }
 }
コード例 #6
0
        void GenerateAllTeams()
        {
            if (!teamsGenerated)
            {
                ScanAllForks();

                variationPaths = QueryEvent.GetAllVariations(eventDB, courseId).ToDictionary(vi => vi.CodeString, vi => vi.Path);
                Debug.Assert(totalPossiblePaths == variationPaths.Count);

                for (int i = 0; i < numberTeams; ++i)
                {
                    results.Add(GenerateTeam());
                }

                teamsGenerated = true;
            }
        }
コード例 #7
0
        public void HideVariationCode()
        {
            SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml"));
            UndoMgr  undomgr  = new UndoMgr(5);
            EventDB  eventDB  = new EventDB(undomgr);

            eventDB.Load(TestUtil.GetTestFile("courserenderer\\Fake Relay.ppen"));
            eventDB.Validate();

            VariationInfo[]  variationInfos   = QueryEvent.GetAllVariations(eventDB, CourseId(3)).ToArray();
            CourseDesignator courseDesignator = new CourseDesignator(CourseId(3), variationInfos.First(vi => vi.CodeString == "BD"));

            CheckCourseBothAppearances("courserenderer\\Fake Relay.ppen", courseDesignator, false, "relayvariations_hidecode_1", RectangleF.FromLTRB(-80, -160, 180, 100));

            variationInfos   = QueryEvent.GetAllVariations(eventDB, CourseId(2)).ToArray();
            courseDesignator = new CourseDesignator(CourseId(2), variationInfos.First(vi => vi.CodeString == "BD"));
            CheckCourseBothAppearances("courserenderer\\Fake Relay.ppen", courseDesignator, false, "relayvariations_hidecode_2", RectangleF.FromLTRB(-80, -160, 180, 100));
        }
コード例 #8
0
        public void DisplayAllCourses()
        {
            UndoMgr              undomgr  = new UndoMgr(5);
            EventDB              eventDB  = new EventDB(undomgr);
            SymbolDB             symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml"));
            CourseView           courseView;
            DescriptionFormatter descFormatter;

            DescriptionLine[] description;

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

            foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB))
            {
                CourseDesignator designator;
                if (QueryEvent.HasVariations(eventDB, courseId))
                {
                    var variationInfo = QueryEvent.GetAllVariations(eventDB, courseId).First();
                    designator = new CourseDesignator(courseId, variationInfo);
                }
                else
                {
                    designator = new CourseDesignator(courseId);
                }
                courseView    = CourseView.CreateViewingCourseView(eventDB, designator);
                descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting);
                description   = descFormatter.CreateDescription(false);
                DescriptionFormatter.DumpDescription(symbolDB, description, Console.Out);
                Console.WriteLine();
            }

            courseView    = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls);
            descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting);
            description   = descFormatter.CreateDescription(false);
            DescriptionFormatter.DumpDescription(symbolDB, description, Console.Out);
        }
コード例 #9
0
ファイル: SelectionMgr.cs プロジェクト: osorensen/PurplePen
        // Check the validate of the selected course view/selected object and update accordingly.
        void UpdateSelection()
        {
            // Check the selection validity.
            if (!activeCourseDesignator.IsAllControls && !eventDB.IsCoursePresent(activeCourseDesignator.CourseId)) {
                // Active course was deleted. Switch to all controls.
                activeCourseDesignator = CourseDesignator.AllControls;
                ClearSelection();
            }

            // Check that variation still exists.
            if (activeCourseDesignator.IsVariation && QueryEvent.HasVariations(eventDB, activeCourseDesignator.CourseId)) {
                IEnumerable<VariationInfo> variations = QueryEvent.GetAllVariations(eventDB, activeCourseDesignator.CourseId);
                if (!variations.Any(v => v.Equals(activeCourseDesignator.VariationInfo)))
                    activeCourseDesignator = activeCourseDesignator.WithAllVariations();
            }

            // Does the current part still exist?
            int numberOfParts = QueryEvent.CountCourseParts(eventDB, activeCourseDesignator);
            if (!activeCourseDesignator.IsAllControls && !activeCourseDesignator.AllParts && 
                (numberOfParts == 1 || activeCourseDesignator.Part >= numberOfParts)) 
            {
                // No part that large any more.
                if (numberOfParts > 1)
                    activeCourseDesignator = activeCourseDesignator.WithPart(numberOfParts - 1);
                else
                    activeCourseDesignator = activeCourseDesignator.WithAllParts();
                ClearSelection();
            }

            if (selectedCourseControl.IsNotNone && !eventDB.IsCourseControlPresent(selectedCourseControl)) {
                // Selected course control is no longer there.
                selectedCourseControl = Id<CourseControl>.None;
                ClearSelection();
            }

            if (selectedCourseControl.IsNotNone && activeCourseDesignator.IsNotAllControls && 
                (!activeCourseDesignator.AllParts || activeCourseDesignator.IsVariation) && 
                !QueryEvent.IsCourseControlInPart(eventDB, activeCourseDesignator, selectedCourseControl)) {
                // Selected course control is not in active part.
                // Could be allowed if it's the finish.
                Id<ControlPoint> controlId = eventDB.GetCourseControl(selectedCourseControl).control;
                if (!(eventDB.IsControlPresent(controlId) && 
                      eventDB.GetControl(controlId).kind == ControlPointKind.Finish &&
                      QueryEvent.GetPartOptions(eventDB, activeCourseDesignator).ShowFinish))
                {
                    selectedCourseControl = Id<CourseControl>.None;
                    ClearSelection();
                }
            }

            if (selectedCourseControl2.IsNotNone && !eventDB.IsCourseControlPresent(selectedCourseControl2)) {
                // Selected course control 2 is no longer there.
                selectedCourseControl2 = Id<CourseControl>.None;
                ClearSelection();
            }

            if (selectedCourseControl2.IsNotNone && activeCourseDesignator.IsNotAllControls && !activeCourseDesignator.AllParts && 
                !QueryEvent.IsCourseControlInPart(eventDB, activeCourseDesignator, selectedCourseControl2)) {
                // Selected course control 2 is not in active part.
                selectedCourseControl2 = Id<CourseControl>.None;
                ClearSelection();
            }

            if (selectedControl.IsNotNone && !eventDB.IsControlPresent(selectedControl)) {
                // Selected control is no longer there.
                ClearSelection();
            }

            if (selectedSpecial.IsNotNone && !eventDB.IsSpecialPresent(selectedSpecial)) {
                // Selected special is no longer there.
                ClearSelection();
            }

            if (selectedSpecial.IsNotNone && !(activeCourseDesignator.IsAllControls || QueryEvent.CourseContainsSpecial(eventDB, activeCourseDesignator, selectedSpecial))) {
                // Selected special is not in current course
                ClearSelection();
            }
        }