diff --git a/Trolleybus/Trolleybus/DrawingSmallTrolleybus.cs b/Trolleybus/Trolleybus/DrawingSmallTrolleybus.cs index af5dd4d..98b5582 100644 --- a/Trolleybus/Trolleybus/DrawingSmallTrolleybus.cs +++ b/Trolleybus/Trolleybus/DrawingSmallTrolleybus.cs @@ -28,10 +28,12 @@ namespace Trolleybus Brush dBlue = new SolidBrush(Color.DarkBlue); Brush bWhite = new SolidBrush(Color.White); Pen WinBlue = new Pen(Color.Blue); + Brush br = new SolidBrush(smallTrolleybus?.DopColor ?? Color.Black); base.DrawTransport(g); if (smallTrolleybus.BodyKit) { + g.FillRectangle(br, _startPosX, _startPosY, 200, 50); g.DrawRectangle(pen, _startPosX, _startPosY, 200, 50); g.DrawRectangle(pen, _startPosX + 100, _startPosY + 10, 20, 40); g.FillEllipse(brBlue, _startPosX, _startPosY + 5, 20, 25); @@ -59,11 +61,13 @@ namespace Trolleybus { g.DrawLine(pen, _startPosX + 100, _startPosY - 10, _startPosX + 150, _startPosY - 20); g.DrawLine(pen, _startPosX + 150, _startPosY - 20, _startPosX, _startPosY - 30); + g.FillRectangle(dopBrush, _startPosX + 50, _startPosY - 10, 100, 10); g.DrawRectangle(pen, _startPosX + 50, _startPosY - 10, 100, 10); } if (smallTrolleybus.Battary) { + g.FillRectangle(dopBrush, _startPosX + 100, _startPosY, 10, 10); g.DrawRectangle(pen, _startPosX + 100, _startPosY, 10, 10); } } diff --git a/Trolleybus/Trolleybus/DrawingTrolleybus.cs b/Trolleybus/Trolleybus/DrawingTrolleybus.cs index 38e8d7a..38c81ca 100644 --- a/Trolleybus/Trolleybus/DrawingTrolleybus.cs +++ b/Trolleybus/Trolleybus/DrawingTrolleybus.cs @@ -136,8 +136,9 @@ namespace Trolleybus } Pen pen = new Pen(Color.Black); Brush brBlue = new SolidBrush(Color.LightBlue); - Brush dBlue = new SolidBrush(Color.DarkBlue); Brush bWhite = new SolidBrush(Color.White); + Brush br = new SolidBrush(Trolleybus?.BodyColor ?? Color.Black); + g.FillRectangle(br, _startPosX, _startPosY, 200, 50); g.DrawRectangle(pen, _startPosX, _startPosY, 200, 50); g.DrawRectangle(pen, _startPosX + 100, _startPosY + 10, 20, 40); Pen WinBlue = new Pen(Color.Blue); diff --git a/Trolleybus/Trolleybus/EntitySmallTrolleybus.cs b/Trolleybus/Trolleybus/EntitySmallTrolleybus.cs index 796bace..5f39c2f 100644 --- a/Trolleybus/Trolleybus/EntitySmallTrolleybus.cs +++ b/Trolleybus/Trolleybus/EntitySmallTrolleybus.cs @@ -12,16 +12,16 @@ namespace Trolleybus /// /// Дополнительный цвет /// - public Color DopColor { get; private set; } + public Color DopColor { get; set; } /// /// Признак наличия обвеса /// - public bool BodyKit { get; private set; } + public bool BodyKit { get; set; } /// /// Признак наличия гоночной полосы /// - public bool Horns { get; private set; } - public bool Battary { get; private set; } + public bool Horns { get; set; } + public bool Battary { get; set; } /// /// Инициализация свойств /// diff --git a/Trolleybus/Trolleybus/EntityTrolleybus.cs b/Trolleybus/Trolleybus/EntityTrolleybus.cs index 10bb18d..405d7f5 100644 --- a/Trolleybus/Trolleybus/EntityTrolleybus.cs +++ b/Trolleybus/Trolleybus/EntityTrolleybus.cs @@ -23,7 +23,7 @@ namespace Trolleybus /// /// Цвет кузова /// - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } /// /// Шаг перемещения троллейбуса /// diff --git a/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.Designer.cs b/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.Designer.cs index e0c5493..dfd50d6 100644 --- a/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.Designer.cs +++ b/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.Designer.cs @@ -29,6 +29,12 @@ private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); + 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.textBoxNewMapName = new System.Windows.Forms.TextBox(); + this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); this.buttonLeft = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); @@ -38,16 +44,10 @@ this.buttonRemoveTrolleybus = new System.Windows.Forms.Button(); this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox(); this.buttonAddTrolleybus = 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.textBoxNewMapName = new System.Windows.Forms.TextBox(); - this.buttonAddMap = new System.Windows.Forms.Button(); - this.listBoxMaps = new System.Windows.Forms.ListBox(); - this.buttonDeleteMap = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.SuspendLayout(); // // groupBox1 @@ -63,125 +63,15 @@ this.groupBox1.Controls.Add(this.maskedTextBoxPosition); this.groupBox1.Controls.Add(this.buttonAddTrolleybus); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right; - this.groupBox1.Location = new System.Drawing.Point(600, 0); + this.groupBox1.Location = new System.Drawing.Point(900, 0); + this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(200, 648); + this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.groupBox1.Size = new System.Drawing.Size(300, 997); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Инструменты"; // - // buttonLeft - // - this.buttonLeft.BackgroundImage = global::Trolleybus.Properties.Resources.left30; - this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(80, 605); - this.buttonLeft.Name = "buttonLeft"; - this.buttonLeft.Size = new System.Drawing.Size(32, 31); - this.buttonLeft.TabIndex = 9; - this.buttonLeft.UseVisualStyleBackColor = true; - this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonRight - // - this.buttonRight.BackgroundImage = global::Trolleybus.Properties.Resources.right30; - this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(156, 605); - this.buttonRight.Name = "buttonRight"; - this.buttonRight.Size = new System.Drawing.Size(32, 31); - this.buttonRight.TabIndex = 8; - this.buttonRight.UseVisualStyleBackColor = true; - this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonDown - // - this.buttonDown.BackgroundImage = global::Trolleybus.Properties.Resources.down30; - this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(118, 605); - this.buttonDown.Name = "buttonDown"; - this.buttonDown.Size = new System.Drawing.Size(32, 31); - this.buttonDown.TabIndex = 7; - this.buttonDown.UseVisualStyleBackColor = true; - this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonUp - // - this.buttonUp.BackgroundImage = global::Trolleybus.Properties.Resources.up30; - this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(118, 568); - this.buttonUp.Name = "buttonUp"; - this.buttonUp.Size = new System.Drawing.Size(32, 31); - this.buttonUp.TabIndex = 6; - this.buttonUp.UseVisualStyleBackColor = true; - this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonShowOnMap - // - this.buttonShowOnMap.Location = new System.Drawing.Point(7, 511); - this.buttonShowOnMap.Name = "buttonShowOnMap"; - this.buttonShowOnMap.Size = new System.Drawing.Size(181, 23); - this.buttonShowOnMap.TabIndex = 5; - this.buttonShowOnMap.Text = "Посмотреть карту"; - this.buttonShowOnMap.UseVisualStyleBackColor = true; - this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click); - // - // buttonShowStorage - // - this.buttonShowStorage.Location = new System.Drawing.Point(7, 471); - this.buttonShowStorage.Name = "buttonShowStorage"; - this.buttonShowStorage.Size = new System.Drawing.Size(181, 23); - this.buttonShowStorage.TabIndex = 4; - this.buttonShowStorage.Text = "Посмотреть хранилище"; - this.buttonShowStorage.UseVisualStyleBackColor = true; - this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click); - // - // buttonRemoveTrolleybus - // - this.buttonRemoveTrolleybus.Location = new System.Drawing.Point(6, 425); - this.buttonRemoveTrolleybus.Name = "buttonRemoveTrolleybus"; - this.buttonRemoveTrolleybus.Size = new System.Drawing.Size(182, 23); - this.buttonRemoveTrolleybus.TabIndex = 3; - this.buttonRemoveTrolleybus.Text = "Удалить троллейбус"; - this.buttonRemoveTrolleybus.UseVisualStyleBackColor = true; - this.buttonRemoveTrolleybus.Click += new System.EventHandler(this.ButtonRemoveTrolleybus_Click); - // - // maskedTextBoxPosition - // - this.maskedTextBoxPosition.Location = new System.Drawing.Point(7, 383); - this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; - this.maskedTextBoxPosition.Size = new System.Drawing.Size(181, 20); - this.maskedTextBoxPosition.TabIndex = 2; - // - // buttonAddTrolleybus - // - this.buttonAddTrolleybus.Location = new System.Drawing.Point(7, 340); - this.buttonAddTrolleybus.Name = "buttonAddTrolleybus"; - this.buttonAddTrolleybus.Size = new System.Drawing.Size(181, 23); - this.buttonAddTrolleybus.TabIndex = 1; - this.buttonAddTrolleybus.Text = "Добавить троллейбус"; - this.buttonAddTrolleybus.UseVisualStyleBackColor = true; - this.buttonAddTrolleybus.Click += new System.EventHandler(this.ButtonAddTrolleybus_Click); - // - // comboBoxSelectorMap - // - this.comboBoxSelectorMap.FormattingEnabled = true; - this.comboBoxSelectorMap.Items.AddRange(new object[] { - "Простая карта", - "Сложная карта"}); - this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 44); - this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; - this.comboBoxSelectorMap.Size = new System.Drawing.Size(169, 21); - 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.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(600, 648); - this.pictureBox.TabIndex = 1; - this.pictureBox.TabStop = false; - // // groupBox2 // this.groupBox2.Controls.Add(this.buttonDeleteMap); @@ -189,60 +79,194 @@ this.groupBox2.Controls.Add(this.buttonAddMap); this.groupBox2.Controls.Add(this.textBoxNewMapName); this.groupBox2.Controls.Add(this.comboBoxSelectorMap); - this.groupBox2.Location = new System.Drawing.Point(6, 19); + this.groupBox2.Location = new System.Drawing.Point(9, 29); + this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(181, 287); + this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.groupBox2.Size = new System.Drawing.Size(272, 442); this.groupBox2.TabIndex = 2; this.groupBox2.TabStop = false; this.groupBox2.Text = "Карты"; // - // textBoxNewMapName + // buttonDeleteMap // - this.textBoxNewMapName.Location = new System.Drawing.Point(7, 18); - this.textBoxNewMapName.Name = "textBoxNewMapName"; - this.textBoxNewMapName.Size = new System.Drawing.Size(168, 20); - this.textBoxNewMapName.TabIndex = 1; - // - // buttonAddMap - // - this.buttonAddMap.Location = new System.Drawing.Point(7, 72); - this.buttonAddMap.Name = "buttonAddMap"; - this.buttonAddMap.Size = new System.Drawing.Size(168, 23); - this.buttonAddMap.TabIndex = 2; - this.buttonAddMap.Text = "Добавить Карту"; - this.buttonAddMap.UseVisualStyleBackColor = true; + this.buttonDeleteMap.Location = new System.Drawing.Point(10, 314); + this.buttonDeleteMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonDeleteMap.Name = "buttonDeleteMap"; + this.buttonDeleteMap.Size = new System.Drawing.Size(252, 35); + this.buttonDeleteMap.TabIndex = 4; + this.buttonDeleteMap.Text = "Удалить Карту"; + this.buttonDeleteMap.UseVisualStyleBackColor = true; + this.buttonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click); // // listBoxMaps // this.listBoxMaps.FormattingEnabled = true; - this.listBoxMaps.Location = new System.Drawing.Point(7, 102); + this.listBoxMaps.ItemHeight = 20; + this.listBoxMaps.Location = new System.Drawing.Point(10, 157); + this.listBoxMaps.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.listBoxMaps.Name = "listBoxMaps"; - this.listBoxMaps.Size = new System.Drawing.Size(168, 95); + this.listBoxMaps.Size = new System.Drawing.Size(250, 144); this.listBoxMaps.TabIndex = 3; + this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged); // - // buttonDeleteMap + // buttonAddMap // - this.buttonDeleteMap.Location = new System.Drawing.Point(7, 204); - this.buttonDeleteMap.Name = "buttonDeleteMap"; - this.buttonDeleteMap.Size = new System.Drawing.Size(168, 23); - this.buttonDeleteMap.TabIndex = 4; - this.buttonDeleteMap.Text = "Удалить Карту"; - this.buttonDeleteMap.UseVisualStyleBackColor = true; + this.buttonAddMap.Location = new System.Drawing.Point(10, 111); + this.buttonAddMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonAddMap.Name = "buttonAddMap"; + this.buttonAddMap.Size = new System.Drawing.Size(252, 35); + 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(10, 28); + this.textBoxNewMapName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.textBoxNewMapName.Name = "textBoxNewMapName"; + this.textBoxNewMapName.Size = new System.Drawing.Size(250, 26); + this.textBoxNewMapName.TabIndex = 1; + // + // comboBoxSelectorMap + // + this.comboBoxSelectorMap.FormattingEnabled = true; + this.comboBoxSelectorMap.Items.AddRange(new object[] { + "Простая карта", + "Сложная карта"}); + this.comboBoxSelectorMap.Location = new System.Drawing.Point(9, 68); + this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; + this.comboBoxSelectorMap.Size = new System.Drawing.Size(252, 28); + this.comboBoxSelectorMap.TabIndex = 0; + this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); + // + // buttonLeft + // + this.buttonLeft.BackgroundImage = global::Trolleybus.Properties.Resources.left30; + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonLeft.Location = new System.Drawing.Point(120, 931); + this.buttonLeft.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(48, 48); + this.buttonLeft.TabIndex = 9; + this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonRight + // + this.buttonRight.BackgroundImage = global::Trolleybus.Properties.Resources.right30; + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonRight.Location = new System.Drawing.Point(234, 931); + this.buttonRight.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(48, 48); + this.buttonRight.TabIndex = 8; + this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonDown + // + this.buttonDown.BackgroundImage = global::Trolleybus.Properties.Resources.down30; + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonDown.Location = new System.Drawing.Point(177, 931); + this.buttonDown.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(48, 48); + this.buttonDown.TabIndex = 7; + this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonUp + // + this.buttonUp.BackgroundImage = global::Trolleybus.Properties.Resources.up30; + this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonUp.Location = new System.Drawing.Point(177, 874); + this.buttonUp.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonUp.Name = "buttonUp"; + this.buttonUp.Size = new System.Drawing.Size(48, 48); + this.buttonUp.TabIndex = 6; + this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonShowOnMap + // + this.buttonShowOnMap.Location = new System.Drawing.Point(10, 786); + this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonShowOnMap.Name = "buttonShowOnMap"; + this.buttonShowOnMap.Size = new System.Drawing.Size(272, 35); + this.buttonShowOnMap.TabIndex = 5; + this.buttonShowOnMap.Text = "Посмотреть карту"; + this.buttonShowOnMap.UseVisualStyleBackColor = true; + this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click); + // + // buttonShowStorage + // + this.buttonShowStorage.Location = new System.Drawing.Point(10, 725); + this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonShowStorage.Name = "buttonShowStorage"; + this.buttonShowStorage.Size = new System.Drawing.Size(272, 35); + this.buttonShowStorage.TabIndex = 4; + this.buttonShowStorage.Text = "Посмотреть хранилище"; + this.buttonShowStorage.UseVisualStyleBackColor = true; + this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click); + // + // buttonRemoveTrolleybus + // + this.buttonRemoveTrolleybus.Location = new System.Drawing.Point(9, 654); + this.buttonRemoveTrolleybus.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonRemoveTrolleybus.Name = "buttonRemoveTrolleybus"; + this.buttonRemoveTrolleybus.Size = new System.Drawing.Size(273, 35); + this.buttonRemoveTrolleybus.TabIndex = 3; + this.buttonRemoveTrolleybus.Text = "Удалить троллейбус"; + this.buttonRemoveTrolleybus.UseVisualStyleBackColor = true; + this.buttonRemoveTrolleybus.Click += new System.EventHandler(this.ButtonRemoveTrolleybus_Click); + // + // maskedTextBoxPosition + // + this.maskedTextBoxPosition.Location = new System.Drawing.Point(10, 589); + this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; + this.maskedTextBoxPosition.Size = new System.Drawing.Size(270, 26); + this.maskedTextBoxPosition.TabIndex = 2; + // + // buttonAddTrolleybus + // + this.buttonAddTrolleybus.Location = new System.Drawing.Point(10, 523); + this.buttonAddTrolleybus.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.buttonAddTrolleybus.Name = "buttonAddTrolleybus"; + this.buttonAddTrolleybus.Size = new System.Drawing.Size(272, 35); + this.buttonAddTrolleybus.TabIndex = 1; + this.buttonAddTrolleybus.Text = "Добавить троллейбус"; + this.buttonAddTrolleybus.UseVisualStyleBackColor = true; + this.buttonAddTrolleybus.Click += new System.EventHandler(this.ButtonAddTrolleybus_Click); + // + // 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(4, 5, 4, 5); + this.pictureBox.Name = "pictureBox"; + this.pictureBox.Size = new System.Drawing.Size(900, 997); + this.pictureBox.TabIndex = 1; + this.pictureBox.TabStop = false; // // FormMapWithSetTrolleybus // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 648); + this.ClientSize = new System.Drawing.Size(1200, 997); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBox1); + this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.Name = "FormMapWithSetTrolleybus"; this.Text = "FormMapWithSetTrolleybus"; this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); this.ResumeLayout(false); } diff --git a/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.cs b/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.cs index e176789..091f483 100644 --- a/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.cs +++ b/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.cs @@ -38,6 +38,11 @@ namespace Trolleybus listBoxMaps.Items.Add(_mapsCollection.Keys[i]); } + foreach (string map in _mapsCollection.Keys) + { + listBoxMaps.Items.Add(map); + } + if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count)) { listBoxMaps.SelectedIndex = 0; @@ -102,12 +107,34 @@ namespace Trolleybus _mapTrolleybusCollectionGeneric = null; } } - private void ButtonAddTrolleybus_Click(object sender, EventArgs e) + private void AddTrolleybus(DrawingTrolleybus trolleybus) { if (listBoxMaps.SelectedIndex == -1) { return; } + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectTrolleybus(trolleybus) != -1) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + + } + + private void ButtonAddTrolleybus_Click(object sender, EventArgs e) + { + var formTrolleybusConfig = new FormTrolleybusConfig(); + + formTrolleybusConfig.AddEvent(AddTrolleybus); + formTrolleybusConfig.Show(); + /*if (listBoxMaps.SelectedIndex == -1) + { + return; + } Form1 form = new(); if (form.ShowDialog() == DialogResult.OK) { @@ -121,7 +148,7 @@ namespace Trolleybus { MessageBox.Show("Не удалось добавить объект"); } - } + }*/ } /// /// Удаление объекта @@ -153,7 +180,7 @@ namespace Trolleybus /// private void ButtonShowStorage_Click(object sender, EventArgs e) { - if (listBoxMaps.SelectedIndex == -1) + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] == null) { return; } @@ -185,23 +212,23 @@ namespace Trolleybus } //получаем имя кнопки string name = ((Button)sender)?.Name ?? string.Empty; - Direction enums = Direction.None; + Direction dir = Direction.None; switch (name) { - case "buttonsUp": - enums = Direction.Up; + case "buttonUp": + dir = Direction.Up; break; - case "buttonsDown": - enums = Direction.Down; + case "buttonDown": + dir = Direction.Down; break; - case "buttonsLeft": - enums = Direction.Left; + case "buttonLeft": + dir = Direction.Left; break; - case "buttonsRight": - enums = Direction.Right; + case "buttonRight": + dir = Direction.Right; break; } - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(enums); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir); } } } diff --git a/Trolleybus/Trolleybus/FormTrolleybusConfig.Designer.cs b/Trolleybus/Trolleybus/FormTrolleybusConfig.Designer.cs new file mode 100644 index 0000000..f027b62 --- /dev/null +++ b/Trolleybus/Trolleybus/FormTrolleybusConfig.Designer.cs @@ -0,0 +1,383 @@ +namespace Trolleybus +{ + partial class FormTrolleybusConfig + { + /// + /// 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.checkBoxBodyKit = new System.Windows.Forms.CheckBox(); + this.labelModifiedObject = new System.Windows.Forms.Label(); + this.labelSimpleObject = new System.Windows.Forms.Label(); + this.groupBoxColors = new System.Windows.Forms.GroupBox(); + this.panelPurple = new System.Windows.Forms.Panel(); + this.panelBlack = new System.Windows.Forms.Panel(); + this.panelGrey = new System.Windows.Forms.Panel(); + this.panelWhite = new System.Windows.Forms.Panel(); + this.panelYellow = new System.Windows.Forms.Panel(); + this.panelBlue = new System.Windows.Forms.Panel(); + this.panelGreen = new System.Windows.Forms.Panel(); + this.panelRed = new System.Windows.Forms.Panel(); + this.checkBoxBattary = new System.Windows.Forms.CheckBox(); + this.checkBoxHorns = new System.Windows.Forms.CheckBox(); + this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); + this.labelWeight = new System.Windows.Forms.Label(); + this.labelSpeed = new System.Windows.Forms.Label(); + this.pictureBoxObject = new System.Windows.Forms.PictureBox(); + this.panelObject = new System.Windows.Forms.Panel(); + this.labelDopColor = new System.Windows.Forms.Label(); + this.labelColor = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxConfig.SuspendLayout(); + this.groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); + this.panelObject.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxConfig + // + this.groupBoxConfig.Controls.Add(this.checkBoxBodyKit); + this.groupBoxConfig.Controls.Add(this.labelModifiedObject); + this.groupBoxConfig.Controls.Add(this.labelSimpleObject); + this.groupBoxConfig.Controls.Add(this.groupBoxColors); + this.groupBoxConfig.Controls.Add(this.checkBoxBattary); + this.groupBoxConfig.Controls.Add(this.checkBoxHorns); + this.groupBoxConfig.Controls.Add(this.numericUpDownWeight); + this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed); + this.groupBoxConfig.Controls.Add(this.labelWeight); + this.groupBoxConfig.Controls.Add(this.labelSpeed); + this.groupBoxConfig.Location = new System.Drawing.Point(13, 13); + this.groupBoxConfig.Name = "groupBoxConfig"; + this.groupBoxConfig.Size = new System.Drawing.Size(657, 457); + this.groupBoxConfig.TabIndex = 0; + this.groupBoxConfig.TabStop = false; + this.groupBoxConfig.Text = "Параметры"; + // + // checkBoxBodyKit + // + this.checkBoxBodyKit.AutoSize = true; + this.checkBoxBodyKit.Location = new System.Drawing.Point(11, 224); + this.checkBoxBodyKit.Name = "checkBoxBodyKit"; + this.checkBoxBodyKit.Size = new System.Drawing.Size(89, 24); + this.checkBoxBodyKit.TabIndex = 10; + this.checkBoxBodyKit.Text = "BodyKit"; + this.checkBoxBodyKit.UseVisualStyleBackColor = true; + // + // labelModifiedObject + // + this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelModifiedObject.Location = new System.Drawing.Point(483, 214); + this.labelModifiedObject.Name = "labelModifiedObject"; + this.labelModifiedObject.Size = new System.Drawing.Size(130, 34); + this.labelModifiedObject.TabIndex = 9; + this.labelModifiedObject.Text = "Продвинутый"; + this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelObject_Mouse_Down); + // + // labelSimpleObject + // + this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelSimpleObject.Location = new System.Drawing.Point(336, 214); + this.labelSimpleObject.Name = "labelSimpleObject"; + this.labelSimpleObject.Size = new System.Drawing.Size(100, 34); + this.labelSimpleObject.TabIndex = 8; + this.labelSimpleObject.Text = "Простой"; + this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelObject_Mouse_Down); + // + // groupBoxColors + // + this.groupBoxColors.Controls.Add(this.panelPurple); + this.groupBoxColors.Controls.Add(this.panelBlack); + this.groupBoxColors.Controls.Add(this.panelGrey); + this.groupBoxColors.Controls.Add(this.panelWhite); + this.groupBoxColors.Controls.Add(this.panelYellow); + this.groupBoxColors.Controls.Add(this.panelBlue); + this.groupBoxColors.Controls.Add(this.panelGreen); + this.groupBoxColors.Controls.Add(this.panelRed); + this.groupBoxColors.Location = new System.Drawing.Point(340, 26); + this.groupBoxColors.Name = "groupBoxColors"; + this.groupBoxColors.Size = new System.Drawing.Size(301, 185); + this.groupBoxColors.TabIndex = 7; + this.groupBoxColors.TabStop = false; + this.groupBoxColors.Text = "Цвета"; + // + // panelPurple + // + this.panelPurple.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(192))))); + this.panelPurple.Location = new System.Drawing.Point(211, 81); + this.panelPurple.Name = "panelPurple"; + this.panelPurple.Size = new System.Drawing.Size(62, 49); + this.panelPurple.TabIndex = 2; + this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelBlack + // + this.panelBlack.BackColor = System.Drawing.Color.Black; + this.panelBlack.Location = new System.Drawing.Point(143, 81); + this.panelBlack.Name = "panelBlack"; + this.panelBlack.Size = new System.Drawing.Size(62, 49); + this.panelBlack.TabIndex = 2; + this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelGrey + // + this.panelGrey.BackColor = System.Drawing.Color.Silver; + this.panelGrey.Location = new System.Drawing.Point(75, 81); + this.panelGrey.Name = "panelGrey"; + this.panelGrey.Size = new System.Drawing.Size(62, 49); + this.panelGrey.TabIndex = 2; + this.panelGrey.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelWhite + // + this.panelWhite.BackColor = System.Drawing.Color.Snow; + this.panelWhite.Location = new System.Drawing.Point(7, 81); + this.panelWhite.Name = "panelWhite"; + this.panelWhite.Size = new System.Drawing.Size(62, 49); + this.panelWhite.TabIndex = 2; + this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelYellow + // + this.panelYellow.BackColor = System.Drawing.Color.Yellow; + this.panelYellow.Location = new System.Drawing.Point(211, 26); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(62, 49); + this.panelYellow.TabIndex = 2; + this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelBlue + // + this.panelBlue.BackColor = System.Drawing.Color.Blue; + this.panelBlue.Location = new System.Drawing.Point(143, 26); + this.panelBlue.Name = "panelBlue"; + this.panelBlue.Size = new System.Drawing.Size(62, 49); + this.panelBlue.TabIndex = 1; + this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelGreen + // + this.panelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); + this.panelGreen.Location = new System.Drawing.Point(75, 25); + this.panelGreen.Name = "panelGreen"; + this.panelGreen.Size = new System.Drawing.Size(62, 50); + this.panelGreen.TabIndex = 1; + this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelRed + // + this.panelRed.BackColor = System.Drawing.Color.Red; + this.panelRed.Location = new System.Drawing.Point(7, 26); + this.panelRed.Name = "panelRed"; + this.panelRed.Size = new System.Drawing.Size(62, 49); + this.panelRed.TabIndex = 0; + this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // checkBoxBattary + // + this.checkBoxBattary.AutoSize = true; + this.checkBoxBattary.Location = new System.Drawing.Point(11, 180); + this.checkBoxBattary.Name = "checkBoxBattary"; + this.checkBoxBattary.Size = new System.Drawing.Size(234, 24); + this.checkBoxBattary.TabIndex = 5; + this.checkBoxBattary.Text = "Признак наличия батареи"; + this.checkBoxBattary.UseVisualStyleBackColor = true; + // + // checkBoxHorns + // + this.checkBoxHorns.AutoSize = true; + this.checkBoxHorns.Location = new System.Drawing.Point(11, 121); + this.checkBoxHorns.Name = "checkBoxHorns"; + this.checkBoxHorns.Size = new System.Drawing.Size(216, 24); + this.checkBoxHorns.TabIndex = 4; + this.checkBoxHorns.Text = "Признак наличия антен"; + this.checkBoxHorns.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + this.numericUpDownWeight.Location = new System.Drawing.Point(95, 75); + this.numericUpDownWeight.Name = "numericUpDownWeight"; + this.numericUpDownWeight.Size = new System.Drawing.Size(120, 26); + this.numericUpDownWeight.TabIndex = 3; + this.numericUpDownWeight.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // numericUpDownSpeed + // + this.numericUpDownSpeed.Location = new System.Drawing.Point(95, 26); + this.numericUpDownSpeed.Name = "numericUpDownSpeed"; + this.numericUpDownSpeed.Size = new System.Drawing.Size(120, 26); + this.numericUpDownSpeed.TabIndex = 2; + this.numericUpDownSpeed.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // labelWeight + // + this.labelWeight.AutoSize = true; + this.labelWeight.Location = new System.Drawing.Point(7, 75); + this.labelWeight.Name = "labelWeight"; + this.labelWeight.Size = new System.Drawing.Size(37, 20); + this.labelWeight.TabIndex = 1; + this.labelWeight.Text = "Вес"; + // + // labelSpeed + // + this.labelSpeed.AutoSize = true; + this.labelSpeed.Location = new System.Drawing.Point(7, 26); + this.labelSpeed.Name = "labelSpeed"; + this.labelSpeed.Size = new System.Drawing.Size(81, 20); + this.labelSpeed.TabIndex = 0; + this.labelSpeed.Text = "Скорость"; + // + // pictureBoxObject + // + this.pictureBoxObject.Anchor = System.Windows.Forms.AnchorStyles.None; + this.pictureBoxObject.Location = new System.Drawing.Point(27, 81); + this.pictureBoxObject.Name = "pictureBoxObject"; + this.pictureBoxObject.Size = new System.Drawing.Size(346, 208); + this.pictureBoxObject.TabIndex = 1; + this.pictureBoxObject.TabStop = false; + // + // panelObject + // + this.panelObject.AllowDrop = true; + this.panelObject.Controls.Add(this.labelDopColor); + this.panelObject.Controls.Add(this.labelColor); + this.panelObject.Controls.Add(this.pictureBoxObject); + this.panelObject.Location = new System.Drawing.Point(698, 39); + this.panelObject.Name = "panelObject"; + this.panelObject.Size = new System.Drawing.Size(412, 316); + this.panelObject.TabIndex = 2; + this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop); + this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelObject_DragEnter); + // + // labelDopColor + // + this.labelDopColor.AllowDrop = true; + this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelDopColor.Location = new System.Drawing.Point(139, 26); + this.labelDopColor.Name = "labelDopColor"; + this.labelDopColor.Size = new System.Drawing.Size(106, 52); + this.labelDopColor.TabIndex = 3; + this.labelDopColor.Text = "Доп цвет"; + this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragDrop); + this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); + // + // labelColor + // + this.labelColor.AllowDrop = true; + this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelColor.Location = new System.Drawing.Point(27, 26); + this.labelColor.Name = "labelColor"; + this.labelColor.Size = new System.Drawing.Size(106, 52); + this.labelColor.TabIndex = 2; + this.labelColor.Text = "Цвет"; + this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop); + this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); + // + // buttonOk + // + this.buttonOk.Location = new System.Drawing.Point(725, 361); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(106, 50); + this.buttonOk.TabIndex = 3; + this.buttonOk.Text = "Добваить"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(837, 361); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(106, 50); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // FormTrolleybusConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1180, 482); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.panelObject); + this.Controls.Add(this.groupBoxConfig); + this.Name = "FormTrolleybusConfig"; + this.Text = "FormTrolleybusConfig"; + this.groupBoxConfig.ResumeLayout(false); + this.groupBoxConfig.PerformLayout(); + this.groupBoxColors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); + this.panelObject.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxConfig; + private System.Windows.Forms.GroupBox groupBoxColors; + private System.Windows.Forms.Panel panelBlue; + private System.Windows.Forms.Panel panelGreen; + private System.Windows.Forms.Panel panelRed; + private System.Windows.Forms.CheckBox checkBoxBattary; + private System.Windows.Forms.CheckBox checkBoxHorns; + private System.Windows.Forms.NumericUpDown numericUpDownWeight; + private System.Windows.Forms.NumericUpDown numericUpDownSpeed; + private System.Windows.Forms.Label labelWeight; + private System.Windows.Forms.Label labelSpeed; + private System.Windows.Forms.Label labelModifiedObject; + private System.Windows.Forms.Label labelSimpleObject; + private System.Windows.Forms.Panel panelPurple; + private System.Windows.Forms.Panel panelBlack; + private System.Windows.Forms.Panel panelGrey; + private System.Windows.Forms.Panel panelWhite; + private System.Windows.Forms.Panel panelYellow; + private System.Windows.Forms.PictureBox pictureBoxObject; + private System.Windows.Forms.Panel panelObject; + private System.Windows.Forms.Label labelDopColor; + private System.Windows.Forms.Label labelColor; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.CheckBox checkBoxBodyKit; + } +} \ No newline at end of file diff --git a/Trolleybus/Trolleybus/FormTrolleybusConfig.cs b/Trolleybus/Trolleybus/FormTrolleybusConfig.cs new file mode 100644 index 0000000..f376efe --- /dev/null +++ b/Trolleybus/Trolleybus/FormTrolleybusConfig.cs @@ -0,0 +1,129 @@ +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 Trolleybus +{ + public partial class FormTrolleybusConfig : Form + { + DrawingTrolleybus _trolleybus = null; + private event TrolleybusDelegate EventAddTrolleybus; + public FormTrolleybusConfig() + { + InitializeComponent(); + panelBlack.MouseDown += PanelColor_MouseDown; + panelPurple.MouseDown += PanelColor_MouseDown; + panelGrey.MouseDown += PanelColor_MouseDown; + panelGreen.MouseDown += PanelColor_MouseDown; + panelRed.MouseDown += PanelColor_MouseDown; + panelWhite.MouseDown += PanelColor_MouseDown; + panelYellow.MouseDown += PanelColor_MouseDown; + panelBlue.MouseDown += PanelColor_MouseDown; + + buttonCancel.Click += (object sender, EventArgs e) => Close(); + } + + private void DrawTrolleybus() + { + Bitmap btm = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(btm); + _trolleybus?.SetPosition(25, 25, pictureBoxObject.Width, pictureBoxObject.Height); + _trolleybus?.DrawTransport(gr); + pictureBoxObject.Image = btm; + } + + public void AddEvent(TrolleybusDelegate ev) + { + if (EventAddTrolleybus == null) + { + EventAddTrolleybus = new TrolleybusDelegate(ev); + } + else + { + EventAddTrolleybus += ev; + } + } + + private void labelObject_Mouse_Down(object sender, MouseEventArgs e) + { + (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void panelObject_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.Text)) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void panelObject_DragDrop(object sender, DragEventArgs e) + { + //labelColor.BackColor = Color.Red; + switch (e.Data.GetData(DataFormats.Text).ToString()) + { + case "labelSimpleObject": + _trolleybus = new DrawingTrolleybus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + _trolleybus = new DrawningSmallTrolleybus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, + checkBoxBodyKit.Checked, checkBoxHorns.Checked, checkBoxBattary.Checked); + break; + } + DrawTrolleybus(); + } + private void PanelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + private void LabelColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) + { + //проверка на пустоту объекта + if (_trolleybus != null) + { + _trolleybus.Trolleybus.BodyColor = (Color)e.Data.GetData(typeof(Color)); + + DrawTrolleybus(); + } + } + + private void LabelAddColor_DragDrop(object sender, DragEventArgs e) + { + //проверка на пустоту объекта и правильную сущноть + if (_trolleybus != null && _trolleybus.Trolleybus is EntitySmallTrolleybus smallTrolleybus) + { + smallTrolleybus.DopColor = (Color)e.Data.GetData(typeof(Color)); + + DrawTrolleybus(); + } + } + + private void ButtonOk_Click(object sender, EventArgs e) + { + EventAddTrolleybus?.Invoke(_trolleybus); + Close(); + } + } +} diff --git a/Trolleybus/Trolleybus/FormTrolleybusConfig.resx b/Trolleybus/Trolleybus/FormTrolleybusConfig.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Trolleybus/Trolleybus/FormTrolleybusConfig.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 diff --git a/Trolleybus/Trolleybus/MapWithSetTrolleybusGeneric.cs b/Trolleybus/Trolleybus/MapWithSetTrolleybusGeneric.cs index 80c8143..f9d11bb 100644 --- a/Trolleybus/Trolleybus/MapWithSetTrolleybusGeneric.cs +++ b/Trolleybus/Trolleybus/MapWithSetTrolleybusGeneric.cs @@ -169,7 +169,7 @@ namespace Trolleybus { if (countInRow >= _pictureWidth / (_placeSizeWidth + 30)) { - xForLocomotive = _pictureWidth - _placeSizeWidth + 40; + xForLocomotive = _pictureWidth - 2 * _placeSizeWidth + 60; yForLocomotive += _placeSizeHeight; countInRow = 0; } diff --git a/Trolleybus/Trolleybus/Trolleybus.csproj b/Trolleybus/Trolleybus/Trolleybus.csproj index 8084a04..9425bfb 100644 --- a/Trolleybus/Trolleybus/Trolleybus.csproj +++ b/Trolleybus/Trolleybus/Trolleybus.csproj @@ -74,6 +74,12 @@ FormMapWithSetTrolleybus.cs + + Form + + + FormTrolleybusConfig.cs + @@ -81,6 +87,7 @@ + Form1.cs @@ -90,6 +97,9 @@ FormMapWithSetTrolleybus.cs + + FormTrolleybusConfig.cs + ResXFileCodeGenerator Resources.Designer.cs diff --git a/Trolleybus/Trolleybus/TrolleybusDelegate.cs b/Trolleybus/Trolleybus/TrolleybusDelegate.cs new file mode 100644 index 0000000..295f631 --- /dev/null +++ b/Trolleybus/Trolleybus/TrolleybusDelegate.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Trolleybus +{ + public delegate void TrolleybusDelegate(DrawingTrolleybus trolleybus); +}