Compare commits
No commits in common. "2a53b2840c71ff0dc766373f7a05c7c481f016c1" and "19b93bd2ee6655184bdb8f6346bd96807a03c6b7" have entirely different histories.
2a53b2840c
...
19b93bd2ee
214
WinFormsApp1/FormMapWithSetTraktor.Designer.cs
generated
214
WinFormsApp1/FormMapWithSetTraktor.Designer.cs
generated
@ -31,12 +31,6 @@ namespace WinFormsApp1
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBoxMaps = new System.Windows.Forms.GroupBox();
|
||||
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
||||
this.buttonDeleteMap = new System.Windows.Forms.Button();
|
||||
this.buttonAddMap = new System.Windows.Forms.Button();
|
||||
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
@ -46,15 +40,14 @@ namespace WinFormsApp1
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonRemoveTraktor = new System.Windows.Forms.Button();
|
||||
this.buttonAddTraktor = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBoxMaps.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.groupBoxMaps);
|
||||
this.groupBox1.Controls.Add(this.buttonRight);
|
||||
this.groupBox1.Controls.Add(this.buttonDown);
|
||||
this.groupBox1.Controls.Add(this.buttonLeft);
|
||||
@ -64,138 +57,68 @@ namespace WinFormsApp1
|
||||
this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBox1.Controls.Add(this.buttonRemoveTraktor);
|
||||
this.groupBox1.Controls.Add(this.buttonAddTraktor);
|
||||
this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBox1.Location = new System.Drawing.Point(596, 0);
|
||||
this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.groupBox1.Location = new System.Drawing.Point(832, 0);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.groupBox1.Size = new System.Drawing.Size(219, 476);
|
||||
this.groupBox1.Size = new System.Drawing.Size(250, 518);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Инструменты";
|
||||
//
|
||||
// groupBoxMaps
|
||||
//
|
||||
this.groupBoxMaps.Controls.Add(this.listBoxMaps);
|
||||
this.groupBoxMaps.Controls.Add(this.buttonDeleteMap);
|
||||
this.groupBoxMaps.Controls.Add(this.buttonAddMap);
|
||||
this.groupBoxMaps.Controls.Add(this.textBoxNewMapName);
|
||||
this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBoxMaps.Location = new System.Drawing.Point(7, 20);
|
||||
this.groupBoxMaps.Name = "groupBoxMaps";
|
||||
this.groupBoxMaps.Size = new System.Drawing.Size(200, 244);
|
||||
this.groupBoxMaps.TabIndex = 2;
|
||||
this.groupBoxMaps.TabStop = false;
|
||||
this.groupBoxMaps.Text = "Карты";
|
||||
//
|
||||
// listBoxMaps
|
||||
//
|
||||
this.listBoxMaps.FormattingEnabled = true;
|
||||
this.listBoxMaps.ItemHeight = 15;
|
||||
this.listBoxMaps.Location = new System.Drawing.Point(6, 109);
|
||||
this.listBoxMaps.Name = "listBoxMaps";
|
||||
this.listBoxMaps.Size = new System.Drawing.Size(188, 94);
|
||||
this.listBoxMaps.TabIndex = 4;
|
||||
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged);
|
||||
//
|
||||
// buttonDeleteMap
|
||||
//
|
||||
this.buttonDeleteMap.Location = new System.Drawing.Point(6, 215);
|
||||
this.buttonDeleteMap.Name = "buttonDeleteMap";
|
||||
this.buttonDeleteMap.Size = new System.Drawing.Size(188, 23);
|
||||
this.buttonDeleteMap.TabIndex = 3;
|
||||
this.buttonDeleteMap.Text = "Удалить карту";
|
||||
this.buttonDeleteMap.UseVisualStyleBackColor = true;
|
||||
this.buttonDeleteMap.Click += new System.EventHandler(this.buttonDeleteMap_Click);
|
||||
//
|
||||
// buttonAddMap
|
||||
//
|
||||
this.buttonAddMap.Location = new System.Drawing.Point(6, 80);
|
||||
this.buttonAddMap.Name = "buttonAddMap";
|
||||
this.buttonAddMap.Size = new System.Drawing.Size(188, 23);
|
||||
this.buttonAddMap.TabIndex = 2;
|
||||
this.buttonAddMap.Text = " Добавить карту";
|
||||
this.buttonAddMap.UseVisualStyleBackColor = true;
|
||||
this.buttonAddMap.Click += new System.EventHandler(this.buttonAddMap_Click);
|
||||
//
|
||||
// textBoxNewMapName
|
||||
//
|
||||
this.textBoxNewMapName.Location = new System.Drawing.Point(6, 22);
|
||||
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
||||
this.textBoxNewMapName.Size = new System.Drawing.Size(188, 23);
|
||||
this.textBoxNewMapName.TabIndex = 1;
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||
"Простая карта",
|
||||
"Поле"});
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 52);
|
||||
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(188, 23);
|
||||
this.comboBoxSelectorMap.TabIndex = 0;
|
||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::Tractors.Properties.Resources.RkYIe2_6DuQ;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(126, 435);
|
||||
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonRight.TabIndex = 10;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::Tractors.Properties.Resources.MbV2DYU_nPM;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(91, 435);
|
||||
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonDown.TabIndex = 9;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::Tractors.Properties.Resources.Hhxt4dLqV5g;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(56, 435);
|
||||
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonLeft.TabIndex = 8;
|
||||
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 = global::Tractors.Properties.Resources._2EdzyM4iEKw;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(91, 405);
|
||||
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonUp.Location = new System.Drawing.Point(55, 426);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonUp.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonUp.TabIndex = 7;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::Tractors.Properties.Resources.Hhxt4dLqV5g;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(15, 466);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonLeft.TabIndex = 8;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::Tractors.Properties.Resources.MbV2DYU_nPM;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(55, 466);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonDown.TabIndex = 9;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::Tractors.Properties.Resources.RkYIe2_6DuQ;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(95, 466);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonRight.TabIndex = 10;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonShowOnMap
|
||||
//
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(7, 380);
|
||||
this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(6, 281);
|
||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(207, 22);
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(193, 29);
|
||||
this.buttonShowOnMap.TabIndex = 5;
|
||||
this.buttonShowOnMap.Text = "Посмотреть карту";
|
||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||
@ -203,10 +126,9 @@ namespace WinFormsApp1
|
||||
//
|
||||
// buttonShowStorage
|
||||
//
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(7, 353);
|
||||
this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(6, 246);
|
||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(207, 22);
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(193, 29);
|
||||
this.buttonShowStorage.TabIndex = 4;
|
||||
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
||||
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
||||
@ -214,18 +136,16 @@ namespace WinFormsApp1
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(7, 298);
|
||||
this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 122);
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(207, 23);
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(100, 27);
|
||||
this.maskedTextBoxPosition.TabIndex = 11;
|
||||
//
|
||||
// buttonRemoveTraktor
|
||||
//
|
||||
this.buttonRemoveTraktor.Location = new System.Drawing.Point(7, 325);
|
||||
this.buttonRemoveTraktor.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonRemoveTraktor.Location = new System.Drawing.Point(6, 155);
|
||||
this.buttonRemoveTraktor.Name = "buttonRemoveTraktor";
|
||||
this.buttonRemoveTraktor.Size = new System.Drawing.Size(207, 24);
|
||||
this.buttonRemoveTraktor.Size = new System.Drawing.Size(151, 32);
|
||||
this.buttonRemoveTraktor.TabIndex = 2;
|
||||
this.buttonRemoveTraktor.Text = "Удалить трактор";
|
||||
this.buttonRemoveTraktor.UseVisualStyleBackColor = true;
|
||||
@ -233,39 +153,46 @@ namespace WinFormsApp1
|
||||
//
|
||||
// buttonAddTraktor
|
||||
//
|
||||
this.buttonAddTraktor.Location = new System.Drawing.Point(7, 269);
|
||||
this.buttonAddTraktor.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonAddTraktor.Location = new System.Drawing.Point(6, 83);
|
||||
this.buttonAddTraktor.Name = "buttonAddTraktor";
|
||||
this.buttonAddTraktor.Size = new System.Drawing.Size(207, 25);
|
||||
this.buttonAddTraktor.Size = new System.Drawing.Size(151, 33);
|
||||
this.buttonAddTraktor.TabIndex = 1;
|
||||
this.buttonAddTraktor.Text = "Добавить трактор";
|
||||
this.buttonAddTraktor.UseVisualStyleBackColor = true;
|
||||
this.buttonAddTraktor.Click += new System.EventHandler(this.ButtonAddTraktor_Click);
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||
"Простая карта",
|
||||
"Поле"});
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 26);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(151, 28);
|
||||
this.comboBoxSelectorMap.TabIndex = 0;
|
||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBox.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(596, 476);
|
||||
this.pictureBox.Size = new System.Drawing.Size(832, 518);
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// FormMapWithSetTraktor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(815, 476);
|
||||
this.ClientSize = new System.Drawing.Size(1082, 518);
|
||||
this.Controls.Add(this.pictureBox);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormMapWithSetTraktor";
|
||||
this.Text = "Автобус";
|
||||
this.Text = "Трактор";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBoxMaps.ResumeLayout(false);
|
||||
this.groupBoxMaps.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
@ -285,10 +212,5 @@ namespace WinFormsApp1
|
||||
private Button buttonDown;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
private GroupBox groupBoxMaps;
|
||||
private Button buttonDeleteMap;
|
||||
private Button buttonAddMap;
|
||||
private TextBox textBoxNewMapName;
|
||||
private ListBox listBoxMaps;
|
||||
}
|
||||
}
|
@ -15,46 +15,17 @@ namespace WinFormsApp1
|
||||
{
|
||||
private MapWithSetTraktorGeneric<DrawningObjectTractor, AbstractMap> _mapTraktorCollectionGeneric;
|
||||
|
||||
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||
{
|
||||
{"Простая карта", new SimpleMap() },
|
||||
{"Поле", new FieldMap() }
|
||||
};
|
||||
|
||||
private readonly MapsCollection _mapsCollection;
|
||||
//DrawingBus SelectedBus { get; private set; }
|
||||
|
||||
public FormMapWithSetTraktor()
|
||||
{
|
||||
InitializeComponent();
|
||||
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||
comboBoxSelectorMap.Items.Clear();
|
||||
foreach (var item in _mapsDict)
|
||||
{
|
||||
comboBoxSelectorMap.Items.Add(item.Key);
|
||||
}
|
||||
AbstractMap map = new SimpleMap();
|
||||
_mapTraktorCollectionGeneric = new MapWithSetTraktorGeneric<DrawningObjectTractor, AbstractMap>(
|
||||
pictureBox.Width, pictureBox.Height, map);
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
AbstractMap map = null;
|
||||
@ -81,7 +52,7 @@ namespace WinFormsApp1
|
||||
|
||||
private void ButtonAddTraktor_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
if (_mapTraktorCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -96,10 +67,10 @@ namespace WinFormsApp1
|
||||
|
||||
DrawningObjectTractor bus = new(form.SelectedTractor);
|
||||
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + bus != -1)
|
||||
if (_mapTraktorCollectionGeneric + bus != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
pictureBox.Image = _mapTraktorCollectionGeneric.ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -110,29 +81,21 @@ namespace WinFormsApp1
|
||||
|
||||
private void ButtonRemoveTraktor_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||
if (_mapTraktorCollectionGeneric - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
pictureBox.Image = _mapTraktorCollectionGeneric.ShowSet();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
@ -145,7 +108,7 @@ namespace WinFormsApp1
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
pictureBox.Image = _mapTraktorCollectionGeneric.ShowSet();
|
||||
}
|
||||
|
||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||
@ -154,7 +117,7 @@ namespace WinFormsApp1
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||
pictureBox.Image = _mapTraktorCollectionGeneric.ShowOnMap();
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
@ -183,40 +146,5 @@ namespace WinFormsApp1
|
||||
}
|
||||
pictureBox.Image = _mapTraktorCollectionGeneric.MoveObject(dir);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
private void listBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
|
||||
private void buttonDeleteMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
ReloadMaps();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,9 +50,13 @@ namespace WinFormsApp1
|
||||
public Bitmap ShowOnMap()
|
||||
{
|
||||
Shaking();
|
||||
foreach (var traktor in _setTraktors.GetTraktor())
|
||||
for (int i = 0; i < _setTraktors.Count; i++)
|
||||
{
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, traktor);
|
||||
var bus = _setTraktors.Get(i);
|
||||
if (bus != null)
|
||||
{
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, bus);
|
||||
}
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
@ -71,11 +75,11 @@ namespace WinFormsApp1
|
||||
int j = _setTraktors.Count - 1;
|
||||
for (int i = 0; i < _setTraktors.Count; i++)
|
||||
{
|
||||
if (_setTraktors[i] == null)
|
||||
if (_setTraktors.Get(i) == null)
|
||||
{
|
||||
for (; j > i; j--)
|
||||
{
|
||||
var bus = _setTraktors[j];
|
||||
var bus = _setTraktors.Get(j);
|
||||
if (bus != null)
|
||||
{
|
||||
_setTraktors.Insert(bus, i);
|
||||
@ -109,31 +113,31 @@ namespace WinFormsApp1
|
||||
|
||||
private void DrawTraktors(Graphics g)
|
||||
{
|
||||
|
||||
int widthEl = _pictureWidth / _placeSizeWidth;
|
||||
int heightEl = _pictureHeight / _placeSizeHeight;
|
||||
|
||||
int curWidth = 0;
|
||||
int curHeight = 0;
|
||||
|
||||
int currentWidth = _pictureWidth / _placeSizeWidth - 1;
|
||||
int currentHeight = _pictureHeight / _placeSizeHeight - 1;
|
||||
|
||||
foreach (var traktor in _setTraktors.GetTraktor())
|
||||
for (int i = _setTraktors.Count; i >= 0; i--)
|
||||
{
|
||||
traktor?.SetObject(
|
||||
currentWidth * _placeSizeWidth + 50, currentHeight * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
|
||||
traktor?.DrawningObject(g);
|
||||
_setTraktors.Get(i)?.SetObject(
|
||||
_pictureWidth - _placeSizeWidth * curWidth - 60,
|
||||
curHeight * _placeSizeHeight + 30, _pictureWidth, _pictureHeight);
|
||||
_setTraktors.Get(i)?.DrawningObject(g);
|
||||
|
||||
if (currentWidth > 0)
|
||||
{
|
||||
currentWidth -= 1;
|
||||
}
|
||||
if (curWidth < widthEl)
|
||||
curWidth++;
|
||||
else
|
||||
{
|
||||
if (currentHeight > 0)
|
||||
{
|
||||
currentHeight -= 1;
|
||||
currentWidth = _pictureWidth / _placeSizeWidth - 1;
|
||||
}
|
||||
else return;
|
||||
curWidth = 1;
|
||||
curHeight++;
|
||||
}
|
||||
if (curHeight > heightEl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsApp1
|
||||
{
|
||||
internal class MapsCollection
|
||||
{
|
||||
readonly Dictionary<string, MapWithSetTraktorGeneric<DrawningObjectTractor, AbstractMap>> _mapStorages;
|
||||
|
||||
public List<string> Keys => _mapStorages.Keys.ToList();
|
||||
|
||||
private readonly int _pictureWidth;
|
||||
|
||||
private readonly int _pictureHeight;
|
||||
|
||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_mapStorages = new Dictionary<string, MapWithSetTraktorGeneric<DrawningObjectTractor, AbstractMap>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
|
||||
public void AddMap(string name, AbstractMap map)
|
||||
{
|
||||
if (_mapStorages.ContainsKey(name)) return; //уникальное имя
|
||||
else
|
||||
{
|
||||
_mapStorages.Add(name, new MapWithSetTraktorGeneric<DrawningObjectTractor, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
}
|
||||
}
|
||||
|
||||
public void DelMap(string name)
|
||||
{
|
||||
if (_mapStorages.ContainsKey(name))
|
||||
{
|
||||
_mapStorages.Remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
public MapWithSetTraktorGeneric<DrawningObjectTractor, AbstractMap> this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
_mapStorages.TryGetValue(ind, out var MapWithSetDoubleDeckerBusGeneric);
|
||||
return MapWithSetDoubleDeckerBusGeneric;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -9,15 +9,13 @@ namespace WinFormsApp1
|
||||
internal class SetTraktorGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly List<T> _places;
|
||||
public int Count => _places.Count;
|
||||
private readonly int _maxCount;
|
||||
private readonly T[] _places;
|
||||
public int Count => _places.Length;
|
||||
private int TractorPlaces = 0;
|
||||
|
||||
public SetTraktorGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T>(); ;
|
||||
_places = new T[count];
|
||||
}
|
||||
|
||||
public int Insert(T tractor)
|
||||
@ -27,61 +25,38 @@ namespace WinFormsApp1
|
||||
|
||||
public int Insert(T tractor, int position)
|
||||
{
|
||||
if (position < 0 && position > _maxCount)
|
||||
if (position < 0 || position >= _places.Length || TractorPlaces == _places.Length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
TractorPlaces++;
|
||||
while (_places[position] != null)
|
||||
{
|
||||
_places.Insert(position, tractor);
|
||||
return position;
|
||||
for (int i = _places.Length - 1; i > 0; --i)
|
||||
{
|
||||
if (_places[i] == null && _places[i - 1] != null)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
_places[i - 1] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
_places[position] = tractor;
|
||||
return position;
|
||||
}
|
||||
|
||||
public T Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= _maxCount)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var result = _places[position];
|
||||
_places.RemoveAt(position);
|
||||
return result;
|
||||
if (position < 0 || position >= _places.Length) return null;
|
||||
T savedTractor = _places[position];
|
||||
_places[position] = null;
|
||||
return savedTractor;
|
||||
}
|
||||
|
||||
|
||||
public T this[int position]
|
||||
public T Get(int position)
|
||||
{
|
||||
get
|
||||
{
|
||||
if (position >= 0 && position < _maxCount && position < Count)
|
||||
{
|
||||
return _places[position];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
Insert(value, position);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetTraktor()
|
||||
{
|
||||
foreach (var traktor in _places)
|
||||
{
|
||||
if (traktor != null)
|
||||
{
|
||||
yield return traktor;
|
||||
}
|
||||
else
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
if (position < 0 || position >= _places.Length) return null;
|
||||
return _places[position];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user