EveryDB2のデータベースを読み込んでWinFormでGUI表示するサンプル
修订版 | 44c0c71583d2c32f739d266020fd99d0354e45bc (tree) |
---|---|
时间 | 2021-06-07 02:27:27 |
作者 | yoshy <yoshy@user...> |
Commiter | yoshy |
temp_20210607_0227
@@ -18,6 +18,7 @@ using UmaTest.App.Domain.Model.Repository.Database.Entity.EveryDB2; | ||
18 | 18 | using UmaTest.Infra.Adaptor.Command; |
19 | 19 | using UmaTest.Infra.Adaptor.ViewModel; |
20 | 20 | using UmaTest.Infra.Domain.Translator; |
21 | +using UmaTest.Infra.Helper; | |
21 | 22 | using UmaTest.Infra.Presentation.View; |
22 | 23 | |
23 | 24 | namespace UmaTest.App.Presentation.View |
@@ -202,8 +203,8 @@ namespace UmaTest.App.Presentation.View | ||
202 | 203 | }, |
203 | 204 | new DataGridViewTextBoxColumn |
204 | 205 | { |
205 | - DataPropertyName = "Zenso.GradeName", | |
206 | - Name = "前走G", | |
206 | + DataPropertyName = "Zenso.JyoName", | |
207 | + Name = "前走場所", | |
207 | 208 | }, |
208 | 209 | new DataGridViewTextBoxColumn |
209 | 210 | { |
@@ -212,6 +213,11 @@ namespace UmaTest.App.Presentation.View | ||
212 | 213 | }, |
213 | 214 | new DataGridViewTextBoxColumn |
214 | 215 | { |
216 | + DataPropertyName = "Zenso.GradeName", | |
217 | + Name = "前走G", | |
218 | + }, | |
219 | + new DataGridViewTextBoxColumn | |
220 | + { | |
215 | 221 | DataPropertyName = "Zenso.RaceName", |
216 | 222 | Name = "前走レース名", |
217 | 223 | }, |
@@ -287,8 +293,8 @@ namespace UmaTest.App.Presentation.View | ||
287 | 293 | }, |
288 | 294 | new DataGridViewTextBoxColumn |
289 | 295 | { |
290 | - DataPropertyName = "NisoMae.GradeName", | |
291 | - Name = "前々走G", | |
296 | + DataPropertyName = "NisoMae.JyoName", | |
297 | + Name = "前々走場所", | |
292 | 298 | }, |
293 | 299 | new DataGridViewTextBoxColumn |
294 | 300 | { |
@@ -297,6 +303,11 @@ namespace UmaTest.App.Presentation.View | ||
297 | 303 | }, |
298 | 304 | new DataGridViewTextBoxColumn |
299 | 305 | { |
306 | + DataPropertyName = "NisoMae.GradeName", | |
307 | + Name = "前々走G", | |
308 | + }, | |
309 | + new DataGridViewTextBoxColumn | |
310 | + { | |
300 | 311 | DataPropertyName = "NisoMae.RaceName", |
301 | 312 | Name = "前々走レース名", |
302 | 313 | }, |
@@ -546,13 +557,13 @@ namespace UmaTest.App.Presentation.View | ||
546 | 557 | }, |
547 | 558 | new DataGridViewTextBoxColumn |
548 | 559 | { |
549 | - DataPropertyName = "GradeName", | |
550 | - Name = "G", | |
560 | + DataPropertyName = "CourseName", | |
561 | + Name = "コース", | |
551 | 562 | }, |
552 | 563 | new DataGridViewTextBoxColumn |
553 | 564 | { |
554 | - DataPropertyName = "CourseName", | |
555 | - Name = "コース", | |
565 | + DataPropertyName = "GradeName", | |
566 | + Name = "G", | |
556 | 567 | }, |
557 | 568 | new DataGridViewTextBoxColumn |
558 | 569 | { |
@@ -841,9 +852,13 @@ namespace UmaTest.App.Presentation.View | ||
841 | 852 | { |
842 | 853 | foreach (DataGridViewRow row in dataGridView1.Rows) |
843 | 854 | { |
855 | + UmaSummaryRowDto rowDto = row.DataBoundItem as UmaSummaryRowDto; | |
856 | + | |
857 | + DataGridViewCell cellJyuni = row.Cells["着順"]; | |
844 | 858 | DataGridViewCell cellNinki = row.Cells["人気"]; |
845 | 859 | |
846 | 860 | ColorizeNinki(cellNinki); |
861 | + ColorizeJyuni(cellJyuni, cellNinki); | |
847 | 862 | |
848 | 863 | DataGridViewCell cellKankaku = row.Cells["間隔"]; |
849 | 864 |
@@ -853,6 +868,18 @@ namespace UmaTest.App.Presentation.View | ||
853 | 868 | |
854 | 869 | ColorizeKankaku(cellZensoKankaku); |
855 | 870 | |
871 | + DataGridViewCell cellZensoGrade = row.Cells["前走G"]; | |
872 | + DataGridViewCell cellZensoBasyo = row.Cells["前走場所"]; | |
873 | + DataGridViewCell cellZensoCourse = row.Cells["前走コース"]; | |
874 | + | |
875 | + ColorizeGradeBasyoCourse(rowDto.Zenso?.Race, cellZensoGrade, cellZensoBasyo, cellZensoCourse); | |
876 | + | |
877 | + DataGridViewCell cellNisoMaeGrade = row.Cells["前々走G"]; | |
878 | + DataGridViewCell cellNisoMaeBasyo = row.Cells["前々走場所"]; | |
879 | + DataGridViewCell cellNisoMaeCourse = row.Cells["前々走コース"]; | |
880 | + | |
881 | + ColorizeGradeBasyoCourse(rowDto.NisoMae?.Race, cellNisoMaeGrade, cellNisoMaeBasyo, cellNisoMaeCourse); | |
882 | + | |
856 | 883 | DataGridViewCell cellZensoJyuni = row.Cells["前走着順"]; |
857 | 884 | DataGridViewCell cellZensoNinki = row.Cells["前走人気"]; |
858 | 885 |
@@ -891,23 +918,20 @@ namespace UmaTest.App.Presentation.View | ||
891 | 918 | } |
892 | 919 | } |
893 | 920 | |
894 | - private static void ChangeCellBackColor(DataGridViewCell cell, Color backColor) | |
895 | - { | |
896 | - cell.Style.BackColor = backColor; | |
897 | - cell.Style.SelectionBackColor = backColor; | |
898 | - cell.Style.SelectionForeColor = SystemColors.WindowText; | |
899 | - } | |
900 | - | |
901 | 921 | private void ColorizeUmaRaceListView() |
902 | 922 | { |
903 | 923 | foreach (DataGridViewRow row in dataGridView2.Rows) |
904 | 924 | { |
905 | - DataGridViewCell cellNinki = row.Cells["人気"]; | |
925 | + DataGridViewCell cellGrade = row.Cells["G"]; | |
926 | + DataGridViewCell cellBasyo = row.Cells["場所"]; | |
927 | + DataGridViewCell cellCourse = row.Cells["コース"]; | |
906 | 928 | |
907 | - ColorizeNinki(cellNinki); | |
929 | + ColorizeGradeBasyoCourse(row, cellGrade, cellBasyo, cellCourse); | |
908 | 930 | |
931 | + DataGridViewCell cellNinki = row.Cells["人気"]; | |
909 | 932 | DataGridViewCell cellJyuni = row.Cells["着順"]; |
910 | 933 | |
934 | + ColorizeNinki(cellNinki); | |
911 | 935 | ColorizeJyuni(cellJyuni, cellNinki); |
912 | 936 | |
913 | 937 | DataGridViewCell cellPCI = row.Cells["ペース変化指数"]; |
@@ -924,9 +948,182 @@ namespace UmaTest.App.Presentation.View | ||
924 | 948 | } |
925 | 949 | } |
926 | 950 | |
951 | + private void ColorizeGradeBasyoCourse(DataGridViewRow row, DataGridViewCell cellGrade, DataGridViewCell cellBasyo, DataGridViewCell cellCourse) | |
952 | + { | |
953 | + NRace race = null; | |
954 | + | |
955 | + if (row.DataBoundItem.GetType() == typeof(UmaRaceRowDto)) | |
956 | + { | |
957 | + UmaRaceRowDto rowDto = row.DataBoundItem as UmaRaceRowDto; | |
958 | + race = rowDto.Race; | |
959 | + } | |
960 | + | |
961 | + if (race == null) | |
962 | + { | |
963 | + return; | |
964 | + } | |
965 | + | |
966 | + ColorizeGradeBasyoCourse(race, cellGrade, cellBasyo, cellCourse); | |
967 | + } | |
968 | + | |
969 | + private void ColorizeGradeBasyoCourse(NRace race, DataGridViewCell cellGrade, DataGridViewCell cellBasyo, DataGridViewCell cellCourse) | |
970 | + { | |
971 | + if ( (race == null) || (cellGrade?.Value == null) || (cellBasyo?.Value == null) || (cellCourse?.Value == null) ) | |
972 | + { | |
973 | + return; | |
974 | + } | |
975 | + | |
976 | + if (!int.TryParse(raceInfo?.Kyori, out int raceKyori)) | |
977 | + { | |
978 | + return; | |
979 | + } | |
980 | + | |
981 | + if (!int.TryParse(race?.Kyori, out int rowKyori)) | |
982 | + { | |
983 | + return; | |
984 | + } | |
985 | + | |
986 | + string raceTurfDirt = CodeHelper.GetInstance().GetTurfDurtName(raceInfo?.Trackcd, string.Empty); | |
987 | + string rowTurfDirt = CodeHelper.GetInstance().GetTurfDurtName(race.Trackcd, string.Empty); | |
988 | + | |
989 | + bool isRowNearKyori = Math.Abs(raceKyori - rowKyori) <= 200; | |
990 | + bool isRowEqualKyori = raceKyori == rowKyori; | |
991 | + bool isRowEqualTrackCd = raceInfo?.Trackcd == race.Trackcd; | |
992 | + bool isRowEqualJyoCd = raceInfo?.Jyocd == race.Jyocd; | |
993 | + bool isRowEqualTurfDirt = raceTurfDirt == rowTurfDirt; | |
994 | + bool isRowEqualGrade = raceInfo?.GradeName == CodeHelper.GetInstance().GetGradeName(race, string.Empty); | |
995 | + | |
996 | + bool isNearCourse = isRowEqualTurfDirt && isRowNearKyori; | |
997 | + bool isEqualCourse = isNearCourse && isRowEqualKyori && isRowEqualTrackCd; | |
998 | + | |
999 | + bool isNearBasyoCourse = isNearCourse && isRowEqualJyoCd; | |
1000 | + bool isEqualBasyoCourse = isNearBasyoCourse && isEqualCourse; | |
1001 | + | |
1002 | + bool isNearGrade = isNearCourse && isRowEqualGrade; | |
1003 | + bool isEqualGrade = isNearGrade && isEqualBasyoCourse; | |
1004 | + | |
1005 | + Color colorGrade = isNearGrade | |
1006 | + ? isEqualGrade | |
1007 | + ? Color.Yellow | |
1008 | + : Color.Cyan | |
1009 | + : Color.Transparent; | |
1010 | + | |
1011 | + Color colorBasyo = isNearBasyoCourse | |
1012 | + ? isEqualBasyoCourse | |
1013 | + ? Color.Yellow | |
1014 | + : Color.Cyan | |
1015 | + : Color.Transparent; | |
1016 | + | |
1017 | + Color colorCourse = isNearCourse | |
1018 | + ? isEqualCourse | |
1019 | + ? Color.Yellow | |
1020 | + : Color.Cyan | |
1021 | + : Color.Transparent; | |
1022 | + | |
1023 | + if (colorGrade != Color.Transparent) | |
1024 | + { | |
1025 | + ChangeCellBackColor(cellGrade, colorGrade); | |
1026 | + } | |
1027 | + | |
1028 | + if (colorBasyo != Color.Transparent) | |
1029 | + { | |
1030 | + ChangeCellBackColor(cellBasyo, colorBasyo); | |
1031 | + } | |
1032 | + | |
1033 | + if (colorCourse != Color.Transparent) | |
1034 | + { | |
1035 | + ChangeCellBackColor(cellCourse, colorCourse); | |
1036 | + } | |
1037 | + } | |
1038 | + | |
1039 | + private static void ColorizeKankaku(DataGridViewCell cellKankaku) | |
1040 | + { | |
1041 | + if (cellKankaku?.Value == null) | |
1042 | + { | |
1043 | + return; | |
1044 | + } | |
1045 | + | |
1046 | + if (int.TryParse(cellKankaku.Value.ToString(), out int kankaku)) | |
1047 | + { | |
1048 | + if (kankaku >= 30) | |
1049 | + { | |
1050 | + ChangeCellBackColor(cellKankaku, Color.Orange); | |
1051 | + } | |
1052 | + else if (kankaku >= 10) | |
1053 | + { | |
1054 | + ChangeCellBackColor(cellKankaku, Color.Yellow); | |
1055 | + } | |
1056 | + } | |
1057 | + } | |
1058 | + | |
1059 | + private static void ColorizeNinki(DataGridViewCell cellNinki) | |
1060 | + { | |
1061 | + if (cellNinki?.Value == null) | |
1062 | + { | |
1063 | + return; | |
1064 | + } | |
1065 | + | |
1066 | + if (int.TryParse(cellNinki.Value.ToString(), out int ninki)) | |
1067 | + { | |
1068 | + switch (ninki) | |
1069 | + { | |
1070 | + case 1: | |
1071 | + ChangeCellBackColor(cellNinki, Color.Yellow); | |
1072 | + break; | |
1073 | + case 2: | |
1074 | + ChangeCellBackColor(cellNinki, Color.Cyan); | |
1075 | + break; | |
1076 | + case 3: | |
1077 | + ChangeCellBackColor(cellNinki, Color.LightGreen); | |
1078 | + break; | |
1079 | + default: | |
1080 | + break; | |
1081 | + } | |
1082 | + } | |
1083 | + } | |
1084 | + | |
1085 | + private static void ColorizeJyuni(DataGridViewCell cellJyuni, DataGridViewCell cellNinki) | |
1086 | + { | |
1087 | + if ((cellJyuni?.Value == null) || (cellNinki?.Value == null)) | |
1088 | + { | |
1089 | + return; | |
1090 | + } | |
1091 | + | |
1092 | + if (int.TryParse(cellJyuni.Value.ToString(), out int jyuni) | |
1093 | + && int.TryParse(cellNinki.Value.ToString(), out int ninki)) | |
1094 | + { | |
1095 | + switch (jyuni) | |
1096 | + { | |
1097 | + case 1: | |
1098 | + ChangeCellBackColor(cellJyuni, Color.Yellow); | |
1099 | + break; | |
1100 | + case 2: | |
1101 | + ChangeCellBackColor(cellJyuni, Color.Cyan); | |
1102 | + break; | |
1103 | + case 3: | |
1104 | + ChangeCellBackColor(cellJyuni, Color.LightGreen); | |
1105 | + break; | |
1106 | + default: | |
1107 | + if ( (ninki >= 6) && (jyuni <= 6) && (ninki - jyuni > 1) ) | |
1108 | + { | |
1109 | + ChangeCellBackColor(cellJyuni, Color.LightSkyBlue); | |
1110 | + } | |
1111 | + else if ((ninki <= 3) && (jyuni > 3)) | |
1112 | + { | |
1113 | + ChangeCellBackColor(cellJyuni, Color.Orange); | |
1114 | + } | |
1115 | + else if (ninki - jyuni < -2) | |
1116 | + { | |
1117 | + ChangeCellBackColor(cellJyuni, Color.Orange); | |
1118 | + } | |
1119 | + break; | |
1120 | + } | |
1121 | + } | |
1122 | + } | |
1123 | + | |
927 | 1124 | private void ColorizePCI(DataGridViewCell cellPCI, DataGridViewCell cellJyuni) |
928 | 1125 | { |
929 | - if ( (cellPCI?.Value == null) || (cellJyuni?.Value == null) ) | |
1126 | + if ((cellPCI?.Value == null) || (cellJyuni?.Value == null)) | |
930 | 1127 | { |
931 | 1128 | return; |
932 | 1129 | } |
@@ -1099,89 +1296,11 @@ namespace UmaTest.App.Presentation.View | ||
1099 | 1296 | } |
1100 | 1297 | } |
1101 | 1298 | |
1102 | - private static void ColorizeKankaku(DataGridViewCell cellKankaku) | |
1103 | - { | |
1104 | - if (cellKankaku?.Value == null) | |
1105 | - { | |
1106 | - return; | |
1107 | - } | |
1108 | - | |
1109 | - if (int.TryParse(cellKankaku.Value.ToString(), out int kankaku)) | |
1110 | - { | |
1111 | - if (kankaku >= 30) | |
1112 | - { | |
1113 | - ChangeCellBackColor(cellKankaku, Color.Orange); | |
1114 | - } | |
1115 | - else if (kankaku >= 10) | |
1116 | - { | |
1117 | - ChangeCellBackColor(cellKankaku, Color.Yellow); | |
1118 | - } | |
1119 | - } | |
1120 | - } | |
1121 | - | |
1122 | - private static void ColorizeNinki(DataGridViewCell cellNinki) | |
1123 | - { | |
1124 | - if (cellNinki?.Value == null) | |
1125 | - { | |
1126 | - return; | |
1127 | - } | |
1128 | - | |
1129 | - if (int.TryParse(cellNinki.Value.ToString(), out int ninki)) | |
1130 | - { | |
1131 | - switch (ninki) | |
1132 | - { | |
1133 | - case 1: | |
1134 | - ChangeCellBackColor(cellNinki, Color.Yellow); | |
1135 | - break; | |
1136 | - case 2: | |
1137 | - ChangeCellBackColor(cellNinki, Color.Cyan); | |
1138 | - break; | |
1139 | - case 3: | |
1140 | - ChangeCellBackColor(cellNinki, Color.LightGreen); | |
1141 | - break; | |
1142 | - default: | |
1143 | - break; | |
1144 | - } | |
1145 | - } | |
1146 | - } | |
1147 | - | |
1148 | - private static void ColorizeJyuni(DataGridViewCell cellJyuni, DataGridViewCell cellNinki) | |
1299 | + private static void ChangeCellBackColor(DataGridViewCell cell, Color backColor) | |
1149 | 1300 | { |
1150 | - if ((cellJyuni?.Value == null) || (cellNinki?.Value == null)) | |
1151 | - { | |
1152 | - return; | |
1153 | - } | |
1154 | - | |
1155 | - if (int.TryParse(cellJyuni.Value.ToString(), out int jyuni) | |
1156 | - && int.TryParse(cellNinki.Value.ToString(), out int ninki)) | |
1157 | - { | |
1158 | - switch (jyuni) | |
1159 | - { | |
1160 | - case 1: | |
1161 | - ChangeCellBackColor(cellJyuni, Color.Yellow); | |
1162 | - break; | |
1163 | - case 2: | |
1164 | - ChangeCellBackColor(cellJyuni, Color.Cyan); | |
1165 | - break; | |
1166 | - case 3: | |
1167 | - ChangeCellBackColor(cellJyuni, Color.LightGreen); | |
1168 | - break; | |
1169 | - default: | |
1170 | - if ( (ninki >= 6) && (jyuni <= 6) && (ninki - jyuni > 1) ) | |
1171 | - { | |
1172 | - ChangeCellBackColor(cellJyuni, Color.LightSkyBlue); | |
1173 | - } | |
1174 | - else if ((ninki <= 3) && (jyuni > 3)) | |
1175 | - { | |
1176 | - ChangeCellBackColor(cellJyuni, Color.Orange); | |
1177 | - } | |
1178 | - else if (ninki - jyuni < -2) | |
1179 | - { | |
1180 | - ChangeCellBackColor(cellJyuni, Color.Orange); | |
1181 | - } | |
1182 | - break; | |
1183 | - } | |
1184 | - } | |
1301 | + cell.Style.BackColor = backColor; | |
1302 | + cell.Style.SelectionBackColor = backColor; | |
1303 | + cell.Style.SelectionForeColor = SystemColors.WindowText; | |
1185 | 1304 | } |
1186 | 1305 | |
1187 | 1306 | private void MainWindow_ResizeBegin(object sender, EventArgs e) |