рабочие TODO

This commit is contained in:
AnnZhimol 2022-10-04 14:49:13 +04:00
parent c9d1b9f133
commit 7fb61aaaf1
4 changed files with 70 additions and 44 deletions

View File

@ -43,9 +43,9 @@
this.groupBoxTools.SuspendLayout(); this.groupBoxTools.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.maskedTextBoxPosition);
this.groupBoxTools.Controls.Add(this.buttonRemoveWarship); this.groupBoxTools.Controls.Add(this.buttonRemoveWarship);
this.groupBoxTools.Controls.Add(this.buttonShowStorage); this.groupBoxTools.Controls.Add(this.buttonShowStorage);
@ -63,18 +63,18 @@
this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabIndex = 0;
this.groupBoxTools.TabStop = false; this.groupBoxTools.TabStop = false;
this.groupBoxTools.Text = "Инструменты"; this.groupBoxTools.Text = "Инструменты";
// //
// maskedTextBoxPosition // maskedTextBoxPosition
// //
this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 166); this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 166);
this.maskedTextBoxPosition.Mask = "00"; this.maskedTextBoxPosition.Mask = "00";
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23); this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
this.maskedTextBoxPosition.TabIndex = 2; this.maskedTextBoxPosition.TabIndex = 2;
this.maskedTextBoxPosition.ValidatingType = typeof(int); this.maskedTextBoxPosition.ValidatingType = typeof(int);
// //
// buttonRemoveWarship // buttonRemoveWarship
// //
this.buttonRemoveWarship.Location = new System.Drawing.Point(17, 195); this.buttonRemoveWarship.Location = new System.Drawing.Point(17, 195);
this.buttonRemoveWarship.Name = "buttonRemoveWarship"; this.buttonRemoveWarship.Name = "buttonRemoveWarship";
this.buttonRemoveWarship.Size = new System.Drawing.Size(175, 35); this.buttonRemoveWarship.Size = new System.Drawing.Size(175, 35);
@ -82,9 +82,9 @@
this.buttonRemoveWarship.Text = "Удалить корабль"; this.buttonRemoveWarship.Text = "Удалить корабль";
this.buttonRemoveWarship.UseVisualStyleBackColor = true; this.buttonRemoveWarship.UseVisualStyleBackColor = true;
this.buttonRemoveWarship.Click += new System.EventHandler(this.ButtonRemoveWarship_Click); this.buttonRemoveWarship.Click += new System.EventHandler(this.ButtonRemoveWarship_Click);
// //
// buttonShowStorage // buttonShowStorage
// //
this.buttonShowStorage.Location = new System.Drawing.Point(17, 287); this.buttonShowStorage.Location = new System.Drawing.Point(17, 287);
this.buttonShowStorage.Name = "buttonShowStorage"; this.buttonShowStorage.Name = "buttonShowStorage";
this.buttonShowStorage.Size = new System.Drawing.Size(175, 35); this.buttonShowStorage.Size = new System.Drawing.Size(175, 35);
@ -92,9 +92,9 @@
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 // buttonDown
// //
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::Warship.Properties.Resources.arrowDown; this.buttonDown.BackgroundImage = global::Warship.Properties.Resources.arrowDown;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
@ -103,9 +103,9 @@
this.buttonDown.Size = new System.Drawing.Size(30, 30); this.buttonDown.Size = new System.Drawing.Size(30, 30);
this.buttonDown.TabIndex = 10; this.buttonDown.TabIndex = 10;
this.buttonDown.UseVisualStyleBackColor = true; this.buttonDown.UseVisualStyleBackColor = true;
// //
// 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::Warship.Properties.Resources.arrowRight; this.buttonRight.BackgroundImage = global::Warship.Properties.Resources.arrowRight;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
@ -114,9 +114,9 @@
this.buttonRight.Size = new System.Drawing.Size(30, 30); this.buttonRight.Size = new System.Drawing.Size(30, 30);
this.buttonRight.TabIndex = 9; this.buttonRight.TabIndex = 9;
this.buttonRight.UseVisualStyleBackColor = true; this.buttonRight.UseVisualStyleBackColor = true;
// //
// buttonLeft // buttonLeft
// //
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::Warship.Properties.Resources.arrowLeft; this.buttonLeft.BackgroundImage = global::Warship.Properties.Resources.arrowLeft;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
@ -125,9 +125,9 @@
this.buttonLeft.Size = new System.Drawing.Size(30, 30); this.buttonLeft.Size = new System.Drawing.Size(30, 30);
this.buttonLeft.TabIndex = 8; this.buttonLeft.TabIndex = 8;
this.buttonLeft.UseVisualStyleBackColor = true; this.buttonLeft.UseVisualStyleBackColor = true;
// //
// buttonUp // buttonUp
// //
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::Warship.Properties.Resources.arrowUp; this.buttonUp.BackgroundImage = global::Warship.Properties.Resources.arrowUp;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
@ -136,9 +136,9 @@
this.buttonUp.Size = new System.Drawing.Size(30, 30); this.buttonUp.Size = new System.Drawing.Size(30, 30);
this.buttonUp.TabIndex = 7; this.buttonUp.TabIndex = 7;
this.buttonUp.UseVisualStyleBackColor = true; this.buttonUp.UseVisualStyleBackColor = true;
// //
// buttonShowOnMap // buttonShowOnMap
// //
this.buttonShowOnMap.Location = new System.Drawing.Point(17, 391); this.buttonShowOnMap.Location = new System.Drawing.Point(17, 391);
this.buttonShowOnMap.Name = "buttonShowOnMap"; this.buttonShowOnMap.Name = "buttonShowOnMap";
this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35); this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35);
@ -146,9 +146,9 @@
this.buttonShowOnMap.Text = "Посмотреть карту"; this.buttonShowOnMap.Text = "Посмотреть карту";
this.buttonShowOnMap.UseVisualStyleBackColor = true; this.buttonShowOnMap.UseVisualStyleBackColor = true;
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click); this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
// //
// buttonAddWarship // buttonAddWarship
// //
this.buttonAddWarship.Location = new System.Drawing.Point(17, 106); this.buttonAddWarship.Location = new System.Drawing.Point(17, 106);
this.buttonAddWarship.Name = "buttonAddWarship"; this.buttonAddWarship.Name = "buttonAddWarship";
this.buttonAddWarship.Size = new System.Drawing.Size(175, 35); this.buttonAddWarship.Size = new System.Drawing.Size(175, 35);
@ -156,29 +156,31 @@
this.buttonAddWarship.Text = "Добавить корабль"; this.buttonAddWarship.Text = "Добавить корабль";
this.buttonAddWarship.UseVisualStyleBackColor = true; this.buttonAddWarship.UseVisualStyleBackColor = true;
this.buttonAddWarship.Click += new System.EventHandler(this.ButtonAddWarship_Click); this.buttonAddWarship.Click += new System.EventHandler(this.ButtonAddWarship_Click);
// //
// comboBoxSelectorMap // comboBoxSelectorMap
// //
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelectorMap.FormattingEnabled = true; this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {"Простая карта"}); this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Первая карта",
"Вторая карта"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(17, 32); this.comboBoxSelectorMap.Location = new System.Drawing.Point(17, 32);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23); this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
this.comboBoxSelectorMap.TabIndex = 0; this.comboBoxSelectorMap.TabIndex = 0;
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); 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.Name = "pictureBox"; this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(811, 554); this.pictureBox.Size = new System.Drawing.Size(811, 554);
this.pictureBox.TabIndex = 1; this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false; this.pictureBox.TabStop = false;
// //
// FormMapWithSetWarships // FormMapWithSetWarships
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); 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(1015, 554); this.ClientSize = new System.Drawing.Size(1015, 554);
@ -190,6 +192,7 @@
this.groupBoxTools.PerformLayout(); this.groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
#endregion #endregion

