Изменения отображения

This commit is contained in:
Кашин Максим 2022-10-19 09:03:11 +04:00
parent 8bd7a3ee39
commit 74ae24d23b
3 changed files with 90 additions and 46 deletions

View File

@ -63,9 +63,11 @@
this.groupBoxTools.Controls.Add(this.buttonRemoveGasolineTanker); this.groupBoxTools.Controls.Add(this.buttonRemoveGasolineTanker);
this.groupBoxTools.Controls.Add(this.buttonAddGasolineTanker); this.groupBoxTools.Controls.Add(this.buttonAddGasolineTanker);
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBoxTools.Location = new System.Drawing.Point(694, 0); this.groupBoxTools.Location = new System.Drawing.Point(793, 0);
this.groupBoxTools.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBoxTools.Name = "groupBoxTools"; this.groupBoxTools.Name = "groupBoxTools";
this.groupBoxTools.Size = new System.Drawing.Size(200, 629); this.groupBoxTools.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBoxTools.Size = new System.Drawing.Size(229, 839);
this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabIndex = 0;
this.groupBoxTools.TabStop = false; this.groupBoxTools.TabStop = false;
this.groupBoxTools.Text = "Tools"; this.groupBoxTools.Text = "Tools";
@ -77,18 +79,21 @@
this.groupBoxMaps.Controls.Add(this.buttonAddMap); this.groupBoxMaps.Controls.Add(this.buttonAddMap);
this.groupBoxMaps.Controls.Add(this.textBoxNewMapName); this.groupBoxMaps.Controls.Add(this.textBoxNewMapName);
this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap); this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap);
this.groupBoxMaps.Location = new System.Drawing.Point(6, 22); this.groupBoxMaps.Location = new System.Drawing.Point(7, 29);
this.groupBoxMaps.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBoxMaps.Name = "groupBoxMaps"; this.groupBoxMaps.Name = "groupBoxMaps";
this.groupBoxMaps.Size = new System.Drawing.Size(190, 305); this.groupBoxMaps.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.groupBoxMaps.Size = new System.Drawing.Size(217, 407);
this.groupBoxMaps.TabIndex = 13; this.groupBoxMaps.TabIndex = 13;
this.groupBoxMaps.TabStop = false; this.groupBoxMaps.TabStop = false;
this.groupBoxMaps.Text = "Maps"; this.groupBoxMaps.Text = "Maps";
// //
// buttonDeleteMap // buttonDeleteMap
// //
this.buttonDeleteMap.Location = new System.Drawing.Point(6, 241); this.buttonDeleteMap.Location = new System.Drawing.Point(7, 321);
this.buttonDeleteMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonDeleteMap.Name = "buttonDeleteMap"; this.buttonDeleteMap.Name = "buttonDeleteMap";
this.buttonDeleteMap.Size = new System.Drawing.Size(175, 49); this.buttonDeleteMap.Size = new System.Drawing.Size(200, 65);
this.buttonDeleteMap.TabIndex = 16; this.buttonDeleteMap.TabIndex = 16;
this.buttonDeleteMap.Text = "Delete Map"; this.buttonDeleteMap.Text = "Delete Map";
this.buttonDeleteMap.UseVisualStyleBackColor = true; this.buttonDeleteMap.UseVisualStyleBackColor = true;
@ -97,18 +102,20 @@
// listBoxMaps // listBoxMaps
// //
this.listBoxMaps.FormattingEnabled = true; this.listBoxMaps.FormattingEnabled = true;
this.listBoxMaps.ItemHeight = 15; this.listBoxMaps.ItemHeight = 20;
this.listBoxMaps.Location = new System.Drawing.Point(6, 141); this.listBoxMaps.Location = new System.Drawing.Point(7, 188);
this.listBoxMaps.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.listBoxMaps.Name = "listBoxMaps"; this.listBoxMaps.Name = "listBoxMaps";
this.listBoxMaps.Size = new System.Drawing.Size(176, 94); this.listBoxMaps.Size = new System.Drawing.Size(201, 124);
this.listBoxMaps.TabIndex = 15; this.listBoxMaps.TabIndex = 15;
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged); this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged);
// //
// buttonAddMap // buttonAddMap
// //
this.buttonAddMap.Location = new System.Drawing.Point(6, 84); this.buttonAddMap.Location = new System.Drawing.Point(7, 112);
this.buttonAddMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonAddMap.Name = "buttonAddMap"; this.buttonAddMap.Name = "buttonAddMap";
this.buttonAddMap.Size = new System.Drawing.Size(176, 51); this.buttonAddMap.Size = new System.Drawing.Size(201, 68);
this.buttonAddMap.TabIndex = 14; this.buttonAddMap.TabIndex = 14;
this.buttonAddMap.Text = "Add Map"; this.buttonAddMap.Text = "Add Map";
this.buttonAddMap.UseVisualStyleBackColor = true; this.buttonAddMap.UseVisualStyleBackColor = true;
@ -116,9 +123,10 @@
// //
// textBoxNewMapName // textBoxNewMapName
// //
this.textBoxNewMapName.Location = new System.Drawing.Point(6, 24); this.textBoxNewMapName.Location = new System.Drawing.Point(7, 32);
this.textBoxNewMapName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBoxNewMapName.Name = "textBoxNewMapName"; this.textBoxNewMapName.Name = "textBoxNewMapName";
this.textBoxNewMapName.Size = new System.Drawing.Size(178, 23); this.textBoxNewMapName.Size = new System.Drawing.Size(203, 27);
this.textBoxNewMapName.TabIndex = 13; this.textBoxNewMapName.TabIndex = 13;
// //
// comboBoxSelectorMap // comboBoxSelectorMap
@ -128,18 +136,20 @@
this.comboBoxSelectorMap.Items.AddRange(new object[] { this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Simple map", "Simple map",
"Long map"}); "Long map"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 53); this.comboBoxSelectorMap.Location = new System.Drawing.Point(7, 71);
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(178, 23); this.comboBoxSelectorMap.Size = new System.Drawing.Size(203, 28);
this.comboBoxSelectorMap.TabIndex = 12; this.comboBoxSelectorMap.TabIndex = 12;
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
// //
// maskedTextBoxPosition // maskedTextBoxPosition
// //
this.maskedTextBoxPosition.Location = new System.Drawing.Point(10, 391); this.maskedTextBoxPosition.Location = new System.Drawing.Point(11, 521);
this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.maskedTextBoxPosition.Mask = "00"; this.maskedTextBoxPosition.Mask = "00";
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
this.maskedTextBoxPosition.Size = new System.Drawing.Size(184, 23); this.maskedTextBoxPosition.Size = new System.Drawing.Size(210, 27);
this.maskedTextBoxPosition.TabIndex = 11; this.maskedTextBoxPosition.TabIndex = 11;
// //
// keyRight // keyRight
@ -147,9 +157,10 @@
this.keyRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.keyRight.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyRight; this.keyRight.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyRight;
this.keyRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.keyRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.keyRight.Location = new System.Drawing.Point(122, 587); this.keyRight.Location = new System.Drawing.Point(139, 783);
this.keyRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.keyRight.Name = "keyRight"; this.keyRight.Name = "keyRight";
this.keyRight.Size = new System.Drawing.Size(30, 30); this.keyRight.Size = new System.Drawing.Size(34, 40);
this.keyRight.TabIndex = 10; this.keyRight.TabIndex = 10;
this.keyRight.UseVisualStyleBackColor = true; this.keyRight.UseVisualStyleBackColor = true;
this.keyRight.Click += new System.EventHandler(this.ButtonMove_Click); this.keyRight.Click += new System.EventHandler(this.ButtonMove_Click);
@ -159,9 +170,10 @@
this.keyLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.keyLeft.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyLeft; this.keyLeft.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyLeft;
this.keyLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.keyLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.keyLeft.Location = new System.Drawing.Point(50, 587); this.keyLeft.Location = new System.Drawing.Point(57, 783);
this.keyLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.keyLeft.Name = "keyLeft"; this.keyLeft.Name = "keyLeft";
this.keyLeft.Size = new System.Drawing.Size(30, 30); this.keyLeft.Size = new System.Drawing.Size(34, 40);
this.keyLeft.TabIndex = 9; this.keyLeft.TabIndex = 9;
this.keyLeft.UseVisualStyleBackColor = true; this.keyLeft.UseVisualStyleBackColor = true;
this.keyLeft.Click += new System.EventHandler(this.ButtonMove_Click); this.keyLeft.Click += new System.EventHandler(this.ButtonMove_Click);
@ -171,9 +183,10 @@
this.keyUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.keyUp.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyUp; this.keyUp.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyUp;
this.keyUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.keyUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.keyUp.Location = new System.Drawing.Point(86, 551); this.keyUp.Location = new System.Drawing.Point(98, 735);
this.keyUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.keyUp.Name = "keyUp"; this.keyUp.Name = "keyUp";
this.keyUp.Size = new System.Drawing.Size(30, 30); this.keyUp.Size = new System.Drawing.Size(34, 40);
this.keyUp.TabIndex = 8; this.keyUp.TabIndex = 8;
this.keyUp.UseVisualStyleBackColor = true; this.keyUp.UseVisualStyleBackColor = true;
this.keyUp.Click += new System.EventHandler(this.ButtonMove_Click); this.keyUp.Click += new System.EventHandler(this.ButtonMove_Click);
@ -183,18 +196,20 @@
this.keyDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.keyDown.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyDown; this.keyDown.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyDown;
this.keyDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.keyDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.keyDown.Location = new System.Drawing.Point(86, 587); this.keyDown.Location = new System.Drawing.Point(98, 783);
this.keyDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.keyDown.Name = "keyDown"; this.keyDown.Name = "keyDown";
this.keyDown.Size = new System.Drawing.Size(30, 30); this.keyDown.Size = new System.Drawing.Size(34, 40);
this.keyDown.TabIndex = 7; this.keyDown.TabIndex = 7;
this.keyDown.UseVisualStyleBackColor = true; this.keyDown.UseVisualStyleBackColor = true;
this.keyDown.Click += new System.EventHandler(this.ButtonMove_Click); this.keyDown.Click += new System.EventHandler(this.ButtonMove_Click);
// //
// buttonShowOnMap // buttonShowOnMap
// //
this.buttonShowOnMap.Location = new System.Drawing.Point(8, 500); this.buttonShowOnMap.Location = new System.Drawing.Point(9, 667);
this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonShowOnMap.Name = "buttonShowOnMap"; this.buttonShowOnMap.Name = "buttonShowOnMap";
this.buttonShowOnMap.Size = new System.Drawing.Size(186, 34); this.buttonShowOnMap.Size = new System.Drawing.Size(213, 45);
this.buttonShowOnMap.TabIndex = 4; this.buttonShowOnMap.TabIndex = 4;
this.buttonShowOnMap.Text = "Show on map"; this.buttonShowOnMap.Text = "Show on map";
this.buttonShowOnMap.UseVisualStyleBackColor = true; this.buttonShowOnMap.UseVisualStyleBackColor = true;
@ -202,9 +217,10 @@
// //
// buttonShowStorage // buttonShowStorage
// //
this.buttonShowStorage.Location = new System.Drawing.Point(8, 460); this.buttonShowStorage.Location = new System.Drawing.Point(9, 613);
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(186, 34); this.buttonShowStorage.Size = new System.Drawing.Size(213, 45);
this.buttonShowStorage.TabIndex = 3; this.buttonShowStorage.TabIndex = 3;
this.buttonShowStorage.Text = "Show storage"; this.buttonShowStorage.Text = "Show storage";
this.buttonShowStorage.UseVisualStyleBackColor = true; this.buttonShowStorage.UseVisualStyleBackColor = true;
@ -212,18 +228,21 @@
// //
// buttonRemoveGasolineTanker // buttonRemoveGasolineTanker
// //
this.buttonRemoveGasolineTanker.Location = new System.Drawing.Point(8, 420); this.buttonRemoveGasolineTanker.Location = new System.Drawing.Point(9, 560);
this.buttonRemoveGasolineTanker.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonRemoveGasolineTanker.Name = "buttonRemoveGasolineTanker"; this.buttonRemoveGasolineTanker.Name = "buttonRemoveGasolineTanker";
this.buttonRemoveGasolineTanker.Size = new System.Drawing.Size(186, 34); this.buttonRemoveGasolineTanker.Size = new System.Drawing.Size(213, 45);
this.buttonRemoveGasolineTanker.TabIndex = 2; this.buttonRemoveGasolineTanker.TabIndex = 2;
this.buttonRemoveGasolineTanker.Text = "Remove gasoline tanker"; this.buttonRemoveGasolineTanker.Text = "Remove gasoline tanker";
this.buttonRemoveGasolineTanker.UseVisualStyleBackColor = true; this.buttonRemoveGasolineTanker.UseVisualStyleBackColor = true;
this.buttonRemoveGasolineTanker.Click += new System.EventHandler(this.buttonRemoveGasolineTanker_Click);
// //
// buttonAddGasolineTanker // buttonAddGasolineTanker
// //
this.buttonAddGasolineTanker.Location = new System.Drawing.Point(10, 351); this.buttonAddGasolineTanker.Location = new System.Drawing.Point(11, 468);
this.buttonAddGasolineTanker.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonAddGasolineTanker.Name = "buttonAddGasolineTanker"; this.buttonAddGasolineTanker.Name = "buttonAddGasolineTanker";
this.buttonAddGasolineTanker.Size = new System.Drawing.Size(186, 34); this.buttonAddGasolineTanker.Size = new System.Drawing.Size(213, 45);
this.buttonAddGasolineTanker.TabIndex = 1; this.buttonAddGasolineTanker.TabIndex = 1;
this.buttonAddGasolineTanker.Text = "Add gasoline tanker"; this.buttonAddGasolineTanker.Text = "Add gasoline tanker";
this.buttonAddGasolineTanker.UseVisualStyleBackColor = true; this.buttonAddGasolineTanker.UseVisualStyleBackColor = true;
@ -233,18 +252,20 @@
// //
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(694, 629); this.pictureBox.Size = new System.Drawing.Size(793, 839);
this.pictureBox.TabIndex = 1; this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false; this.pictureBox.TabStop = false;
// //
// FormMapWithSetGasolineTanker // FormMapWithSetGasolineTanker
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(894, 629); this.ClientSize = new System.Drawing.Size(1022, 839);
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 = "FormMapWithSetGasolineTanker"; this.Name = "FormMapWithSetGasolineTanker";
this.Text = "FormMapWithSetGasolineTanker"; this.Text = "FormMapWithSetGasolineTanker";
this.groupBoxTools.ResumeLayout(false); this.groupBoxTools.ResumeLayout(false);

