// Sets the current selection. No feedback is provided as to whether the selection // is valid; if invalid, the selection will simply be cleared when it is retrieved. private void SetSelection(SelectionKind selectionKind, Id<CourseControl> courseControlId, Id<CourseControl> courseControlId2, LegInsertionLoc legInsertionLoc, Id<ControlPoint> controlId, Id<Special> specialId, Symbol keySymbol, DescriptionLine.TextLineKind textLineKind) { if (this.selectionKind != selectionKind || this.selectedCourseControl != courseControlId || this.selectedCourseControl2 != courseControlId2 || this.selectedControl != controlId || this.selectedSpecial != specialId) { controller.ScrollHighlightIntoView = true; // scroll the newly selection item into view. } ++selectionChangeNum; this.selectionKind = selectionKind; this.selectedCourseControl = courseControlId; this.selectedCourseControl2 = courseControlId2; this.legInsertionLoc = legInsertionLoc; this.selectedControl = controlId; this.selectedSpecial = specialId; this.selectedKeySymbol = keySymbol; this.selectedTextLineKind = textLineKind; }
// Sets the current selection. No feedback is provided as to whether the selection // is valid; if invalid, the selection will simply be cleared when it is retrieved. private void SetSelection(SelectionKind selectionKind, Id<CourseControl> courseControlId, Id<CourseControl> courseControlId2, Id<ControlPoint> controlId, Id<Special> specialId, Symbol keySymbol, DescriptionLine.TextLineKind textLineKind) { if (this.selectionKind != selectionKind || this.selectedCourseControl != courseControlId || this.selectedCourseControl2 != courseControlId2 || this.selectedControl != controlId || this.selectedSpecial != specialId) { controller.ScrollHighlightIntoView = true; // scroll the newly selection item into view. } ++selectionChangeNum; this.selectionKind = selectionKind; this.selectedCourseControl = courseControlId; this.selectedCourseControl2 = courseControlId2; this.selectedControl = controlId; this.selectedSpecial = specialId; this.selectedKeySymbol = keySymbol; this.selectedTextLineKind = textLineKind; }
// Given some text, a text line for it to a list if the text is non-empty. private void AddTextLine(List <DescriptionLine> list, string text, Id <CourseControl> courseControlId, Id <ControlPoint> controlId, DescriptionLine.TextLineKind textLineKind) { if (!string.IsNullOrEmpty(text)) { list.AddRange(GetTextLineFromText(text, courseControlId, controlId, textLineKind)); } }
// Given the text, create one or more text lines for that text. Lines are split by vertical bars. private DescriptionLine[] GetTextLineFromText(string text, Id <CourseControl> courseControlId, Id <ControlPoint> controlId, DescriptionLine.TextLineKind textLineKind) { string[] texts = text.Split(new char[] { '|' }); int lineCount = texts.Length; DescriptionLine[] lines = new DescriptionLine[lineCount]; for (int index = 0; index < lineCount; ++index) { DescriptionLine line = new DescriptionLine(); line.kind = DescriptionLineKind.Text; line.boxes = new object[1]; line.boxes[0] = texts[index]; line.textual = texts[index]; line.courseControlId = courseControlId; line.controlId = controlId; line.textLineKind = textLineKind; lines[index] = line; } return(lines); }
// Select a text line public void SelectTextLine(Id<ControlPoint> controlId, Id<CourseControl> courseControlId, DescriptionLine.TextLineKind textLineKind) { SetSelection(SelectionKind.TextLine, courseControlId, Id<CourseControl>.None, LegInsertionLoc.Normal, controlId, Id<Special>.None, null, textLineKind); }
// Describe text line private static TextPart[] DescribeTextLine(EventDB eventDB, Id <ControlPoint> controlId, DescriptionLine.TextLineKind textLineKind) { List <TextPart> list = new List <TextPart>(); list.Add(new TextPart(TextFormat.Title, SelectionDescriptionText.TextLine)); list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Location)); string format; switch (textLineKind) { case DescriptionLine.TextLineKind.BeforeControl: format = SelectionDescriptionText.TextLine_AboveAllCourses; break; case DescriptionLine.TextLineKind.BeforeCourseControl: format = SelectionDescriptionText.TextLine_AboveThisCourse; break; case DescriptionLine.TextLineKind.AfterControl: format = SelectionDescriptionText.TextLine_BelowAllCourses; break; case DescriptionLine.TextLineKind.AfterCourseControl: format = SelectionDescriptionText.TextLine_BelowThisCourse; break; case DescriptionLine.TextLineKind.None: default: return(list.ToArray()); } list.Add(new TextPart(TextFormat.NewLine, string.Format(format, Util.ControlPointName(eventDB, controlId, NameStyle.Long)))); return(list.ToArray()); }