EveryDB2のデータベースを読み込んでWinFormでGUI表示するサンプル
Révision | 189493fa659cf9258763c71f782a3b1c943191d0 (tree) |
---|---|
l'heure | 2021-05-29 02:42:48 |
Auteur | yoshy <yoshy@user...> |
Commiter | yoshy |
temp_20210529_0242
@@ -10,6 +10,7 @@ using ICommand = UmaTest.Infra.Adaptor.Command.ICommand; | ||
10 | 10 | using UmaTest.Infra.Adaptor.Controller.Handler; |
11 | 11 | using UmaTest.Infra.Domain.UseCase; |
12 | 12 | using System.Threading.Tasks; |
13 | +using UmaTest.Infra.Gateway.UI; | |
13 | 14 | |
14 | 15 | namespace UmaTest.App.Adaptor.Controller |
15 | 16 | { |
@@ -18,12 +19,14 @@ namespace UmaTest.App.Adaptor.Controller | ||
18 | 19 | private IUseCaseRouter router; |
19 | 20 | private IAsyncUseCaseRouter asyncRouter; |
20 | 21 | private IUserDialogProxy dialog; |
22 | + private IStatusBarProxy statusBar; | |
21 | 23 | |
22 | - public WindowController(IUseCaseRouter router, IAsyncUseCaseRouter asyncRouter, IUserDialogProxy dialog) | |
24 | + public WindowController(IUseCaseRouter router, IAsyncUseCaseRouter asyncRouter, IUserDialogProxy dialog, IStatusBarProxy statusBar) | |
23 | 25 | { |
24 | 26 | this.router = router; |
25 | 27 | this.asyncRouter = asyncRouter; |
26 | 28 | this.dialog = dialog; |
29 | + this.statusBar = statusBar; | |
27 | 30 | |
28 | 31 | Events = new Dictionary<String, EventHandler>() |
29 | 32 | { |
@@ -77,6 +80,10 @@ namespace UmaTest.App.Adaptor.Controller | ||
77 | 80 | res.AbortWithSomeErrors("[Bug Check] コマンドの処理結果が未設定です。ハンドラマップの設定漏れの可能性があります"); |
78 | 81 | } |
79 | 82 | |
83 | + string statusText = !String.IsNullOrEmpty(res.Message) ? res.Message : AppConst.STATUS_BAR_READY; | |
84 | + | |
85 | + statusBar.SetStatusText(statusText); | |
86 | + | |
80 | 87 | if (res.HasSomeError()) |
81 | 88 | { |
82 | 89 | dialog.ShowError(res.Message, req.UIInfo); |
@@ -8,7 +8,7 @@ namespace UmaTest.App.Adaptor.Gateway.UI | ||
8 | 8 | internal class ManualHorseListProxy |
9 | 9 | : ShowChildWindowProxy<ManualHorseListView, IManualHorseListViewModel>, IManualHorseListProxy |
10 | 10 | { |
11 | - private IManualHorseListViewModel vm; | |
11 | + private readonly IManualHorseListViewModel vm; | |
12 | 12 | |
13 | 13 | public ManualHorseListProxy(ManualHorseListView window, IManualHorseListViewModel vm) : base(window) |
14 | 14 | { |
@@ -4,10 +4,11 @@ using System.ComponentModel; | ||
4 | 4 | using UmaTest.App.Adaptor.Gateway.UI; |
5 | 5 | using UmaTest.App.Adaptor.Gateway.ViewModel.Dto; |
6 | 6 | using UmaTest.Infra.Adaptor.Command; |
7 | +using UmaTest.Infra.Adaptor.ViewModel; | |
7 | 8 | |
8 | 9 | namespace UmaTest.App.Adaptor.Gateway.ViewModel |
9 | 10 | { |
10 | - public interface IMainWindowViewModel | |
11 | + public interface IMainWindowViewModel : INotifyPropertyChanged | |
11 | 12 | { |
12 | 13 | ICommand CommandReadHorseList { get; } |
13 | 14 | EventHandler EventSelectedHorseChanged { get; } |
@@ -15,8 +16,6 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
15 | 16 | BindingList<UmaRaceRowDto> RaceList { get; set; } |
16 | 17 | BindingList<UmaSummaryRowDto> UmaSummaryList { get; set; } |
17 | 18 | |
18 | - event PropertyChangedEventHandler PropertyChanged; | |
19 | - | |
20 | 19 | void RefreshModel(List<UmaSummaryRowDto> umaSummaryList, Dictionary<string, List<UmaRaceRowDto>> umaRaceMap); |
21 | 20 | } |
22 | 21 | } |
\ No newline at end of file |
@@ -15,6 +15,7 @@ using UmaTest.Infra.Log; | ||
15 | 15 | using ICommand = UmaTest.Infra.Adaptor.Command.ICommand; |
16 | 16 | using UmaTest.App.Adaptor.Controller; |
17 | 17 | using UmaTest.App.Adaptor.Gateway.UI; |
18 | +using UmaTest.Infra.Adaptor.ViewModel; | |
18 | 19 | |
19 | 20 | namespace UmaTest.App.Adaptor.Gateway.ViewModel |
20 | 21 | { |
@@ -30,11 +31,6 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
30 | 31 | |
31 | 32 | private IWindowController wc; |
32 | 33 | |
33 | - private BindingList<UmaSummaryRowDto> _chakudosuuList = new BindingList<UmaSummaryRowDto>(); | |
34 | - | |
35 | - private BindingList<UmaRaceRowDto> _raceList = new BindingList<UmaRaceRowDto>(); | |
36 | - | |
37 | - private List<UmaSummaryRowDto> _umaSummaryList = null; | |
38 | 34 | private Dictionary<string, List<UmaRaceRowDto>> _umaRaceMap = null; |
39 | 35 | |
40 | 36 | public MainWindowViewModel(IWindowController wc, IManualHorseListProxy horseListProxy) |
@@ -46,12 +42,16 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
46 | 42 | EventSelectedHorseChanged = new EventHandler(OnSelectedHorseChanged); |
47 | 43 | } |
48 | 44 | |
45 | + private BindingList<UmaSummaryRowDto> _umaSummaryList = new BindingList<UmaSummaryRowDto>(); | |
46 | + | |
49 | 47 | public BindingList<UmaSummaryRowDto> UmaSummaryList |
50 | 48 | { |
51 | - get => _chakudosuuList; | |
52 | - set => PropertyChanged.RaiseIfSet(() => UmaSummaryList, ref _chakudosuuList, value); | |
49 | + get => _umaSummaryList; | |
50 | + set => PropertyChanged.RaiseIfSet(() => UmaSummaryList, ref _umaSummaryList, value); | |
53 | 51 | } |
54 | 52 | |
53 | + private BindingList<UmaRaceRowDto> _raceList = new BindingList<UmaRaceRowDto>(); | |
54 | + | |
55 | 55 | public BindingList<UmaRaceRowDto> RaceList |
56 | 56 | { |
57 | 57 | get => _raceList; |
@@ -60,7 +60,6 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
60 | 60 | |
61 | 61 | public void RefreshModel(List<UmaSummaryRowDto> umaSummaryList, Dictionary<string, List<UmaRaceRowDto>> umaRaceMap) |
62 | 62 | { |
63 | - _umaSummaryList = umaSummaryList; | |
64 | 63 | _umaRaceMap = umaRaceMap; |
65 | 64 | |
66 | 65 | UmaSummaryList = new BindingList<UmaSummaryRowDto>(umaSummaryList); |
@@ -28,8 +28,8 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
28 | 28 | { |
29 | 29 | this.wc = wc; |
30 | 30 | this.CommandExecuteReadManualHorseList = new DelegateCommand( |
31 | - //"Read", () => !String.IsNullOrEmpty(HorseList), OnExecuteReadManualHorseList); | |
32 | - "Read", () => true, OnExecuteReadManualHorseList); | |
31 | + "Read", () => !String.IsNullOrEmpty(HorseList), OnExecuteReadManualHorseList); | |
32 | + //"Read", () => true, OnExecuteReadManualHorseList); | |
33 | 33 | |
34 | 34 | this.HorseList = "アドマイヤハダル\r\nエフフォーリア\r\nグラティアス\r\nグレートマジシャン\r\nサトノレイナス\r\nシャフリヤール\r\nステラヴェローチェ\r\nタイトルホルダー\r\nタイムトゥヘヴン\r\nダノンザキッド\r\nディープモンスター\r\nバジオウ\r\nバスラットレオン\r\nヨーホーレイク\r\nラーゴム\r\nレッドジェネシス\r\nワンダフルタウン\r\nヴィクティファルス\r\n"; |
35 | 35 | } |
@@ -47,10 +47,7 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
47 | 47 | public string HorseList |
48 | 48 | { |
49 | 49 | get => _horseList; |
50 | - set | |
51 | - { | |
52 | - PropertyChanged.RaiseIfSet(() => HorseList, ref _horseList, value); | |
53 | - } | |
50 | + set => PropertyChanged.RaiseIfSet(() => HorseList, ref _horseList, value); | |
54 | 51 | } |
55 | 52 | } |
56 | 53 | } |
@@ -11,6 +11,7 @@ using UmaTest.App.Domain.Model.Repository.Database.Entity.EveryDB2; | ||
11 | 11 | using UmaTest.App.Domain.UseCase.Request; |
12 | 12 | using UmaTest.App.Domain.UseCase.Response; |
13 | 13 | using UmaTest.Infra.Domain.UseCase; |
14 | +using UmaTest.Infra.Gateway.UI; | |
14 | 15 | using UmaTest.Infra.Helper; |
15 | 16 | using UmaTest.Infra.Log; |
16 | 17 |
@@ -19,27 +20,27 @@ namespace UmaTest.App.Gateway.Presenter | ||
19 | 20 | public class AsyncLoadHorseRaceSummaryPresenter : IAsyncLoadHorseRaceSummaryPresenter |
20 | 21 | { |
21 | 22 | private IMainWindowViewModel vm; |
23 | + private IStatusBarProxy statusBar; | |
22 | 24 | |
23 | 25 | private List<UmaSummaryRowDto> umaSummaryList = new List<UmaSummaryRowDto>(); |
24 | 26 | private Dictionary<string, List<UmaRaceRowDto>> umaRaceMap = new Dictionary<string, List<UmaRaceRowDto>>(); |
25 | 27 | |
26 | 28 | |
27 | - public AsyncLoadHorseRaceSummaryPresenter(IMainWindowViewModel vm) | |
29 | + public AsyncLoadHorseRaceSummaryPresenter(IStatusBarProxy statusBar, IMainWindowViewModel vm) | |
28 | 30 | { |
29 | 31 | this.vm = vm; |
32 | + this.statusBar = statusBar; | |
30 | 33 | } |
31 | 34 | |
32 | 35 | public Task<UseCaseResponse> HandleAsync(UseCaseResponse baseRes) |
33 | 36 | { |
34 | - return TaskHelper.RunWithContinuation<UseCaseResponse>(Task.Run<UseCaseResponse>(() => | |
37 | + return TaskHelper.RunWithUIAction<UseCaseResponse>(Task.Run<UseCaseResponse>(() => | |
35 | 38 | { |
36 | 39 | LoadHorseRaceSummaryRequest req = baseRes.Request as LoadHorseRaceSummaryRequest; |
37 | 40 | LoadHorseRaceSummaryResponse res = baseRes as LoadHorseRaceSummaryResponse; |
38 | 41 | |
39 | 42 | List<string> kettoNums = res.KettoNums; |
40 | 43 | |
41 | - // TODO 変換処理をtranslatorに委譲 | |
42 | - | |
43 | 44 | foreach (string kettoNum in kettoNums) |
44 | 45 | { |
45 | 46 | Logger.Info($"血統登録番号: {kettoNum}"); |
@@ -52,10 +53,17 @@ namespace UmaTest.App.Gateway.Presenter | ||
52 | 53 | continue; |
53 | 54 | } |
54 | 55 | |
56 | + statusBar.SetStatusText($"血統登録番号: {kettoNum}, 馬名: {uma.Bamei} の情報をレンダリング中です..."); | |
57 | + | |
55 | 58 | summaryDto = new UmaSummaryRowDto(uma); |
56 | 59 | |
57 | 60 | foreach (ChakudosuuSummary chakudosuu in res.Summaries[kettoNum]) |
58 | 61 | { |
62 | + if (chakudosuu.Chakudosuu == "0.0.0.0") | |
63 | + { | |
64 | + continue; | |
65 | + } | |
66 | + | |
59 | 67 | ChakudosuuByGradeRowDto chakudosuuByGrade; |
60 | 68 | |
61 | 69 | switch (chakudosuu.Key1) |
@@ -92,6 +100,8 @@ namespace UmaTest.App.Gateway.Presenter | ||
92 | 100 | break; |
93 | 101 | case "ZZ": |
94 | 102 | chakudosuuByGrade.ZZ = chakudosuu.Chakudosuu; |
103 | + break; | |
104 | + default: | |
95 | 105 | continue; |
96 | 106 | } |
97 | 107 |
@@ -113,7 +123,7 @@ namespace UmaTest.App.Gateway.Presenter | ||
113 | 123 | summaryDto.Long = chakudosuuByGrade; |
114 | 124 | break; |
115 | 125 | default: |
116 | - break; | |
126 | + continue; | |
117 | 127 | } |
118 | 128 | } |
119 | 129 |
@@ -124,7 +134,7 @@ namespace UmaTest.App.Gateway.Presenter | ||
124 | 134 | if (!res.Races.TryGetValue(kettoNum, out IEnumerable<NUmaRaceWithNRace> umaRaces) || (umaRaces.Count() == 0)) |
125 | 135 | { |
126 | 136 | Logger.Warn($"血統登録番号: {kettoNum} の馬レース情報が見つかりませんでした"); |
127 | - return res; | |
137 | + continue; | |
128 | 138 | } |
129 | 139 | |
130 | 140 | List<UmaRaceRowDto> umaRaceList = new List<UmaRaceRowDto>(); |
@@ -19,5 +19,6 @@ namespace UmaTest.App | ||
19 | 19 | |
20 | 20 | internal static readonly string CAPTION_CONFIRM = "確認"; |
21 | 21 | |
22 | + internal static readonly string STATUS_BAR_READY = "Ready."; | |
22 | 23 | } |
23 | 24 | } |
@@ -19,6 +19,8 @@ using UmaTest.Infra.Adaptor.Controller.Handler; | ||
19 | 19 | using UmaTest.Infra.Adaptor.Command; |
20 | 20 | using UmaTest.Infra.DI; |
21 | 21 | using UmaTest.Infra.Helper; |
22 | +using UmaTest.Infra.Adaptor.ViewModel; | |
23 | +using UmaTest.Infra.Gateway.UI; | |
22 | 24 | |
23 | 25 | namespace UmaTest.App.DI |
24 | 26 | { |
@@ -52,6 +54,8 @@ namespace UmaTest.App.DI | ||
52 | 54 | di.RegisterSingleton<MainWindow>(); |
53 | 55 | di.RegisterSingleton<IMainWindowViewModel, MainWindowViewModel>(); |
54 | 56 | |
57 | + di.RegisterSingleton<IStatusBarViewModel, StatusBarViewModel>(); | |
58 | + | |
55 | 59 | di.RegisterSingleton<ManualHorseListView>(); |
56 | 60 | di.RegisterSingleton<IManualHorseListViewModel, ManualHorseListViewModel>(); |
57 | 61 |
@@ -60,6 +64,7 @@ namespace UmaTest.App.DI | ||
60 | 64 | /// |
61 | 65 | |
62 | 66 | di.RegisterSingleton<IUserDialogProxy, UserDialogProxy>(); |
67 | + di.RegisterSingleton<IStatusBarProxy, StatusBarProxy>(); | |
63 | 68 | di.RegisterSingleton<IManualHorseListProxy, ManualHorseListProxy>(); |
64 | 69 | |
65 | 70 | /// |
@@ -6,16 +6,20 @@ using System.Text; | ||
6 | 6 | using System.Threading.Tasks; |
7 | 7 | using UmaTest.App.Domain.Model.Repository.Database.Dao; |
8 | 8 | using UmaTest.App.Domain.Model.Repository.Database.Dto; |
9 | +using UmaTest.Infra.Gateway.UI; | |
9 | 10 | using UmaTest.Infra.Helper; |
10 | 11 | |
11 | 12 | namespace UmaTest.App.Domain.Model.Logic |
12 | 13 | { |
13 | 14 | internal class UmaRaceLogic : IUmaRaceLogic |
14 | 15 | { |
15 | - INUmaRaceDao dao; | |
16 | - public UmaRaceLogic(INUmaRaceDao dao) | |
16 | + private INUmaRaceDao dao; | |
17 | + private IStatusBarProxy statusBar; | |
18 | + | |
19 | + public UmaRaceLogic(INUmaRaceDao dao, IStatusBarProxy statusBar) | |
17 | 20 | { |
18 | 21 | this.dao = dao; |
22 | + this.statusBar = statusBar; | |
19 | 23 | } |
20 | 24 | |
21 | 25 | public Dictionary<string, IEnumerable<NUmaRaceWithNRace>> LoadRaces(List<string> kettoNumList) |
@@ -46,6 +50,7 @@ namespace UmaTest.App.Domain.Model.Logic | ||
46 | 50 | |
47 | 51 | foreach (string kettoNum in kettoNumList) |
48 | 52 | { |
53 | + statusBar.SetStatusText($"血統登録番号: {kettoNum} に紐付くレース着度数情報を集約中です..."); | |
49 | 54 | IEnumerable<ChakudosuuSummary> summaries = await dao.findChakudosuuSummaryAsync(kettoNum); |
50 | 55 | res.Add(kettoNum, summaries); |
51 | 56 | } |
@@ -7,6 +7,7 @@ using UmaTest.App.Domain.Model.Repository.Database.Dto; | ||
7 | 7 | using UmaTest.App.Domain.Model.Repository.Database.Entity.EveryDB2; |
8 | 8 | using UmaTest.App.Domain.UseCase.Request; |
9 | 9 | using UmaTest.App.Domain.UseCase.Response; |
10 | +using UmaTest.Infra.Gateway.UI; | |
10 | 11 | |
11 | 12 | namespace UmaTest.App.Domain.Translator |
12 | 13 | { |
@@ -10,6 +10,7 @@ using UmaTest.App.Domain.Translator; | ||
10 | 10 | using UmaTest.App.Domain.UseCase.Request; |
11 | 11 | using UmaTest.App.Domain.UseCase.Response; |
12 | 12 | using UmaTest.Infra.Domain.UseCase; |
13 | +using UmaTest.Infra.Gateway.UI; | |
13 | 14 | |
14 | 15 | namespace UmaTest.App.Domain.UseCase.Interactor |
15 | 16 | { |
@@ -17,11 +18,15 @@ namespace UmaTest.App.Domain.UseCase.Interactor | ||
17 | 18 | { |
18 | 19 | IUmaLogic logicUma; |
19 | 20 | IUmaRaceLogic logicUmaRace; |
21 | + IStatusBarProxy statusBarProxy; | |
20 | 22 | ILoadHorseRaceSummaryTranslator translator; |
21 | - public AsyncLoadHorseRaceSummaryInteractor(IUmaLogic logicUma, IUmaRaceLogic logicUmaRace, ILoadHorseRaceSummaryTranslator translator) : base() | |
23 | + | |
24 | + public AsyncLoadHorseRaceSummaryInteractor(IUmaLogic logicUma, IUmaRaceLogic logicUmaRace, | |
25 | + IStatusBarProxy statusBarProxy, ILoadHorseRaceSummaryTranslator translator) : base() | |
22 | 26 | { |
23 | 27 | this.logicUma = logicUma; |
24 | 28 | this.logicUmaRace = logicUmaRace; |
29 | + this.statusBarProxy = statusBarProxy; | |
25 | 30 | this.translator = translator; |
26 | 31 | } |
27 | 32 |
@@ -30,6 +35,8 @@ namespace UmaTest.App.Domain.UseCase.Interactor | ||
30 | 35 | LoadHorseRaceSummaryRequest req = baseReq as LoadHorseRaceSummaryRequest; |
31 | 36 | LoadHorseRaceSummaryResponse res = req.Response as LoadHorseRaceSummaryResponse; |
32 | 37 | |
38 | + statusBarProxy.SetStatusText("データ読み込み中..."); | |
39 | + | |
33 | 40 | List<string> bameiList = req.HorseList; |
34 | 41 | |
35 | 42 | if (bameiList.Count == 0) |
@@ -37,11 +44,18 @@ namespace UmaTest.App.Domain.UseCase.Interactor | ||
37 | 44 | return res.AbortWithSomeErrors("馬名リストが設定されていません"); |
38 | 45 | } |
39 | 46 | |
47 | + statusBarProxy.SetStatusText("馬情報を読み込んでいます..."); | |
48 | + | |
40 | 49 | Dictionary<string, NUma> horses = await logicUma.LoadHorsesAsync(req.HorseList); |
41 | 50 | |
42 | 51 | List<string> kettoNums = horses.Select(h => h.Value.Kettonum).OrderBy(k => k).ToList(); |
43 | 52 | |
53 | + statusBarProxy.SetStatusText("馬に紐付くレース情報を読み込んでいます..."); | |
54 | + | |
44 | 55 | Dictionary<string, IEnumerable<NUmaRaceWithNRace>> races = await logicUmaRace.LoadRacesAsync(kettoNums); |
56 | + | |
57 | + statusBarProxy.SetStatusText("馬に紐付く着度数情報を読み込んでいます..."); | |
58 | + | |
45 | 59 | Dictionary<string, IEnumerable<ChakudosuuSummary>> summaries = await logicUmaRace.LoadChakudosuuSummariesAsync(kettoNums); |
46 | 60 | |
47 | 61 | return translator.Translate(res, req, kettoNums, horses, races, summaries); |
@@ -39,6 +39,8 @@ namespace UmaTest.App.Presentation.View | ||
39 | 39 | this.splitContainer2 = new System.Windows.Forms.SplitContainer(); |
40 | 40 | this.dataGridView1 = new System.Windows.Forms.DataGridView(); |
41 | 41 | this.dataGridView2 = new System.Windows.Forms.DataGridView(); |
42 | + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); | |
43 | + this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); | |
42 | 44 | this.menuStrip1.SuspendLayout(); |
43 | 45 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); |
44 | 46 | this.splitContainer1.Panel1.SuspendLayout(); |
@@ -50,6 +52,7 @@ namespace UmaTest.App.Presentation.View | ||
50 | 52 | this.splitContainer2.SuspendLayout(); |
51 | 53 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); |
52 | 54 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit(); |
55 | + this.statusStrip1.SuspendLayout(); | |
53 | 56 | this.SuspendLayout(); |
54 | 57 | // |
55 | 58 | // menuStrip1 |
@@ -103,7 +106,7 @@ namespace UmaTest.App.Presentation.View | ||
103 | 106 | // splitContainer1.Panel2 |
104 | 107 | // |
105 | 108 | this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); |
106 | - this.splitContainer1.Size = new System.Drawing.Size(862, 493); | |
109 | + this.splitContainer1.Size = new System.Drawing.Size(862, 471); | |
107 | 110 | this.splitContainer1.SplitterDistance = 92; |
108 | 111 | this.splitContainer1.TabIndex = 1; |
109 | 112 | // |
@@ -112,7 +115,7 @@ namespace UmaTest.App.Presentation.View | ||
112 | 115 | this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill; |
113 | 116 | this.treeView1.Location = new System.Drawing.Point(0, 0); |
114 | 117 | this.treeView1.Name = "treeView1"; |
115 | - this.treeView1.Size = new System.Drawing.Size(92, 493); | |
118 | + this.treeView1.Size = new System.Drawing.Size(92, 471); | |
116 | 119 | this.treeView1.TabIndex = 0; |
117 | 120 | // |
118 | 121 | // splitContainer2 |
@@ -129,8 +132,8 @@ namespace UmaTest.App.Presentation.View | ||
129 | 132 | // splitContainer2.Panel2 |
130 | 133 | // |
131 | 134 | this.splitContainer2.Panel2.Controls.Add(this.dataGridView2); |
132 | - this.splitContainer2.Size = new System.Drawing.Size(766, 493); | |
133 | - this.splitContainer2.SplitterDistance = 303; | |
135 | + this.splitContainer2.Size = new System.Drawing.Size(766, 471); | |
136 | + this.splitContainer2.SplitterDistance = 289; | |
134 | 137 | this.splitContainer2.TabIndex = 0; |
135 | 138 | // |
136 | 139 | // dataGridView1 |
@@ -138,7 +141,7 @@ namespace UmaTest.App.Presentation.View | ||
138 | 141 | this.dataGridView1.AllowUserToAddRows = false; |
139 | 142 | this.dataGridView1.AllowUserToDeleteRows = false; |
140 | 143 | this.dataGridView1.AllowUserToResizeRows = false; |
141 | - this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; | |
144 | + this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader; | |
142 | 145 | this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; |
143 | 146 | this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; |
144 | 147 | this.dataGridView1.Location = new System.Drawing.Point(0, 0); |
@@ -147,7 +150,7 @@ namespace UmaTest.App.Presentation.View | ||
147 | 150 | this.dataGridView1.ReadOnly = true; |
148 | 151 | this.dataGridView1.RowTemplate.Height = 21; |
149 | 152 | this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; |
150 | - this.dataGridView1.Size = new System.Drawing.Size(766, 303); | |
153 | + this.dataGridView1.Size = new System.Drawing.Size(766, 289); | |
151 | 154 | this.dataGridView1.TabIndex = 0; |
152 | 155 | // |
153 | 156 | // dataGridView2 |
@@ -155,7 +158,7 @@ namespace UmaTest.App.Presentation.View | ||
155 | 158 | this.dataGridView2.AllowUserToAddRows = false; |
156 | 159 | this.dataGridView2.AllowUserToDeleteRows = false; |
157 | 160 | this.dataGridView2.AllowUserToResizeRows = false; |
158 | - this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; | |
161 | + this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader; | |
159 | 162 | this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; |
160 | 163 | this.dataGridView2.Dock = System.Windows.Forms.DockStyle.Fill; |
161 | 164 | this.dataGridView2.Location = new System.Drawing.Point(0, 0); |
@@ -164,15 +167,32 @@ namespace UmaTest.App.Presentation.View | ||
164 | 167 | this.dataGridView2.ReadOnly = true; |
165 | 168 | this.dataGridView2.RowTemplate.Height = 21; |
166 | 169 | this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; |
167 | - this.dataGridView2.Size = new System.Drawing.Size(766, 186); | |
170 | + this.dataGridView2.Size = new System.Drawing.Size(766, 178); | |
168 | 171 | this.dataGridView2.TabIndex = 0; |
169 | 172 | // |
173 | + // statusStrip1 | |
174 | + // | |
175 | + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { | |
176 | + this.toolStripStatusLabel1}); | |
177 | + this.statusStrip1.Location = new System.Drawing.Point(0, 495); | |
178 | + this.statusStrip1.Name = "statusStrip1"; | |
179 | + this.statusStrip1.Size = new System.Drawing.Size(862, 22); | |
180 | + this.statusStrip1.TabIndex = 2; | |
181 | + this.statusStrip1.Text = "statusStrip1"; | |
182 | + // | |
183 | + // toolStripStatusLabel1 | |
184 | + // | |
185 | + this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; | |
186 | + this.toolStripStatusLabel1.Size = new System.Drawing.Size(41, 17); | |
187 | + this.toolStripStatusLabel1.Text = "Ready."; | |
188 | + // | |
170 | 189 | // MainWindow |
171 | 190 | // |
172 | 191 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); |
173 | 192 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
174 | 193 | this.ClientSize = new System.Drawing.Size(862, 517); |
175 | 194 | this.Controls.Add(this.splitContainer1); |
195 | + this.Controls.Add(this.statusStrip1); | |
176 | 196 | this.Controls.Add(this.menuStrip1); |
177 | 197 | this.MainMenuStrip = this.menuStrip1; |
178 | 198 | this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); |
@@ -190,6 +210,8 @@ namespace UmaTest.App.Presentation.View | ||
190 | 210 | this.splitContainer2.ResumeLayout(false); |
191 | 211 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); |
192 | 212 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit(); |
213 | + this.statusStrip1.ResumeLayout(false); | |
214 | + this.statusStrip1.PerformLayout(); | |
193 | 215 | this.ResumeLayout(false); |
194 | 216 | this.PerformLayout(); |
195 | 217 |
@@ -207,6 +229,8 @@ namespace UmaTest.App.Presentation.View | ||
207 | 229 | private System.Windows.Forms.DataGridView dataGridView1; |
208 | 230 | private System.Windows.Forms.TreeView treeView1; |
209 | 231 | private System.Windows.Forms.DataGridView dataGridView2; |
232 | + private System.Windows.Forms.StatusStrip statusStrip1; | |
233 | + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; | |
210 | 234 | } |
211 | 235 | } |
212 | 236 |
@@ -16,7 +16,9 @@ using UmaTest.App.Adaptor.Gateway.ViewModel.Dto; | ||
16 | 16 | using UmaTest.App.Domain.Model.Repository.Database.Dto; |
17 | 17 | using UmaTest.App.Domain.Model.Repository.Database.Entity.EveryDB2; |
18 | 18 | using UmaTest.Infra.Adaptor.Command; |
19 | +using UmaTest.Infra.Adaptor.ViewModel; | |
19 | 20 | using UmaTest.Infra.Domain.Translator; |
21 | +using UmaTest.Infra.Presentation.View; | |
20 | 22 | |
21 | 23 | namespace UmaTest.App.Presentation.View |
22 | 24 | { |
@@ -27,7 +29,7 @@ namespace UmaTest.App.Presentation.View | ||
27 | 29 | private BindingSource bindingSource1 = new BindingSource(); |
28 | 30 | private BindingSource bindingSource2 = new BindingSource(); |
29 | 31 | |
30 | - public MainWindow(IMainWindowViewModel vm, ICommandManager cm) | |
32 | + public MainWindow(IMainWindowViewModel vm, IStatusBarViewModel vmStatusBar, ICommandManager cm) | |
31 | 33 | { |
32 | 34 | InitializeComponent(); |
33 | 35 |
@@ -39,17 +41,22 @@ namespace UmaTest.App.Presentation.View | ||
39 | 41 | |
40 | 42 | vm.ManualHorseListProxy.Owner = this; |
41 | 43 | |
42 | - // Register UI EventHandler of VM | |
44 | + // Register UI EventHandler | |
43 | 45 | |
44 | 46 | this.dataGridView1.SelectionChanged += vm.EventSelectedHorseChanged; |
45 | 47 | |
46 | 48 | // |
47 | - // Bind UI Commands of VM | |
49 | + // Bind UI Commands | |
48 | 50 | // |
49 | 51 | |
50 | 52 | cm.Bind(vm.CommandReadHorseList, this.toolStripMenuOpenHorseList); |
51 | 53 | |
52 | 54 | // |
55 | + // Bind UI Text | |
56 | + // | |
57 | + DataContextHelper.BindText(this.toolStripStatusLabel1, vmStatusBar, "StatusText"); | |
58 | + | |
59 | + // | |
53 | 60 | // Initialize DataGridView1 |
54 | 61 | // |
55 | 62 |
@@ -173,6 +180,8 @@ namespace UmaTest.App.Presentation.View | ||
173 | 180 | }, |
174 | 181 | }; |
175 | 182 | |
183 | + grid1Cols.Do(col => col.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter); | |
184 | + | |
176 | 185 | dataGridView1.Columns.AddRange(grid1Cols); |
177 | 186 | |
178 | 187 | // |
@@ -209,6 +218,16 @@ namespace UmaTest.App.Presentation.View | ||
209 | 218 | }, |
210 | 219 | new DataGridViewTextBoxColumn |
211 | 220 | { |
221 | + DataPropertyName = "Wakuban", | |
222 | + Name = "枠番", | |
223 | + }, | |
224 | + new DataGridViewTextBoxColumn | |
225 | + { | |
226 | + DataPropertyName = "Umaban", | |
227 | + Name = "馬番", | |
228 | + }, | |
229 | + new DataGridViewTextBoxColumn | |
230 | + { | |
212 | 231 | DataPropertyName = "Ninki", |
213 | 232 | Name = "人気", |
214 | 233 | }, |
@@ -239,6 +258,8 @@ namespace UmaTest.App.Presentation.View | ||
239 | 258 | }, |
240 | 259 | }; |
241 | 260 | |
261 | + grid2Cols.Do(col => col.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter); | |
262 | + | |
242 | 263 | dataGridView2.Columns.AddRange(grid2Cols); |
243 | 264 | |
244 | 265 | // |
@@ -282,16 +303,24 @@ namespace UmaTest.App.Presentation.View | ||
282 | 303 | switch (args.PropertyName) |
283 | 304 | { |
284 | 305 | case "UmaSummaryList": |
306 | + dataGridView1.SuspendLayout(); | |
307 | + dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; | |
285 | 308 | dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; |
286 | 309 | bindingSource1.DataSource = vm.UmaSummaryList; |
310 | + dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; | |
287 | 311 | dataGridView1.AutoSizeColumnsMode = vm.UmaSummaryList.Count > 0 |
288 | 312 | ? DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader |
289 | 313 | : DataGridViewAutoSizeColumnsMode.AllCells; |
314 | + dataGridView1.ResumeLayout(); | |
290 | 315 | break; |
291 | 316 | case "RaceList": |
317 | + dataGridView2.SuspendLayout(); | |
318 | + //dataGridView2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; | |
292 | 319 | dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; |
293 | 320 | bindingSource2.DataSource = vm.RaceList; |
321 | + //dataGridView2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; | |
294 | 322 | dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; |
323 | + dataGridView2.ResumeLayout(); | |
295 | 324 | break; |
296 | 325 | } |
297 | 326 | } |
@@ -120,4 +120,7 @@ | ||
120 | 120 | <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
121 | 121 | <value>17, 17</value> |
122 | 122 | </metadata> |
123 | + <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | |
124 | + <value>248, 17</value> | |
125 | + </metadata> | |
123 | 126 | </root> |
\ No newline at end of file |
@@ -30,6 +30,7 @@ namespace UmaTest.App.Presentation.View | ||
30 | 30 | |
31 | 31 | public void ShowChildWindow() |
32 | 32 | { |
33 | + this.CenterToParent(); | |
33 | 34 | this.Show(); |
34 | 35 | } |
35 | 36 |
@@ -40,6 +41,8 @@ namespace UmaTest.App.Presentation.View | ||
40 | 41 | |
41 | 42 | private void Bind(IManualHorseListViewModel vm, ICommandManager cm) |
42 | 43 | { |
44 | + DataContextHelper.BindText(txtHorseList, vm, "HorseList"); | |
45 | + | |
43 | 46 | ICommand commandHide = new DelegateCommand("Cancel", () => true, HideChildWindow); |
44 | 47 | |
45 | 48 | cm.Bind(commandHide, btnCancel); |
@@ -50,8 +53,6 @@ namespace UmaTest.App.Presentation.View | ||
50 | 53 | commandRead.Add(commandHide); |
51 | 54 | |
52 | 55 | cm.Bind(commandRead, this.btnRead); |
53 | - | |
54 | - DataContextHelper.Bind(txtHorseList, "Text", vm, "HorseList"); | |
55 | 56 | } |
56 | 57 | } |
57 | 58 | } |
@@ -0,0 +1,15 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Threading.Tasks; | |
6 | +using System.Windows.Forms; | |
7 | +using UmaTest.Infra.Presentation.View; | |
8 | + | |
9 | +namespace UmaTest.Infra.Gateway.UI | |
10 | +{ | |
11 | + public interface IStatusBarProxy | |
12 | + { | |
13 | + void SetStatusText(string text); | |
14 | + } | |
15 | +} |
@@ -23,16 +23,5 @@ namespace UmaTest.Infra.Gateway.UI | ||
23 | 23 | |
24 | 24 | return dlg.ShowChildDialog(); |
25 | 25 | } |
26 | - | |
27 | - //public void Show(TViewModel context) | |
28 | - //{ | |
29 | - // var dlg = new TWindow() | |
30 | - // { | |
31 | - // Owner = this.Owner, | |
32 | - // DataContext = context, | |
33 | - // }; | |
34 | - | |
35 | - // dlg.Show(); | |
36 | - //} | |
37 | 26 | } |
38 | 27 | } |
@@ -0,0 +1,26 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Threading.Tasks; | |
6 | +using System.Windows.Forms; | |
7 | +using UmaTest.Infra.Adaptor.ViewModel; | |
8 | +using UmaTest.Infra.Presentation.View; | |
9 | + | |
10 | +namespace UmaTest.Infra.Gateway.UI | |
11 | +{ | |
12 | + public class StatusBarProxy : IStatusBarProxy | |
13 | + { | |
14 | + IStatusBarViewModel vm; | |
15 | + | |
16 | + public StatusBarProxy(IStatusBarViewModel vm) | |
17 | + { | |
18 | + this.vm = vm; | |
19 | + } | |
20 | + | |
21 | + public void SetStatusText(string text) | |
22 | + { | |
23 | + this.vm.StatusText = text; | |
24 | + } | |
25 | + } | |
26 | +} |
@@ -0,0 +1,14 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.ComponentModel; | |
4 | +using System.Linq; | |
5 | +using System.Text; | |
6 | +using System.Threading.Tasks; | |
7 | + | |
8 | +namespace UmaTest.Infra.Adaptor.ViewModel | |
9 | +{ | |
10 | + public interface IStatusBarViewModel : INotifyPropertyChanged | |
11 | + { | |
12 | + string StatusText { get; set; } | |
13 | + } | |
14 | +} |
@@ -2,6 +2,7 @@ | ||
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.ComponentModel; |
4 | 4 | using System.Linq.Expressions; |
5 | +using UmaTest.Infra.Log; | |
5 | 6 | |
6 | 7 | namespace UmaTest.App.Adaptor.Gateway.ViewModel |
7 | 8 | { |
@@ -37,6 +38,7 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel | ||
37 | 38 | |
38 | 39 | // 下準備が出来たので、イベント発行!! |
39 | 40 | _this(sender, new PropertyChangedEventArgs(memberEx.Member.Name)); |
41 | + Logger.Debug($"PropertyChangedEvent raised: sender - {sender}, propertyName - {memberEx.Member.Name}"); | |
40 | 42 | } |
41 | 43 | |
42 | 44 | /// <summary> |
@@ -0,0 +1,28 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.ComponentModel; | |
4 | +using System.Linq; | |
5 | +using System.Text; | |
6 | +using System.Threading.Tasks; | |
7 | +using UmaTest.Infra.Adaptor.ViewModel; | |
8 | +using UmaTest.Infra.Log; | |
9 | + | |
10 | +namespace UmaTest.App.Adaptor.Gateway.ViewModel | |
11 | +{ | |
12 | + public class StatusBarViewModel : IStatusBarViewModel | |
13 | + { | |
14 | + public event PropertyChangedEventHandler PropertyChanged; | |
15 | + | |
16 | + private string _statusText = AppConst.STATUS_BAR_READY; | |
17 | + public string StatusText | |
18 | + { | |
19 | + get => _statusText; | |
20 | + set | |
21 | + { | |
22 | + string old = _statusText; | |
23 | + bool raised = PropertyChanged.RaiseIfSet(() => StatusText, ref _statusText, value); | |
24 | + Logger.Debug($"StatusText: old: {old}, new: {value}, raised: {raised}"); | |
25 | + } | |
26 | + } | |
27 | + } | |
28 | +} |
@@ -13,9 +13,9 @@ namespace UmaTest.Infra.Helper | ||
13 | 13 | return task.Result; |
14 | 14 | } |
15 | 15 | |
16 | - public static Task<TResult> RunWithContinuation<TResult>(Task<TResult> task, Action<Task<TResult>> action) | |
16 | + public static Task<TResult> RunWithUIAction<TResult>(Task<TResult> task, Action<Task<TResult>> uiAction) | |
17 | 17 | { |
18 | - task.ContinueWith(action, TaskScheduler.FromCurrentSynchronizationContext()); | |
18 | + task.ContinueWith(uiAction, TaskScheduler.FromCurrentSynchronizationContext()); | |
19 | 19 | |
20 | 20 | return task; |
21 | 21 | } |
@@ -1,9 +1,11 @@ | ||
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | +using System.ComponentModel; | |
3 | 4 | using System.Linq; |
4 | 5 | using System.Text; |
5 | 6 | using System.Threading.Tasks; |
6 | 7 | using System.Windows.Forms; |
8 | +using UmaTest.Infra.Log; | |
7 | 9 | |
8 | 10 | namespace UmaTest.Infra.Presentation.View |
9 | 11 | { |
@@ -13,5 +15,43 @@ namespace UmaTest.Infra.Presentation.View | ||
13 | 15 | { |
14 | 16 | control.DataBindings.Add(propertyName, dataSource, dataMember); |
15 | 17 | } |
18 | + | |
19 | + public static void Bind(ToolStripItem control, string propertyName, object dataSource, string dataMember) | |
20 | + { | |
21 | + //control.DataBindings.Add(propertyName, dataSource, dataMember); | |
22 | + } | |
23 | + | |
24 | + public static void BindText(Control control, object dataSource, string dataMember) | |
25 | + { | |
26 | + Bind(control, "Text", dataSource, dataMember); | |
27 | + } | |
28 | + | |
29 | + public static void BindText(ToolStripItem control, object dataSource, string dataMember) | |
30 | + { | |
31 | + control.Text = ExtractPropertyText(dataSource, dataMember); | |
32 | + | |
33 | + if (dataSource is INotifyPropertyChanged notify) | |
34 | + { | |
35 | + Logger.Debug($"BindText: sender - {dataSource} is INotifyPropertyChanged"); | |
36 | + | |
37 | + notify.PropertyChanged += (o, e) => | |
38 | + { | |
39 | + Logger.Debug($"BindText.PropertyChangedEventHandler: sender - {o}, propertyName - {e.PropertyName}"); | |
40 | + if (e.PropertyName == dataMember) | |
41 | + { | |
42 | + control.Text = ExtractPropertyText(o, dataMember); | |
43 | + } | |
44 | + }; | |
45 | + } | |
46 | + } | |
47 | + | |
48 | + private static string ExtractPropertyText(object dataSource, string dataMember) | |
49 | + { | |
50 | + string text = dataSource.GetType().GetProperty(dataMember)?.GetValue(dataSource) as string; | |
51 | + | |
52 | + Logger.Debug($"dataSource: {dataSource}, dataMember: {dataMember}, text: {text}"); | |
53 | + | |
54 | + return text; | |
55 | + } | |
16 | 56 | } |
17 | 57 | } |
@@ -116,7 +116,11 @@ | ||
116 | 116 | <Compile Include="App\Domain\Model\Logic\IUmaLogic.cs" /> |
117 | 117 | <Compile Include="App\Domain\Model\Logic\IUmaRaceLogic.cs" /> |
118 | 118 | <Compile Include="App\Domain\UseCase\Response\AsyncLoadHorseRaceSummaryResponse.cs" /> |
119 | + <Compile Include="Infra\Adaptor\Gateway\UI\IStatusBarProxy.cs" /> | |
120 | + <Compile Include="Infra\Adaptor\Gateway\UI\StatusBarProxy.cs" /> | |
119 | 121 | <Compile Include="Infra\Adaptor\Presenter\IAsyncPresenter.cs" /> |
122 | + <Compile Include="Infra\Adaptor\ViewModel\StatusBarViewModel .cs" /> | |
123 | + <Compile Include="Infra\Adaptor\ViewModel\IStatusBarViewModel.cs" /> | |
120 | 124 | <Compile Include="Infra\Helper\TaskHelper.cs" /> |
121 | 125 | <Compile Include="App\Domain\UseCase\Interactor\IAsyncLoadHorseRaceSummaryInteractor.cs" /> |
122 | 126 | <Compile Include="App\Domain\UseCase\Interactor\AsyncLoadHorseRaceSummaryInteractor.cs" /> |