C#系统编程:用C#设计Win运用程序模板

通常windows应用程序都有相似的特征:控件、菜单、工具条、状态栏等等。每次我们开始作一个新的windows应用程序时都是以相同的事情开始:建立项目,添加控件和事件处理器。如果我们有一个模板,那么我们就可以节约大量的时间了。

  在介绍如何建立模板的过程中,将涉及大量的微软.net framework类库的基本知识。如果你没有使用集成开发环境那么本文介绍的模板对你将非常有用,如果你使用了visual studio.net这样的集成开发环境你也可以从中了解控件的工作方式,这对你也是很有用的。

  写一个windows应用程序总是从下面的几个步骤开始:

   1、创建一个窗体
   2、给窗体添加控件
   3、添加菜单和菜单项,并绑定到窗体上
   4、创建工具条
   5、添加状态栏
   6、添加事件处理器

  在windows应用程序开发中,你不可能完全跳过这些步骤,你可以对他作些修改,但不可能完全跳过。下面是完全的模板图:


--------------图1 -----------



  创建窗体

  在.Net FrameWork程序设计中,窗体总是System.Windows.Forms.Form类的子类,他继承聊着各类的全部特征,你甚至不用添加任何一行代码就可以创建window窗体了。现在我们创建一个form类的子类myapp,需要注意的是在说明继承时使用冒号:。


using System.Windows.Forms;

public class MyWinApp: Form {

}


  与其他程序相似,我们需要一个main()的主方法作为应用程序的入口。在main()中使用System.Windows.Forms的run方法来开始应用程序和显示窗体。run方法有三种重载方式,对于windows应用程序,我们采取重载一个窗体对象的方式:


public static void Main() {
MyWinApp form = new MyWinApp();
Application.Run(form);
}

作为选择,可以在main()方法中将两行代码写成一行:

public static void Main() {
Application.Run(new MyWinApp());
}


  设置属性

  一旦有了窗体,就可以设置它的属性(象高度、宽度、标题等)并指定一个象图1那样的图标,可以通过代码或从构造器重调用一个方法来完成这个设置。在list1中有一个方法InitializeComponent,可以将初始化代码写入其中。

  使用width和height属性设置宽度和高度

this.Width = 400;
this.Height = 300;


  使用窗体的text属性设置标题

this.Text = \"My Windows Application\";

  设置图标

  如果未作说明,windows应用程序将显示一个缺省图标,可以修改这个图标,方法是设置窗体的icon属性,这个属性接受一个System.Drawing.Icon对象。Icon类有几个可以用于初始化Icon对象的构造函数,需要说明的是最好提供.ico文件的完全路径。

