changes forms

This commit is contained in:
Zara28 2022-09-21 21:31:10 +04:00
parent 6cb049d4d6
commit f6a15851ae
9 changed files with 3793 additions and 21 deletions

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace ArmoredVehicle
{
internal class ArmoredVehicleEntity
public class ArmoredVehicleEntity
{
public ArmoredVehicleEntity(int speed, float weight, Color bodyColor)
{

View File

@ -9,7 +9,7 @@ namespace ArmoredVehicle
/// <summary>
/// Направление перемещения
/// </summary>
internal enum Direction
public enum Direction
{
None = 0,
Up = 1,

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace ArmoredVehicle
{
internal class DrawingArmoredVehicle
public class DrawingArmoredVehicle
{
/// <summary>
/// Класс-сущность

View File

@ -0,0 +1,213 @@
namespace ArmoredVehicle
{
partial class FormMapWithSetMachine
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMapWithSetMachine));
this.groupBoxInstruments = new System.Windows.Forms.GroupBox();
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
this.ButtonDown = new System.Windows.Forms.Button();
this.ButtonRight = new System.Windows.Forms.Button();
this.ButtonLeft = new System.Windows.Forms.Button();
this.ButtonUp = new System.Windows.Forms.Button();
this.buttonMap = new System.Windows.Forms.Button();
this.buttonStore = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.comboBoxMap = new System.Windows.Forms.ComboBox();
this.pictureBoxImage = new System.Windows.Forms.PictureBox();
this.groupBoxInstruments.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImage)).BeginInit();
this.SuspendLayout();
//
// groupBoxInstruments
//
this.groupBoxInstruments.Controls.Add(this.maskedTextBoxPosition);
this.groupBoxInstruments.Controls.Add(this.ButtonDown);
this.groupBoxInstruments.Controls.Add(this.ButtonRight);
this.groupBoxInstruments.Controls.Add(this.ButtonLeft);
this.groupBoxInstruments.Controls.Add(this.ButtonUp);
this.groupBoxInstruments.Controls.Add(this.buttonMap);
this.groupBoxInstruments.Controls.Add(this.buttonStore);
this.groupBoxInstruments.Controls.Add(this.buttonDelete);
this.groupBoxInstruments.Controls.Add(this.buttonAdd);
this.groupBoxInstruments.Controls.Add(this.comboBoxMap);
this.groupBoxInstruments.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBoxInstruments.Location = new System.Drawing.Point(728, 0);
this.groupBoxInstruments.Name = "groupBoxInstruments";
this.groupBoxInstruments.Size = new System.Drawing.Size(300, 644);
this.groupBoxInstruments.TabIndex = 0;
this.groupBoxInstruments.TabStop = false;
this.groupBoxInstruments.Text = "Инструменты";
//
// maskedTextBoxPosition
//
this.maskedTextBoxPosition.Location = new System.Drawing.Point(18, 179);
this.maskedTextBoxPosition.Mask = "00";
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
this.maskedTextBoxPosition.Size = new System.Drawing.Size(270, 31);
this.maskedTextBoxPosition.TabIndex = 18;
//
// ButtonDown
//
this.ButtonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonDown.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("ButtonDown.BackgroundImage")));
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonDown.Location = new System.Drawing.Point(139, 555);
this.ButtonDown.Name = "ButtonDown";
this.ButtonDown.Size = new System.Drawing.Size(40, 36);
this.ButtonDown.TabIndex = 17;
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 = ((System.Drawing.Image)(resources.GetObject("ButtonRight.BackgroundImage")));
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonRight.Location = new System.Drawing.Point(182, 508);
this.ButtonRight.Name = "ButtonRight";
this.ButtonRight.Size = new System.Drawing.Size(40, 36);
this.ButtonRight.TabIndex = 16;
this.ButtonRight.UseVisualStyleBackColor = true;
this.ButtonRight.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 = ((System.Drawing.Image)(resources.GetObject("ButtonLeft.BackgroundImage")));
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonLeft.Location = new System.Drawing.Point(99, 510);
this.ButtonLeft.Name = "ButtonLeft";
this.ButtonLeft.Size = new System.Drawing.Size(40, 36);
this.ButtonLeft.TabIndex = 15;
this.ButtonLeft.UseVisualStyleBackColor = true;
this.ButtonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
// ButtonUp
//
this.ButtonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonUp.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("ButtonUp.BackgroundImage")));
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonUp.Location = new System.Drawing.Point(139, 460);
this.ButtonUp.Name = "ButtonUp";
this.ButtonUp.Size = new System.Drawing.Size(40, 36);
this.ButtonUp.TabIndex = 14;
this.ButtonUp.UseVisualStyleBackColor = true;
this.ButtonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonMap
//
this.buttonMap.Location = new System.Drawing.Point(26, 373);
this.buttonMap.Name = "buttonMap";
this.buttonMap.Size = new System.Drawing.Size(262, 34);
this.buttonMap.TabIndex = 5;
this.buttonMap.Text = "Посмотреть карту";
this.buttonMap.UseVisualStyleBackColor = true;
this.buttonMap.Click += new System.EventHandler(this.buttonMap_Click);
//
// buttonStore
//
this.buttonStore.Location = new System.Drawing.Point(24, 307);
this.buttonStore.Name = "buttonStore";
this.buttonStore.Size = new System.Drawing.Size(264, 34);
this.buttonStore.TabIndex = 4;
this.buttonStore.Text = "Посмотреть хранилище";
this.buttonStore.UseVisualStyleBackColor = true;
this.buttonStore.Click += new System.EventHandler(this.buttonStore_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(20, 234);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(268, 34);
this.buttonDelete.TabIndex = 3;
this.buttonDelete.Text = "Удалить машину";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(13, 117);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(275, 34);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить машину";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// comboBoxMap
//
this.comboBoxMap.FormattingEnabled = true;
this.comboBoxMap.Location = new System.Drawing.Point(9, 41);
this.comboBoxMap.Name = "comboBoxMap";
this.comboBoxMap.Size = new System.Drawing.Size(279, 33);
this.comboBoxMap.TabIndex = 0;
this.comboBoxMap.SelectedIndexChanged += new System.EventHandler(this.comboBoxMap_SelectedIndexChanged);
//
// pictureBoxImage
//
this.pictureBoxImage.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxImage.Location = new System.Drawing.Point(0, 0);
this.pictureBoxImage.Name = "pictureBoxImage";
this.pictureBoxImage.Size = new System.Drawing.Size(728, 644);
this.pictureBoxImage.TabIndex = 1;
this.pictureBoxImage.TabStop = false;
//
// FormMapWithSetMachine
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1028, 644);
this.Controls.Add(this.pictureBoxImage);
this.Controls.Add(this.groupBoxInstruments);
this.Name = "FormMapWithSetMachine";
this.Text = "Карта с набором объектов";
this.groupBoxInstruments.ResumeLayout(false);
this.groupBoxInstruments.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImage)).EndInit();
this.ResumeLayout(false);
}
#endregion
private GroupBox groupBoxInstruments;
private Button buttonMap;
private Button buttonStore;
private Button buttonDelete;
private Button buttonAdd;
private ComboBox comboBoxMap;
private PictureBox pictureBoxImage;
private MaskedTextBox maskedTextBoxPosition;
private Button ButtonDown;
private Button ButtonRight;
private Button ButtonLeft;
private Button ButtonUp;
}
}

