mirror of
https://github.com/JDM170/fuzzy_set_calculator
synced 2025-12-10 05:57:18 +07:00
Update
* Events for the graph rendering buttons have been changed from 3 events to 1 event
* Added 2 new methods ("compareLowHighValues", "compareAlphaLowHigh")
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
6
Form1.Designer.cs
generated
6
Form1.Designer.cs
generated
@@ -248,7 +248,7 @@
|
||||
this.build_a.TabIndex = 8;
|
||||
this.build_a.Text = "Построить A";
|
||||
this.build_a.UseVisualStyleBackColor = true;
|
||||
this.build_a.Click += new System.EventHandler(this.build_a_Click);
|
||||
this.build_a.Click += new System.EventHandler(this.build_graph_Click);
|
||||
//
|
||||
// build_b
|
||||
//
|
||||
@@ -258,7 +258,7 @@
|
||||
this.build_b.TabIndex = 9;
|
||||
this.build_b.Text = "Построить B";
|
||||
this.build_b.UseVisualStyleBackColor = true;
|
||||
this.build_b.Click += new System.EventHandler(this.build_b_Click);
|
||||
this.build_b.Click += new System.EventHandler(this.build_graph_Click);
|
||||
//
|
||||
// build_c
|
||||
//
|
||||
@@ -268,7 +268,7 @@
|
||||
this.build_c.TabIndex = 10;
|
||||
this.build_c.Text = "Построить C";
|
||||
this.build_c.UseVisualStyleBackColor = true;
|
||||
this.build_c.Click += new System.EventHandler(this.build_c_Click);
|
||||
this.build_c.Click += new System.EventHandler(this.build_graph_Click);
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
|
||||
108
Form1.cs
108
Form1.cs
@@ -123,8 +123,35 @@ namespace WindowsFormsApp1
|
||||
points.AddXY(matrix[2, row], matrix[0, row]);
|
||||
}
|
||||
|
||||
// Сравнение нижних и верхних значений
|
||||
bool compareLowHighValues(double[,] matrix)
|
||||
{
|
||||
for(int i = 0; i < matrix.GetLength(1); i++)
|
||||
if (matrix[1, i] > matrix[2, i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool compareAlphaLowHigh(double[,] matrix)
|
||||
{
|
||||
matrix = SortMatrix(matrix);
|
||||
for(int i = 1; i < matrix.GetLength(1); i++)
|
||||
if (matrix[1, i] < matrix[1, i-1] || matrix[2, i] > matrix[2, i-1])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
//dataGridView1.Rows.Add(new object[] { 0, 1, 9 });
|
||||
//dataGridView1.Rows.Add(new object[] { 0.5, 2, 8 });
|
||||
//dataGridView1.Rows.Add(new object[] { 1, 3, 4 });
|
||||
|
||||
//dataGridView2.Rows.Add(new object[] { 0, 1, 9 });
|
||||
//dataGridView2.Rows.Add(new object[] { 0.5, 3, 6 });
|
||||
//dataGridView2.Rows.Add(new object[] { 1, 4, 5 });
|
||||
//dataGridView2.Rows.Add(new object[] { 0.2, 2, 7 });
|
||||
|
||||
dataGridView1.Rows.Add(new object[] { 0, 1, 9 });
|
||||
dataGridView1.Rows.Add(new object[] { 0.5, 2, 8 });
|
||||
dataGridView1.Rows.Add(new object[] { 1, 3, 4 });
|
||||
@@ -147,6 +174,16 @@ namespace WindowsFormsApp1
|
||||
{
|
||||
double[,] matrixA = ConvertDGtoMatrix(dataGridView1),
|
||||
matrixB = ConvertDGtoMatrix(dataGridView2);
|
||||
if (!compareLowHighValues(matrixA) || !compareLowHighValues(matrixB))
|
||||
{
|
||||
MessageBox.Show("Нижнее значение не может быть больше верхнего!");
|
||||
return;
|
||||
}
|
||||
if (!compareAlphaLowHigh(matrixA) || !compareAlphaLowHigh(matrixB))
|
||||
{
|
||||
MessageBox.Show("Некорректное значение");
|
||||
return;
|
||||
}
|
||||
GetUnknownAlpha(matrixA, matrixB).Deconstruct(out matrixA, out matrixB);
|
||||
dataGridView3.Rows.Clear();
|
||||
int matrixLength = matrixA.GetLength(1);
|
||||
@@ -165,6 +202,16 @@ namespace WindowsFormsApp1
|
||||
{
|
||||
double[,] matrixA = ConvertDGtoMatrix(dataGridView1),
|
||||
matrixB = ConvertDGtoMatrix(dataGridView2);
|
||||
if (!compareLowHighValues(matrixA) || !compareLowHighValues(matrixB))
|
||||
{
|
||||
MessageBox.Show("Нижнее значение не может быть больше верхнего!");
|
||||
return;
|
||||
}
|
||||
if (!compareAlphaLowHigh(matrixA) || !compareAlphaLowHigh(matrixB))
|
||||
{
|
||||
MessageBox.Show("Некорректное значение");
|
||||
return;
|
||||
}
|
||||
GetUnknownAlpha(matrixA, matrixB).Deconstruct(out matrixA, out matrixB);
|
||||
dataGridView3.Rows.Clear();
|
||||
int matrixLength = matrixA.GetLength(1);
|
||||
@@ -183,6 +230,16 @@ namespace WindowsFormsApp1
|
||||
{
|
||||
double[,] matrixA = ConvertDGtoMatrix(dataGridView1),
|
||||
matrixB = ConvertDGtoMatrix(dataGridView2);
|
||||
if (!compareLowHighValues(matrixA) || !compareLowHighValues(matrixB))
|
||||
{
|
||||
MessageBox.Show("Нижнее значение не может быть больше верхнего!");
|
||||
return;
|
||||
}
|
||||
if (!compareAlphaLowHigh(matrixA) || !compareAlphaLowHigh(matrixB))
|
||||
{
|
||||
MessageBox.Show("Некорректное значение");
|
||||
return;
|
||||
}
|
||||
GetUnknownAlpha(matrixA, matrixB).Deconstruct(out matrixA, out matrixB);
|
||||
dataGridView3.Rows.Clear();
|
||||
int matrixLength = matrixA.GetLength(1);
|
||||
@@ -201,6 +258,16 @@ namespace WindowsFormsApp1
|
||||
{
|
||||
double[,] matrixA = ConvertDGtoMatrix(dataGridView1),
|
||||
matrixB = ConvertDGtoMatrix(dataGridView2);
|
||||
if (!compareLowHighValues(matrixA) || !compareLowHighValues(matrixB))
|
||||
{
|
||||
MessageBox.Show("Нижнее значение не может быть больше верхнего!");
|
||||
return;
|
||||
}
|
||||
if (!compareAlphaLowHigh(matrixA) || !compareAlphaLowHigh(matrixB))
|
||||
{
|
||||
MessageBox.Show("Некорректное значение");
|
||||
return;
|
||||
}
|
||||
GetUnknownAlpha(matrixA, matrixB).Deconstruct(out matrixA, out matrixB);
|
||||
dataGridView3.Rows.Clear();
|
||||
int matrixLength = matrixA.GetLength(1);
|
||||
@@ -226,19 +293,44 @@ namespace WindowsFormsApp1
|
||||
}
|
||||
}
|
||||
|
||||
private void build_a_Click(object sender, EventArgs e)
|
||||
private void build_graph_Click(object sender, EventArgs e)
|
||||
{
|
||||
PrintGraph(SortMatrix(ConvertDGtoMatrix(dataGridView1)), "A1");
|
||||
DataGridView selected_dgv = null;
|
||||
string selected_graph = "";
|
||||
switch ((sender as Button).Name)
|
||||
{
|
||||
case "build_a":
|
||||
{
|
||||
selected_dgv = dataGridView1;
|
||||
selected_graph = "A1";
|
||||
break;
|
||||
}
|
||||
|
||||
private void build_b_Click(object sender, EventArgs e)
|
||||
case "build_b":
|
||||
{
|
||||
PrintGraph(SortMatrix(ConvertDGtoMatrix(dataGridView2)), "B2");
|
||||
selected_dgv = dataGridView2;
|
||||
selected_graph = "B2";
|
||||
break;
|
||||
}
|
||||
|
||||
private void build_c_Click(object sender, EventArgs e)
|
||||
case "build_c":
|
||||
{
|
||||
PrintGraph(SortMatrix(ConvertDGtoMatrix(dataGridView3)), "C3");
|
||||
selected_dgv = dataGridView3;
|
||||
selected_graph = "C3";
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
double[,] matrix = SortMatrix(ConvertDGtoMatrix(selected_dgv));
|
||||
if (!compareLowHighValues(matrix))
|
||||
{
|
||||
MessageBox.Show("Нижнее значение не может быть больше верхнего!");
|
||||
return;
|
||||
}
|
||||
if (!compareAlphaLowHigh(matrix))
|
||||
{
|
||||
MessageBox.Show("Некорректное значение");
|
||||
return;
|
||||
}
|
||||
PrintGraph(matrix, selected_graph);
|
||||
}
|
||||
|
||||
private void del_by_name_Click(object sender, EventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user