개정판 c7955b40
search 후 Convert 수정
Change-Id: I3c9e136d7fe702e379ec5dfc7b016bb0d3a34745
ConvertService/ServiceBase/Markus.Service.StationController/Controls/GridViewSelectionUtilities.cs | ||
---|---|---|
95 | 95 |
target.Add(o); |
96 | 96 |
} |
97 | 97 |
} |
98 |
//private static bool isSyncingSelection; |
|
99 |
//private static List<Tuple<WeakReference, List<RadGridView>>> collectionToGridViews = new List<Tuple<WeakReference, List<RadGridView>>>(); |
|
100 |
|
|
101 |
//public static readonly DependencyProperty SelectedItemsProperty = DependencyProperty.RegisterAttached( |
|
102 |
// "SelectedItems", |
|
103 |
// typeof(INotifyCollectionChanged), |
|
104 |
// typeof(GridViewSelectionUtilities), |
|
105 |
// new PropertyMetadata(null, OnSelectedItemsChanged)); |
|
106 |
|
|
107 |
//public static INotifyCollectionChanged GetSelectedItems(DependencyObject obj) |
|
108 |
//{ |
|
109 |
// return (INotifyCollectionChanged)obj.GetValue(SelectedItemsProperty); |
|
110 |
//} |
|
111 |
|
|
112 |
//public static void SetSelectedItems(DependencyObject obj, INotifyCollectionChanged value) |
|
113 |
//{ |
|
114 |
// obj.SetValue(SelectedItemsProperty, value); |
|
115 |
//} |
|
116 |
|
|
117 |
//private static void OnSelectedItemsChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) |
|
118 |
//{ |
|
119 |
// var gridView = (RadGridView)target; |
|
120 |
|
|
121 |
// var oldCollection = args.OldValue as INotifyCollectionChanged; |
|
122 |
// if (oldCollection != null) |
|
123 |
// { |
|
124 |
// gridView.SelectionChanged -= GridView_SelectionChanged; |
|
125 |
// oldCollection.CollectionChanged -= SelectedItems_CollectionChanged; |
|
126 |
// RemoveAssociation(oldCollection, gridView); |
|
127 |
// } |
|
128 |
|
|
129 |
// var newCollection = args.NewValue as INotifyCollectionChanged; |
|
130 |
// if (newCollection != null) |
|
131 |
// { |
|
132 |
// gridView.SelectionChanged += GridView_SelectionChanged; |
|
133 |
// newCollection.CollectionChanged += SelectedItems_CollectionChanged; |
|
134 |
// AddAssociation(newCollection, gridView); |
|
135 |
// OnSelectedItemsChanged(newCollection, null, (IList)newCollection); |
|
136 |
// } |
|
137 |
//} |
|
138 |
|
|
139 |
//private static void SelectedItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs args) |
|
140 |
//{ |
|
141 |
// INotifyCollectionChanged collection = (INotifyCollectionChanged)sender; |
|
142 |
// OnSelectedItemsChanged(collection, args.OldItems, args.NewItems); |
|
143 |
//} |
|
144 |
|
|
145 |
//private static void GridView_SelectionChanged(object sender, SelectionChangeEventArgs args) |
|
146 |
//{ |
|
147 |
// if (isSyncingSelection) |
|
148 |
// { |
|
149 |
// return; |
|
150 |
// } |
|
151 |
|
|
152 |
// var collection = (IList)GetSelectedItems((RadGridView)sender); |
|
153 |
// foreach (object item in args.RemovedItems) |
|
154 |
// { |
|
155 |
// collection.Remove(item); |
|
156 |
// } |
|
157 |
// foreach (object item in args.AddedItems) |
|
158 |
// { |
|
159 |
// collection.Add(item); |
|
160 |
// } |
|
161 |
//} |
|
162 |
|
|
163 |
//private static void OnSelectedItemsChanged(INotifyCollectionChanged collection, IList oldItems, IList newItems) |
|
164 |
//{ |
|
165 |
// isSyncingSelection = true; |
|
166 |
|
|
167 |
// var gridViews = GetOrCreateGridViews(collection); |
|
168 |
// foreach (var gridView in gridViews) |
|
169 |
// { |
|
170 |
// SyncSelection(gridView, oldItems, newItems); |
|
171 |
// } |
|
172 |
|
|
173 |
// isSyncingSelection = false; |
|
174 |
//} |
|
175 |
|
|
176 |
//private static void SyncSelection(RadGridView gridView, IList oldItems, IList newItems) |
|
177 |
//{ |
|
178 |
// if (oldItems != null) |
|
179 |
// { |
|
180 |
// SetItemsSelection(gridView, oldItems, false); |
|
181 |
// } |
|
182 |
|
|
183 |
// if (newItems != null) |
|
184 |
// { |
|
185 |
// SetItemsSelection(gridView, newItems, true); |
|
186 |
// } |
|
187 |
//} |
|
188 |
|
|
189 |
//private static void SetItemsSelection(RadGridView gridView, IList items, bool shouldSelect) |
|
190 |
//{ |
|
191 |
// foreach (var item in items) |
|
192 |
// { |
|
193 |
// bool contains = gridView.SelectedItems.Contains(item); |
|
194 |
// if (shouldSelect && !contains) |
|
195 |
// { |
|
196 |
// gridView.SelectedItems.Add(item); |
|
197 |
// } |
|
198 |
// else if (contains && !shouldSelect) |
|
199 |
// { |
|
200 |
// gridView.SelectedItems.Remove(item); |
|
201 |
// } |
|
202 |
// } |
|
203 |
//} |
|
204 |
|
|
205 |
//private static void AddAssociation(INotifyCollectionChanged collection, RadGridView gridView) |
|
206 |
//{ |
|
207 |
// List<RadGridView> gridViews = GetOrCreateGridViews(collection); |
|
208 |
// gridViews.Add(gridView); |
|
209 |
//} |
|
210 |
|
|
211 |
//private static void RemoveAssociation(INotifyCollectionChanged collection, RadGridView gridView) |
|
212 |
//{ |
|
213 |
// List<RadGridView> gridViews = GetOrCreateGridViews(collection); |
|
214 |
// gridViews.Remove(gridView); |
|
215 |
|
|
216 |
// if (gridViews.Count == 0) |
|
217 |
// { |
|
218 |
// CleanUp(); |
|
219 |
// } |
|
220 |
//} |
|
221 |
|
|
222 |
//private static List<RadGridView> GetOrCreateGridViews(INotifyCollectionChanged collection) |
|
223 |
//{ |
|
224 |
// for (int i = 0; i < collectionToGridViews.Count; i++) |
|
225 |
// { |
|
226 |
// var wr = collectionToGridViews[i].Item1; |
|
227 |
// if (wr.Target == collection) |
|
228 |
// { |
|
229 |
// return collectionToGridViews[i].Item2; |
|
230 |
// } |
|
231 |
// } |
|
232 |
|
|
233 |
// collectionToGridViews.Add(new Tuple<WeakReference, List<RadGridView>>(new WeakReference(collection), new List<RadGridView>())); |
|
234 |
// return collectionToGridViews[collectionToGridViews.Count - 1].Item2; |
|
235 |
//} |
|
236 |
|
|
237 |
//private static void CleanUp() |
|
238 |
//{ |
|
239 |
// for (int i = collectionToGridViews.Count - 1; i >= 0; i--) |
|
240 |
// { |
|
241 |
// bool isAlive = collectionToGridViews[i].Item1.IsAlive; |
|
242 |
// var behaviors = collectionToGridViews[i].Item2; |
|
243 |
// if (behaviors.Count == 0 || !isAlive) |
|
244 |
// { |
|
245 |
// collectionToGridViews.RemoveAt(i); |
|
246 |
// } |
|
247 |
// } |
|
248 |
//} |
|
249 | 98 |
} |
250 | 99 |
} |
내보내기 Unified diff