From ff4209df640bd90a1827c3aaed4ab0ff50b796b6 Mon Sep 17 00:00:00 2001 From: KirillFirsof <117719052+KirillFirsof@users.noreply.github.com> Date: Thu, 12 Oct 2023 21:39:45 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=B9=20=D1=81=D0=B1=D1=80=D0=BE=D1=81=20=D0=BA=20=D1=81?= =?UTF-8?q?=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8E=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RPP_FirstLaba_Tractor/FormTractor.cs | 196 +----------------- 1 file changed, 2 insertions(+), 194 deletions(-) diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs index 23c4cac..2c28f2f 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs @@ -1,201 +1,9 @@ namespace RPP_FirstLaba_Tractor { - /// - /// Форма работы с объектом "Спортивный автомобиль" - /// + public partial class FormTractor : Form { - private PictureBox pictureBoxTractor; - private Button buttonCreate; - private Button buttonTop; - private Button buttonLeft; - private Button buttonDown; - private Button buttonRight; + - public int getPictureWidth() - { - return pictureBoxTractor.Width; - } - public int getPictureHeight() - { - return pictureBoxTractor.Height; - } - - /// - /// Поле-объект для прорисовки объекта - /// - private DrawningTractor? _drawningTractor; - /// - /// Инициализация формы - /// - public FormTractor() - { - InitializeComponent(); - } - /// - /// Метод прорисовки машины - /// - private void Draw() - { - if (_drawningTractor == null) - { - return; - } - Bitmap bmp = new(pictureBoxTractor.Width, - pictureBoxTractor.Height); - Graphics gr = Graphics.FromImage(bmp); - _drawningTractor.DrawTransport(gr); - pictureBoxTractor.Image = bmp; - } - /// - /// Обработка нажатия кнопки "Создать" - /// - /// - /// - private void ButtonCreate_Click(object sender, EventArgs e) - { - Random random = new(); - _drawningTractor = new DrawningTractor(); - _drawningTractor.Init(random.Next(100, 300), - random.Next(1000, 3000), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), - random.Next(0, 256)), - pictureBoxTractor.Width, pictureBoxTractor.Height); - _drawningTractor.SetPosition(random.Next(10, 100), - random.Next(10, 100)); - Draw(); - } - - /// - /// Изменение размеров формы - /// - /// - /// - private void ButtonMove_Click(object sender, EventArgs e) - { - if (_drawningTractor == null) - { - return; - } - string name = ((Button)sender)?.Name ?? string.Empty; - switch (name) - { - case "buttonTop": - _drawningTractor.MoveTransport(DirectionType.Up); - break; - case "buttonDown": - _drawningTractor.MoveTransport(DirectionType.Down); - break; - case "buttonLeft": - _drawningTractor.MoveTransport(DirectionType.Left); - break; - case "buttonRight": - _drawningTractor.MoveTransport(DirectionType.Right); - break; - } - Draw(); - } - - private void InitializeComponent() - { - this.pictureBoxTractor = new System.Windows.Forms.PictureBox(); - this.buttonCreate = new System.Windows.Forms.Button(); - this.buttonTop = new System.Windows.Forms.Button(); - this.buttonLeft = new System.Windows.Forms.Button(); - this.buttonDown = new System.Windows.Forms.Button(); - this.buttonRight = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).BeginInit(); - this.SuspendLayout(); - // - // pictureBoxTractor - // - this.pictureBoxTractor.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxTractor.Location = new System.Drawing.Point(0, 0); - this.pictureBoxTractor.Name = "pictureBoxTractor"; - this.pictureBoxTractor.Size = new System.Drawing.Size(891, 490); - this.pictureBoxTractor.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxTractor.TabIndex = 0; - this.pictureBoxTractor.TabStop = false; - // - // buttonCreate - // - this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreate.Location = new System.Drawing.Point(12, 440); - this.buttonCreate.Name = "buttonCreate"; - this.buttonCreate.Size = new System.Drawing.Size(94, 29); - this.buttonCreate.TabIndex = 1; - this.buttonCreate.Text = "Создать"; - this.buttonCreate.UseVisualStyleBackColor = true; - this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); - // - // buttonTop - // - this.buttonTop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonTop.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowUp; - this.buttonTop.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonTop.Location = new System.Drawing.Point(813, 412); - this.buttonTop.Name = "buttonTop"; - this.buttonTop.Size = new System.Drawing.Size(30, 30); - this.buttonTop.TabIndex = 2; - this.buttonTop.UseVisualStyleBackColor = true; - this.buttonTop.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonLeft - // - this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonLeft.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowLeft; - this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(777, 448); - this.buttonLeft.Name = "buttonLeft"; - this.buttonLeft.Size = new System.Drawing.Size(30, 30); - this.buttonLeft.TabIndex = 3; - this.buttonLeft.UseVisualStyleBackColor = true; - this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonDown - // - this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDown.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowDown; - this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(813, 448); - this.buttonDown.Name = "buttonDown"; - this.buttonDown.Size = new System.Drawing.Size(30, 30); - this.buttonDown.TabIndex = 4; - this.buttonDown.UseVisualStyleBackColor = true; - this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonRight - // - this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRight.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowRight; - this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(849, 448); - this.buttonRight.Name = "buttonRight"; - this.buttonRight.Size = new System.Drawing.Size(30, 30); - this.buttonRight.TabIndex = 5; - this.buttonRight.UseVisualStyleBackColor = true; - this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); - // - // FormTractor - // - this.ClientSize = new System.Drawing.Size(891, 490); - this.Controls.Add(this.buttonRight); - this.Controls.Add(this.buttonDown); - this.Controls.Add(this.buttonLeft); - this.Controls.Add(this.buttonTop); - this.Controls.Add(this.buttonCreate); - this.Controls.Add(this.pictureBoxTractor); - this.Name = "FormTractor"; - this.Load += new System.EventHandler(this.FormTractor_Load); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - private void FormTractor_Load(object sender, EventArgs e) - { - - } } } \ No newline at end of file