From 01ad994227c2544d9f65af4c96b03d23ddf491df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Sun, 30 Oct 2022 20:35:08 +0400 Subject: [PATCH 1/7] =?UTF-8?q?=D0=AD=D1=82=D0=B0=D0=BF=201.=20=D0=A1?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B0=20=D0=BC=D0=B0=D1=81=D1=81=D0=B8=D0=B2?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B0=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bus/Bus/MapWithSetDoubleDeckerBusGeneric.cs | 20 +++++----- Bus/Bus/SetDoubleDeckerBusGeneric.cs | 42 ++++++++++++++++----- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/Bus/Bus/MapWithSetDoubleDeckerBusGeneric.cs b/Bus/Bus/MapWithSetDoubleDeckerBusGeneric.cs index 83cb173..f8d3444 100644 --- a/Bus/Bus/MapWithSetDoubleDeckerBusGeneric.cs +++ b/Bus/Bus/MapWithSetDoubleDeckerBusGeneric.cs @@ -49,13 +49,11 @@ namespace Bus public Bitmap ShowOnMap() { Shaking(); - for (int i = 0; i< _setBus.Count; i++) + foreach (var bus in _setBus.GetBuses()) { - var bus = _setBus.Get(i); - if (bus != null) - { - return _map.CreateMap(_pictureWidth, _pictureHeight, bus); - } + + return _map.CreateMap(_pictureWidth, _pictureHeight, bus); + } return new(_pictureWidth, _pictureHeight); } @@ -74,11 +72,11 @@ namespace Bus int j = _setBus.Count - 1; for (int i = 0; i<_setBus.Count;i++) { - if(_setBus.Get(i) == null) + if(_setBus[i] == null) { for(; j > i; j--) { - var bus = _setBus.Get(j); + var bus = _setBus[j]; if (bus != null) { _setBus.Insert(bus, i); @@ -125,12 +123,12 @@ namespace Bus int currentWidth = width - 1; int currentHeight = 0; - for (int i = 0; i < _setBus.Count; i++) + foreach (var bus in _setBus.GetBuses()) { - _setBus.Get(i)?.SetObject(currentWidth * _placeSizeWidth, + bus?.SetObject(currentWidth * _placeSizeWidth, currentHeight * _placeSizeHeight, _pictureWidth, _pictureHeight); - _setBus.Get(i)?.DrawingObject(g); + bus?.DrawingObject(g); if (currentWidth > 0) currentWidth--; diff --git a/Bus/Bus/SetDoubleDeckerBusGeneric.cs b/Bus/Bus/SetDoubleDeckerBusGeneric.cs index 70c05f7..e3f7fa3 100644 --- a/Bus/Bus/SetDoubleDeckerBusGeneric.cs +++ b/Bus/Bus/SetDoubleDeckerBusGeneric.cs @@ -9,13 +9,16 @@ namespace Bus internal class SetDoubleDeckerBusGeneric where T : class { - private readonly T[] _places; - public int Count => _places.Length; + private readonly List _places; + public int Count => _places.Count; private int BusPlaces = 0; + private readonly int _maxCount; + public SetDoubleDeckerBusGeneric(int count) { - _places = new T[count]; + _maxCount = count; + _places = new List(); } public int Insert(T bus) @@ -25,14 +28,14 @@ namespace Bus public int Insert(T bus, int position) { - if (position < 0 || position >= _places.Length || BusPlaces == _places.Length) + if (position < 0 || position >= _maxCount || BusPlaces == _maxCount) { return -1; } BusPlaces++; while (_places[position] != null) { - for (int i = _places.Length - 1; i > 0; --i) + for (int i = _places.Count - 1; i > 0; --i) { if (_places[i] == null && _places[i - 1] != null) { @@ -47,16 +50,37 @@ namespace Bus public T Remove(int position) { - if (position < 0 || position >= _places.Length) return null; + if (position < 0 || position >= _maxCount) return null; T savedBus = _places[position]; _places[position] = null; return savedBus; } - public T Get(int position) + public T this[int position] { - if (position < 0 || position >= _places.Length) return null; - return _places[position]; + get + { + return _places[position]; + } + set + { + // todo + } + } + + public IEnumerable GetBuses() + { + foreach (var bus in _places) + { + if (bus != null) + { + yield return bus; + } + else + { + yield break; + } + } } } } -- 2.25.1 From 998be1be710d5cb3698e49aa7ae5f9d33fb0714e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Sun, 30 Oct 2022 20:51:44 +0400 Subject: [PATCH 2/7] =?UTF-8?q?=D0=AD=D1=82=D0=B0=D0=BF=202.=20=D0=9A?= =?UTF-8?q?=D0=BB=D0=B0=D1=81=D1=81=20MapsCollection.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bus/Bus/MapsCollection.cs | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Bus/Bus/MapsCollection.cs diff --git a/Bus/Bus/MapsCollection.cs b/Bus/Bus/MapsCollection.cs new file mode 100644 index 0000000..d98fde3 --- /dev/null +++ b/Bus/Bus/MapsCollection.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Bus +{ + internal class MapsCollection + { + readonly Dictionary> _mapStorages; + + public List Keys => _mapStorages.Keys.ToList(); + + private readonly int _pictureWidth; + + private readonly int _pictureHeight; + + public MapsCollection(int pictureWidth, int pictureHeight) + { + _mapStorages = new Dictionary>(); + _pictureWidth = pictureWidth; + _pictureHeight = pictureHeight; + } + + public void AddMap(string name, AbstractMap map) + { + // TODO Прописать логику для добавления + } + + public void DelMap(string name) + { + // TODO Прописать логику для удаления + } + + public MapWithSetDoubleDeckerBusGeneric this[string ind] + { + get + { + // TODO Продумать логику получения объекта + return null; + } + + } + } +} -- 2.25.1 From 36451baa69c437cd5b53888732fa3227428417ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Sun, 30 Oct 2022 21:36:14 +0400 Subject: [PATCH 3/7] =?UTF-8?q?=D0=AD=D1=82=D0=B0=D0=BF=203.=20=D0=A4?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormMapWithSetDoubleDeckerBus.Designer.cs | 100 ++++++++++++++---- Bus/Bus/FormMapWithSetDoubleDeckerBus.cs | 77 ++++++++++++-- 2 files changed, 153 insertions(+), 24 deletions(-) diff --git a/Bus/Bus/FormMapWithSetDoubleDeckerBus.Designer.cs b/Bus/Bus/FormMapWithSetDoubleDeckerBus.Designer.cs index 4a7771e..3cc52e0 100644 --- a/Bus/Bus/FormMapWithSetDoubleDeckerBus.Designer.cs +++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.Designer.cs @@ -40,8 +40,14 @@ this.buttonAddBus = new System.Windows.Forms.Button(); this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); this.pictureBox = new System.Windows.Forms.PictureBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.buttonDeleteMap = new System.Windows.Forms.Button(); + this.listBoxMaps = new System.Windows.Forms.ListBox(); + this.buttonAddMap = new System.Windows.Forms.Button(); + this.maskedTextBox1 = new System.Windows.Forms.MaskedTextBox(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox1 @@ -55,11 +61,10 @@ this.groupBox1.Controls.Add(this.maskedTextBoxPosition); this.groupBox1.Controls.Add(this.buttonRemoveBus); this.groupBox1.Controls.Add(this.buttonAddBus); - this.groupBox1.Controls.Add(this.comboBoxSelectorMap); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right; - this.groupBox1.Location = new System.Drawing.Point(550, 0); + this.groupBox1.Location = new System.Drawing.Point(598, 0); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(250, 450); + this.groupBox1.Size = new System.Drawing.Size(250, 618); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Инструменты"; @@ -69,7 +74,7 @@ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::Bus.Properties.Resources.Frame_4; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(95, 398); + this.buttonRight.Location = new System.Drawing.Point(95, 566); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(40, 40); this.buttonRight.TabIndex = 10; @@ -81,7 +86,7 @@ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::Bus.Properties.Resources.Frame_5; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(55, 398); + this.buttonDown.Location = new System.Drawing.Point(55, 566); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(40, 40); this.buttonDown.TabIndex = 9; @@ -93,7 +98,7 @@ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::Bus.Properties.Resources.Frame_6; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(15, 398); + this.buttonLeft.Location = new System.Drawing.Point(15, 566); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(40, 40); this.buttonLeft.TabIndex = 8; @@ -105,7 +110,7 @@ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.BackgroundImage = global::Bus.Properties.Resources.Frame_3; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(55, 358); + this.buttonUp.Location = new System.Drawing.Point(55, 526); this.buttonUp.Name = "buttonUp"; this.buttonUp.Size = new System.Drawing.Size(40, 40); this.buttonUp.TabIndex = 7; @@ -114,7 +119,7 @@ // // buttonShowOnMap // - this.buttonShowOnMap.Location = new System.Drawing.Point(6, 281); + this.buttonShowOnMap.Location = new System.Drawing.Point(15, 426); this.buttonShowOnMap.Name = "buttonShowOnMap"; this.buttonShowOnMap.Size = new System.Drawing.Size(193, 29); this.buttonShowOnMap.TabIndex = 5; @@ -124,7 +129,7 @@ // // buttonShowStorage // - this.buttonShowStorage.Location = new System.Drawing.Point(6, 246); + this.buttonShowStorage.Location = new System.Drawing.Point(15, 391); this.buttonShowStorage.Name = "buttonShowStorage"; this.buttonShowStorage.Size = new System.Drawing.Size(193, 29); this.buttonShowStorage.TabIndex = 4; @@ -134,16 +139,16 @@ // // maskedTextBoxPosition // - this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 122); + this.maskedTextBoxPosition.Location = new System.Drawing.Point(15, 320); this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; this.maskedTextBoxPosition.Size = new System.Drawing.Size(100, 27); this.maskedTextBoxPosition.TabIndex = 11; // // buttonRemoveBus // - this.buttonRemoveBus.Location = new System.Drawing.Point(6, 155); + this.buttonRemoveBus.Location = new System.Drawing.Point(15, 353); this.buttonRemoveBus.Name = "buttonRemoveBus"; - this.buttonRemoveBus.Size = new System.Drawing.Size(151, 32); + this.buttonRemoveBus.Size = new System.Drawing.Size(129, 32); this.buttonRemoveBus.TabIndex = 2; this.buttonRemoveBus.Text = "Удалить автобус"; this.buttonRemoveBus.UseVisualStyleBackColor = true; @@ -151,9 +156,9 @@ // // buttonAddBus // - this.buttonAddBus.Location = new System.Drawing.Point(6, 83); + this.buttonAddBus.Location = new System.Drawing.Point(15, 281); this.buttonAddBus.Name = "buttonAddBus"; - this.buttonAddBus.Size = new System.Drawing.Size(151, 33); + this.buttonAddBus.Size = new System.Drawing.Size(129, 33); this.buttonAddBus.TabIndex = 1; this.buttonAddBus.Text = "Добавить автобус"; this.buttonAddBus.UseVisualStyleBackColor = true; @@ -165,9 +170,9 @@ this.comboBoxSelectorMap.Items.AddRange(new object[] { "Простая карта", "Водная карта"}); - this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 26); + this.comboBoxSelectorMap.Location = new System.Drawing.Point(8, 59); this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; - this.comboBoxSelectorMap.Size = new System.Drawing.Size(151, 28); + this.comboBoxSelectorMap.Size = new System.Drawing.Size(125, 28); this.comboBoxSelectorMap.TabIndex = 0; this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); // @@ -176,15 +181,67 @@ this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox.Location = new System.Drawing.Point(0, 0); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(550, 450); + this.pictureBox.Size = new System.Drawing.Size(598, 618); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // + // groupBox2 + // + this.groupBox2.Controls.Add(this.buttonDeleteMap); + this.groupBox2.Controls.Add(this.listBoxMaps); + this.groupBox2.Controls.Add(this.buttonAddMap); + this.groupBox2.Controls.Add(this.maskedTextBox1); + this.groupBox2.Controls.Add(this.comboBoxSelectorMap); + this.groupBox2.Location = new System.Drawing.Point(605, 26); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(238, 243); + this.groupBox2.TabIndex = 12; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Карты"; + // + // buttonDeleteMap + // + this.buttonDeleteMap.Location = new System.Drawing.Point(8, 203); + this.buttonDeleteMap.Name = "buttonDeleteMap"; + this.buttonDeleteMap.Size = new System.Drawing.Size(193, 34); + 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 = 20; + this.listBoxMaps.Location = new System.Drawing.Point(8, 133); + this.listBoxMaps.Name = "listBoxMaps"; + this.listBoxMaps.Size = new System.Drawing.Size(150, 64); + this.listBoxMaps.TabIndex = 3; + this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged); + // + // buttonAddMap + // + this.buttonAddMap.Location = new System.Drawing.Point(8, 93); + this.buttonAddMap.Name = "buttonAddMap"; + this.buttonAddMap.Size = new System.Drawing.Size(193, 34); + this.buttonAddMap.TabIndex = 2; + this.buttonAddMap.Text = "Добавить карту"; + this.buttonAddMap.UseVisualStyleBackColor = true; + this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click); + // + // maskedTextBox1 + // + this.maskedTextBox1.Location = new System.Drawing.Point(8, 26); + this.maskedTextBox1.Name = "maskedTextBox1"; + this.maskedTextBox1.Size = new System.Drawing.Size(125, 27); + this.maskedTextBox1.TabIndex = 1; + // // FormMapWithSetDoubleDeckerBus // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(848, 618); + this.Controls.Add(this.groupBox2); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBox1); this.Name = "FormMapWithSetDoubleDeckerBus"; @@ -192,6 +249,8 @@ this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); this.ResumeLayout(false); } @@ -210,5 +269,10 @@ private Button buttonDown; private Button buttonLeft; private Button buttonUp; + private GroupBox groupBox2; + private Button buttonDeleteMap; + private ListBox listBoxMaps; + private Button buttonAddMap; + private MaskedTextBox maskedTextBox1; } } \ No newline at end of file diff --git a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs index f10d972..841f593 100644 --- a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs +++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs @@ -14,17 +14,45 @@ namespace Bus { private MapWithSetDoubleDeckerBusGeneric _mapBusCollectionGeneric; - //DrawingBus SelectedBus { get; private set; } + private readonly Dictionary _mapsDict = new() + { + {"Простая карта", new SimpleMap() } + }; + + private readonly MapsCollection _mapsCollection; public FormMapWithSetDoubleDeckerBus() { InitializeComponent(); - AbstractMap map = new SimpleMap(); - _mapBusCollectionGeneric = new MapWithSetDoubleDeckerBusGeneric( - pictureBox.Width, pictureBox.Height, map); + _mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height); + comboBoxSelectorMap.Items.Clear(); + foreach (var item in _mapsDict) + { + comboBoxSelectorMap.Items.Add(item.Key); + } } - + + 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; @@ -144,6 +172,43 @@ namespace Bus break; } pictureBox.Image = _mapBusCollectionGeneric.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(); + } + } + + } } -- 2.25.1 From 4498a36c12db02798c8215901f8d5f1e4d487102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Tue, 1 Nov 2022 23:32:20 +0400 Subject: [PATCH 4/7] =?UTF-8?q?=D0=AD=D1=82=D0=B0=D0=BF=203.1=20-=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormMapWithSetDoubleDeckerBus.Designer.cs | 16 +++---- Bus/Bus/FormMapWithSetDoubleDeckerBus.cs | 7 +-- Bus/Bus/MapsCollection.cs | 14 +++++- Bus/Bus/SetDoubleDeckerBusGeneric.cs | 43 ++++++++++--------- 4 files changed, 47 insertions(+), 33 deletions(-) diff --git a/Bus/Bus/FormMapWithSetDoubleDeckerBus.Designer.cs b/Bus/Bus/FormMapWithSetDoubleDeckerBus.Designer.cs index 3cc52e0..a4dad44 100644 --- a/Bus/Bus/FormMapWithSetDoubleDeckerBus.Designer.cs +++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.Designer.cs @@ -44,7 +44,7 @@ this.buttonDeleteMap = new System.Windows.Forms.Button(); this.listBoxMaps = new System.Windows.Forms.ListBox(); this.buttonAddMap = new System.Windows.Forms.Button(); - this.maskedTextBox1 = new System.Windows.Forms.MaskedTextBox(); + this.textBoxNewMapName = new System.Windows.Forms.TextBox(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.groupBox2.SuspendLayout(); @@ -187,10 +187,10 @@ // // groupBox2 // + this.groupBox2.Controls.Add(this.textBoxNewMapName); this.groupBox2.Controls.Add(this.buttonDeleteMap); this.groupBox2.Controls.Add(this.listBoxMaps); this.groupBox2.Controls.Add(this.buttonAddMap); - this.groupBox2.Controls.Add(this.maskedTextBox1); this.groupBox2.Controls.Add(this.comboBoxSelectorMap); this.groupBox2.Location = new System.Drawing.Point(605, 26); this.groupBox2.Name = "groupBox2"; @@ -229,12 +229,12 @@ this.buttonAddMap.UseVisualStyleBackColor = true; this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click); // - // maskedTextBox1 + // textBoxNewMapName // - this.maskedTextBox1.Location = new System.Drawing.Point(8, 26); - this.maskedTextBox1.Name = "maskedTextBox1"; - this.maskedTextBox1.Size = new System.Drawing.Size(125, 27); - this.maskedTextBox1.TabIndex = 1; + this.textBoxNewMapName.Location = new System.Drawing.Point(6, 26); + this.textBoxNewMapName.Name = "textBoxNewMapName"; + this.textBoxNewMapName.Size = new System.Drawing.Size(125, 27); + this.textBoxNewMapName.TabIndex = 5; // // FormMapWithSetDoubleDeckerBus // @@ -273,6 +273,6 @@ private Button buttonDeleteMap; private ListBox listBoxMaps; private Button buttonAddMap; - private MaskedTextBox maskedTextBox1; + private TextBox textBoxNewMapName; } } \ No newline at end of file diff --git a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs index 841f593..0150735 100644 --- a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs +++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs @@ -16,7 +16,8 @@ namespace Bus private readonly Dictionary _mapsDict = new() { - {"Простая карта", new SimpleMap() } + {"Простая карта", new SimpleMap() }, + {"Водная карта", new MyMap() }, }; private readonly MapsCollection _mapsCollection; @@ -135,7 +136,7 @@ namespace Bus { return; } - pictureBox.Image = _mapBusCollectionGeneric.ShowSet(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } private void ButtonShowOnMap_Click(object sender, EventArgs e) @@ -144,7 +145,7 @@ namespace Bus { return; } - pictureBox.Image = _mapBusCollectionGeneric.ShowOnMap(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap(); } private void ButtonMove_Click(object sender, EventArgs e) diff --git a/Bus/Bus/MapsCollection.cs b/Bus/Bus/MapsCollection.cs index d98fde3..a28b8e5 100644 --- a/Bus/Bus/MapsCollection.cs +++ b/Bus/Bus/MapsCollection.cs @@ -25,12 +25,21 @@ namespace Bus public void AddMap(string name, AbstractMap map) { - // TODO Прописать логику для добавления + if (_mapStorages.ContainsKey(name)) return; //уникальное имя + else + { + _mapStorages.Add(name, new MapWithSetDoubleDeckerBusGeneric(_pictureWidth, _pictureHeight, map)); + } } public void DelMap(string name) { // TODO Прописать логику для удаления + if (_mapStorages.ContainsKey(name)) + { + _mapStorages.Remove(name); + } + } public MapWithSetDoubleDeckerBusGeneric this[string ind] @@ -38,7 +47,8 @@ namespace Bus get { // TODO Продумать логику получения объекта - return null; + _mapStorages.TryGetValue(ind, out var MapWithSetDoubleDeckerBusGeneric); + return MapWithSetDoubleDeckerBusGeneric; } } diff --git a/Bus/Bus/SetDoubleDeckerBusGeneric.cs b/Bus/Bus/SetDoubleDeckerBusGeneric.cs index e3f7fa3..3551703 100644 --- a/Bus/Bus/SetDoubleDeckerBusGeneric.cs +++ b/Bus/Bus/SetDoubleDeckerBusGeneric.cs @@ -26,45 +26,48 @@ namespace Bus return Insert(bus, 0); } + private bool isCorrectPosition(int position) + { + return 0 <= position && position < _maxCount; + } + public int Insert(T bus, int position) { - if (position < 0 || position >= _maxCount || BusPlaces == _maxCount) + if (!isCorrectPosition(position)) { return -1; } - BusPlaces++; - while (_places[position] != null) - { - for (int i = _places.Count - 1; i > 0; --i) - { - if (_places[i] == null && _places[i - 1] != null) - { - _places[i] = _places[i - 1]; - _places[i - 1] = null; - } - } - } - _places[position] = bus; + _places.Insert(position, bus); return position; } public T Remove(int position) { - if (position < 0 || position >= _maxCount) return null; - T savedBus = _places[position]; - _places[position] = null; - return savedBus; + if (position < 0 || position >= _maxCount) + { + return null; + } + var result = _places[position]; + _places.RemoveAt(position); + return result; } public T this[int position] { get { - return _places[position]; + if (position >= 0 && position < _maxCount && position < Count) + { + return _places[position]; + } + else + { + return null; + } } set { - // todo + Insert(value, position); } } -- 2.25.1 From 9da228d7ecb8402ec507b15d9928ed55821c2087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Sun, 6 Nov 2022 12:23:24 +0400 Subject: [PATCH 5/7] 1234567890 --- Bus/Bus/FormBusConfig.Designer.cs | 294 ++++++++++++++++++++++++++++++ Bus/Bus/FormBusConfig.cs | 28 +++ Bus/Bus/FormBusConfig.resx | 60 ++++++ 3 files changed, 382 insertions(+) create mode 100644 Bus/Bus/FormBusConfig.Designer.cs create mode 100644 Bus/Bus/FormBusConfig.cs create mode 100644 Bus/Bus/FormBusConfig.resx diff --git a/Bus/Bus/FormBusConfig.Designer.cs b/Bus/Bus/FormBusConfig.Designer.cs new file mode 100644 index 0000000..7c4ff4d --- /dev/null +++ b/Bus/Bus/FormBusConfig.Designer.cs @@ -0,0 +1,294 @@ +namespace Bus +{ + partial class FormBusConfig + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxConfig = new System.Windows.Forms.GroupBox(); + //this.labelObject = new System.Windows.Forms.Label(); + this.labelSimpleObject = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.checkBox3 = new System.Windows.Forms.CheckBox(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.panelPurple = new System.Windows.Forms.Panel(); + this.panelYellow = new System.Windows.Forms.Panel(); + this.panelaBlack = new System.Windows.Forms.Panel(); + this.panelBlue = new System.Windows.Forms.Panel(); + this.panelCray = new System.Windows.Forms.Panel(); + this.panelWhite = new System.Windows.Forms.Panel(); + this.panelGreen = new System.Windows.Forms.Panel(); + this.panelPed = new System.Windows.Forms.Panel(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.groupBoxConfig.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // groupBoxConfig + // + /////////////this.groupBoxConfig.Controls.Add(this.labelObject); + this.groupBoxConfig.Controls.Add(this.labelSimpleObject); + this.groupBoxConfig.Controls.Add(this.groupBox1); + this.groupBoxConfig.Controls.Add(this.checkBox3); + this.groupBoxConfig.Controls.Add(this.checkBox2); + this.groupBoxConfig.Controls.Add(this.checkBox1); + this.groupBoxConfig.Controls.Add(this.numericUpDownWeight); + this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed); + this.groupBoxConfig.Controls.Add(this.label2); + this.groupBoxConfig.Controls.Add(this.label1); + this.groupBoxConfig.Location = new System.Drawing.Point(12, 12); + this.groupBoxConfig.Name = "groupBoxConfig"; + this.groupBoxConfig.Size = new System.Drawing.Size(581, 226); + this.groupBoxConfig.TabIndex = 0; + this.groupBoxConfig.TabStop = false; + this.groupBoxConfig.Text = "Параметры"; + // + // labelObject + // + /*this.labelObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelObject.Location = new System.Drawing.Point(452, 169); + this.labelObject.Name = "labelObject"; + this.labelObject.Size = new System.Drawing.Size(111, 40); + this.labelObject.TabIndex = 9; + this.labelObject.Text = "Продвинутый"; + this.labelObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;*/ + // + // labelSimpleObject + // + this.labelSimpleObject.Location = new System.Drawing.Point(0, 0); + this.labelSimpleObject.Name = "labelSimpleObject"; + this.labelSimpleObject.Size = new System.Drawing.Size(100, 23); + this.labelSimpleObject.TabIndex = 10; + // + // groupBox1 + // + this.groupBox1.Location = new System.Drawing.Point(0, 0); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(200, 100); + this.groupBox1.TabIndex = 11; + this.groupBox1.TabStop = false; + // + // checkBox3 + // + this.checkBox3.Location = new System.Drawing.Point(0, 0); + this.checkBox3.Name = "checkBox3"; + this.checkBox3.Size = new System.Drawing.Size(104, 24); + this.checkBox3.TabIndex = 12; + // + // checkBox2 + // + this.checkBox2.Location = new System.Drawing.Point(0, 0); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(104, 24); + this.checkBox2.TabIndex = 13; + // + // checkBox1 + // + this.checkBox1.Location = new System.Drawing.Point(0, 0); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(104, 24); + this.checkBox1.TabIndex = 14; + // + // numericUpDownWeight + // + this.numericUpDownWeight.Location = new System.Drawing.Point(0, 0); + this.numericUpDownWeight.Name = "numericUpDownWeight"; + this.numericUpDownWeight.Size = new System.Drawing.Size(120, 27); + this.numericUpDownWeight.TabIndex = 15; + // + // numericUpDownSpeed + // + this.numericUpDownSpeed.Location = new System.Drawing.Point(0, 0); + this.numericUpDownSpeed.Name = "numericUpDownSpeed"; + this.numericUpDownSpeed.Size = new System.Drawing.Size(120, 27); + this.numericUpDownSpeed.TabIndex = 16; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(0, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(100, 23); + this.label2.TabIndex = 17; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(100, 23); + this.label1.TabIndex = 18; + // + // panelPurple + // + this.panelPurple.Location = new System.Drawing.Point(0, 0); + this.panelPurple.Name = "panelPurple"; + this.panelPurple.Size = new System.Drawing.Size(200, 100); + this.panelPurple.TabIndex = 0; + // + // panelYellow + // + this.panelYellow.Location = new System.Drawing.Point(0, 0); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(200, 100); + this.panelYellow.TabIndex = 0; + // + // panelaBlack + // + this.panelaBlack.Location = new System.Drawing.Point(0, 0); + this.panelaBlack.Name = "panelaBlack"; + this.panelaBlack.Size = new System.Drawing.Size(200, 100); + this.panelaBlack.TabIndex = 0; + // + // panelBlue + // + this.panelBlue.Location = new System.Drawing.Point(0, 0); + this.panelBlue.Name = "panelBlue"; + this.panelBlue.Size = new System.Drawing.Size(200, 100); + this.panelBlue.TabIndex = 0; + // + // panelCray + // + this.panelCray.Location = new System.Drawing.Point(0, 0); + this.panelCray.Name = "panelCray"; + this.panelCray.Size = new System.Drawing.Size(200, 100); + this.panelCray.TabIndex = 0; + // + // panelWhite + // + this.panelWhite.Location = new System.Drawing.Point(0, 0); + this.panelWhite.Name = "panelWhite"; + this.panelWhite.Size = new System.Drawing.Size(200, 100); + this.panelWhite.TabIndex = 0; + // + // panelGreen + // + this.panelGreen.Location = new System.Drawing.Point(0, 0); + this.panelGreen.Name = "panelGreen"; + this.panelGreen.Size = new System.Drawing.Size(200, 100); + this.panelGreen.TabIndex = 0; + // + // panelPed + // + this.panelPed.Location = new System.Drawing.Point(0, 0); + this.panelPed.Name = "panelPed"; + this.panelPed.Size = new System.Drawing.Size(200, 100); + this.panelPed.TabIndex = 0; + // + // pictureBox1 + // + this.pictureBox1.Location = new System.Drawing.Point(0, 0); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(100, 50); + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + // + // panel1 + // + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(200, 100); + this.panel1.TabIndex = 0; + // + // label5 + // + this.label5.Location = new System.Drawing.Point(0, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(100, 23); + this.label5.TabIndex = 0; + // + // label6 + // + this.label6.Location = new System.Drawing.Point(0, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(100, 23); + this.label6.TabIndex = 0; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(0, 0); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 0; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(0, 0); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 0; + // + // FormBusConfig + // + this.ClientSize = new System.Drawing.Size(282, 253); + this.Name = "FormBusConfig"; + this.groupBoxConfig.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBoxConfig; + //private Label labelObject; + private Label labelSimpleObject; + private GroupBox groupBox1; + private Panel panelPurple; + private Panel panelYellow; + private Panel panelaBlack; + private Panel panelBlue; + private Panel panelCray; + private Panel panelWhite; + private Panel panelGreen; + private Panel panelPed; + private CheckBox checkBox3; + private CheckBox checkBox2; + private CheckBox checkBox1; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label label2; + private Label label1; + private PictureBox pictureBox1; + private Panel panel1; + private Label label5; + private Label label6; + private Button button1; + private Button button2; + } +} \ No newline at end of file diff --git a/Bus/Bus/FormBusConfig.cs b/Bus/Bus/FormBusConfig.cs new file mode 100644 index 0000000..ad5d6f9 --- /dev/null +++ b/Bus/Bus/FormBusConfig.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Bus +{ + public partial class FormBusConfig : Form + { + public FormBusConfig() + { + InitializeComponent(); + } + + /*private void LabelObject_MouseDown(object sender, MouseEventArgs e) + { + + }*/ + + + } +} + \ No newline at end of file diff --git a/Bus/Bus/FormBusConfig.resx b/Bus/Bus/FormBusConfig.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Bus/Bus/FormBusConfig.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file -- 2.25.1 From 773235a0b76e16b01edec6362b66fb427f5ccfbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Sun, 6 Nov 2022 12:32:31 +0400 Subject: [PATCH 6/7] =?UTF-8?q?=D1=80=D0=B0=D0=B7=D1=80=D0=B5=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=84=D0=BB=D0=B8=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bus/Bus/FormBusConfig.Designer.cs | 294 ------------------------------ Bus/Bus/FormBusConfig.cs | 28 --- Bus/Bus/FormBusConfig.resx | 60 ------ 3 files changed, 382 deletions(-) delete mode 100644 Bus/Bus/FormBusConfig.Designer.cs delete mode 100644 Bus/Bus/FormBusConfig.cs delete mode 100644 Bus/Bus/FormBusConfig.resx diff --git a/Bus/Bus/FormBusConfig.Designer.cs b/Bus/Bus/FormBusConfig.Designer.cs deleted file mode 100644 index 7c4ff4d..0000000 --- a/Bus/Bus/FormBusConfig.Designer.cs +++ /dev/null @@ -1,294 +0,0 @@ -namespace Bus -{ - partial class FormBusConfig - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBoxConfig = new System.Windows.Forms.GroupBox(); - //this.labelObject = new System.Windows.Forms.Label(); - this.labelSimpleObject = new System.Windows.Forms.Label(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.checkBox3 = new System.Windows.Forms.CheckBox(); - this.checkBox2 = new System.Windows.Forms.CheckBox(); - this.checkBox1 = new System.Windows.Forms.CheckBox(); - this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.panelPurple = new System.Windows.Forms.Panel(); - this.panelYellow = new System.Windows.Forms.Panel(); - this.panelaBlack = new System.Windows.Forms.Panel(); - this.panelBlue = new System.Windows.Forms.Panel(); - this.panelCray = new System.Windows.Forms.Panel(); - this.panelWhite = new System.Windows.Forms.Panel(); - this.panelGreen = new System.Windows.Forms.Panel(); - this.panelPed = new System.Windows.Forms.Panel(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.panel1 = new System.Windows.Forms.Panel(); - this.label5 = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.groupBoxConfig.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.SuspendLayout(); - // - // groupBoxConfig - // - /////////////this.groupBoxConfig.Controls.Add(this.labelObject); - this.groupBoxConfig.Controls.Add(this.labelSimpleObject); - this.groupBoxConfig.Controls.Add(this.groupBox1); - this.groupBoxConfig.Controls.Add(this.checkBox3); - this.groupBoxConfig.Controls.Add(this.checkBox2); - this.groupBoxConfig.Controls.Add(this.checkBox1); - this.groupBoxConfig.Controls.Add(this.numericUpDownWeight); - this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed); - this.groupBoxConfig.Controls.Add(this.label2); - this.groupBoxConfig.Controls.Add(this.label1); - this.groupBoxConfig.Location = new System.Drawing.Point(12, 12); - this.groupBoxConfig.Name = "groupBoxConfig"; - this.groupBoxConfig.Size = new System.Drawing.Size(581, 226); - this.groupBoxConfig.TabIndex = 0; - this.groupBoxConfig.TabStop = false; - this.groupBoxConfig.Text = "Параметры"; - // - // labelObject - // - /*this.labelObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelObject.Location = new System.Drawing.Point(452, 169); - this.labelObject.Name = "labelObject"; - this.labelObject.Size = new System.Drawing.Size(111, 40); - this.labelObject.TabIndex = 9; - this.labelObject.Text = "Продвинутый"; - this.labelObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;*/ - // - // labelSimpleObject - // - this.labelSimpleObject.Location = new System.Drawing.Point(0, 0); - this.labelSimpleObject.Name = "labelSimpleObject"; - this.labelSimpleObject.Size = new System.Drawing.Size(100, 23); - this.labelSimpleObject.TabIndex = 10; - // - // groupBox1 - // - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(200, 100); - this.groupBox1.TabIndex = 11; - this.groupBox1.TabStop = false; - // - // checkBox3 - // - this.checkBox3.Location = new System.Drawing.Point(0, 0); - this.checkBox3.Name = "checkBox3"; - this.checkBox3.Size = new System.Drawing.Size(104, 24); - this.checkBox3.TabIndex = 12; - // - // checkBox2 - // - this.checkBox2.Location = new System.Drawing.Point(0, 0); - this.checkBox2.Name = "checkBox2"; - this.checkBox2.Size = new System.Drawing.Size(104, 24); - this.checkBox2.TabIndex = 13; - // - // checkBox1 - // - this.checkBox1.Location = new System.Drawing.Point(0, 0); - this.checkBox1.Name = "checkBox1"; - this.checkBox1.Size = new System.Drawing.Size(104, 24); - this.checkBox1.TabIndex = 14; - // - // numericUpDownWeight - // - this.numericUpDownWeight.Location = new System.Drawing.Point(0, 0); - this.numericUpDownWeight.Name = "numericUpDownWeight"; - this.numericUpDownWeight.Size = new System.Drawing.Size(120, 27); - this.numericUpDownWeight.TabIndex = 15; - // - // numericUpDownSpeed - // - this.numericUpDownSpeed.Location = new System.Drawing.Point(0, 0); - this.numericUpDownSpeed.Name = "numericUpDownSpeed"; - this.numericUpDownSpeed.Size = new System.Drawing.Size(120, 27); - this.numericUpDownSpeed.TabIndex = 16; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(0, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(100, 23); - this.label2.TabIndex = 17; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(0, 0); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(100, 23); - this.label1.TabIndex = 18; - // - // panelPurple - // - this.panelPurple.Location = new System.Drawing.Point(0, 0); - this.panelPurple.Name = "panelPurple"; - this.panelPurple.Size = new System.Drawing.Size(200, 100); - this.panelPurple.TabIndex = 0; - // - // panelYellow - // - this.panelYellow.Location = new System.Drawing.Point(0, 0); - this.panelYellow.Name = "panelYellow"; - this.panelYellow.Size = new System.Drawing.Size(200, 100); - this.panelYellow.TabIndex = 0; - // - // panelaBlack - // - this.panelaBlack.Location = new System.Drawing.Point(0, 0); - this.panelaBlack.Name = "panelaBlack"; - this.panelaBlack.Size = new System.Drawing.Size(200, 100); - this.panelaBlack.TabIndex = 0; - // - // panelBlue - // - this.panelBlue.Location = new System.Drawing.Point(0, 0); - this.panelBlue.Name = "panelBlue"; - this.panelBlue.Size = new System.Drawing.Size(200, 100); - this.panelBlue.TabIndex = 0; - // - // panelCray - // - this.panelCray.Location = new System.Drawing.Point(0, 0); - this.panelCray.Name = "panelCray"; - this.panelCray.Size = new System.Drawing.Size(200, 100); - this.panelCray.TabIndex = 0; - // - // panelWhite - // - this.panelWhite.Location = new System.Drawing.Point(0, 0); - this.panelWhite.Name = "panelWhite"; - this.panelWhite.Size = new System.Drawing.Size(200, 100); - this.panelWhite.TabIndex = 0; - // - // panelGreen - // - this.panelGreen.Location = new System.Drawing.Point(0, 0); - this.panelGreen.Name = "panelGreen"; - this.panelGreen.Size = new System.Drawing.Size(200, 100); - this.panelGreen.TabIndex = 0; - // - // panelPed - // - this.panelPed.Location = new System.Drawing.Point(0, 0); - this.panelPed.Name = "panelPed"; - this.panelPed.Size = new System.Drawing.Size(200, 100); - this.panelPed.TabIndex = 0; - // - // pictureBox1 - // - this.pictureBox1.Location = new System.Drawing.Point(0, 0); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(100, 50); - this.pictureBox1.TabIndex = 0; - this.pictureBox1.TabStop = false; - // - // panel1 - // - this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(200, 100); - this.panel1.TabIndex = 0; - // - // label5 - // - this.label5.Location = new System.Drawing.Point(0, 0); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(100, 23); - this.label5.TabIndex = 0; - // - // label6 - // - this.label6.Location = new System.Drawing.Point(0, 0); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(100, 23); - this.label6.TabIndex = 0; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(0, 0); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 0; - // - // button2 - // - this.button2.Location = new System.Drawing.Point(0, 0); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(75, 23); - this.button2.TabIndex = 0; - // - // FormBusConfig - // - this.ClientSize = new System.Drawing.Size(282, 253); - this.Name = "FormBusConfig"; - this.groupBoxConfig.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private GroupBox groupBoxConfig; - //private Label labelObject; - private Label labelSimpleObject; - private GroupBox groupBox1; - private Panel panelPurple; - private Panel panelYellow; - private Panel panelaBlack; - private Panel panelBlue; - private Panel panelCray; - private Panel panelWhite; - private Panel panelGreen; - private Panel panelPed; - private CheckBox checkBox3; - private CheckBox checkBox2; - private CheckBox checkBox1; - private NumericUpDown numericUpDownWeight; - private NumericUpDown numericUpDownSpeed; - private Label label2; - private Label label1; - private PictureBox pictureBox1; - private Panel panel1; - private Label label5; - private Label label6; - private Button button1; - private Button button2; - } -} \ No newline at end of file diff --git a/Bus/Bus/FormBusConfig.cs b/Bus/Bus/FormBusConfig.cs deleted file mode 100644 index ad5d6f9..0000000 --- a/Bus/Bus/FormBusConfig.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Bus -{ - public partial class FormBusConfig : Form - { - public FormBusConfig() - { - InitializeComponent(); - } - - /*private void LabelObject_MouseDown(object sender, MouseEventArgs e) - { - - }*/ - - - } -} - \ No newline at end of file diff --git a/Bus/Bus/FormBusConfig.resx b/Bus/Bus/FormBusConfig.resx deleted file mode 100644 index f298a7b..0000000 --- a/Bus/Bus/FormBusConfig.resx +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file -- 2.25.1 From ca865bc1f0f15f4b0b2baa324c841df7d20a47ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Tue, 8 Nov 2022 12:21:37 +0400 Subject: [PATCH 7/7] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=BD=D1=8F=D1=82=D0=B0?= =?UTF-8?q?=D1=8F=204=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bus/Bus/DrawingBus.cs | 2 +- Bus/Bus/FormMapWithSetDoubleDeckerBus.cs | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Bus/Bus/DrawingBus.cs b/Bus/Bus/DrawingBus.cs index f8924a1..4a13fe0 100644 --- a/Bus/Bus/DrawingBus.cs +++ b/Bus/Bus/DrawingBus.cs @@ -1,4 +1,4 @@ -using System; +using Bus; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs index 0150735..acc98b1 100644 --- a/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs +++ b/Bus/Bus/FormMapWithSetDoubleDeckerBus.cs @@ -80,7 +80,7 @@ namespace Bus private void ButtonAddBus_Click(object sender, EventArgs e) { - if (_mapBusCollectionGeneric == null) + if (listBoxMaps.SelectedIndex == -1) { return; } @@ -94,11 +94,10 @@ namespace Bus } DrawingObjectBus bus = new(form.SelectedBus); - - if (_mapBusCollectionGeneric + bus != -1) + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + bus != -1) { MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapBusCollectionGeneric.ShowSet(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else { @@ -109,20 +108,27 @@ namespace Bus private void ButtonRemoveBus_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 (_mapBusCollectionGeneric - pos != null) + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null) { MessageBox.Show("Объект удален"); - pictureBox.Image = _mapBusCollectionGeneric.ShowSet(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else { -- 2.25.1