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

📄 mainform.cs

📁 以MS .NET 所寫的RSA程式
💻 CS
📖 第 1 页 / 共 3 页
字号:
			// inputTextBox
			// 
			this.inputTextBox.AcceptsReturn = true;
			this.inputTextBox.AcceptsTab = true;
			this.inputTextBox.BackColor = System.Drawing.Color.Black;
			this.inputTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.inputTextBox.ForeColor = System.Drawing.Color.LightGreen;
			this.inputTextBox.ImeMode = System.Windows.Forms.ImeMode.NoControl;
			this.inputTextBox.Location = new System.Drawing.Point(0, 0);
			this.inputTextBox.Multiline = true;
			this.inputTextBox.Name = "inputTextBox";
			this.inputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.inputTextBox.Size = new System.Drawing.Size(634, 427);
			this.inputTextBox.TabIndex = 1;
			this.inputTextBox.TabStop = false;
			this.inputTextBox.Text = "";
			this.inputTextBox.TextChanged += new System.EventHandler(this.inputTextBox_TextChanged);
			// 
			// fontDialog
			// 
			this.fontDialog.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.fontDialog.FontMustExist = true;
			this.fontDialog.ShowEffects = false;
			// 
			// panel
			// 
			this.panel.BackColor = System.Drawing.Color.Black;
			this.panel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.panel.Controls.Add(this.processingLabel);
			this.panel.Controls.Add(this.pictureBox);
			this.panel.ForeColor = System.Drawing.Color.Lime;
			this.panel.Location = new System.Drawing.Point(0, 416);
			this.panel.Name = "panel";
			this.panel.Size = new System.Drawing.Size(200, 88);
			this.panel.TabIndex = 0;
			this.panel.Visible = false;
			// 
			// processingLabel
			// 
			this.processingLabel.Location = new System.Drawing.Point(8, 48);
			this.processingLabel.Name = "processingLabel";
			this.processingLabel.Size = new System.Drawing.Size(184, 23);
			this.processingLabel.TabIndex = 1;
			this.processingLabel.Text = "Processing please wait...";
			// 
			// pictureBox
			// 
			this.pictureBox.BackColor = System.Drawing.Color.Black;
			this.pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.pictureBox.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox.Image")));
			this.pictureBox.Location = new System.Drawing.Point(80, 8);
			this.pictureBox.Name = "pictureBox";
			this.pictureBox.Size = new System.Drawing.Size(32, 34);
			this.pictureBox.TabIndex = 0;
			this.pictureBox.TabStop = false;
			// 
			// mainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(8, 19);
			this.BackColor = System.Drawing.SystemColors.Control;
			this.ClientSize = new System.Drawing.Size(632, 404);
			this.Controls.Add(this.panel);
			this.Controls.Add(this.inputTextBox);
			this.Font = new System.Drawing.Font("Georgia", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Menu = this.mainMenu;
			this.Name = "mainForm";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "RSACryptoPad";
			this.Resize += new System.EventHandler(this.mainForm_Resize);
			this.Closing += new System.ComponentModel.CancelEventHandler(this.mainForm_Closing);
			this.Load += new System.EventHandler(this.mainForm_Load);
			this.panel.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		[ STAThread ]
		static void Main()
		{
			System.Windows.Forms.Application.EnableVisualStyles();
			Application.Run(new mainForm());
		}

		private void mainForm_Resize( object sender, System.EventArgs e )
		{
			inputTextBox.Height = this.Size.Height - 53;
			inputTextBox.Width = this.Size.Width - 7;
		}

		private void newFileMenuItem_Click( object sender, System.EventArgs e )
		{
			if( !originalText )
			{
				switch( System.Windows.Forms.MessageBox.Show( "Would you like to save this document?", "RSACryptoPad", System.Windows.Forms.MessageBoxButtons.YesNoCancel ) )
				{
					case System.Windows.Forms.DialogResult.Yes:
					{
						saveFile();
						inputTextBox.Text = "";	
						originalText = true;						
						break;
					}
					case System.Windows.Forms.DialogResult.No:
					{
						inputTextBox.Text = "";
						originalText = true;
						break;
					}
					case System.Windows.Forms.DialogResult.Cancel:
					{break;}
					default:
					{break;}
				}
			}
			else
			{
				inputTextBox.Text = "";
				originalText = true;
			}
		}

		private void openFileMenuItem_Click( object sender, System.EventArgs e )
		{
			if( !originalText )
			{
				switch( System.Windows.Forms.MessageBox.Show( "Would you like to save this document?", "RSACryptoPad", System.Windows.Forms.MessageBoxButtons.YesNoCancel ) )
				{
					case System.Windows.Forms.DialogResult.Yes:
					{
						saveFile();
						originalText = true;
						break;
					}
					case System.Windows.Forms.DialogResult.No:
					{
						originalText = true;
						break;
					}
					case System.Windows.Forms.DialogResult.Cancel:
					{return;}
					default:
					{break;}
				}
			}
			try
			{
				openFileDialog.Title = "Open";
				openFileDialog.ValidateNames = true;
				openFileDialog.DereferenceLinks = true;
				openFileDialog.Filter = "Text Document( *.txt )|*.txt|All Files|*.*";
				openFileDialog.FileName = "";
				openFileDialog.ShowDialog();
				if( !openFileDialog.FileName.Equals( "" ) )
				{
					System.IO.StreamReader streamReader = new System.IO.StreamReader( openFileDialog.FileName, true );
					inputTextBox.Text = streamReader.ReadToEnd();
					if( inputTextBox.Text.Length >= inputTextBox.MaxLength )
					{
						System.Windows.Forms.MessageBox.Show( "ERROR: \nThe file you are trying to open is too big for the text editor to display properly.\nPlease open a smaller document!\nOperation Aborted!" );
						inputTextBox.Text = "";
					}
					else
					{originalText = true;}
					streamReader.Close();					
				}
			}
			catch( System.Exception Ex ) {System.Windows.Forms.MessageBox.Show( "ERROR: \n" + Ex.Message );}			
		}

		private void saveAsFileMenuItem_Click( object sender, System.EventArgs e )
		{
			saveFile();
			originalText = true;
		}

		private void exitMenuItem_Click( object sender, System.EventArgs e )
		{
			if( !originalText )
			{
				switch( System.Windows.Forms.MessageBox.Show( "Would you like to save this Untitled document?", "RSACryptoPad", System.Windows.Forms.MessageBoxButtons.YesNo ) )
				{
					case System.Windows.Forms.DialogResult.Yes:
					{
						saveFile();
						break;
					}
					case System.Windows.Forms.DialogResult.No:
					{
						this.Dispose( true );
						break;
					}
					default:
					{
						this.Dispose( true );
						break;
					}
				}
			}
			else
			{this.Dispose( true );}
			this.Dispose( true );
		}

		private void mainForm_Closing( object sender, System.ComponentModel.CancelEventArgs e )
		{
			if( !originalText )
			{
				switch( System.Windows.Forms.MessageBox.Show( "Would you like to save this document?", "RSACryptoPad", System.Windows.Forms.MessageBoxButtons.YesNo ) )
				{
					case System.Windows.Forms.DialogResult.Yes:
					{
						saveFile();
						break;
					}
					case System.Windows.Forms.DialogResult.No:
					{break;}
					default:
					{break;}
				}
			}
			else
			{this.Dispose( true );}
		}

		private void saveFile()
		{
			saveFileDialog.Title = "Save As";
			saveFileDialog.ValidateNames = true;
			saveFileDialog.OverwritePrompt = true;
			saveFileDialog.AddExtension = true;
			saveFileDialog.DereferenceLinks = true;
			saveFileDialog.Filter = "Text Document( *.txt )|*.txt|All Files|*.*";
			saveFileDialog.ValidateNames = true;
			saveFileDialog.FileName = "*.txt";
			switch( saveFileDialog.ShowDialog() )
			{
				case System.Windows.Forms.DialogResult.Cancel:
				{break;}
				default:
				{
					try
					{
						System.IO.StreamWriter streamWriter = new System.IO.StreamWriter( saveFileDialog.FileName, false );
						streamWriter.Write( inputTextBox.Text );
						streamWriter.Close();																			
					}
					catch( System.Exception Ex ) {System.Console.WriteLine( Ex.Message );}
					break;
				}
			}			
		}

		private void fontMenuItem_Click( object sender, System.EventArgs e )
		{
			if( fontDialog.ShowDialog() != System.Windows.Forms.DialogResult.Cancel )
			{inputTextBox.Font = fontDialog.Font;}
		}

		private void inputTextBox_TextChanged( object sender, System.EventArgs e )
		{originalText = false;}

		private void wordWrapMenuItem_Click( object sender, System.EventArgs e )
		{
			if( wordWrapMenuItem.Checked == true )
			{
				wordWrapMenuItem.Checked = false;
				inputTextBox.WordWrap = false;
			}
			else
			{
				wordWrapMenuItem.Checked = true;
				inputTextBox.WordWrap = true;
			}
		}	

		private void cutMenuItem_Click( object sender, System.EventArgs e )
		{
			try

⌨️ 快捷键说明

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