Tsukanova I.V. LabWork5 #7
@ -23,6 +23,10 @@ namespace AircraftCarrier
|
||||
{
|
||||
Warship = new EntityAircraftCarrier(speed, weight, bodyColor, dopColor, bodyKit, сabin, superEngine);
|
||||
}
|
||||
public void SetDopColor(Color color)
|
||||
{
|
||||
((EntityAircraftCarrier)Warship).DopColor = color;
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
@ -33,8 +37,6 @@ namespace AircraftCarrier
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush dopBrush = new SolidBrush(aircraftCarrier.DopColor);
|
||||
Brush brGray = new SolidBrush(Color.Gray);
|
||||
Brush brRed = new SolidBrush(Color.Red);
|
||||
Brush br = new SolidBrush(Warship?.BodyColor ?? Color.White);
|
||||
|
||||
if (aircraftCarrier.BodyKit)
|
||||
@ -62,22 +64,22 @@ namespace AircraftCarrier
|
||||
{
|
||||
pontStartLine1, pontStartLine2, pontStartLine3, pontStartLine4
|
||||
};
|
||||
g.FillPolygon(brGray, PointsStartLine);
|
||||
g.FillPolygon(dopBrush, PointsStartLine);
|
||||
g.DrawPolygon(pen, PointsStartLine);
|
||||
}
|
||||
|
||||
if (aircraftCarrier.SuperEngine)
|
||||
{
|
||||
g.FillEllipse(brRed, _startPosX, _startPosY, 10, 10);
|
||||
g.FillEllipse(dopBrush, _startPosX, _startPosY, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY, 10, 10);
|
||||
|
||||
g.FillEllipse(brRed, _startPosX, _startPosY + 10, 10, 10);
|
||||
g.FillEllipse(dopBrush, _startPosX, _startPosY + 10, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY + 10, 10, 10);
|
||||
|
||||
g.FillEllipse(brRed, _startPosX, _startPosY + 18, 10, 10);
|
||||
g.FillEllipse(dopBrush, _startPosX, _startPosY + 18, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY + 18, 10, 10);
|
||||
|
||||
g.FillEllipse(brRed, _startPosX, _startPosY + 30, 10, 10);
|
||||
g.FillEllipse(dopBrush, _startPosX, _startPosY + 30, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY + 30, 10, 10);
|
||||
}
|
||||
|
||||
@ -85,13 +87,13 @@ namespace AircraftCarrier
|
||||
|
||||
if (aircraftCarrier.Сabin)
|
||||
{
|
||||
g.FillEllipse(brGray, _startPosX + 10, _startPosY + 15, 10, 10);
|
||||
g.FillEllipse(dopBrush, _startPosX + 10, _startPosY + 15, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 15, 10, 10);
|
||||
|
||||
g.FillEllipse(brGray, _startPosX + 20, _startPosY + 15, 10, 10);
|
||||
g.FillEllipse(dopBrush, _startPosX + 20, _startPosY + 15, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX + 20, _startPosY + 15, 10, 10);
|
||||
|
||||
g.FillRectangle(brGray, _startPosX + 15, _startPosY + 15, 10, 10);
|
||||
g.FillRectangle(dopBrush, _startPosX + 15, _startPosY + 15, 10, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 15, _startPosY + 15, 10, 10);
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,8 @@ namespace AircraftCarrier
|
||||
_warshipWidth = warshipWidth;
|
||||
_warshipHeight = warshipHeight;
|
||||
}
|
||||
public void SetColor(Color color) => Warship.BodyColor = color;
|
||||
|
||||
/// <summary>
|
||||
/// Установка позиции военного корабля
|
||||
/// </summary>
|
||||
|
@ -11,7 +11,7 @@ namespace AircraftCarrier
|
||||
/// <summary>
|
||||
/// Дополнительный цвет
|
||||
/// </summary>
|
||||
public Color DopColor { get; private set; }
|
||||
public Color DopColor { get; set; }
|
||||
/// <summary>
|
||||
/// Признак наличия боковой площадки
|
||||
/// </summary>
|
||||
|
@ -22,7 +22,7 @@ namespace AircraftCarrier
|
||||
/// <summary>
|
||||
/// Цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения
|
||||
/// </summary>
|
||||
|
@ -114,9 +114,33 @@ namespace AircraftCarrier
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddWarship_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formCarConfig = new FormCarConfig();
|
||||
// TODO Call method AddEvent from formCarConfig
|
||||
formCarConfig.Show();
|
||||
var formWarshipConfig = new FormWarshipConfig();
|
||||
formWarshipConfig.AddEvent(AddWarshipOnForm);
|
||||
formWarshipConfig.Show();
|
||||
}
|
||||
/// <summary>
|
||||
/// добавление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void AddWarshipOnForm(DrawingWarship drawningWarship)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DrawingObjectWarship warship = new(drawningWarship);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship >= 0)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace AircraftCarrier
|
||||
{
|
||||
partial class FormCarConfig
|
||||
partial class FormWarshipConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -89,7 +89,7 @@
|
||||
this.labelModifiedObject.TabIndex = 16;
|
||||
this.labelModifiedObject.Text = "Advanced";
|
||||
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelObject_MouseDown);
|
||||
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
@ -100,7 +100,7 @@
|
||||
this.labelSimpleObject.TabIndex = 15;
|
||||
this.labelSimpleObject.Text = "Simple";
|
||||
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelObject_MouseDown);
|
||||
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
@ -292,6 +292,7 @@
|
||||
this.buttonOk.TabIndex = 7;
|
||||
this.buttonOk.Text = "Add";
|
||||
this.buttonOk.UseVisualStyleBackColor = true;
|
||||
this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
@ -316,6 +317,8 @@
|
||||
this.labelDopColor.TabIndex = 2;
|
||||
this.labelDopColor.Text = "DopColor";
|
||||
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
|
||||
this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter);
|
||||
//
|
||||
// labelBaseColor
|
||||
//
|
||||
@ -327,6 +330,8 @@
|
||||
this.labelBaseColor.TabIndex = 1;
|
||||
this.labelBaseColor.Text = "Color";
|
||||
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop);
|
||||
this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter);
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
@ -336,7 +341,7 @@
|
||||
this.pictureBoxObject.TabIndex = 0;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// FormCarConfig
|
||||
// FormWarshipConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
@ -345,7 +350,7 @@
|
||||
this.Controls.Add(this.buttonOk);
|
||||
this.Controls.Add(this.panelObject);
|
||||
this.Controls.Add(this.groupBoxConfig);
|
||||
this.Name = "FormCarConfig";
|
||||
this.Name = "FormWarshipConfig";
|
||||
this.Text = "Creating object";
|
||||
this.groupBoxConfig.ResumeLayout(false);
|
||||
this.groupBoxConfig.PerformLayout();
|
@ -10,7 +10,7 @@ using System.Windows.Forms;
|
||||
|
||||
namespace AircraftCarrier
|
||||
{
|
||||
public partial class FormCarConfig : Form
|
||||
public partial class FormWarshipConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранный корабль
|
||||
@ -23,7 +23,7 @@ namespace AircraftCarrier
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormCarConfig()
|
||||
public FormWarshipConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
@ -34,6 +34,8 @@ namespace AircraftCarrier
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
|
||||
buttonCancel.Click += (sender, e) => Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовать корабль
|
||||
@ -66,7 +68,7 @@ namespace AircraftCarrier
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void labelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
@ -137,7 +139,9 @@ namespace AircraftCarrier
|
||||
/// <param name="e"></param>
|
||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
// TODO Call method from object _car and set color
|
||||
Color color = (Color)e.Data.GetData(typeof(Color));
|
||||
_warship.SetColor(color);
|
||||
DrawingWarship();
|
||||
}
|
||||
/// <summary>
|
||||
/// Принимаем дополнительный цвет
|
||||
@ -146,7 +150,12 @@ namespace AircraftCarrier
|
||||
/// <param name="e"></param>
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
// TODO Call method from object _car if _car is DrawningSportCar and set dop color
|
||||
Color dopColor = (Color)e.Data.GetData(typeof(Color));
|
||||
if (_warship is DrawingAircraftCarrier aircraftCarrier)
|
||||
{
|
||||
aircraftCarrier.SetDopColor(dopColor);
|
||||
DrawingWarship();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление корабля
|
Loading…
Reference in New Issue
Block a user