なろうブックマーク分析用ツールのPrism+WinUI3サンプル実装
Revisão | a4f2ab01ffea43b75bf3d2a65bd2b608b13b3c8f (tree) |
---|---|
Hora | 2022-08-24 07:54:20 |
Autor | yoshy <yoshy.org.bitbucket@gz.j...> |
Commiter | yoshy |
[MOD] SortableSynchronizedCoupleView によるソート処理の実装(すべての列を移行)
@@ -22,6 +22,7 @@ namespace TestNarou3.Adaptor.Boundary.Gateway.ViewModel | ||
22 | 22 | |
23 | 23 | void SynchronizeWith(BookmarkDetailList list); |
24 | 24 | |
25 | - void Sort(string tag, Func<IBookmarkDetailListRowViewModel, string> selector, bool asceding); | |
25 | + void SortByValueColumn<TValueColumn>(string tag, Func<BookmarkDetailListRow, TValueColumn> selector, bool asceding); | |
26 | + void SortByViewColumn<TViewColumn>(string tag, Func<IBookmarkDetailListRowViewModel, TViewColumn> selector, bool asceding); | |
26 | 27 | } |
27 | 28 | } |
@@ -9,6 +9,7 @@ using System.Collections.ObjectModel; | ||
9 | 9 | using System.ComponentModel; |
10 | 10 | using System.Diagnostics; |
11 | 11 | using System.Reactive.Disposables; |
12 | +using System.Windows.Input; | |
12 | 13 | using TestNarou3.Adaptor.Boundary.Controller; |
13 | 14 | using TestNarou3.Adaptor.Boundary.Gateway.ViewModel; |
14 | 15 | using TestNarou3.Adaptor.Boundary.Gateway.ViewModel.Child; |
@@ -86,11 +87,10 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel | ||
86 | 87 | |
87 | 88 | public void SynchronizeWith(BookmarkDetailList source) |
88 | 89 | { |
89 | -#if true | |
90 | 90 | if (this.Source == null) |
91 | 91 | { |
92 | 92 | this.SortableRows = source.Rows |
93 | - .ToSortableSynchronizedCoupleView(r => r.NCode, r => this.vmTranslator.Translate(r, this), new DetailListComparer(r => r.Title.Value, true)); | |
93 | + .ToSortableSynchronizedCoupleView(r => r.NCode, r => this.vmTranslator.Translate(r, this), new DetailListViewComparer<string>(r => r.Title.Value, true)); | |
94 | 94 | |
95 | 95 | this.Rows = this.SortableRows |
96 | 96 | .ToSynchronizedSingleView() |
@@ -107,52 +107,80 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel | ||
107 | 107 | logger.Trace("BookmarkDetailListViewModel.SynchronizeWith: viewmodel already synchronized to model [{0}]", |
108 | 108 | this.Source.ToHashString()); |
109 | 109 | } |
110 | -#else | |
111 | - if (this.Rows != null) | |
110 | + } | |
111 | + | |
112 | + public void SortByViewColumn<TViewColumn>(string tag, Func<IBookmarkDetailListRowViewModel, TViewColumn> selector, bool ascending) | |
113 | + { | |
114 | + logger.Trace("Sort: {0}, ascending = {1}", tag, ascending); | |
115 | + this.SortableRows.Sort(new DetailListViewComparer<TViewColumn>(selector, ascending)); | |
116 | + } | |
117 | + | |
118 | + public void SortByValueColumn<TValueColumn>(string tag, Func<BookmarkDetailListRow, TValueColumn> selector, bool ascending) | |
119 | + { | |
120 | + logger.Trace("Sort: {0}, ascending = {1}", tag, ascending); | |
121 | + this.SortableRows.Sort(new DetailListValueComparer<TValueColumn>(selector, ascending)); | |
122 | + } | |
123 | + | |
124 | + internal class DetailListViewComparer<TViewColumn> : ViewComparer<string, BookmarkDetailListRow, IBookmarkDetailListRowViewModel, TViewColumn> | |
125 | + { | |
126 | + public DetailListViewComparer( | |
127 | + Func<IBookmarkDetailListRowViewModel, TViewColumn> selector, bool ascending = true | |
128 | + ) : base(selector, ascending) | |
112 | 129 | { |
113 | - this.Rows.Dispose(); | |
114 | - this.disposables.Remove(this.Rows); | |
115 | 130 | } |
131 | + } | |
116 | 132 | |
117 | - this.SortableRows = new FreezedList<BookmarkDetailListRow>(source.Rows) | |
118 | - .ToSynchronizedSortableCoupleView(r => this.vmTranslator.Translate(r, this), | |
119 | - new ViewComparer<IBookmarkDetailListRowViewModel, string>(r => r.Title.Value)); | |
133 | + internal class ViewComparer<TKey, T, TView, TViewColumn> : IComparer<(TKey, T, TView)> | |
134 | + { | |
135 | + readonly Func<TView, TViewColumn> selector; | |
136 | + readonly int f; | |
120 | 137 | |
121 | - this.Rows = this.SortableRows | |
122 | - .ToSynchronizedSingleView() | |
123 | - .WithINotifyCollectionChangedList() | |
124 | - .AddTo(disposables); | |
138 | + public ViewComparer(Func<TView, TViewColumn> selector, bool ascending = true) | |
139 | + { | |
140 | + this.selector = selector; | |
141 | + this.f = ascending ? 1 : -1; | |
142 | + } | |
125 | 143 | |
126 | - this.Source = source; | |
144 | + public int Compare((TKey, T, TView) x, (TKey, T, TView) y) | |
145 | + { | |
146 | + int c = Comparer<TViewColumn>.Default.Compare(selector(x.Item3), selector(y.Item3)) * f; | |
147 | + | |
148 | + if (c == 0) | |
149 | + { | |
150 | + c = Comparer<TKey>.Default.Compare(x.Item1, y.Item1) * f; | |
151 | + } | |
127 | 152 | |
128 | - // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Rows")); | |
129 | -#endif | |
153 | + return c; | |
154 | + } | |
130 | 155 | } |
131 | 156 | |
132 | - public void Sort(string tag, Func<IBookmarkDetailListRowViewModel, string> selector, bool ascending) | |
157 | + internal class DetailListValueComparer<TValueColumn> : ValueComparer<string, BookmarkDetailListRow, IBookmarkDetailListRowViewModel, TValueColumn> | |
133 | 158 | { |
134 | - logger.Trace("Sort: {0}, ascending = {1}", tag, ascending); | |
135 | - this.SortableRows.Sort(new DetailListComparer(selector, ascending)); | |
159 | + public DetailListValueComparer( | |
160 | + Func<BookmarkDetailListRow, TValueColumn> selector, bool ascending = true | |
161 | + ) : base(selector, ascending) | |
162 | + { | |
163 | + } | |
136 | 164 | } |
137 | 165 | |
138 | - internal class DetailListComparer : IComparer<(string, BookmarkDetailListRow, IBookmarkDetailListRowViewModel)> | |
166 | + internal class ValueComparer<TKey, T, TView, TValueColumn> : IComparer<(TKey, T, TView)> | |
139 | 167 | { |
140 | - readonly Func<IBookmarkDetailListRowViewModel, string> selector; | |
168 | + readonly Func<T, TValueColumn> selector; | |
141 | 169 | readonly int f; |
142 | 170 | |
143 | - public DetailListComparer(Func<IBookmarkDetailListRowViewModel, string> selector, bool ascending = true) | |
171 | + public ValueComparer(Func<T, TValueColumn> selector, bool ascending = true) | |
144 | 172 | { |
145 | 173 | this.selector = selector; |
146 | 174 | this.f = ascending ? 1 : -1; |
147 | 175 | } |
148 | 176 | |
149 | - public int Compare((string, BookmarkDetailListRow, IBookmarkDetailListRowViewModel) x, (string, BookmarkDetailListRow, IBookmarkDetailListRowViewModel) y) | |
177 | + public int Compare((TKey, T, TView) x, (TKey, T, TView) y) | |
150 | 178 | { |
151 | - int c = selector(x.Item3).CompareTo(selector(y.Item3)) * f; | |
179 | + int c = Comparer<TValueColumn>.Default.Compare(selector(x.Item2), selector(y.Item2)) * f; | |
152 | 180 | |
153 | 181 | if (c == 0) |
154 | 182 | { |
155 | - c = x.Item1.CompareTo(y.Item1); | |
183 | + c = Comparer<TKey>.Default.Compare(x.Item1, y.Item1) * f; | |
156 | 184 | } |
157 | 185 | |
158 | 186 | return c; |
@@ -191,6 +219,5 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel | ||
191 | 219 | } |
192 | 220 | |
193 | 221 | #endregion |
194 | - | |
195 | 222 | } |
196 | 223 | } |
@@ -58,7 +58,7 @@ | ||
58 | 58 | </DataTemplate> |
59 | 59 | </ctc:DataGridTemplateColumn.CellTemplate> |
60 | 60 | </ctc:DataGridTemplateColumn> |
61 | - <ctc:DataGridTemplateColumn Header="タイトル" Width="300" CanUserSort="False"> | |
61 | + <ctc:DataGridTemplateColumn Header="タイトル" Width="300" Tag="Title"> | |
62 | 62 | <ctc:DataGridTemplateColumn.CellTemplate> |
63 | 63 | <DataTemplate x:DataType="vm:IBookmarkDetailListRowViewModel"> |
64 | 64 | <Grid VerticalAlignment="Center"> |
@@ -46,19 +46,28 @@ namespace TestNarou3.OuterEdge.UI.View | ||
46 | 46 | |
47 | 47 | switch (tag) |
48 | 48 | { |
49 | + case "Title": | |
50 | + if ((e.Column.SortDirection == null) || (direction == DataGridSortDirection.Descending)) | |
51 | + { | |
52 | + this.ViewModel.SortByViewColumn(tag, r => r.Title.Value, true); | |
53 | + e.Column.SortDirection = DataGridSortDirection.Ascending; | |
54 | + } | |
55 | + else | |
56 | + { | |
57 | + this.ViewModel.SortByViewColumn(tag, r => r.Title.Value, false); | |
58 | + e.Column.SortDirection = DataGridSortDirection.Descending; | |
59 | + } | |
60 | + break; | |
61 | + | |
49 | 62 | case "Writer": |
50 | 63 | if ((e.Column.SortDirection == null) || (direction == DataGridSortDirection.Descending)) |
51 | 64 | { |
52 | - //dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
53 | - // from item in ViewModel.Rows orderby item.Writer.Value ascending select item); | |
54 | - this.ViewModel.Sort(tag, r => r.Writer.Value, true); | |
65 | + this.ViewModel.SortByViewColumn(tag, r => r.Writer.Value, true); | |
55 | 66 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
56 | 67 | } |
57 | 68 | else |
58 | 69 | { |
59 | - //dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
60 | - // from item in ViewModel.Rows orderby item.Writer.Value descending select item); | |
61 | - this.ViewModel.Sort(tag, r => r.Writer.Value, false); | |
70 | + this.ViewModel.SortByViewColumn(tag, r => r.Writer.Value, false); | |
62 | 71 | e.Column.SortDirection = DataGridSortDirection.Descending; |
63 | 72 | } |
64 | 73 | break; |
@@ -66,14 +75,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
66 | 75 | case "End": |
67 | 76 | if (direction == DataGridSortDirection.Ascending) |
68 | 77 | { |
69 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
70 | - from item in ViewModel.Rows orderby item.End.Value descending select item); | |
78 | + this.ViewModel.SortByViewColumn(tag, r => r.End.Value, false); | |
71 | 79 | e.Column.SortDirection = DataGridSortDirection.Descending; |
72 | 80 | } |
73 | 81 | else |
74 | 82 | { |
75 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
76 | - from item in ViewModel.Rows orderby item.End.Value ascending select item); | |
83 | + this.ViewModel.SortByViewColumn(tag, r => r.End.Value, true); | |
77 | 84 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
78 | 85 | } |
79 | 86 | break; |
@@ -81,14 +88,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
81 | 88 | case "GeneralAllNo": |
82 | 89 | if (direction == DataGridSortDirection.Ascending) |
83 | 90 | { |
84 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
85 | - from item in ViewModel.Rows orderby item.GeneralAllNo.Value descending select item); | |
91 | + this.ViewModel.SortByViewColumn(tag, r => r.GeneralAllNo.Value, false); | |
86 | 92 | e.Column.SortDirection = DataGridSortDirection.Descending; |
87 | 93 | } |
88 | 94 | else |
89 | 95 | { |
90 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
91 | - from item in ViewModel.Rows orderby item.GeneralAllNo.Value ascending select item); | |
96 | + this.ViewModel.SortByViewColumn(tag, r => r.GeneralAllNo.Value, true); | |
92 | 97 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
93 | 98 | } |
94 | 99 | break; |
@@ -96,14 +101,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
96 | 101 | case "Time": |
97 | 102 | if (direction == DataGridSortDirection.Ascending) |
98 | 103 | { |
99 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
100 | - from item in ViewModel.Rows orderby item.Time.Value descending select item); | |
104 | + this.ViewModel.SortByViewColumn(tag, r => r.Time.Value, false); | |
101 | 105 | e.Column.SortDirection = DataGridSortDirection.Descending; |
102 | 106 | } |
103 | 107 | else |
104 | 108 | { |
105 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
106 | - from item in ViewModel.Rows orderby item.Time.Value ascending select item); | |
109 | + this.ViewModel.SortByViewColumn(tag, r => r.Time.Value, true); | |
107 | 110 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
108 | 111 | } |
109 | 112 | break; |
@@ -111,14 +114,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
111 | 114 | case "IsStop": |
112 | 115 | if ((e.Column.SortDirection == null) || (direction == DataGridSortDirection.Descending)) |
113 | 116 | { |
114 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
115 | - from item in ViewModel.Rows orderby item.IsStop.Value ascending select item); | |
117 | + this.ViewModel.SortByViewColumn(tag, r => r.IsStop.Value, true); | |
116 | 118 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
117 | 119 | } |
118 | 120 | else |
119 | 121 | { |
120 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
121 | - from item in ViewModel.Rows orderby item.IsStop.Value descending select item); | |
122 | + this.ViewModel.SortByViewColumn(tag, r => r.IsStop.Value, false); | |
122 | 123 | e.Column.SortDirection = DataGridSortDirection.Descending; |
123 | 124 | } |
124 | 125 | break; |
@@ -126,14 +127,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
126 | 127 | case "GlobalPoint": |
127 | 128 | if (direction == DataGridSortDirection.Ascending) |
128 | 129 | { |
129 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
130 | - from item in ViewModel.Rows orderby item.GlobalPoint.Value descending select item); | |
130 | + this.ViewModel.SortByViewColumn(tag, r => r.GlobalPoint.Value, false); | |
131 | 131 | e.Column.SortDirection = DataGridSortDirection.Descending; |
132 | 132 | } |
133 | 133 | else |
134 | 134 | { |
135 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
136 | - from item in ViewModel.Rows orderby item.GlobalPoint.Value ascending select item); | |
135 | + this.ViewModel.SortByViewColumn(tag, r => r.GlobalPoint.Value, true); | |
137 | 136 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
138 | 137 | } |
139 | 138 | break; |
@@ -141,14 +140,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
141 | 140 | case "PointPerMin": |
142 | 141 | if (direction == DataGridSortDirection.Ascending) |
143 | 142 | { |
144 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
145 | - from item in ViewModel.Rows orderby item.PointPerMin.Value descending select item); | |
143 | + this.ViewModel.SortByViewColumn(tag, r => r.PointPerMin.Value, false); | |
146 | 144 | e.Column.SortDirection = DataGridSortDirection.Descending; |
147 | 145 | } |
148 | 146 | else |
149 | 147 | { |
150 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
151 | - from item in ViewModel.Rows orderby item.PointPerMin.Value ascending select item); | |
148 | + this.ViewModel.SortByViewColumn(tag, r => r.PointPerMin.Value, true); | |
152 | 149 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
153 | 150 | } |
154 | 151 | break; |
@@ -156,14 +153,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
156 | 153 | case "DailyPoint": |
157 | 154 | if (direction == DataGridSortDirection.Ascending) |
158 | 155 | { |
159 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
160 | - from item in ViewModel.Rows orderby item.DailyPoint.Value descending select item); | |
156 | + this.ViewModel.SortByViewColumn(tag, r => r.DailyPoint.Value, false); | |
161 | 157 | e.Column.SortDirection = DataGridSortDirection.Descending; |
162 | 158 | } |
163 | 159 | else |
164 | 160 | { |
165 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
166 | - from item in ViewModel.Rows orderby item.DailyPoint.Value ascending select item); | |
161 | + this.ViewModel.SortByViewColumn(tag, r => r.DailyPoint.Value, true); | |
167 | 162 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
168 | 163 | } |
169 | 164 | break; |
@@ -171,14 +166,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
171 | 166 | case "WeeklyPoint": |
172 | 167 | if (direction == DataGridSortDirection.Ascending) |
173 | 168 | { |
174 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
175 | - from item in ViewModel.Rows orderby item.WeeklyPoint.Value descending select item); | |
169 | + this.ViewModel.SortByViewColumn(tag, r => r.WeeklyPoint.Value, false); | |
176 | 170 | e.Column.SortDirection = DataGridSortDirection.Descending; |
177 | 171 | } |
178 | 172 | else |
179 | 173 | { |
180 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
181 | - from item in ViewModel.Rows orderby item.WeeklyPoint.Value ascending select item); | |
174 | + this.ViewModel.SortByViewColumn(tag, r => r.WeeklyPoint.Value, true); | |
182 | 175 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
183 | 176 | } |
184 | 177 | break; |
@@ -186,14 +179,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
186 | 179 | case "MonthlyPoint": |
187 | 180 | if (direction == DataGridSortDirection.Ascending) |
188 | 181 | { |
189 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
190 | - from item in ViewModel.Rows orderby item.MonthlyPoint.Value descending select item); | |
182 | + this.ViewModel.SortByViewColumn(tag, r => r.MonthlyPoint.Value, false); | |
191 | 183 | e.Column.SortDirection = DataGridSortDirection.Descending; |
192 | 184 | } |
193 | 185 | else |
194 | 186 | { |
195 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
196 | - from item in ViewModel.Rows orderby item.MonthlyPoint.Value ascending select item); | |
187 | + this.ViewModel.SortByViewColumn(tag, r => r.MonthlyPoint.Value, true); | |
197 | 188 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
198 | 189 | } |
199 | 190 | break; |
@@ -201,14 +192,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
201 | 192 | case "QuarterPoint": |
202 | 193 | if (direction == DataGridSortDirection.Ascending) |
203 | 194 | { |
204 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
205 | - from item in ViewModel.Rows orderby item.QuarterPoint.Value descending select item); | |
195 | + this.ViewModel.SortByViewColumn(tag, r => r.QuarterPoint.Value, false); | |
206 | 196 | e.Column.SortDirection = DataGridSortDirection.Descending; |
207 | 197 | } |
208 | 198 | else |
209 | 199 | { |
210 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
211 | - from item in ViewModel.Rows orderby item.QuarterPoint.Value ascending select item); | |
200 | + this.ViewModel.SortByViewColumn(tag, r => r.QuarterPoint.Value, true); | |
212 | 201 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
213 | 202 | } |
214 | 203 | break; |
@@ -216,14 +205,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
216 | 205 | case "YearlyPoint": |
217 | 206 | if (direction == DataGridSortDirection.Ascending) |
218 | 207 | { |
219 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
220 | - from item in ViewModel.Rows orderby item.YearlyPoint.Value descending select item); | |
208 | + this.ViewModel.SortByViewColumn(tag, r => r.YearlyPoint.Value, false); | |
221 | 209 | e.Column.SortDirection = DataGridSortDirection.Descending; |
222 | 210 | } |
223 | 211 | else |
224 | 212 | { |
225 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
226 | - from item in ViewModel.Rows orderby item.YearlyPoint.Value ascending select item); | |
213 | + this.ViewModel.SortByViewColumn(tag, r => r.YearlyPoint.Value, true); | |
227 | 214 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
228 | 215 | } |
229 | 216 | break; |
@@ -231,14 +218,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
231 | 218 | case "FavNovelCnt": |
232 | 219 | if (direction == DataGridSortDirection.Ascending) |
233 | 220 | { |
234 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
235 | - from item in ViewModel.Rows orderby item.FavNovelCnt.Value descending select item); | |
221 | + this.ViewModel.SortByViewColumn(tag, r => r.FavNovelCnt.Value, false); | |
236 | 222 | e.Column.SortDirection = DataGridSortDirection.Descending; |
237 | 223 | } |
238 | 224 | else |
239 | 225 | { |
240 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
241 | - from item in ViewModel.Rows orderby item.FavNovelCnt.Value ascending select item); | |
226 | + this.ViewModel.SortByViewColumn(tag, r => r.FavNovelCnt.Value, true); | |
242 | 227 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
243 | 228 | } |
244 | 229 | break; |
@@ -246,14 +231,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
246 | 231 | case "ImpressionCnt": |
247 | 232 | if (direction == DataGridSortDirection.Ascending) |
248 | 233 | { |
249 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
250 | - from item in ViewModel.Rows orderby item.ImpressionCnt.Value descending select item); | |
234 | + this.ViewModel.SortByViewColumn(tag, r => r.ImpressionCnt.Value, false); | |
251 | 235 | e.Column.SortDirection = DataGridSortDirection.Descending; |
252 | 236 | } |
253 | 237 | else |
254 | 238 | { |
255 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
256 | - from item in ViewModel.Rows orderby item.ImpressionCnt.Value ascending select item); | |
239 | + this.ViewModel.SortByViewColumn(tag, r => r.ImpressionCnt.Value, true); | |
257 | 240 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
258 | 241 | } |
259 | 242 | break; |
@@ -261,14 +244,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
261 | 244 | case "ReviewCnt": |
262 | 245 | if (direction == DataGridSortDirection.Ascending) |
263 | 246 | { |
264 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
265 | - from item in ViewModel.Rows orderby item.ReviewCnt.Value descending select item); | |
247 | + this.ViewModel.SortByViewColumn(tag, r => r.ReviewCnt.Value, false); | |
266 | 248 | e.Column.SortDirection = DataGridSortDirection.Descending; |
267 | 249 | } |
268 | 250 | else |
269 | 251 | { |
270 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
271 | - from item in ViewModel.Rows orderby item.ReviewCnt.Value ascending select item); | |
252 | + this.ViewModel.SortByViewColumn(tag, r => r.ReviewCnt.Value, true); | |
272 | 253 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
273 | 254 | } |
274 | 255 | break; |
@@ -276,14 +257,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
276 | 257 | case "AllPoint": |
277 | 258 | if (direction == DataGridSortDirection.Ascending) |
278 | 259 | { |
279 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
280 | - from item in ViewModel.Rows orderby item.AllPoint.Value descending select item); | |
281 | - e.Column.SortDirection = DataGridSortDirection.Descending; | |
260 | + this.ViewModel.SortByViewColumn(tag, r => r.AllPoint.Value, false); | |
261 | + e.Column.SortDirection = DataGridSortDirection.Descending; | |
282 | 262 | } |
283 | 263 | else |
284 | 264 | { |
285 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
286 | - from item in ViewModel.Rows orderby item.AllPoint.Value ascending select item); | |
265 | + this.ViewModel.SortByViewColumn(tag, r => r.AllPoint.Value, true); | |
287 | 266 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
288 | 267 | } |
289 | 268 | break; |
@@ -291,14 +270,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
291 | 270 | case "AllHyokaCnt": |
292 | 271 | if (direction == DataGridSortDirection.Ascending) |
293 | 272 | { |
294 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
295 | - from item in ViewModel.Rows orderby item.AllHyokaCnt.Value descending select item); | |
273 | + this.ViewModel.SortByViewColumn(tag, r => r.AllHyokaCnt.Value, false); | |
296 | 274 | e.Column.SortDirection = DataGridSortDirection.Descending; |
297 | 275 | } |
298 | 276 | else |
299 | 277 | { |
300 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
301 | - from item in ViewModel.Rows orderby item.AllHyokaCnt.Value ascending select item); | |
278 | + this.ViewModel.SortByViewColumn(tag, r => r.AllHyokaCnt.Value, true); | |
302 | 279 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
303 | 280 | } |
304 | 281 | break; |
@@ -306,14 +283,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
306 | 283 | case "GeneralLastUp": |
307 | 284 | if (direction == DataGridSortDirection.Ascending) |
308 | 285 | { |
309 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
310 | - from item in ViewModel.Rows orderby item.GeneralLastUp.Value descending select item); | |
286 | + this.ViewModel.SortByValueColumn(tag, r => r.GeneralLastUp.Value, false); | |
311 | 287 | e.Column.SortDirection = DataGridSortDirection.Descending; |
312 | 288 | } |
313 | 289 | else |
314 | 290 | { |
315 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
316 | - from item in ViewModel.Rows orderby item.GeneralLastUp.Value ascending select item); | |
291 | + this.ViewModel.SortByValueColumn(tag, r => r.GeneralLastUp.Value, true); | |
317 | 292 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
318 | 293 | } |
319 | 294 | break; |
@@ -321,14 +296,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
321 | 296 | case "GeneralFirstUp": |
322 | 297 | if (direction == DataGridSortDirection.Ascending) |
323 | 298 | { |
324 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
325 | - from item in ViewModel.Rows orderby item.GeneralFirstUp.Value descending select item); | |
299 | + this.ViewModel.SortByValueColumn(tag, r => r.GeneralFirstUp.Value, false); | |
326 | 300 | e.Column.SortDirection = DataGridSortDirection.Descending; |
327 | 301 | } |
328 | 302 | else |
329 | 303 | { |
330 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
331 | - from item in ViewModel.Rows orderby item.GeneralFirstUp.Value ascending select item); | |
304 | + this.ViewModel.SortByValueColumn(tag, r => r.GeneralFirstUp.Value, true); | |
332 | 305 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
333 | 306 | } |
334 | 307 | break; |
@@ -336,14 +309,12 @@ namespace TestNarou3.OuterEdge.UI.View | ||
336 | 309 | case "NovelUpdatedAt": |
337 | 310 | if (direction == DataGridSortDirection.Ascending) |
338 | 311 | { |
339 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
340 | - from item in ViewModel.Rows orderby item.NovelUpdatedAt.Value descending select item); | |
312 | + this.ViewModel.SortByValueColumn(tag, r => r.NovelUpdatedAt.Value, false); | |
341 | 313 | e.Column.SortDirection = DataGridSortDirection.Descending; |
342 | 314 | } |
343 | 315 | else |
344 | 316 | { |
345 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
346 | - from item in ViewModel.Rows orderby item.NovelUpdatedAt.Value ascending select item); | |
317 | + this.ViewModel.SortByValueColumn(tag, r => r.NovelUpdatedAt.Value, true); | |
347 | 318 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
348 | 319 | } |
349 | 320 | break; |