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

📄 form1.cs

📁 This source code is about the basic sorting algorithm implemented in C#. The algorithms included are
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

using System.Threading;

namespace algorithm_analysis
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private Random rnd = new Random();
		private int[] list, list1, list2, list3 ;
		//private Thread[] thCounter = new Thread[3];
		//private Thread[] thExecute = new Thread[3];
		//private Thread bubbleCounter = new Thread[];
		private enum SortType { Bubble, Insertion, Selection };
		private int delay=100, total = 10;
		private TimeSpan start, end;
		private string mode = null;


		private System.Windows.Forms.Panel plBubble;
		private System.Windows.Forms.Panel plInsertion;
		private System.Windows.Forms.Panel plSelection;
		private System.Windows.Forms.Button btnGenerate;
		private System.Windows.Forms.Button btnStart;
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.TextBox tbResult_Bubble;
		private System.Windows.Forms.Label lbEnd_Bubble;
		private System.Windows.Forms.Label lbStart_Bubble;
		private System.Windows.Forms.Label lbStart_Insertion;
		private System.Windows.Forms.Label lbEnd_Insertion;
		private System.Windows.Forms.TextBox tbResult_Insertion;
		private System.Windows.Forms.Label lbEnd_Selection;
		private System.Windows.Forms.Label lbStart_Selection;
		private System.Windows.Forms.TextBox tbResult_Selection;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.Label lbDelay;
		private System.Windows.Forms.TextBox tbDelay;
		private System.Windows.Forms.TextBox tbTotal;
		private System.Windows.Forms.Label lbTotal;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Button btBubble;
		private System.Windows.Forms.Button btSelection;
		private System.Windows.Forms.Button btInsertion;
		private System.Windows.Forms.Label lbTotal_Bubble;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.Label label13;
		private System.Windows.Forms.Label label15;
		private System.Windows.Forms.Label lbTotal_Insertion;
		private System.Windows.Forms.Label lbTotal_Selection;
		private System.Windows.Forms.Button btClear;
		private System.Windows.Forms.Button btClearDisplay;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.Label label14;
		private System.Windows.Forms.Label label16;
		
		private System.Windows.Forms.TextBox tbList;
		

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

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <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(Form1));
			this.plBubble = new System.Windows.Forms.Panel();
			this.label11 = new System.Windows.Forms.Label();
			this.lbTotal_Bubble = new System.Windows.Forms.Label();
			this.label12 = new System.Windows.Forms.Label();
			this.btBubble = new System.Windows.Forms.Button();
			this.tbResult_Bubble = new System.Windows.Forms.TextBox();
			this.lbEnd_Bubble = new System.Windows.Forms.Label();
			this.lbStart_Bubble = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.plInsertion = new System.Windows.Forms.Panel();
			this.label16 = new System.Windows.Forms.Label();
			this.label15 = new System.Windows.Forms.Label();
			this.btInsertion = new System.Windows.Forms.Button();
			this.label7 = new System.Windows.Forms.Label();
			this.label8 = new System.Windows.Forms.Label();
			this.label9 = new System.Windows.Forms.Label();
			this.lbStart_Insertion = new System.Windows.Forms.Label();
			this.lbEnd_Insertion = new System.Windows.Forms.Label();
			this.tbResult_Insertion = new System.Windows.Forms.TextBox();
			this.lbTotal_Insertion = new System.Windows.Forms.Label();
			this.plSelection = new System.Windows.Forms.Panel();
			this.label13 = new System.Windows.Forms.Label();
			this.btSelection = new System.Windows.Forms.Button();
			this.label3 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.lbEnd_Selection = new System.Windows.Forms.Label();
			this.lbStart_Selection = new System.Windows.Forms.Label();
			this.tbResult_Selection = new System.Windows.Forms.TextBox();
			this.lbTotal_Selection = new System.Windows.Forms.Label();
			this.label14 = new System.Windows.Forms.Label();
			this.btnGenerate = new System.Windows.Forms.Button();
			this.btnStart = new System.Windows.Forms.Button();
			this.tbList = new System.Windows.Forms.TextBox();
			this.label10 = new System.Windows.Forms.Label();
			this.lbDelay = new System.Windows.Forms.Label();
			this.tbDelay = new System.Windows.Forms.TextBox();
			this.tbTotal = new System.Windows.Forms.TextBox();
			this.lbTotal = new System.Windows.Forms.Label();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.btClear = new System.Windows.Forms.Button();
			this.btClearDisplay = new System.Windows.Forms.Button();
			this.plBubble.SuspendLayout();
			this.plInsertion.SuspendLayout();
			this.plSelection.SuspendLayout();
			this.SuspendLayout();
			// 
			// plBubble
			// 
			this.plBubble.BackColor = System.Drawing.Color.Transparent;
			this.plBubble.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.plBubble.Controls.AddRange(new System.Windows.Forms.Control[] {
																				   this.label11,
																				   this.lbTotal_Bubble,
																				   this.label12,
																				   this.btBubble,
																				   this.tbResult_Bubble,
																				   this.lbEnd_Bubble,
																				   this.lbStart_Bubble,
																				   this.label6,
																				   this.label4,
																				   this.label5});
			this.plBubble.Location = new System.Drawing.Point(24, 72);
			this.plBubble.Name = "plBubble";
			this.plBubble.Size = new System.Drawing.Size(760, 104);
			this.plBubble.TabIndex = 0;
			// 
			// label11
			// 
			this.label11.BackColor = System.Drawing.SystemColors.ControlDark;
			this.label11.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label11.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.label11.Image = ((System.Drawing.Bitmap)(resources.GetObject("label11.Image")));
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(760, 23);
			this.label11.TabIndex = 13;
			this.label11.Text = "Bubble Sort";
			this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// lbTotal_Bubble
			// 
			this.lbTotal_Bubble.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.lbTotal_Bubble.Location = new System.Drawing.Point(376, 32);
			this.lbTotal_Bubble.Name = "lbTotal_Bubble";
			this.lbTotal_Bubble.Size = new System.Drawing.Size(176, 23);
			this.lbTotal_Bubble.TabIndex = 11;
			this.lbTotal_Bubble.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label12
			// 
			this.label12.Location = new System.Drawing.Point(296, 32);
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(72, 23);
			this.label12.TabIndex = 12;
			this.label12.Text = "Total Time : ";
			this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// btBubble
			// 
			this.btBubble.BackgroundImage = ((System.Drawing.Bitmap)(resources.GetObject("btBubble.BackgroundImage")));
			this.btBubble.Location = new System.Drawing.Point(672, 32);
			this.btBubble.Name = "btBubble";
			this.btBubble.Size = new System.Drawing.Size(72, 24);
			this.btBubble.TabIndex = 10;
			this.btBubble.Text = "Start";
			this.btBubble.Click += new System.EventHandler(this.btBubble_Click);
			// 
			// tbResult_Bubble
			// 
			this.tbResult_Bubble.Location = new System.Drawing.Point(88, 80);
			this.tbResult_Bubble.Name = "tbResult_Bubble";
			this.tbResult_Bubble.Size = new System.Drawing.Size(656, 20);
			this.tbResult_Bubble.TabIndex = 2;
			this.tbResult_Bubble.Text = "Result of Bubble Sort";
			// 
			// lbEnd_Bubble
			// 
			this.lbEnd_Bubble.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.lbEnd_Bubble.Location = new System.Drawing.Point(88, 56);
			this.lbEnd_Bubble.Name = "lbEnd_Bubble";
			this.lbEnd_Bubble.Size = new System.Drawing.Size(176, 23);
			this.lbEnd_Bubble.TabIndex = 1;
			this.lbEnd_Bubble.Text = "lbEnd_Bubble";
			this.lbEnd_Bubble.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// lbStart_Bubble
			// 
			this.lbStart_Bubble.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.lbStart_Bubble.Location = new System.Drawing.Point(88, 32);
			this.lbStart_Bubble.Name = "lbStart_Bubble";
			this.lbStart_Bubble.Size = new System.Drawing.Size(176, 23);
			this.lbStart_Bubble.TabIndex = 0;
			this.lbStart_Bubble.Text = "lbStart_Bubble";
			this.lbStart_Bubble.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(8, 32);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(72, 23);
			this.label6.TabIndex = 7;
			this.label6.Text = "Start Time :";
			this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(16, 80);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(64, 23);
			this.label4.TabIndex = 9;
			this.label4.Text = "Result :";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(8, 56);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(72, 23);
			this.label5.TabIndex = 8;
			this.label5.Text = "End Time :";
			this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// plInsertion
			// 
			this.plInsertion.BackColor = System.Drawing.Color.Transparent;
			this.plInsertion.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.plInsertion.Controls.AddRange(new System.Windows.Forms.Control[] {
																					  this.label16,
																					  this.label15,
																					  this.btInsertion,
																					  this.label7,
																					  this.label8,
																					  this.label9,
																					  this.lbStart_Insertion,
																					  this.lbEnd_Insertion,
																					  this.tbResult_Insertion,
																					  this.lbTotal_Insertion});
			this.plInsertion.Location = new System.Drawing.Point(24, 304);
			this.plInsertion.Name = "plInsertion";
			this.plInsertion.Size = new System.Drawing.Size(760, 112);
			this.plInsertion.TabIndex = 3;
			// 
			// label16
			// 
			this.label16.BackColor = System.Drawing.SystemColors.ControlDark;
			this.label16.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label16.ForeColor = System.Drawing.SystemColors.ControlLightLight;
			this.label16.Image = ((System.Drawing.Bitmap)(resources.GetObject("label16.Image")));
			this.label16.Name = "label16";
			this.label16.Size = new System.Drawing.Size(760, 23);
			this.label16.TabIndex = 15;
			this.label16.Text = "Insertion Sort";
			this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label15
			// 
			this.label15.Location = new System.Drawing.Point(296, 32);
			this.label15.Name = "label15";
			this.label15.Size = new System.Drawing.Size(72, 23);
			this.label15.TabIndex = 14;
			this.label15.Text = "Total Time : ";

⌨️ 快捷键说明

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