EveryDB2のデータベースを読み込んでWinFormでGUI表示するサンプル
修订版 | 102b844a30e32230194d991c15cf18adbb0340f2 (tree) |
---|---|
时间 | 2021-06-08 08:02:38 |
作者 | yoshy <yoshy@user...> |
Commiter | yoshy |
temp_20210608_0802
@@ -1,5 +1,6 @@ | ||
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | +using System.Drawing; | |
3 | 4 | using System.Linq; |
4 | 5 | using System.Text; |
5 | 6 | using System.Threading.Tasks; |
@@ -20,5 +21,52 @@ namespace UmaTest.App | ||
20 | 21 | internal static readonly string CAPTION_CONFIRM = "確認"; |
21 | 22 | |
22 | 23 | internal static readonly string STATUS_BAR_READY = "Ready."; |
24 | + | |
25 | + internal static readonly Color COLOR_SAFE_RED = Color.FromArgb(255, 75, 0); | |
26 | + internal static readonly Color COLOR_SAFE_YELLOW = Color.FromArgb(255, 241, 0); | |
27 | + internal static readonly Color COLOR_SAFE_GREEN = Color.FromArgb(3, 175, 122); | |
28 | + internal static readonly Color COLOR_SAFE_BLUE = Color.FromArgb(0, 90, 255); | |
29 | + internal static readonly Color COLOR_SAFE_CYAN = Color.FromArgb(77, 196, 255); | |
30 | + internal static readonly Color COLOR_SAFE_PINK = Color.FromArgb(255, 128, 130); | |
31 | + internal static readonly Color COLOR_SAFE_ORANGE = Color.FromArgb(246, 170, 0); | |
32 | + internal static readonly Color COLOR_SAFE_MAGENTA = Color.FromArgb(153, 0, 153); | |
33 | + internal static readonly Color COLOR_SAFE_SIENNA = Color.FromArgb(128, 64, 0); | |
34 | + | |
35 | + internal static readonly Color COLOR_SAFE_BASE_LIGHT_PINK = Color.FromArgb(255, 202, 191); | |
36 | + internal static readonly Color COLOR_SAFE_BASE_CREAM = Color.FromArgb(255, 255, 128); | |
37 | + internal static readonly Color COLOR_SAFE_BASE_LIGHT_YELLOW_GREEN = Color.FromArgb(216, 242, 85); | |
38 | + internal static readonly Color COLOR_SAFE_BASE_LIGHT_SKY_BLUE = Color.FromArgb(191, 228, 255); | |
39 | + internal static readonly Color COLOR_SAFE_BASE_BEIGE = Color.FromArgb(255, 202, 128); | |
40 | + internal static readonly Color COLOR_SAFE_BASE_LIGHT_GREEN = Color.FromArgb(119, 217, 168); | |
41 | + internal static readonly Color COLOR_SAFE_BASE_LIGHT_MAGENTA = Color.FromArgb(201, 172, 230); | |
42 | + | |
43 | + internal static readonly Color COLOR_SAFE_LIGHT_GRAY = Color.FromArgb(200, 200, 203); | |
44 | + internal static readonly Color COLOR_SAFE_GRAY = Color.FromArgb(132, 145, 158); | |
45 | + | |
46 | + | |
47 | + internal static readonly Color COLOR_BACK_FIRST = COLOR_SAFE_YELLOW; | |
48 | + internal static readonly Color COLOR_BACK_SECOND = COLOR_SAFE_CYAN; | |
49 | + internal static readonly Color COLOR_BACK_THIRD = COLOR_SAFE_GREEN; | |
50 | + internal static readonly Color COLOR_BACK_GOOD = COLOR_SAFE_BLUE; | |
51 | + internal static readonly Color COLOR_BACK_WARNING = COLOR_SAFE_ORANGE; | |
52 | + internal static readonly Color COLOR_BACK_IGNORE_WARNING = COLOR_SAFE_SIENNA; | |
53 | + internal static readonly Color COLOR_BACK_IGNORE = COLOR_SAFE_GRAY; | |
54 | + | |
55 | + internal static readonly Color COLOR_FORE_FIRST = Color.Black; | |
56 | + internal static readonly Color COLOR_FORE_SECOND = Color.Black; | |
57 | + internal static readonly Color COLOR_FORE_THIRD = Color.Black; | |
58 | + internal static readonly Color COLOR_FORE_GOOD = Color.White; | |
59 | + internal static readonly Color COLOR_FORE_WARNING = Color.Black; | |
60 | + internal static readonly Color COLOR_FORE_IGNORE_WARNING = Color.White; | |
61 | + internal static readonly Color COLOR_FORE_IGNORE = Color.Black; | |
62 | + | |
63 | + internal static readonly (Color, Color) COLOR_FIRST = (COLOR_BACK_FIRST, COLOR_FORE_FIRST); | |
64 | + internal static readonly (Color, Color) COLOR_SECOND = (COLOR_BACK_SECOND, COLOR_FORE_SECOND); | |
65 | + internal static readonly (Color, Color) COLOR_THIRD = (COLOR_BACK_THIRD, COLOR_FORE_THIRD); | |
66 | + internal static readonly (Color, Color) COLOR_GOOD = (COLOR_BACK_GOOD, COLOR_FORE_GOOD); | |
67 | + internal static readonly (Color, Color) COLOR_WARNING = (COLOR_BACK_WARNING, COLOR_FORE_WARNING); | |
68 | + internal static readonly (Color, Color) COLOR_IGNORE_WARNING = (COLOR_BACK_IGNORE_WARNING, COLOR_FORE_IGNORE_WARNING); | |
69 | + internal static readonly (Color, Color) COLOR_IGNORE = (COLOR_BACK_IGNORE, COLOR_FORE_IGNORE); | |
70 | + internal static readonly (Color, Color) COLOR_NONE = (Color.Transparent, Color.Transparent); | |
23 | 71 | } |
24 | 72 | } |
@@ -1002,35 +1002,35 @@ namespace UmaTest.App.Presentation.View | ||
1002 | 1002 | bool isNearGrade = isNearCourse && isRowEqualGrade; |
1003 | 1003 | bool isEqualGrade = isNearGrade && isEqualBasyoCourse; |
1004 | 1004 | |
1005 | - Color colorGrade = isNearGrade | |
1005 | + (Color, Color) colorGrade = isNearGrade | |
1006 | 1006 | ? isEqualGrade |
1007 | - ? Color.Yellow | |
1008 | - : Color.Cyan | |
1009 | - : Color.Transparent; | |
1007 | + ? AppConst.COLOR_FIRST | |
1008 | + : AppConst.COLOR_SECOND | |
1009 | + : AppConst.COLOR_NONE; | |
1010 | 1010 | |
1011 | - Color colorBasyo = isNearBasyoCourse | |
1011 | + (Color, Color) colorBasyo = isNearBasyoCourse | |
1012 | 1012 | ? isEqualBasyoCourse |
1013 | - ? Color.Yellow | |
1014 | - : Color.Cyan | |
1015 | - : Color.Transparent; | |
1013 | + ? AppConst.COLOR_FIRST | |
1014 | + : AppConst.COLOR_SECOND | |
1015 | + : AppConst.COLOR_NONE; | |
1016 | 1016 | |
1017 | - Color colorCourse = isNearCourse | |
1017 | + (Color, Color) colorCourse = isNearCourse | |
1018 | 1018 | ? isEqualCourse |
1019 | - ? Color.Yellow | |
1020 | - : Color.Cyan | |
1021 | - : Color.Transparent; | |
1019 | + ? AppConst.COLOR_FIRST | |
1020 | + : AppConst.COLOR_SECOND | |
1021 | + : AppConst.COLOR_NONE; | |
1022 | 1022 | |
1023 | - if (colorGrade != Color.Transparent) | |
1023 | + if (colorGrade != AppConst.COLOR_NONE) | |
1024 | 1024 | { |
1025 | 1025 | ChangeCellBackColor(cellGrade, colorGrade); |
1026 | 1026 | } |
1027 | 1027 | |
1028 | - if (colorBasyo != Color.Transparent) | |
1028 | + if (colorBasyo != AppConst.COLOR_NONE) | |
1029 | 1029 | { |
1030 | 1030 | ChangeCellBackColor(cellBasyo, colorBasyo); |
1031 | 1031 | } |
1032 | 1032 | |
1033 | - if (colorCourse != Color.Transparent) | |
1033 | + if (colorCourse != AppConst.COLOR_NONE) | |
1034 | 1034 | { |
1035 | 1035 | ChangeCellBackColor(cellCourse, colorCourse); |
1036 | 1036 | } |
@@ -1047,11 +1047,11 @@ namespace UmaTest.App.Presentation.View | ||
1047 | 1047 | { |
1048 | 1048 | if (kankaku >= 30) |
1049 | 1049 | { |
1050 | - ChangeCellBackColor(cellKankaku, Color.Orange); | |
1050 | + ChangeCellBackColor(cellKankaku, AppConst.COLOR_WARNING); | |
1051 | 1051 | } |
1052 | 1052 | else if (kankaku >= 10) |
1053 | 1053 | { |
1054 | - ChangeCellBackColor(cellKankaku, Color.Yellow); | |
1054 | + ChangeCellBackColor(cellKankaku, AppConst.COLOR_FIRST); | |
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | } |
@@ -1068,13 +1068,13 @@ namespace UmaTest.App.Presentation.View | ||
1068 | 1068 | switch (ninki) |
1069 | 1069 | { |
1070 | 1070 | case 1: |
1071 | - ChangeCellBackColor(cellNinki, Color.Yellow); | |
1071 | + ChangeCellBackColor(cellNinki, AppConst.COLOR_FIRST); | |
1072 | 1072 | break; |
1073 | 1073 | case 2: |
1074 | - ChangeCellBackColor(cellNinki, Color.Cyan); | |
1074 | + ChangeCellBackColor(cellNinki, AppConst.COLOR_SECOND); | |
1075 | 1075 | break; |
1076 | 1076 | case 3: |
1077 | - ChangeCellBackColor(cellNinki, Color.LightGreen); | |
1077 | + ChangeCellBackColor(cellNinki, AppConst.COLOR_THIRD); | |
1078 | 1078 | break; |
1079 | 1079 | default: |
1080 | 1080 | break; |
@@ -1095,26 +1095,26 @@ namespace UmaTest.App.Presentation.View | ||
1095 | 1095 | switch (jyuni) |
1096 | 1096 | { |
1097 | 1097 | case 1: |
1098 | - ChangeCellBackColor(cellJyuni, Color.Yellow); | |
1098 | + ChangeCellBackColor(cellJyuni, AppConst.COLOR_FIRST); | |
1099 | 1099 | break; |
1100 | 1100 | case 2: |
1101 | - ChangeCellBackColor(cellJyuni, Color.Cyan); | |
1101 | + ChangeCellBackColor(cellJyuni, AppConst.COLOR_SECOND); | |
1102 | 1102 | break; |
1103 | 1103 | case 3: |
1104 | - ChangeCellBackColor(cellJyuni, Color.LightGreen); | |
1104 | + ChangeCellBackColor(cellJyuni, AppConst.COLOR_THIRD); | |
1105 | 1105 | break; |
1106 | 1106 | default: |
1107 | 1107 | if ( (ninki >= 6) && (jyuni <= 6) && (ninki - jyuni > 1) ) |
1108 | 1108 | { |
1109 | - ChangeCellBackColor(cellJyuni, Color.LightSkyBlue); | |
1109 | + ChangeCellBackColor(cellJyuni, AppConst.COLOR_GOOD); | |
1110 | 1110 | } |
1111 | 1111 | else if ((ninki <= 3) && (jyuni > 3)) |
1112 | 1112 | { |
1113 | - ChangeCellBackColor(cellJyuni, Color.Orange); | |
1113 | + ChangeCellBackColor(cellJyuni, AppConst.COLOR_WARNING); | |
1114 | 1114 | } |
1115 | 1115 | else if (ninki - jyuni < -2) |
1116 | 1116 | { |
1117 | - ChangeCellBackColor(cellJyuni, Color.Orange); | |
1117 | + ChangeCellBackColor(cellJyuni, AppConst.COLOR_WARNING); | |
1118 | 1118 | } |
1119 | 1119 | break; |
1120 | 1120 | } |
@@ -1137,42 +1137,42 @@ namespace UmaTest.App.Presentation.View | ||
1137 | 1137 | |
1138 | 1138 | if (decimal.TryParse(cellPCI.Value.ToString(), out decimal pci)) |
1139 | 1139 | { |
1140 | - Color backColor = SystemColors.Window; | |
1140 | + (Color, Color) color = AppConst.COLOR_NONE; | |
1141 | 1141 | |
1142 | 1142 | if (pci >= 115) |
1143 | 1143 | { |
1144 | - backColor = Color.Yellow; | |
1144 | + color = AppConst.COLOR_FIRST; | |
1145 | 1145 | } |
1146 | 1146 | else if (pci >= 105) |
1147 | 1147 | { |
1148 | - backColor = Color.Cyan; | |
1148 | + color = AppConst.COLOR_SECOND; | |
1149 | 1149 | } |
1150 | 1150 | else if (pci >= 95) |
1151 | 1151 | { |
1152 | - backColor = Color.LightGreen; | |
1152 | + color = AppConst.COLOR_THIRD; | |
1153 | 1153 | } |
1154 | 1154 | else if (pci >= 85) |
1155 | 1155 | { |
1156 | - backColor = Color.LightSkyBlue; | |
1156 | + color = AppConst.COLOR_GOOD; | |
1157 | 1157 | } |
1158 | 1158 | else if (pci <= 75) |
1159 | 1159 | { |
1160 | - backColor = Color.Orange; | |
1160 | + color = AppConst.COLOR_WARNING; | |
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | if (!isWarningOnly) |
1164 | 1164 | { |
1165 | - ChangeCellBackColor(cellPCI, backColor); | |
1165 | + ChangeCellBackColor(cellPCI, color); | |
1166 | 1166 | } |
1167 | 1167 | else |
1168 | 1168 | { |
1169 | - if (backColor == Color.Orange) | |
1169 | + if (color == AppConst.COLOR_WARNING) | |
1170 | 1170 | { |
1171 | - ChangeCellBackColor(cellPCI, Color.Sienna); | |
1171 | + ChangeCellBackColor(cellPCI, AppConst.COLOR_IGNORE_WARNING); | |
1172 | 1172 | } |
1173 | 1173 | else |
1174 | 1174 | { |
1175 | - ChangeCellBackColor(cellPCI, Color.Silver); | |
1175 | + ChangeCellBackColor(cellPCI, AppConst.COLOR_IGNORE); | |
1176 | 1176 | } |
1177 | 1177 | } |
1178 | 1178 | } |
@@ -1194,46 +1194,46 @@ namespace UmaTest.App.Presentation.View | ||
1194 | 1194 | |
1195 | 1195 | if (decimal.TryParse(cellAvgHaronTimeMinus3.Value.ToString(), out decimal pci)) |
1196 | 1196 | { |
1197 | - Color backColor = SystemColors.Window; | |
1197 | + (Color, Color) color; | |
1198 | 1198 | |
1199 | 1199 | if (pci >= 125) |
1200 | 1200 | { |
1201 | - backColor = Color.Orange; | |
1201 | + color = AppConst.COLOR_WARNING; | |
1202 | 1202 | } |
1203 | 1203 | else if (pci >= 115) |
1204 | 1204 | { |
1205 | - backColor = Color.Yellow; | |
1205 | + color = AppConst.COLOR_FIRST; | |
1206 | 1206 | } |
1207 | 1207 | else if (pci >= 105) |
1208 | 1208 | { |
1209 | - backColor = Color.Cyan; | |
1209 | + color = AppConst.COLOR_SECOND; | |
1210 | 1210 | } |
1211 | 1211 | else if (pci >= 95) |
1212 | 1212 | { |
1213 | - backColor = Color.LightGreen; | |
1213 | + color = AppConst.COLOR_THIRD; | |
1214 | 1214 | } |
1215 | 1215 | else if (pci >= 85) |
1216 | 1216 | { |
1217 | - backColor = Color.LightSkyBlue; | |
1217 | + color = AppConst.COLOR_GOOD; | |
1218 | 1218 | } |
1219 | - else if (pci < 85) | |
1219 | + else | |
1220 | 1220 | { |
1221 | - backColor = Color.Orange; | |
1221 | + color = AppConst.COLOR_WARNING; | |
1222 | 1222 | } |
1223 | 1223 | |
1224 | 1224 | if (!isWarningOnly) |
1225 | 1225 | { |
1226 | - ChangeCellBackColor(cellAvgHaronTimeMinus3, backColor); | |
1226 | + ChangeCellBackColor(cellAvgHaronTimeMinus3, color); | |
1227 | 1227 | } |
1228 | 1228 | else |
1229 | 1229 | { |
1230 | - if (backColor == Color.Orange) | |
1230 | + if (color == AppConst.COLOR_WARNING) | |
1231 | 1231 | { |
1232 | - ChangeCellBackColor(cellAvgHaronTimeMinus3, Color.Sienna); | |
1232 | + ChangeCellBackColor(cellAvgHaronTimeMinus3, AppConst.COLOR_IGNORE_WARNING); | |
1233 | 1233 | } |
1234 | 1234 | else |
1235 | 1235 | { |
1236 | - ChangeCellBackColor(cellAvgHaronTimeMinus3, Color.Silver); | |
1236 | + ChangeCellBackColor(cellAvgHaronTimeMinus3, AppConst.COLOR_IGNORE); | |
1237 | 1237 | } |
1238 | 1238 | } |
1239 | 1239 | } |
@@ -1255,52 +1255,58 @@ namespace UmaTest.App.Presentation.View | ||
1255 | 1255 | |
1256 | 1256 | if (decimal.TryParse(cellHaronTimeL3.Value.ToString(), out decimal pci)) |
1257 | 1257 | { |
1258 | - Color backColor = SystemColors.Window; | |
1258 | + (Color, Color) color; | |
1259 | 1259 | |
1260 | 1260 | if (pci >= 140) |
1261 | 1261 | { |
1262 | - backColor = Color.Yellow; | |
1262 | + color = AppConst.COLOR_FIRST; | |
1263 | 1263 | } |
1264 | 1264 | else if (pci >= 120) |
1265 | 1265 | { |
1266 | - backColor = Color.Cyan; | |
1266 | + color = AppConst.COLOR_SECOND; | |
1267 | 1267 | } |
1268 | 1268 | else if (pci >= 100) |
1269 | 1269 | { |
1270 | - backColor = Color.LightGreen; | |
1270 | + color = AppConst.COLOR_THIRD; | |
1271 | 1271 | } |
1272 | 1272 | else if (pci >= 80) |
1273 | 1273 | { |
1274 | - backColor = Color.LightSkyBlue; | |
1274 | + color = AppConst.COLOR_GOOD; | |
1275 | 1275 | } |
1276 | - else if (pci < 80) | |
1276 | + else | |
1277 | 1277 | { |
1278 | - backColor = Color.Orange; | |
1278 | + color = AppConst.COLOR_WARNING; | |
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | if (!isWarningOnly) |
1282 | 1282 | { |
1283 | - ChangeCellBackColor(cellHaronTimeL3, backColor); | |
1283 | + ChangeCellBackColor(cellHaronTimeL3, color); | |
1284 | 1284 | } |
1285 | 1285 | else |
1286 | 1286 | { |
1287 | - if (backColor == Color.Orange) | |
1287 | + if (color == AppConst.COLOR_WARNING) | |
1288 | 1288 | { |
1289 | - ChangeCellBackColor(cellHaronTimeL3, Color.Sienna); | |
1289 | + ChangeCellBackColor(cellHaronTimeL3, AppConst.COLOR_IGNORE_WARNING); | |
1290 | 1290 | } |
1291 | 1291 | else |
1292 | 1292 | { |
1293 | - ChangeCellBackColor(cellHaronTimeL3, Color.Silver); | |
1293 | + ChangeCellBackColor(cellHaronTimeL3, AppConst.COLOR_IGNORE); | |
1294 | 1294 | } |
1295 | 1295 | } |
1296 | 1296 | } |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - private static void ChangeCellBackColor(DataGridViewCell cell, Color backColor) | |
1299 | + private static void ChangeCellBackColor(DataGridViewCell cell, (Color, Color) color) | |
1300 | 1300 | { |
1301 | - cell.Style.BackColor = backColor; | |
1302 | - cell.Style.SelectionBackColor = backColor; | |
1303 | - cell.Style.SelectionForeColor = SystemColors.WindowText; | |
1301 | + if (color == AppConst.COLOR_NONE) | |
1302 | + { | |
1303 | + return; | |
1304 | + } | |
1305 | + | |
1306 | + cell.Style.BackColor = color.Item1; | |
1307 | + cell.Style.ForeColor = color.Item2; | |
1308 | + cell.Style.SelectionBackColor = color.Item1; | |
1309 | + cell.Style.SelectionForeColor = color.Item2; | |
1304 | 1310 | } |
1305 | 1311 | |
1306 | 1312 | private void MainWindow_ResizeBegin(object sender, EventArgs e) |