Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8.  
  9. namespace lab_5
  10. {
  11.     public partial class Paint_gist : Form
  12.     {
  13.         clas_for_data mas = new clas_for_data();
  14.         public Paint_gist(clas_for_data mas1)
  15.         {
  16.             InitializeComponent();
  17.             this.WindowState = FormWindowState.Maximized;
  18.             mas = mas1;
  19.         }
  20.        
  21.      
  22.         private void Paint_gist_Paint(object sender, PaintEventArgs e)
  23.         {
  24.             Graphics g = Graphics.FromHwnd(this.Handle);
  25.  
  26.             g.TranslateTransform(0, 200);
  27.             g.ScaleTransform(1, -1);
  28.             List<SolidBrush> esc = new List<SolidBrush>();
  29.             Random r = new Random();
  30.             //рисование столбиков
  31.             for (int i = 0; i < mas.mas.Count; i++)
  32.             {
  33.                 int t = 50*i+5;
  34.                 esc.Add(new SolidBrush(Color.FromArgb(255, r.Next() % 255, r.Next() % 255, r.Next() % 255)));
  35.                 for (int s = 0; s < mas.mas[i]; s++)
  36.                 {
  37.                    
  38.                     Rectangle rec = new Rectangle(t, 20, 40, s);
  39.                     g.FillRectangle(esc[i], rec);
  40.                     System.Threading.Thread.Sleep(10);
  41.                 }
  42.                 Graphics g1 = e.Graphics;
  43.                 g1.DrawString(Convert.ToString(mas.mas[i]), new Font("Arial", 16), new SolidBrush(Color.DarkRed), t, 200);
  44.             }
  45.             Pen blackPen = new Pen(Color.Black, 3);
  46.             double sum = 0;
  47.             for (int a = 0; a < mas.mas.Count; a++)
  48.                 sum += mas.mas[a];
  49.             double degree = sum/360;
  50.             double Angel = 0;
  51.             int sweepAngle = 0;
  52.             int startAngle = sweepAngle;
  53.            
  54.             //рисование секторов
  55.             for (int i = 0; i < mas.mas.Count; i++)
  56.             {
  57.  
  58.                 startAngle += sweepAngle;int x = 578, y = 300, width = 300, height = 300;
  59.                 Angel = mas.mas[i]/degree;
  60.                 sweepAngle = (int)Angel;
  61.                 Graphics ell = Graphics.FromHwnd(this.Handle);
  62.                 // Draw pie to screen.
  63.                 if(i == mas.mas.Count-1){
  64.                     int finish = startAngle;
  65.                     do
  66.                     {
  67.                         ell.FillPie(esc[i], x, y, width, height, finish, 1);
  68.                         finish++;
  69.                     } while (finish < 360);
  70.                     break;
  71.                 }
  72.                 ell.FillPie(esc[i], x, y, width, height, startAngle, sweepAngle);
  73.             }
  74.             Angel = 0;
  75.             sweepAngle = 0;
  76.             startAngle = sweepAngle;
  77.             Graphics g2 = e.Graphics;
  78.             for (int i = 0; i < mas.mas.Count; i++)
  79.             {
  80.  
  81.                 startAngle += sweepAngle;
  82.                 // Create location and size of ellipse.
  83.                 int x = 578, y = 300, width = 300, height = 300;
  84.                 Angel = mas.mas[i] / degree;
  85.                 sweepAngle = (int)Angel;
  86.                 Graphics ell = Graphics.FromHwnd(this.Handle);
  87.                 // Draw pie to screen.
  88.                 if (i == mas.mas.Count - 1)
  89.                 {
  90.                     break;
  91.                 }
  92.                 ell.DrawPie(new Pen(Color.Black, 2), x, y, width, height, startAngle, sweepAngle);
  93.             }
  94.             g2.DrawEllipse(blackPen, 578, 300, 300, 300);
  95.         }
  96.  
  97.         private void инфоToolStripMenuItem_Click(object sender, EventArgs e)
  98.         {
  99.             MessageBox.Show("Артемьев Даниил Иванович, 525а гр.", "");
  100.         }
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement