diff --git a/ArmoredCar/ArmoredCar/FormMap.Designer.cs b/ArmoredCar/ArmoredCar/FormMap.Designer.cs new file mode 100644 index 0000000..574b60c --- /dev/null +++ b/ArmoredCar/ArmoredCar/FormMap.Designer.cs @@ -0,0 +1,212 @@ + +namespace ArmoredCar +{ + partial class FormMap + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); + this.pictureBoxCar = new System.Windows.Forms.PictureBox(); + this.button1 = new System.Windows.Forms.Button(); + this.buttonUp = 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(); + this.button2 = new System.Windows.Forms.Button(); + this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); + this.statusStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit(); + this.SuspendLayout(); + // + // statusStrip1 + // + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabelSpeed, + this.toolStripStatusLabelWeight, + this.toolStripStatusLabelBodyColor}); + this.statusStrip1.Location = new System.Drawing.Point(0, 428); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(800, 22); + this.statusStrip1.TabIndex = 0; + this.statusStrip1.Text = "statusStrip1"; + // + // toolStripStatusLabelSpeed + // + this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed"; + this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17); + this.toolStripStatusLabelSpeed.Text = "Скорость:"; + // + // toolStripStatusLabelWeight + // + this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight"; + this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(32, 17); + this.toolStripStatusLabelWeight.Text = "Вес: "; + // + // toolStripStatusLabelBodyColor + // + this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor"; + this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17); + this.toolStripStatusLabelBodyColor.Text = "Цвет:"; + // + // pictureBoxCar + // + this.pictureBoxCar.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxCar.Location = new System.Drawing.Point(0, 0); + this.pictureBoxCar.Name = "pictureBoxCar"; + this.pictureBoxCar.Size = new System.Drawing.Size(800, 428); + this.pictureBoxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBoxCar.TabIndex = 6; + this.pictureBoxCar.TabStop = false; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.button1.Location = new System.Drawing.Point(42, 382); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 7; + this.button1.Text = "Создать"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.ButtonCreate_Click); + // + // buttonUp + // + this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUp.BackgroundImage = global::ArmoredCar.Properties.Resources.Up; + this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonUp.Location = new System.Drawing.Point(692, 324); + this.buttonUp.Name = "buttonUp"; + this.buttonUp.Size = new System.Drawing.Size(30, 30); + this.buttonUp.TabIndex = 8; + this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.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::ArmoredCar.Properties.Resources.Left; + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonLeft.Location = new System.Drawing.Point(656, 360); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(30, 30); + this.buttonLeft.TabIndex = 9; + 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::ArmoredCar.Properties.Resources.Down; + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonDown.Location = new System.Drawing.Point(692, 360); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(30, 30); + this.buttonDown.TabIndex = 10; + 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::ArmoredCar.Properties.Resources.Right; + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonRight.Location = new System.Drawing.Point(728, 360); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(30, 30); + this.buttonRight.TabIndex = 11; + this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(154, 382); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(95, 23); + this.button2.TabIndex = 12; + this.button2.Text = "Модификация"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.ButtonCreateModif_Click); + // + // comboBoxSelectorMap + // + this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSelectorMap.FormattingEnabled = true; + this.comboBoxSelectorMap.Items.AddRange(new object[] { + "Простая карта", + "Карта 1", + "Карта 2"}); + this.comboBoxSelectorMap.Location = new System.Drawing.Point(42, 26); + this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; + this.comboBoxSelectorMap.Size = new System.Drawing.Size(107, 23); + this.comboBoxSelectorMap.TabIndex = 13; + this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); + // + // FormMap + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.comboBoxSelectorMap); + this.Controls.Add(this.button2); + this.Controls.Add(this.buttonRight); + this.Controls.Add(this.buttonDown); + this.Controls.Add(this.buttonLeft); + this.Controls.Add(this.buttonUp); + this.Controls.Add(this.button1); + this.Controls.Add(this.pictureBoxCar); + this.Controls.Add(this.statusStrip1); + this.Name = "FormMap"; + this.Text = "Карта"; + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpeed; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelWeight; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelBodyColor; + private System.Windows.Forms.PictureBox pictureBoxCar; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button buttonUp; + private System.Windows.Forms.Button buttonLeft; + private System.Windows.Forms.Button buttonDown; + private System.Windows.Forms.Button buttonRight; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.ComboBox comboBoxSelectorMap; + } +} + diff --git a/ArmoredCar/ArmoredCar/FormMap.cs b/ArmoredCar/ArmoredCar/FormMap.cs new file mode 100644 index 0000000..996cdd7 --- /dev/null +++ b/ArmoredCar/ArmoredCar/FormMap.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ArmoredCar +{ + public partial class FormMap : Form + { + + private AbstractMap _abstractMap; + public FormMap() + { + InitializeComponent(); + _abstractMap = new SimpleMap(); + } + private void SetData(DrawningArmoredCar car) + { + toolStripStatusLabelSpeed.Text = $"Скорость: {car.ArmoredCar.Speed}"; + toolStripStatusLabelWeight.Text = $"Вес: {car.ArmoredCar.Weight}"; + toolStripStatusLabelBodyColor.Text = $"Цвет:{ car.ArmoredCar.BodyColor.Name}"; + pictureBoxCar.Image = _abstractMap.CreateMap(pictureBoxCar.Width, + pictureBoxCar.Height, new DrawningObjectArmCar(car)); + } + + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void ButtonCreate_Click(object sender, EventArgs e) + { + Random rnd = new(); + var car = new DrawningArmoredCar(rnd.Next(100, 300), rnd.Next(1000, 2000), + Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + SetData(car); + } + + /// + /// Изменение размеров формы + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + //получаем имя кнопки + string name = ((Button)sender)?.Name ?? string.Empty; + Direction dir = Direction.None; + switch (name) + { + case "buttonUp": + dir = Direction.Up; + break; + case "buttonDown": + dir = Direction.Down; + break; + case "buttonLeft": + dir = Direction.Left; + break; + case "buttonRight": + dir = Direction.Right; + break; + } + pictureBoxCar.Image = _abstractMap?.MoveObject(dir); + } + /// + /// Обработка нажатия кнопки "Модификация" + /// + /// + /// + private void ButtonCreateModif_Click(object sender, EventArgs e) + { + Random rnd = new(); + var tank = new DrawningTank(rnd.Next(100, 300), rnd.Next(1000, + 2000), + Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, + 256)), + Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, + 256)), + Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); + SetData(tank); + } + /// + /// Смена карты + /// + /// + /// + private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, + EventArgs e) + { + switch (comboBoxSelectorMap.Text) + { + case "Простая карта": + _abstractMap = new SimpleMap(); + break; + + case "Карта 1": + _abstractMap = new MyMapWooden(); + break; + case "Карта 2": + _abstractMap = new MyMapLabirinth(); + break; + + } + } + } +} diff --git a/ArmoredCar/ArmoredCar/FormMap.resx b/ArmoredCar/ArmoredCar/FormMap.resx new file mode 100644 index 0000000..5cb320f --- /dev/null +++ b/ArmoredCar/ArmoredCar/FormMap.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file