ISEbd-21 Nikolay Gapon LabWork04 HARD #4

Closed
NikGapon wants to merge 3 commits from LabWork04 into LabWork03
7 changed files with 62 additions and 6 deletions
Showing only changes of commit 9ccb83c58d - Show all commits

View File

@ -133,4 +133,4 @@ namespace Airbus
}
}
}
}

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Airbus
{
internal class DrawningObjectAirplane : IDrawningObject
public class DrawningObjectAirplane : IDrawningObject
{
private DrawningAirplane _airplane = null;
@ -31,5 +31,6 @@ namespace Airbus
{
_airplane?.SetPosition(x, y, width, height);
}
public static explicit operator DrawningAirplane(DrawningObjectAirplane drawningObject) => drawningObject._airplane;
}
}

View File

@ -16,9 +16,15 @@ namespace Airbus
private DrawningAirplane airplane;
public DrawningAirplane SelectedAirplane { get; private set; }
public FormAirplane()
public FormAirplane(DrawningAirplane? goairplane = null)
{
airplane = goairplane;
InitializeComponent();
if (goairplane != null)
{
SetData();
Draw();
}
}
private void Draw()

View File

@ -46,6 +46,7 @@
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
this.buttonAddAirplane = new System.Windows.Forms.Button();
this.pictureBox = new System.Windows.Forms.PictureBox();
this.buttonRemoveFromTrashcan = new System.Windows.Forms.Button();
this.groupBoxTools.SuspendLayout();
this.groupBoxMaps.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
@ -53,6 +54,7 @@
//
// groupBoxTools
//
this.groupBoxTools.Controls.Add(this.buttonRemoveFromTrashcan);
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
this.groupBoxTools.Controls.Add(this.buttonAddAirplaneWithPar);
this.groupBoxTools.Controls.Add(this.buttonDown);
@ -195,7 +197,7 @@
//
// 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.Size = new System.Drawing.Size(75, 23);
this.buttonShowOnMap.TabIndex = 5;
@ -205,7 +207,7 @@
//
// 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.Size = new System.Drawing.Size(188, 23);
this.buttonStorage.TabIndex = 4;
@ -250,6 +252,16 @@
this.pictureBox.TabIndex = 1;
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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@ -286,5 +298,6 @@
private Button buttonDelMap;
private Button buttonAddMap;
private TextBox textBoxNewMapName;
private Button buttonRemoveFromTrashcan;
}
}

View File

@ -22,6 +22,7 @@ namespace Airbus
/// Объект от коллекции карт
/// </summary>
private readonly MapsCollection _mapsCollection;
private LinkedList<DrawningObjectAirplane> trashcan;
/// <summary>
/// Конструктор
/// </summary>
@ -30,6 +31,7 @@ namespace Airbus
InitializeComponent();
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
comboBoxSelectorMap.Items.Clear();
trashcan = new();
foreach (var elem in _mapsDict)
{
comboBoxSelectorMap.Items.Add(elem.Key);
@ -144,8 +146,11 @@ namespace Airbus
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
var delObject = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty, pos];
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
{
trashcan.AddLast(delObject);
MessageBox.Show("Объект удален");
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("Не удалось добавить объект");
}
}
}
}
}

View File

@ -29,7 +29,7 @@ namespace Airbus
/// <summary>
/// Набор объектов
/// </summary>
private readonly SetAirplaneGeneric<T> _setAirplane;
public SetAirplaneGeneric<T> _setAirplane { get; private set; }
/// <summary>
/// Карта
/// </summary>

View File

@ -67,5 +67,13 @@ namespace Airbus
return null;
}
}
public DrawningObjectAirplane this[string ind, int indDrawningObject]
{
get
{
_mapStorages.TryGetValue(ind, out var returnAirplane);
return returnAirplane?._setAirplane[indDrawningObject];
}
}
}
}