View File

@ -96,7 +96,7 @@ namespace GasolineTanker
{ {
return; return;
} }
pictureBox.Image = _mapGasolineTankerCollectionGeneric.ShowOnMap(); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
} }
private void ButtonMove_Click(object sender, EventArgs e) private void ButtonMove_Click(object sender, EventArgs e)
{ {
@ -181,5 +181,31 @@ namespace GasolineTanker
{ {
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
} }
private void buttonRemoveGasolineTanker_Click(object sender, EventArgs e)
{
if (listBoxMaps.SelectedIndex == -1)
{
return;
}
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
{
return;
}
if (MessageBox.Show("Delete object?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
{
MessageBox.Show("Object delete");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
MessageBox.Show("Errore delete object");
}
}
} }
} }

View File

@ -110,16 +110,13 @@ namespace GasolineTanker
{ {
int width = _pictureWidth / _placeSizeWidth; int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight; int height = _pictureHeight / _placeSizeHeight;
foreach (var gasolineTanker in _setGasolineTanker.GetGasolineTanker()) int i = 0;
foreach (var warship in _setGasolineTanker.GetGasolineTanker())
{ {
gasolineTanker.SetObject(width, height, _pictureWidth, _pictureHeight); warship.SetObject(i % width * _placeSizeWidth+10, (height - 1 - i / width) * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
gasolineTanker.DrawningObject(g); warship.DrawningObject(g);
width += _placeSizeWidth; i++;
if (width > _pictureWidth - _placeSizeWidth)
{
width = _pictureWidth / _placeSizeWidth;
height -= _placeSizeHeight;
}
} }
} }
} }