Inheritance: ICloneable
Exemple #1
0
        public static void ChangePartOptions(EventDB eventDB, CourseDesignator courseDesignator, PartOptions partOptions)
        {
            Debug.Assert(courseDesignator.IsNotAllControls);

            Course course = eventDB.GetCourse(courseDesignator.CourseId);

            course = (Course)course.Clone();
            course.partOptions[courseDesignator.Part] = partOptions.Clone();
            eventDB.ReplaceCourse(courseDesignator.CourseId, course);
        }
Exemple #2
0
        public override void ReadAttributesAndContent(XmlInput xmlinput)
        {
            string kindText = xmlinput.GetAttributeString("kind");
            switch (kindText) {
                case "normal":      kind = CourseKind.Normal; break;
                case "score":       kind = CourseKind.Score; break;
                default:            xmlinput.BadXml("Invalid course kind '{0}'", kindText); break;
            }

            sortOrder = xmlinput.GetAttributeInt("order", 0);    // 0 sort orders fixed up later in EventDB.FixCourseSortOrders()

            name = "";
            printScale = 15000;
            descKind = DescriptionKind.Symbols;
            firstCourseControl = Id<CourseControl>.None;
            firstControlOrdinal = 1;
            labelKind = (kind == CourseKind.Score) ? ControlLabelKind.Code : ControlLabelKind.Sequence;
            scoreColumn = (kind == CourseKind.Score) ? 0 : -1;

            bool first = true;
            while (xmlinput.FindSubElement(first, "name", "secondary-title", "first", "print-area", "options", "labels", "part-options", "relay")) {
                switch (xmlinput.Name) {
                    case "name":
                        name = xmlinput.GetContentString();
                        break;

                    case "secondary-title":
                        secondaryTitle = xmlinput.GetContentString();
                        break;

                    case "first":
                        firstCourseControl = new Id<CourseControl>(xmlinput.GetAttributeInt("course-control"));
                        firstControlOrdinal = xmlinput.GetAttributeInt("control-number", 1);
                        xmlinput.Skip();
                        break;

                    case "print-area":
                        PrintArea area = new PrintArea();
                        int part = xmlinput.GetAttributeInt("part", -1);
                        area.ReadAttributesAndContent(xmlinput);

                        if (part == -1)
                            printArea = area;
                        else
                            partPrintAreas[part] = area;

                        break;

                    case "options":
                        printScale = xmlinput.GetAttributeFloat("print-scale");
                        climb = xmlinput.GetAttributeFloat("climb", -1F);
                        load = xmlinput.GetAttributeInt("load", -1);
                        if (kind == CourseKind.Score) 
                            scoreColumn = EventDBUtil.ReadScoreColumnAttribute(xmlinput);
                        descKind = EventDBUtil.ReadDescriptionKindAttribute(xmlinput);

                        float len = xmlinput.GetAttributeFloat("course-length", -1F);
                        if (len > 0)
                            overrideCourseLength = len;
                        else
                            overrideCourseLength = null;

                        xmlinput.Skip();
                        break;

                    case "part-options":
                        part = xmlinput.GetAttributeInt("part", -1);
                        bool showFinish = xmlinput.GetAttributeBool("show-finish");

                        if (part != -1)
                            partOptions[part] = new PartOptions() { ShowFinish = showFinish };

                        xmlinput.Skip();
                        break;


                    case "labels":
                        string labelKindText = xmlinput.GetAttributeString("label-kind");
                        switch (labelKindText) {
                            case "sequence":                labelKind = ControlLabelKind.Sequence; break;
                            case "code":                    labelKind = ControlLabelKind.Code; break;
                            case "sequence-and-code":       labelKind = ControlLabelKind.SequenceAndCode; break;
                            case "sequence-and-score":      labelKind = ControlLabelKind.SequenceAndScore; break;
                            case "code-and-score":          labelKind = ControlLabelKind.CodeAndScore; break;
                            default:                        labelKind = ControlLabelKind.Sequence; break;
                        }
                        xmlinput.Skip();
                        break;

                    case "relay":
                        relayTeams = xmlinput.GetAttributeInt("teams", 0);
                        relayLegs = xmlinput.GetAttributeInt("legs", 1);
                        xmlinput.Skip();
                        break;
                }

                first = false;
            }

            if (printArea == null)
                printArea = PrintArea.DefaultPrintArea;
        }