Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace lab_5
- {
- public partial class Paint_gist : Form
- {
- clas_for_data mas = new clas_for_data();
- public Paint_gist(clas_for_data mas1)
- {
- InitializeComponent();
- this.WindowState = FormWindowState.Maximized;
- mas = mas1;
- }
- private void Paint_gist_Paint(object sender, PaintEventArgs e)
- {
- Graphics g = Graphics.FromHwnd(this.Handle);
- g.TranslateTransform(0, 200);
- g.ScaleTransform(1, -1);
- List<SolidBrush> esc = new List<SolidBrush>();
- Random r = new Random();
- //рисование столбиков
- for (int i = 0; i < mas.mas.Count; i++)
- {
- int t = 50*i+5;
- esc.Add(new SolidBrush(Color.FromArgb(255, r.Next() % 255, r.Next() % 255, r.Next() % 255)));
- for (int s = 0; s < mas.mas[i]; s++)
- {
- Rectangle rec = new Rectangle(t, 20, 40, s);
- g.FillRectangle(esc[i], rec);
- System.Threading.Thread.Sleep(10);
- }
- Graphics g1 = e.Graphics;
- g1.DrawString(Convert.ToString(mas.mas[i]), new Font("Arial", 16), new SolidBrush(Color.DarkRed), t, 200);
- }
- Pen blackPen = new Pen(Color.Black, 3);
- double sum = 0;
- for (int a = 0; a < mas.mas.Count; a++)
- sum += mas.mas[a];
- double degree = sum/360;
- double Angel = 0;
- int sweepAngle = 0;
- int startAngle = sweepAngle;
- //рисование секторов
- for (int i = 0; i < mas.mas.Count; i++)
- {
- startAngle += sweepAngle;int x = 578, y = 300, width = 300, height = 300;
- Angel = mas.mas[i]/degree;
- sweepAngle = (int)Angel;
- Graphics ell = Graphics.FromHwnd(this.Handle);
- // Draw pie to screen.
- if(i == mas.mas.Count-1){
- int finish = startAngle;
- do
- {
- ell.FillPie(esc[i], x, y, width, height, finish, 1);
- finish++;
- } while (finish < 360);
- break;
- }
- ell.FillPie(esc[i], x, y, width, height, startAngle, sweepAngle);
- }
- Angel = 0;
- sweepAngle = 0;
- startAngle = sweepAngle;
- Graphics g2 = e.Graphics;
- for (int i = 0; i < mas.mas.Count; i++)
- {
- startAngle += sweepAngle;
- // Create location and size of ellipse.
- int x = 578, y = 300, width = 300, height = 300;
- Angel = mas.mas[i] / degree;
- sweepAngle = (int)Angel;
- Graphics ell = Graphics.FromHwnd(this.Handle);
- // Draw pie to screen.
- if (i == mas.mas.Count - 1)
- {
- break;
- }
- ell.DrawPie(new Pen(Color.Black, 2), x, y, width, height, startAngle, sweepAngle);
- }
- g2.DrawEllipse(blackPen, 578, 300, 300, 300);
- }
- private void инфоToolStripMenuItem_Click(object sender, EventArgs e)
- {
- MessageBox.Show("Артемьев Даниил Иванович, 525а гр.", "");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement