Смена массива на список. Класс MapsCollection. Изменение формы.
This commit is contained in:
parent
d75256eac8
commit
52405afadb
270
Warship/Warship/FormMapWithSetWarship.Designer.cs
generated
270
Warship/Warship/FormMapWithSetWarship.Designer.cs
generated
@ -22,106 +22,173 @@
|
|||||||
|
|
||||||
#region Windows Form Designer generated code
|
#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()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.groupBoxTools = new System.Windows.Forms.GroupBox();
|
this.groupBoxTools = new System.Windows.Forms.GroupBox();
|
||||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
this.groupBoxMaps = new System.Windows.Forms.GroupBox();
|
||||||
this.buttonRemoveTruck = new System.Windows.Forms.Button();
|
this.buttonAddMap = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDeleteMap = new System.Windows.Forms.Button();
|
||||||
|
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
||||||
|
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
|
||||||
|
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||||
|
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
this.buttonRemoveWarship = new System.Windows.Forms.Button();
|
||||||
|
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||||
|
this.buttonAddWarship = new System.Windows.Forms.Button();
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
this.buttonAddTruck = new System.Windows.Forms.Button();
|
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
|
||||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
this.groupBoxTools.SuspendLayout();
|
this.groupBoxTools.SuspendLayout();
|
||||||
|
this.groupBoxMaps.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonRemoveTruck);
|
this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonShowStorage);
|
this.groupBoxTools.Controls.Add(this.buttonShowStorage);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonDown);
|
this.groupBoxTools.Controls.Add(this.buttonRemoveWarship);
|
||||||
|
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonAddWarship);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonRight);
|
this.groupBoxTools.Controls.Add(this.buttonRight);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonLeft);
|
this.groupBoxTools.Controls.Add(this.buttonLeft);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonUp);
|
this.groupBoxTools.Controls.Add(this.buttonUp);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
|
this.groupBoxTools.Controls.Add(this.buttonDown);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonAddTruck);
|
|
||||||
this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
|
|
||||||
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
this.groupBoxTools.Location = new System.Drawing.Point(927, 0);
|
this.groupBoxTools.Location = new System.Drawing.Point(833, 0);
|
||||||
this.groupBoxTools.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.groupBoxTools.Name = "groupBoxTools";
|
this.groupBoxTools.Name = "groupBoxTools";
|
||||||
this.groupBoxTools.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.groupBoxTools.Size = new System.Drawing.Size(217, 649);
|
||||||
this.groupBoxTools.Size = new System.Drawing.Size(233, 739);
|
|
||||||
this.groupBoxTools.TabIndex = 0;
|
this.groupBoxTools.TabIndex = 0;
|
||||||
this.groupBoxTools.TabStop = false;
|
this.groupBoxTools.TabStop = false;
|
||||||
this.groupBoxTools.Text = "Инструменты";
|
this.groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// maskedTextBoxPosition
|
// groupBoxMaps
|
||||||
//
|
//
|
||||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(19, 221);
|
this.groupBoxMaps.Controls.Add(this.buttonAddMap);
|
||||||
this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.groupBoxMaps.Controls.Add(this.buttonDeleteMap);
|
||||||
this.maskedTextBoxPosition.Mask = "00";
|
this.groupBoxMaps.Controls.Add(this.listBoxMaps);
|
||||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
this.groupBoxMaps.Controls.Add(this.textBoxNewMapName);
|
||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(199, 27);
|
this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap);
|
||||||
this.maskedTextBoxPosition.TabIndex = 2;
|
this.groupBoxMaps.Location = new System.Drawing.Point(6, 22);
|
||||||
this.maskedTextBoxPosition.ValidatingType = typeof(int);
|
this.groupBoxMaps.Name = "groupBoxMaps";
|
||||||
|
this.groupBoxMaps.Size = new System.Drawing.Size(205, 257);
|
||||||
|
this.groupBoxMaps.TabIndex = 19;
|
||||||
|
this.groupBoxMaps.TabStop = false;
|
||||||
|
this.groupBoxMaps.Text = "Карты";
|
||||||
//
|
//
|
||||||
// buttonRemoveTruck
|
// buttonAddMap
|
||||||
//
|
//
|
||||||
this.buttonRemoveTruck.Location = new System.Drawing.Point(19, 260);
|
this.buttonAddMap.Location = new System.Drawing.Point(14, 80);
|
||||||
this.buttonRemoveTruck.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.buttonAddMap.Name = "buttonAddMap";
|
||||||
this.buttonRemoveTruck.Name = "buttonRemoveWarship";
|
this.buttonAddMap.Size = new System.Drawing.Size(180, 35);
|
||||||
this.buttonRemoveTruck.Size = new System.Drawing.Size(200, 47);
|
this.buttonAddMap.TabIndex = 2;
|
||||||
this.buttonRemoveTruck.TabIndex = 3;
|
this.buttonAddMap.Text = "Добавить карту";
|
||||||
this.buttonRemoveTruck.Text = "Удалить военный корбаль";
|
this.buttonAddMap.UseVisualStyleBackColor = true;
|
||||||
this.buttonRemoveTruck.UseMnemonic = false;
|
this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
|
||||||
this.buttonRemoveTruck.UseVisualStyleBackColor = true;
|
//
|
||||||
this.buttonRemoveTruck.Click += new System.EventHandler(this.ButtonRemoveWarship_Click);
|
// buttonDeleteMap
|
||||||
|
//
|
||||||
|
this.buttonDeleteMap.Location = new System.Drawing.Point(14, 206);
|
||||||
|
this.buttonDeleteMap.Name = "buttonDeleteMap";
|
||||||
|
this.buttonDeleteMap.Size = new System.Drawing.Size(180, 35);
|
||||||
|
this.buttonDeleteMap.TabIndex = 4;
|
||||||
|
this.buttonDeleteMap.Text = "Удалить карту";
|
||||||
|
this.buttonDeleteMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
|
||||||
|
//
|
||||||
|
// listBoxMaps
|
||||||
|
//
|
||||||
|
this.listBoxMaps.FormattingEnabled = true;
|
||||||
|
this.listBoxMaps.ItemHeight = 15;
|
||||||
|
this.listBoxMaps.Location = new System.Drawing.Point(14, 121);
|
||||||
|
this.listBoxMaps.Name = "listBoxMaps";
|
||||||
|
this.listBoxMaps.Size = new System.Drawing.Size(180, 79);
|
||||||
|
this.listBoxMaps.TabIndex = 3;
|
||||||
|
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// textBoxNewMapName
|
||||||
|
//
|
||||||
|
this.textBoxNewMapName.Location = new System.Drawing.Point(14, 22);
|
||||||
|
this.textBoxNewMapName.Multiline = true;
|
||||||
|
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
||||||
|
this.textBoxNewMapName.Size = new System.Drawing.Size(180, 23);
|
||||||
|
this.textBoxNewMapName.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// comboBoxSelectorMap
|
||||||
|
//
|
||||||
|
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||||
|
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
|
"Простая карта",
|
||||||
|
"Морская карта"});
|
||||||
|
this.comboBoxSelectorMap.Location = new System.Drawing.Point(14, 51);
|
||||||
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(180, 23);
|
||||||
|
this.comboBoxSelectorMap.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// buttonShowOnMap
|
||||||
|
//
|
||||||
|
this.buttonShowOnMap.Location = new System.Drawing.Point(20, 516);
|
||||||
|
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||||
|
this.buttonShowOnMap.Size = new System.Drawing.Size(180, 35);
|
||||||
|
this.buttonShowOnMap.TabIndex = 18;
|
||||||
|
this.buttonShowOnMap.Text = "Посмотреть карту";
|
||||||
|
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||||
//
|
//
|
||||||
// buttonShowStorage
|
// buttonShowStorage
|
||||||
//
|
//
|
||||||
this.buttonShowStorage.Location = new System.Drawing.Point(19, 383);
|
this.buttonShowStorage.Location = new System.Drawing.Point(20, 475);
|
||||||
this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||||
this.buttonShowStorage.Size = new System.Drawing.Size(200, 47);
|
this.buttonShowStorage.Size = new System.Drawing.Size(180, 35);
|
||||||
this.buttonShowStorage.TabIndex = 4;
|
this.buttonShowStorage.TabIndex = 17;
|
||||||
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
||||||
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
||||||
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||||
//
|
//
|
||||||
// buttonDown
|
// buttonRemoveWarship
|
||||||
//
|
//
|
||||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonRemoveWarship.Location = new System.Drawing.Point(20, 434);
|
||||||
this.buttonDown.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелкаbott;
|
this.buttonRemoveWarship.Name = "buttonRemoveWarship";
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonRemoveWarship.Size = new System.Drawing.Size(180, 35);
|
||||||
this.buttonDown.Location = new System.Drawing.Point(104, 672);
|
this.buttonRemoveWarship.TabIndex = 16;
|
||||||
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.buttonRemoveWarship.Text = "Удалить военный корабль";
|
||||||
this.buttonDown.Name = "buttonDown";
|
this.buttonRemoveWarship.UseVisualStyleBackColor = true;
|
||||||
this.buttonDown.Size = new System.Drawing.Size(34, 40);
|
this.buttonRemoveWarship.Click += new System.EventHandler(this.ButtonRemoveWarship_Click);
|
||||||
this.buttonDown.TabIndex = 10;
|
//
|
||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
// maskedTextBoxPosition
|
||||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
//
|
||||||
|
this.maskedTextBoxPosition.Location = new System.Drawing.Point(20, 405);
|
||||||
|
this.maskedTextBoxPosition.Mask = "00";
|
||||||
|
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(180, 23);
|
||||||
|
this.maskedTextBoxPosition.TabIndex = 15;
|
||||||
|
this.maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||||
|
//
|
||||||
|
// buttonAddWarship
|
||||||
|
//
|
||||||
|
this.buttonAddWarship.Location = new System.Drawing.Point(20, 364);
|
||||||
|
this.buttonAddWarship.Name = "buttonAddWarship";
|
||||||
|
this.buttonAddWarship.Size = new System.Drawing.Size(180, 35);
|
||||||
|
this.buttonAddWarship.TabIndex = 14;
|
||||||
|
this.buttonAddWarship.Text = "Добавить военный корабль";
|
||||||
|
this.buttonAddWarship.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddWarship.Click += new System.EventHandler(this.ButtonAddWarship_Click);
|
||||||
//
|
//
|
||||||
// buttonRight
|
// buttonRight
|
||||||
//
|
//
|
||||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonRight.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелкаright;
|
this.buttonRight.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелкаright;
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonRight.Location = new System.Drawing.Point(145, 672);
|
this.buttonRight.Location = new System.Drawing.Point(126, 609);
|
||||||
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.buttonRight.Name = "buttonRight";
|
this.buttonRight.Name = "buttonRight";
|
||||||
this.buttonRight.Size = new System.Drawing.Size(34, 40);
|
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonRight.TabIndex = 9;
|
this.buttonRight.TabIndex = 13;
|
||||||
|
this.buttonRight.Text = " ";
|
||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
@ -130,11 +197,11 @@
|
|||||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonLeft.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелка;
|
this.buttonLeft.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелка;
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(63, 672);
|
this.buttonLeft.Location = new System.Drawing.Point(54, 609);
|
||||||
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(34, 40);
|
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonLeft.TabIndex = 8;
|
this.buttonLeft.TabIndex = 12;
|
||||||
|
this.buttonLeft.Text = " ";
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
@ -143,73 +210,49 @@
|
|||||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonUp.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелкаtop;
|
this.buttonUp.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелкаtop;
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonUp.Location = new System.Drawing.Point(104, 624);
|
this.buttonUp.Location = new System.Drawing.Point(90, 573);
|
||||||
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.buttonUp.Name = "buttonUp";
|
this.buttonUp.Name = "buttonUp";
|
||||||
this.buttonUp.Size = new System.Drawing.Size(34, 40);
|
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonUp.TabIndex = 7;
|
this.buttonUp.TabIndex = 11;
|
||||||
|
this.buttonUp.Text = " ";
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonShowOnMap
|
// buttonDown
|
||||||
//
|
//
|
||||||
this.buttonShowOnMap.Location = new System.Drawing.Point(19, 521);
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.buttonDown.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелкаbott;
|
||||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonShowOnMap.Size = new System.Drawing.Size(200, 47);
|
this.buttonDown.Location = new System.Drawing.Point(90, 609);
|
||||||
this.buttonShowOnMap.TabIndex = 5;
|
this.buttonDown.Name = "buttonDown";
|
||||||
this.buttonShowOnMap.Text = "Посмотреть карту";
|
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
this.buttonDown.TabIndex = 10;
|
||||||
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
this.buttonDown.Text = " ";
|
||||||
//
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
// buttonAddTruck
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
|
||||||
this.buttonAddTruck.Location = new System.Drawing.Point(19, 141);
|
|
||||||
this.buttonAddTruck.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.buttonAddTruck.Name = "buttonAddTruck";
|
|
||||||
this.buttonAddTruck.Size = new System.Drawing.Size(200, 47);
|
|
||||||
this.buttonAddTruck.TabIndex = 1;
|
|
||||||
this.buttonAddTruck.Text = "Добавить военный корабль";
|
|
||||||
this.buttonAddTruck.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAddTruck.Click += new System.EventHandler(this.ButtonAddWarship_Click);
|
|
||||||
//
|
|
||||||
// comboBoxSelectorMap
|
|
||||||
//
|
|
||||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
|
||||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
|
||||||
"Простая карта",
|
|
||||||
"Морская карта",
|
|
||||||
});
|
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(19, 43);
|
|
||||||
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(199, 28);
|
|
||||||
this.comboBoxSelectorMap.TabIndex = 0;
|
|
||||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
|
||||||
//
|
//
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||||
this.pictureBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.pictureBox.Name = "pictureBox";
|
this.pictureBox.Name = "pictureBox";
|
||||||
this.pictureBox.Size = new System.Drawing.Size(927, 739);
|
this.pictureBox.Size = new System.Drawing.Size(833, 649);
|
||||||
this.pictureBox.TabIndex = 1;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.pictureBox.TabStop = false;
|
this.pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
// FormMapWithSetTrucks
|
// FormMapWithSetWarship
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1160, 739);
|
this.ClientSize = new System.Drawing.Size(1050, 649);
|
||||||
this.Controls.Add(this.pictureBox);
|
this.Controls.Add(this.pictureBox);
|
||||||
this.Controls.Add(this.groupBoxTools);
|
this.Controls.Add(this.groupBoxTools);
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.Name = "FormMapWithSetWarship";
|
||||||
this.Name = "FormMapWithSetTrucks";
|
|
||||||
this.Text = "Карта с набором объектов";
|
this.Text = "Карта с набором объектов";
|
||||||
this.groupBoxTools.ResumeLayout(false);
|
this.groupBoxTools.ResumeLayout(false);
|
||||||
this.groupBoxTools.PerformLayout();
|
this.groupBoxTools.PerformLayout();
|
||||||
|
this.groupBoxMaps.ResumeLayout(false);
|
||||||
|
this.groupBoxMaps.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
@ -220,14 +263,19 @@
|
|||||||
private GroupBox groupBoxTools;
|
private GroupBox groupBoxTools;
|
||||||
private PictureBox pictureBox;
|
private PictureBox pictureBox;
|
||||||
private ComboBox comboBoxSelectorMap;
|
private ComboBox comboBoxSelectorMap;
|
||||||
private Button buttonShowOnMap;
|
|
||||||
private Button buttonAddTruck;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonShowOnMap;
|
||||||
private Button buttonShowStorage;
|
private Button buttonShowStorage;
|
||||||
private Button buttonRemoveTruck;
|
private Button buttonRemoveWarship;
|
||||||
private MaskedTextBox maskedTextBoxPosition;
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
|
private Button buttonAddWarship;
|
||||||
|
private GroupBox groupBoxMaps;
|
||||||
|
private Button buttonAddMap;
|
||||||
|
private Button buttonDeleteMap;
|
||||||
|
private ListBox listBoxMaps;
|
||||||
|
private TextBox textBoxNewMapName;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,40 +15,96 @@ namespace AircraftCarrier
|
|||||||
public partial class FormMapWithSetWarship : Form
|
public partial class FormMapWithSetWarship : Form
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Объект от класса карты с набором объектов
|
/// Словарь для выпадающего списка
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap> _mapWarshipsCollectionGeneric;
|
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||||
|
{
|
||||||
|
{ "Простая карта", new SimpleMap() },
|
||||||
|
{ "Морская карта", new SeaMap() }
|
||||||
|
};
|
||||||
|
/// <summary>
|
||||||
|
/// Объект от коллекции карт
|
||||||
|
/// </summary>
|
||||||
|
private readonly MapsCollection _mapsCollection;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FormMapWithSetWarship()
|
public FormMapWithSetWarship()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||||
|
comboBoxSelectorMap.Items.Clear();
|
||||||
|
foreach (var elem in _mapsDict)
|
||||||
|
{
|
||||||
|
comboBoxSelectorMap.Items.Add(elem.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Заполнение listBoxMaps
|
||||||
|
/// </summary>
|
||||||
|
private void ReloadMaps()
|
||||||
|
{
|
||||||
|
int index = listBoxMaps.SelectedIndex;
|
||||||
|
|
||||||
|
listBoxMaps.Items.Clear();
|
||||||
|
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
||||||
|
{
|
||||||
|
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
|
||||||
|
{
|
||||||
|
listBoxMaps.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
|
||||||
|
{
|
||||||
|
listBoxMaps.SelectedIndex = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonAddMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Какое-то поле пустое", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!_mapsDict.ContainsKey(comboBoxSelectorMap.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Карта отсутсвует", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
|
||||||
|
ReloadMaps();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Выбор карты
|
/// Выбор карты
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AbstractMap map = null;
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
switch (comboBoxSelectorMap.Text)
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonDeleteMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
case "Простая карта":
|
return;
|
||||||
map = new SimpleMap();
|
|
||||||
break;
|
|
||||||
case "Морская карта":
|
|
||||||
map = new SeaMap();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (map != null)
|
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
_mapWarshipsCollectionGeneric = new MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap>(pictureBox.Width, pictureBox.Height, map);
|
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||||
}
|
ReloadMaps();
|
||||||
else
|
|
||||||
{
|
|
||||||
_mapWarshipsCollectionGeneric = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -58,7 +114,7 @@ namespace AircraftCarrier
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonAddWarship_Click(object sender, EventArgs e)
|
private void ButtonAddWarship_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapWarshipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -66,10 +122,10 @@ namespace AircraftCarrier
|
|||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
DrawingObjectWarship warship = new(form.SelectedWarship);
|
DrawingObjectWarship warship = new(form.SelectedWarship);
|
||||||
if (_mapWarshipsCollectionGeneric + warship != -1)
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship >= 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _mapWarshipsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -88,15 +144,16 @@ namespace AircraftCarrier
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if (_mapWarshipsCollectionGeneric - pos != null)
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _mapWarshipsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -110,11 +167,11 @@ namespace AircraftCarrier
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapWarshipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapWarshipsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывод карты
|
/// Вывод карты
|
||||||
@ -123,11 +180,11 @@ namespace AircraftCarrier
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapWarshipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapWarshipsCollectionGeneric.ShowOnMap();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перемещение
|
/// Перемещение
|
||||||
@ -136,30 +193,29 @@ namespace AircraftCarrier
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapWarshipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//получаем имя кнопки
|
//получаем имя кнопки
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
Direction direction = Direction.None;
|
Direction dir = Direction.None;
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case "buttonUp":
|
case "buttonUp":
|
||||||
direction = Direction.Up;
|
dir = Direction.Up;
|
||||||
break;
|
break;
|
||||||
case "buttonDown":
|
case "buttonDown":
|
||||||
direction = Direction.Down;
|
dir = Direction.Down;
|
||||||
break;
|
break;
|
||||||
case "buttonLeft":
|
case "buttonLeft":
|
||||||
direction = Direction.Left;
|
dir = Direction.Left;
|
||||||
break;
|
break;
|
||||||
case "buttonRight":
|
case "buttonRight":
|
||||||
direction = Direction.Right;
|
dir = Direction.Right;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapWarshipsCollectionGeneric.MoveObject(direction);
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace AircraftCarrier
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Размер занимаемого объектом места (высота)
|
/// Размер занимаемого объектом места (высота)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _placeSizeHeight = 137;
|
private readonly int _placeSizeHeight = 161;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Набор объектов
|
/// Набор объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -94,13 +94,9 @@ namespace AircraftCarrier
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
Shaking();
|
Shaking();
|
||||||
for (int i = 0; i < _setWarships.Count; i++)
|
foreach (var warship in _setWarships.GetWarships())
|
||||||
{
|
{
|
||||||
var warship = _setWarships.Get(i);
|
return _map.CreateMap(_pictureWidth, _pictureHeight, warship);
|
||||||
if (warship != null)
|
|
||||||
{
|
|
||||||
return _map.CreateMap(_pictureWidth, _pictureHeight, warship);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return new(_pictureWidth, _pictureHeight);
|
return new(_pictureWidth, _pictureHeight);
|
||||||
}
|
}
|
||||||
@ -126,11 +122,11 @@ namespace AircraftCarrier
|
|||||||
int j = _setWarships.Count - 1;
|
int j = _setWarships.Count - 1;
|
||||||
for (int i = 0; i < _setWarships.Count; i++)
|
for (int i = 0; i < _setWarships.Count; i++)
|
||||||
{
|
{
|
||||||
if (_setWarships.Get(i) == null)
|
if (_setWarships[i] == null)
|
||||||
{
|
{
|
||||||
for (; j > i; j--)
|
for (; j > i; j--)
|
||||||
{
|
{
|
||||||
var warship = _setWarships.Get(j);
|
var warship = _setWarships[j];
|
||||||
if (warship != null)
|
if (warship != null)
|
||||||
{
|
{
|
||||||
_setWarships.Insert(warship, i);
|
_setWarships.Insert(warship, i);
|
||||||
@ -172,15 +168,15 @@ namespace AircraftCarrier
|
|||||||
{
|
{
|
||||||
int width = _pictureWidth / _placeSizeWidth;
|
int width = _pictureWidth / _placeSizeWidth;
|
||||||
int height = _pictureHeight / _placeSizeHeight;
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
for (int i = 0; i < _setWarships.Count; i++)
|
foreach (var warship in _setWarships.GetWarships())
|
||||||
{
|
{
|
||||||
if (_setWarships.Get(i) != null)
|
warship.SetObject(i % width * _placeSizeWidth + 10, (height - 1 - i / width) * _placeSizeHeight + 25, _pictureWidth, _pictureHeight);
|
||||||
{
|
warship.DrawningObject(g);
|
||||||
_setWarships.Get(i).SetObject(i % width * _placeSizeWidth + 10, (height - 1 - i / width) * _placeSizeHeight + 25, _pictureWidth, _pictureHeight);
|
i++;
|
||||||
_setWarships.Get(i)?.DrawningObject(g);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
69
Warship/Warship/MapsCollection.cs
Normal file
69
Warship/Warship/MapsCollection.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftCarrier
|
||||||
|
{
|
||||||
|
internal class MapsCollection
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Словарь (хранилище) с картами
|
||||||
|
/// </summary>
|
||||||
|
readonly Dictionary<string, MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap>> _mapStorages;
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращение списка названий карт
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Keys => _mapStorages.Keys.ToList();
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pictureWidth"></param>
|
||||||
|
/// <param name="pictureHeight"></param>
|
||||||
|
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||||
|
{
|
||||||
|
_mapStorages = new Dictionary<string, MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название карты</param>
|
||||||
|
/// <param name="map">Карта</param>
|
||||||
|
public void AddMap(string name, AbstractMap map)
|
||||||
|
{
|
||||||
|
_mapStorages.Add(name, new(_pictureWidth, _pictureHeight, map));
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название карты</param>
|
||||||
|
public void DelMap(string name)
|
||||||
|
{
|
||||||
|
_mapStorages.Remove(name);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Доступ к докам
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ind"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap> this[string ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
_mapStorages.TryGetValue(ind, out var MapWithSetWarshipsGeneric);
|
||||||
|
return MapWithSetWarshipsGeneric;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,21 +14,23 @@ namespace AircraftCarrier
|
|||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Массив объектов, которые храним
|
/// Список объектов, которые храним
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly T[] _places;
|
private readonly List<T> _places;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Количество объектов в массиве
|
/// Количество объектов в списке
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Count => _places.Length;
|
public int Count => _places.Count;
|
||||||
|
|
||||||
|
private readonly int _maxCount;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="count"></param>
|
/// <param name="count"></param>
|
||||||
public SetWarshipsGeneric(int count)
|
public SetWarshipsGeneric(int count)
|
||||||
{
|
{
|
||||||
_places = new T[count];
|
_maxCount = count;
|
||||||
|
_places = new List<T>();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в набор
|
/// Добавление объекта в набор
|
||||||
@ -37,31 +39,7 @@ namespace AircraftCarrier
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T ship)
|
public int Insert(T ship)
|
||||||
{
|
{
|
||||||
bool CheckEmptySpace = false;
|
return Insert(ship, 0);
|
||||||
int indexOfEmptyPlace = 0;
|
|
||||||
for (int i = 0; i < Count; ++i)
|
|
||||||
{
|
|
||||||
if (_places[i] == null || _places[i] == default(T))
|
|
||||||
{
|
|
||||||
CheckEmptySpace = true;
|
|
||||||
indexOfEmptyPlace = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CheckEmptySpace)
|
|
||||||
{
|
|
||||||
for (int i = indexOfEmptyPlace; i > 0; --i)
|
|
||||||
{
|
|
||||||
_places[i] = _places[i - 1];
|
|
||||||
}
|
|
||||||
_places[0] = ship;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в набор на конкретную позицию
|
/// Добавление объекта в набор на конкретную позицию
|
||||||
@ -71,42 +49,8 @@ namespace AircraftCarrier
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T ship, int position)
|
public int Insert(T ship, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (position >= _maxCount || position < 0) return -1; _places.Insert(position, ship);
|
||||||
{
|
return 1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (_places[position] == null || _places[position] == default(T))
|
|
||||||
{
|
|
||||||
_places[position] = ship;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool hasEmptySpace = false;
|
|
||||||
int indexOfEmptyPlace = 0;
|
|
||||||
for (int i = position + 1; i < Count; ++i)
|
|
||||||
{
|
|
||||||
if (_places[i] == null || _places[i] == default(T))
|
|
||||||
{
|
|
||||||
hasEmptySpace = true;
|
|
||||||
indexOfEmptyPlace = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasEmptySpace)
|
|
||||||
{
|
|
||||||
for (int i = indexOfEmptyPlace; i > position; --i)
|
|
||||||
{
|
|
||||||
_places[i] = _places[i - 1];
|
|
||||||
}
|
|
||||||
_places[position] = ship;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта из набора с конкретной позиции
|
/// Удаление объекта из набора с конкретной позиции
|
||||||
@ -115,32 +59,49 @@ namespace AircraftCarrier
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (position >= _maxCount || position < 0)
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
var result = _places[position];
|
||||||
|
_places.RemoveAt(position);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public T this[int position]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (position >= _maxCount || position < 0) return null;
|
||||||
|
return _places[position];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Insert(value, position);
|
||||||
}
|
}
|
||||||
T memoryObj = _places[position];
|
|
||||||
_places[position] = null;
|
|
||||||
return memoryObj;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта из набора по позиции
|
/// Проход по набору до первого пустого
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T Get(int position)
|
public IEnumerable<T> GetWarships()
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
foreach (var warship in _places)
|
||||||
{
|
{
|
||||||
return null;
|
if (warship != null)
|
||||||
|
{
|
||||||
|
yield return warship;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return _places[position];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user