?? mainform.cs
字號:
?using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
LoggingLib.Impl.Logger.getInstance().addLog(this.textBoxLog1);
//int[] originalData = new int[] { 89, 45, 23, 12, 34, 0, 55, 9, 112, 6, 20, 345, 123, 45, 13, -9, 234, 7, 1, 39, 63, 6, 131234 };
//Processor.CreatProcessors(originalData, 4);
//Processor.StartProcessors();
//Processor.WaitSortCompleted();
//int[] sortedData = Processor.SortedDatas;
}
private void button1_Click(object sender, EventArgs e)
{
if (radioButtonRadom.Checked)
{
int[] originalData = new int[arrayLength];
Random r = new Random();
for (int i = 0; i < originalData.Length; i++)
{
originalData[i] = r.Next(0 - arrayLength * 2, arrayLength * 2);
}
string temp = "The original datas are:" + Environment.NewLine;
for (int i = 0; i < originalData.Length; i++)
{
temp += originalData[i].ToString() + " ";
}
LoggingLib.Impl.Logger.getInstance().debug(temp);
int p = (int)this.comboBox1.SelectedItem;
Processor.CreatProcessors(originalData, p);
Processor.StartProcessors();
Processor.WaitSortCompleted();
int[] sortedData = Processor.SortedDatas;
temp = "The sorted datas are:" + Environment.NewLine;
for (int i = 0; i < sortedData.Length; i++)
{
temp += sortedData[i].ToString() + " ";
}
LoggingLib.Impl.Logger.getInstance().debug(temp);
}
else if (radioButtonFile.Checked)
{
System.Windows.Forms.MessageBox.Show("對不起,本程序目前還不支持文件輸入數據!");
}
else if (radioButtonHand.Checked)
{
System.Windows.Forms.MessageBox.Show("對不起,本程序目前還不支持手動輸入數據!");
}
else
{
System.Windows.Forms.MessageBox.Show("請選擇一個數據輸入方式!");
}
}
private void radioButtonRadom_CheckedChanged(object sender, EventArgs e)
{
if (radioButtonRadom.Checked)
{
this.textBoxLength.Enabled = true;
this.textBoxLength.Focus();
}
else
{
this.textBoxLength.Enabled = false;
}
}
private void textBoxLength_Validated(object sender, EventArgs e)
{
try
{
int length = Convert.ToInt32(textBoxLength.Text);
if (length < 4)
{
System.Windows.Forms.MessageBox.Show("數組長度必須>=3");
this.textBoxLength.Focus();
}
arrayLength = length;
int p = (int)Math.Truncate(Math.Sqrt(length));
this.comboBox1.Items.Clear();
for (int i = 2; i <= p; i++)
{
this.comboBox1.Items.Add(i);
}
this.comboBox1.SelectedIndex = this.comboBox1.Items.Count - 1;
}
catch (Exception ex)
{
MessageBox.Show("請輸入一個大于1的整數!");
this.textBoxLength.Focus();
}
}
private int arrayLength = -1;
private void button2_Click(object sender, EventArgs e)
{
this.textBoxLog1.Clear();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -