前几天,有个做B/S的朋友说,需要一个套在B/S程序名外边的应用程序,因为他一直搞WEB开发,所以找到我让帮忙实现一下。
虽然东西不难,不过很奇怪客户会有这样的要求,要么干脆做个C/S的程序就好了。不过客户要求了,咱就得实现,上帝嘛!
其中应用到了文件操作,修改bin\Debug目录下的Config.ini文件可更新程序标题,皮肤,及默认网址。
前几天,有个做B/S的朋友说,需要一个套在B/S程序名外边的应用程序,因为他一直搞WEB开发,所以找到我让帮忙实现一下。
虽然东西不难,不过很奇怪客户会有这样的要求,要么干脆做个C/S的程序就好了。不过客户要求了,咱就得实现,上帝嘛!
其中应用到了文件操作,修改bin\Debug目录下的Config.ini文件可更新程序标题,皮肤,及默认网址。
Skin\目录下保存有五个皮肤文件,可用来更换。
编译完成后必要文件及目录为bin\Debug中的:
WebForm.exe,IrisSkin2.dll,Config.ini及Skin目录
实现代码如下:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Text;
7
using System.Windows.Forms;
8
using System.IO;
9
using System.Collections;
10
using System.Text.RegularExpressions;
11![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
namespace WebForm
13![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
14
public partial class Form1 : Form
15![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
16
string FilePaht = @"Config.ini";
17
string Url;
18
string[] Names;
19
string[] strSqit;
20
Hashtable ListView = new Hashtable();
21![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
public Form1()
23![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
24
InitializeComponent();
25
Names = File.ReadAllLines(FilePaht,Encoding.Default);//读取文件中所有的行
26![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27
foreach (string strName in Names) //遍历所有行
28![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
29
strSqit = strName.Split('=');
30
ListView.Add(strSqit[0],strSqit[1]); //将文本中内容添加到Hashtable表中
31
}
32
Url = ListView["Url"].ToString();//获取文件中URL
33
skinEngine1.SkinFile = ListView["SkinFile"].ToString(); //读取皮肤设置
34
this.Text = ListView["SysName"].ToString(); //读取系统名称
35
}
36![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
37
private void Form1_Load(object sender, EventArgs e)
38![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
39
webBrowser1.Navigate(Url);
40
}
41![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
42
private void toolStripButton2_Click(object sender, EventArgs e)
43![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
44
webBrowser1.GoBack(); //返回上一页
45
}
46![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
47
private void toolStripSplitButton1_ButtonClick(object sender, EventArgs e)
48![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
49
webBrowser1.GoForward(); //前进到下一页
50
}
51![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
52
private void toolStripButton1_Click(object sender, EventArgs e)
53![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
54
webBrowser1.Refresh(); //刷新
55
}
56![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
57
private void toolStripButton3_Click(object sender, EventArgs e)
58![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
59
webBrowser1.Stop(); //停止加载
60
}
61![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
62
private void toolStripButton4_Click(object sender, EventArgs e)
63![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
64
webBrowser1.Navigate(Url); //返回首页
65
}
66![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
67
private void toolStripButton5_Click(object sender, EventArgs e)
68![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
69
Application.Exit(); //退出系统
70
}
71![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
72![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
73
/// 当更新下载进度时发生
74
/// </summary>
75
/// <param name="sender"></param>
76
/// <param name="e"></param>
77
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
78![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
79
toolStripProgressBar1.Visible = true; //显示进度条控件
80
if (e.CurrentProgress > 0 && e.MaximumProgress > 0)//已经加载数及正在加载数大于0时
81![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
82
toolStripProgressBar1.Maximum = (int)e.MaximumProgress; //获取进度条最大值为下载文档字节总数
83
toolStripProgressBar1.Step = (int)e.CurrentProgress; //获取已经下载字节数
84
toolStripProgressBar1.PerformStep(); //增加到当前位置
85
}
86
else if (webBrowser1.ReadyState == WebBrowserReadyState.Complete) //下载完成之后
87![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
88
toolStripProgressBar1.Value = 0; //进度条设为0
89
toolStripProgressBar1.Visible = false; //不显示进度条
90
}
91
}
92
}
93
}
94![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
源码:点击下载