实例介绍
【实例简介】
【实例截图】
【核心代码】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 | using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ToolClassLibrary; using ImageLibrary; using System.Runtime.InteropServices; using OptimizeToolToolForm.FormMenu; using System.Management; using Microsoft.Win32; using System.Diagnostics; using System.Collections; using System.IO; using ToolClassLibrary.SystemToolClass; using System.Threading; namespace OptimizeToolToolForm { public partial class WindowMenu : Form { #region 控制窗体拖动 API [DllImport( "user32.dll" )] public static extern bool ReleaseCapture(); [DllImport( "user32.dll" )] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); public const int WM_SYSCOMMAND = 0x0112; public const int SC_MOVE = 0xF010; public const int HTCAPTION = 0x0002; #endregion public WindowMenu() { InitializeComponent(); //当前窗体的图片 BindFormInit(); #region 窗体标题按钮集合 ImageFormClass.SetFormImage( this .title_but1, ImageLibrary.Properties.Resource_Png.titlebut_01_2011_01_01, ImageLibrary.ImagePoint.titlebut_01_2011_01_01, this .labindex); this .title_but1.Tag = "1" ; ImageFormClass.SetFormImage( this .title_but2, ImageLibrary.Properties.Resource_Png.titlebut_02_2011_01_02, ImageLibrary.ImagePoint.titlebut_02_2011_01_02, this .labtitle2); ImageFormClass.SetFormImage( this .title_but3, ImageLibrary.Properties.Resource_Png.titlebut_03_2011_01_02, ImageLibrary.ImagePoint.titlebut_03_2011_01_02, this .labtitle3); ImageFormClass.SetFormImage( this .title_but4, ImageLibrary.Properties.Resource_Png.titlebut_04_2011_01_02, ImageLibrary.ImagePoint.titlebut_04_2011_01_02, this .labtitle4); ImageFormClass.SetFormImage( this .title_but5, ImageLibrary.Properties.Resource_Png.titlebut_05_2011_01_02, ImageLibrary.ImagePoint.titlebut_05_2011_01_02, this .labtitle5); ImageFormClass.SetFormImage( this .title_but6, ImageLibrary.Properties.Resource_Png.titlebut_06_2011_01_02, ImageLibrary.ImagePoint.titlebut_06_2011_01_02, this .labtitle6); ImageFormClass.SetFormImage( this .title_but7, ImageLibrary.Properties.Resource_Png.titlebut_07_2011_01_02, ImageLibrary.ImagePoint.titlebut_07_2011_01_02, this .labtitle7); #endregion #region //关闭按钮设置 ImageFormClass.SetFormImage( this .picexit, ImageLibrary.Properties.Resource_Png.exit_2011_01_02, ImageLibrary.ImagePoint.exit_2011_01_01); //最小化按钮设置 ImageFormClass.SetFormImage( this .pichide, ImageLibrary.Properties.Resource_Png.hide_2011_01_02, ImageLibrary.ImagePoint.hide_2011_01_02); //提点建议链接 linkjy.Location = new Point(ImagePoint.linkjy[0], ImagePoint.linkjy[1]); ImageFormClass.SetFormImage( this .picleave, ImageLibrary.Properties.Resource_Png.leave_2011_01_01, ImageLibrary.ImagePoint.leave_2011_01_01); //检测更新 ImageFormClass.SetFormImage( this .picupdate, ImageLibrary.Properties.Resource_Png.update_2011_01_01, ImageLibrary.ImagePoint.update_2011_01_01); linkupdate.Location = new Point(ImagePoint.linkupdate[0], ImagePoint.linkupdate[1]); //皮肤按钮 ImageFormClass.SetFormImage( this .picSkin, ImageLibrary.Properties.Resource_Png.skin_2011_01_01, ImageLibrary.ImagePoint.skin_2011_01_01); ImageFormClass.SetBackgroundImage( this .panelskin, ImageLibrary.Properties.Resource_Png.skinbgcolor, ImageLibrary.ImagePoint.panelskin); #endregion #region panel集合背景 ImageFormClass.SetBackgroundImage( this .panelindex, Properties.Resources.panelindex_bg_2011_01_01, ImageLibrary.ImagePoint.panelindex); //panelindex_1位置和背景图片 ImageFormClass.SetBackgroundImage( this .panelindex_1, Properties.Resources.panelindex_bg_2011_01_01, ImageLibrary.ImagePoint.panelindex); //panelindex_1控件位置 BindControlPoint(paneltree1_1, ImageLibrary.ImagePoint.paneltree1); BindControlPoint(panellistView1_1, ImageLibrary.ImagePoint.panellistView1); ImageFormClass.SetBackgroundImage( this .panel2, Properties.Resources.panelindex_bg_2011_01_01, ImageLibrary.ImagePoint.panelindex); ImageFormClass.SetBackgroundImage( this .panel3, Properties.Resources.panelindex_bg_2011_01_01, ImageLibrary.ImagePoint.panelindex); ImageFormClass.SetBackgroundImage( this .panel4, Properties.Resources.panelindex_bg_2011_01_01, ImageLibrary.ImagePoint.panelindex); //listview列表位置设定 BindControlPoint(Panel_04_listView1, ImageLibrary.ImagePoint.Panel_04_listView1); //按钮位置设定 ImageFormClass.SetBtnImage(Panel_04picbf, ImageLibrary.Properties.Resource_Png.btn_beifen_2011_01_01, ImageLibrary.ImagePoint.Panel_04picbf); ImageFormClass.SetBtnImage(Panel_04pichy, ImageLibrary.Properties.Resource_Png.btn_huanyuan_2011_01_01, ImageLibrary.ImagePoint.Panel_04pichy); ImageFormClass.SetBtnImage(Panel_04picyh, ImageLibrary.Properties.Resource_Png.btn_youhua_2011_01_01, ImageLibrary.ImagePoint.Panel_04picyh); ImageFormClass.SetBackgroundImage( this .panel5, Properties.Resources.panelindex_bg_2011_01_01, ImageLibrary.ImagePoint.panelindex); ImageFormClass.SetBackgroundImage( this .panel6, Properties.Resources.panelindex_bg_2011_01_01, ImageLibrary.ImagePoint.panelindex); ImageFormClass.SetBackgroundImage( this .panel7, Properties.Resources.panelindex_bg_2011_01_01, ImageLibrary.ImagePoint.panelindex); pic_control.Location = new Point(ImageLibrary.ImagePoint.pic_control[0], ImageLibrary.ImagePoint.pic_control[1]); pic_control.Size = new Size(ImageLibrary.ImagePoint.pic_control[2], ImageLibrary.ImagePoint.pic_control[3]); #endregion } #region 初始值绑定 /// <summary> /// 初始值绑定 /// </summary> private void BindFormInit() { this .Opacity = Convert.ToInt32(ToolClassLibrary.PublicClass.Diaphaneity) / 100.0; tckback.Value = Convert.ToInt32(ToolClassLibrary.PublicClass.Diaphaneity); switch (ToolClassLibrary.PublicClass.Skin) { case "1" : { BindLab(Color.White, 1); ImageFormClass.SetFormImage( this , ImageLibrary.Properties.Resource_Png.menu2011_01_01); } break ; case "2" : { BindLab(Color.Black, 2); ImageFormClass.SetFormImage( this , ImageLibrary.Properties.Resource_Png.menu2011_01_02); } break ; case "3" : { BindLab(Color.Black, 3); ImageFormClass.SetFormImage( this , ImageLibrary.Properties.Resource_Png.menu2011_01_03); } break ; default : { BindLab(Color.White, 1); ImageFormClass.SetFormImage( this , ImageLibrary.Properties.Resource_Png.menu2011_01_01); } break ; } } #endregion #region 窗体拖动 private Point mouse_offset; private void WindowMenu_MouseMove( object sender, MouseEventArgs e) { ////当为性能最佳时,不执行效果拖动 if (ToolClassLibrary.PublicClass.Capability == "1" ) { if (e.Button == MouseButtons.Left) { Point mousePos = Control.MousePosition; mousePos.Offset(mouse_offset.X, mouse_offset.Y); Location = mousePos; } } } private void WindowMenu_MouseDown( object sender, MouseEventArgs e) { //当为性能最佳时,不执行效果拖动 if (ToolClassLibrary.PublicClass.Capability == "1" ) { mouse_offset = new Point(-e.X, -e.Y); } else { //性能最佳拖动 ReleaseCapture(); SendMessage( this .Handle, WM_SYSCOMMAND, SC_MOVE HTCAPTION, 0); } } #endregion #region 关闭按钮事件 /// <summary> /// 点击关闭,触发关闭事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void picexit_Click( object sender, EventArgs e) { this .Hide(); } /// <summary> /// 鼠标进入控件可见部分时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void picexit_MouseEnter( object sender, EventArgs e) { ImageFormClass.SetFormImage( this .picexit, ImageLibrary.Properties.Resource_Png.exit_2011_01_01, ImageLibrary.ImagePoint.exit_2011_01_01); } /// <summary> /// 鼠标移出控件发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void picexit_MouseLeave( object sender, EventArgs e) { ImageFormClass.SetFormImage( this .picexit, ImageLibrary.Properties.Resource_Png.exit_2011_01_02, ImageLibrary.ImagePoint.exit_2011_01_02); } #endregion #region 最小化按钮事件 /// <summary> /// 鼠标进入控件可见部分时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pichide_MouseEnter( object sender, EventArgs e) { ImageFormClass.SetFormImage( this .pichide, ImageLibrary.Properties.Resource_Png.hide_2011_01_01, ImageLibrary.ImagePoint.hide_2011_01_01); } /// <summary> /// 鼠标移出控件发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pichide_MouseLeave( object sender, EventArgs e) { ImageFormClass.SetFormImage( this .pichide, ImageLibrary.Properties.Resource_Png.hide_2011_01_02, ImageLibrary.ImagePoint.hide_2011_01_02); } /// <summary> /// 点击事件 最小化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pichide_Click( object sender, EventArgs e) { this .WindowState = FormWindowState.Minimized; } #endregion #region 绑定菜单标题方法 /// <summary> /// 绑定菜单标题方法 /// </summary> /// <param name="p"></param> private void BindTitle( int p) { //先清空选中 ImageFormClass.SetFormImage( this .title_but1, ImageLibrary.Properties.Resource_Png.titlebut_01_2011_01_02, ImageLibrary.ImagePoint.titlebut_01_2011_01_02, this .labindex); ImageFormClass.SetFormImage( this .title_but2, ImageLibrary.Properties.Resource_Png.titlebut_02_2011_01_02, ImageLibrary.ImagePoint.titlebut_02_2011_01_02, this .labtitle2); ImageFormClass.SetFormImage( this .title_but3, ImageLibrary.Properties.Resource_Png.titlebut_03_2011_01_02, ImageLibrary.ImagePoint.titlebut_03_2011_01_02, this .labtitle3); ImageFormClass.SetFormImage( this .title_but4, ImageLibrary.Properties.Resource_Png.titlebut_04_2011_01_02, ImageLibrary.ImagePoint.titlebut_04_2011_01_02, this .labtitle4); ImageFormClass.SetFormImage( this .title_but5, ImageLibrary.Properties.Resource_Png.titlebut_05_2011_01_02, ImageLibrary.ImagePoint.titlebut_05_2011_01_02, this .labtitle5); ImageFormClass.SetFormImage( this .title_but6, ImageLibrary.Properties.Resource_Png.titlebut_06_2011_01_02, ImageLibrary.ImagePoint.titlebut_06_2011_01_02, this .labtitle6); ImageFormClass.SetFormImage( this .title_but7, ImageLibrary.Properties.Resource_Png.titlebut_07_2011_01_02, ImageLibrary.ImagePoint.titlebut_07_2011_01_02, this .labtitle7); this .title_but1.Tag = "0" ; this .title_but2.Tag = "0" ; this .title_but3.Tag = "0" ; this .title_but4.Tag = "0" ; this .title_but5.Tag = "0" ; this .title_but6.Tag = "0" ; this .title_but7.Tag = "0" ; switch (p) { case 1: { this .title_but1.Tag = p; ImageFormClass.SetFormImage( this .title_but1, ImageLibrary.Properties.Resource_Png.titlebut_01_2011_01_01, ImageLibrary.ImagePoint.titlebut_01_2011_01_01, this .labindex); } break ; case 2: { this .title_but2.Tag = p; ImageFormClass.SetFormImage( this .title_but2, ImageLibrary.Properties.Resource_Png.titlebut_02_2011_01_01, ImageLibrary.ImagePoint.titlebut_02_2011_01_01, this .labtitle2); } break ; case 3: { this .title_but3.Tag = p; ImageFormClass.SetFormImage( this .title_but3, ImageLibrary.Properties.Resource_Png.titlebut_03_2011_01_01, ImageLibrary.ImagePoint.titlebut_03_2011_01_01, this .labtitle3); } break ; case 4: { this .title_but4.Tag = p; ImageFormClass.SetFormImage( this .title_but4, ImageLibrary.Properties.Resource_Png.titlebut_04_2011_01_01, ImageLibrary.ImagePoint.titlebut_04_2011_01_01, this .labtitle4); } break ; case 5: { this .title_but5.Tag = p; ImageFormClass.SetFormImage( this .title_but5, ImageLibrary.Properties.Resource_Png.titlebut_05_2011_01_01, ImageLibrary.ImagePoint.titlebut_05_2011_01_01, this .labtitle5); } break ; case 6: { this .title_but6.Tag = p; ImageFormClass.SetFormImage( this .title_but6, ImageLibrary.Properties.Resource_Png.titlebut_06_2011_01_01, ImageLibrary.ImagePoint.titlebut_06_2011_01_01, this .labtitle6); } break ; case 7: { this .title_but7.Tag = p; ImageFormClass.SetFormImage( this .title_but7, ImageLibrary.Properties.Resource_Png.titlebut_07_2011_01_01, ImageLibrary.ImagePoint.titlebut_07_2011_01_01, this .labtitle7); } break ; default : { } break ; } } #endregion #region 公用提取方法 private void BIndisMouseEnterByLeave(Control control, Bitmap bmap, int [] sizes, Control lab) { if (control.Tag.ToString() == "0" ) { ImageFormClass.SetFormImage(control, bmap, sizes, lab); } } #endregion #region 第一个菜单标题 private void title_but1_Click( object sender, EventArgs e) { panelindex.Visible = true ; panelindex_1.Visible = false ; if (title_but1.Tag.ToString() == "0" ) { BIndisMouseEnterByLeave( this .title_but1, ImageLibrary.Properties.Resource_Png.titlebut_01_2011_01_01, ImageLibrary.ImagePoint.titlebut_01_2011_01_01, this .labindex); BindTitle(1); BindIsDisplay(1); } } private void title_but1_MouseEnter( object sender, EventArgs e) { BIndisMouseEnterByLeave( this .title_but1, ImageLibrary.Properties.Resource_Png.titlebut_01_2011_01_01, ImageLibrary.ImagePoint.titlebut_01_2011_01_01, this .labindex); } private void title_but1_MouseLeave( object sender, EventArgs e) { BIndisMouseEnterByLeave( this .title_but1, ImageLibrary.Properties.Resource_Png.titlebut_01_2011_01_02, ImageLibrary.ImagePoint.titlebut_01_2011_01_02, this .labindex); } #endregion #region 第二个菜单标题 private void title_but2_MouseEnter( object sender, EventArgs e) { BIndisMouseEnterByLeave(title_but2, ImageLibrary.Properties.Resource_Png.titlebut_02_2011_01_01, ImageLibrary.ImagePoint.titlebut_02_2011_01_01, this .labtitle2); } private void title_but2_MouseLeave( object sender, EventArgs e) { BIndisMouseEnterByLeave( this .title_but2, ImageLibrary.Properties.Resource_Png.titlebut_02_2011_01_02, ImageLibrary.ImagePoint.titlebut_02_2011_01_02, this .labtitle2); } private void title_but2_Click( object sender, EventArgs e) { if (title_but2.Tag.ToString() == "0" ) { BIndisMouseEnterByLeave( this .title_but2, ImageLibrary.Properties.Resource_Png.titlebut_02_2011_01_01, ImageLibrary.ImagePoint.titlebut_02_2011_01_01, this .labtitle2); BindTitle(2); //对菜单显示panel BindIsDisplay(2); } } #endregion #region 第三个菜单标题 private void title_but3_MouseEnter( object sender, EventArgs e) { BIndisMouseEnterByLeave(title_but3, ImageLibrary.Properties.Resource_Png.titlebut_03_2011_01_01, ImageLibrary.ImagePoint.titlebut_03_2011_01_01, this .labtitle3); } private void title_but3_MouseLeave( object sender, EventArgs e) { BIndisMouseEnterByLeave( this .title_but3, ImageLibrary.Properties.Resource_Png.titlebut_03_2011_01_02, ImageLibrary.ImagePoint.titlebut_03_2011_01_02, this .labtitle3); } private void title_but3_Click( object sender, EventArgs e) { if (title_but3.Tag.ToString() == "0" ) { BIndisMouseEnterByLeave( this .title_but3, ImageLibrary.Properties.Resource_Png.titlebut_03_2011_01_01, ImageLibrary.ImagePoint.titlebut_03_2011_01_01, this .labtitle3); BindTitle(3); BindIsDisplay(3); } } #endregion #region 第四个菜单标题 private void title_but4_MouseEnter( object sender, EventArgs e) { BIndisMouseEnterByLeave(title_but4, ImageLibrary.Properties.Resource_Png.titlebut_04_2011_01_01, ImageLibrary.ImagePoint.titlebut_04_2011_01_01, this .labtitle4); } private void title_but4_MouseLeave( object sender, EventArgs e) { BIndisMouseEnterByLeave( this .title_but4, ImageLibrary.Properties.Resource_Png.titlebut_04_2011_01_02, ImageLibrary.ImagePoint.titlebut_04_2011_01_02, this .labtitle4); } private void title_but4_Click( object sender, EventArgs e) { if (title_but4.Tag.ToString() == "0" ) { BIndisMouseEnterByLeave( this .title_but4, ImageLibrary.Properties.Resource_Png.titlebut_04_2011_01_01, ImageLibrary.ImagePoint.titlebut_04_2011_01_01, this .labtitle4); BindTitle(4); BindIsDisplay(4); } } #endregion #region 第五个菜单标题 private void title_but5_MouseEnter( object sender, EventArgs e) { BIndisMouseEnterByLeave(title_but5, ImageLibrary.Properties.Resource_Png.titlebut_05_2011_01_01, ImageLibrary.ImagePoint.titlebut_05_2011_01_01, this .labtitle5); } private void title_but5_MouseLeave( object sender, EventArgs e) { BIndisMouseEnterByLeave( this .title_but5, ImageLibrary.Properties.Resource_Png.titlebut_05_2011_01_02, ImageLibrary.ImagePoint.titlebut_05_2011_01_02, this .labtitle5); } private void title_but5_Click( object sender, EventArgs e) { if (title_but5.Tag.ToString() == "0" ) { BIndisMouseEnterByLeave( this .title_but5, ImageLibrary.Properties.Resource_Png.titlebut_05_2011_01_01, ImageLibrary.ImagePoint.titlebut_05_2011_01_01, this .labtitle5); BindTitle(5); BindIsDisplay(5); } } #endregion #region 第六个菜单标题 private void title_but6_MouseEnter( object sender, EventArgs e) { BIndisMouseEnterByLeave(title_but6, ImageLibrary.Properties.Resource_Png.titlebut_06_2011_01_01, ImageLibrary.ImagePoint.titlebut_06_2011_01_01, this .labtitle6); } private void title_but6_MouseLeave( object sender, EventArgs e) { BIndisMouseEnterByLeave( this .title_but6, ImageLibrary.Properties.Resource_Png.titlebut_06_2011_01_02, ImageLibrary.ImagePoint.titlebut_06_2011_01_02, this .labtitle6); } private void title_but6_Click( object sender, EventArgs e) { if (title_but6.Tag.ToString() == "0" ) { BIndisMouseEnterByLeave( this .title_but6, ImageLibrary.Properties.Resource_Png.titlebut_06_2011_01_01, ImageLibrary.ImagePoint.titlebut_06_2011_01_01, this .labtitle6); BindTitle(6); BindIsDisplay(6); //打开进程管理数据 tbcProcess.Visible = true ; tbcProcess.Dock = DockStyle.Fill; ; getProcessInfo(); getWindowsInfo(); } } #endregion #region 第七个菜单标题 (高级功能) private void title_but7_MouseEnter( object sender, EventArgs e) { BIndisMouseEnterByLeave(title_but7, ImageLibrary.Properties.Resource_Png.titlebut_07_2011_01_01, ImageLibrary.ImagePoint.titlebut_07_2011_01_01, this .labtitle7); } private void title_but7_MouseLeave( object sender, EventArgs e) { BIndisMouseEnterByLeave( this .title_but7, ImageLibrary.Properties.Resource_Png.titlebut_07_2011_01_02, ImageLibrary.ImagePoint.titlebut_07_2011_01_02, this .labtitle7); } private void title_but7_Click( object sender, EventArgs e) { if (title_but7.Tag.ToString() == "0" ) { bindInit(); } } /// <summary> /// panel7数据绑定(高级功能) /// </summary> private void BIndpanel7() { //得到系统自带工具 List<ToolClassLibrary.SystemToolClass.SystemTool> list = BindSystemTool(); //得到第三方工具 List<ToolClassLibrary.SystemToolClass.SystemTool> list1 = BindUserTool(); if (list1.Count > 0) { list.AddRange(list1); } //得到用户上传的工具 if (PublicClass.list.Count > 0) { list.AddRange(PublicClass.list); } int w = 0; //增加宽度 int h = 0; //增加高度 int wl = 0; int hl = 0; int number = 1; //换行数 int i = 1; foreach (ToolClassLibrary.SystemToolClass.SystemTool item in list) { // // pic_xt_01 // PictureBox pic_xt_01 = new PictureBox(); pic_xt_01.Location = new System.Drawing.Point(36 w, 65 h); pic_xt_01.Name = "pic_xt_0" i; pic_xt_01.Size = new System.Drawing.Size(52, 52); pic_xt_01.TabIndex = 5; pic_xt_01.TabStop = false ; pic_xt_01.Tag = item.Content; pic_xt_01.BackColor = Color.Transparent; if (item.Img != null ) { pic_xt_01.Image = item.Img; } else { //给他默认图片 pic_xt_01.Image = Properties.Resources.system_001; } pic_xt_01.Cursor = System.Windows.Forms.Cursors.Hand; pic_xt_01.MouseEnter = pic_xt_01_MouseEnter; pic_xt_01.MouseLeave = pic_xt_01_MouseLeave; pic_xt_01.MouseDown = ToolRight_MouseDown; // // lab_xt_01 // Label lab_xt_01 = new Label(); lab_xt_01.AutoSize = true ; lab_xt_01.BackColor = System.Drawing.Color.Transparent; lab_xt_01.Location = new System.Drawing.Point(31 wl, 120 hl); lab_xt_01.Name = "lab_xt_0" i; lab_xt_01.Size = new System.Drawing.Size(89, 12); lab_xt_01.TabIndex = 4; lab_xt_01.Text = item.Name; lab_xt_01.Tag = item.Content; lab_xt_01.Cursor = System.Windows.Forms.Cursors.Hand; lab_xt_01.MouseDown = ToolRight_MouseDown; panel7.Controls.Add(lab_xt_01); panel7.Controls.Add(pic_xt_01); w = w ImageLibrary.ImagePoint.panel7_img[0]; wl = wl ImageLibrary.ImagePoint.panel7_lab[0]; if (i == ImageLibrary.ImagePoint.panel7_img[2] * number) { number ; w = 0; wl = 0; h = h ImageLibrary.ImagePoint.panel7_img[1]; hl = hl ImageLibrary.ImagePoint.panel7_lab[1]; } i ; } } #endregion #region 工具边框的改变 private void pic_xt_01_MouseEnter( object sender, EventArgs e) { (sender as PictureBox).BorderStyle = BorderStyle.FixedSingle; } private void pic_xt_01_MouseLeave( object sender, EventArgs e) { (sender as PictureBox).BorderStyle = BorderStyle.None; } #endregion #region 打开系统工具事件 /// <summary> /// 打开系统工具 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// //API [DllImport( "shell32.dll" , EntryPoint = "ShellExecute" )] private static extern int ShellExecute( int hwnd, String lpOperation, String lpFile, String lpParameters, String lpDirectory, int nShowCmd); private void ToolRight_MouseDown( object sender, MouseEventArgs e) { panel_rightClick.Visible = false ; if (e.Button == System.Windows.Forms.MouseButtons.Right) { if ((sender as PictureBox) != null ) { panel_rightClick.Location = new Point((sender as PictureBox).Location.X (sender as PictureBox).Width 2, (sender as PictureBox).Location.Y); link_start.Tag = (sender as PictureBox).Tag; link_delete.Tag = (sender as PictureBox).Tag; } else { panel_rightClick.Location = new Point((sender as Label).Location.X (sender as Label).Width 2, (sender as Label).Location.Y); link_start.Tag = (sender as Label).Tag; link_delete.Tag = (sender as Label).Tag; } panel_rightClick.Visible = true ; } if (e.Button == System.Windows.Forms.MouseButtons.Left) { string str = "" ; if ((sender as PictureBox) != null ) { str = (sender as PictureBox).Tag.ToString(); } else if ((sender as Label) != null ) { str = (sender as Label).Tag.ToString(); } else if ((sender as LinkLabel) != null ) { str = (sender as LinkLabel).Tag.ToString(); } if (str == "搜索" ) { ShellExecute(0, "find" , "" , "" , "" , 0); } else { System.Diagnostics.Process.Start(str); } } } #endregion #region 绑定系统工具 /// <summary> /// 绑定系统工具 /// </summary> /// <returns></returns> private List<ToolClassLibrary.SystemToolClass.SystemTool> BindSystemTool() { List<ToolClassLibrary.SystemToolClass.SystemTool> list = new List<ToolClassLibrary.SystemToolClass.SystemTool>(); ToolClassLibrary.SystemToolClass.SystemTool sc = new ToolClassLibrary.SystemToolClass.SystemTool(); sc.Name = "添加或删除程序" ; sc.Content = "appwiz.cpl" ; sc.Img = Properties.Resources.system_001; ToolClassLibrary.SystemToolClass.SystemTool sc1 = new ToolClassLibrary.SystemToolClass.SystemTool(); sc1.Name = "注册表编辑器" ; string regeditstr = Environment.GetEnvironmentVariable( "WinDir" ); sc1.Content = regeditstr "\\regedit.exe" ; sc1.Img = Properties.Resources.system_002; ToolClassLibrary.SystemToolClass.SystemTool sc2 = new ToolClassLibrary.SystemToolClass.SystemTool(); sc2.Name = "计算机管理" ; sc2.Content = Environment.SystemDirectory.ToString() "\\compmgmt.msc" ; sc2.Img = Properties.Resources.system_003; ToolClassLibrary.SystemToolClass.SystemTool sc3 = new ToolClassLibrary.SystemToolClass.SystemTool(); sc3.Name = "显示属性" ; sc3.Content = "desk.cpl" ; sc3.Img = Properties.Resources.system_004; ToolClassLibrary.SystemToolClass.SystemTool sc4 = new ToolClassLibrary.SystemToolClass.SystemTool(); sc4.Name = "DX诊断工具" ; sc4.Content = Environment.SystemDirectory.ToString() "\\dxdiag.exe" ; sc4.Img = Properties.Resources.system_005; ToolClassLibrary.SystemToolClass.SystemTool sc5 = new ToolClassLibrary.SystemToolClass.SystemTool(); sc5.Name = "组策略" ; sc5.Content = Environment.SystemDirectory.ToString() "\\gpedit.msc" ; sc5.Img = Properties.Resources.system_006; ToolClassLibrary.SystemToolClass.SystemTool sc6 = new ToolClassLibrary.SystemToolClass.SystemTool(); sc6.Name = "系统属性" ; sc6.Content = "sysdm.cpl" ; sc6.Img = Properties.Resources.system_007; ToolClassLibrary.SystemToolClass.SystemTool sc7 = new ToolClassLibrary.SystemToolClass.SystemTool(); sc7.Name = "日期和时间" ; sc7.Content = "timedate.cpl" ; sc7.Img = Properties.Resources.system_007; ToolClassLibrary.SystemToolClass.SystemTool sc8 = new ToolClassLibrary.SystemToolClass.SystemTool(); sc8.Name = "声音和音频设备" ; sc8.Content = "mmsys.cpl" ; sc8.Img = Properties.Resources.system_007; ToolClassLibrary.SystemToolClass.SystemTool sc9 = new ToolClassLibrary.SystemToolClass.SystemTool(); sc9.Name = "网络连接" ; sc9.Content = "ncpa.cpl" ; sc9.Img = Properties.Resources.system_007; ToolClassLibrary.SystemToolClass.SystemTool sc10 = new ToolClassLibrary.SystemToolClass.SystemTool(); sc10.Name = "搜索" ; sc10.Content = "搜索" ; sc10.Img = Properties.Resources.system_007; list.Add(sc); list.Add(sc1); list.Add(sc2); list.Add(sc3); list.Add(sc4); list.Add(sc5); list.Add(sc6); list.Add(sc7); list.Add(sc8); list.Add(sc9); list.Add(sc10); return list; } /// <summary> /// 查询用户文件夹工具 /// </summary> /// <returns></returns> private List<ToolClassLibrary.SystemToolClass.SystemTool> BindUserTool() { List<ToolClassLibrary.SystemToolClass.SystemTool> list = new List<ToolClassLibrary.SystemToolClass.SystemTool>(); try { string PicPath = "Files" ; DirectoryInfo di = new DirectoryInfo(PicPath); FileSystemInfo[] fsi = di.GetFileSystemInfos(); foreach (FileSystemInfo item in fsi) { ToolClassLibrary.SystemToolClass.SystemTool sc7 = new ToolClassLibrary.SystemToolClass.SystemTool(); sc7.Name = item.ToString().Remove(item.ToString().LastIndexOf( "." )); sc7.Content = PicPath "\\" item.ToString(); list.Add(sc7); } } catch { } return list; } #endregion #region 点击提建议,跳转到页面 /// <summary> /// 点击提建议,跳转到页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void linkjy_Click( object sender, EventArgs e) { } #endregion #region 点击检测更新 /// <summary> /// 点击检测更新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void linkupdate_Click( object sender, EventArgs e) { MessageBox.Show( "小伟提示:当前已是最新版本。" ); } #endregion #region 皮肤按钮事件 private void picSkin_MouseEnter( object sender, EventArgs e) { ImageFormClass.SetFormImage( this .picSkin, ImageLibrary.Properties.Resource_Png.skin_2011_01_02, ImageLibrary.ImagePoint.skin_2011_01_02); } private void picSkin_MouseLeave( object sender, EventArgs e) { ImageFormClass.SetFormImage( this .picSkin, ImageLibrary.Properties.Resource_Png.skin_2011_01_01, ImageLibrary.ImagePoint.skin_2011_01_01); } /// <summary> /// 点击皮肤按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void picSkin_Click( object sender, EventArgs e) { panelskin.Location = new Point(ImageLibrary.ImagePoint.panelskin[0], ImageLibrary.ImagePoint.panelskin[1]); if (panelskin.Visible == false ) { panelskin.Visible = true ; } else { panelskin.Visible = false ; } } private void picskin_01_Click( object sender, EventArgs e) { BindLab(Color.White, 1); ImageFormClass.SetFormImage( this , ImageLibrary.Properties.Resource_Png.menu2011_01_01); } private void picskin_02_Click( object sender, EventArgs e) { BindLab(Color.Black, 2); ImageFormClass.SetFormImage( this , ImageLibrary.Properties.Resource_Png.menu2011_01_02); } private void picskin_03_Click( object sender, EventArgs e) { BindLab(Color.Black, 3); ImageFormClass.SetFormImage( this , ImageLibrary.Properties.Resource_Png.menu2011_01_03); } #region 给lab字体统一 private void BindLab(Color col, int skin) { labindex.ForeColor = col; labtitle2.ForeColor = col; labtitle3.ForeColor = col; labtitle4.ForeColor = col; labtitle5.ForeColor = col; labtitle6.ForeColor = col; labtitle7.ForeColor = col; linkjy.ForeColor = col; linkupdate.ForeColor = col; //将设置保存到全局变量 ToolClassLibrary.PublicClass.Skin = skin.ToString(); ToolClassLibrary.PublicClass.FoerColor = col; } #endregion private void picskin_01_MouseEnter( object sender, EventArgs e) { picskin_01.Image = Properties.Resources.skin_01_02; } private void picskin_01_MouseLeave( object sender, EventArgs e) { picskin_01.Image = Properties.Resources.skin_01; } private void picskin_02_MouseEnter( object sender, EventArgs e) { picskin_02.Image = Properties.Resources.skin_02_02; } private void picskin_02_MouseLeave( object sender, EventArgs e) { picskin_02.Image = Properties.Resources.skin_02; } private void picskin_03_MouseEnter( object sender, EventArgs e) { picskin_03.Image = Properties.Resources.skin_03_02; } private void picskin_03_MouseLeave( object sender, EventArgs e) { picskin_03.Image = Properties.Resources.skin_03; } #endregion #region 改变窗体透明度 /// <summary> /// 改变窗体透明度时候 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tckback_Scroll( object sender, EventArgs e) { this .Opacity = Convert.ToDouble(tckback.Value) / 100.0; ToolClassLibrary.PublicClass.Diaphaneity = tckback.Value.ToString(); } #endregion #region 数据加载绑定lab /// <summary> /// 数据加载绑定lab /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WindowMenu_Load( object sender, EventArgs e) { BindLabPoint( this .lab_001, ImageLibrary.ImagePoint.lab_001); BindLabPoint( this .lab_002, ImageLibrary.ImagePoint.lab_002); BindLabPoint( this .lab_003, ImageLibrary.ImagePoint.lab_003); BindLabPoint( this .lab_004, ImageLibrary.ImagePoint.lab_004); BindLabPoint( this .lab_005, ImageLibrary.ImagePoint.lab_005); BindLabPoint( this .lab_006, ImageLibrary.ImagePoint.lab_006); BindLabPoint( this .lab_007, ImageLibrary.ImagePoint.lab_007); BindLabPoint( this .lab_008, ImageLibrary.ImagePoint.lab_008); lab_001.Text = ToolClassLibrary.PublicClass.systemwind; lab_002.Text = ToolClassLibrary.PublicClass.systemclq; lab_003.Text = ToolClassLibrary.PublicClass.systemnc; lab_004.Text = ToolClassLibrary.PublicClass.systemxk; lab_005.Text = ToolClassLibrary.PublicClass.systemyp; lab_006.Text = ToolClassLibrary.PublicClass.systemkj; lab_007.Text = ToolClassLibrary.PublicClass.systemaz; lab_008.Text = "查看详细" ; CheckForIllegalCrossThreadCalls = false ; TreeNode tn1 = new TreeNode( "Windows" ); TreeNode tn2 = new TreeNode( "CPU与主板" ); TreeNode tn3 = new TreeNode( "视频设备" ); TreeNode tn4 = new TreeNode( "音频设备" ); TreeNode tn5 = new TreeNode( "存储设备" ); TreeNode tn6 = new TreeNode( "网络设备" ); TreeNode tn8 = new TreeNode( "总线与接口" ); TreeNode tn9 = new TreeNode( "输入设备" ); TreeNode tn10 = new TreeNode( "打印与传真" ); #region Windows父节点的子节点 tn1.Nodes.Add( "Windows信息" ); tn1.Nodes.Add( "Windows用户" ); tn1.Nodes.Add( "用户组别" ); tn1.Nodes.Add( "当前进程" ); tn1.Nodes.Add( "系统服务" ); tn1.Nodes.Add( "系统驱动" ); #endregion #region CPU与主板父节点的子节点 tn2.Nodes.Add( "中央处理器" ); tn2.Nodes.Add( "主板" ); tn2.Nodes.Add( "BIOS信息" ); #endregion #region 视频设备父节点的子节点 tn3.Nodes.Add( "显卡" ); #endregion #region 存储设备父节点的子节点 tn5.Nodes.Add( "物理内存" ); tn5.Nodes.Add( "磁盘" ); #endregion tn6.Nodes.Add( "网络适配器" ); tn6.Nodes.Add( "网络协议" ); tn8.Nodes.Add( "串口" ); tn8.Nodes.Add( "IDE控制器" ); tn8.Nodes.Add( "软驱控制器" ); tn8.Nodes.Add( "USB控制器" ); tn8.Nodes.Add( "SCSI控制器" ); tn8.Nodes.Add( "PCMCIA卡控制器" ); tn8.Nodes.Add( "1394控制器" ); tn8.Nodes.Add( "即插即用设备" ); tn9.Nodes.Add( "鼠标" ); tn9.Nodes.Add( "键盘" ); paneltree1.Nodes.Add(tn1); paneltree1.Nodes.Add(tn10); paneltree1.Nodes.Add(tn2); paneltree1.Nodes.Add(tn3); paneltree1.Nodes.Add(tn4); paneltree1.Nodes.Add(tn5); paneltree1.Nodes.Add(tn6); paneltree1.Nodes.Add(tn8); paneltree1.Nodes.Add(tn9); } #endregion #region 绑定控件单一的位置方法 private void BindLabPoint(Control col, int [] sizes) { col.Location = new Point(sizes[0], sizes[1]); } private void BindControlPoint(Control col, int [] sizes) { col.Location = new Point(sizes[0], sizes[1]); col.Width = sizes[2]; col.Height = sizes[3]; } #endregion /// <summary> /// 查看详细 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lab_008_Click( object sender, EventArgs e) { panelindex.Visible = false ; panelindex_1.Visible = true ; } /// <summary> /// 点击标题菜单,对panel的显示 /// </summary> /// <param name="p"></param> private void BindIsDisplay( int p) { panelindex.Visible = false ; panelindex_1.Visible = false ; panel2.Visible = false ; panel3.Visible = false ; panel4.Visible = false ; panel5.Visible = false ; panel6.Visible = false ; panel7.Visible = false ; switch (p) { case 1: { panelindex.Visible = true ; } break ; case 2: { panel2.Visible = true ; } break ; case 3: { panel3.Visible = true ; } break ; case 4: { panel4.Visible = true ; } break ; case 5: { panelindex_1.Visible = true ; } break ; case 6: { panel6.Visible = true ; } break ; case 7: { panel7.Visible = true ; } break ; default : { } break ; } } #region 硬件检测方法 public string selectTxt; private void GetInfo() { Input pc = new Input(); switch (selectTxt) { case "Windows信息" : pc.getInfo1(panellistView1); break ; case "Windows用户" : pc.InsertInfo( "Win32_UserAccount" , ref panellistView1, true ); break ; case "用户组别" : pc.InsertInfo( "Win32_Group" , ref panellistView1, true ); break ; case "当前进程" : pc.InsertInfo( "Win32_Process" , ref panellistView1, true ); break ; case "系统服务" : pc.InsertInfo( "Win32_Service" , ref panellistView1, true ); break ; case "系统驱动" : pc.InsertInfo( "Win32_SystemDriver" , ref panellistView1, true ); break ; case "中央处理器" : pc.InsertInfo( "Win32_Processor" , ref panellistView1, true ); break ; case "主板" : pc.InsertInfo( "Win32_BaseBoard" , ref panellistView1, true ); break ; case "BIOS信息" : pc.InsertInfo( "Win32_BIOS" , ref panellistView1, true ); break ; case "显卡" : pc.InsertInfo( "Win32_VideoController" , ref panellistView1, true ); break ; case "音频设备" : pc.InsertInfo( "Win32_SoundDevice" , ref panellistView1, true ); break ; case "物理内存" : pc.InsertInfo( "Win32_PhysicalMemory" , ref panellistView1, true ); break ; case "磁盘" : pc.InsertInfo( "Win32_LogicalDisk" , ref panellistView1, true ); break ; case "网络适配器" : pc.InsertInfo( "Win32_NetworkAdapter" , ref panellistView1, true ); break ; case "网络协议" : pc.InsertInfo( "Win32_NetworkProtocol" , ref panellistView1, true ); break ; case "打印与传真" : pc.InsertInfo( "Win32_Printer" , ref panellistView1, true ); break ; case "键盘" : pc.InsertInfo( "Win32_Keyboard" , ref panellistView1, true ); break ; case "鼠标" : pc.InsertInfo( "Win32_PointingDevice" , ref panellistView1, true ); break ; case "串口" : pc.InsertInfo( "Win32_SerialPort" , ref panellistView1, true ); break ; case "IDE控制器" : pc.InsertInfo( "Win32_IDEController" , ref panellistView1, true ); break ; case "软驱控制器" : pc.InsertInfo( "Win32_FloppyController" , ref panellistView1, true ); break ; case "USB控制器" : pc.InsertInfo( "Win32_USBController" , ref panellistView1, true ); break ; case "SCSI控制器" : pc.InsertInfo( "Win32_SCSIController" , ref panellistView1, true ); break ; case "PCMCIA卡控制器" : pc.InsertInfo( "Win32_PCMCIAController" , ref panellistView1, true ); break ; case "1394控制器" : pc.InsertInfo( "Win32_1394Controller" , ref panellistView1, true ); break ; case "即插即用设备" : pc.InsertInfo( "Win32_PnPEntity" , ref panellistView1, true ); break ; } } /// <summary> /// 点击查看详细硬件信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void treeView1_AfterSelect( object sender, TreeViewEventArgs e) { panellistView1.Items.Clear(); selectTxt = paneltree1.SelectedNode.Text; GetInfo(); } #endregion #region 注册表备份还原 /// <summary> /// 点击备份注册表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click( object sender, EventArgs e) { try { System.Diagnostics.Process myProcess = new System.Diagnostics.Process(); myProcess.StartInfo.FileName = "cmd.exe" ; myProcess.StartInfo.UseShellExecute = false ; myProcess.StartInfo.RedirectStandardInput = true ; myProcess.StartInfo.RedirectStandardOutput = true ; myProcess.StartInfo.RedirectStandardError = true ; myProcess.StartInfo.CreateNoWindow = true ; myProcess.Start(); string pp = "regedit /e " Environment.SystemDirectory.ToString() "\\backup.reg" ; myProcess.StandardInput.WriteLine(pp); MessageBox.Show( "注册表备份成功" , "提示" , MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { System.Diagnostics.Process myProcess = new System.Diagnostics.Process(); myProcess.StartInfo.FileName = "cmd.exe" ; myProcess.StartInfo.UseShellExecute = false ; myProcess.StartInfo.RedirectStandardInput = true ; myProcess.StartInfo.RedirectStandardOutput = true ; myProcess.StartInfo.RedirectStandardError = true ; myProcess.StartInfo.CreateNoWindow = true ; myProcess.Start(); string pp = "regedit /e " Environment.SystemDirectory.ToString() "\\backup.reg" ; myProcess.StandardInput.WriteLine(pp); } } /// <summary> /// 点击还原注册表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click( object sender, EventArgs e) { try { System.Diagnostics.Process myProcess = new System.Diagnostics.Process(); myProcess.StartInfo.FileName = "cmd.exe" ; myProcess.StartInfo.UseShellExecute = false ; myProcess.StartInfo.RedirectStandardInput = true ; myProcess.StartInfo.RedirectStandardOutput = true ; myProcess.StartInfo.RedirectStandardError = true ; myProcess.StartInfo.CreateNoWindow = true ; myProcess.Start(); string pp = "regedit /s " Environment.SystemDirectory.ToString() "\\backup.reg" ; myProcess.StandardInput.WriteLine(pp); MessageBox.Show( "注册表还原成功" , "提示" , MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { System.Diagnostics.Process myProcess = new System.Diagnostics.Process(); myProcess.StartInfo.FileName = "cmd.exe" ; myProcess.StartInfo.UseShellExecute = false ; myProcess.StartInfo.RedirectStandardInput = true ; myProcess.StartInfo.RedirectStandardOutput = true ; myProcess.StartInfo.RedirectStandardError = true ; myProcess.StartInfo.CreateNoWindow = true ; myProcess.Start(); string pp = "regedit /s " Environment.SystemDirectory.ToString() "\\backup.reg" ; myProcess.StandardInput.WriteLine(pp); } } #endregion #region 系统优化 /// <summary> /// 点击优化系统 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click( object sender, EventArgs e) { for ( int i = 0; i < Panel_04_listView1.Items.Count; i ) { if (Panel_04_listView1.Items[i].Checked == true ) { SetRegValue(Panel_04_listView1.Items[i].Text); } } MessageBox.Show( "优化系统成功" , "提示" , MessageBoxButtons.OK, MessageBoxIcon.Information); } /// <summary> /// 系统优化方法 /// </summary> /// <param name="str"></param> private void SetRegValue( string str) { RegistryKey reg; switch (str) { case "开机和关机" : reg = Registry.CurrentUser; reg = reg.CreateSubKey( "SYSTEM\\CurrentControlSet\\Control" ); reg.SetValue( "WaitToKillServiceTimeout" , 1000); reg.Close(); break ; case "菜单" : reg = Registry.CurrentUser; reg = reg.CreateSubKey( "Control Panel\\Desktop" ); reg.SetValue( "MenuShowDelay" , 40); reg.Close(); break ; case "程序" : reg = Registry.LocalMachine; reg = reg.CreateSubKey( "SYSTEM\\CurrentControlSet\\Control\\FileSystem" ); reg.SetValue( "ConfigFileAllocSize" , "dword:000001f4" ); reg.Close(); break ; case "加快预读能力" : reg = Registry.LocalMachine; reg = reg.CreateSubKey( "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management\\PrefetchParameters" ); reg.SetValue( "EnablePrefetcher" , 4, RegistryValueKind.DWord); reg.Close(); break ; case "自动清除内存中多余的DLL资料" : reg = Registry.LocalMachine; reg = reg.CreateSubKey( "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer" ); reg.SetValue( "AlwaysUnloadDLL" , 1, RegistryValueKind.DWord); reg.Close(); break ; case "禁止远程修改注册表" : reg = Registry.LocalMachine; reg = reg.CreateSubKey( "SYSTEM\\CurrentControlSet\\Control\\SecurePipeServers\\winreg" ); reg.SetValue( "RemoteRegAccess" , 1, RegistryValueKind.DWord); reg.Close(); break ; case "禁用系统还原" : reg = Registry.LocalMachine; reg = reg.CreateSubKey( "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore" ); reg.SetValue( "DisableSR" , 1, RegistryValueKind.DWord); reg.Close(); break ; case "在桌面上显示系统版本" : reg = Registry.CurrentUser; reg = reg.CreateSubKey( "Control Panel\\Desktop" ); reg.SetValue( "PaintDesktopVersion" , 1, RegistryValueKind.DWord); reg.Close(); break ; case "关机时自动关闭停止响应的程序" : reg = Registry.CurrentUser; reg = reg.CreateSubKey( "Control Panel\\Desktop" ); reg.SetValue( "AutoEndTasks" , 1, RegistryValueKind.DWord); reg.Close(); break ; } } #endregion #region 进程管理 private void getProcessInfo() { try { listView1.Items.Clear(); Process[] MyProcesses = Process.GetProcesses(); string [] Minfo = new string [6]; foreach (Process MyProcess in MyProcesses) { Minfo[0] = MyProcess.ProcessName; Minfo[1] = MyProcess.Id.ToString(); Minfo[2] = MyProcess.Threads.Count.ToString(); Minfo[3] = MyProcess.BasePriority.ToString(); Minfo[4] = Convert.ToString(MyProcess.WorkingSet / 1024) "K" ; Minfo[5] = Convert.ToString(MyProcess.VirtualMemorySize / 1024) "K" ; ListViewItem lvi = new ListViewItem(Minfo, "process" ); listView1.Items.Add(lvi); // tsslProcessCount.Text = "总进程数:" listView1.Items.Count.ToString(); } } catch { } } private void getWindowsInfo() { try { listView2.Items.Clear(); Process[] MyProcesses = Process.GetProcesses(); string [] Minfo = new string [6]; foreach (Process MyProcess in MyProcesses) { if (MyProcess.MainWindowTitle.Length > 0) { Minfo[0] = MyProcess.MainWindowTitle; Minfo[1] = MyProcess.Id.ToString(); Minfo[2] = MyProcess.ProcessName; Minfo[3] = MyProcess.StartTime.ToString(); ListViewItem lvi = new ListViewItem(Minfo, "process" ); listView2.Items.Add(lvi); } } } catch { } } private void 刷新ToolStripMenuItem_Click( object sender, EventArgs e) { getProcessInfo(); } private void 结束进程ToolStripMenuItem_Click( object sender, EventArgs e) { try { if (MessageBox.Show( "警告:终止进程会导致不希望发生的结果,\r包括数据丢失和系统不稳定。在被终止前,\r进程将没有机会保存其状态和数据。确实\r想终止该进程吗?" , "任务管理器警告" , MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { string ProcessName = listView1.SelectedItems[0].Text; Process[] MyProcess = Process.GetProcessesByName(ProcessName); MyProcess[0].Kill(); getProcessInfo(); } else { } } catch { string ProcessName = listView1.SelectedItems[0].Text; Process[] MyProcess1 = Process.GetProcessesByName(ProcessName); Process MyProcess = new Process(); //设定程序名 MyProcess.StartInfo.FileName = "cmd.exe" ; //关闭Shell的使用 MyProcess.StartInfo.UseShellExecute = false ; //重定向标准输入 MyProcess.StartInfo.RedirectStandardInput = true ; //重定向标准输出 MyProcess.StartInfo.RedirectStandardOutput = true ; //重定向错误输出 MyProcess.StartInfo.RedirectStandardError = true ; //设置不显示窗口 MyProcess.StartInfo.CreateNoWindow = true ; //执行强制结束命令 MyProcess.Start(); MyProcess.StandardInput.WriteLine( "ntsd -c q -p " (MyProcess1[0].Id).ToString()); MyProcess.StandardInput.WriteLine( "Exit" ); getProcessInfo(); } } private void 刷新ToolStripMenuItem1_Click( object sender, EventArgs e) { getWindowsInfo(); } private void 终止进程ToolStripMenuItem_Click( object sender, EventArgs e) { try { if (MessageBox.Show( "警告:终止进程会导致不希望发生的结果,\r包括数据丢失和系统不稳定。在被终止前,\r进程将没有机会保存其状态和数据。确实\r想终止该进程吗?" , "任务管理器警告" , MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { string ProcessName = listView2.SelectedItems[0].SubItems[2].Text.Trim(); Process[] MyProcess = Process.GetProcessesByName(ProcessName); MyProcess[0].Kill(); listView2.Items.Clear(); getWindowsInfo(); } else { } } catch { MessageBox.Show( "请选择终止的进程" ); } } Input pc = new Input(); private void listView1_ColumnClick( object sender, ColumnClickEventArgs e) { listView1.ListViewItemSorter = new ListViewItemComparer(e.Column); if (listView1.Sorting == SortOrder.Ascending) { listView1.Sorting = SortOrder.Descending; } else { listView1.Sorting = SortOrder.Ascending; } } #endregion /// <summary> /// 双击状态栏图标 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void notifyIcon1_DoubleClick( object sender, EventArgs e) { if ( this .Visible == false ) { this .Visible = true ; return ; } if ( this .WindowState == FormWindowState.Minimized) { this .WindowState = FormWindowState.Normal; return ; } else { this .WindowState = FormWindowState.Minimized; return ; } } private void 退出ToolStripMenuItem_Click( object sender, EventArgs e) { if (DialogResult.Yes == MessageBox.Show( "真的要退出吗!退出后您的系统将会面临着威胁!" , "警告!" , MessageBoxButtons.YesNo, MessageBoxIcon.Error)) { this .Close(); this .Dispose(); } } /// <summary> /// 点击click事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBox1_Click( object sender, EventArgs e) { DialogResult res = openFileDialog1.ShowDialog(); if (res == DialogResult.OK) { textContent.Text = openFileDialog1.FileName; } } private void textImg_Click( object sender, EventArgs e) { DialogResult res = openFileDialog2.ShowDialog(); if (res == DialogResult.OK) { textImg.Text = openFileDialog2.FileName; pic_yulan.Image = Image.FromFile(openFileDialog2.FileName); } } /// <summary> /// 点击保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pictureBox1_Click( object sender, EventArgs e) { SystemTool tool = new SystemTool(); tool.Name = textName.Text; tool.Content = textContent.Text; tool.Img = Image.FromFile(openFileDialog2.FileName); PublicClass.list.Add(tool); Input.ObjectSerialize(PublicClass.list, Application.StartupPath "\\tool.dll" ); textName.Text = "" ; textContent.Text = "" ; MessageBox.Show( "添加完成!" ); } private void 删除ToolStripMenuItem_Click( object sender, EventArgs e) { } /// <summary> /// 点击添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void linkLabel1_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e) { panel_AddUser.Show(); panel_rightClick.Visible = false ; panel_AddUser.Dock = DockStyle.Fill; } /// <summary> /// 点击删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void link_delete_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e) { List<SystemTool> list1 = new List<SystemTool>(); list1.AddRange(PublicClass.list); try { SystemTool item1 = new SystemTool(); foreach (SystemTool item in PublicClass.list) { if (item.Content == link_delete.Tag.ToString()) { list1.Remove(item); item1 = item; } } PublicClass.list.Remove(item1); Input.ObjectSerialize(list1, Application.StartupPath "\\tool.dll" ); bindInit(); MessageBox.Show( "删除成功!" ); } catch { MessageBox.Show( "删除失败!" ); } } private void bindInit() { panel_rightClick.Visible = false ; List<Control> co = new List<Control>(); foreach (Control item in panel7.Controls) { if (item.Name.Contains( "lab_xt_0" ) || item.Name.Contains( "pic_xt_0" )) { co.Add(item); } } foreach (Control item1 in co) { panel7.Controls.Remove(item1); } if (File.Exists(Application.StartupPath "\\tool.dll" )) { PublicClass.list = (List<SystemTool>)Input.ObjectDeSerialize(Application.StartupPath "\\tool.dll" ); } panel_AddUser.Visible = false ; //加载数据 BIndpanel7(); BIndisMouseEnterByLeave( this .title_but7, ImageLibrary.Properties.Resource_Png.titlebut_07_2011_01_01, ImageLibrary.ImagePoint.titlebut_07_2011_01_01, this .labtitle7); BindTitle(7); BindIsDisplay(7); } /// <summary> /// 调整控件大小 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WindowMenu_Resize( object sender, EventArgs e) { } } #region 对ListView控件中的项进行排序 /// <summary> /// 对ListView控件中的项进行排序 /// </summary> class ListViewItemComparer : IComparer { private int col; public ListViewItemComparer() { col = 0; } public ListViewItemComparer( int column) { col = column; } public int Compare( object x, object y) { return String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text); } } #endregion } |
好例子网口号:伸出你的我的手 — 分享!
网友评论
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)