EveryDB2のデータベースを読み込んでWinFormでGUI表示するサンプル
Revision | 9b5f965b7402faf4769a4ec83932867924442ef4 (tree) |
---|---|
Zeit | 2021-06-07 00:43:47 |
Autor | yoshy <yoshy@user...> |
Commiter | yoshy |
temp_20210607_0043
@@ -14,5 +14,21 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel.Dto | ||
14 | 14 | { |
15 | 15 | BeanHelper.Copy(this, race); |
16 | 16 | } |
17 | + | |
18 | + public string YearMonthDay => FormatHelper.FormatYearMonthDay(Year, Monthday); | |
19 | + | |
20 | + public string JyoName => CodeHelper.GetInstance().GetName(CodeHelper.JYO_CODE, Jyocd, 3, "不明"); | |
21 | + | |
22 | + public string RaceNumFormatted => FormatHelper.SuppressZeroLeading(Racenum); | |
23 | + | |
24 | + public string RaceName => CodeHelper.GetInstance().GetRaceName(this, "不明"); | |
25 | + | |
26 | + public string GradeName => CodeHelper.GetInstance().GetGradeName(this, "不明"); | |
27 | + | |
28 | + public string CourseName => CodeHelper.GetInstance().GetTurfDurtName(Trackcd, "不明") + Kyori; | |
29 | + | |
30 | + public string TosuFormatted => FormatHelper.FormatTosu(this); | |
31 | + | |
32 | + public string HassoTimeFormatted => FormatHelper.FormatTimeHHMM(Hassotime); | |
17 | 33 | } |
18 | 34 | } |
@@ -9,31 +9,11 @@ using UmaTest.Infra.Helper; | ||
9 | 9 | |
10 | 10 | namespace UmaTest.App.Adaptor.Gateway.ViewModel.Dto |
11 | 11 | { |
12 | - public class SearchRaceRowDto : NRace | |
12 | + public class SearchRaceRowDto : RaceInfo | |
13 | 13 | { |
14 | - public SearchRaceRowDto() | |
14 | + public SearchRaceRowDto(NRace race) : base(race) | |
15 | 15 | { |
16 | 16 | } |
17 | 17 | |
18 | - public SearchRaceRowDto(NRace race) | |
19 | - { | |
20 | - BeanHelper.Copy(this, race); | |
21 | - } | |
22 | - | |
23 | - public string YearMonthDay => FormatHelper.FormatYearMonthDay(Year, Monthday); | |
24 | - | |
25 | - public string JyoName => CodeHelper.GetInstance().GetName(CodeHelper.JYO_CODE, Jyocd, 3, "不明"); | |
26 | - | |
27 | - public string RaceNumFormatted => FormatHelper.SuppressZeroLeading(Racenum); | |
28 | - | |
29 | - public string RaceName => CodeHelper.GetInstance().GetRaceName(this, "不明"); | |
30 | - | |
31 | - public string GradeName => CodeHelper.GetInstance().GetGradeName(this, "不明"); | |
32 | - | |
33 | - public string CourseName => CodeHelper.GetInstance().GetTurfDurtName(Trackcd, "不明") + Kyori; | |
34 | - | |
35 | - public string TosuFormatted => FormatHelper.FormatTosu(this); | |
36 | - | |
37 | - public string HassoTimeFormatted => FormatHelper.FormatTimeHHMM(Hassotime); | |
38 | 18 | } |
39 | 19 | } |
@@ -25,7 +25,7 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel.Dto | ||
25 | 25 | Kettonum = kettoNum; |
26 | 26 | Bataijyu = bataijyu; |
27 | 27 | |
28 | - Race = BeanHelper.CreateAndCopy<NRace>(tokuRace); | |
28 | + Race = tokuRace.ToNRace(); | |
29 | 29 | |
30 | 30 | InitProperties(); |
31 | 31 | } |
@@ -11,17 +11,19 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
11 | 11 | { |
12 | 12 | public interface IMainWindowViewModel |
13 | 13 | { |
14 | - string Caption { get; set; } | |
14 | + string Caption { get; } | |
15 | 15 | ICommand CommandOpenHorseList { get; } |
16 | 16 | ICommand CommandOpenTokuRaceList { get; } |
17 | 17 | ICommand CommandSearchRace { get; } |
18 | 18 | EventHandler EventSelectedHorseChanged { get; } |
19 | 19 | IManualHorseListProxy ManualHorseListProxy { get; } |
20 | - BindingList<UmaRaceRowDto> UmaRaceList { get; set; } | |
20 | + BindingList<UmaRaceRowDto> UmaRaceList { get; } | |
21 | 21 | ISearchRaceViewProxy SearchRaceViewProxy { get; } |
22 | 22 | ITokuRaceListProxy TokuRaceListProxy { get; } |
23 | - BindingList<UmaSummaryRowDto> UmaSummaryList { get; set; } | |
24 | - EventObserver UmaSummaryListChangingEvent { get; set; } | |
23 | + BindingList<UmaSummaryRowDto> UmaSummaryList { get; } | |
24 | + EventObserver UmaSummaryListChangingEvent { get; set; } | |
25 | + | |
26 | + RaceInfo Race { get; } | |
25 | 27 | |
26 | 28 | event PropertyChangedEventHandler PropertyChanged; |
27 | 29 |
@@ -18,6 +18,7 @@ using UmaTest.App.Adaptor.Gateway.UI; | ||
18 | 18 | using UmaTest.Infra.Adaptor.ViewModel; |
19 | 19 | using System.Collections.ObjectModel; |
20 | 20 | using UmaTest.App.Domain.Model.Repository.Database.Entity.EveryDB2; |
21 | +using UmaTest.Infra.Helper; | |
21 | 22 | |
22 | 23 | namespace UmaTest.App.Adaptor.Gateway.ViewModel |
23 | 24 | { |
@@ -70,7 +71,7 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
70 | 71 | public string Caption |
71 | 72 | { |
72 | 73 | get => _caption; |
73 | - set => PropertyChanged.RaiseIfSet(() => Caption, ref _caption, value); | |
74 | + private set => PropertyChanged.RaiseIfSet(() => Caption, ref _caption, value); | |
74 | 75 | } |
75 | 76 | |
76 | 77 | private RaceInfo _race; |
@@ -78,7 +79,7 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
78 | 79 | public RaceInfo Race |
79 | 80 | { |
80 | 81 | get => _race; |
81 | - set => PropertyChanged.RaiseIfSet(() => Race, ref _race, value); | |
82 | + private set => PropertyChanged.RaiseIfSet(() => Race, ref _race, value); | |
82 | 83 | } |
83 | 84 | |
84 | 85 | private BindingList<UmaSummaryRowDto> _umaSummaryList = new BindingList<UmaSummaryRowDto>(); |
@@ -86,7 +87,7 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
86 | 87 | public BindingList<UmaSummaryRowDto> UmaSummaryList |
87 | 88 | { |
88 | 89 | get => _umaSummaryList; |
89 | - set => PropertyChanged.RaiseIfSet(() => UmaSummaryList, ref _umaSummaryList, value); | |
90 | + private set => PropertyChanged.RaiseIfSet(() => UmaSummaryList, ref _umaSummaryList, value); | |
90 | 91 | } |
91 | 92 | |
92 | 93 | private BindingList<UmaRaceRowDto> _umaRaceList = new BindingList<UmaRaceRowDto>(); |
@@ -94,7 +95,7 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
94 | 95 | public BindingList<UmaRaceRowDto> UmaRaceList |
95 | 96 | { |
96 | 97 | get => _umaRaceList; |
97 | - set => PropertyChanged.RaiseIfSet(() => UmaRaceList, ref _umaRaceList, value); | |
98 | + private set => PropertyChanged.RaiseIfSet(() => UmaRaceList, ref _umaRaceList, value); | |
98 | 99 | } |
99 | 100 | |
100 | 101 | public void RefreshModel(IList<UmaSummaryRowDto> umaSummaryList, IDictionary<string, IList<UmaRaceRowDto>> umaRaceMap) |
@@ -107,6 +108,23 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
107 | 108 | if (race != null) |
108 | 109 | { |
109 | 110 | Race = new RaceInfo(race); |
111 | + | |
112 | + switch (race.Recordspec) | |
113 | + { | |
114 | + case "RA": | |
115 | + string dataKbn = CodeHelper.GetInstance().GetName(CodeHelper.RACE_DATA_KUBUN, race.Datakubun, "不明"); | |
116 | + Caption = $"レース検索結果:[ {Race.YearMonthDay} {Race.JyoName}{FormatHelper.SuppressZeroLeading(Race.Racenum)}R {Race.RaceName} ({Race.CourseName}m) ] - {dataKbn}"; | |
117 | + break; | |
118 | + case "TK": | |
119 | + Caption = $"特別登録:[ {Race.YearMonthDay} {Race.JyoName}{FormatHelper.SuppressZeroLeading(Race.Racenum)}R {Race.RaceName} ({Race.CourseName}m) ]"; | |
120 | + break; | |
121 | + default: | |
122 | + break; | |
123 | + } | |
124 | + } | |
125 | + else | |
126 | + { | |
127 | + Caption = $"仮想出馬表:[ {DateTime.Now} ]"; | |
110 | 128 | } |
111 | 129 | |
112 | 130 | _umaRaceMap = new ReadOnlyDictionary<string, IList<UmaRaceRowDto>>(umaRaceMap); |
@@ -80,7 +80,6 @@ namespace UmaTest.App.Gateway.Presenter | ||
80 | 80 | }), |
81 | 81 | task => |
82 | 82 | { |
83 | - vm.Caption = $"仮想出馬表:[ {DateTime.Now} ]"; | |
84 | 83 | vm.RefreshModel(umaSummaryList, umaRaceMap); |
85 | 84 | }); |
86 | 85 | } |
@@ -66,10 +66,7 @@ namespace UmaTest.App.Gateway.Presenter | ||
66 | 66 | }), |
67 | 67 | task => |
68 | 68 | { |
69 | - SearchRaceRowDto race = req.Race; | |
70 | - string dataKbn = CodeHelper.GetInstance().GetName(CodeHelper.RACE_DATA_KUBUN, race.Datakubun, "不明"); | |
71 | - vm.Caption = $"レース検索結果:[ {race.YearMonthDay} {race.JyoName}{int.Parse(race.Racenum)}R {race.RaceName} ({race.CourseName}m) ] - {dataKbn}"; | |
72 | - vm.RefreshModel(race, umaSummaryList, umaRaceMap); | |
69 | + vm.RefreshModel(req.Race, umaSummaryList, umaRaceMap); | |
73 | 70 | }); |
74 | 71 | } |
75 | 72 | } |
@@ -51,7 +51,7 @@ namespace UmaTest.App.Gateway.Presenter | ||
51 | 51 | // FIXME |
52 | 52 | UmaRaceRowDto zenso = umaRaceList.Count > 0 ? umaRaceList[0] : null; |
53 | 53 | UmaRaceRowDto nisoMae = umaRaceList.Count > 1 ? umaRaceList[1] : null; |
54 | - UmaRaceRowDto konso = new UmaRaceRowDto(req.Race, kettoNum, summaryDto?.Zenso.Bataijyu); | |
54 | + UmaRaceRowDto konso = new UmaRaceRowDto(req.Race, kettoNum, zenso?.Bataijyu); | |
55 | 55 | |
56 | 56 | summaryDto.LoadUmaRaceList(konso, zenso, nisoMae); |
57 | 57 | summaryDto.SenSuu = umaRaceList.Count.ToString(); |
@@ -63,9 +63,7 @@ namespace UmaTest.App.Gateway.Presenter | ||
63 | 63 | }), |
64 | 64 | task => |
65 | 65 | { |
66 | - TokuRaceRowDto race = req.Race; | |
67 | - vm.Caption = $"特別登録:[ {race.YearMonthDay} {race.JyoName}{int.Parse(race.Racenum)}R {race.RaceName} ({race.CourseName}m) ]"; | |
68 | - vm.RefreshModel(race.ToNRace(), umaSummaryList, umaRaceMap); | |
66 | + vm.RefreshModel(req.Race.ToNRace(), umaSummaryList, umaRaceMap); | |
69 | 67 | }); |
70 | 68 | } |
71 | 69 | } |
@@ -31,6 +31,8 @@ namespace UmaTest.App.Presentation.View | ||
31 | 31 | |
32 | 32 | private bool isFormInitialized = false; |
33 | 33 | |
34 | + private RaceInfo raceInfo = null; | |
35 | + | |
34 | 36 | public MainWindow(IMainWindowViewModel vm, IStatusBarViewModel vmStatusBar, ICommandManager cm) |
35 | 37 | { |
36 | 38 | InitializeComponent(); |
@@ -799,6 +801,9 @@ namespace UmaTest.App.Presentation.View | ||
799 | 801 | case "Caption": |
800 | 802 | this.Text = AppConst.CAPTION + " - " + vm.Caption; |
801 | 803 | break; |
804 | + case "Race": | |
805 | + this.raceInfo = vm.Race; | |
806 | + break; | |
802 | 807 | case "UmaSummaryList": |
803 | 808 | { |
804 | 809 | bindingSource1.DataSource = vm.UmaSummaryList; |
@@ -47,7 +47,7 @@ namespace UmaTest.Infra.Helper | ||
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | - if (toProperty.PropertyType.IsAssignableFrom(fromValue.GetType())) | |
50 | + if ( (fromValue == null) || toProperty.PropertyType.IsAssignableFrom(fromValue.GetType()) ) | |
51 | 51 | { |
52 | 52 | toProperty.SetValue(to, fromValue); |
53 | 53 | } |
@@ -180,6 +180,11 @@ namespace UmaTest.Infra.Helper | ||
180 | 180 | |
181 | 181 | public string GetTurfDurtName(string trackCd, string errorValue) |
182 | 182 | { |
183 | + if (string.IsNullOrEmpty(trackCd)) | |
184 | + { | |
185 | + return string.Empty; | |
186 | + } | |
187 | + | |
183 | 188 | string trackEngName = GetName(TRACK_CODE, trackCd, 2, errorValue); |
184 | 189 | |
185 | 190 | if (trackCd.CompareTo("50") < 0) |
@@ -105,7 +105,7 @@ namespace UmaTest.Infra.Helper | ||
105 | 105 | return SuppressZeroLeading(race.Ninki); |
106 | 106 | } |
107 | 107 | |
108 | - if (!string.IsNullOrEmpty(race.OddsTanpuku.Tanninki) && (race.OddsTanpuku.Tanninki != "00")) | |
108 | + if (!string.IsNullOrEmpty(race.OddsTanpuku?.Tanninki) && (race.OddsTanpuku.Tanninki != "00")) | |
109 | 109 | { |
110 | 110 | return SuppressZeroLeading(race.OddsTanpuku.Tanninki); |
111 | 111 | } |