Exemple #1
0
 public CategoryNodeCollection(CategoryNodeCollection other)
 {
     foreach (CategoryNode node in other)
     {
         Add(node);
     }
 }
Exemple #2
0
 private void ReleaseAllCategoriesButton_Click(object sender, RoutedEventArgs e)
 {
     if (PickedCategories.SelectedIndex == -1)
     {
         while (Rvt.Data.PickedCategories.Count > 0)
         {
             CategoryNode tmp = Rvt.Data.PickedCategories[0];
             Rvt.Data.PickedCategories.RemoveAt(0);
             Rvt.Data.AvailableCategories.Insert(Rvt.Data.AvailableCategories.Count, tmp);
         }
     }
     else
     {
         var tmpCollection = new CategoryNodeCollection();
         foreach (CategoryNode node in PickedCategories.SelectedItems)
         {
             tmpCollection.Add(node);
         }
         foreach (CategoryNode item in tmpCollection)
         {
             Rvt.Data.PickedCategories.Remove(item);
             Rvt.Data.AvailableCategories.Insert(Rvt.Data.AvailableCategories.Count, item);
         }
     }
 }
Exemple #3
0
        private int Partition(CategoryNodeCollection array, int start, int end, bool ascending, bool byName)
        {
            int marker = start;             //divides left and right subarrays

            for (int i = start; i < end; i++)
            {
                //array[end] is pivot
                if (byName == true)
                {
                    if ((ascending == true && array[i].Name.CompareTo(array[end].Name) < 0) ||
                        (ascending == false && array[i].Name.CompareTo(array[end].Name) > 0))
                    {
                        Swap(marker, i);
                        marker += 1;
                    }
                }
                else                 // if sort by elements count
                {
                    if ((ascending == true && array[i].Count < array[end].Count) ||
                        (ascending == false && array[i].Count > array[end].Count))
                    {
                        Swap(marker, i);
                        marker += 1;
                    }
                }
            }
            // put pivot(array[end]) between left and right subarrays
            Swap(marker, end);
            return(marker);
        }
Exemple #4
0
 public RvtData()
 {
     AllCategories       = new CategoryNodeCollection();
     AvailableCategories = new CategoryNodeCollection();
     PickedCategories    = new CategoryNodeCollection();
     AvailableElements   = new ElementCollection();
     PickedElements      = new ElementCollection();
     InitData();
     InitAvailableCategories();
 }
Exemple #5
0
 public bool CategoryNodeInList(CategoryNodeCollection list, CategoryNode categoryNode)
 {
     foreach (var node in list)
     {
         if (node.Category.Equals(categoryNode.Category))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #6
0
        private void Quicksort(CategoryNodeCollection array, int start, int end, bool ascending, bool byName)
        {
            if (start >= end)
            {
                return;
            }
            int pivot = Partition(array, start, end, ascending, byName);

            Quicksort(array, start, pivot - 1, ascending, byName);
            Quicksort(array, pivot + 1, end, ascending, byName);
        }
Exemple #7
0
 public CategoryNode RemoveCategoryNodeFromList(CategoryNodeCollection list, CategoryNode categoryNode)
 {
     if (CategoryNodeInList(list, categoryNode) == false)
     {
         return(null);
     }
     if (list.Remove(categoryNode) == false)
     {
         return(null);
     }
     return(categoryNode);
 }