なろうブックマーク分析用ツールのPrism+WinUI3サンプル実装
Révision | 281b6e05c99f3d3dd62848cf5313e5938c8d037a (tree) |
---|---|
l'heure | 2022-08-24 01:34:21 |
Auteur | yoshy <yoshy.org.bitbucket@gz.j...> |
Commiter | yoshy |
[MOD] ObservableCollectionMod を本体プロジェクトから分離したことによる対応
[MOD] SortableSynchronizedCoupleView によるソート処理の実装(作者列のみ移行)
@@ -1,4 +1,5 @@ | ||
1 | -using ObservableCollections; | |
1 | +using CleanAuLait.ObservableCollectionsMod; | |
2 | +using ObservableCollections; | |
2 | 3 | using Reactive.Bindings; |
3 | 4 | using TestNarou3.Adaptor.Boundary.Controller; |
4 | 5 | using TestNarou3.Adaptor.Boundary.Gateway.ViewModel.Child; |
@@ -1,7 +1,5 @@ | ||
1 | -using ObservableCollections; | |
1 | +using CleanAuLait.ObservableCollectionsMod; | |
2 | 2 | using Reactive.Bindings; |
3 | -using System; | |
4 | -using System.ComponentModel; | |
5 | 3 | using TestNarou3.Adaptor.Boundary.Gateway.ViewModel.Child; |
6 | 4 | using TestNarou3.Domain.Model.Entity; |
7 | 5 | using TestNarou3.Domain.Model.Entity.Child; |
@@ -23,5 +21,7 @@ namespace TestNarou3.Adaptor.Boundary.Gateway.ViewModel | ||
23 | 21 | BookmarkDetailList Source { get; } |
24 | 22 | |
25 | 23 | void SynchronizeWith(BookmarkDetailList list); |
24 | + | |
25 | + void Sort(string tag, Func<IBookmarkDetailListRowViewModel, string> selector, bool asceding); | |
26 | 26 | } |
27 | 27 | } |
@@ -1,9 +1,11 @@ | ||
1 | 1 | using CleanAuLait.Core.Log; |
2 | +using CleanAuLait.ObservableCollectionsMod; | |
2 | 3 | using NLog; |
3 | 4 | using ObservableCollections; |
4 | 5 | using Prism.Navigation; |
5 | 6 | using Reactive.Bindings; |
6 | 7 | using Reactive.Bindings.Extensions; |
8 | +using System.Collections.ObjectModel; | |
7 | 9 | using System.ComponentModel; |
8 | 10 | using System.Diagnostics; |
9 | 11 | using System.Reactive.Disposables; |
@@ -28,6 +30,7 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel | ||
28 | 30 | public ReactiveProperty<IBookmarkDetailListRowViewModel> SelectedItem { get; } |
29 | 31 | |
30 | 32 | public INotifyCollectionChangedListSynchronizedSingleView<BookmarkDetailListRow, IBookmarkDetailListRowViewModel> Rows { get; private set; } = null; |
33 | + private ISortableSynchronizedCoupleView<BookmarkDetailListRow, string, IBookmarkDetailListRowViewModel> SortableRows { get; set; } | |
31 | 34 | |
32 | 35 | public ReactiveCommand CommandOpenBookmark { get; } |
33 | 36 |
@@ -83,10 +86,13 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel | ||
83 | 86 | |
84 | 87 | public void SynchronizeWith(BookmarkDetailList source) |
85 | 88 | { |
89 | +#if true | |
86 | 90 | if (this.Source == null) |
87 | 91 | { |
88 | - this.Rows = source.Rows | |
89 | - .ToSynchronizedCoupleView(r => this.vmTranslator.Translate(r, this)) | |
92 | + this.SortableRows = source.Rows | |
93 | + .ToSortableSynchronizedCoupleView(r => r.NCode, r => this.vmTranslator.Translate(r, this), new DetailListComparer(r => r.Title.Value, true)); | |
94 | + | |
95 | + this.Rows = this.SortableRows | |
90 | 96 | .ToSynchronizedSingleView() |
91 | 97 | .WithINotifyCollectionChangedList() |
92 | 98 | .AddTo(disposables); |
@@ -101,6 +107,56 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel | ||
101 | 107 | logger.Trace("BookmarkDetailListViewModel.SynchronizeWith: viewmodel already synchronized to model [{0}]", |
102 | 108 | this.Source.ToHashString()); |
103 | 109 | } |
110 | +#else | |
111 | + if (this.Rows != null) | |
112 | + { | |
113 | + this.Rows.Dispose(); | |
114 | + this.disposables.Remove(this.Rows); | |
115 | + } | |
116 | + | |
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)); | |
120 | + | |
121 | + this.Rows = this.SortableRows | |
122 | + .ToSynchronizedSingleView() | |
123 | + .WithINotifyCollectionChangedList() | |
124 | + .AddTo(disposables); | |
125 | + | |
126 | + this.Source = source; | |
127 | + | |
128 | + // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Rows")); | |
129 | +#endif | |
130 | + } | |
131 | + | |
132 | + public void Sort(string tag, Func<IBookmarkDetailListRowViewModel, string> selector, bool ascending) | |
133 | + { | |
134 | + logger.Trace("Sort: {0}, ascending = {1}", tag, ascending); | |
135 | + this.SortableRows.Sort(new DetailListComparer(selector, ascending)); | |
136 | + } | |
137 | + | |
138 | + internal class DetailListComparer : IComparer<(string, BookmarkDetailListRow, IBookmarkDetailListRowViewModel)> | |
139 | + { | |
140 | + readonly Func<IBookmarkDetailListRowViewModel, string> selector; | |
141 | + readonly int f; | |
142 | + | |
143 | + public DetailListComparer(Func<IBookmarkDetailListRowViewModel, string> selector, bool ascending = true) | |
144 | + { | |
145 | + this.selector = selector; | |
146 | + this.f = ascending ? 1 : -1; | |
147 | + } | |
148 | + | |
149 | + public int Compare((string, BookmarkDetailListRow, IBookmarkDetailListRowViewModel) x, (string, BookmarkDetailListRow, IBookmarkDetailListRowViewModel) y) | |
150 | + { | |
151 | + int c = selector(x.Item3).CompareTo(selector(y.Item3)) * f; | |
152 | + | |
153 | + if (c == 0) | |
154 | + { | |
155 | + c = x.Item1.CompareTo(y.Item1); | |
156 | + } | |
157 | + | |
158 | + return c; | |
159 | + } | |
104 | 160 | } |
105 | 161 | |
106 | 162 | #endregion |
@@ -16,7 +16,7 @@ | ||
16 | 16 | </ItemGroup> |
17 | 17 | |
18 | 18 | <ItemGroup> |
19 | + <ProjectReference Include="..\..\CleanAuLait.ObservableCollectionsMod\CleanAuLait.ObservableCollectionsMod.csproj" /> | |
19 | 20 | <ProjectReference Include="..\..\CleanAuLait.Prism.WinUI3\CleanAuLait.Prism.WinUI3.csproj" /> |
20 | - <ProjectReference Include="..\..\ObservableCollectionsMod\src\ObservableCollections\ObservableCollections.csproj" /> | |
21 | 21 | </ItemGroup> |
22 | 22 | </Project> |
@@ -49,14 +49,16 @@ namespace TestNarou3.OuterEdge.UI.View | ||
49 | 49 | case "Writer": |
50 | 50 | if ((e.Column.SortDirection == null) || (direction == DataGridSortDirection.Descending)) |
51 | 51 | { |
52 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
53 | - from item in ViewModel.Rows orderby item.Writer.Value ascending select item); | |
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); | |
54 | 55 | e.Column.SortDirection = DataGridSortDirection.Ascending; |
55 | 56 | } |
56 | 57 | else |
57 | 58 | { |
58 | - dg.ItemsSource = new ObservableCollection<IBookmarkDetailListRowViewModel>( | |
59 | - from item in ViewModel.Rows orderby item.Writer.Value descending select item); | |
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); | |
60 | 62 | e.Column.SortDirection = DataGridSortDirection.Descending; |
61 | 63 | } |
62 | 64 | break; |
@@ -359,7 +361,6 @@ namespace TestNarou3.OuterEdge.UI.View | ||
359 | 361 | dgColumn.SortDirection = null; |
360 | 362 | } |
361 | 363 | } |
362 | - | |
363 | 364 | } |
364 | 365 | } |
365 | 366 | } |
@@ -19,13 +19,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Unity.WinUI", "D:\Rep | ||
19 | 19 | EndProject |
20 | 20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CleanAuLait", "..\CleanAuLait\CleanAuLait.csproj", "{543C3E97-A0BC-4AC6-8780-701902406542}" |
21 | 21 | EndProject |
22 | -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanAuLait.Prism.WinUI3", "..\CleanAuLait.Prism.WinUI3\CleanAuLait.Prism.WinUI3.csproj", "{F804C913-6C3E-4116-82DB-24BFD501E397}" | |
22 | +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CleanAuLait.Prism.WinUI3", "..\CleanAuLait.Prism.WinUI3\CleanAuLait.Prism.WinUI3.csproj", "{F804C913-6C3E-4116-82DB-24BFD501E397}" | |
23 | 23 | EndProject |
24 | -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestNarou3.10Domain", "TestNarou3.Domain\TestNarou3.10Domain.csproj", "{9D49E4D8-8D72-4273-8393-D39EB047E8EE}" | |
24 | +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestNarou3.10Domain", "TestNarou3.Domain\TestNarou3.10Domain.csproj", "{9D49E4D8-8D72-4273-8393-D39EB047E8EE}" | |
25 | 25 | EndProject |
26 | -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ObservableCollections", "..\ObservableCollectionsMod\src\ObservableCollections\ObservableCollections.csproj", "{17A69251-440F-4665-ACD1-986351AC168E}" | |
26 | +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestNarou3.20UseCase", "TestNarou3.UseCase\TestNarou3.20UseCase.csproj", "{7A85A717-EFEF-4F87-A2BB-76D03F864287}" | |
27 | 27 | EndProject |
28 | -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestNarou3.20UseCase", "TestNarou3.UseCase\TestNarou3.20UseCase.csproj", "{7A85A717-EFEF-4F87-A2BB-76D03F864287}" | |
28 | +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CleanAuLait.ObservableCollectionsMod", "..\CleanAuLait.ObservableCollectionsMod\CleanAuLait.ObservableCollectionsMod.csproj", "{B9BA0032-9C0E-4B3A-A646-8280D64EF45B}" | |
29 | 29 | EndProject |
30 | 30 | Global |
31 | 31 | GlobalSection(SolutionConfigurationPlatforms) = preSolution |
@@ -207,22 +207,6 @@ Global | ||
207 | 207 | {9D49E4D8-8D72-4273-8393-D39EB047E8EE}.Release|x64.Build.0 = Release|Any CPU |
208 | 208 | {9D49E4D8-8D72-4273-8393-D39EB047E8EE}.Release|x86.ActiveCfg = Release|Any CPU |
209 | 209 | {9D49E4D8-8D72-4273-8393-D39EB047E8EE}.Release|x86.Build.0 = Release|Any CPU |
210 | - {17A69251-440F-4665-ACD1-986351AC168E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
211 | - {17A69251-440F-4665-ACD1-986351AC168E}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
212 | - {17A69251-440F-4665-ACD1-986351AC168E}.Debug|arm64.ActiveCfg = Debug|Any CPU | |
213 | - {17A69251-440F-4665-ACD1-986351AC168E}.Debug|arm64.Build.0 = Debug|Any CPU | |
214 | - {17A69251-440F-4665-ACD1-986351AC168E}.Debug|x64.ActiveCfg = Debug|Any CPU | |
215 | - {17A69251-440F-4665-ACD1-986351AC168E}.Debug|x64.Build.0 = Debug|Any CPU | |
216 | - {17A69251-440F-4665-ACD1-986351AC168E}.Debug|x86.ActiveCfg = Debug|Any CPU | |
217 | - {17A69251-440F-4665-ACD1-986351AC168E}.Debug|x86.Build.0 = Debug|Any CPU | |
218 | - {17A69251-440F-4665-ACD1-986351AC168E}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
219 | - {17A69251-440F-4665-ACD1-986351AC168E}.Release|Any CPU.Build.0 = Release|Any CPU | |
220 | - {17A69251-440F-4665-ACD1-986351AC168E}.Release|arm64.ActiveCfg = Release|Any CPU | |
221 | - {17A69251-440F-4665-ACD1-986351AC168E}.Release|arm64.Build.0 = Release|Any CPU | |
222 | - {17A69251-440F-4665-ACD1-986351AC168E}.Release|x64.ActiveCfg = Release|Any CPU | |
223 | - {17A69251-440F-4665-ACD1-986351AC168E}.Release|x64.Build.0 = Release|Any CPU | |
224 | - {17A69251-440F-4665-ACD1-986351AC168E}.Release|x86.ActiveCfg = Release|Any CPU | |
225 | - {17A69251-440F-4665-ACD1-986351AC168E}.Release|x86.Build.0 = Release|Any CPU | |
226 | 210 | {7A85A717-EFEF-4F87-A2BB-76D03F864287}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
227 | 211 | {7A85A717-EFEF-4F87-A2BB-76D03F864287}.Debug|Any CPU.Build.0 = Debug|Any CPU |
228 | 212 | {7A85A717-EFEF-4F87-A2BB-76D03F864287}.Debug|arm64.ActiveCfg = Debug|Any CPU |
@@ -239,6 +223,22 @@ Global | ||
239 | 223 | {7A85A717-EFEF-4F87-A2BB-76D03F864287}.Release|x64.Build.0 = Release|Any CPU |
240 | 224 | {7A85A717-EFEF-4F87-A2BB-76D03F864287}.Release|x86.ActiveCfg = Release|Any CPU |
241 | 225 | {7A85A717-EFEF-4F87-A2BB-76D03F864287}.Release|x86.Build.0 = Release|Any CPU |
226 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
227 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
228 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Debug|arm64.ActiveCfg = Debug|Any CPU | |
229 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Debug|arm64.Build.0 = Debug|Any CPU | |
230 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Debug|x64.ActiveCfg = Debug|Any CPU | |
231 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Debug|x64.Build.0 = Debug|Any CPU | |
232 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Debug|x86.ActiveCfg = Debug|Any CPU | |
233 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Debug|x86.Build.0 = Debug|Any CPU | |
234 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
235 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Release|Any CPU.Build.0 = Release|Any CPU | |
236 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Release|arm64.ActiveCfg = Release|Any CPU | |
237 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Release|arm64.Build.0 = Release|Any CPU | |
238 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Release|x64.ActiveCfg = Release|Any CPU | |
239 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Release|x64.Build.0 = Release|Any CPU | |
240 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Release|x86.ActiveCfg = Release|Any CPU | |
241 | + {B9BA0032-9C0E-4B3A-A646-8280D64EF45B}.Release|x86.Build.0 = Release|Any CPU | |
242 | 242 | EndGlobalSection |
243 | 243 | GlobalSection(SolutionProperties) = preSolution |
244 | 244 | HideSolutionNode = FALSE |
@@ -1,7 +1,8 @@ | ||
1 | 1 | { |
2 | 2 | "profiles": { |
3 | 3 | "TestNarou3 (Package)": { |
4 | - "commandName": "MsixPackage" | |
4 | + "commandName": "MsixPackage", | |
5 | + "nativeDebugging": false | |
5 | 6 | }, |
6 | 7 | "TestNarou3 (Unpackaged)": { |
7 | 8 | "commandName": "Project" |