Ignore:
Timestamp:
Aug 12, 2011, 4:32:33 PM (13 years ago)
Author:
bayral
Message:

root category handled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/PiwigoLib/PiwigoWpf/DTO/Helper/PwgCategoryListWPFHelper.cs

    r11911 r11935  
    3434                    aPwgCategoryListWPF = new PwgCategoryListWPF();
    3535                }
     36
    3637                foreach (PwgCategory pwgCat in aPwgCategoryList)
    3738                {
     
    4041            }
    4142        }
     43
     44        public static void ConvertPwgCategoryListToPwgRootCategoryWPF(List<PwgCategory> aPwgCategoryList, ref PwgRootCategoryWPF aPwgRootCategory)
     45        {
     46            if (aPwgCategoryList != null)
     47            {
     48                if ((aPwgRootCategory == null)
     49                    || (aPwgRootCategory.Childrens == null))
     50                {
     51                    throw new SystemException("The PwgCategoryListWPFHelper.InitRootCategory must be called before calling this.");
     52                }
     53
     54                if (aPwgRootCategory.Childrens == null)
     55                {
     56                    aPwgRootCategory.Childrens = new PwgCategoryListWPF();
     57                }
     58
     59                PwgCategoryListWPF aPwgCategoryListWPF = aPwgRootCategory.Childrens;
     60                foreach (PwgCategory pwgCat in aPwgCategoryList)
     61                {
     62                    AddPwgCategoryToList(pwgCat, ref aPwgCategoryListWPF);
     63                }
     64            }
     65        }
     66
     67        public static void InitRootCategory ()
     68          {
     69            if (PwgModelManager.Instance.CategoryList == null)
     70            {
     71                throw new SystemException("The PwgModelManager.Instance.CategoryList must be initialized from presentation tread before calling this.");
     72            }
     73            if (PwgModelManager.Instance.CategoryList.Count != 1)
     74            {
     75                PwgModelManager.Instance.CategoryList.Clear();
     76                PwgRootCategoryWPF aRootCategory = new PwgRootCategoryWPF();
     77                aRootCategory.Name = "Root";
     78                aRootCategory.Childrens = new PwgCategoryListWPF();
     79                PwgModelManager.Instance.CategoryList.Add(aRootCategory);
     80                PwgModelManager.Instance.RootCategoryList = aRootCategory;
     81            }
     82
     83            if (PwgModelManager.Instance.RootCategoryList == null)
     84            {
     85                PwgModelManager.Instance.RootCategoryList = PwgModelManager.Instance.CategoryList.ElementAtOrDefault(0);
     86            }
     87
     88          }
    4289    }
    4390}
Note: See TracChangeset for help on using the changeset viewer.