コード例 #1
0
        private void FillAssgnCheckedListBox(IEnumerable <string> activeCats)
        {
            List <string> prevUnchecked = new List <string>();
            List <string> prevExisted   = new List <string>();

            foreach (var item in CheckedListBoxAssignments.Items)
            {
                prevExisted.Add(item.ToString());
                if (!CheckedListBoxAssignments.CheckedItems.Contains(item))
                {
                    prevUnchecked.Add(item.ToString());
                }
            }
            CheckedListBoxAssignments.Items.Clear();

            List <string> assgnsInCats = new List <string>();

            foreach (var item in activeCats)
            {
                int          index      = _schoolClass.CatExists(item);
                Assignment[] tempAssgns = _schoolClass.GetAssgnsInCat(index);
                foreach (Assignment assgn in tempAssgns)
                {
                    assgnsInCats.Add(assgn.name);
                }
            }
            foreach (string assgnName in assgnsInCats)
            {
                CheckedListBoxAssignments.Items.Add(assgnName);
                if (prevExisted.Contains(assgnName))
                {
                    CheckedListBoxAssignments.SetItemChecked(CheckedListBoxAssignments.Items.IndexOf(assgnName),
                                                             !prevUnchecked.Contains(assgnName));
                }
                else
                {
                    CheckedListBoxAssignments.SetItemChecked(CheckedListBoxAssignments.Items.IndexOf(assgnName), true);
                }
            }
        }
コード例 #2
0
        private void InitAssgnCheckedListBox(string curveName)
        {
            CheckedListBoxAssignments.Items.Clear();

            Curve         curve        = _schoolClass.curves[_schoolClass.CurveExists(curveName)];
            List <string> assgnsInCats = new List <string>();

            foreach (int index in curve.appliedCatIndexes)
            {
                Assignment[] tempAssgns = _schoolClass.GetAssgnsInCat(index);
                foreach (Assignment assgn in tempAssgns)
                {
                    assgnsInCats.Add(assgn.name);
                }
            }
            foreach (string assgnName in assgnsInCats)
            {
                CheckedListBoxAssignments.Items.Add(assgnName);
                CheckedListBoxAssignments.SetItemChecked(CheckedListBoxAssignments.Items.IndexOf(assgnName),
                                                         curve.appliedAssgnNames.Contains(assgnName));
            }
        }