找传奇、传世资源到传世资源站!

C# 仿QQ管家UI以及功能源码,效果不错,值得收藏

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboard
from clipboard
from clipboard
from clipboard
from clipboard
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) { System.Diagnostics.Process.Start("http://hi.baidu.com/xiaowei0705/"); } #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}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复