View File

@ -0,0 +1,171 @@
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 ArmoredVehicle
{
public partial class FormMapWithSetMachine : Form
{
/// <summary>
/// Объект от класса карты с набором объектов
/// </summary>
private MapWithSetMachineGeneric<DrawningObject, AbstractMap> _mapCarsCollectionGeneric;
/// <summary>
/// Конструктор
/// </summary>
public FormMapWithSetMachine()
{
InitializeComponent();
}
/// <summary>
/// Выбор карты
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void comboBoxMap_SelectedIndexChanged(object sender, EventArgs e)
{
AbstractMap map = null;
switch (comboBoxMap.Text)
{
case "Простая карта":
map = new SimpleMap();
break;
case "Горизонтальная карта":
map = new HorizontalMap();
break;
case "Вертикальная карта":
map = new VerticalMap();
break;
}
if (map != null)
{
_mapCarsCollectionGeneric = new MapWithSetMachineGeneric<DrawningObject, AbstractMap>(
pictureBoxImage.Width, pictureBoxImage.Height, map);
}
else
{
_mapCarsCollectionGeneric = null;
}
}
/// <summary>
/// Добавление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAdd_Click(object sender, EventArgs e)
{
if (_mapCarsCollectionGeneric == null)
{
return;
}
MainForm form = new();
if (form.ShowDialog() == DialogResult.OK)
{
DrawningObject machine = new(form.SelectedMachine);
if (_mapCarsCollectionGeneric + machine)
{
MessageBox.Show("Объект добавлен");
pictureBoxImage.Image = _mapCarsCollectionGeneric.ShowSet();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
/// <summary>
/// Удаление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonDelete_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_mapCarsCollectionGeneric - pos)
{
MessageBox.Show("Объект удален");
pictureBoxImage.Image = _mapCarsCollectionGeneric.ShowSet();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
/// <summary>
/// Вывод набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonStore_Click(object sender, EventArgs e)
{
if (_mapCarsCollectionGeneric == null)
{
return;
}
pictureBoxImage.Image = _mapCarsCollectionGeneric.ShowSet();
}
/// <summary>
/// Вывод карты
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonMap_Click(object sender, EventArgs e)
{
if (_mapCarsCollectionGeneric == null)
{
return;
}
pictureBoxImage.Image = _mapCarsCollectionGeneric.ShowOnMap();
}
/// <summary>
/// Перемещение
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_mapCarsCollectionGeneric == null)
{
return;
}
//получаем имя кнопки
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;
}
pictureBoxImage.Image = _mapCarsCollectionGeneric.MoveObject(dir);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,7 @@
this.toolStripStatusLabelColor = new System.Windows.Forms.ToolStripStatusLabel();
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.TankButton = new System.Windows.Forms.Button();
this.Mapbutton = new System.Windows.Forms.Button();
this.ChooseButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.DrawingPictureBox)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
@ -109,7 +109,7 @@
this.DrawingPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.DrawingPictureBox.Location = new System.Drawing.Point(0, 0);
this.DrawingPictureBox.Name = "DrawingPictureBox";
this.DrawingPictureBox.Size = new System.Drawing.Size(800, 418);
this.DrawingPictureBox.Size = new System.Drawing.Size(800, 450);
this.DrawingPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.DrawingPictureBox.TabIndex = 7;
this.DrawingPictureBox.TabStop = false;
@ -156,30 +156,30 @@
this.TankButton.UseVisualStyleBackColor = true;
this.TankButton.Click += new System.EventHandler(this.TankButton_Click);
//
// Mapbutton
// ChooseButton
//
this.Mapbutton.Location = new System.Drawing.Point(304, 362);
this.Mapbutton.Name = "Mapbutton";
this.Mapbutton.Size = new System.Drawing.Size(179, 34);
this.Mapbutton.TabIndex = 15;
this.Mapbutton.Text = "Перейти на карту";
this.Mapbutton.UseVisualStyleBackColor = true;
this.Mapbutton.Click += new System.EventHandler(this.Mapbutton_Click);
this.ChooseButton.Location = new System.Drawing.Point(484, 362);
this.ChooseButton.Name = "ChooseButton";
this.ChooseButton.Size = new System.Drawing.Size(143, 34);
this.ChooseButton.TabIndex = 15;
this.ChooseButton.Text = "Выбрать";
this.ChooseButton.UseVisualStyleBackColor = true;
this.ChooseButton.Click += new System.EventHandler(this.ChooseButton_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.Mapbutton);
this.Controls.Add(this.ChooseButton);
this.Controls.Add(this.TankButton);
this.Controls.Add(this.ButtonDown);
this.Controls.Add(this.ButtonRight);
this.Controls.Add(this.ButtonLeft);
this.Controls.Add(this.ButtonUp);
this.Controls.Add(this.CreateButton);
this.Controls.Add(this.DrawingPictureBox);
this.Controls.Add(this.statusStrip);
this.Controls.Add(this.DrawingPictureBox);
this.MinimumSize = new System.Drawing.Size(210, 50);
this.Name = "MainForm";
this.Text = "Военная машина";
@ -204,6 +204,6 @@
private ToolStripStatusLabel toolStripStatusLabelColor;
private StatusStrip statusStrip;
private Button TankButton;
private Button Mapbutton;
private Button ChooseButton;
}
}

View File

@ -6,8 +6,9 @@ namespace ArmoredVehicle
public MainForm()
{
InitializeComponent();
//this.MinimumSize = new System.Drawing.Size(300, 250);
}
public DrawingArmoredVehicle SelectedMachine { get; private set; }
/// <summary>
/// Ìåòîä ïðîðèñîâêè ìàøèíû
/// </summary>
@ -100,10 +101,15 @@ namespace ArmoredVehicle
Draw();
}
private void Mapbutton_Click(object sender, EventArgs e)
/// <summary>
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Âûáðàòü"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ChooseButton_Click(object sender, EventArgs e)
{
FormMap map = new FormMap();
map.Show();
SelectedMachine = _ArmoredVehicle;
DialogResult = DialogResult.OK;
}
}
}

View File

@ -11,7 +11,7 @@ namespace ArmoredVehicle
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormMap());
Application.Run(new FormMapWithSetMachine());
}
}
}