public DescriptionPrinting(EventDB eventDB, SymbolDB symbolDB, Controller controller, DescriptionPrintSettings descPrintSettings) : base(QueryEvent.GetEventTitle(eventDB, " "), controller, descPrintSettings.PageSettings, descPrintSettings.BoxSize, descPrintSettings.CountKind, descPrintSettings.Count) { this.eventDB = eventDB; this.symbolDB = symbolDB; this.descPrintSettings = descPrintSettings; }
// Format the given CourseView into a bunch of course objects, and add it to the given course Layout public RectangleF FormatCourseToLayout(SymbolDB symbolDB, CourseView courseViewAllVariations, CourseView specificVariation, CourseLayout courseLayout, CourseLayer layerAllVariations, CourseLayer layerSpecificVariation) { this.eventDB = courseViewAllVariations.EventDB; this.symbolDB = symbolDB; this.courseLayout = courseLayout; this.courseLayerAllVariationsAndParts = layerAllVariations; this.courseLayerSpecificVariation = layerSpecificVariation; this.controlViewsAllVariationsAndParts = courseViewAllVariations.ControlViews; this.controlViewsSpecificVariation = specificVariation.ControlViews; this.controlPositions = new ControlPosition[controlViewsAllVariationsAndParts.Count]; this.courseControlIdsSpecificVariation = QueryEvent.EnumCourseControlIds(eventDB, specificVariation.CourseDesignator).ToArray(); this.variationMap = QueryEvent.GetVariantCodeMapping(eventDB, courseViewAllVariations.CourseDesignator); SizeF totalAbstractSize = AssignControlPositions(0, controlViewsAllVariationsAndParts.Count, 0, 0); // Now create objects now that the positions have been created. scaleRatio = 1.0F; appearance = new CourseAppearance(); for (int index = 0; index < controlViewsAllVariationsAndParts.Count; ++index) { CreateObjectsForControlView(controlViewsAllVariationsAndParts[index], controlPositions[index]); } PointF bottomCenter = LocationFromAbstractPosition(0, 0); SizeF size = SizeFromAbstractSize(totalAbstractSize); RectangleF rect = new RectangleF(bottomCenter.X - size.Width / 2, bottomCenter.Y - size.Height, size.Width, size.Height); rect.Inflate(widthUnit, heightUnit); return rect; }
public ExportRouteGadget(SymbolDB symbolDB, EventDB eventDB, MapDisplay mapDisplay) { this.symbolDB = symbolDB; this.eventDB = eventDB; this.mapDisplay = mapDisplay.CloneToFullIntensity(); this.mapDisplay.SetCourse(null); this.mapDisplay.SetPrintArea(null); }
public OcadCreation(SymbolDB symbolDB, EventDB eventDB, Controller controller, CourseAppearance courseAppearance, OcadCreationSettings creationSettings) { this.symbolDB = symbolDB; this.eventDB = eventDB; this.controller = controller; this.courseAppearance = courseAppearance; this.creationSettings = creationSettings; }
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; }
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(); }
internal CustomSymbolText(SymbolDB symbolDB, bool useAsLocalizeTool) : this() { this.symbolDB = symbolDB; this.useAsLocalizeTool = useAsLocalizeTool; FillListBox(); FillLanguages(); listBoxSymbols.SelectedIndex = 0; if (useAsLocalizeTool) { labelSymbolName.Visible = textBoxSymbolName.Visible = true; buttonDefault.Visible = checkBoxShowKey.Visible = false; checkBoxDefaultLanguage.Visible = false; } }
// mapDisplay is a MapDisplay that contains the correct map. All other features of the map display need to be customized. public CoursePrinting(EventDB eventDB, SymbolDB symbolDB, Controller controller, MapDisplay mapDisplay, CoursePrintSettings coursePrintSettings, CourseAppearance appearance) : base(QueryEvent.GetEventTitle(eventDB, " "), controller, coursePrintSettings.PageSettings, coursePrintSettings.PrintingColorModel) { this.eventDB = eventDB; this.symbolDB = symbolDB; this.controller = controller; this.mapDisplay = mapDisplay; this.coursePrintSettings = coursePrintSettings; this.appearance = appearance; // Set default features for printing. mapDisplay.MapIntensity = 1.0F; mapDisplay.AntiAlias = false; mapDisplay.Printing = true; mapDisplay.ColorModel = base.colorModel; }
// mapDisplay is a MapDisplay that contains the correct map. All other features of the map display need to be customized. public CoursePdf(EventDB eventDB, SymbolDB symbolDB, Controller controller, MapDisplay mapDisplay, CoursePdfSettings coursePdfSettings, CourseAppearance appearance) { this.eventDB = eventDB; this.symbolDB = symbolDB; this.controller = controller; this.mapDisplay = mapDisplay; this.coursePdfSettings = coursePdfSettings; this.appearance = appearance; // Set default features for printing. mapDisplay.MapIntensity = 1.0F; mapDisplay.AntiAlias = false; mapDisplay.Printing = true; mapDisplay.ColorModel = coursePdfSettings.ColorModel; mapBounds = mapDisplay.MapBounds; if (mapDisplay.MapType == MapType.PDF) { // For PDF maps, we remove the PDF map from the MapDisplay and add it in separately. sourcePdfMapFileName = mapDisplay.FileName; } }
// Find the best matching SymbolText. Gender can be null or empty for don't care. Same with nounCase. If // nounCase is empty then the first noun case from the language is chosen if possible. static SymbolText FindBestText(SymbolDB symbolDB, List<SymbolText> texts, string language, bool plural, string gender, string nounCase) { int best = 99999; SymbolText bestSymText = null; if (gender == null) gender = ""; string defaultNounCase = ""; SymbolLanguage symbolLanguage = symbolDB.GetLanguage(language); if (symbolLanguage != null && symbolLanguage.CaseModifiers && symbolLanguage.Cases.Length > 0) defaultNounCase = symbolLanguage.Cases[0]; // Search for exact match. foreach (SymbolText symtext in texts) { int metric = 0; if (symtext.Lang != language && symtext.Lang != "en") metric += 100; if (symtext.Lang != language && symtext.Lang == "en") // english is most preferred if no language match metric += 50; if (symtext.Plural != plural) metric += 10; if (gender != "" && symtext.Gender != gender) metric += 5; if (nounCase != "" && symtext.Case != nounCase) metric += 3; if (nounCase == "" && symtext.Case != null && symtext.Case != defaultNounCase) metric += 1; if (metric < best) { best = metric; bestSymText = symtext; } } return bestSymText; }
// Get the gender for a item from a list of symbol texts. public static string GetSymbolGender(SymbolDB symbolDB, List<SymbolText> texts, string language) { SymbolText best = FindBestText(symbolDB, texts, language, false, "", ""); if (best != null) return best.Gender; else return null; }
public SymbolPopup(SymbolDB symbolDB, int boxSize) { this.symbolDB = symbolDB; this.boxSize = boxSize; }
CourseView topologyCourseView; // The active course view, but: null if all controls or score, plus always shows all variations and parts. #endregion Fields #region Constructors public SelectionMgr(EventDB eventDB, SymbolDB symbolDB, Controller controller) { this.eventDB = eventDB; this.symbolDB = symbolDB; this.controller = controller; this.activeCourseDesignator = CourseDesignator.AllControls; }
bool textboxChanged; // has the text box been changed? #endregion Fields #region Constructors public SymbolPopup(SymbolDB symbolDB, int boxSize) { this.symbolDB = symbolDB; this.boxSize = boxSize; }
// Find the longest description we have. If we have no courses, then return None. static CourseDesignator FindLongestDescription(EventDB eventDB, SymbolDB symbolDB) { int longest = 0; CourseDesignator longestCourse = CourseDesignator.AllControls; foreach (Id<Course> courseId in eventDB.AllCourseIds) { int numberOfParts = QueryEvent.CountCourseParts(eventDB, courseId); for (int part = 0; part < numberOfParts; ++part) { DescriptionFormatter descFormatter = new DescriptionFormatter(CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(courseId, part)), symbolDB); DescriptionKind descKind = QueryEvent.GetDefaultDescKind(eventDB, courseId); DescriptionLine[] description = descFormatter.CreateDescription(descKind == DescriptionKind.Symbols); if (description.Length > longest) { longest = description.Length; longestCourse = new CourseDesignator(courseId, part); } } } return longestCourse; }
// Describe a course object, and return an array of TextParts for display in the UI. Return null if nothing useful // can be said. public static TextPart[] DescribeCourseObject(SymbolDB symbolDB, EventDB eventDB, CourseObj courseObj, float scaleRatio) { if (courseObj is LineCourseObj && courseObj.courseControlId.IsNotNone && ((LineCourseObj)courseObj).courseControlId2.IsNotNone) { return DescribeLeg(eventDB, courseObj.courseControlId, ((LineCourseObj)courseObj).courseControlId2, DescKind.Tooltip); } else if (courseObj.controlId.IsNotNone) { return DescribeControlPoint(symbolDB, eventDB, courseObj.controlId, DescKind.Tooltip); } else if (courseObj.specialId.IsNotNone) { return DescribeSpecial(eventDB, courseObj.specialId, scaleRatio, DescKind.Tooltip); } else { return null; } }
// Return the description and description kind for a given CourseView. public static DescriptionLine[] GetCourseDescription(EventDB eventDB, SymbolDB symbolDB, CourseDesignator courseDesignator, out DescriptionKind descKind) { CourseView courseViewDescription; DescriptionLine[] description; bool noTextOrSymbols = false; // Get the course view for the description we're using. courseViewDescription = CourseView.CreateViewingCourseView(eventDB, courseDesignator); // Create the description. Note the courseId is None only if we're both in all controls, and there are no courses. DescriptionFormatter descFormatter = new DescriptionFormatter(courseViewDescription, symbolDB); descKind = QueryEvent.GetDefaultDescKind(eventDB, courseDesignator.CourseId); description = descFormatter.CreateDescription(descKind == DescriptionKind.Symbols); if (noTextOrSymbols) DescriptionFormatter.ClearTextAndSymbols(description); return description; }
public static void DumpDescription(SymbolDB symbolDB, DescriptionLine[] lines, TextWriter writer) { foreach (DescriptionLine line in lines) DumpDescriptionLine(symbolDB, line, writer); }
// Create a description formatter to format the given courseView. // Currently, the language for the text descriptions is taken from the language set for the event. It would be easy to make this // a parameter to the constructor (e.g., to allow printing in a different language), but this currently isn't required. public DescriptionFormatter(CourseView courseView, SymbolDB symbolDB) { this.courseView = courseView; this.eventDB = courseView.EventDB; this.symbolDB = symbolDB; this.language = QueryEvent.GetDescriptionLanguage(eventDB); }
public Symbol(SymbolDB symbolDB, int sortOrder) { this.symbolDB = symbolDB; this.SortOrder = sortOrder; }
public DescriptionLocalize(SymbolDB symbolDB) { this.symbolDB = symbolDB; }
// Describe a control point. private static TextPart[] DescribeControlPoint(SymbolDB symbolDB, EventDB eventDB, Id<ControlPoint> controlId, DescKind descKind) { Debug.Assert(descKind == DescKind.DescPane || descKind == DescKind.Tooltip); List<TextPart> list = new List<TextPart>(); ControlPoint control = eventDB.GetControl(controlId); // Control name/code. list.Add(new TextPart(TextFormat.Title, Util.ControlPointName(eventDB, controlId, NameStyle.Long))); // Control location. if (descKind == DescKind.DescPane) { list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Location + " ")); list.Add(new TextPart(TextFormat.SameLine, string.Format("({0:##0.0}, {1:##0.0})", control.location.X, control.location.Y))); } // Which courses is it used in? list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.UsedIn : SelectionDescriptionText.UsedInCourses))); Id<Course>[] coursesUsingControl = QueryEvent.CoursesUsingControl(eventDB, controlId); list.Add(new TextPart(descKind == DescKind.Tooltip ? TextFormat.SameLine : TextFormat.NewLine, CourseListText(eventDB, coursesUsingControl))); // What is the competitor load? int load = QueryEvent.GetControlLoad(eventDB, controlId); if (load >= 0) { list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.Load : SelectionDescriptionText.CompetitorLoad))); list.Add(new TextPart(TextFormat.SameLine, string.Format("{0}", load))); } // Text version of the descriptions if (descKind == DescKind.DescPane) { Textifier textifier = new Textifier(eventDB, symbolDB, QueryEvent.GetDescriptionLanguage(eventDB)); string descText = textifier.CreateTextForControl(controlId, null); list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.TextDescription)); list.Add(new TextPart(TextFormat.NewLine, descText)); } return list.ToArray(); }
// Dump a description line to a text writer. static void DumpDescriptionLine(SymbolDB symbolDB, DescriptionLine line, TextWriter writer) { if (line.controlId.IsNotNone) { writer.Write("({0,3}) |", line.controlId); } else { writer.Write(" |"); } switch (line.kind) { case DescriptionLineKind.Title: case DescriptionLineKind.SecondaryTitle: case DescriptionLineKind.Text: writer.Write(" {0,-46}|", line.boxes[0]); break; case DescriptionLineKind.Normal: for (int i = 0; i < 8; ++i) { string text; if (line.boxes[i] == null) { text = ""; } else if (line.boxes[i] is Symbol) { text = ((Symbol)(line.boxes[i])).Id; } else { text = (string)(line.boxes[i]); } writer.Write("{0,5}|", line.boxes[i] is Symbol ? ((Symbol)(line.boxes[i])).Id : (string)(line.boxes[i])); } break; case DescriptionLineKind.Header3Box: writer.Write("{0,-17}|", line.boxes[0] == null ? "" : (string)(line.boxes[0])); writer.Write("{0,-17}|", line.boxes[1] == null ? "" : (string)(line.boxes[1])); writer.Write("{0,-11}|", line.boxes[2] == null ? "" : (string)(line.boxes[2])); break; case DescriptionLineKind.Header2Box: writer.Write("{0,-17}|", line.boxes[0] == null ? "" : (string)(line.boxes[0])); writer.Write("{0,-29}|", line.boxes[1] == null ? "" : (string)(line.boxes[1])); break; case DescriptionLineKind.Key: writer.Write("{0,-17}|", line.boxes[0] == null ? "" : ((Symbol)(line.boxes[0])).Id); writer.Write("{0,-29}|", line.boxes[1] == null ? "" : (string)(line.boxes[1])); break; case DescriptionLineKind.Directive: writer.Write(" {0,16}: {1,-24}|", line.boxes[0] != null ? ((Symbol)(line.boxes[0])).Id : "", line.boxes[1] == null ? "" : (string)(line.boxes[1])); break; } if (line.textual != null) { writer.Write(" [{0}]", line.textual); } writer.WriteLine(); }
// Initialize the textifier. public Textifier(EventDB eventDB, SymbolDB symbolDB, string language) { this.eventDB = eventDB; this.symbolDB = symbolDB; this.language = language; }
// Dump a description line to a text writer. static void DumpDescriptionLine(SymbolDB symbolDB, DescriptionLine line, TextWriter writer) { if (line.controlId.IsNotNone) writer.Write("({0,3}) |", line.controlId); else writer.Write(" |"); switch (line.kind) { case DescriptionLineKind.Title: case DescriptionLineKind.SecondaryTitle: case DescriptionLineKind.Text: writer.Write(" {0,-46}|", line.boxes[0]); break; case DescriptionLineKind.Normal: for (int i = 0; i < 8; ++i) { string text; if (line.boxes[i] == null) text = ""; else if (line.boxes[i] is Symbol) text = ((Symbol)(line.boxes[i])).Id; else text = (string)(line.boxes[i]); writer.Write("{0,5}|", line.boxes[i] is Symbol ? ((Symbol)(line.boxes[i])).Id : (string)(line.boxes[i])); } break; case DescriptionLineKind.Header3Box: writer.Write("{0,-17}|", line.boxes[0] == null ? "" : (string)(line.boxes[0])); writer.Write("{0,-17}|", line.boxes[1] == null ? "" : (string)(line.boxes[1])); writer.Write("{0,-11}|", line.boxes[2] == null ? "" : (string)(line.boxes[2])); break; case DescriptionLineKind.Header2Box: writer.Write("{0,-17}|", line.boxes[0] == null ? "" : (string) (line.boxes[0])); writer.Write("{0,-29}|", line.boxes[1] == null ? "" : (string) (line.boxes[1])); break; case DescriptionLineKind.Key: writer.Write("{0,-17}|", line.boxes[0] == null ? "" : ((Symbol) (line.boxes[0])).Id); writer.Write("{0,-29}|", line.boxes[1] == null ? "" : (string) (line.boxes[1])); break; case DescriptionLineKind.Directive: writer.Write(" {0,16}: {1,-24}|", line.boxes[0] != null ? ((Symbol)(line.boxes[0])).Id : "", line.boxes[1] == null ? "" : (string)(line.boxes[1])); break; } if (line.textual != null) writer.Write(" [{0}]", line.textual); writer.WriteLine(); }
// Create the course objects associated with this special. Assign the given layer to it. static CourseObj CreateDescriptionSpecial(EventDB eventDB, SymbolDB symbolDB, CourseView.DescriptionView descriptionView, CourseLayer layer) { Special special = eventDB.GetSpecial(descriptionView.SpecialId); Debug.Assert(special.kind == SpecialKind.Descriptions); DescriptionKind descKind; DescriptionLine[] description = GetCourseDescription(eventDB, symbolDB, descriptionView.CourseDesignator, out descKind); CourseObj courseObj = new DescriptionCourseObj(descriptionView.SpecialId, special.locations[0], (float)Geometry.Distance(special.locations[0], special.locations[1]), symbolDB, description, descKind, special.numColumns); courseObj.layer = layer; return courseObj; }
// mapDisplay is a MapDisplay that contains the correct map. All other features of the map display need to be customized. public CoursePageLayout(EventDB eventDB, SymbolDB symbolDB, Controller controller, CourseAppearance appearance, bool cropLargePrintArea) { this.eventDB = eventDB; this.symbolDB = symbolDB; this.controller = controller; this.appearance = appearance; this.cropLargePrintArea = cropLargePrintArea; }
public DescriptionRenderer(SymbolDB symbolDB) { this.symbolDB = symbolDB; }
// Describe the selection, and return an array of TextParts for display in the UI. public static TextPart[] DescribeSelection(SymbolDB symbolDB, EventDB eventDB, CourseView activeCourseView, SelectionMgr.SelectionInfo selection) { if (selection.SelectionKind == SelectionMgr.SelectionKind.Key) { return DescribeKey(eventDB); } else if (selection.SelectionKind == SelectionMgr.SelectionKind.TextLine) { return DescribeTextLine(eventDB, selection.SelectedControl, selection.SelectedTextLineKind); } else if (selection.SelectionKind == SelectionMgr.SelectionKind.Control) { return DescribeControlPoint(symbolDB, eventDB, selection.SelectedControl, DescKind.DescPane); } else if (selection.SelectionKind == SelectionMgr.SelectionKind.Leg) { return DescribeLeg(eventDB, selection.SelectedCourseControl, selection.SelectedCourseControl2, DescKind.DescPane); } else if (selection.SelectionKind == SelectionMgr.SelectionKind.Special) { return DescribeSpecial(eventDB, selection.SelectedSpecial, activeCourseView.ScaleRatio, DescKind.DescPane); } else if (selection.SelectionKind == SelectionMgr.SelectionKind.MapExchangeAtControl) { return DescribeMapExchangeAtControl(eventDB, selection.SelectedControl); } else if (selection.ActiveCourseDesignator.IsNotAllControls) { return DescribeCourse(eventDB, activeCourseView); } else { return DescribeAllControls(eventDB, activeCourseView); } }
// Description a control. public static TextPart[] DescribeControl(SymbolDB symbolDB, EventDB eventDB, Id<ControlPoint> controlId) { return DescribeControlPoint(symbolDB, eventDB, controlId, DescKind.Tooltip); }
// Description a control. public static TextPart[] DescribeControl(SymbolDB symbolDB, EventDB eventDB, Id <ControlPoint> controlId) { return(DescribeControlPoint(symbolDB, eventDB, controlId, DescKind.Tooltip)); }
public EnterSymbolText(SymbolDB symbolDB) { this.symbolDB = symbolDB; InitializeComponent(); }
// Allow test code access. #endif #region Constructors public Symbol(SymbolDB symbolDB) { this.symbolDB = symbolDB; }
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); }
// Get the best symbol text for a language from a list of symbol texts. public static string GetBestSymbolText(SymbolDB symbolDB, List<SymbolText> texts, string language, bool plural, string gender, string nounCase) { SymbolText best = FindBestText(symbolDB, texts, language, plural, gender, nounCase); if (best != null) return best.Text; else return null; }
// Get the case of what this symbol modifies, or "" if none. public static string GetModifiedCase(SymbolDB symbolDB, List<SymbolText> texts, string language) { SymbolText best = FindBestText(symbolDB, texts, language, false, "", ""); if (best != null) return best.CaseOfModified; else return null; }