84 lines
2.5 KiB
C#
84 lines
2.5 KiB
C#
|
using System.Diagnostics;
|
||
|
|
||
|
namespace Lab6
|
||
|
{
|
||
|
public partial class Form1 : Form
|
||
|
{
|
||
|
public Controller service;
|
||
|
public Alg1 Alg1;
|
||
|
public Alg2 Alg2;
|
||
|
public Stopwatch stopwatch;
|
||
|
public int[,] matrixA;
|
||
|
|
||
|
public Form1()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
this.service = new Controller();
|
||
|
this.Alg1 = new Alg1();
|
||
|
this.Alg2 = new Alg2();
|
||
|
this.stopwatch = new Stopwatch();
|
||
|
}
|
||
|
|
||
|
private void buttonAlg1_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
stopwatch.Start();
|
||
|
int result = Alg1.Begin(matrixA);
|
||
|
stopwatch.Stop();
|
||
|
|
||
|
labelResultTime.Text = "" + stopwatch.Elapsed;
|
||
|
textBoxResult.Text = Convert.ToString(result);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
stopwatch.Reset();
|
||
|
}
|
||
|
|
||
|
private void buttonAlg2_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
double[,] doubleMatrix = service.ConvertArray(matrixA);
|
||
|
|
||
|
stopwatch.Start();
|
||
|
textBoxResult.Text = Convert.ToString(Alg2.Begin(doubleMatrix, (int)countStream.Value));
|
||
|
stopwatch.Stop();
|
||
|
|
||
|
labelResultTime.Text = "" + stopwatch.Elapsed;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
stopwatch.Reset();
|
||
|
}
|
||
|
|
||
|
private void buttonLoadMatrix1_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
openFileDialog1.ShowDialog();
|
||
|
string filePath = openFileDialog1.FileName;
|
||
|
string result = service.GetTextFromFile(filePath);
|
||
|
|
||
|
textBoxMatrix1.Text = result;
|
||
|
|
||
|
matrixA = service.GetMatrixFromTextbox(result);
|
||
|
}
|
||
|
|
||
|
private void buttonGenerateMatrix1_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
matrixA = service.GenerateNewMatrix((int)genCountRowCol.Value);
|
||
|
textBoxMatrix1.Text = service.PrintResultMatrix(matrixA);
|
||
|
}
|
||
|
|
||
|
private void button1_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
textBoxMatrix1.Text = "";
|
||
|
textBoxResult.Text = "";
|
||
|
matrixA = null;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|