internal SetPrintAreaDialog(MainFrame mainFrame, Controller controller, PrintAreaKind printAreaKind) { InitializeComponent(); this.mainFrame = mainFrame; this.controller = controller; this.printAreaKind = printAreaKind; this.printArea = PrintArea.DefaultPrintArea; }
// Set the creation info so we are ready to create. private void SetCreateInfo() { createEventInfo.title = eventTitlePage.titleText.Text; createEventInfo.eventFileName = GetEventFullPath(); createEventInfo.mapType = MapType; createEventInfo.mapFileName = MapFileName; createEventInfo.scale = MapScale; createEventInfo.allControlsPrintScale = DefaultPrintScale; createEventInfo.dpi = bitmapScalePage.dpi; createEventInfo.firstCode = (int) numberingPage.startingCodeNumericUpDown.Value; createEventInfo.disallowInvertibleCodes = numberingPage.disallowInvertibleCheckBox.Checked; createEventInfo.descriptionLangId = null; // use default description language. PrintArea printArea = new PrintArea(); printArea.autoPrintArea = true; printArea.restrictToPageSize = true; printArea.pageWidth = paperSizePage.paperSizeControl.PaperSize.Width; printArea.pageHeight = paperSizePage.paperSizeControl.PaperSize.Height; printArea.pageMargins = paperSizePage.paperSizeControl.MarginSize; printArea.pageLandscape = paperSizePage.paperSizeControl.Landscape; createEventInfo.printArea = printArea; }
// Give a map file name, get the default print area. public static PrintArea GetDefaultPrintArea(string mapFileName, float printScaleRatio) { float scale, dpi; Size bitmapSize; RectangleF mapBounds; MapType mapType; string errorMessageText; // If this failes, mapBounds will be empty rectangle, which is what we want to pass to GetDefaultPageSize; ValidateMapFile(mapFileName, out scale, out dpi, out bitmapSize, out mapBounds, out mapType, out errorMessageText); PrintArea printArea = new PrintArea(); printArea.autoPrintArea = true; printArea.restrictToPageSize = true; GetDefaultPageSize(mapBounds, printScaleRatio, out printArea.pageWidth, out printArea.pageHeight, out printArea.pageMargins, out printArea.pageLandscape); return printArea; }
// Change the course print area. If "removeParts" is true, and the course is an all parts, // then remove print descriptions for each part. public static void ChangePrintArea(EventDB eventDB, CourseDesignator courseDesignator, bool removeParts, PrintArea printArea) { printArea = (PrintArea) printArea.Clone(); if (courseDesignator.IsAllControls) { Event e = eventDB.GetEvent(); e = (Event) e.Clone(); e.printArea = printArea; eventDB.ChangeEvent(e); } else { Course course = eventDB.GetCourse(courseDesignator.CourseId); course = (Course) course.Clone(); if (courseDesignator.AllParts) { course.printArea = printArea; if (removeParts) course.partPrintAreas = new Dictionary<int, PrintArea>(); } else { course.partPrintAreas[courseDesignator.Part] = printArea; } eventDB.ReplaceCourse(courseDesignator.CourseId, course); } }
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; }
public Course(CourseKind kind, string name, float printScale, int sortOrder): this() { this.kind = kind; this.name = name; this.printScale = printScale; this.sortOrder = sortOrder; this.labelKind = (kind == CourseKind.Score) ? ControlLabelKind.Code : ControlLabelKind.Sequence; this.overrideCourseLength = null; this.climb = -1; this.load = -1; this.firstControlOrdinal = 1; this.scoreColumn = -1; this.printArea = PrintArea.DefaultPrintArea; }
public override void ReadAttributesAndContent(XmlInput xmlinput) { firstControlCode = 31; disallowInvertibleCodes = true; courseAppearance.purpleColorBlend = false; // default for existing events is false, true for new events. printArea = null; // Will be set at end if not loaded. bool first = true; while (xmlinput.FindSubElement(first, "title", "notes", "map", "all-controls", "numbering", "punch-card", "course-appearance", "print-area", "descriptions", "ocad", "custom-symbol-text")) { switch (xmlinput.Name) { case "title": title = xmlinput.GetContentString(); break; case "notes": notes = xmlinput.GetContentString(); break; case "map": mapScale = xmlinput.GetAttributeFloat("scale"); string kindString = xmlinput.GetAttributeString("kind"); switch (kindString) { case "none": mapType = MapType.None; break; case "OCAD": mapType = MapType.OCAD; break; case "bitmap": mapType = MapType.Bitmap; break; case "PDF": mapType = MapType.PDF; break; default: xmlinput.BadXml("Invalid map kind '{0}'", kindString); break; } if (mapType == MapType.Bitmap) mapDpi = xmlinput.GetAttributeFloat("dpi"); else mapDpi = 0; if (mapType == MapType.OCAD) ignoreMissingFonts = xmlinput.GetAttributeBool("ignore-missing-fonts", false); if (mapType != MapType.None) { mapFileName = xmlinput.GetContentString(); mapFileName = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(xmlinput.FileName), mapFileName)); // file name is relative to the XML file } else { mapFileName = null; xmlinput.Skip(); } break; case "all-controls": allControlsPrintScale = xmlinput.GetAttributeFloat("print-scale", 0); allControlsDescKind = EventDBUtil.ReadDescriptionKindAttribute(xmlinput); xmlinput.Skip(); break; case "numbering": firstControlCode = xmlinput.GetAttributeInt("start", 31); disallowInvertibleCodes = xmlinput.GetAttributeBool("disallow-invertible", true); xmlinput.Skip(); break; case "punch-card": punchcardFormat.boxesDown = xmlinput.GetAttributeInt("rows", PunchcardAppearance.defaultBoxesDown); punchcardFormat.boxesAcross = xmlinput.GetAttributeInt("columns", PunchcardAppearance.defaultBoxesAcross); punchcardFormat.leftToRight = xmlinput.GetAttributeBool("left-to-right", PunchcardAppearance.defaultLeftToRight); punchcardFormat.topToBottom = xmlinput.GetAttributeBool("top-to-bottom", PunchcardAppearance.defaultTopToBottom); xmlinput.Skip(); break; case "course-appearance": courseAppearance.controlCircleSize = xmlinput.GetAttributeFloat("control-circle-size-ratio", 1.0F); courseAppearance.lineWidth = xmlinput.GetAttributeFloat("line-width-ratio", 1.0F); courseAppearance.centerDotDiameter = xmlinput.GetAttributeFloat("center-dot-diameter", 0.0F); courseAppearance.numberHeight = xmlinput.GetAttributeFloat("number-size-ratio", 1.0F); courseAppearance.numberBold = xmlinput.GetAttributeBool("number-bold", false); courseAppearance.numberOutlineWidth = xmlinput.GetAttributeFloat("number-outline-width", 0.0F); courseAppearance.autoLegGapSize = xmlinput.GetAttributeFloat("auto-leg-gap-size", 3.5F); // default value courseAppearance.purpleColorBlend = xmlinput.GetAttributeBool("blend-purple", false); courseAppearance.purpleC = xmlinput.GetAttributeFloat("purple-cyan", -1F); courseAppearance.purpleM = xmlinput.GetAttributeFloat("purple-magenta", -1F); courseAppearance.purpleY = xmlinput.GetAttributeFloat("purple-yellow", -1F); courseAppearance.purpleK = xmlinput.GetAttributeFloat("purple-black", -1F); if (courseAppearance.purpleC < 0 || courseAppearance.purpleM < 0 || courseAppearance.purpleY < 0 || courseAppearance.purpleK < 0) { courseAppearance.useDefaultPurple = true; courseAppearance.purpleC = courseAppearance.purpleM = courseAppearance.purpleY = courseAppearance.purpleK = 1; } else { courseAppearance.useDefaultPurple = false; } xmlinput.Skip(); break; case "print-area": printArea = new PrintArea(); printArea.ReadAttributesAndContent(xmlinput); break; case "descriptions": descriptionLangId = xmlinput.GetAttributeString("lang"); string descriptionColor = xmlinput.GetAttributeString("color", "black"); if (descriptionColor.Equals("purple", StringComparison.InvariantCultureIgnoreCase)) courseAppearance.descriptionsPurple = true; else courseAppearance.descriptionsPurple = false; xmlinput.Skip(); break; case "ocad": courseAppearance.useOcadOverprint = xmlinput.GetAttributeBool("overprint-colors", false); xmlinput.Skip(); break; case "custom-symbol-text": string iof2004id = xmlinput.GetAttributeString("iof-2004-ref"); bool key = xmlinput.GetAttributeBool("show-key", false); customSymbolKey[iof2004id] = key; xmlinput.Read(); xmlinput.MoveToContent(); List<SymbolText> texts = new List<SymbolText>(); if (xmlinput.Reader.NodeType == XmlNodeType.Text) { // Reading the old-style custom symbol text. string customText = xmlinput.Reader.ReadString(); if (iof2004id.StartsWith("8.", StringComparison.InvariantCulture)) customText += " {0}"; // old style for modifiers didn't have the fill-in placeholder. SymbolText text = new SymbolText(); text.Lang = "en"; text.Plural = false; text.Gender = ""; text.Text = customText; texts.Add(text); } else { // Read the new-style custom symbol text. while (xmlinput.Reader.NodeType == XmlNodeType.Element && xmlinput.Name == "text") { SymbolText text = new SymbolText(); text.ReadXml(xmlinput); texts.Add(text); xmlinput.Skip(); } } customSymbolText[iof2004id] = texts; xmlinput.Skip(); break; } first = false; } if (allControlsPrintScale == 0) allControlsPrintScale = mapScale; float scaleRatio; if (mapScale > 0 && allControlsPrintScale > 0) scaleRatio = allControlsPrintScale / mapScale; else scaleRatio = 1.0F; if (printArea == null) { printArea = MapUtil.GetDefaultPrintArea(mapFileName, scaleRatio); } }
public Dictionary<string, bool> customSymbolKey = new Dictionary<string, bool>(); // maps symbol IDs to whether to display key for this custom symbol public Event() { title = ""; descriptionLangId = "en"; printArea = PrintArea.DefaultPrintArea; }