diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.Designer.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.Designer.cs index 3c99b6b..617e2a0 100644 --- a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.Designer.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.Designer.cs @@ -47,7 +47,7 @@ namespace WinF_Lab2_Cruiser RandomGenerator = new Button(); RemoveButton = new Button(); maskedTextBox1 = new MaskedTextBox(); - Add2Button = new Button(); + // Add2Button = new Button(); AddButton = new Button(); comboBox1 = new ComboBox(); pictureBox1 = new PictureBox(); @@ -63,7 +63,7 @@ namespace WinF_Lab2_Cruiser ToolBox.Controls.Add(RandomGenerator); ToolBox.Controls.Add(RemoveButton); ToolBox.Controls.Add(maskedTextBox1); - ToolBox.Controls.Add(Add2Button); + // ToolBox.Controls.Add(Add2Button); ToolBox.Controls.Add(AddButton); ToolBox.Controls.Add(comboBox1); @@ -173,10 +173,10 @@ namespace WinF_Lab2_Cruiser maskedTextBox1.TabIndex = 5; maskedTextBox1.ValidatingType = typeof(int); - // // Add2Button - // + // + /* Add2Button.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; Add2Button.Location = new Point(6, 126); Add2Button.Name = "Add2Button"; @@ -184,18 +184,23 @@ namespace WinF_Lab2_Cruiser Add2Button.TabIndex = 6; Add2Button.Text = "Advanced"; Add2Button.UseVisualStyleBackColor = true; - Add2Button.Click += Add2Button_Click; + // Add2Button.Click += Add2Button_Click; + // Add2Button.Click += NewFormCreate; + */ + // // AddButton // AddButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; AddButton.Location = new Point(6, 84); AddButton.Name = "AddButton"; - AddButton.Size = new Size(198, 40); + AddButton.Size = new Size(198, 70); AddButton.TabIndex = 7; - AddButton.Text = "Base"; + AddButton.Text = "Create a cruiser"; AddButton.UseVisualStyleBackColor = true; - AddButton.Click += AddButton_Click; + AddButton.Click += NewFormCreate; + // AddButton.Click += AddButton_Click; + // // comboBox1 // @@ -249,7 +254,7 @@ namespace WinF_Lab2_Cruiser private ComboBox comboBox1; private Button AddButton; - private Button Add2Button; + // private Button Add2Button; private MaskedTextBox maskedTextBox1; private PictureBox pictureBox1; private Button RemoveButton; diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.cs index b750b7e..55b3839 100644 --- a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.cs @@ -39,6 +39,7 @@ namespace WinF_Lab2_Cruiser */ } + /* private static Color GetColor(Random r) { Color cl = Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256)); @@ -65,10 +66,10 @@ namespace WinF_Lab2_Cruiser Transport = new DrawingBase(rn.Next(100, 300), rn.Next(1000, 3000), GetColor(rn)); break; case nameof(DrawingCruiser): - Class_CruiserEntity Obj = new Class_CruiserEntity(rn.Next(100, 300), rn.Next(1000, 3000), + Transport = new DrawingCruiser(rn.Next(100, 300), rn.Next(1000, 3000), GetColor(rn), GetColor(rn), Convert.ToBoolean(rn.Next(0, 2)), Convert.ToBoolean(rn.Next(0, 2)), rn.Next(1, 4), rn.Next(5, 10), rn.Next(1, 3)); - Transport = new DrawingCruiser(Obj); + // (Obj); break; default: return; @@ -86,6 +87,32 @@ namespace WinF_Lab2_Cruiser private void AddButton_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingBase)); private void Add2Button_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingCruiser)); + */ + + private void NewFormCreate(object sender, EventArgs e) + { + FormTransportConfig form = new(); + // TODO передать метод + form.Show(); + form.AddEvent(SetObj); + } + + private void SetObj(DrawingBase? ship) + { + if (_Company == null || ship == null) + { + return; + } + if (_Company + ship != -1) + { + MessageBox.Show(" > Object was added"); + pictureBox1.Image = _Company.Show(); + } + else + { + MessageBox.Show(" > Can't create an object"); + } + } private void RemoveButton_Click(object sender, EventArgs e) { @@ -143,7 +170,7 @@ namespace WinF_Lab2_Cruiser Form.SetTransport = drBase; Form.ShowDialog(); - // ---------------------------------------------------------- + // -------------------------------------------------- } private void Check_Click(object sender, EventArgs e) diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingCruiser.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingCruiser.cs index b960c36..8406e46 100644 --- a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingCruiser.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingCruiser.cs @@ -21,9 +21,12 @@ namespace WinF_Lab2_Cruiser.Drawing_tools // BaseEntity = new Class_CruiserEntity(speed, weight, mainc, addtc, pad, hangar, p, d_coordinates, h); //} - public DrawingCruiser(Class_CruiserEntity Obj) : base(302, 72) + public DrawingCruiser(int speed, double weight, + Color mainc, Color addtc, bool pad, + bool hangar, int p, int d_coordinates, int h) : base(302, 72) // Class_CruiserEntity Obj) : base(302, 72) { - BaseEntity = Obj; + BaseEntity = new Class_CruiserEntity(speed, weight, mainc, + addtc, pad, hangar, p, d_coordinates, h); } public override void DrawTransport(Graphics g) diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Base_Class_Cruiser.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Base_Class_Cruiser.cs index 8b1a31b..1cefdbf 100644 --- a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Base_Class_Cruiser.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Base_Class_Cruiser.cs @@ -12,6 +12,11 @@ namespace WinF_Lab2_Cruiser.Entity_Folder public int Speed { get; private set; } public double Weight { get; private set; } public Color MainC { get; private set; } + public void setMColor(Color color) + { + MainC = color; + } + public double Step => Speed * 100 / Weight; /// Конструктор diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Class_CruiserEntity.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Class_CruiserEntity.cs index d9213fd..910c139 100644 --- a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Class_CruiserEntity.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Class_CruiserEntity.cs @@ -12,6 +12,11 @@ namespace WinF_Lab2_Cruiser.Entity_Folder /// ADDITIONAL свойства public Color AdditionalC { get; private set; } + public void setAdditionalColor(Color color) + { + AdditionalC = color; + } + /// признаки (наличия) public bool HelicopterPads { get; private set; } /// вертолетная площадка public bool Hangar { get; private set; } /// ангар diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.Designer.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.Designer.cs new file mode 100644 index 0000000..24feed4 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.Designer.cs @@ -0,0 +1,344 @@ +namespace WinF_Lab2_Cruiser +{ + partial class FormTransportConfig + { + /// + /// 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() + { + ParametersBox = new GroupBox(); + AdvLabel = new Label(); + BaseLabel = new Label(); + groupBox2 = new GroupBox(); + PurpleP = new Panel(); + GreenP = new Panel(); + PinkP = new Panel(); + OrangeP = new Panel(); + CyanP = new Panel(); + YellowP = new Panel(); + RedP = new Panel(); + BlueP = new Panel(); + CheckBox_Pads = new CheckBox(); + CheckBox_Hangars = new CheckBox(); + WeightN = new NumericUpDown(); + SpeedN = new NumericUpDown(); + Label = new Label(); + Showcase = new PictureBox(); + AddButton = new Button(); + CancelButton = new Button(); + panelObject = new Panel(); + labelAcolor = new Label(); + labelMcolor = new Label(); + ParametersBox.SuspendLayout(); + groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)WeightN).BeginInit(); + ((System.ComponentModel.ISupportInitialize)SpeedN).BeginInit(); + ((System.ComponentModel.ISupportInitialize)Showcase).BeginInit(); + panelObject.SuspendLayout(); + SuspendLayout(); + // + // ParametersBox + // + ParametersBox.Controls.Add(AdvLabel); + ParametersBox.Controls.Add(BaseLabel); + ParametersBox.Controls.Add(groupBox2); + ParametersBox.Controls.Add(CheckBox_Pads); + ParametersBox.Controls.Add(CheckBox_Hangars); + ParametersBox.Controls.Add(WeightN); + ParametersBox.Controls.Add(SpeedN); + ParametersBox.Controls.Add(Label); + ParametersBox.Location = new Point(12, 0); + ParametersBox.Name = "ParametersBox"; + ParametersBox.Size = new Size(388, 495); + ParametersBox.TabIndex = 0; + ParametersBox.TabStop = false; + ParametersBox.Text = "Parameters"; + // + // AdvLabel + // + AdvLabel.BorderStyle = BorderStyle.FixedSingle; + AdvLabel.Location = new Point(175, 428); + AdvLabel.Name = "AdvLabel"; + AdvLabel.Size = new Size(184, 46); + AdvLabel.TabIndex = 5; + AdvLabel.Text = "Advanced"; + AdvLabel.TextAlign = ContentAlignment.MiddleCenter; + AdvLabel.MouseDown += BaseAdvLabel_MouseDown; + // + // BaseLabel + // + BaseLabel.BorderStyle = BorderStyle.FixedSingle; + BaseLabel.Location = new Point(17, 428); + BaseLabel.Name = "BaseLabel"; + BaseLabel.Size = new Size(132, 46); + BaseLabel.TabIndex = 4; + BaseLabel.Text = "Base"; + BaseLabel.TextAlign = ContentAlignment.MiddleCenter; + BaseLabel.MouseDown += BaseAdvLabel_MouseDown; + // + // groupBox2 + // + groupBox2.Controls.Add(PurpleP); + groupBox2.Controls.Add(GreenP); + groupBox2.Controls.Add(PinkP); + groupBox2.Controls.Add(OrangeP); + groupBox2.Controls.Add(CyanP); + groupBox2.Controls.Add(YellowP); + groupBox2.Controls.Add(RedP); + groupBox2.Controls.Add(BlueP); + groupBox2.Location = new Point(17, 197); + groupBox2.Name = "groupBox2"; + groupBox2.Size = new Size(342, 213); + groupBox2.TabIndex = 1; + groupBox2.TabStop = false; + groupBox2.Text = "Color picker"; + // + // PurpleP + // + PurpleP.BackColor = Color.DarkViolet; + PurpleP.Location = new Point(260, 126); + PurpleP.Name = "PurpleP"; + PurpleP.Size = new Size(63, 59); + PurpleP.TabIndex = 12; + // + // GreenP + // + GreenP.BackColor = Color.SpringGreen; + GreenP.Location = new Point(259, 49); + GreenP.Name = "GreenP"; + GreenP.Size = new Size(63, 59); + GreenP.TabIndex = 9; + // + // PinkP + // + PinkP.BackColor = Color.DeepPink; + PinkP.Location = new Point(180, 126); + PinkP.Name = "PinkP"; + PinkP.Size = new Size(63, 59); + PinkP.TabIndex = 11; + // + // OrangeP + // + OrangeP.BackColor = Color.DarkOrange; + OrangeP.Location = new Point(180, 49); + OrangeP.Name = "OrangeP"; + OrangeP.Size = new Size(63, 59); + OrangeP.TabIndex = 8; + // + // CyanP + // + CyanP.BackColor = Color.Cyan; + CyanP.Location = new Point(100, 126); + CyanP.Name = "CyanP"; + CyanP.Size = new Size(63, 59); + CyanP.TabIndex = 10; + // + // YellowP + // + YellowP.BackColor = Color.Gold; + YellowP.Location = new Point(19, 126); + YellowP.Name = "YellowP"; + YellowP.Size = new Size(63, 59); + YellowP.TabIndex = 9; + // + // RedP + // + RedP.BackColor = Color.Firebrick; + RedP.Location = new Point(100, 49); + RedP.Name = "RedP"; + RedP.Size = new Size(63, 59); + RedP.TabIndex = 7; + // + // BlueP + // + BlueP.BackColor = SystemColors.Highlight; + BlueP.Location = new Point(19, 49); + BlueP.Name = "BlueP"; + BlueP.Size = new Size(63, 59); + BlueP.TabIndex = 6; + // + // CheckBox_Pads + // + CheckBox_Pads.AutoSize = true; + CheckBox_Pads.Location = new Point(24, 142); + CheckBox_Pads.Name = "CheckBox_Pads"; + CheckBox_Pads.Size = new Size(203, 36); + CheckBox_Pads.TabIndex = 3; + CheckBox_Pads.Text = "Helicopter pad"; + CheckBox_Pads.UseVisualStyleBackColor = true; + // + // CheckBox_Hangars + // + CheckBox_Hangars.AutoSize = true; + CheckBox_Hangars.Location = new Point(234, 142); + CheckBox_Hangars.Name = "CheckBox_Hangars"; + CheckBox_Hangars.Size = new Size(133, 36); + CheckBox_Hangars.TabIndex = 1; + CheckBox_Hangars.Text = "Hangars"; + CheckBox_Hangars.UseVisualStyleBackColor = true; + // + // WeightN + // + WeightN.Location = new Point(198, 88); + WeightN.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + WeightN.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + WeightN.Name = "WeightN"; + WeightN.Size = new Size(142, 39); + WeightN.TabIndex = 2; + WeightN.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // SpeedN + // + SpeedN.Location = new Point(36, 88); + SpeedN.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + SpeedN.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + SpeedN.Name = "SpeedN"; + SpeedN.Size = new Size(142, 39); + SpeedN.TabIndex = 1; + SpeedN.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // Label + // + Label.AutoSize = true; + Label.Location = new Point(36, 53); + Label.Name = "Label"; + Label.Size = new Size(304, 32); + Label.TabIndex = 1; + Label.Text = "Speed Weight"; + // + // Showcase + // + Showcase.Location = new Point(58, 98); + Showcase.Name = "Showcase"; + Showcase.Size = new Size(458, 272); + Showcase.TabIndex = 1; + Showcase.TabStop = false; + // + // AddButton + // + AddButton.Location = new Point(419, 447); + AddButton.Name = "AddButton"; + AddButton.Size = new Size(268, 46); + AddButton.TabIndex = 2; + AddButton.Text = "Add"; + AddButton.UseVisualStyleBackColor = true; + AddButton.Click += AddButton_Click; + // + // CancelButton + // + CancelButton.Location = new Point(694, 447); + CancelButton.Name = "CancelButton"; + CancelButton.Size = new Size(286, 46); + CancelButton.TabIndex = 3; + CancelButton.Text = "Cancel"; + CancelButton.UseVisualStyleBackColor = true; + // + // panelObject + // + panelObject.AllowDrop = true; + panelObject.Controls.Add(labelAcolor); + panelObject.Controls.Add(labelMcolor); + panelObject.Controls.Add(Showcase); + panelObject.Location = new Point(419, 12); + panelObject.Name = "panelObject"; + panelObject.Size = new Size(561, 410); + panelObject.TabIndex = 4; + panelObject.DragDrop += PanelObject_DragDrop; + panelObject.DragEnter += PanelObject_DragEnter; + // + // labelAcolor + // + labelAcolor.AllowDrop = true; + labelAcolor.BorderStyle = BorderStyle.FixedSingle; + labelAcolor.Location = new Point(253, 39); + labelAcolor.Name = "labelAcolor"; + labelAcolor.Size = new Size(263, 42); + labelAcolor.TabIndex = 7; + labelAcolor.Text = "Additional color"; + labelAcolor.TextAlign = ContentAlignment.MiddleCenter; + labelAcolor.DragDrop += AdditionalColor_DragDrop; + labelAcolor.DragEnter += AdditionalColor_DragEnter; + // + // labelMcolor + // + labelMcolor.AllowDrop = true; + labelMcolor.BorderStyle = BorderStyle.FixedSingle; + labelMcolor.Location = new Point(58, 39); + labelMcolor.Name = "labelMcolor"; + labelMcolor.Size = new Size(180, 42); + labelMcolor.TabIndex = 6; + labelMcolor.Text = "Main color"; + labelMcolor.TextAlign = ContentAlignment.MiddleCenter; + labelMcolor.DragDrop += BodyColor_DragDrop; + labelMcolor.DragEnter += BodyColor_DragEnter; + // + // FormTransportConfig + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(992, 516); + Controls.Add(panelObject); + Controls.Add(CancelButton); + Controls.Add(AddButton); + Controls.Add(ParametersBox); + Name = "FormTransportConfig"; + Text = "FormTransportConfig"; + ParametersBox.ResumeLayout(false); + ParametersBox.PerformLayout(); + groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)WeightN).EndInit(); + ((System.ComponentModel.ISupportInitialize)SpeedN).EndInit(); + ((System.ComponentModel.ISupportInitialize)Showcase).EndInit(); + panelObject.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private GroupBox ParametersBox; + private Label Label; + private CheckBox CheckBox_Pads; + private CheckBox CheckBox_Hangars; + private NumericUpDown WeightN; + private NumericUpDown SpeedN; + private GroupBox groupBox2; + private Label BaseLabel; + private Label AdvLabel; + private Panel PurpleP; + private Panel GreenP; + private Panel PinkP; + private Panel OrangeP; + private Panel CyanP; + private Panel YellowP; + private Panel RedP; + private Panel BlueP; + private PictureBox Showcase; + private Button AddButton; + private Button CancelButton; + private Panel panelObject; + private Label labelMcolor; + private Label labelAcolor; + } +} \ No newline at end of file diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.cs new file mode 100644 index 0000000..b368ef4 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.cs @@ -0,0 +1,137 @@ +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; +using WinF_Lab2_Cruiser.Drawing_tools; +using WinF_Lab2_Cruiser.Entity_Folder; + +namespace WinF_Lab2_Cruiser +{ + public partial class FormTransportConfig : Form + { + private DrawingBase _cruiser; + + // private event Action? shipDelegate; + private event ShipDelegate? shipDelegate; + + public FormTransportConfig() + { + InitializeComponent(); + BlueP.MouseDown += Panel_MouseDown; + RedP.MouseDown += Panel_MouseDown; + PinkP.MouseDown += Panel_MouseDown; + YellowP.MouseDown += Panel_MouseDown; + CyanP.MouseDown += Panel_MouseDown; + PurpleP.MouseDown += Panel_MouseDown; + GreenP.MouseDown += Panel_MouseDown; + OrangeP.MouseDown += Panel_MouseDown; + CancelButton.Click += (sender, e) => Close(); + } + + public void AddEvent(ShipDelegate del)// Action delegator) + { + if (shipDelegate == null) shipDelegate = del; + else shipDelegate += del; + //shipDelegate += del; + } + + private void DrawObject() + { + Bitmap bmp = new(Showcase.Width, Showcase.Height); + Graphics gr = Graphics.FromImage(bmp); + _cruiser?.SetPicSize(Showcase.Width, Showcase.Height); + _cruiser?.SetPos(Showcase.Width - 400, Showcase.Height - 120); + _cruiser?.DrawTransport(gr); + Showcase.Image = bmp; + } + + private void Panel_MouseDown(object? sender, MouseEventArgs e) + { + // TODO отправка цвета в Drag&Drop + (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + + //private void FormTransportConfig_Load(object sender, EventArgs e) + //{ + // + //} + + private void BaseAdvLabel_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, 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 PanelObject_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data?.GetData(DataFormats.Text)?.ToString()) + { + case "BaseLabel": + _cruiser = new DrawingBase((int)SpeedN.Value, (double)WeightN.Value, Color.White); + break; + case "AdvLabel": + Random rn = new Random(); + _cruiser = new DrawingCruiser((int)SpeedN.Value, (double)WeightN.Value, + Color.White, Color.Black, CheckBox_Pads.Checked, CheckBox_Hangars.Checked, + rn.Next(1, 4), rn.Next(5, 10), rn.Next(1, 3)); + break; + } + labelMcolor.BackColor = Color.Empty; + labelAcolor.BackColor = Color.Empty; + DrawObject(); + } + + // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта) + private void BodyColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(Color))) e.Effect = DragDropEffects.Copy; + else e.Effect = DragDropEffects.None; + } + + private void BodyColor_DragDrop(object sender, DragEventArgs e) + { + if (_cruiser != null) + { + _cruiser.BaseEntity.setMColor((Color)e.Data.GetData(typeof(Color))); + DrawObject(); + } + } + + private void AdditionalColor_DragEnter(object sender, DragEventArgs e) + { + if (_cruiser is DrawingCruiser) + { + if (e.Data.GetDataPresent(typeof(Color))) e.Effect = DragDropEffects.Copy; + else e.Effect = DragDropEffects.None; + } + } + + private void AdditionalColor_DragDrop(object sender, DragEventArgs e) + { + if (_cruiser.BaseEntity is Class_CruiserEntity _ship) + { + _ship.setAdditionalColor((Color)e.Data.GetData(typeof(Color))); + } + DrawObject(); + } + + private void AddButton_Click(object sender, EventArgs e) + { + if (_cruiser != null) + { + shipDelegate?.Invoke(_cruiser); + Close(); + } + } + } +} diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.resx b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/FormTransportConfig.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/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/shipDelegate.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/shipDelegate.cs new file mode 100644 index 0000000..a52be11 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/shipDelegate.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WinF_Lab2_Cruiser.Drawing_tools; + +namespace WinF_Lab2_Cruiser +{ + public delegate void ShipDelegate(DrawingBase transport); +}