1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | using Com.Piwigo.Lib.DTO; |
---|
6 | |
---|
7 | namespace Com.Piwigo.Wpf.DTO.Helper |
---|
8 | { |
---|
9 | public static class PwgAlbumListWPFHelper |
---|
10 | { |
---|
11 | public static void AddPwgAlbumToList( PwgAlbum aPwgAlbum, |
---|
12 | ref PwgAlbumListWPF aPwgAlbumListWPF) |
---|
13 | { |
---|
14 | if (aPwgAlbum != null) |
---|
15 | { |
---|
16 | if (aPwgAlbumListWPF == null) |
---|
17 | { |
---|
18 | aPwgAlbumListWPF = new PwgAlbumListWPF(); |
---|
19 | } |
---|
20 | |
---|
21 | PwgAlbumWPF pwgCat = new PwgAlbumWPF(); |
---|
22 | PwgAlbumWPFHelper.ConvertPwgAlbumToPwgAlbumWPF(aPwgAlbum, ref pwgCat); |
---|
23 | |
---|
24 | aPwgAlbumListWPF.Add(pwgCat); |
---|
25 | } |
---|
26 | } |
---|
27 | |
---|
28 | public static void ConvertPwgAlbumListToPwgAlbumListWPF(List<PwgAlbum> aPwgAlbumList, ref PwgAlbumListWPF aPwgAlbumListWPF) |
---|
29 | { |
---|
30 | if (aPwgAlbumList != null) |
---|
31 | { |
---|
32 | if (aPwgAlbumListWPF == null) |
---|
33 | { |
---|
34 | aPwgAlbumListWPF = new PwgAlbumListWPF(); |
---|
35 | } |
---|
36 | |
---|
37 | foreach (PwgAlbum pwgCat in aPwgAlbumList) |
---|
38 | { |
---|
39 | AddPwgAlbumToList(pwgCat, ref aPwgAlbumListWPF); |
---|
40 | } |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | public static void ConvertPwgAlbumListToPwgRootAlbumWPF(List<PwgAlbum> aPwgAlbumList, ref PwgRootAlbumWPF aPwgRootAlbum) |
---|
45 | { |
---|
46 | if (aPwgAlbumList != null) |
---|
47 | { |
---|
48 | if ((aPwgRootAlbum == null) |
---|
49 | || (aPwgRootAlbum.Childrens == null)) |
---|
50 | { |
---|
51 | throw new SystemException("The PwgAlbumListWPFHelper.InitRootAlbum must be called before calling this."); |
---|
52 | } |
---|
53 | |
---|
54 | if (aPwgRootAlbum.Childrens == null) |
---|
55 | { |
---|
56 | aPwgRootAlbum.Childrens = new PwgAlbumListWPF(); |
---|
57 | } |
---|
58 | |
---|
59 | PwgAlbumListWPF aPwgAlbumListWPF = aPwgRootAlbum.Childrens; |
---|
60 | foreach (PwgAlbum pwgCat in aPwgAlbumList) |
---|
61 | { |
---|
62 | AddPwgAlbumToList(pwgCat, ref aPwgAlbumListWPF); |
---|
63 | } |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | public static void InitRootAlbum () |
---|
68 | { |
---|
69 | if (PwgModelManager.Instance.AlbumList == null) |
---|
70 | { |
---|
71 | throw new SystemException("The PwgModelManager.Instance.AlbumList must be initialized from presentation tread before calling this."); |
---|
72 | } |
---|
73 | if (PwgModelManager.Instance.AlbumList.Count != 1) |
---|
74 | { |
---|
75 | PwgModelManager.Instance.AlbumList.Clear(); |
---|
76 | PwgRootAlbumWPF aRootAlbum = new PwgRootAlbumWPF(); |
---|
77 | aRootAlbum.Name = "Albums"; |
---|
78 | aRootAlbum.Childrens = new PwgAlbumListWPF(); |
---|
79 | PwgModelManager.Instance.AlbumList.Add(aRootAlbum); |
---|
80 | PwgModelManager.Instance.RootAlbumList = aRootAlbum; |
---|
81 | } |
---|
82 | |
---|
83 | if (PwgModelManager.Instance.RootAlbumList == null) |
---|
84 | { |
---|
85 | PwgModelManager.Instance.RootAlbumList = PwgModelManager.Instance.AlbumList.ElementAtOrDefault(0); |
---|
86 | } |
---|
87 | |
---|
88 | } |
---|
89 | } |
---|
90 | } |
---|