Form1.cs
上传用户:chizxy
上传日期:2014-11-29
资源大小:407k
文件大小:6k
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using System.IO;
- namespace popedom
- {
- /// <summary>
- /// Form1 的摘要说明。
- /// </summary>
- public class Form1 : System.Windows.Forms.Form
- {
- private string file_url;
- private string app_url;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.Button btn_browse;
- private System.Windows.Forms.Button btn_ok;
- private System.Windows.Forms.PictureBox pictureBox1;
- private System.Windows.Forms.Button btn_esc;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public Form1()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
- this.label1 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.btn_browse = new System.Windows.Forms.Button();
- this.btn_ok = new System.Windows.Forms.Button();
- this.pictureBox1 = new System.Windows.Forms.PictureBox();
- this.btn_esc = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(8, 14);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(100, 16);
- this.label1.TabIndex = 0;
- this.label1.Text = "请选择授权文件";
- //
- // textBox1
- //
- this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.textBox1.Location = new System.Drawing.Point(24, 47);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(208, 21);
- this.textBox1.TabIndex = 1;
- this.textBox1.Text = "";
- //
- // btn_browse
- //
- this.btn_browse.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btn_browse.Location = new System.Drawing.Point(244, 47);
- this.btn_browse.Name = "btn_browse";
- this.btn_browse.TabIndex = 2;
- this.btn_browse.Text = "浏览";
- this.btn_browse.Click += new System.EventHandler(this.btn_browse_Click);
- //
- // btn_ok
- //
- this.btn_ok.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btn_ok.Location = new System.Drawing.Point(144, 98);
- this.btn_ok.Name = "btn_ok";
- this.btn_ok.Size = new System.Drawing.Size(56, 24);
- this.btn_ok.TabIndex = 3;
- this.btn_ok.Text = "确定";
- this.btn_ok.Click += new System.EventHandler(this.btn_ok_Click);
- //
- // pictureBox1
- //
- this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
- this.pictureBox1.Location = new System.Drawing.Point(0, 88);
- this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(344, 4);
- this.pictureBox1.TabIndex = 4;
- this.pictureBox1.TabStop = false;
- //
- // btn_esc
- //
- this.btn_esc.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btn_esc.Location = new System.Drawing.Point(232, 98);
- this.btn_esc.Name = "btn_esc";
- this.btn_esc.Size = new System.Drawing.Size(56, 24);
- this.btn_esc.TabIndex = 5;
- this.btn_esc.Text = "取消";
- this.btn_esc.Click += new System.EventHandler(this.btn_esc_Click);
- //
- // Form1
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(328, 125);
- this.Controls.Add(this.btn_esc);
- this.Controls.Add(this.pictureBox1);
- this.Controls.Add(this.btn_ok);
- this.Controls.Add(this.btn_browse);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.label1);
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.MaximizeBox = false;
- this.Name = "Form1";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "授权文件设置";
- this.ResumeLayout(false);
- }
- #endregion
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.Run(new Form1());
- }
- private void btn_browse_Click(object sender, System.EventArgs e)
- {
- OpenFileDialog opfile = new OpenFileDialog();
- opfile.Filter = "授权文件.dat|*.dat|所有文件|*.*";
- if(opfile.ShowDialog() == DialogResult.OK)
- {
- this.file_url = opfile.FileName;
- this.textBox1.Text = this.file_url;
- }
- }
- private void btn_ok_Click(object sender, System.EventArgs e)
- {
- if(this.textBox1.Text.Length>0)
- {
- this.app_url = Application.StartupPath+"\授权文件.dat";
- try
- {
- File.Copy(this.textBox1.Text.Trim(),this.app_url,true);
- MessageBox.Show("授权文件设置成功","系统信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
- }
- catch(IOException ee)
- {
- MessageBox.Show("系统错误:"+ee.Message.ToString(),"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- }
- else
- {
- MessageBox.Show("请先选择授权文件","错误信息",MessageBoxButtons.OK,MessageBoxIcon.Warning);
- }
-
- }
- private void btn_esc_Click(object sender, System.EventArgs e)
- {
- this.Close();
- }
- }
- }