なろうブックマーク分析用ツールのPrism+WPFサンプル実装
Revision | c1a816e7e1073c8765976dabc25b3f499e2d82b2 (tree) |
---|---|
Time | 2022-08-06 20:50:08 |
Author | yoshy <yoshy.org.bitbucket@gz.j...> |
Commiter | yoshy |
[ADD] ブックマーク詳細リストにサマリ列を追加
@@ -9,6 +9,7 @@ namespace TestNarou.Domain.Model.Entity.Child | ||
9 | 9 | string NCode, |
10 | 10 | ReactivePropertySlim<string> Title, |
11 | 11 | ReactivePropertySlim<string> Writer, |
12 | + ReactivePropertySlim<string> Story, | |
12 | 13 | ReactivePropertySlim<int> GeneralAllNo, |
13 | 14 | ReactivePropertySlim<int> Time, |
14 | 15 | ReactivePropertySlim<int> IsStop, |
@@ -34,6 +35,7 @@ namespace TestNarou.Domain.Model.Entity.Child | ||
34 | 35 | NCode: null, |
35 | 36 | Title: new(), |
36 | 37 | Writer: new(), |
38 | + Story: new(), | |
37 | 39 | GeneralAllNo: new(), |
38 | 40 | Time: new(), |
39 | 41 | IsStop: new(), |
@@ -54,6 +56,7 @@ namespace TestNarou.Domain.Model.Entity.Child | ||
54 | 56 | { |
55 | 57 | this.Title.AddTo(this.disposables); |
56 | 58 | this.Writer.AddTo(this.disposables); |
59 | + this.Story.AddTo(this.disposables); | |
57 | 60 | this.GeneralAllNo.AddTo(this.disposables); |
58 | 61 | this.Time.AddTo(this.disposables); |
59 | 62 | this.IsStop.AddTo(this.disposables); |
@@ -29,6 +29,7 @@ namespace TestNarou.Domain.Translator | ||
29 | 29 | .ForMember(d => d.NCode, opts => opts.MapFrom(s => s.NCode)) |
30 | 30 | .ForMember(d => d.Title, opts => opts.MapFrom(s => s.Title)) |
31 | 31 | .ForMember(d => d.Writer, opts => opts.MapFrom(s => s.Writer)) |
32 | + .ForMember(d => d.Story, opts => opts.MapFrom(s => s.Story)) | |
32 | 33 | .ForMember(d => d.GeneralAllNo, opts => opts.MapFrom(s => s.GeneralAllNo)) |
33 | 34 | .ForMember(d => d.Time, opts => opts.MapFrom(s => s.Time)) |
34 | 35 | .ForMember(d => d.IsStop, opts => opts.MapFrom(s => s.IsStop)) |
@@ -6,6 +6,7 @@ namespace TestNarou.Adaptor.Boundary.Gateway.ViewModel.Child | ||
6 | 6 | public interface IBookmarkDetailListRowViewModel |
7 | 7 | { |
8 | 8 | string NCode { get; } |
9 | + ReadOnlyReactiveProperty<string> Summary { get; } | |
9 | 10 | ReadOnlyReactiveProperty<string> Title { get; } |
10 | 11 | ReadOnlyReactiveProperty<string> Writer { get; } |
11 | 12 | ReadOnlyReactiveProperty<int> GeneralAllNo { get; } |
@@ -8,6 +8,8 @@ namespace TestNarou.Adaptor.Boundary.Gateway.ViewModel | ||
8 | 8 | { |
9 | 9 | public interface IBookmarkDetailListViewModel |
10 | 10 | { |
11 | + public static readonly string SUMMARY_LABEL = "●"; | |
12 | + | |
11 | 13 | internal const string CATEGORY_NO_KEY = "CATEGORY_NO"; |
12 | 14 | |
13 | 15 | internal static readonly Uri URI = new("BookmarkDetailListView", UriKind.Relative); |
@@ -11,6 +11,7 @@ namespace TestNarou.Adaptor.Gateway.ViewModel.Child | ||
11 | 11 | : IBookmarkDetailListRowViewModel, IDisposable |
12 | 12 | { |
13 | 13 | public string NCode { get; private set; } |
14 | + public ReadOnlyReactiveProperty<string> Summary { get; private set; } | |
14 | 15 | public ReadOnlyReactiveProperty<string> Title { get; private set; } |
15 | 16 | public ReadOnlyReactiveProperty<string> Writer { get; private set; } |
16 | 17 | public ReadOnlyReactiveProperty<int> GeneralAllNo { get; private set; } |
@@ -35,6 +35,8 @@ namespace TestNarou.Adaptor.Translator | ||
35 | 35 | mappingExpression |
36 | 36 | .ForMember(d => d.NCode, |
37 | 37 | opts => opts.MapFrom(s => s.NCode)) |
38 | + .ForMember(d => d.Summary, | |
39 | + opts => opts.MapFrom<SummaryResolver>()) | |
38 | 40 | .ForMember(d => d.Title, |
39 | 41 | opts => opts.MapFrom(s => s.Title |
40 | 42 | .ToReadOnlyReactiveProperty(null, ReactivePropertyMode.Default, null, null))) |
@@ -0,0 +1,32 @@ | ||
1 | +using AutoMapper; | |
2 | +using Reactive.Bindings; | |
3 | +using System; | |
4 | +using System.Reactive.Linq; | |
5 | +using System.Text; | |
6 | +using TestNarou.Adaptor.Gateway.ViewModel.Child; | |
7 | +using TestNarou.Domain.Model.Entity.Child; | |
8 | + | |
9 | +namespace TestNarou.Adaptor.Translator.Converter | |
10 | +{ | |
11 | + internal class SummaryResolver | |
12 | + : IValueResolver<BookmarkDetailListRow, BookmarkDetailListRowViewModel, ReadOnlyReactiveProperty<string>> | |
13 | + { | |
14 | + public ReadOnlyReactiveProperty<string> Resolve( | |
15 | + BookmarkDetailListRow source, BookmarkDetailListRowViewModel destination, | |
16 | + ReadOnlyReactiveProperty<string> destMember, ResolutionContext context) | |
17 | + { | |
18 | + return source.Title.CombineLatest(source.Story, (title, story) => Convert(title, story)).ToReadOnlyReactiveProperty(); | |
19 | + } | |
20 | + | |
21 | + private static string Convert(string title, string story) | |
22 | + { | |
23 | + StringBuilder buf = new(); | |
24 | + | |
25 | + buf.AppendLine(title); | |
26 | + buf.AppendLine(); | |
27 | + buf.Append(story); | |
28 | + | |
29 | + return buf.ToString(); | |
30 | + } | |
31 | + } | |
32 | +} |
@@ -44,20 +44,40 @@ | ||
44 | 44 | </DataGrid.CellStyle> |
45 | 45 | |
46 | 46 | <DataGrid.Columns> |
47 | + <DataGridTextColumn Header="概" Width="10" | |
48 | + Binding="{Binding Source={x:Static vm:IBookmarkDetailListViewModel.SUMMARY_LABEL}, Mode=OneWay}"> | |
49 | + <DataGridTextColumn.CellStyle> | |
50 | + <Style TargetType="DataGridCell"> | |
51 | + <Setter Property="ToolTip" Value="{Binding Summary.Value}" /> | |
52 | + </Style> | |
53 | + </DataGridTextColumn.CellStyle> | |
54 | + </DataGridTextColumn> | |
47 | 55 | <DataGridTextColumn Header="タイトル" Width="300" |
48 | - Binding="{Binding Title.Value}" /> | |
56 | + Binding="{Binding Title.Value}"> | |
57 | + <DataGridTextColumn.CellStyle> | |
58 | + <Style TargetType="DataGridCell"> | |
59 | + <Setter Property="ToolTip" Value="{Binding Title.Value}" /> | |
60 | + </Style> | |
61 | + </DataGridTextColumn.CellStyle> | |
62 | + </DataGridTextColumn> | |
49 | 63 | <DataGridTextColumn Header="作者" Width="100" |
50 | - Binding="{Binding Writer.Value}" /> | |
64 | + Binding="{Binding Writer.Value}"> | |
65 | + <DataGridTextColumn.CellStyle> | |
66 | + <Style TargetType="DataGridCell"> | |
67 | + <Setter Property="ToolTip" Value="{Binding Writer.Value}" /> | |
68 | + </Style> | |
69 | + </DataGridTextColumn.CellStyle> | |
70 | + </DataGridTextColumn> | |
51 | 71 | <DataGridTextColumn Header="話数" Width="40" |
52 | - Binding="{Binding GeneralAllNo.Value, StringFormat=\{0:N0\}}"> | |
72 | + Binding="{Binding GeneralAllNo.Value, StringFormat=\{0:N0\}}"> | |
53 | 73 | <DataGridTextColumn.ElementStyle> |
54 | 74 | <Style TargetType="{x:Type TextBlock}"> |
55 | 75 | <Setter Property="HorizontalAlignment" Value="Right" /> |
56 | 76 | </Style> |
57 | 77 | </DataGridTextColumn.ElementStyle> |
58 | 78 | </DataGridTextColumn> |
59 | - <DataGridTextColumn Header="長さ[h]" Width="40" | |
60 | - Binding="{Binding Time.Value, StringFormat=\{0:N0\}}"> | |
79 | + <DataGridTextColumn Header="長さ[h]" Width="50" | |
80 | + Binding="{Binding Time.Value, StringFormat=\{0:N0\}}"> | |
61 | 81 | <DataGridTextColumn.ElementStyle> |
62 | 82 | <Style TargetType="{x:Type TextBlock}"> |
63 | 83 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -65,7 +85,7 @@ | ||
65 | 85 | </DataGridTextColumn.ElementStyle> |
66 | 86 | </DataGridTextColumn> |
67 | 87 | <DataGridTextColumn Header="エタ" Width="25" |
68 | - Binding="{Binding IsStop.Value}"> | |
88 | + Binding="{Binding IsStop.Value}"> | |
69 | 89 | <DataGridTextColumn.ElementStyle> |
70 | 90 | <Style TargetType="{x:Type TextBlock}"> |
71 | 91 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -73,7 +93,7 @@ | ||
73 | 93 | </DataGridTextColumn.ElementStyle> |
74 | 94 | </DataGridTextColumn> |
75 | 95 | <DataGridTextColumn Header="総合評価pt." Width="60" |
76 | - Binding="{Binding GlobalPoint.Value, StringFormat=\{0:N0\}}"> | |
96 | + Binding="{Binding GlobalPoint.Value, StringFormat=\{0:N0\}}"> | |
77 | 97 | <DataGridTextColumn.ElementStyle> |
78 | 98 | <Style TargetType="{x:Type TextBlock}"> |
79 | 99 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -81,7 +101,7 @@ | ||
81 | 101 | </DataGridTextColumn.ElementStyle> |
82 | 102 | </DataGridTextColumn> |
83 | 103 | <DataGridTextColumn Header="評価/分" Width="50" |
84 | - Binding="{Binding PointPerMin.Value, StringFormat=\{0:N0\}}"> | |
104 | + Binding="{Binding PointPerMin.Value, StringFormat=\{0:N0\}}"> | |
85 | 105 | <DataGridTextColumn.ElementStyle> |
86 | 106 | <Style TargetType="{x:Type TextBlock}"> |
87 | 107 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -89,7 +109,7 @@ | ||
89 | 109 | </DataGridTextColumn.ElementStyle> |
90 | 110 | </DataGridTextColumn> |
91 | 111 | <DataGridTextColumn Header="日間pt." Width="50" |
92 | - Binding="{Binding DailyPoint.Value, StringFormat=\{0:N0\}}"> | |
112 | + Binding="{Binding DailyPoint.Value, StringFormat=\{0:N0\}}"> | |
93 | 113 | <DataGridTextColumn.ElementStyle> |
94 | 114 | <Style TargetType="{x:Type TextBlock}"> |
95 | 115 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -97,7 +117,7 @@ | ||
97 | 117 | </DataGridTextColumn.ElementStyle> |
98 | 118 | </DataGridTextColumn> |
99 | 119 | <DataGridTextColumn Header="週間pt." Width="50" |
100 | - Binding="{Binding WeeklyPoint.Value, StringFormat=\{0:N0\}}"> | |
120 | + Binding="{Binding WeeklyPoint.Value, StringFormat=\{0:N0\}}"> | |
101 | 121 | <DataGridTextColumn.ElementStyle> |
102 | 122 | <Style TargetType="{x:Type TextBlock}"> |
103 | 123 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -105,7 +125,7 @@ | ||
105 | 125 | </DataGridTextColumn.ElementStyle> |
106 | 126 | </DataGridTextColumn> |
107 | 127 | <DataGridTextColumn Header="月間pt." Width="50" |
108 | - Binding="{Binding MonthlyPoint.Value, StringFormat=\{0:N0\}}"> | |
128 | + Binding="{Binding MonthlyPoint.Value, StringFormat=\{0:N0\}}"> | |
109 | 129 | <DataGridTextColumn.ElementStyle> |
110 | 130 | <Style TargetType="{x:Type TextBlock}"> |
111 | 131 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -113,7 +133,7 @@ | ||
113 | 133 | </DataGridTextColumn.ElementStyle> |
114 | 134 | </DataGridTextColumn> |
115 | 135 | <DataGridTextColumn Header="四半期pt." Width="50" |
116 | - Binding="{Binding QuarterPoint.Value, StringFormat=\{0:N0\}}"> | |
136 | + Binding="{Binding QuarterPoint.Value, StringFormat=\{0:N0\}}"> | |
117 | 137 | <DataGridTextColumn.ElementStyle> |
118 | 138 | <Style TargetType="{x:Type TextBlock}"> |
119 | 139 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -121,7 +141,7 @@ | ||
121 | 141 | </DataGridTextColumn.ElementStyle> |
122 | 142 | </DataGridTextColumn> |
123 | 143 | <DataGridTextColumn Header="年間pt." Width="50" |
124 | - Binding="{Binding YearlyPoint.Value, StringFormat=\{0:N0\}}"> | |
144 | + Binding="{Binding YearlyPoint.Value, StringFormat=\{0:N0\}}"> | |
125 | 145 | <DataGridTextColumn.ElementStyle> |
126 | 146 | <Style TargetType="{x:Type TextBlock}"> |
127 | 147 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -129,7 +149,7 @@ | ||
129 | 149 | </DataGridTextColumn.ElementStyle> |
130 | 150 | </DataGridTextColumn> |
131 | 151 | <DataGridTextColumn Header="ブクマ数" Width="50" |
132 | - Binding="{Binding FavNovelCnt.Value, StringFormat=\{0:N0\}}"> | |
152 | + Binding="{Binding FavNovelCnt.Value, StringFormat=\{0:N0\}}"> | |
133 | 153 | <DataGridTextColumn.ElementStyle> |
134 | 154 | <Style TargetType="{x:Type TextBlock}"> |
135 | 155 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -137,7 +157,7 @@ | ||
137 | 157 | </DataGridTextColumn.ElementStyle> |
138 | 158 | </DataGridTextColumn> |
139 | 159 | <DataGridTextColumn Header="感想数" Width="50" |
140 | - Binding="{Binding ImpressionCnt.Value, StringFormat=\{0:N0\}}"> | |
160 | + Binding="{Binding ImpressionCnt.Value, StringFormat=\{0:N0\}}"> | |
141 | 161 | <DataGridTextColumn.ElementStyle> |
142 | 162 | <Style TargetType="{x:Type TextBlock}"> |
143 | 163 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -145,7 +165,7 @@ | ||
145 | 165 | </DataGridTextColumn.ElementStyle> |
146 | 166 | </DataGridTextColumn> |
147 | 167 | <DataGridTextColumn Header="レビュー数" Width="40" |
148 | - Binding="{Binding ReviewCnt.Value, StringFormat=\{0:N0\}}"> | |
168 | + Binding="{Binding ReviewCnt.Value, StringFormat=\{0:N0\}}"> | |
149 | 169 | <DataGridTextColumn.ElementStyle> |
150 | 170 | <Style TargetType="{x:Type TextBlock}"> |
151 | 171 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -153,7 +173,7 @@ | ||
153 | 173 | </DataGridTextColumn.ElementStyle> |
154 | 174 | </DataGridTextColumn> |
155 | 175 | <DataGridTextColumn Header="評価pt." Width="60" |
156 | - Binding="{Binding AllPoint.Value, StringFormat=\{0:N0\}}"> | |
176 | + Binding="{Binding AllPoint.Value, StringFormat=\{0:N0\}}"> | |
157 | 177 | <DataGridTextColumn.ElementStyle> |
158 | 178 | <Style TargetType="{x:Type TextBlock}"> |
159 | 179 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -161,7 +181,7 @@ | ||
161 | 181 | </DataGridTextColumn.ElementStyle> |
162 | 182 | </DataGridTextColumn> |
163 | 183 | <DataGridTextColumn Header="評価者数" Width="50" |
164 | - Binding="{Binding AllHyokaCnt.Value, StringFormat=\{0:N0\}}"> | |
184 | + Binding="{Binding AllHyokaCnt.Value, StringFormat=\{0:N0\}}"> | |
165 | 185 | <DataGridTextColumn.ElementStyle> |
166 | 186 | <Style TargetType="{x:Type TextBlock}"> |
167 | 187 | <Setter Property="HorizontalAlignment" Value="Right" /> |
@@ -169,7 +189,7 @@ | ||
169 | 189 | </DataGridTextColumn.ElementStyle> |
170 | 190 | </DataGridTextColumn> |
171 | 191 | <DataGridTextColumn Header="最終更新" Width="120" |
172 | - Binding="{Binding NovelUpdatedAt.Value}"> | |
192 | + Binding="{Binding NovelUpdatedAt.Value}"> | |
173 | 193 | <DataGridTextColumn.ElementStyle> |
174 | 194 | <Style TargetType="{x:Type TextBlock}"> |
175 | 195 | <Setter Property="HorizontalAlignment" Value="Right" /> |