|
Создание базы данных
189 End Select1190End Sub11911192Private Sub Enabled3DCheck_Click() 1193 DimImg. Picture = DiagTypeImgs. ListImages(5 + Enabled3DCheck. value). Picture1194End Sub11951196Private Sub Form_Load() 1197 Call ButEnabled(OkImg, OkBut, False) 1198 Call ButEnabled(CancelImg, CancelBut, True) 1199 TopImg. Picture = MainForm. TopImageList. ListImages(1). Picture1200 DiagTypeCombo. ListIndex = 01201 DimImg. Picture = DiagTypeImgs. ListImages(5). Picture1202 1203 TableIndexCombo. Clear1204 SelectColList. Clear1205 For i% = 1 To MainForm. TabStrip. Tabs. Count1206 TableIndexCombo. AddItem MainForm. TabStrip. Tabs(i). Caption1207 Next i1208 TableIndexCombo. ListIndex = 01209End Sub12101211' по строке "{x, YYY} ZZZ" возвращает номер таблицы (x) 1212Sub GetTableIndex(ByVal str As String, TI As Integer) 1213 s$ = Trim$(Mid$(str, 2, InStr(1, str, ",") - 2)) 1214 TI = CInt(s) 1215End Sub12161217' по строке "{x, YYY} ZZZ" и номеру таблицы возвращает номер поля с заголовком ZZZ1218Sub GetColIndex(ByVal str As String, ByVal TI As Integer, CI As Integer) 1219 s$ = Trim$(Mid$(str, InStr(1, str, "}") + 1)) 1220 For i% = 0 To DB(TI). Header. ColCount - 11221 If (s = Trim(DB(TI). Cols(i). title)) Then1222 CI = i1223 Exit Sub1224 End If1225 Next i1226 CI = - 1 ' событие невозможное но вероятное1227End Sub12281229Function GettingDiagData(OnlyOneCol As Boolean) As Boolean1230 GettingDiagData = False12311232 Dim TI As Integer, CI As Integer1233 1234 Select Case OnlyOneCol1235 Case True ' ************************************************************************1236 Call GetTableIndex(SelectColList. List(0), TI) 1237 Call GetColIndex(SelectColList. List(0), TI, CI) 1238 ' зная номер таблицы и номер поля данных нужно проверить тип поля1239 If (DB(TI). Cols(CI). Class <> ccInteger) Then1240 Call MsgForm. ErrorMsg("Нельзя строить диаграмму по нечисленным данным! ") 1241 Exit Function1242 End If1243 ' заполнение массива данных1244 ReDim DiagData(2 * DB(TI). Header. RowCount) 1245 For i% = 0 To DB(TI). Header. RowCount - 11246 DiagData(2 * i) = DB(TI). Rows(i). Fields(CI) 1247 DiagData(2 * i + 1) = DiagData(2 * i) 1248 Next i1249 GettingDiagData = True1250 1251 Case False ' ************************************************************************1252 ReDim DiagData(2 * SelectColList. ListCount) 1253 For R% = 0 To SelectColList. ListCount - 11254 Call GetTableIndex(SelectColList. List(R), TI) 1255 Call GetColIndex(SelectColList. List(R), TI, CI) 1256 ' зная номер таблицы и номер поля данных нужно проверить тип поля1257 If (DB(TI). Cols(CI). Class <> ccInteger) Then1258 Call MsgForm. ErrorMsg("Нельзя строить диаграмму по нечисленным данным! ") 1259 Exit Function1260 End If1261 Dim Summary As Integer1262 Summary = 01263 For i% = 0 To DB(TI). Header. RowCount - 11264 Summary = Summary + DB(TI). Rows(i). Fields(CI) 1265 Next i1266 ' заполнение массива данных1267 DiagData(2 * R) = Summary1268 DiagData(2 * R + 1) = MainForm. TabStrip. Tabs(TI + 1). Caption + ". " + DB(TI). Cols(CI). title1269 Next R1270 GettingDiagData = True1271 End Select1272 1273End Function12741275Private Sub OkBut_Click() 1276 If (OkBut. Tag = 0) Then Exit Sub1277 Call SoundClick1278 1279 If GettingDiagData(SelectColList. ListCount = 1) Then1280 Load DiagResForm1281 Call DiagResForm. InitDiagData(DiagData, DiagTypeCombo. ListIndex, (Enabled3DCheck. value = 1)) 1282 DiagResForm. Show vbModal1283 End If1284End Sub12851286Private Sub CancelBut_Click() 1287 Call SoundClick1288 Unload Me1289End Sub12901291Private Sub TableColList_DblClick() 1292 i% = TableColList. ListIndex1293 s$ = "{ " + CStr(TableIndexCombo. ListIndex) + ", " + TableIndexCombo. Text + " } " + TableColList. List(i) 1294 For j% = 0 To SelectColList. ListCount - 11295 If (SelectColList. List(j) = s) Then Exit Sub1296 Next j1297 Call ButEnabled(OkImg, OkBut, True) 1298 SelectColList. AddItem s1299End Sub13001301Private Sub SelectColList_DblClick() 1302 If (SelectColList. ListIndex > - 1) Then SelectColList. RemoveItem SelectColList. ListIndex1303 Call ButEnabled(OkImg, OkBut, (SelectColList. ListCount > 0)) 1304End Sub13051306Private Sub TableIndexCombo_Click() 1307 DBI% = TableIndexCombo. ListIndex1308 TableColList. Clear1309 For i% = 0 To DB(DBI). Header. ColCount - 11310 TableColList. AddItem DB(DBI). Cols(i). title1311 Next i1312 If (TableColList. ListCount > 0) Then TableColList. ListIndex = 01313End SubФорма: PasswordForm. frm1314Public res As Boolean13151316Private Sub Form_Activate() 1317 res = False1318 If Frame1. Visible Then1319 PassText. SetFocus1320 Else1321 SetPassText. SetFocus1322 End If1323End Sub13241325Private Sub Form_Load() 1326 Call ButEnabled(OkImg, OkBut, True) 1327 Call ButEnabled(CancelImg, CancelBut, True) 1328 TopImg. Picture = MainForm. TopImageList. ListImages(1). Picture1329End Sub13301331Private Sub OkBut_Click() 1332 res = True1333 Call SoundClick1334 Hide1335End Sub13361337Private Sub CancelBut_Click() 1338 Call SoundClick1339 Hide1340End Sub13411342Private Sub PassText_KeyDown(KeyCode As Integer, Shift As Integer) 1343 If (KeyCode = 13) Then Call OkBut_Click1344End Sub13451346Private Sub SetPassText_KeyDown(KeyCode As Integer, Shift As Integer) 1347 If (KeyCode = 13) Then Call OkBut_Click1348End SubФорма: AboutForm. frm1349Private Sub Form_Load() 1350 Call MInit1351 Call ButEnabled(OkImg, OkBut, True) 1352 Label6. Caption = "v. " + CStr(App. Major) + ". " + CStr(App. Minor) + ". " + CStr(App. Revision) 1353End Sub13541355Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) 1356 Call MDown(x, y) 1357End Sub13581359Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) 1360 Call MMove(hwnd, x, y) 1361End Sub13621363Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) 1364 Call MUp1365End Sub13661367Private Sub Image2_Click() 1368 Call ShellExecute(0, "", "mailto: xerx@nightmail. ru", "", "", 1) 1369End Sub13701371Private Sub NoViewLabel_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) 1372 Call MDown(x, y) 1373End Sub13741375Private Sub NoViewLabel_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) 1376 Call MMove(hwnd, x, y) 1377End Sub13781379Private Sub NoViewLabel_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) 1380 Call MUp1381End Sub13821383Private Sub OkBut_Click() 1384 Unload Me1385End SubФорма: DiagResForm. frm1386Dim dW%, dH%, dX%, dH2%1387Dim DiagData() As TDiagElem1388Dim DrawingMode As Byte, Use3D As Boolean13891390' константы для вывода куска более 270 градусов (выводимая часть) 1391Const mode270begin As Byte = 11392Const mode270end As Byte = 213931394' данные для процедур рисования1395 Const Pi_180 As Double = 1.74532925199433E-021396 Const Pi_2 As Double = 1.57079632679491397 Const NearZero As Double = 1E-4513981399 Dim Xc%, Yc% ' центр диаграммы1400 Dim Radius# ' радиус кусков1401 Dim InRad# ' радиус разноса кусков1402 Dim OneGradus# ' единиц в одном градусе1403 Dim ChartHeight% ' высота графика1404 Dim ChartWidth% ' ширина графика1405 Dim ChartTop% ' верх графика1406 Dim ChartDown% ' низ графика1407 Dim ItemCount% ' кол-во элементов1408 Dim Max%, Sum% ' максимальное значение и сумма всех значений1409 Dim OldGrad# ' предыдущий угол1410 Dim LineCount As Long ' количество полос заливки1411 Dim d3D% ' смещение в 3D, в пикселях1412 Dim dWidth As Single ' ширина одного столбца1413 Dim dHeight As Single ' высота 'единицы высоты'1414 Dim StartFillColor As Long1415 Dim EndFillColor As Long1416 Dim LineColor As Long1417 Dim LineWidth As Byte1418 Dim PointRadius%1419 Dim Ellipce#1420 Dim UseColorFill As Boolean1421 Dim UseCircleLegend As Boolean1422 Dim UseLineLeftValues As Boolean14231424Public Sub InitDiagData(Data(), ByVal Mode As Byte, ByVal May3D As Boolean) 1425 ReDim DiagData(UBound(Data) \ 2 - 1) 1426 d# = 255 / (UBound(Data) \ 2 - 1) 1427 For i% = 0 To (UBound(Data) \ 2 - 1) 1428 DiagData(i). Val = Abs(Data(2 * i)) 1429 DiagData(i). Text = Data(2 * i + 1) 1430 DiagData(i). Color = RGB(i * d, i * d, i * d) 1431 Next i1432 DrawingMode = Mode1433 Use3D = May3D1434 1435 Label2. Visible = (DrawingMode <> 3) 1436 Label3. Visible = Label2. Visible1437 VScroll. Enabled = Not Label2. Visible1438End Sub14391440Public Sub ColorFill(PB As PictureBox, ByVal StColor As Long, ByVal EnColor As Long) 1441 Dim dR#, dG#, DB#, dC1 As Long, dC2 As Long1442 Dim R#, G#, B#1443 Dim intLoop As Long1444 1445 PB. Line (0, 0) - (PB. Width, PB. Height), EnColor, BF14461447 ' get Red1448 dC1 = StColor - (StColor \ &H100) * &H1001449 R = dC11450 dC2 = EnColor - (EnColor \ &H100) * &H1001451 dR = (dC1 - dC2) / LineCount1452 1453 ' get Green1454 dC1 = (StColor - (StColor \ &H10000) * &H10000 - dC1) \ &H1001455 G = dC11456 dC2 = (EnColor - (EnColor \ &H10000) * &H10000 - dC2) \ &H1001457 dG = (dC1 - dC2) / LineCount1458 1459 ' get Blue1460 dC1 = StColor \ &H100001461 B = dC11462 dC2 = EnColor \ &H100001463 DB = (dC1 - dC2) / LineCount14641465 With PB1466. DrawStyle = 11467. DrawMode = vbCopyPen1468. ScaleMode = vbPixels1469. DrawWidth = 21470. ScaleHeight = LineCount1471 For intLoop = 0 To LineCount - 11472 PB. Line (0, intLoop) - (PB. Width, intLoop - 1), RGB(R, G, B), BF1473 R = R - dR: If (R < 0) Then R = 255: If (R > 255) Then R = 01474 G = G - dG: If (G < 0) Then G = 255: If (G > 255) Then G = 01475 B = B - DB: If (B < 0) Then B = 255: If (B > 255) Then B = 01476 Next intLoop1477. ScaleMode = vbTwips1478. DrawWidth = 11479 End With1480End Sub14811482Sub OutOneElem(ElemIndex As Integer, StAn#, EnAn#, Optional Mode270Mode As Byte = 0) 1483 ' центральный угол1484 angle# = (StAn + (EnAn - StAn) / 2) * Pi_1801485 1486 ' динамическая глубина1487 d3D_% = Round(d3D / 100 * (100 - Round(100 * Ellipce))) 1488 If (d3D_ = 0) Then d3D_ = 11489 ' динамическое смещение центров кусков1490 r_# = Ellipce * d3D / 1001491 1492 X1# = Xc + Radius * Cos(angle) 1493 Y1# = Yc - Radius * Sin(angle) 1494 1495 x# = Xc + InRad / Radius * (X1 - Xc) 1496 y# = Yc + InRad / Radius * (Y1 - Yc) * r_1497 1498 If (Not Use3D) Then1499 Chart. FillStyle = 01500 Chart. FillColor = DiagData(ElemIndex). Color1501 If (StAn <> 0) Then1502 Chart. Circle (x, y), Radius, LineColor, - StAn * Pi_180, - EnAn * Pi_180, Ellipce1503 Else1504 Chart. Circle (x, y), Radius, LineColor, - 1E-45, - EnAn * Pi_180, Ellipce1505 End If1506 Chart. FillStyle = 11507 1508 ' вывод значений1509 R# = 1.3. * Radius1510 X2# = x + R * Cos(angle) 1511 Y2# = y - Ellipce * R * Sin(angle) 1512 1513 x0# = x + Radius * Cos(angle) 1514 y0# = y - Ellipce * Radius * Sin(angle) 1515 1516 str_1$ = CStr(DiagData(ElemIndex). Text) 1517 d1# = Chart. TextWidth(str_1) 1518 str_2$ = CStr(DiagData(ElemIndex). Val) 1519 d2# = Chart. TextWidth(str_2) 1520 1521 If UseCircleLegend Then1522 Chart. DrawStyle = 41523 Chart. Line (x0, y0) - (X2, Y2), LineColor1524 Chart. DrawStyle = 01525 1526 If Not ((angle > Pi_2) And (angle <= 3 * Pi_2)) Then1527 Chart. Line (X2, Y2) - (X2 + d1, Y2), LineColor1528 Chart. CurrentX = X21529 Chart. CurrentY = Y21530 Chart. Print CStr(str_1) 1531 1532 Chart. CurrentX = X21533 Chart. CurrentY = Y2 - Chart. TextHeight(str_2) 1534 Chart. Print CStr(str_2) 1535 Else1536 Chart. Line (X2, Y2) - (X2 - d1, Y2), LineColor1537 Chart. CurrentX = X2 - d11538 Chart. CurrentY = Y21539 Chart. Print CStr(str_1) 1540 1541 Chart. CurrentX = X2 - d11542 Chart. CurrentY = Y2 - Chart. TextHeight(str_2) 1543 Chart. Print CStr(str_2) 1544 End If1545 End If1546 1547 Else1548 Chart. FillStyle = 01549 Chart. FillColor = DiagData(ElemIndex). Color1550 1551 Select Case Mode270Mode1552 Case 01553 sa# = StAn1554 If (sa = 0) Then sa = 1E-45 Else sa = sa * Pi_1801555 For i% = d3D_ To 1 Step - 11556 If (i = d3D_) Then1557 Chart. DrawStyle = vbSolid1558 Chart. Circle (x, Screen. TwipsPerPixelY * (i - 1) + y), Radius, LineColor, - sa, - EnAn * Pi_180, Ellipce1559 Chart. DrawStyle = vbInvisible1560 ElseIf (i = 1) Then1561 Chart. DrawStyle = vbSolid1562 Chart. Circle (x, y), Radius, LineColor, - sa, - EnAn * Pi_180, Ellipce1563 Chart. DrawStyle = vbInvisible1564 Else1565 Chart. Circle (x, Screen. TwipsPerPixelY * (i - 1) + y), Radius, LineColor, - sa, - EnAn * Pi_180, Ellipce1566 End If1567 Next i1568 1569 Case mode270begin1570 For i% = d3D_ To 1 Step - 11571 If (i = d3D_) Then1572 Chart. DrawStyle = vbSolid1573 Chart. Circle (x, Screen. TwipsPerPixelY * (i - 1) + y), Radius, LineColor, - StAn * Pi_180, - EnAn * Pi_180, Ellipce1574 Chart. DrawStyle = vbInvisible1575 Else1576 Chart. Circle (x, Screen. TwipsPerPixelY * (i - 1) + y), Radius, LineColor, - StAn * Pi_180, - angle, Ellipce1577 End If1578 Next i1579 1580 Case mode270end1581 For i% = d3D_ To 1 Step - 11582 If (i = 1) Then1583 Chart. DrawStyle = vbSolid1584 Chart. Circle (x, y), Radius, LineColor, - StAn * Pi_180, - EnAn * Pi_180, Ellipce1585 Else1586 Chart. DrawStyle = vbInvisible1587 Chart. Circle (x, Screen. TwipsPerPixelY * (i - 1) + y), Radius, LineColor, - angle, - EnAn * Pi_180, Ellipce1588 End If1589 Next i1590 End Select1591 1592 Chart. FillStyle = 11593 Chart. DrawStyle = vbSolid1594 1595 ' вывод значений1596 R# = 1.3. * Radius1597 X2# = x + R * Cos(angle) 1598 Y2# = y - Ellipce * R * Sin(angle) 1599 1600 x0# = x + Radius * Cos(angle) 1601 y0# = y - Ellipce * Radius * Sin(angle) 1602 1603 str_1$ = CStr(DiagData(ElemIndex). Text) 1604 d1# = Chart. TextWidth(str_1) 1605 str_2$ = CStr(DiagData(ElemIndex). Val) 1606 d2# = Chart. TextWidth(str_2) 1607 1608 If UseCircleLegend Then1609 Chart. DrawStyle = 41610 Chart. Line (x0, y0) - (X2, Y2), LineColor1611 Chart. DrawStyle = 01612 1613 If Not ((angle > Pi_2) And (angle <= 3 * Pi_2)) Then1614 Chart. Line (X2, Y2) - (X2 + d1, Y2), LineColor1615 Chart. CurrentX = X21616 Chart. CurrentY = Y21617 Chart. Print CStr(str_1) 1618 1619 Chart. CurrentX = X21620 Chart. CurrentY = Y2 - Chart. TextHeight(str_2) 1621 Chart. Print CStr(str_2) 1622 Else1623 Chart. Line (X2, Y2) - (X2 - d1, Y2), LineColor1624 Chart. CurrentX = X2 - d11625 Chart. CurrentY = Y21626 Chart. Print CStr(str_1) 1627 1628 Chart. CurrentX = X2 - d11629 Chart. CurrentY = Y2 - Chart. TextHeight(str_2) 1630 Chart. Print CStr(str_2) 1631 End If1632 End If1633 1634 ' а теперь вывод боковых линий1635 Chart. DrawStyle = 016361637 ' начальный угол1638 If Not ((StAn > 90) And (StAn < 180)) Then1639 sa# = StAn * Pi_1801640 x0 = x + Radius * Cos(sa) 1641 y0 = y - Radius * Ellipce * Sin(sa) 16421643 If (Mode270Mode <> mode270end) Then1644 Chart. Line (x0, y0) - (x0, y0 + d3D_ * Screen. TwipsPerPixelY), LineColor1645 End If1646 End If16471648 ' конечный угол1649 If Not ((EnAn > 0) And (EnAn < 90)) Then1650 x0 = x + Radius * Cos(EnAn * Pi_180) 1651 y0 = y - Radius * Ellipce * Sin(EnAn * Pi_180) 16521653 Chart. Line (x0, y0) - (x0, y0 + d3D_ * Screen. TwipsPerPixelY), LineColor1654 End If1655 1656 ' центр1657 If Not ((EnAn >= 270) And (StAn <= 270)) Then1658 Chart. Line (x, y) - (x, y + d3D_ * Screen. TwipsPerPixelY), LineColor1659 End If1660 1661 ' левый край1662 If ((StAn <= 180) And (EnAn >= 180)) Then1663 Chart. Line (x - Radius, y) - (x - Radius, y + d3D_ * Screen. TwipsPerPixelY), LineColor1664 End If1665 1666 End If1667 1668 OldGrad = Grad1669End Sub167016711672' рисование круговой диаграммы1673Sub DrawCircle() 1674 Dim Mode270 As Boolean1675 Dim Item270%16761677 ItemCount = UBound(DiagData) + 11678 1679 With Chart1680 Max = - 11681 Sum = 01682 For i% = 1 To ItemCount1683 If (DiagData(i - 1). Val > Max) Then Max = DiagData(i - 1). Val1684 Sum = Sum + DiagData(i - 1). Val1685 Next i1686 1687 Mode270 = (Max > 3 / 4 * Sum) 1688 1689 OneGradus = 360 / Sum1690 OldGrad = 0.000011691 1692 Xc = Chart. Width \ 21693 Yc = Chart. Height \ 21694 1695 Dim pos90%, pos270% ' индексы ключевых элементов1696 pos90 = - 11697 pos270 = - 11698 OldGrad = 01699 1700 Dim Angles() As Double1701 ReDim Angles(ItemCount - 1, 1) 1702 1703 For i% = 1 To ItemCount1704 If Mode270 Then If (DiagData(i - 1). Val = Max) Then Item270 = i - 11705 Grad# = DiagData(i - 1). Val * OneGradus + OldGrad1706 If (OldGrad <= 90) And (Grad >= 90) Then pos90 = i - 11707 If (OldGrad <= 270) And (Grad >= 270) Then pos270 = i - 11708 Angles(i - 1, 0) = OldGrad1709 Angles(i - 1, 1) = Grad1710 OldGrad = Grad1711 Next i1712 1713 Chart. DrawStyle = 01714 1715 If Not Mode270 Then1716 1717 For i% = pos90 To 0 Step - 11718 Call OutOneElem(i, Angles(i, 0), Angles(i, 1)) 1719 Next i1720 1721 For i% = pos90 + 1 To pos270 - 11722 Call OutOneElem(i, Angles(i, 0), Angles(i, 1)) 1723 Next i1724 1725 For i% = ItemCount - 1 To pos270 Step - 11726 Call OutOneElem(i, Angles(i, 0), Angles(i, 1)) 1727 Next i1728 Else1729 1730 i% = pos90 - 11731 If (i < 0) Then i = ItemCount - 11732 1733 Call OutOneElem(Item270, Angles(Item270, 0), Angles(Item270, 1), mode270begin) 1734 1735 Do While (i <> Item270) 1736 Call OutOneElem(i, Angles(i, 0), Angles(i, 1)) 1737 1738 i = i - 11739 If (i < 0) Then i = ItemCount - 11740 Loop1741 1742 Call OutOneElem(Item270, Angles(Item270, 0), Angles(Item270, 1), mode270end) 1743 1744 End If1745 End With1746End Sub17471748' рисование линейной, точечной и столбчатой диаграмм1749Sub DrawPoint() 1750 Dim d3DX%1751 Dim d3DY%1752 Dim OldX%, OldY% ' координаты предыдущей точки1753 1754 ItemCount = UBound(DiagData) + 11755 ChartHeight = Chart. Height * 0.81756 ChartTop = Chart. Height * 0.11757 ChartDown = Chart. Height * 0.91758 1759 With Chart1760 dWidth = Chart. Width / (2 * ItemCount + 1) 1761 1762 Max = - 11763 Sum = 01764 For i% = 1 To ItemCount1765 If (DiagData(i - 1). Val > Max) Then Max = DiagData(i - 1). Val1766 Sum = Sum + DiagData(i - 1). Val1767 Next i1768 1769 dHeight = ChartHeight / Max1770 1771 d3DX = Screen. TwipsPerPixelX1772 d3DY = Screen. TwipsPerPixelY1773 1774 With Chart1775. DrawWidth = 11776. DrawStyle = 31777 Chart. Line (dWidth * 0.9, ChartTop \ 2) - (dWidth * 0.9, ChartDown), LineColor1778 Chart. Line (dWidth * 0.9, ChartDown) - ((2 * ItemCount + 0.5) * dWidth, ChartDown), LineColor1779. DrawStyle = 017801781. FontSize =. FontSize + 31782. FontUnderline = True17831784. CurrentX = 2 * d3DX1785. CurrentY = 2 * d3DY1786 Chart. Print "Значения"1787 1788 str_$ = "Подписи"1789. CurrentX =. Width - . TextWidth(str_) - 10 * d3DX1790. CurrentY = ChartDown +. TextHeight(str_) 1791 Chart. Print str_17921793. FontSize =. FontSize - 31794. FontUnderline = False1795 End With179617971798 For i% = 1 To ItemCount1799 j% = 2 * i - 11800 Dim y#, x#1801 y = ChartTop + dHeight * (Max - DiagData(i - 1). Val) 1802 1803 Select Case DrawingMode1804 Case 0 ' // // // // // // // // // // // // // // // // / ЛИНИИ // // // // // // // // // // // // // // // // // // // // /1805 x# = (j + 0.5) * dWidth1806 1807 If (i > 1) Then1808 Chart. DrawWidth = LineWidth1809 Chart. Line (OldX, OldY) - (x, y), DiagData(i - 1). Color1810 Chart. DrawWidth = 11811 End If1812 Chart. DrawStyle = 11813 Chart. Line (x, y) - (x, ChartDown), DiagData(i - 1). Color1814 Chart. DrawStyle = 01815 OldX = x1816 OldY = y1817 1818 str_$ = CStr(DiagData(i - 1). Text) 1819 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) \ 21820 Chart. CurrentY = ChartDown + Chart. TextHeight(str_) \ 101821 Chart. Print str_1822 1823 str_ = CStr(Round(DiagData(i - 1). Val / Sum * 100)) + "%"1824 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) \ 21825 Chart. CurrentY = y - Chart. TextHeight(str_) * 1.21826 Chart. Print str_1827 1828 ' значение слева с засечкой и линией1829 str_ = CStr(DiagData(i - 1). Val) 1830 If UseLineLeftValues Then1831 Chart. CurrentX = dWidth * 0.8 - Chart. TextWidth(str_) 1832 Chart. DrawStyle = 21833 Chart. Line (dWidth * 0.9, y) - (x, y), LineColor1834 Chart. DrawStyle = 01835 End If18361837 Chart. DrawWidth = 21838 Chart. Line (dWidth * 0.85, y) - (dWidth * 0.95, y), LineColor1839 Chart. DrawWidth = 11840 x# = dWidth * 0.8 - Chart. TextWidth(str_) 1841 Chart. CurrentX = x1842 Chart. CurrentY = y - Chart. TextHeight(str_) \ 21843 Chart. Print str_1844 1845 Case 1 ' // // // // // // // // // // // // // // // // / КОЛОНКИ // // // // // // // // // // // // // // // // // // // /1846 If (Not Use3D) Then1847 Chart. Line (j * dWidth, y) - ((j + 1) * dWidth, ChartDown), DiagData(i - 1). Color, BF1848 Chart. Line (j * dWidth, y) - ((j + 1) * dWidth, ChartDown), LineColor, B1849 1850 str_ = CStr(DiagData(i - 1). Text) 1851 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) \ 21852 Chart. CurrentY = ChartDown + Chart. TextHeight(str_) \ 101853 Chart. Print str_1854 1855 str_ = CStr(Round(DiagData(i - 1). Val / Sum * 100)) + "%"1856 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) \ 21857 Chart. CurrentY = y - Chart. TextHeight(str_) * 1.21858 Chart. Print str_1859 1860 ' значение слева с засечкой и линией1861 str_ = CStr(DiagData(i - 1). Val) 1862 If UseLineLeftValues Then1863 Chart. CurrentX = dWidth * 0.8 - Chart. TextWidth(str_) 1864 Chart. DrawStyle = 21865 Chart. Line (dWidth * 0.9, y) - (j * dWidth, y), LineColor1866 Chart. DrawStyle = 01867 End If1868 1869 x# = dWidth * 0.8 - Chart. TextWidth(str_) 1870 Chart. CurrentX = x1871 Chart. CurrentY = y - Chart. TextHeight(str_) \ 21872 Chart. Print str_1873 Chart. CurrentX = x1874 Chart. CurrentY = y1875 Chart. DrawWidth = 21876 Chart. Line (dWidth * 0.85, y) - (dWidth * 0.95, y), LineColor1877 Chart. DrawWidth = 11878 Else1879 For k% = 0 To d3D - 11880 Chart. Line (j * dWidth + k * d3DX, y - k * d3DY) - ((j + 1) * dWidth + k * d3DX, ChartDown - k * d3DY), DiagData(i - 1). Color, B1881 Next k1882 Chart. Line (j * dWidth, y) - ((j + 1) * dWidth, ChartDown), DiagData(i - 1). Color, BF1883 ' верхняя левая в глубине1884 ltdx% = j * dWidth + (d3D - 1) * d3DX1885 ltdy% = y - (d3D - 1) * d3DY1886 ' верхняя правая в глубине1887 rtdx% = (j + 1) * dWidth + (d3D - 1) * d3DX1888 rtdy% = y - (d3D - 1) * d3DY1889 ' нижняя правая в глубине1890 rddx% = (j + 1) * dWidth + (d3D - 1) * d3DX1891 rddy% = ChartDown - (d3D - 1) * d3DY1892 ' верхняя в глубине1893 Chart. Line (rtdx, rtdy) - (rddx, rddy), LineColor1894 ' правая в глубине1895 Chart. Line (ltdx, ltdy) - (rtdx, rtdy), LineColor1896 1897 ' левая переходная1898 Chart. Line (ltdx, ltdy) - (ltdx - d3D * d3DX, ltdy + d3D * d3DY), LineColor1899 ' правая верхняя переходная1900 Chart. Line (rtdx, rtdy) - (rtdx - d3D * d3DX, rtdy + d3D * d3DY), LineColor1901 ' правая нижняя переходная1902 Chart. Line (rddx, rddy) - (rddx - d3D * d3DX, rddy + d3D * d3DY), LineColor1903 Chart. Line (j * dWidth, y) - ((j + 1) * dWidth, ChartDown), LineColor, B1904 1905 ' надпись внизу1906 str_ = CStr(DiagData(i - 1). Text) 1907 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) \ 21908 Chart. CurrentY = ChartDown + Chart. TextHeight(str_) \ 101909 Chart. Print str_1910 ' процент вверху1911 str_ = CStr(Round(DiagData(i - 1). Val / Sum * 100)) + "%"1912 Chart. CurrentX = d3D * d3DX + j * dWidth + (dWidth - Chart. TextWidth(str_)) \ 21913 Chart. CurrentY = y - d3D * d3DY - Chart. TextHeight(str_) * 1.21914 Chart. Print str_1915 ' значение слева с засечкой и линией1916 str_ = CStr(DiagData(i - 1). Val) 1917 If UseLineLeftValues Then1918 Chart. CurrentX = dWidth * 0.8 - Chart. TextWidth(str_) 1919 Chart. DrawStyle = 21920 Chart. Line (dWidth * 0.9, y) - (j * dWidth, y), LineColor1921 Chart. DrawStyle = 01922 End If1923 1924 x# = dWidth * 0.8 - Chart. TextWidth(str_) 1925 Chart. CurrentX = x1926 Chart. CurrentY = y - Chart. TextHeight(str_) \ 21927 Chart. Print str_1928 Chart. CurrentX = x1929 Chart. CurrentY = y1930 Chart. DrawWidth = 21931 Chart. Line (dWidth * 0.85, y) - (dWidth * 0.95, y), LineColor1932 Chart. DrawWidth = 11933 End If1934 1935 Case 2 ' // // // // // // // // // // // // // // // // / ТОЧКИ // // // // // // // // // // // // // // // // // // // // /1936 Chart. FillStyle = 01937 Chart. FillColor = DiagData(i - 1). Color1938 x# = (j + 0.5) * dWidth1939 Chart. Circle (x, y), PointRadius * d3DX, LineColor1940 Chart. FillStyle = 11941 Chart. DrawStyle = 11942 Chart. Line (x, y) - (x, ChartDown), DiagData(i - 1). Color1943 Chart. DrawStyle = 01944 1945 str_ = CStr(DiagData(i - 1). Text) 1946 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) \ 21947 Chart. CurrentY = ChartDown + Chart. TextHeight(str_) \ 101948 Chart. Print str_1949 1950 str_ = CStr(Round(DiagData(i - 1). Val / Sum * 100)) + "%"1951 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) \ 21952 Chart. CurrentY = y - PointRadius * d3D - Chart. TextHeight(str_) * 1.21953 Chart. Print str_1954 1955 ' значение слева с засечкой и линией1956 str_ = CStr(DiagData(i - 1). Val) 1957 Chart. CurrentX = dWidth * 0.8 - Chart. TextWidth(str_) 1958 Chart. DrawStyle = 21959 Chart. Line (dWidth * 0.9, y) - (x, y), LineColor1960 Chart. DrawStyle = 01961 1962 Chart. DrawWidth = 21963 Chart. Line (dWidth * 0.85, y) - (dWidth * 0.95, y), LineColor1964 Chart. DrawWidth = 11965 x# = dWidth * 0.8 - Chart. TextWidth(str_) 1966 Chart. CurrentX = x1967 Chart. CurrentY = y - Chart. TextHeight(str_) \ 21968 Chart. Print str_1969 End Select1970 Next i1971 1972 End With1973End Sub19741975Sub DrawDiagram() 1976 If (Chart. Height > Screen. TwipsPerPixelX * 5) And (UseColorFill) Then1977 Call ColorFill(Chart, StartFillColor, EndFillColor) 1978 Else1979 Chart. Line (0, 0) - (Chart. Width, Chart. Height), StartFillColor, BF1980 End If19811982 Select Case DrawingMode1983 Case 3: Call DrawCircle1984 Case Else: Call DrawPoint1985 End Select1986End Sub19871988Private Sub Chart_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) 1989 If (DrawingMode <> 3) Then1990 y = Round((ChartDown - y) * Max / (ChartDown - ChartTop)) 1991 Label3. Caption = CStr(y) 1992 End If1993End Sub19941995Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 1996 If (KeyCode = vbKeyF5) Then Call DrawDiagram1997End Sub19981999Private Sub Form_Load() 2000 dW = Width - Chart. Width2001 dH = Height - Chart. Height2002 dX = Width - VScroll. Left2003 dH2 = Height - VScroll. Height2004 DrawingMode = 02005 Use3D = False2006 LineCount = 1002007 d3D = 152008 StartFillColor = RGB(255, 255, 128) 2009 EndFillColor = RGB(0, 128, 255) 2010 LineColor = 02011 LineWidth = 12012 Ellipce = 2 / 52013 PointRadius = 152014 2015 UseColorFill = True2016 UseCircleLegend = True2017 UseLineLeftValues = True2018 2019 ChartHeight = Chart. Height * 0.852020 ChartWidth = Chart. Width * 0.852021 ChartTop = Chart. Height * 0.0752022 ChartDown = Chart. Height * 0.9252023 If (ChartWidth < ChartHeight) Then Radius = ChartWidth Else Radius = ChartHeight2024 Radius = Radius * 0.52025 InRad = 0.1 * Radius2026End Sub20272028Private Sub Form_Resize() 2029 Min% = Width - dW + 5 * Screen. TwipsPerPixelX2030 If (Min < 0) Then Min = 02031 Chart. Width = Min2032 2033 Min% = Height - dH + Screen. TwipsPerPixelY2034 If (Min < 0) Then Min = 02035 Chart. Height = Min2036 2037 VScroll. Left = Width - dX2038 2039 Min% = Height - dH2 + Screen. TwipsPerPixelY2040 If (Min < 0) Then Min = 02041 VScroll. Height = Min2042 2043 Call DrawDiagram2044End Sub20452046Private Sub Image1_Click() 2047 CD. FileName = ""2048 CD. ShowSave2049 If (CD. FileName <> "") Then2050 Call SavePicture(Chart. Image, CD. FileName) 2051 End If2052End Sub20532054Private Sub Image2_Click() 2055 With DiagOptForm2056 ' цвета2057. Frame2(0). BackColor = StartFillColor2058. Frame2(1). BackColor = EndFillColor2059. Frame2(2). BackColor = Chart. ForeColor2060. Frame2(3). BackColor = LineColor2061 ' размеры2062. UpDown1. value = LineWidth2063. UpDown2. value = d3D2064. UpDown3. value = PointRadius2065. UpDown4. value = LineCount2066. UpDown5. value = Round(Ellipce * 100) 2067 2068. UpDown6. Max = Chart. Width2069 If (Chart. Height < Chart. Width) Then. UpDown6. Max = Chart. Width2070. UpDown6. Max = Round(. UpDown6. Max / Screen. TwipsPerPixelX) 2071. UpDown6. value = Round(Radius / Screen. TwipsPerPixelX) 20722073. UpDown7. Max =. UpDown6. Max * 0.92074. UpDown7. value = Round(InRad / Screen. TwipsPerPixelX) 2075 2076 ' цвета и надписи2077. List1. Clear2078 For i% = 1 To ItemCount2079. List1. AddItem (DiagData(i - 1). Text) 2080. List1. ItemData(i - 1) = DiagData(i - 1). Color2081 Next i2082 If (. List1. ListCount > 0) Then. List1. ListIndex = 02083 2084 ' флаги2085. Check1. value = - CInt(UseColorFill) 2086. Check3. value = - CInt(UseCircleLegend) 2087. Check2. value = - CInt(UseLineLeftValues) 2088 2089. Show vbModal2090 If (. res = 1) Then2091 ' цвета2092 StartFillColor =. Frame2(0). BackColor2093 EndFillColor =. Frame2(1). BackColor2094 Chart. ForeColor =. Frame2(2). BackColor2095 LineColor =. Frame2(3). BackColor2096 ' размеры2097 LineWidth =. UpDown1. value2098 d3D =. UpDown2. value2099 PointRadius =. UpDown3. value2100 LineCount =. UpDown4. value2101 Ellipce =. UpDown5. value / 1002102 Radius =. UpDown6. value * Screen. TwipsPerPixelX2103 InRad =. UpDown7. value * Screen. TwipsPerPixelX2104 ' цвета и надписи2105 For i% = 1 To ItemCount2106 DiagData(i - 1). Text =. List1. List(i - 1) 2107 DiagData(i - 1). Color =. List1. ItemData(i - 1) 2108 Next i2109 ' флаги2110 UseColorFill = (. Check1. value = 1) 2111 UseCircleLegend = (. Check3. value = 1) 2112 UseLineLeftValues = (. Check2. value = 1) 2113 Call DrawDiagram2114 End If2115 End With2116End Sub21172118Private Sub Image3_Click() 2119 Hide2120End Sub21212122Private Sub VScroll_Change() 2123 Ellipce = VScroll. value / 1002124 Call DrawDiagram2125End SubФорма: InputForm. frm2126Dim res%21272128Private Sub CancelBut_Click() 2129 Call SoundClick2130 Hide2131End Sub21322133Private Sub Form_Activate() 2134 Text1. SetFocus2135End Sub21362137Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 2138 Select Case KeyCode2139 Case 13: Call YesBut_Click2140 Case 27: Call CancelBut_Click2141 End Select2142End Sub21432144Private Sub Form_Load() 2145 Call ButEnabled(YesImg, YesBut, True) 2146 Call ButEnabled(CancelImg, CancelBut, True) 2147End Sub21482149Public Function InputVal(str$) As String2150 Label1. Caption = str2151 Text1. Text = ""2152 res = 02153 Me. Show vbModal2154 If (res = 1) Then InputVal = Text1. Text2155 Unload Me2156End Function21572158Private Sub YesBut_Click() 2159 Call SoundClick2160 res = 12161 Hide2162End SubФорма: DiagOpt. frm2163Public res%21642165Private Sub Form_Load() 2166 res = 02167 Call ButEnabled(SelectImg, SelectBut, True) 2168 Call ButEnabled(CancelImg, CancelBut, True) 2169End Sub21702171Private Sub Form_Paint() 2172 Call DiagResForm. ColorFill(Picture1, Frame2(0). BackColor, Frame2(1). BackColor) 2173End Sub21742175Private Sub Frame2_Click(Index As Integer) 2176 ColorDlg. Color = Frame2(Index). BackColor2177 ColorDlg. ShowColor2178 Frame2(Index). BackColor = ColorDlg. Color2179 If (Index < 2) Then Call DiagResForm. ColorFill(Picture1, Frame2(0). BackColor, Frame2(1). BackColor) 2180 If (Index = 4) Then List1. ItemData(List1. ListIndex) = Frame2(4). BackColor2181End Sub21822183Private Sub Label10_Click() 2184 res = 12185 Hide2186End Sub21872188Private Sub Label15_Click() 2189 Hide2190End Sub21912192Private Sub List1_Click() 2193 If (List1. ListIndex > - 1) Then2194 Text1. Text = List1. List(List1. ListIndex) 2195 Frame2(4). BackColor = List1. ItemData(List1. ListIndex) 2196 End If2197End Sub21982199Private Sub List1_KeyPress(KeyAscii As Integer) 2200 Call List1_Click2201End Sub22022203Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) 2204 If (KeyCode = 13) Then2205 List1. List(List1. ListIndex) = Text1. Text2206 List1. ItemData(List1. ListIndex) = Frame2(4). BackColor2207 End If2208End SubФорма: SplashScreenForm. frm2209Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 2210 If (KeyCode = 27) Or (KeyCode = 13) Then2211 MainForm. Show2212 Unload Me2213 End If2214End Sub22152216Private Sub Form_Load() 2217 Label2. Caption = "v. " + CStr(App. Major) + ". " + CStr(App. Minor) 2218End Sub22192220Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) 2221 Call MDown(x, y) 2222End Sub22232224Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) 2225 Call MMove(hwnd, x, y) 2226End Sub22272228Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) 2229 Call MUp2230End SubФорма: MonthForm. frm2231Public res%22322233Private Sub CancelBut_Click() 2234 Hide2235End Sub22362237Private Sub EditBut_Click() 2238 res = - 12239 Hide2240End Sub22412242Private Sub Form_Load() 2243 Call ButEnabled(YesImg, YesBut, True) 2244 Call ButEnabled(EditImg, EditBut, True) 2245 Call ButEnabled(CancelImg, CancelBut, True) 2246 res = 02247End Sub22482249Private Sub YesBut_Click() 2250 res = 12251 Hide2252End SubМодуль: DBTypes. bas2253'************************************2254' модуль DBTypes. bas2255' вся работа с файлом БД2256'************************************22572258'************************************** Описание типов **************************************22592260' заголовок файла2261Type TDBHeader2262 ' "DBX" - проверка файла2263 Header As String * 32264 ' флаги2265 Flags As Byte2266 ' количество полей2267 ColCount As Long2268 ' количество записей2269 RowCount As Long2270End Type22712272' имеет ли пользователь права на редактирование2273Public UserIsAdmin As Boolean22742275' данные о столбце2276Type TDBElemData2277 ' тип данных2278 Class As Byte2279 ' длина заголовка2280 TitleLen As Byte2281 ' заголовок, длины TitleLen2282 title As String2283 ' значение по-умолчанию2284 DefValue As Variant2285End Type22862287' запись2288Type TDBElem2289 ' поля записи2290 Fields() As Variant2291End Type22922293' элемент в массиве DB2294Type TDBCell2295 Header As TDBHeader2296 Cols() As TDBElemData2297 Rows() As TDBElem2298 Password As String2299End Type23002301'************************************** Описание констант **************************************23022303' контрольный байт2304Public Const ValidateByte As Byte = &H7F23052306'************************************** Описание переменных **************************************23072308' путь к БД2309Public DBPath$2310' флаг изменения БД2311Public DBChanged As Boolean2312' данные таблиц: каждый элемент - это копия некоторой таблицы2313Public DB() As TDBCell23142315'************************************** Процедуры и функции **************************************23162317' удаление поля2318Public Sub DelCol_(DBIndex%, Optional ByVal Index% = - 1, Optional ByVal conf As Boolean = True) 2319 With DB(DBIndex). Header2320 If (. ColCount = 0) Then Exit Sub2321 If (Index = - 1) Then Index =. ColCount - 12322 If (Index >. ColCount - 1) Or (Index < - 1) Then2323 Call MsgForm. ErrorMsg("Ошибка удаления столбца! ") 2324 Exit Sub2325 End If2326 2327 If conf Then2328 If (MsgForm. QuestMsg("Удалить столбец? ") <> resOk) Then Exit Sub2329 End If2330 ' вырезаю из полей2331 For i% = Index To (. ColCount - 2) 2332 DB(DBIndex). Cols(i) = DB(DBIndex). Cols(i + 1) 2333 Next i2334 ' вырезаю из записей2335 For R% = 0 To (. RowCount - 1) 2336 For c% = Index To (. ColCount - 2) 2337 DB(DBIndex). Rows(R). Fields(c) = DB(DBIndex). Rows(R). Fields(c + 1) 2338 Next c2339 Next R2340 2341. ColCount =. ColCount - 12342 ReDim Preserve DB(DBIndex). Cols(. ColCount) 2343 DBChanged = True
Страницы: 1, 2, 3, 4
|
|