PurplePen.SelectionMgr.UpdateSelectedCourseObjects C# (CSharp) Method

UpdateSelectedCourseObjects() private method

private UpdateSelectedCourseObjects ( ) : void
return void
        void UpdateSelectedCourseObjects()
        {
            if (selectionKind == SelectionKind.None) {
                selectedCourseObjects = null;
                return;
            }

            List<CourseObj> list = new List<CourseObj>();

            // Get through each object in the active course and find which ones match. Ignore stuff in the All Controls layer.
            foreach (CourseObj courseobj in activeCourse) {
                if (courseobj.layer != CourseLayer.AllControls) {
                    if (selectionKind == SelectionKind.Control &&
                            !(courseobj is LineCourseObj) &&    // don't select legs
                            courseobj.controlId == selectedControl &&
                            courseobj.courseControlId == selectedCourseControl)
                    {
                        list.Add(courseobj);
                    }
                    else if (selectionKind == SelectionKind.Leg &&
                            courseobj is LineCourseObj &&
                            courseobj.courseControlId == selectedCourseControl &&
                            ((LineCourseObj) courseobj).courseControlId2 == selectedCourseControl2)
                    {
                        // The leg may be made up of multiple parts due to flagging and gaps. Create a single course object for the whole thing.
                        CourseObj legObject = CourseFormatter.CreateSimpleLeg(eventDB, courseobj.scaleRatio, courseobj.appearance, selectedCourseControl, selectedCourseControl2);
                        if (legObject != null)
                            list.Add(legObject);
                        break;
                    }
                    else if (selectionKind == SelectionKind.Special &&
                        courseobj.specialId == selectedSpecial)
                    {
                        list.Add(courseobj);
                    }
                }
            }

            selectedCourseObjects = list.ToArray();
        }