distributed-computing/tasks/grenaderova-aa/lab_5/5LABA/Form1.cs

81 lines
2.5 KiB
C#
Raw Permalink Normal View History

2023-12-18 16:34:36 +04:00
using System.Diagnostics;
namespace 5LABA
{
public partial class Form1 : Form
{
public Controller service;
public Alg1 Alg1;
public Alg2 Alg2;
public Stopwatch stopwatch;
public int[,] matrixA;
public int[,] matrixB;
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[,] matrixResult = Alg1.Begin(matrixA, matrixB);
stopwatch.Stop();
labelResultTime.Text = "" + stopwatch.Elapsed;
textBoxResult.Text = service.PrintResultMatrix(matrixResult);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
stopwatch.Reset();
}
private void buttonAlg2_Click(object sender, EventArgs e)
{
try
{
stopwatch.Start();
int[,] matrixResult = Alg2.Begin(matrixA, matrixB, (int)countStream.Value);
stopwatch.Stop();
labelResultTime.Text = "" + stopwatch.Elapsed;
textBoxResult.Text = service.PrintResultMatrix(matrixResult);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
stopwatch.Reset();
}
private void buttonGenerateMatrix1_Click(object sender, EventArgs e)
{
matrixA = service.GenerateNewMatrix((int)genCountRowCol.Value);
textBoxMatrix1.Text = service.PrintResultMatrix(matrixA);
}
private void buttonGenerateMatrix2_Click(object sender, EventArgs e)
{
matrixB = service.GenerateNewMatrix((int)genCountRowCol.Value);
textBoxMatrix2.Text = service.PrintResultMatrix(matrixB);
}
private void button1_Click(object sender, EventArgs e)
{
textBoxMatrix1.Text = "";
textBoxMatrix2.Text = "";
textBoxResult.Text = "";
matrixA = null;
matrixB = null;
}
}
}