• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

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

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


Commit MetaInfo

Révision9189d8a132828b2c4f58017d2fcfae22775e6e3e (tree)
l'heure2022-08-29 21:48:41
Auteuryoshy <yoshy.org.bitbucket@gz.j...>
Commiteryoshy

Message de Log

[ADD] ブックマーク詳細リストに「分/話」列(1話あたりの平均読了時間)を追加

Change Summary

Modification

--- a/TestNarou3.Adaptor/Boundary/Gateway/ViewModel/Child/IBookmarkDetailListRowViewModel.cs
+++ b/TestNarou3.Adaptor/Boundary/Gateway/ViewModel/Child/IBookmarkDetailListRowViewModel.cs
@@ -14,6 +14,7 @@ namespace TestNarou3.Adaptor.Boundary.Gateway.ViewModel.Child
1414 ReadOnlyReactiveProperty<int> Time { get; }
1515 ReadOnlyReactiveProperty<string> IsStop { get; }
1616 ReadOnlyReactiveProperty<int> GlobalPoint { get; }
17+ ReadOnlyReactiveProperty<int> MinPerAllNo { get; }
1718 ReadOnlyReactiveProperty<int> PointPerMin { get; }
1819 ReadOnlyReactiveProperty<int> DailyPoint { get; }
1920 ReadOnlyReactiveProperty<int> WeeklyPoint { get; }
--- a/TestNarou3.Adaptor/Gateway/ViewModel/Child/BookmarkDetailListRowViewModel.AfterMap.cs
+++ b/TestNarou3.Adaptor/Gateway/ViewModel/Child/BookmarkDetailListRowViewModel.AfterMap.cs
@@ -17,6 +17,7 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel.Child
1717 d.Time.AddTo(d.disposables);
1818 d.IsStop.AddTo(d.disposables);
1919 d.GlobalPoint.AddTo(d.disposables);
20+ d.MinPerAllNo.AddTo(d.disposables);
2021 d.PointPerMin.AddTo(d.disposables);
2122 d.DailyPoint.AddTo(d.disposables);
2223 d.WeeklyPoint.AddTo(d.disposables);
--- a/TestNarou3.Adaptor/Gateway/ViewModel/Child/BookmarkDetailListRowViewModel.cs
+++ b/TestNarou3.Adaptor/Gateway/ViewModel/Child/BookmarkDetailListRowViewModel.cs
@@ -21,6 +21,7 @@ namespace TestNarou3.Adaptor.Gateway.ViewModel.Child
2121 public ReadOnlyReactiveProperty<int> Time { get; private set; }
2222 public ReadOnlyReactiveProperty<string> IsStop { get; private set; }
2323 public ReadOnlyReactiveProperty<int> GlobalPoint { get; private set; }
24+ public ReadOnlyReactiveProperty<int> MinPerAllNo { get; private set; }
2425 public ReadOnlyReactiveProperty<int> PointPerMin { get; private set; }
2526 public ReadOnlyReactiveProperty<int> DailyPoint { get; private set; }
2627 public ReadOnlyReactiveProperty<int> WeeklyPoint { get; private set; }
--- a/TestNarou3.Adaptor/Translator/BookmarkDetailListRowViewModelTranslator.cs
+++ b/TestNarou3.Adaptor/Translator/BookmarkDetailListRowViewModelTranslator.cs
@@ -55,6 +55,8 @@ namespace TestNarou3.Adaptor.Translator
5555 .ForMember(d => d.GlobalPoint,
5656 opts => opts.MapFrom(s => s.GlobalPoint
5757 .ToReadOnlyReactiveProperty(0, ReactivePropertyMode.Default, null, null)))
58+ .ForMember(d => d.MinPerAllNo,
59+ opts => opts.MapFrom<MinPerAllNoResolver>())
5860 .ForMember(d => d.PointPerMin,
5961 opts => opts.MapFrom<PointPerMinResolver>())
6062 .ForMember(d => d.DailyPoint,
--- /dev/null
+++ b/TestNarou3.Adaptor/Translator/Converter/MinPerAllNoResolver.cs
@@ -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+}
--- a/TestNarou3.OuterEdge/UI/View/BookmarkDetailListView.xaml
+++ b/TestNarou3.OuterEdge/UI/View/BookmarkDetailListView.xaml
@@ -126,6 +126,14 @@
126126 </Style>
127127 </ctc:DataGridTextColumn.ElementStyle>
128128 </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>
129137 <ctc:DataGridTextColumn Header="評価/分" Width="80" Tag="PointPerMin"
130138 Binding="{Binding PointPerMin.Value, Converter={StaticResource StringFormat},ConverterParameter=\{0:N0\}}" >
131139 <ctc:DataGridTextColumn.ElementStyle>
--- a/TestNarou3.OuterEdge/UI/View/BookmarkDetailListView.xaml.cs
+++ b/TestNarou3.OuterEdge/UI/View/BookmarkDetailListView.xaml.cs
@@ -137,6 +137,19 @@ namespace TestNarou3.OuterEdge.UI.View
137137 }
138138 break;
139139
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+
140153 case "PointPerMin":
141154 if (direction == DataGridSortDirection.Ascending)
142155 {