Помогите) Составить программу для рисования желтого квадрата в красном круге.

Помогите) Составить программу для рисования желтого квадрата в красном круге.
Гость
Ответ(ы) на вопрос:
Гость
using System; using System.Windows.Forms; using System.Drawing; namespace RedSquareInYellowCircle {     static class Program {         [STAThread]         static void Main() {             Application.EnableVisualStyles();             Application.SetCompatibleTextRenderingDefault(false);             Application.Run(new Form1());         }     }     public class Form1 : Form {         private System.ComponentModel.IContainer components = null;         protected override void Dispose(bool disposing) {             if (disposing && (components != null)) {                 components.Dispose();             }             base.Dispose(disposing);         }         public Form1() {             InitializeComponent();         }         private void InitializeComponent() {             this.SuspendLayout();             //             // Form1             //             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);             this.Name = "Form1";             this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);             this.ResumeLayout(false);         }         private void Form1_Paint(object sender, PaintEventArgs e) {             const int radius = 100;             float a = (float)Math.Sqrt(2) * radius;             int[] center = { this.ClientRectangle.Width / 2, this.ClientRectangle.Height / 2 };             Pen pen = new Pen(Color.Black, 0);             SolidBrush sbYellow = new SolidBrush(Color.Yellow);             SolidBrush sbRed = new SolidBrush(Color.Red);             e.Graphics.FillEllipse(sbYellow, new Rectangle(center[0] - radius, center[1] - radius, 2 * radius, 2 * radius));             e.Graphics.FillRectangle(sbRed, new Rectangle(center[0] - (int)a / 2, center[1] - (int)a / 2, (int)a, (int)a));             // Освободить объекты GDI+             pen.Dispose();             sbYellow.Dispose();             sbRed.Dispose();         }     } }   сделанно в 2010 студии, если вдруг проблемы с компиляцией
Не нашли ответ?
Ответить на вопрос
Похожие вопросы