⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.cs

📁 Windows Mobile用户签名程序
💻 CS
📖 第 1 页 / 共 2 页
字号:
/*
	MainForm class
	--
	Application's main window. Receives encrypted signature data from client
	over TCP sockets. The data is decrypted using crypto APIs and displayed
	in four different views:
	
	1) Signature view draws the signature.
	2) Points view displays the signature segments and coordinates.
	3) Encrypt view displays the encrypted signature data received over socket.
	4) Decrypt view displays the decrypted signature data.
	
	Draws signature using cardinal splines if 'use smooth lines' is checked,
	otherwise uses straight lines.
	
	The encryption passphrase is always displayed so user can change the
	passphrase and see how it affects the decryption process (can't decrypt
	with the wrong passphrase).
	
	Settings are stored in XML .config file.
*/


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Drawing.Drawing2D;
using System.Text;
using System.Diagnostics;
using Common;


namespace DesktopSignature
{
	/// <summary>
	/// Main window. Receives encrypted signature data over socket and 
	/// displays data in four different views.
	/// </summary>
	public class MainForm : System.Windows.Forms.Form
	{
		// signature data
		SignatureData _signature;
		
		// encrypted data received over socket
		// store the encrypted bytes so user can change the 
		// encryption passphrase and see how the data changes
		byte[] _encryptData;

		// network communication
		ServerSocket _server = new ServerSocket();
		
		// Control.Invoke callback, used to process the 
		// socket notification event on the GUI's thread
		delegate void ProcessSocketCommandHandler(NotifyCommand command, object data);
		ProcessSocketCommandHandler _processCommand;
		
		private System.Windows.Forms.TabControl tabControl;
		private System.Windows.Forms.TabPage tabSignature;
		private System.Windows.Forms.TabPage tabEncrypt;
		private System.Windows.Forms.TabPage tabDecrypt;
		private System.Windows.Forms.PictureBox pictSignature;
		private System.Windows.Forms.TextBox textEncrypt;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox textDecrypt;
		private System.Windows.Forms.TabPage tabPoints;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox textPoints;
		private System.Windows.Forms.CheckBox checkSmooth;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.StatusBar statusBar;
		private System.Windows.Forms.StatusBarPanel panelMain;
		private System.Windows.Forms.TextBox textPassphrase;

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public MainForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
			this.statusBar = new System.Windows.Forms.StatusBar();
			this.panelMain = new System.Windows.Forms.StatusBarPanel();
			this.tabControl = new System.Windows.Forms.TabControl();
			this.tabSignature = new System.Windows.Forms.TabPage();
			this.pictSignature = new System.Windows.Forms.PictureBox();
			this.tabPoints = new System.Windows.Forms.TabPage();
			this.label3 = new System.Windows.Forms.Label();
			this.textPoints = new System.Windows.Forms.TextBox();
			this.tabEncrypt = new System.Windows.Forms.TabPage();
			this.label1 = new System.Windows.Forms.Label();
			this.textEncrypt = new System.Windows.Forms.TextBox();
			this.tabDecrypt = new System.Windows.Forms.TabPage();
			this.label2 = new System.Windows.Forms.Label();
			this.textDecrypt = new System.Windows.Forms.TextBox();
			this.checkSmooth = new System.Windows.Forms.CheckBox();
			this.label4 = new System.Windows.Forms.Label();
			this.textPassphrase = new System.Windows.Forms.TextBox();
			((System.ComponentModel.ISupportInitialize)(this.panelMain)).BeginInit();
			this.tabControl.SuspendLayout();
			this.tabSignature.SuspendLayout();
			this.tabPoints.SuspendLayout();
			this.tabEncrypt.SuspendLayout();
			this.tabDecrypt.SuspendLayout();
			this.SuspendLayout();
			// 
			// statusBar
			// 
			this.statusBar.Location = new System.Drawing.Point(0, 260);
			this.statusBar.Name = "statusBar";
			this.statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
																						 this.panelMain});
			this.statusBar.ShowPanels = true;
			this.statusBar.Size = new System.Drawing.Size(376, 22);
			this.statusBar.TabIndex = 4;
			this.statusBar.Text = "Received signature";
			// 
			// panelMain
			// 
			this.panelMain.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
			this.panelMain.Width = 360;
			// 
			// tabControl
			// 
			this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.tabControl.Controls.Add(this.tabSignature);
			this.tabControl.Controls.Add(this.tabPoints);
			this.tabControl.Controls.Add(this.tabEncrypt);
			this.tabControl.Controls.Add(this.tabDecrypt);
			this.tabControl.Location = new System.Drawing.Point(0, 0);
			this.tabControl.Name = "tabControl";
			this.tabControl.SelectedIndex = 0;
			this.tabControl.Size = new System.Drawing.Size(376, 228);
			this.tabControl.TabIndex = 0;
			// 
			// tabSignature
			// 
			this.tabSignature.Controls.Add(this.pictSignature);
			this.tabSignature.Location = new System.Drawing.Point(4, 22);
			this.tabSignature.Name = "tabSignature";
			this.tabSignature.Size = new System.Drawing.Size(368, 202);
			this.tabSignature.TabIndex = 0;
			this.tabSignature.Text = "Signature";
			// 
			// pictSignature
			// 
			this.pictSignature.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.pictSignature.Location = new System.Drawing.Point(8, 8);
			this.pictSignature.Name = "pictSignature";
			this.pictSignature.Size = new System.Drawing.Size(352, 188);
			this.pictSignature.TabIndex = 1;
			this.pictSignature.TabStop = false;
			this.pictSignature.Paint += new System.Windows.Forms.PaintEventHandler(this.pictSignature_Paint);
			// 
			// tabPoints
			// 
			this.tabPoints.Controls.Add(this.label3);
			this.tabPoints.Controls.Add(this.textPoints);
			this.tabPoints.Location = new System.Drawing.Point(4, 22);
			this.tabPoints.Name = "tabPoints";
			this.tabPoints.Size = new System.Drawing.Size(368, 202);
			this.tabPoints.TabIndex = 3;
			this.tabPoints.Text = "Points";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 8);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(144, 16);
			this.label3.TabIndex = 3;
			this.label3.Text = "Signature coordinates";
			// 
			// textPoints
			// 
			this.textPoints.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.textPoints.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.textPoints.Location = new System.Drawing.Point(8, 24);
			this.textPoints.Multiline = true;
			this.textPoints.Name = "textPoints";
			this.textPoints.ReadOnly = true;
			this.textPoints.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.textPoints.Size = new System.Drawing.Size(352, 172);
			this.textPoints.TabIndex = 2;
			this.textPoints.Text = "";
			// 
			// tabEncrypt
			// 
			this.tabEncrypt.Controls.Add(this.label1);
			this.tabEncrypt.Controls.Add(this.textEncrypt);
			this.tabEncrypt.Location = new System.Drawing.Point(4, 22);
			this.tabEncrypt.Name = "tabEncrypt";
			this.tabEncrypt.Size = new System.Drawing.Size(368, 202);
			this.tabEncrypt.TabIndex = 1;
			this.tabEncrypt.Text = "Encrypt";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(144, 16);
			this.label1.TabIndex = 1;
			this.label1.Text = "Encrypted signature data";
			// 
			// textEncrypt
			// 
			this.textEncrypt.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.textEncrypt.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.textEncrypt.Location = new System.Drawing.Point(8, 24);
			this.textEncrypt.Multiline = true;
			this.textEncrypt.Name = "textEncrypt";
			this.textEncrypt.ReadOnly = true;
			this.textEncrypt.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.textEncrypt.Size = new System.Drawing.Size(352, 172);
			this.textEncrypt.TabIndex = 0;
			this.textEncrypt.Text = "";
			// 
			// tabDecrypt
			// 
			this.tabDecrypt.Controls.Add(this.label2);
			this.tabDecrypt.Controls.Add(this.textDecrypt);
			this.tabDecrypt.Location = new System.Drawing.Point(4, 22);
			this.tabDecrypt.Name = "tabDecrypt";
			this.tabDecrypt.Size = new System.Drawing.Size(368, 202);
			this.tabDecrypt.TabIndex = 2;
			this.tabDecrypt.Text = "Decrypt";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 8);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(168, 16);
			this.label2.TabIndex = 3;
			this.label2.Text = "Decrypted signature data";
			// 
			// textDecrypt
			// 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -