Revision 759bd3c4 trunk/Pithos.Client.WPF/SelectiveSynch/DirectoryRecord.cs
b/trunk/Pithos.Client.WPF/SelectiveSynch/DirectoryRecord.cs | ||
---|---|---|
47 | 47 |
using System.Linq; |
48 | 48 |
using System.Text; |
49 | 49 |
using Caliburn.Micro; |
50 |
using Pithos.Core.Agents; |
|
51 |
using Pithos.Interfaces; |
|
50 | 52 |
|
51 | 53 |
namespace Pithos.Client.WPF.SelectiveSynch |
52 | 54 |
{ |
53 | 55 |
public class DirectoryRecord : PropertyChangedBase,IEnumerable<DirectoryRecord> |
54 | 56 |
{ |
55 |
public DirectoryInfo Info { get; set; } |
|
57 |
private ObjectInfo _objectInfo; |
|
58 |
public ObjectInfo ObjectInfo |
|
59 |
{ |
|
60 |
get { return _objectInfo; } |
|
61 |
set |
|
62 |
{ |
|
63 |
_objectInfo = value; |
|
64 |
Uri = value.Uri; |
|
65 |
} |
|
66 |
} |
|
56 | 67 |
|
68 |
public Uri Uri { get; set; } |
|
69 |
//public DirectoryInfo LocalInfo { get; set; } |
|
57 | 70 |
|
58 | 71 |
DirectoryRecord _parent; |
59 | 72 |
|
60 | 73 |
public bool Added { get; set; } |
61 | 74 |
public bool Removed { get; set; } |
62 | 75 |
|
63 |
private bool? _isChecked; |
|
76 |
private bool? _isChecked=true;
|
|
64 | 77 |
#region IsChecked |
65 | 78 |
|
66 | 79 |
/// <summary> |
... | ... | |
88 | 101 |
Removed = !(_isChecked??true); |
89 | 102 |
|
90 | 103 |
if (updateChildren && _isChecked.HasValue) |
91 |
this.Directories.ForEach(c => c.SetIsChecked(_isChecked, true, false));
|
|
104 |
this.Directories.Apply(c => c.SetIsChecked(_isChecked, true, false));
|
|
92 | 105 |
|
93 | 106 |
if (updateParent && _parent != null) |
94 | 107 |
_parent.VerifyCheckState(); |
... | ... | |
99 | 112 |
void VerifyCheckState() |
100 | 113 |
{ |
101 | 114 |
bool? state = null; |
102 |
for (int i = 0; i < this.Directories.Count; ++i)
|
|
115 |
for (var i = 0; i < this.Directories.Count(); ++i)
|
|
103 | 116 |
{ |
104 |
bool? current = this.Directories[i].IsChecked;
|
|
117 |
bool? current = this.Directories.ElementAt(i).IsChecked;
|
|
105 | 118 |
if (i == 0) |
106 | 119 |
{ |
107 | 120 |
state = current; |
... | ... | |
120 | 133 |
|
121 | 134 |
public bool IsInitiallySelected { get; private set; } |
122 | 135 |
|
123 |
readonly Lazy<List<DirectoryRecord>> _directories = new Lazy<List<DirectoryRecord>>(); |
|
136 |
/*readonly Lazy<List<DirectoryRecord>> _directories = new Lazy<List<DirectoryRecord>>();
|
|
124 | 137 |
|
125 | 138 |
public List<DirectoryRecord> Directories |
126 | 139 |
{ |
... | ... | |
128 | 141 |
{ |
129 | 142 |
return _directories.Value; |
130 | 143 |
} |
144 |
}*/ |
|
145 |
|
|
146 |
private IEnumerable<DirectoryRecord> _directories=new List<DirectoryRecord>(); |
|
147 |
public IEnumerable<DirectoryRecord> Directories |
|
148 |
{ |
|
149 |
get { return _directories; } |
|
150 |
set { _directories = value; } |
|
131 | 151 |
} |
132 | 152 |
|
133 |
public DirectoryRecord(string ignorePath)
|
|
153 |
public DirectoryRecord() |
|
134 | 154 |
{ |
135 |
_directories = new Lazy<List<DirectoryRecord>>(() => |
|
155 |
|
|
156 |
/* |
|
157 |
_directories = new Lazy<List<DirectoryRecord>>(() => |
|
158 |
new List<DirectoryRecord>()); |
|
159 |
*/ |
|
160 |
/* |
|
161 |
_directories = new Lazy<List<DirectoryRecord>>(() => |
|
136 | 162 |
(from directory in Info.EnumerateDirectories("*", SearchOption.TopDirectoryOnly) |
137 | 163 |
where !directory.FullName.StartsWith(ignorePath) |
138 | 164 |
select new DirectoryRecord(ignorePath) { Info = directory }).ToList()); |
165 |
*/ |
|
139 | 166 |
} |
140 | 167 |
|
168 |
private string _displayName; |
|
169 |
public string DisplayName |
|
170 |
{ |
|
171 |
get |
|
172 |
{ |
|
173 |
if (ObjectInfo != null) |
|
174 |
return ObjectInfo.Name; |
|
175 |
return _displayName; |
|
176 |
} |
|
177 |
set { _displayName = value; } |
|
178 |
} |
|
179 |
|
|
180 |
public DirectoryRecord(string rootPath,ObjectInfo info) |
|
181 |
{ |
|
182 |
var relativePath = info.RelativeUrlToFilePath(info.Account); |
|
183 |
//LocalInfo = new DirectoryInfo(Path.Combine(rootPath, relativePath)); |
|
184 |
ObjectInfo = info; |
|
185 |
} |
|
141 | 186 |
|
142 | 187 |
|
143 | 188 |
/* |
Also available in: Unified diff