Круговая диаграмма принятия решений (паутинная диаграмма)
Контрольная работа - Компьютеры, программирование
Другие контрольные работы по предмету Компьютеры, программирование
B =0;Settings settings = new Settings();
Form1()
{();
}
//получение данных для таблицы и рисованияvoid getData()
{= (int)numericUpDown1.Value;= 360 / countOfPie;= (int)numericUpDown2.Value;.setLegend(checkBox1.Checked);.setAxis(checkBox2.Checked);.setPipki(checkBox3.Checked);.setPipSize((int)numericUpDown3.Value);.setCountSum(checkBox4.Checked);
}
// создание и заполнение таблицы из формыvoid createTableOfWeight()
{= new double[rows, cols];(int i = 0; i < rows; i++)
{(int j = 0; j < cols; j++)
{[i, j] = Convert.ToDouble(dataGridView1.Rows[i].Cells[j].Value);
}
}
/*(int i = 0; i < rows; i++)
{(int j = 0; j < cols; j++)
{.AppendText(tables[i,j].ToString());.AppendText(" ");
}.AppendText(" /n ");
}
*/
}
//проверка правильного заполнения рядовBoolean checkTable()
{
[]tempTable = new int[rows];check = false;sum = 0;k=0;(int i = 0; i < tables.GetLength(0); i++)
{= 0;
(int j = 0; j < tables.GetLength(1); j++)
{+= tables[i,j];
// textBox1.AppendText(sum.ToString());
// textBox1.AppendText(" ");
}
//если сумма в ряде больше единицы, записываем номер этого ряда
(sum > 1)
{[k] = i;++;= 0;
//textBox1.AppendText("get bug ");
}
}
//заполним таблицу ошибочных рядов= new int[k];(int l =0; l<k; l++)
{
[l] = tempTable[l];
}
//если все ряды в порядке(k == 0)
{= true;
}check;
}
//рисуемvoid button1_Click(object sender, EventArgs e)
{= true;
//DEBUG
// textBox1.AppendText(degrees.ToString());
// textBox1.AppendText(" ");
//DEBUG
//забираем данные();
//забираем данные из таблицы();
//проверяем данные, если в порядке, то рисуем.(checkTable() == true)
{.Text = "Данные верны ";();
}
{
// MessageBox msg = new MessageBox;
//не в порядкеtext;= "Ошибка в заполнении рядов: ";(int i = 0; i < wrongRows.Length; i++)
{+= " " + (wrongRows[i]+1) + ";";
}.Text = text;
}
}
//рисуем пирогvoid drawMyPie()
{= new Bitmap(pictureBox1.Width, pictureBox1.Height);.Image = bm;g = Graphics.FromImage(pictureBox1.Image);
//длина единичного отрезка на пирогеradius = 0;
//Graphics g = Graphics.FromHwnd(panel1.Handle);.SmoothingMode = SmoothingMode.AntiAlias;.Clear(Color.AntiqueWhite);
//смещениеdx = 260;
//масштаб пирога. цифра больше - масштаб меньше.call = 70;
//пирогrect = new Rectangle(call, call, pictureBox1.Width - dx-call*2,.Height - call*2);start, end;= 0;= 0;(int i = 0; i < countOfPie; i++)
{= i * degrees;= start + degrees;.DrawPie(new Pen(Color.Black, 1), rect, 0, end);
}
// единичный отрезок= (pictureBox1.Height - call*2) / 2; //старый вариант
//radius = (panel1.Height) / 2 - 10;
// центр областиOx = (pictureBox1.Width-dx) / 2;Oy = pictureBox1.Height / 2;R = 0;angle = 0;
//рисуем пипки(settings.getPipki() == true)
{
//задание точек для пипок[] pipkiPoints = new PointF[rows];Rpipki = 0;
(int lm = 0; lm < 10; lm++)
{
(int m = 0; m < rows; m++)
{= (Convert.ToDouble(lm)+1)/10*radius;
//textBox1.AppendText("Rpipki = ");
//textBox1.AppendText(Rpipki.ToString());
//textBox1.AppendText("LM = ");
///textBox1.AppendText(lm.ToString());= Math.PI * (degrees * m) / 180.0;[m].X = (float)(Rpipki * Math.Cos(angle)) + Ox;[m].Y = (float)(Rpipki * Math.Sin(angle)) + Oy;myBrush = new SolidBrush(Color.Black);
//SolidBrush myBrush = new SolidBrush(Color.Red);(((lm+1) % 5) == 0)
{.FillEllipse(myBrush, pipkiPoints[m].X - settings.getPipSize() / 2, pipkiPoints[m].Y - settings.getPipSize() / 2, settings.getPipSize(), settings.getPipSize());
}.FillEllipse(myBrush, pipkiPoints[m].X - settings.getPipSize() / 4, pipkiPoints[m].Y - settings.getPipSize() / 4, settings.getPipSize() / 2, settings.getPipSize() / 2);
}.FillEllipse(new SolidBrush(Color.Black), Ox - settings.getPipSize() / 2, Oy - settings.getPipSize() / 2, settings.getPipSize(), settings.getPipSize());
}
}
//рисуем подписи(settings.getAxis() == true)
{
//определение точек для подписей осей[] textPoints = new PointF[rows];R1 = 0;
(int s = 0; s < rows; s++)
{text2 = "Критерий ";= radius + 40;= Math.PI * (degrees * s) / 180.0;[s].X = (float)(R1 * Math.Cos(angle)) + Ox;[s].Y = (float)(R1 * Math.Sin(angle)) + Oy;((degrees * s) == 90)
{[s].Y += 10;
}((degrees * s) == 270)
{[s].Y -= 10;
}((degrees*s > 100) && (degrees*s < 260))
{.AppendText(degrees.ToString());.AppendText("\n");[s].X -= 32;.AppendText(textPoints[s].X.ToString());.AppendText("\n");
}+= " " + Convert.ToString(s + 1);.DrawString(text2, new Font("helveticz", 8), Brushes.Black, textPoints[s]);
}
}
[] polygonPoints = new PointF[rows];
//рисование многоугольника и надписей.(int j = 0; j < cols; j++)
{
//получаем точки для многоугольника(int i = 0; i < rows; i++)
{= tables[i, j] * radius;= Math.PI * (degrees * i) / 180.0;[i].X = (float)(R * Math.Cos(angle)) + Ox;[i].Y = (float)(R * Math.Sin(angle)) + Oy;
}
text = "Объект №";+= " " + Convert.ToString(j+1);
myPen = new Pen(Color.FromArgb(cR, cG, cB), 2);
//тип линии определяем(j % 3 == 0).DashStyle = DashStyle.Dot;(j % 2 == 0).DashStyle = DashStyle.Dash;(j % 5 == 0).DashStyle = DashStyle.DashDot;();(polygonPoints.Length > 1)
{.DrawPolygon(myPen, polygonPoints);(settings.getLegend() == true)
{.DrawLine(myPen, (rect.Width + 220), (j + 1) * 21, (rect.Width + 280), (j + 1) * 21);.DrawString(text, new Font("Helvetica", 8), Brushes.Black, rect.Width + 300, (j + 1) * 20);
}
}
}.Clear();(settings.getCountSum() == true)
{max = 0;ch = 0;
//подсчет площади многоугольника.
//первый и второй катет треугольникаpRS1 = 0;pRS2 = 0;
//площадь треугольникаsquareSum = 0;squareTriangle = 0;
(int countSq = 0; countSq < cols; countSq++)
{(int pS = 1; pS <= rows; pS++)
{(pS == rows)
{= tables[0, countSq] * radius;
}
{= tables[pS, countSq] * radius;
}= tables[pS - 1, countSq] * radius;
= Math.PI * (degrees) / 180.0;
= 0.5 * pRS1 * pRS2 * (float)(Math.Sin(angle));+= squareTriangle;
}(squareSum > max)
{= countSq;= squareSum;
}.AppendText("Площадь многоугольника №: ");.AppendText(Convert.ToString(countSq+1));.AppendText(" ");.AppendText(squareSum.ToString());.AppendText(" единиц; ");.AppendText("\n");
//string tex = "lj";
//tex.
}.AppendText("Максимальная площадь ");.AppendText(max.ToString());.AppendText(" у объекта № ");.AppendText(Convert.ToString(ch+1));
.Dispose();.Invalidate();
}
}
void nextRGB()
{dx = 60;+= dx;(cR > 255)
{+= dx;-= 255;(cG > 255)
{+= dx;-= 255;(cB > 255)
{-= 255;
}
}
}
}
//onPaintvoid panel1_Paint(object sender, PaintEventArgs e)
{g = e.Graphics;(goodGo == true)();
}
//создание таблицыvoid CreateTable(int row, int col)
{_row = row;_col = col;.ColumnCount = _col;.RowHeadersVisible = false;.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;.RowCount = _row;
}
//задание данных для таблицыvoid Button2_Click(object sender, EventArgs e)
{();= (int)countOfPie;= aims;(rows, cols);
}
//применить настройки и отрисоватьvoid button3_Click_1(object sender, EventArgs e)
{(goodGo == true)
{();();
}
}
void выходToolStripMenuItem_Click(object sender, EventArgs e)
{();
}
//очистить область диаграммvoid button5_Click(object sender, EventArgs e)
{
// Graphics g = Graphics.FromHwnd(panel1.Handle);g = Graphics.FromHwnd(pictureBox1.Handle);.Clear(Color.AntiqueWhite);
}
void Form1_Load(object sender, EventArgs e)