this.Icon = new Icon(imageFolder + \"applicationLogo.ico\");

  这里 imageFolder是一个静态域,用于指示icon文件的目录,imageFolder的定义如下:

static String imageFolder = \"Images\" +

Path.DirectorySeparatorChar.ToString();

  这告诉应用程序icon文件在应用程序的image目录下,这里使用了System.IO.Path 类的DirectorySeparatorChar属性获得操作系统用于分隔目录和父目录的分隔符,在这里没有使用\"/\",这是因为对于windows操作系统这是正确的,但对于linux和unix则不然。这也是为了证明模板对于其他操作系统也是方便的。

  窗体的位置

  使窗体居中时非常有用的,要达到这个目的,需要使用StartPosition属性,并将FormStartPosition 的一个成员赋给他。

this.StartPosition = FormStartPosition.CenterScreen;

  当然也可以用form类的CenterToScreen方法是窗体居中,但这个方法不能直接使用。

this.CenterToScreen();

  form类还有其他一些让人感兴趣的属性和方法,这里列出了其中的部分:

   1、设置Opacity 属性创建一个透明或半透明的窗体

   2、设置modal属性使窗体为模式的或非模式的

   3、通过BackColor属性改变窗体的背景颜色

   4、将TopMost属性设置为true,以确定窗体在其他所有非最顶部窗体之上



  给窗体添加控件

  windows控件均继承自System.Windows.Forms.Control类,control类处理用户输入、安全等,他给窗体的控件提供了一个windows句柄,以及一些重要的属性,如Name, Enabled, Text, BackColor, Left, Top, Size, Location, Visible, Width, 和 Height。

  System.Windows.Forms名称空间提供了12个控件,每一个控件都有它自己的属性和特征,所以在篇文章中我们不可能全部讨论。给窗体添加控减非常容易,下面的代码给窗体添加了三个控件,分别是:Label, Button, 和TreeView。

Label label;
Button button;
TreeView tree;

  为了简便,可以在声明的同时实例化这些对象。

Label label = new Label();
Button button = new Button();
TreeView tree = new TreeView();

  然后在InitializeComponent方法中设置这些控件的属性,尤其是设置控件的大小和在窗体中的位置,对于大小可以使用width和height属性,比如treeview控件的大小可以使用下面的属性:

tree.Width = 100;
tree.Height = 100;

  确定控件的位置可以使用控件的left和top属性,这两个属性决定了控件的左上角的位置,就像下面的语句决定了treeview的位置:

tree.Top = 40;
tree.Left = 20;

  当然你也可以使用更简单的Location属性,将System.Drawing.Point结构的实例赋给他。我们用这种方法确定Label和Button的位置。

label.Location = new Point(220, 40);
button.Location = new Point(220, 80);

  下一步就是要使控件在窗体上可见。使用Form.ControlCollection类的add方法将每个控件添加到窗体的ControlCollection中,ControlCollection可以使用窗体的控件属性访问。

this.Controls.Add(label);
this.Controls.Add(button);
this.Controls.Add(tree);




  添加菜单和菜单项

  要找到没有菜单的windows应用程序非常困难,菜单使访问应用程序的功能变得很简单,在大多数环境下可以最小的使用控件。菜单比控件占用更少的空间,同时使应用程序显得更有组织。

  在System.Windows.Forms名称空间中,所有与菜单相关的控件都是menu类的子类。menu是一个抽象类,你不能直接实例化,menu类有三个子类:

ContextMenu
MainMenu
MenuItem

  ContextMenu类表示快捷菜单,在控件或窗体区域点击鼠标右键时显示。快捷菜单常用于组合窗体mainmenu类的菜单项给出应用程序的上下文,这对于用户时非常有用的。

  MainMenu表示传统的位于窗体顶部的菜单,你可以把它看成窗体菜单结构的容器。一个菜单是由MenuItem表示的菜单项组成的,对于应用程序而言每一个菜单项是一个命令或其它子菜单项的父菜单。form类都有一个menu属性,采用将mainmenu对象赋给menu属性的方式将mainmenu对象绑定到窗体。

  在这个模板中,我们没有使用ContextMenu类,但我们示范了如何使用MainMenu和MenuItem类。我们首先需要在窗体中添加一个菜单,给窗体添加一个MainMenu对象。

MainMenu mainMenu = new MainMenu();

  现在MainMenu对象中什么都没有,下面我们给他添加一个MenuItem对象。在List1中主菜单称为fileMenuItem,它的text属性是&File,&表示他后面的字母带下划线,是该菜单的快捷键。通过使用Menu对象的MenuItemCollection的add方法为MainMenu添加一个或几个MenuItem,这个集合可以通过menu类的MenuItems属性访问。

MenuItem fileMenuItem = new MenuItem();
mainMenu.MenuItems.Add(fileMenuItem);

  我们在fileMenuItem 菜单项中还添加了其它MenuItem,这些MenuItem是fileMenuItem的子菜单。你也可以给子菜单添加子菜单。图2显示了菜单的等级结构。


---------图2---------

  菜单项的声明如下:

MenuItem fileNewMenuItem;
MenuItem fileOpenMenuItem;
MenuItem fileSaveMenuItem;
MenuItem fileSaveAsMenuItem;
MenuItem fileMenuWithSubmenu;
MenuItem submenuMenuItem;
MenuItem fileExitMenuItem;


  MenuItem类有几个构造函数,使用这些构造函数实例化你的 MenuItem对象,并添加一个事件处理器。

// the following constructor is the same as:
// menuItem fileNewMenuItem = new MenuItem();
// fileNewMenuItem.Text = \"&New\";
// fileNewMenuItem.Shortcut = Shortcut.CtrlN;
// fileNewMenuItem.Click += new
// System.EventHandler(this.fileNewMenuItem_Click);
fileNewMenuItem = new MenuItem(\"&New\",
new System.EventHandler(this.fileNewMenuItem_Click), Shortcut.CtrlN);

fileOpenMenuItem = new MenuItem(\"&Open\",
new System.EventHandler(this.fileOpenMenuItem_Click), Shortcut.CtrlO);

fileSaveMenuItem = new MenuItem(\"&Save\",
new System.EventHandler(this.fileSaveMenuItem_Click), Shortcut.CtrlS);

fileSaveAsMenuItem = new MenuItem(\"Save &As\",
new System.EventHandler(this.fileSaveAsMenuItem_Click));

fileMenuWithSubmenu = new MenuItem(\"&With Submenu\");

submenuMenuItem = new MenuItem(\"Su&bmenu\",
new System.EventHandler(this.submenuMenuItem_Click));

fileExitMenuItem = new MenuItem(\"E&xit\",
new System.EventHandler(this.fileExitMenuItem_Click));


Event handling is discussed further in the section \"Adding Event Handlers.\"

As mentioned, the menu items are added to the fileMenuItem control.


fileMenuItem.MenuItems.Add(fileNewMenuItem);
fileMenuItem.MenuItems.Add(fileOpenMenuItem);
fileMenuItem.MenuItems.Add(fileSaveMenuItem);
fileMenuItem.MenuItems.Add(fileSaveAsMenuItem);
fileMenuItem.MenuItems.Add(fileMenuWithSubmenu);
fileMenuWithSubmenu.MenuItems.Add(submenuMenuItem);
fileMenuItem.MenuItems.Add(\"-\"); // add a separator
fileMenuItem.MenuItems.Add(fileExitMenuItem);

  注意在菜单项之间可以创建一个分隔符,方法是使用menu类的MenuItems集合的add方法。上面的例子中使用的分隔符是\"-\"。



  创建工具条

  为了使应用程序的界面更友好,可以在窗体中添加一个工具条。工具条由System.Windows.Forms.ToolBar类描述。窗体中可有多个工具条,工具条中包含了一个或多个ToolBarButton类描述的按钮,可以在每个按钮中插入图像或图标,要达到这个目的你需要一个ImageList控件作为图像容器。

ImageList imageList = new ImageList();

  对于每个图像文件首先要实例化为image对象,然后将这些图像添加到ImageList控件中,Image和Bitmap类可以在System.Drawing名称空间中找到。

Image newFileImage = new Bitmap(imageFolder + \"newFile.bmp\");
Image openFileImage = new Bitmap(imageFolder + \"openFile.gif\");
Image saveFileImage = new Bitmap(imageFolder + \"saveFile.bmp\");
Image printImage = new Bitmap(imageFolder + \"print.gif\");
.
.
.
imageList.Images.Add(newFileImage);
imageList.Images.Add(openFileImage);
imageList.Images.Add(saveFileImage);
imageList.Images.Add(printImage);


  注意你可以使用Images集合的add方法将image对象加入到imagelist控件中。现在为将这些图加入到控件中,必须将ImageList控件赋给ToolBar的ImageList属性。

toolBar.ImageList = imageList;

  然后将ImageList控件中的图像赋给工具按钮的ImageIndex属性。

newToolBarButton.ImageIndex = 0;
openToolBarButton.ImageIndex = 1;
saveToolBarButton.ImageIndex = 2;
printToolBarButton.ImageIndex = 3;


  象菜单项一样,现在必须把工具按钮加入到工具条中。

toolBar.Buttons.Add(separatorToolBarButton);
toolBar.Buttons.Add(newToolBarButton);
toolBar.Buttons.Add(openToolBarButton);
toolBar.Buttons.Add(saveToolBarButton);
toolBar.Buttons.Add(separatorToolBarButton);
toolBar.Buttons.Add(printToolBarButton);

  最后将工具条加入到窗体中。

this.Controls.Add(toolBar);

  添加状态条

  状态条由System.Windows.Forms.StatusBar描述,它提供了定制控件的外观的属性,状态条由StatusBarPanel对象组成,在我们的模板中状态条有两个嵌套板:

StatusBar statusBar = new StatusBar();
StatusBarPanel statusBarPanel1 = new StatusBarPanel();
StatusBarPanel statusBarPanel2 = new StatusBarPanel();


  状态条和状态跳上的嵌套板由下面的代码设置:

statusBarPanel1.BorderStyle = StatusBarPanelBorderStyle.Sunken;
statusBarPanel1.Text = \" ress F1 for Help\";
statusBarPanel1.AutoSize = StatusBarPanelAutoSize.Spring;
statusBarPanel2.BorderStyle = StatusBarPanelBorderStyle.Raised;
statusBarPanel2.ToolTipText = System.DateTime.Now.ToShortTimeString();
statusBarPanel2.Text = System.DateTime.Today.ToLongDateString();
statusBarPanel2.AutoSize = StatusBarPanelAutoSize.Contents;
statusBar.ShowPanels = true;
statusBar.Panels.Add(statusBarPanel1);
statusBar.Panels.Add(statusBarPanel2);

   同样我们需要将状态条添加到窗体中:

this.Controls.Add(statusBar);

  事件处理器

  在windows程序设计中添加事件处理器是最重要的任务。事件处理器保证了程序与用户交互,同时完成其他重要的功能。在c#中你可以给控件和菜单事件添加事件处理器以俘获你想处理的事件,下面的代码给Button控件的click事件设计了一个事件处理器:

button.Click += new System.EventHandler(this.button_Click);

button_Click事件处理器必须被处理:

private void button_Click(Object sender, System.EventArgs e) {
MessageBox.Show(\"Thank you.\", \"The Event Information\");
}


  MenuItem 对象在实例化的同时可以给赋以一个事件处理器:

fileNewMenuItem = new MenuItem(\"&New\",
new System.EventHandler(this.fileNewMenuItem_Click), Shortcut.CtrlN);

fileOpenMenuItem = new MenuItem(\"&Open\",
new System.EventHandler(this.fileOpenMenuItem_Click), Shortcut.CtrlO);

fileSaveMenuItem = new MenuItem(\"&Save\",
new System.EventHandler(this.fileSaveMenuItem_Click), Shortcut.CtrlS);

fileSaveAsMenuItem = new MenuItem(\"Save &As\",
new System.EventHandler(this.fileSaveAsMenuItem_Click));

fileMenuWithSubmenu = new MenuItem(\"&With Submenu\");

submenuMenuItem = new MenuItem(\"Su&bmenu\",
new System.EventHandler(this.submenuMenuItem_Click));

fileExitMenuItem = new MenuItem(\"E&xit\",
new System.EventHandler(this.fileExitMenuItem_Click));

  你不能给工具按钮指派一个事件处理器,但可以给工具条指派一个事件处理器:

toolBar.ButtonClick += new

ToolBarButtonClickEventHandler(this.toolBar_ButtonClick);

protected void toolBar_ButtonClick(Object sender, ToolBarButtonClickEventArgs

e) {

// Evaluate the Button property to determine which button was clicked.
switch (toolBar.Buttons.IndexOf(e.Button)) {
case 1:
MessageBox.Show(\"Second button.\", \"The Event Information\");
break;
case 2:
MessageBox.Show(\"third button\", \"The Event Information\");
break;
case 3:
MessageBox.Show(\"fourth button.\", \"The Event Information\");
break;
}
}


  例子中也给窗体的close事件设计了一个事件处理器,通过重载OnClosing方法你可以接收用户点击窗体的X按钮,这样你可以取消关闭事件:

protected override void OnClosing(CancelEventArgs e) {
MessageBox.Show(\"Exit now.\", \"The Event Information\");
}


  现在我们的模板就完成了,你可以使用他开始你的WINDOWS应用程序设计。



  附录 Listing 1. C# Windows 应用程序模板

/*
to compile this source file, type
csc MyWinApp.cs
*/

using System;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
using System.ComponentModel;

public class MyWinApp: Form {

Label label = new Label();
Button button = new Button();
TreeView tree = new TreeView();
ImageList imageList = new ImageList();
static String imageFolder = \"Images\" +

Path.DirectorySeparatorChar.ToString();

// -------------- Images declarations ------------------------------------
Image newFileImage = new Bitmap(imageFolder + \"newFile.bmp\");
Image openFileImage = new Bitmap(imageFolder + \"openFile.gif\");
Image saveFileImage = new Bitmap(imageFolder + \"saveFile.bmp\");
Image printImage = new Bitmap(imageFolder + \"print.gif\");

// -------------- End of Images declaration

------------------------------------

// -------------- menu ------------------------------------
MainMenu mainMenu = new MainMenu();

MenuItem fileMenuItem = new MenuItem();
MenuItem fileNewMenuItem;
MenuItem fileOpenMenuItem;
MenuItem fileSaveMenuItem;
MenuItem fileSaveAsMenuItem;
MenuItem fileMenuWithSubmenu;
MenuItem submenuMenuItem;
MenuItem fileExitMenuItem;

// -------------- End of menu ------------------------------------

// -------------- Toolbar ------------------------------------
ToolBar toolBar = new ToolBar();
ToolBarButton separatorToolBarButton = new ToolBarButton();
ToolBarButton newToolBarButton = new ToolBarButton();
ToolBarButton openToolBarButton = new ToolBarButton();
ToolBarButton saveToolBarButton = new ToolBarButton();
ToolBarButton printToolBarButton = new ToolBarButton();

// -------------- End of Toolbar ------------------------------------

// -------------- StatusBar ------------------------------------
StatusBar statusBar = new StatusBar();

StatusBarPanel statusBarPanel1 = new StatusBarPanel();
StatusBarPanel statusBarPanel2 = new StatusBarPanel();

// -------------- End of StatusBar ------------------------------------


public MyWinApp() {
InitializeComponent();
}

private void InitializeComponent() {
this.Text = \"My Windows Application\";
this.Icon = new Icon(imageFolder + \"applicationLogo.ico\");
this.Width = 400;
this.Height = 300;
this.StartPosition = FormStartPosition.CenterScreen;

imageList.Images.Add(newFileImage);
imageList.Images.Add(openFileImage);
imageList.Images.Add(saveFileImage);
imageList.Images.Add(printImage);


// menu
fileMenuItem.Text = \"&File\";

// the following constructor is the same as:
// menuItem fileNewMenuItem = new MenuItem();
// fileNewMenuItem.Text = \"&New\";
// fileNewMenuItem.Shortcut = Shortcut.CtrlN;
// fileNewMenuItem.Click += new

System.EventHandler(this.fileNewMenuItem_Click);
fileNewMenuItem = new MenuItem(\"&New\",
new System.EventHandler(this.fileNewMenuItem_Click), Shortcut.CtrlN);

fileOpenMenuItem = new MenuItem(\"&Open\",
new System.EventHandler(this.fileOpenMenuItem_Click), Shortcut.CtrlO);

fileSaveMenuItem = new MenuItem(\"&Save\",
new System.EventHandler(this.fileSaveMenuItem_Click), Shortcut.CtrlS);

fileSaveAsMenuItem = new MenuItem(\"Save &As\",
new System.EventHandler(this.fileSaveAsMenuItem_Click));

fileMenuWithSubmenu = new MenuItem(\"&With Submenu\");

submenuMenuItem = new MenuItem(\"Su&bmenu\",
new System.EventHandler(this.submenuMenuItem_Click));

fileExitMenuItem = new MenuItem(\"E&xit\",
new System.EventHandler(this.fileExitMenuItem_Click));


mainMenu.MenuItems.Add(fileMenuItem);
fileOpenMenuItem.Checked = true;
fileMenuItem.MenuItems.Add(fileNewMenuItem);
fileMenuItem.MenuItems.Add(fileOpenMenuItem);
fileMenuItem.MenuItems.Add(fileSaveMenuItem);
fileMenuItem.MenuItems.Add(fileSaveAsMenuItem);
fileMenuItem.MenuItems.Add(fileMenuWithSubmenu);
fileMenuWithSubmenu.MenuItems.Add(submenuMenuItem);
fileMenuItem.MenuItems.Add(\"-\"); // add a separator
fileMenuItem.MenuItems.Add(fileExitMenuItem);


toolBar.Appearance = ToolBarAppearance.Normal;
//toolBar.Appearance = ToolBarAppearance.Flat;
toolBar.ImageList = imageList;
toolBar.ButtonSize = new Size(14, 6);

separatorToolBarButton.Style = ToolBarButtonStyle.Separator;
newToolBarButton.ToolTipText = \"New Document\";
newToolBarButton.ImageIndex = 0;
openToolBarButton.ToolTipText = \"Open Document\";
openToolBarButton.ImageIndex = 1;
saveToolBarButton.ToolTipText = \"Save\";
saveToolBarButton.ImageIndex = 2;
printToolBarButton.ToolTipText = \" rint\";
printToolBarButton.ImageIndex = 3;

toolBar.ButtonClick += new

ToolBarButtonClickEventHandler(this.toolBar_ButtonClick);

toolBar.Buttons.Add(separatorToolBarButton);
toolBar.Buttons.Add(newToolBarButton);
toolBar.Buttons.Add(openToolBarButton);
toolBar.Buttons.Add(saveToolBarButton);
toolBar.Buttons.Add(separatorToolBarButton);
toolBar.Buttons.Add(printToolBarButton);

tree.Top = 40;
tree.Left = 20;
tree.Width = 100;
tree.Height = 100;

label.Location = new Point(220, 40);
label.Size = new Size(160, 30);
label.Text = \"Yes, click the button\";

button.Location = new Point(220, 80);
button.Size = new Size(100, 30);
button.Text = \"Click this\";
button.Click += new System.EventHandler(this.button_Click);

statusBarPanel1.BorderStyle = StatusBarPanelBorderStyle.Sunken;
statusBarPanel1.Text = \" ress F1 for Help\";
statusBarPanel1.AutoSize = StatusBarPanelAutoSize.Spring;
statusBarPanel2.BorderStyle = StatusBarPanelBorderStyle.Raised;
statusBarPanel2.ToolTipText = System.DateTime.Now.ToShortTimeString();
statusBarPanel2.Text = System.DateTime.Today.ToLongDateString();
statusBarPanel2.AutoSize = StatusBarPanelAutoSize.Contents;
statusBar.ShowPanels = true;
statusBar.Panels.Add(statusBarPanel1);
statusBar.Panels.Add(statusBarPanel2);


this.Menu = mainMenu;
this.Controls.Add(toolBar);
this.Controls.Add(tree);
this.Controls.Add(label);
this.Controls.Add(button);
this.Controls.Add(statusBar);
}


// -------------- Event Handlers --------------------------

private void fileNewMenuItem_Click(Object sender, EventArgs e) {
MessageBox.Show(\"You clicked the File -- New menu.\", \"The Event

Information\");
}

private void fileOpenMenuItem_Click(Object sender, EventArgs e) {
MessageBox.Show(\"You clicked the File -- Open menu.\", \"The Event

Information\");
}

private void fileSaveMenuItem_Click(Object sender, EventArgs e) {
MessageBox.Show(\"You clicked the File -- Save menu.\", \"The Event

Information\");
}

private void fileSaveAsMenuItem_Click(Object sender, EventArgs e) {
MessageBox.Show(\"You clicked the File -- Save As menu.\", \"The Event

Information\");
}

private void fileExitMenuItem_Click(Object sender, EventArgs e) {
MessageBox.Show(\"You clicked the File -- Exit As menu.\", \"The Event

Information\");
}

private void submenuMenuItem_Click(Object sender, EventArgs e) {
MessageBox.Show(\"You clicked the submenu.\", \"The Event Information\");
}

protected void toolBar_ButtonClick(Object sender,

ToolBarButtonClickEventArgs e) {

// Evaluate the Button property to determine which button was clicked.
switch (toolBar.Buttons.IndexOf(e.Button)) {
case 1:
MessageBox.Show(\"Second button.\", \"The Event Information\");
break;
case 2:
MessageBox.Show(\"third button\", \"The Event Information\");
break;
case 3:
MessageBox.Show(\"fourth button.\", \"The Event Information\");
break;
}
}

protected override void OnClosing(CancelEventArgs e) {
MessageBox.Show(\"Exit now.\", \"The Event Information\");
}

private void button_Click(Object sender, System.EventArgs e) {
MessageBox.Show(\"Thank you.\", \"The Event Information\");
}

// -------------- End of Event Handlers -------------------



public static void Main() {
MyWinApp form = new MyWinApp();
Application.Run(form);
}

}


转自 http://www.51myit.com/thread-18599-1-1.html



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
第2章 QQ企业通    2.1 设计思路 28   2.2 关键技术 28   2.2.1 INI文件的应用 28   2.2.2 线程的应用 30   2.2.3 在Socket中发送大容量的消息 30   2.2.4 将流序列化或反序列化为对象 31   2.2.5 用InnerList列表记录信息 31   2.3 设计过程 32   2.3.1 类库的设计 33   2.3.2 客户端注册模块设计 40   2.3.3 客户端登录模块设计 42   2.3.4 客户端QQ模块设计 43   2.3.5 客户端消息发送模块设计 48   2.3.6 服务器端控制台模块设计 52 第3章 SQL数据表提取器模块    3.1 概述 56   3.2 关键技术 56   3.2.1 如何备份数据库 56   3.2.2 如何还原数据库 57   3.2.3 如何附加数据库 58   3.2.4 如何分离数据库 59   3.2.5 设置数据库模式 59   3.3 设计过程 61   3.3.1 主窗体 61   3.3.2 获取服务器名称 62   3.3.3 获取所有数据库 63   3.3.4 获取所有数据表 64   3.3.5 备份数据库 66   3.3.6 还原数据库 67   3.3.7 附加数据库 68   3.3.8 分离数据库 70   3.3.9 导出表结构 71   3.3.10 导出数据 74 第4章 万能搜索模块    4.1 设计思路 80   4.2 关键技术 80   4.2.1 如何制作一个接口程序 80   4.2.2 实现接口程序的信息互传 80   4.2.3 如何将接口程序加载到其他程序中 82   4.2.4 怎样操作RichtextBox控件的择文本 82   4.2.5 如何获取数据表中字段的描述信息 83   4.3 设计过程 83   4.3.1 获取数据表中字段的中文信息 84   4.3.2 添加数据表的查询条件 86   4.3.3 向SQL语句中添加括号 89   4.3.4 查询生成后的SQL语句 90   4.3.5 主程序获得接口信息 92 第5章 万能打印模块    5.1 设计思路 94   5.2 关键技术 94   5.2.1 打印设置(PrintDocument类) 94   5.2.2 打印预览对话框(PrintPreview Dialog) 95   5.2.3 打印对话框(PrintDialog) 96   5.2.4 获取指定颜色值和字体样式 97   5.2.5 DataGridView控件的相关应用 97   5.3 设计过程 98   5.3.1 打印信息的设置 98   5.3.2 表格样式的设置 100   5.3.3 打印类的设置 101   5.3.4 打印数据信息 108 第6章 决策分析模块    6.1 设计思路 112   6.2 关键技术 112   6.2.1 游标的基本操作 112   6.2.2 存储过程的基本操作 115   6.2.3 透视表的基本概念 117   6.2.4 统计表的基本操作 117   6.2.5 单击显示右键菜单 118   6.3 设计过程 118   6.3.1 主窗体的初始化 119   6.3.2 透视表的筛 127   6.3.3 透视表的设计 130   6.3.4 统计表的设计 132 第7章 自定义图表控件    7.1 设计思路 136   7.2 关键技术 137   7.2.1 控件的生成 137   7.2.2 如何在项目中添加控件 137   7.2.3 在“属性”对话框中添加属性 137   7.2.4 用GDI+绘制图形 139   7.2.5 如何在控件上绘制图形 143   7.2.6 获取扇形外弧中心点的位置 143   7.3 设计过程 144   7.3.1 向自定义控件中添加属性 144   7.3.2 获取绘制图表的初始值数据 149   7.3.3 绘制标签框 153   7.3.4 绘制图表中的表格 157   7.3.5 绘制条形图 163   7.3.6 绘制面形图 170   7.3.7 绘制饼形图 174 第8章 电子邮件收发模块    8.1 概述 180   8.2 关键技术 180   8.2.1 Base64编码格式 180   8.2.2 SMTP服务 181   8.2.3 POP3协议 184   8.2.4 使用Jmail组件接收邮件 186   8.2.5 邮件发送类的使用 188   8.2.6 使用正则表达式验证邮件格式 190   8.3 设计过程 191   8.3.1 数据库设计 191   8.3.2 系统登录 191   8.3.3 邮件发送实现 192   8.3.4 为邮件上传多个附件 193   8.3.5 邮件接收实现 194   8.3.6 查看邮件详细信息 196   8.3.7 下载附件的实现 197   8.3.8 删除邮件实现 198   8.3.9 用户管理 198 第9章 短信群发模块    9.1 设计思路 202   9.2 关键技术 202   9.2.1 短信猫中API函数的使用 202   9.2.2 短信猫中的短信接收格式 205   9.2.3 窗体间的互操作 205   9.2.4 锁定模块主窗体 206   9.2.5 使用ADO.NET连接Access数据库 206   9.3 设计过程 207   9.3.1 数据库设计 207   9.3.2 群发短信实现 209   9.3.3 已发送短信管理 213   9.3.4 接收短信实现 215   9.3.5 常用联系人管理 219   9.3.6 常用短语管理 221 第10章 桌面精灵模块    10.1 概述 226   10.2 关键技术 226   10.2.1 阴阳历转换算法 226   10.2.2 调用系统API实现鼠标穿透效果 230   10.2.3 修改注册表控制程序开机自启动 231   10.2.4 通过控制窗体透明度实现日历透明显示效果 231   10.2.5 拖动无标题栏窗体 232   10.2.6 将窗体的关闭位置写入到注册表中 232   10.2.7 将程序图标写入到托盘 232   10.3 设计过程 233   10.3.1 桌面精灵模块公共类设计 233   10.3.2 当前日期的农历、天干地支年、节日及星座显示 235   10.3.3 定时提醒的实现 240   10.3.4 日历窗体效果控制 242   10.3.5 转到某天、某周、某月及某年的实现 243   10.3.6 节日管理 245   10.3.7 提醒管理 249 第11章 文件批量处理器    11.1 概述 256   11.2 关键技术 256   11.2.1 文件流技术 256   11.2.2 文件解压缩技术 258   11.2.3 获取系统文件及文件夹图标 262   11.2.4 获取指定目录下的所有文件及文件夹 265   11.2.5 Word操作技术 266   11.2.6 进度条的显示 266   11.2.7 对ListView控件中的项进行排序 267   11.3 设计过程 267   11.3.1 主窗体预览 267   11.3.2 批量复制、剪切文件 268   11.3.3 批量复制、剪切文件夹 270   11.3.4 批量重命名文件 271   11.3.5 批量删除文件及文件夹 275   11.3.6 搜索文件及文件夹 276   11.3.7 批量压缩、解压文件 278   11.3.8 分割、合并文件 280 第12章 图片管理工具模块    12.1 概述 286   12.2 关键技术 286   12.2.1 上下移动ListBox中项 286   12.2.2 将文件复制到剪切板 287   12.2.3 格式转换 288   12.2.4 图片幻灯片 288   12.2.5 图片旋转 289   12.3 设计过程 290   12.3.1 主窗体 290   12.3.2 打开图片目录 291   12.3.3 图片格式转换 292   12.3.4 设为桌面背景 294   12.3.5 图片特效 296   12.3.6 图片调节 300   12.3.7 图片水印 304   12.3.8 幻灯片放映 306   12.3.9 图片打印 308 、

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值