View File

@ -22,11 +22,15 @@ namespace Warship
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
{ {
AbstractMap map = null; AbstractMap map = null;
switch (comboBoxSelectorMap.Text) switch (comboBoxSelectorMap.Text)
{ {
case ростая карта": case ервая карта":
map = new SimpleMap(); map = new SimpleMap();
break; break;
case "Вторая карта":
map = new SecondMap();
break;
} }
if (map != null) if (map != null)
{ {

View File

@ -96,29 +96,30 @@ namespace Warship
private void DrawBackground(Graphics gr) private void DrawBackground(Graphics gr)
{ {
Pen pen = new(Color.Black, 3); Pen pen = new(Color.Black, 5);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{ {
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
{ {
gr.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight); gr.DrawLine(pen, i * _placeSizeWidth+10, j * _placeSizeHeight+2, i * _placeSizeWidth + (int)(_placeSizeWidth*0.8), j * _placeSizeHeight+2);
gr.DrawLine(pen, i * _placeSizeWidth + (int)(_placeSizeWidth * 0.8), j * _placeSizeHeight + 2, i * _placeSizeWidth + (int)(_placeSizeWidth * 0.9)+10, j * _placeSizeHeight + 2+20);
gr.DrawLine(pen, i * _placeSizeWidth + (int)(_placeSizeWidth * 0.9) + 10, j * _placeSizeHeight + 2 + 20, i * _placeSizeWidth + (int)(_placeSizeWidth * 0.9) + 10, j * _placeSizeHeight + 2 + 20);
} }
gr.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight/_placeSizeHeight) * _placeSizeHeight);
} }
} }
private void DrawWarship(Graphics gr) private void DrawWarship(Graphics gr)
{ {
int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight;
for (int i = 0; i < _setWarship.Count; i++) for (int i = 0; i < _setWarship.Count; i++)
{ {
for (int i1 = 0; i1 < _pictureWidth / _placeSizeWidth; i1++) if (_setWarship.Get(i) != null)
{ {
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) _setWarship.Get(i).SetObject(i % width * _placeSizeWidth + 10, (height - 1 - i / width) * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
{ _setWarship.Get(i)?.DrawingObject(gr);
_setWarship.Get(i)?.SetObject(i1 * _placeSizeWidth, j * _placeSizeHeight, _pictureWidth, _pictureHeight);
}
} }
_setWarship.Get(i)?.DrawingObject(gr);
} }
} }
} }

