public static GetBestSymbolText ( |
||
symbolDB | ||
texts | List |
|
language | string | |
plural | bool | |
gender | string | |
nounCase | string | |
리턴 | string |
// Get the plural text for a symbol. Checks the eventDB for overrides to the symbol text; otherwise uses the default for the symbol. string GetSymbolPluralText(Symbol symbol, string gender, string nounCase = "") { Event ev = eventDB.GetEvent(); string id = symbol.Id; if (ev.customSymbolText.ContainsKey(id) && Symbol.ContainsLanguage(ev.customSymbolText[id], language)) { return(Symbol.GetBestSymbolText(symbolDB, ev.customSymbolText[id], language, true, gender, nounCase)); } else { return(symbol.GetPluralText(language, gender, nounCase)); } }
// Fill the grid with the values in symbolTexts. void UpdateGrid() { bool usePlurals = numberColumn.Visible = checkBoxPlural.Checked; bool useGender = genderColumn.Visible = checkBoxGender.Checked; bool useCases = caseColumn.Visible = checkBoxCases.Checked; dataGridView.Rows.Clear(); int genderIndex = 0, caseIndex = 0; bool plural = false; for (; ;) { string gender = useGender ? symLanguage.Genders[genderIndex] : ""; string nounCase = useCases ? symLanguage.Cases[caseIndex] : ""; string text = Symbol.GetBestSymbolText(symbolDB, symbolTexts, symLanguage.LangId, plural, gender, nounCase); int index = dataGridView.Rows.Add(); dataGridView[0, index].Value = plural ? MiscText.Plural : MiscText.Singular; dataGridView[1, index].Value = gender; dataGridView[2, index].Value = nounCase; dataGridView[3, index].Value = SanitizeFillIn(text); if (useCases && caseIndex < symLanguage.Cases.Length - 1) { caseIndex += 1; } else if (useGender && genderIndex < symLanguage.Genders.Length - 1) { genderIndex += 1; // go to next gender caseIndex = 0; } else if (usePlurals && !plural) { genderIndex = 0; // go to next number caseIndex = 0; plural = true; } else { break; // done. } } dataGridView.AutoResizeColumns(); dataGridView.CurrentCell = dataGridView[3, 0]; }
// Get a regular 8-box line for a start or regular control. private DescriptionLine GetRegularLine(CourseView.CourseViewKind kind, int scoreColumn, CourseView.ControlView controlView, Dictionary <string, string> descriptionKey) { Event ev = eventDB.GetEvent(); ControlPoint control = eventDB.GetControl(controlView.controlId); CourseControl courseControl; if (controlView.courseControlIds[0].IsNone) { courseControl = null; } else { courseControl = eventDB.GetCourseControl(controlView.courseControlIds[0]); } Debug.Assert(control.kind == ControlPointKind.Normal || control.kind == ControlPointKind.Start || control.kind == ControlPointKind.MapExchange); DescriptionLine line = new DescriptionLine(); line.kind = DescriptionLineKind.Normal; line.boxes = new object[8]; // Box A: ordinal or start triangle or points. if (control.kind == ControlPointKind.Start || control.kind == ControlPointKind.MapExchange) { line.boxes[0] = symbolDB["start"]; } else if (kind != CourseView.CourseViewKind.AllControls && controlView.ordinal > 0) { line.boxes[0] = Convert.ToString(controlView.ordinal); } else { line.boxes[0] = null; } // Box B: code of the control if (control.kind == ControlPointKind.Normal) { line.boxes[1] = Convert.ToString(control.code); } // Boxes C-H, from the symbols for (int i = 2; i < 8; ++i) { String symbolID = control.symbolIds[i - 2]; if (symbolID != null) { line.boxes[i] = symbolDB[control.symbolIds[i - 2]]; // See if we need to add this to the key. bool addToKey; if (ev.customSymbolKey.TryGetValue(symbolID, out addToKey) && addToKey && Symbol.ContainsLanguage(ev.customSymbolText[symbolID], language)) { descriptionKey[symbolID] = Symbol.GetBestSymbolText(symbolDB, ev.customSymbolText[symbolID], language, false, "", ""); } } } // Box F -- may be text instead of a symbol. if (control.columnFText != null) { Debug.Assert(line.boxes[5] == null); line.boxes[5] = control.columnFText; } // Put points in the score column, for a score course. if (control.kind == ControlPointKind.Normal && scoreColumn >= 0 && courseControl != null) { int points = courseControl.points; if (points > 0) { line.boxes[scoreColumn] = Convert.ToString(courseControl.points); } else { line.boxes[scoreColumn] = null; } } // Get the text version of the control using the Textifier. Textifier textifier = new Textifier(eventDB, symbolDB, language); line.textual = textifier.CreateTextForControl(controlView.controlId, ""); // The course control ID, for use in coordinating the selection line.controlId = controlView.controlId; line.courseControlId = controlView.courseControlIds[0]; return(line); }