なろうブックマーク分析用ツールのPrism+WinUI3サンプル実装
Revisión | 9189d8a132828b2c4f58017d2fcfae22775e6e3e (tree) |
---|---|
Tiempo | 2022-08-29 21:48:41 |
Autor | yoshy <yoshy.org.bitbucket@gz.j...> |
Commiter | yoshy |
[ADD] ブックマーク詳細リストに「分/話」列(1話あたりの平均読了時間)を追加
@@ -14,6 +14,7 @@ namespace TestNarou3.Adaptor.Boundary.Gateway.ViewModel.Child | ||
14 | 14 | ReadOnlyReactiveProperty<int> Time { get; } |
15 | 15 | ReadOnlyReactiveProperty<string> IsStop { get; } |
16 | 16 | ReadOnlyReactiveProperty<int> GlobalPoint { get; } |
17 | + ReadOnlyReactiveProperty<int> MinPerAllNo { get; } | |
17 | 18 | ReadOnlyReactiveProperty<int> PointPerMin { get; } |
18 | 19 | ReadOnlyReactiveProperty<int> DailyPoint { get; } |
19 | 20 | ReadOnlyReactiveProperty<int> WeeklyPoint { get; } |
@@ -17,6 +17,7 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel.Child | ||
17 | 17 | d.Time.AddTo(d.disposables); |
18 | 18 | d.IsStop.AddTo(d.disposables); |
19 | 19 | d.GlobalPoint.AddTo(d.disposables); |
20 | + d.MinPerAllNo.AddTo(d.disposables); | |
20 | 21 | d.PointPerMin.AddTo(d.disposables); |
21 | 22 | d.DailyPoint.AddTo(d.disposables); |
22 | 23 | d.WeeklyPoint.AddTo(d.disposables); |
@@ -21,6 +21,7 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel.Child | ||
21 | 21 | public ReadOnlyReactiveProperty<int> Time { get; private set; } |
22 | 22 | public ReadOnlyReactiveProperty<string> IsStop { get; private set; } |
23 | 23 | public ReadOnlyReactiveProperty<int> GlobalPoint { get; private set; } |
24 | + public ReadOnlyReactiveProperty<int> MinPerAllNo { get; private set; } | |
24 | 25 | public ReadOnlyReactiveProperty<int> PointPerMin { get; private set; } |
25 | 26 | public ReadOnlyReactiveProperty<int> DailyPoint { get; private set; } |
26 | 27 | public ReadOnlyReactiveProperty<int> WeeklyPoint { get; private set; } |
@@ -55,6 +55,8 @@ namespace TestNarou3.Adaptor.Translator | ||
55 | 55 | .ForMember(d => d.GlobalPoint, |
56 | 56 | opts => opts.MapFrom(s => s.GlobalPoint |
57 | 57 | .ToReadOnlyReactiveProperty(0, ReactivePropertyMode.Default, null, null))) |
58 | + .ForMember(d => d.MinPerAllNo, | |
59 | + opts => opts.MapFrom<MinPerAllNoResolver>()) | |
58 | 60 | .ForMember(d => d.PointPerMin, |
59 | 61 | opts => opts.MapFrom<PointPerMinResolver>()) |
60 | 62 | .ForMember(d => d.DailyPoint, |
@@ -0,0 +1,24 @@ | ||
1 | +using AutoMapper; | |
2 | +using Reactive.Bindings; | |
3 | +using System.Reactive.Linq; | |
4 | +using TestNarou3.Adaptor.Gateway.ViewModel.Child; | |
5 | +using TestNarou3.Domain.Model.Entity.Child; | |
6 | + | |
7 | +namespace TestNarou3.Adaptor.Translator.Converter | |
8 | +{ | |
9 | + internal class MinPerAllNoResolver | |
10 | + : IValueResolver<BookmarkDetailListRow, BookmarkDetailListRowViewModel, ReadOnlyReactiveProperty<int>> | |
11 | + { | |
12 | + public ReadOnlyReactiveProperty<int> Resolve( | |
13 | + BookmarkDetailListRow source, BookmarkDetailListRowViewModel destination, | |
14 | + ReadOnlyReactiveProperty<int> destMember, ResolutionContext context) | |
15 | + { | |
16 | + return source.Time.CombineLatest(source.GeneralAllNo, (time, allNo) => Convert(time, allNo)).ToReadOnlyReactiveProperty(); | |
17 | + } | |
18 | + | |
19 | + private static int Convert(int time, int allNo) | |
20 | + { | |
21 | + return (int)Math.Round((double)time / allNo, 0, MidpointRounding.AwayFromZero); | |
22 | + } | |
23 | + } | |
24 | +} |
@@ -126,6 +126,14 @@ | ||
126 | 126 | </Style> |
127 | 127 | </ctc:DataGridTextColumn.ElementStyle> |
128 | 128 | </ctc:DataGridTextColumn> |
129 | + <ctc:DataGridTextColumn Header="分/話" Width="80" Tag="MinPerAllNo" | |
130 | + Binding="{Binding MinPerAllNo.Value, Converter={StaticResource StringFormat},ConverterParameter=\{0:N0\}}" > | |
131 | + <ctc:DataGridTextColumn.ElementStyle> | |
132 | + <Style TargetType="TextBlock"> | |
133 | + <Setter Property="HorizontalAlignment" Value="Right" /> | |
134 | + </Style> | |
135 | + </ctc:DataGridTextColumn.ElementStyle> | |
136 | + </ctc:DataGridTextColumn> | |
129 | 137 | <ctc:DataGridTextColumn Header="評価/分" Width="80" Tag="PointPerMin" |
130 | 138 | Binding="{Binding PointPerMin.Value, Converter={StaticResource StringFormat},ConverterParameter=\{0:N0\}}" > |
131 | 139 | <ctc:DataGridTextColumn.ElementStyle> |
@@ -137,6 +137,19 @@ namespace TestNarou3.OuterEdge.UI.View | ||
137 | 137 | } |
138 | 138 | break; |
139 | 139 | |
140 | + case "MinPerAllNo": | |
141 | + if (direction == DataGridSortDirection.Ascending) | |
142 | + { | |
143 | + this.ViewModel.SortByViewColumn(tag, r => r.MinPerAllNo.Value, false); | |
144 | + e.Column.SortDirection = DataGridSortDirection.Descending; | |
145 | + } | |
146 | + else | |
147 | + { | |
148 | + this.ViewModel.SortByViewColumn(tag, r => r.MinPerAllNo.Value, true); | |
149 | + e.Column.SortDirection = DataGridSortDirection.Ascending; | |
150 | + } | |
151 | + break; | |
152 | + | |
140 | 153 | case "PointPerMin": |
141 | 154 | if (direction == DataGridSortDirection.Ascending) |
142 | 155 | { |