View File

@ -20,24 +20,36 @@ namespace Warship
public bool Insert(T warship) public bool Insert(T warship)
{ {
_places[0] = warship; return Insert(warship,0);
return true;
} }
public bool Insert(T warship, int position) public bool Insert(T warship, int position)
{ {
int EmptyEl=position; int EmptyEl=-1;
if (_places[position]!=null) if (position>=Count || position < 0)
return false;
if (_places[position] == null)
{ {
for (int i = position; i < Count; i++) _places[position] = warship;
return true;
}
else if (_places[position] != null)
{
for (int i = position + 1; i < Count; i++)
if (_places[i] == null) if (_places[i] == null)
{ {
EmptyEl = i; EmptyEl = i;
break; break;
} }
for (int j = EmptyEl; j > position; j--)
_places[j] = _places[j - 1]; if (EmptyEl == -1)
return false;
for (int i = EmptyEl; i > position; i--)
_places[i] = _places[i - 1];
} }
_places[position] = warship; _places[position] = warship;
@ -46,12 +58,18 @@ namespace Warship
public bool Remove(int position) public bool Remove(int position)
{ {
if (position >= Count || position < 0 || _places[position]==null)
return false;
_places[position] = null; _places[position] = null;
return true; return true;
} }
public T Get(int position) public T Get(int position)
{ {
if (position >= Count || position < 0)
return null;
return _places[position]; return _places[position];
} }
} }