• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

なろうブックマーク分析用ツールのPrism+WinUI3サンプル実装


コミットメタ情報

リビジョン281b6e05c99f3d3dd62848cf5313e5938c8d037a (tree)
日時2022-08-24 01:34:21
作者yoshy <yoshy.org.bitbucket@gz.j...>
コミッターyoshy

ログメッセージ

[MOD] ObservableCollectionMod を本体プロジェクトから分離したことによる対応
[MOD] SortableSynchronizedCoupleView によるソート処理の実装(作者列のみ移行)

変更サマリ

差分

--- a/TestNarou3.Adaptor/Boundary/Gateway/ViewModel/IBookmarkCategoryViewModel.cs
+++ b/TestNarou3.Adaptor/Boundary/Gateway/ViewModel/IBookmarkCategoryViewModel.cs
@@ -1,4 +1,5 @@
1-using ObservableCollections;
1+using CleanAuLait.ObservableCollectionsMod;
2+using ObservableCollections;
23 using Reactive.Bindings;
34 using TestNarou3.Adaptor.Boundary.Controller;
45 using TestNarou3.Adaptor.Boundary.Gateway.ViewModel.Child;
--- a/TestNarou3.Adaptor/Boundary/Gateway/ViewModel/IBookmarkDetailListViewModel.cs
+++ b/TestNarou3.Adaptor/Boundary/Gateway/ViewModel/IBookmarkDetailListViewModel.cs
@@ -1,7 +1,5 @@
1-using ObservableCollections;
1+using CleanAuLait.ObservableCollectionsMod;
22 using Reactive.Bindings;
3-using System;
4-using System.ComponentModel;
53 using TestNarou3.Adaptor.Boundary.Gateway.ViewModel.Child;
64 using TestNarou3.Domain.Model.Entity;
75 using TestNarou3.Domain.Model.Entity.Child;
@@ -23,5 +21,7 @@ namespace TestNarou3.Adaptor.Boundary.Gateway.ViewModel
2321 BookmarkDetailList Source { get; }
2422
2523 void SynchronizeWith(BookmarkDetailList list);
24+
25+ void Sort(string tag, Func<IBookmarkDetailListRowViewModel, string> selector, bool asceding);
2626 }
2727 }
--- a/TestNarou3.Adaptor/Gateway/ViewModel/BookmarkDetailListViewModel.cs
+++ b/TestNarou3.Adaptor/Gateway/ViewModel/BookmarkDetailListViewModel.cs
@@ -1,9 +1,11 @@
11 using CleanAuLait.Core.Log;
2+using CleanAuLait.ObservableCollectionsMod;
23 using NLog;
34 using ObservableCollections;
45 using Prism.Navigation;
56 using Reactive.Bindings;
67 using Reactive.Bindings.Extensions;
8+using System.Collections.ObjectModel;
79 using System.ComponentModel;
810 using System.Diagnostics;
911 using System.Reactive.Disposables;
@@ -28,6 +30,7 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel
2830 public ReactiveProperty<IBookmarkDetailListRowViewModel> SelectedItem { get; }
2931
3032 public INotifyCollectionChangedListSynchronizedSingleView<BookmarkDetailListRow, IBookmarkDetailListRowViewModel> Rows { get; private set; } = null;
33+ private ISortableSynchronizedCoupleView<BookmarkDetailListRow, string, IBookmarkDetailListRowViewModel> SortableRows { get; set; }
3134
3235 public ReactiveCommand CommandOpenBookmark { get; }
3336
@@ -83,10 +86,13 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel
8386
8487 public void SynchronizeWith(BookmarkDetailList source)
8588 {
89+#if true
8690 if (this.Source == null)
8791 {
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
9096 .ToSynchronizedSingleView()
9197 .WithINotifyCollectionChangedList()
9298 .AddTo(disposables);
@@ -101,6 +107,56 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel
101107 logger.Trace("BookmarkDetailListViewModel.SynchronizeWith: viewmodel already synchronized to model [{0}]",
102108 this.Source.ToHashString());
103109 }
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+ }
104160 }
105161
106162 #endregion
--- a/TestNarou3.Infra/TestNarou3.90Infra.csproj
+++ b/TestNarou3.Infra/TestNarou3.90Infra.csproj
@@ -16,7 +16,7 @@
1616 </ItemGroup>
1717
1818 <ItemGroup>
19+ <ProjectReference Include="..\..\CleanAuLait.ObservableCollectionsMod\CleanAuLait.ObservableCollectionsMod.csproj" />
1920 <ProjectReference Include="..\..\CleanAuLait.Prism.WinUI3\CleanAuLait.Prism.WinUI3.csproj" />
20- <ProjectReference Include="..\..\ObservableCollectionsMod\src\ObservableCollections\ObservableCollections.csproj" />
2121 </ItemGroup>
2222 </Project>
--- a/TestNarou3.OuterEdge/UI/View/BookmarkDetailListView.xaml.cs
+++ b/TestNarou3.OuterEdge/UI/View/BookmarkDetailListView.xaml.cs
@@ -49,14 +49,16 @@ namespace TestNarou3.OuterEdge.UI.View
4949 case "Writer":
5050 if ((e.Column.SortDirection == null) || (direction == DataGridSortDirection.Descending))
5151 {
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);
5455 e.Column.SortDirection = DataGridSortDirection.Ascending;
5556 }
5657 else
5758 {
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);
6062 e.Column.SortDirection = DataGridSortDirection.Descending;
6163 }
6264 break;
@@ -359,7 +361,6 @@ namespace TestNarou3.OuterEdge.UI.View
359361 dgColumn.SortDirection = null;
360362 }
361363 }
362-
363364 }
364365 }
365366 }
--- a/TestNarou3.sln
+++ b/TestNarou3.sln
@@ -19,13 +19,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Unity.WinUI", "D:\Rep
1919 EndProject
2020 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CleanAuLait", "..\CleanAuLait\CleanAuLait.csproj", "{543C3E97-A0BC-4AC6-8780-701902406542}"
2121 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}"
2323 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}"
2525 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}"
2727 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}"
2929 EndProject
3030 Global
3131 GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -207,22 +207,6 @@ Global
207207 {9D49E4D8-8D72-4273-8393-D39EB047E8EE}.Release|x64.Build.0 = Release|Any CPU
208208 {9D49E4D8-8D72-4273-8393-D39EB047E8EE}.Release|x86.ActiveCfg = Release|Any CPU
209209 {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
226210 {7A85A717-EFEF-4F87-A2BB-76D03F864287}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
227211 {7A85A717-EFEF-4F87-A2BB-76D03F864287}.Debug|Any CPU.Build.0 = Debug|Any CPU
228212 {7A85A717-EFEF-4F87-A2BB-76D03F864287}.Debug|arm64.ActiveCfg = Debug|Any CPU
@@ -239,6 +223,22 @@ Global
239223 {7A85A717-EFEF-4F87-A2BB-76D03F864287}.Release|x64.Build.0 = Release|Any CPU
240224 {7A85A717-EFEF-4F87-A2BB-76D03F864287}.Release|x86.ActiveCfg = Release|Any CPU
241225 {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
242242 EndGlobalSection
243243 GlobalSection(SolutionProperties) = preSolution
244244 HideSolutionNode = FALSE
--- a/TestNarou3/Properties/launchSettings.json
+++ b/TestNarou3/Properties/launchSettings.json
@@ -1,7 +1,8 @@
11 {
22 "profiles": {
33 "TestNarou3 (Package)": {
4- "commandName": "MsixPackage"
4+ "commandName": "MsixPackage",
5+ "nativeDebugging": false
56 },
67 "TestNarou3 (Unpackaged)": {
78 "commandName": "Project"