/// <summary> /// Method to join together selected categories in the listview. /// </summary> /// <param name="categoriesIndices">Indices of selected categories.</param> public void JoinCategories(ArrayList categoriesIndices) { categoriesIndices.Sort(); CategoryType firstType = new CategoryType(); String newName; newName = "Join < "; if (categoriesIndices.Count > 0) { firstType = this.GetCategory(Convert.ToInt32(categoriesIndices[0])).CatType; } else { return; } Category newMultiSet = new Category(); newMultiSet.CatType = firstType; bool firstRun = true; foreach (int index1 in categoriesIndices) { //cannot join multisets of different types if (this.GetCategory(index1).CatType != firstType) { return; } //if the category is of interval type, add all of the intervals to the new category if (newMultiSet.CatType == CategoryType.Interval) { foreach (Interval tempInterval in this.GetCategory(index1).GetIntervals()) { newMultiSet.AddInterval(tempInterval); } } //add all of the enum values otherwise else { newMultiSet.AddSingleSet(this.GetCategory(index1).Set); } if (firstRun) { newName = newName + this.GetCategory(index1).Name; firstRun = false; } else { newName = newName + "; " + this.GetCategory(index1).Name; } } newName = newName + " >"; newMultiSet.Name = newName; int offset = 0; foreach (object index1 in categoriesIndices) { int index = Convert.ToInt32(index1.ToString()); this.RemoveCategory(index - offset); offset++; } this.AddNewCategoryDirect(newMultiSet); this.OnDataStructureChange(); }