diff --git a/AirBomber/BomberDelegate.cs b/AirBomber/BomberDelegate.cs new file mode 100644 index 0000000..68db759 --- /dev/null +++ b/AirBomber/BomberDelegate.cs @@ -0,0 +1,6 @@ +using AirBomber.Rendering; + +namespace AirBomber +{ + public delegate void BomberDelegate(BomberRendererBase Renderer); +} diff --git a/AirBomber/Entities/BomberEntity.cs b/AirBomber/Entities/BomberEntity.cs index 1eed6a6..f537f24 100644 --- a/AirBomber/Entities/BomberEntity.cs +++ b/AirBomber/Entities/BomberEntity.cs @@ -13,5 +13,10 @@ this.FuelTanks = FuelTanks; this.Bombs = Bombs; } + + public void SetAdditionalColor(Color AdditionalColor) + { + this.AdditionalColor = AdditionalColor; + } } } diff --git a/AirBomber/Entities/BomberEntityBase.cs b/AirBomber/Entities/BomberEntityBase.cs index a7f25d8..c815ded 100644 --- a/AirBomber/Entities/BomberEntityBase.cs +++ b/AirBomber/Entities/BomberEntityBase.cs @@ -13,5 +13,10 @@ this.Weight = Weight; this.BodyColor = BodyColor; } + + public void SetBaseColor(Color BaseColor) + { + BodyColor = BaseColor; + } } } diff --git a/AirBomber/FormBomberConfig.Designer.cs b/AirBomber/FormBomberConfig.Designer.cs new file mode 100644 index 0000000..4d3651c --- /dev/null +++ b/AirBomber/FormBomberConfig.Designer.cs @@ -0,0 +1,370 @@ +namespace AirBomber +{ + partial class FormBomberConfig + { + /// + /// 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() + { + ParamsGroupBox = new GroupBox(); + AdvancedEntityLabel = new Label(); + BaseEntityLabel = new Label(); + ColorsGroupBox = new GroupBox(); + VioletPanel = new Panel(); + BlackPanel = new Panel(); + GrayPanel = new Panel(); + WhitePanel = new Panel(); + OrangePanel = new Panel(); + BluePanel = new Panel(); + GreenPanel = new Panel(); + RedPanel = new Panel(); + FuelTanksCheckbox = new CheckBox(); + BombsCheckBox = new CheckBox(); + WeightNumericUpDown = new NumericUpDown(); + SpeedNumericUpDown = new NumericUpDown(); + WeightLabel = new Label(); + SpeedLabel = new Label(); + ObjectRepresentationPanel = new Panel(); + EntityPictureBox = new PictureBox(); + AdditionalColorLabel = new Label(); + ColorLabel = new Label(); + AddButton = new Button(); + ConfigCancelButton = new Button(); + ParamsGroupBox.SuspendLayout(); + ColorsGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).BeginInit(); + ((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).BeginInit(); + ObjectRepresentationPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)EntityPictureBox).BeginInit(); + SuspendLayout(); + // + // ParamsGroupBox + // + ParamsGroupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; + ParamsGroupBox.Controls.Add(AdvancedEntityLabel); + ParamsGroupBox.Controls.Add(BaseEntityLabel); + ParamsGroupBox.Controls.Add(ColorsGroupBox); + ParamsGroupBox.Controls.Add(FuelTanksCheckbox); + ParamsGroupBox.Controls.Add(BombsCheckBox); + ParamsGroupBox.Controls.Add(WeightNumericUpDown); + ParamsGroupBox.Controls.Add(SpeedNumericUpDown); + ParamsGroupBox.Controls.Add(WeightLabel); + ParamsGroupBox.Controls.Add(SpeedLabel); + ParamsGroupBox.Location = new Point(12, 12); + ParamsGroupBox.Name = "ParamsGroupBox"; + ParamsGroupBox.Size = new Size(555, 343); + ParamsGroupBox.TabIndex = 0; + ParamsGroupBox.TabStop = false; + ParamsGroupBox.Text = "Параметры"; + // + // AdvancedEntityLabel + // + AdvancedEntityLabel.BorderStyle = BorderStyle.FixedSingle; + AdvancedEntityLabel.Location = new Point(391, 200); + AdvancedEntityLabel.Name = "AdvancedEntityLabel"; + AdvancedEntityLabel.Size = new Size(110, 40); + AdvancedEntityLabel.TabIndex = 9; + AdvancedEntityLabel.Text = "Продвинутый"; + AdvancedEntityLabel.TextAlign = ContentAlignment.MiddleCenter; + AdvancedEntityLabel.MouseDown += LabelObject_MouseDown; + // + // BaseEntityLabel + // + BaseEntityLabel.BorderStyle = BorderStyle.FixedSingle; + BaseEntityLabel.Location = new Point(250, 200); + BaseEntityLabel.Name = "BaseEntityLabel"; + BaseEntityLabel.Size = new Size(110, 40); + BaseEntityLabel.TabIndex = 8; + BaseEntityLabel.Text = "Простой"; + BaseEntityLabel.TextAlign = ContentAlignment.MiddleCenter; + BaseEntityLabel.MouseDown += LabelObject_MouseDown; + // + // ColorsGroupBox + // + ColorsGroupBox.Controls.Add(VioletPanel); + ColorsGroupBox.Controls.Add(BlackPanel); + ColorsGroupBox.Controls.Add(GrayPanel); + ColorsGroupBox.Controls.Add(WhitePanel); + ColorsGroupBox.Controls.Add(OrangePanel); + ColorsGroupBox.Controls.Add(BluePanel); + ColorsGroupBox.Controls.Add(GreenPanel); + ColorsGroupBox.Controls.Add(RedPanel); + ColorsGroupBox.Location = new Point(235, 22); + ColorsGroupBox.Name = "ColorsGroupBox"; + ColorsGroupBox.Size = new Size(281, 155); + ColorsGroupBox.TabIndex = 7; + ColorsGroupBox.TabStop = false; + ColorsGroupBox.Text = "Цвета"; + // + // VioletPanel + // + VioletPanel.BackColor = Color.BlueViolet; + VioletPanel.ForeColor = SystemColors.ControlText; + VioletPanel.Location = new Point(216, 90); + VioletPanel.Name = "VioletPanel"; + VioletPanel.Size = new Size(50, 50); + VioletPanel.TabIndex = 4; + // + // BlackPanel + // + BlackPanel.BackColor = Color.Black; + BlackPanel.ForeColor = SystemColors.ControlText; + BlackPanel.Location = new Point(150, 90); + BlackPanel.Name = "BlackPanel"; + BlackPanel.Size = new Size(50, 50); + BlackPanel.TabIndex = 3; + // + // GrayPanel + // + GrayPanel.BackColor = Color.LightSlateGray; + GrayPanel.ForeColor = SystemColors.ControlText; + GrayPanel.Location = new Point(82, 90); + GrayPanel.Name = "GrayPanel"; + GrayPanel.Size = new Size(50, 50); + GrayPanel.TabIndex = 2; + // + // WhitePanel + // + WhitePanel.BackColor = Color.White; + WhitePanel.ForeColor = SystemColors.ControlText; + WhitePanel.Location = new Point(15, 90); + WhitePanel.Name = "WhitePanel"; + WhitePanel.Size = new Size(50, 50); + WhitePanel.TabIndex = 1; + // + // OrangePanel + // + OrangePanel.BackColor = Color.Orange; + OrangePanel.ForeColor = SystemColors.ControlText; + OrangePanel.Location = new Point(216, 22); + OrangePanel.Name = "OrangePanel"; + OrangePanel.Size = new Size(50, 50); + OrangePanel.TabIndex = 3; + // + // BluePanel + // + BluePanel.BackColor = Color.RoyalBlue; + BluePanel.ForeColor = SystemColors.ControlText; + BluePanel.Location = new Point(150, 22); + BluePanel.Name = "BluePanel"; + BluePanel.Size = new Size(50, 50); + BluePanel.TabIndex = 2; + // + // GreenPanel + // + GreenPanel.BackColor = Color.Green; + GreenPanel.ForeColor = SystemColors.ControlText; + GreenPanel.Location = new Point(82, 22); + GreenPanel.Name = "GreenPanel"; + GreenPanel.Size = new Size(50, 50); + GreenPanel.TabIndex = 1; + // + // RedPanel + // + RedPanel.BackColor = Color.Red; + RedPanel.ForeColor = SystemColors.ControlText; + RedPanel.Location = new Point(15, 22); + RedPanel.Name = "RedPanel"; + RedPanel.Size = new Size(50, 50); + RedPanel.TabIndex = 0; + // + // FuelTanksCheckbox + // + FuelTanksCheckbox.AutoSize = true; + FuelTanksCheckbox.Location = new Point(20, 158); + FuelTanksCheckbox.Name = "FuelTanksCheckbox"; + FuelTanksCheckbox.Size = new Size(174, 19); + FuelTanksCheckbox.TabIndex = 5; + FuelTanksCheckbox.Text = "Наличие топливных баков"; + FuelTanksCheckbox.UseVisualStyleBackColor = true; + // + // BombsCheckBox + // + BombsCheckBox.AutoSize = true; + BombsCheckBox.Location = new Point(20, 123); + BombsCheckBox.Name = "BombsCheckBox"; + BombsCheckBox.Size = new Size(108, 19); + BombsCheckBox.TabIndex = 4; + BombsCheckBox.Text = "Наличие бомб"; + BombsCheckBox.UseVisualStyleBackColor = true; + // + // WeightNumericUpDown + // + WeightNumericUpDown.Location = new Point(88, 71); + WeightNumericUpDown.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + WeightNumericUpDown.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + WeightNumericUpDown.Name = "WeightNumericUpDown"; + WeightNumericUpDown.Size = new Size(120, 23); + WeightNumericUpDown.TabIndex = 3; + WeightNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // SpeedNumericUpDown + // + SpeedNumericUpDown.Location = new Point(88, 32); + SpeedNumericUpDown.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + SpeedNumericUpDown.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + SpeedNumericUpDown.Name = "SpeedNumericUpDown"; + SpeedNumericUpDown.Size = new Size(120, 23); + SpeedNumericUpDown.TabIndex = 2; + SpeedNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // WeightLabel + // + WeightLabel.AutoSize = true; + WeightLabel.Location = new Point(20, 73); + WeightLabel.Name = "WeightLabel"; + WeightLabel.Size = new Size(29, 15); + WeightLabel.TabIndex = 1; + WeightLabel.Text = "Вес:"; + // + // SpeedLabel + // + SpeedLabel.AutoSize = true; + SpeedLabel.Location = new Point(20, 34); + SpeedLabel.Name = "SpeedLabel"; + SpeedLabel.Size = new Size(62, 15); + SpeedLabel.TabIndex = 0; + SpeedLabel.Text = "Скорость:"; + // + // ObjectRepresentationPanel + // + ObjectRepresentationPanel.AllowDrop = true; + ObjectRepresentationPanel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + ObjectRepresentationPanel.Controls.Add(EntityPictureBox); + ObjectRepresentationPanel.Controls.Add(AdditionalColorLabel); + ObjectRepresentationPanel.Controls.Add(ColorLabel); + ObjectRepresentationPanel.Location = new Point(582, 12); + ObjectRepresentationPanel.Name = "ObjectRepresentationPanel"; + ObjectRepresentationPanel.Size = new Size(311, 307); + ObjectRepresentationPanel.TabIndex = 1; + ObjectRepresentationPanel.DragDrop += PanelObject_DragDrop; + ObjectRepresentationPanel.DragEnter += PanelObject_DragEnter; + // + // EntityPictureBox + // + EntityPictureBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + EntityPictureBox.Location = new Point(13, 52); + EntityPictureBox.Name = "EntityPictureBox"; + EntityPictureBox.Size = new Size(283, 252); + EntityPictureBox.TabIndex = 2; + EntityPictureBox.TabStop = false; + // + // AdditionalColorLabel + // + AdditionalColorLabel.AllowDrop = true; + AdditionalColorLabel.Anchor = AnchorStyles.Top | AnchorStyles.Right; + AdditionalColorLabel.BorderStyle = BorderStyle.FixedSingle; + AdditionalColorLabel.Location = new Point(180, 12); + AdditionalColorLabel.Name = "AdditionalColorLabel"; + AdditionalColorLabel.Size = new Size(115, 35); + AdditionalColorLabel.TabIndex = 1; + AdditionalColorLabel.Text = "Доп цвет"; + AdditionalColorLabel.TextAlign = ContentAlignment.MiddleCenter; + AdditionalColorLabel.DragDrop += LabelAdditionalColor_DragDrop; + AdditionalColorLabel.DragEnter += LabelColor_DragEnter; + // + // ColorLabel + // + ColorLabel.AllowDrop = true; + ColorLabel.BorderStyle = BorderStyle.FixedSingle; + ColorLabel.Location = new Point(13, 12); + ColorLabel.Name = "ColorLabel"; + ColorLabel.Size = new Size(115, 35); + ColorLabel.TabIndex = 0; + ColorLabel.Text = "Цвет"; + ColorLabel.TextAlign = ContentAlignment.MiddleCenter; + ColorLabel.DragDrop += LabelBaseColor_DragDrop; + ColorLabel.DragEnter += LabelColor_DragEnter; + // + // AddButton + // + AddButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + AddButton.Location = new Point(607, 325); + AddButton.Name = "AddButton"; + AddButton.Size = new Size(104, 30); + AddButton.TabIndex = 2; + AddButton.Text = "Добавить"; + AddButton.UseVisualStyleBackColor = true; + AddButton.Click += OkButtonClick; + // + // ConfigCancelButton + // + ConfigCancelButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + ConfigCancelButton.Location = new Point(764, 325); + ConfigCancelButton.Name = "ConfigCancelButton"; + ConfigCancelButton.Size = new Size(100, 30); + ConfigCancelButton.TabIndex = 3; + ConfigCancelButton.Text = "Отмена"; + ConfigCancelButton.UseVisualStyleBackColor = true; + // + // FormBomberConfig + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(905, 367); + Controls.Add(ConfigCancelButton); + Controls.Add(AddButton); + Controls.Add(ObjectRepresentationPanel); + Controls.Add(ParamsGroupBox); + Name = "FormBomberConfig"; + Text = "Создание объекта"; + ParamsGroupBox.ResumeLayout(false); + ParamsGroupBox.PerformLayout(); + ColorsGroupBox.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).EndInit(); + ((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).EndInit(); + ObjectRepresentationPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)EntityPictureBox).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox ParamsGroupBox; + private GroupBox ColorsGroupBox; + private Panel RedPanel; + private CheckBox FuelTanksCheckbox; + private CheckBox BombsCheckBox; + private NumericUpDown WeightNumericUpDown; + private NumericUpDown SpeedNumericUpDown; + private Label WeightLabel; + private Label SpeedLabel; + private Panel ObjectRepresentationPanel; + private PictureBox EntityPictureBox; + private Label AdditionalColorLabel; + private Label ColorLabel; + private Button AddButton; + private Panel OrangePanel; + private Panel BluePanel; + private Panel GreenPanel; + private Label AdvancedEntityLabel; + private Label BaseEntityLabel; + private Panel VioletPanel; + private Panel BlackPanel; + private Panel GrayPanel; + private Panel WhitePanel; + private Button ConfigCancelButton; + } +} \ No newline at end of file diff --git a/AirBomber/FormBomberConfig.cs b/AirBomber/FormBomberConfig.cs new file mode 100644 index 0000000..3246f9b --- /dev/null +++ b/AirBomber/FormBomberConfig.cs @@ -0,0 +1,124 @@ +using AirBomber.Rendering; + +namespace AirBomber +{ + public partial class FormBomberConfig : Form + { + BomberRendererBase? _renderer = null; + + private event Action? OnBomberAdded; + + public FormBomberConfig() + { + InitializeComponent(); + + RedPanel.MouseDown += PanelColor_MouseDown; + GreenPanel.MouseDown += PanelColor_MouseDown; + BluePanel.MouseDown += PanelColor_MouseDown; + OrangePanel.MouseDown += PanelColor_MouseDown; + WhitePanel.MouseDown += PanelColor_MouseDown; + GrayPanel.MouseDown += PanelColor_MouseDown; + BlackPanel.MouseDown += PanelColor_MouseDown; + VioletPanel.MouseDown += PanelColor_MouseDown; + + ConfigCancelButton.Click += (sender, e) => { Close(); }; + } + + private void DrawBomber() + { + Bitmap bmp = new Bitmap(EntityPictureBox.Width, EntityPictureBox.Height); + Graphics g = Graphics.FromImage(bmp); + + _renderer?.SetPosition(5, 5); + _renderer?.DrawEntity(g); + + EntityPictureBox.Image = bmp; + } + + public void AddEvent(Action ev) + { + if (OnBomberAdded is null) + OnBomberAdded = ev; + else + OnBomberAdded += ev; + } + + private void LabelObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void PanelColor_MouseDown(object? sender, MouseEventArgs e) + { + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void PanelObject_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) + e.Effect = DragDropEffects.Copy; + else + e.Effect = DragDropEffects.None; + } + + private void LabelColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent("System.Drawing.Color") ?? false) + e.Effect = DragDropEffects.Copy; + else + e.Effect = DragDropEffects.None; + } + + private void PanelObject_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data?.GetData(DataFormats.Text).ToString()) + { + case "BaseEntityLabel": + _renderer = new BomberRendererBase( + (int)SpeedNumericUpDown.Value, + (int)WeightNumericUpDown.Value, + Color.White, + EntityPictureBox.Width, EntityPictureBox.Height + ); + break; + + case "AdvancedEntityLabel": + _renderer = new BomberRenderer( + (int)SpeedNumericUpDown.Value, + (int)WeightNumericUpDown.Value, + Color.White, Color.Black, + FuelTanksCheckbox.Checked, + BombsCheckBox.Checked, + EntityPictureBox.Width, EntityPictureBox.Height + ); + break; + } + + DrawBomber(); + } + + private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) + { + Color SelectedColor = (Color)e.Data?.GetData("System.Drawing.Color")!; + _renderer?.SetBaseColor(SelectedColor); + + DrawBomber(); + } + + private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e) + { + Color SelectedColor = (Color)e.Data?.GetData("System.Drawing.Color")!; + (_renderer as BomberRenderer)?.SetAdditionalColor(SelectedColor); + + DrawBomber(); + } + + private void OkButtonClick(object sender, EventArgs e) + { + if (_renderer is not null) + OnBomberAdded?.Invoke(_renderer); + + Close(); + } + } +} diff --git a/AirBomber/FormBomberConfig.resx b/AirBomber/FormBomberConfig.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/AirBomber/FormBomberConfig.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/AirBomber/FormEntityCollection.Designer.cs b/AirBomber/FormEntityCollection.Designer.cs index 885b63f..d7ccbef 100644 --- a/AirBomber/FormEntityCollection.Designer.cs +++ b/AirBomber/FormEntityCollection.Designer.cs @@ -30,7 +30,7 @@ { CollectionPictureBox = new PictureBox(); ToolGroupBox = new GroupBox(); - groupBox1 = new GroupBox(); + SetsGroupBox = new GroupBox(); SetNameTextBox = new TextBox(); StorageListBox = new ListBox(); AddSetButton = new Button(); @@ -41,7 +41,7 @@ AddBomberButton = new Button(); ((System.ComponentModel.ISupportInitialize)CollectionPictureBox).BeginInit(); ToolGroupBox.SuspendLayout(); - groupBox1.SuspendLayout(); + SetsGroupBox.SuspendLayout(); SuspendLayout(); // // CollectionPictureBox @@ -56,7 +56,7 @@ // ToolGroupBox // ToolGroupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; - ToolGroupBox.Controls.Add(groupBox1); + ToolGroupBox.Controls.Add(SetsGroupBox); ToolGroupBox.Controls.Add(RefreshCollectionButton); ToolGroupBox.Controls.Add(RemoveBomberButton); ToolGroupBox.Controls.Add(NumberMaskedTextBox); @@ -68,18 +68,18 @@ ToolGroupBox.TabStop = false; ToolGroupBox.Text = "Инструменты"; // - // groupBox1 + // SetsGroupBox // - groupBox1.Controls.Add(SetNameTextBox); - groupBox1.Controls.Add(StorageListBox); - groupBox1.Controls.Add(AddSetButton); - groupBox1.Controls.Add(RemoveSetButton); - groupBox1.Location = new Point(6, 22); - groupBox1.Name = "groupBox1"; - groupBox1.Size = new Size(164, 232); - groupBox1.TabIndex = 8; - groupBox1.TabStop = false; - groupBox1.Text = "Наборы"; + SetsGroupBox.Controls.Add(SetNameTextBox); + SetsGroupBox.Controls.Add(StorageListBox); + SetsGroupBox.Controls.Add(AddSetButton); + SetsGroupBox.Controls.Add(RemoveSetButton); + SetsGroupBox.Location = new Point(6, 22); + SetsGroupBox.Name = "SetsGroupBox"; + SetsGroupBox.Size = new Size(164, 232); + SetsGroupBox.TabIndex = 8; + SetsGroupBox.TabStop = false; + SetsGroupBox.Text = "Наборы"; // // SetNameTextBox // @@ -170,8 +170,8 @@ ((System.ComponentModel.ISupportInitialize)CollectionPictureBox).EndInit(); ToolGroupBox.ResumeLayout(false); ToolGroupBox.PerformLayout(); - groupBox1.ResumeLayout(false); - groupBox1.PerformLayout(); + SetsGroupBox.ResumeLayout(false); + SetsGroupBox.PerformLayout(); ResumeLayout(false); } @@ -183,7 +183,7 @@ private Button RemoveBomberButton; private MaskedTextBox NumberMaskedTextBox; private Button AddBomberButton; - private GroupBox groupBox1; + private GroupBox SetsGroupBox; private TextBox SetNameTextBox; private ListBox StorageListBox; private Button AddSetButton; diff --git a/AirBomber/FormEntityCollection.cs b/AirBomber/FormEntityCollection.cs index d6a3fd5..3b0a265 100644 --- a/AirBomber/FormEntityCollection.cs +++ b/AirBomber/FormEntityCollection.cs @@ -1,4 +1,5 @@ using AirBomber.Generics; +using AirBomber.Rendering; namespace AirBomber { @@ -33,24 +34,27 @@ namespace AirBomber if (StorageListBox.SelectedIndex == -1) return; + FormBomberConfig ConfigForm = new FormBomberConfig(); + ConfigForm.AddEvent(OnEntityAdded); + + ConfigForm.Show(); + } + + public void OnEntityAdded(BomberRendererBase Renderer) + { var obj = _storage[StorageListBox.SelectedItem.ToString() ?? string.Empty]; if (obj is null) return; - BomberForm Form = new BomberForm(); - - if (Form.ShowDialog() == DialogResult.OK) + if (obj + (Renderer) != -1) { - if (obj + Form.SelectedRenderer != -1) - { - MessageBox.Show("Объект добавлен"); - CollectionPictureBox.Image = obj.ShowEntities(); - } + MessageBox.Show("Объект добавлен"); + CollectionPictureBox.Image = obj.ShowEntities(); + } - else - { - MessageBox.Show("Не удалось добавить объект"); - } + else + { + MessageBox.Show("Не удалось добавить объект"); } } diff --git a/AirBomber/FormEntityCollection.resx b/AirBomber/FormEntityCollection.resx index f298a7b..af32865 100644 --- a/AirBomber/FormEntityCollection.resx +++ b/AirBomber/FormEntityCollection.resx @@ -1,4 +1,64 @@ - + + + diff --git a/AirBomber/Rendering/BomberRenderer.cs b/AirBomber/Rendering/BomberRenderer.cs index f17a167..1956afb 100644 --- a/AirBomber/Rendering/BomberRenderer.cs +++ b/AirBomber/Rendering/BomberRenderer.cs @@ -51,5 +51,11 @@ namespace AirBomber.Rendering g.FillEllipse(AdditionalBrush, new Rectangle(RightBombStartXY, RightBombSize)); } } + + public void SetAdditionalColor(Color AdditionalColor) + { + if (EntityBomber is BomberEntity AdvancedBomber) + AdvancedBomber.SetAdditionalColor(AdditionalColor); + } } } diff --git a/AirBomber/Rendering/BomberRendererBase.cs b/AirBomber/Rendering/BomberRendererBase.cs index 0856feb..7f477c0 100644 --- a/AirBomber/Rendering/BomberRendererBase.cs +++ b/AirBomber/Rendering/BomberRendererBase.cs @@ -59,16 +59,10 @@ namespace AirBomber.Rendering if (x < 0) x = 0; - else if (x + _bomberWidth > _pictureWidth) - x = _pictureWidth - _bomberWidth; - _startPosX = x; if (y < 0) y = 0; - else if (y + _bomberHeight > _pictureHeight) - y = _pictureHeight - _bomberHeight; - _startPosY = y; } @@ -169,5 +163,10 @@ namespace AirBomber.Rendering }; g.DrawPolygon(Pen, BackRightWing); } + + public void SetBaseColor(Color BaseColor) + { + EntityBomber?.SetBaseColor(BaseColor); + } } }