lab 4 complete
This commit is contained in:
parent
f3fb6e9fec
commit
9ccb83c58d
@ -133,4 +133,4 @@ namespace Airbus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Airbus
|
namespace Airbus
|
||||||
{
|
{
|
||||||
internal class DrawningObjectAirplane : IDrawningObject
|
public class DrawningObjectAirplane : IDrawningObject
|
||||||
{
|
{
|
||||||
private DrawningAirplane _airplane = null;
|
private DrawningAirplane _airplane = null;
|
||||||
|
|
||||||
@ -31,5 +31,6 @@ namespace Airbus
|
|||||||
{
|
{
|
||||||
_airplane?.SetPosition(x, y, width, height);
|
_airplane?.SetPosition(x, y, width, height);
|
||||||
}
|
}
|
||||||
|
public static explicit operator DrawningAirplane(DrawningObjectAirplane drawningObject) => drawningObject._airplane;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,15 @@ namespace Airbus
|
|||||||
private DrawningAirplane airplane;
|
private DrawningAirplane airplane;
|
||||||
public DrawningAirplane SelectedAirplane { get; private set; }
|
public DrawningAirplane SelectedAirplane { get; private set; }
|
||||||
|
|
||||||
public FormAirplane()
|
public FormAirplane(DrawningAirplane? goairplane = null)
|
||||||
{
|
{
|
||||||
|
airplane = goairplane;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
if (goairplane != null)
|
||||||
|
{
|
||||||
|
SetData();
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Draw()
|
private void Draw()
|
||||||
|
17
Airbus/Airbus/FormMapWithSetAirplane.Designer.cs
generated
17
Airbus/Airbus/FormMapWithSetAirplane.Designer.cs
generated
@ -46,6 +46,7 @@
|
|||||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||||
this.buttonAddAirplane = new System.Windows.Forms.Button();
|
this.buttonAddAirplane = new System.Windows.Forms.Button();
|
||||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
|
this.buttonRemoveFromTrashcan = new System.Windows.Forms.Button();
|
||||||
this.groupBoxTools.SuspendLayout();
|
this.groupBoxTools.SuspendLayout();
|
||||||
this.groupBoxMaps.SuspendLayout();
|
this.groupBoxMaps.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
@ -53,6 +54,7 @@
|
|||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonRemoveFromTrashcan);
|
||||||
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
|
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonAddAirplaneWithPar);
|
this.groupBoxTools.Controls.Add(this.buttonAddAirplaneWithPar);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonDown);
|
this.groupBoxTools.Controls.Add(this.buttonDown);
|
||||||
@ -195,7 +197,7 @@
|
|||||||
//
|
//
|
||||||
// buttonShowOnMap
|
// buttonShowOnMap
|
||||||
//
|
//
|
||||||
this.buttonShowOnMap.Location = new System.Drawing.Point(62, 370);
|
this.buttonShowOnMap.Location = new System.Drawing.Point(60, 399);
|
||||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||||
this.buttonShowOnMap.Size = new System.Drawing.Size(75, 23);
|
this.buttonShowOnMap.Size = new System.Drawing.Size(75, 23);
|
||||||
this.buttonShowOnMap.TabIndex = 5;
|
this.buttonShowOnMap.TabIndex = 5;
|
||||||
@ -205,7 +207,7 @@
|
|||||||
//
|
//
|
||||||
// buttonStorage
|
// buttonStorage
|
||||||
//
|
//
|
||||||
this.buttonStorage.Location = new System.Drawing.Point(6, 399);
|
this.buttonStorage.Location = new System.Drawing.Point(6, 428);
|
||||||
this.buttonStorage.Name = "buttonStorage";
|
this.buttonStorage.Name = "buttonStorage";
|
||||||
this.buttonStorage.Size = new System.Drawing.Size(188, 23);
|
this.buttonStorage.Size = new System.Drawing.Size(188, 23);
|
||||||
this.buttonStorage.TabIndex = 4;
|
this.buttonStorage.TabIndex = 4;
|
||||||
@ -250,6 +252,16 @@
|
|||||||
this.pictureBox.TabIndex = 1;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.pictureBox.TabStop = false;
|
this.pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// buttonRemoveFromTrashcan
|
||||||
|
//
|
||||||
|
this.buttonRemoveFromTrashcan.Location = new System.Drawing.Point(6, 370);
|
||||||
|
this.buttonRemoveFromTrashcan.Name = "buttonRemoveFromTrashcan";
|
||||||
|
this.buttonRemoveFromTrashcan.Size = new System.Drawing.Size(182, 23);
|
||||||
|
this.buttonRemoveFromTrashcan.TabIndex = 11;
|
||||||
|
this.buttonRemoveFromTrashcan.Text = "Вернуть с корзины";
|
||||||
|
this.buttonRemoveFromTrashcan.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRemoveFromTrashcan.Click += new System.EventHandler(this.buttonRemoveFromTrashcan_Click);
|
||||||
|
//
|
||||||
// FormMapWithSetAirplane
|
// FormMapWithSetAirplane
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
@ -286,5 +298,6 @@
|
|||||||
private Button buttonDelMap;
|
private Button buttonDelMap;
|
||||||
private Button buttonAddMap;
|
private Button buttonAddMap;
|
||||||
private TextBox textBoxNewMapName;
|
private TextBox textBoxNewMapName;
|
||||||
|
private Button buttonRemoveFromTrashcan;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,6 +22,7 @@ namespace Airbus
|
|||||||
/// Объект от коллекции карт
|
/// Объект от коллекции карт
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly MapsCollection _mapsCollection;
|
private readonly MapsCollection _mapsCollection;
|
||||||
|
private LinkedList<DrawningObjectAirplane> trashcan;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -30,6 +31,7 @@ namespace Airbus
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||||
comboBoxSelectorMap.Items.Clear();
|
comboBoxSelectorMap.Items.Clear();
|
||||||
|
trashcan = new();
|
||||||
foreach (var elem in _mapsDict)
|
foreach (var elem in _mapsDict)
|
||||||
{
|
{
|
||||||
comboBoxSelectorMap.Items.Add(elem.Key);
|
comboBoxSelectorMap.Items.Add(elem.Key);
|
||||||
@ -144,8 +146,11 @@ namespace Airbus
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
|
var delObject = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty, pos];
|
||||||
|
|
||||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||||
{
|
{
|
||||||
|
trashcan.AddLast(delObject);
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
@ -233,5 +238,28 @@ namespace Airbus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buttonRemoveFromTrashcan_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1 || trashcan.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FormAirplane form = new((DrawningAirplane)trashcan.First());
|
||||||
|
trashcan.RemoveFirst();
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
DrawningObjectAirplane airplane = new(form.SelectedAirplane);
|
||||||
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + airplane > -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace Airbus
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Набор объектов
|
/// Набор объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly SetAirplaneGeneric<T> _setAirplane;
|
public SetAirplaneGeneric<T> _setAirplane { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Карта
|
/// Карта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -67,5 +67,13 @@ namespace Airbus
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public DrawningObjectAirplane this[string ind, int indDrawningObject]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
_mapStorages.TryGetValue(ind, out var returnAirplane);
|
||||||
|
return returnAirplane?._setAirplane[indDrawningObject];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user