настройка формы, корректировка коллекции удалённых элементов.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
/// <summary>
|
||||
/// Объект от класса отрисовки локомотива
|
||||
/// </summary>
|
||||
private DrawningLocomotive _locomotive = null;
|
||||
public DrawningLocomotive _locomotive { get; private set; }
|
||||
public DrawningObjectLocomotive(DrawningLocomotive locomotive)
|
||||
{
|
||||
_locomotive = locomotive;
|
||||
|
||||
@@ -16,9 +16,19 @@
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// Конструктор для вызова формы с готовым объектом
|
||||
/// </summary>
|
||||
/// <param name=""></param>
|
||||
/// <param name=""></param>
|
||||
public FormLocomotive(DrawningLocomotive drawningObject)
|
||||
{
|
||||
_locomotive = drawningObject;
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод отрисовки локомотива
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
public void Draw()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
@@ -132,10 +142,5 @@
|
||||
SelectedLocomotive = _locomotive;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void buttonGenerateEntities_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonAddCar = new System.Windows.Forms.Button();
|
||||
this.pictureBoxLocomotives = new System.Windows.Forms.PictureBox();
|
||||
this.buttonShowLastRemovedObject = new System.Windows.Forms.Button();
|
||||
this.groupBoxTools.SuspendLayout();
|
||||
this.groupBoxMaps.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotives)).BeginInit();
|
||||
@@ -52,6 +53,7 @@
|
||||
//
|
||||
// groupBoxTools
|
||||
//
|
||||
this.groupBoxTools.Controls.Add(this.buttonShowLastRemovedObject);
|
||||
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
|
||||
this.groupBoxTools.Controls.Add(this.buttonUp);
|
||||
this.groupBoxTools.Controls.Add(this.buttonDown);
|
||||
@@ -240,6 +242,16 @@
|
||||
this.pictureBoxLocomotives.TabIndex = 1;
|
||||
this.pictureBoxLocomotives.TabStop = false;
|
||||
//
|
||||
// buttonShowLastRemovedObject
|
||||
//
|
||||
this.buttonShowLastRemovedObject.Location = new System.Drawing.Point(31, 517);
|
||||
this.buttonShowLastRemovedObject.Name = "buttonShowLastRemovedObject";
|
||||
this.buttonShowLastRemovedObject.Size = new System.Drawing.Size(164, 40);
|
||||
this.buttonShowLastRemovedObject.TabIndex = 2;
|
||||
this.buttonShowLastRemovedObject.Text = "Показать последний удалённый элемент";
|
||||
this.buttonShowLastRemovedObject.UseVisualStyleBackColor = true;
|
||||
this.buttonShowLastRemovedObject.Click += new System.EventHandler(this.ButtonShowLastRemovedObject_Click);
|
||||
//
|
||||
// FormMapWithSetLocomotives
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
@@ -277,5 +289,6 @@
|
||||
private ListBox listBoxMaps;
|
||||
private Button buttonAddMap;
|
||||
private TextBox textBoxNewMapName;
|
||||
private Button buttonShowLastRemovedObject;
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
IDrawningObject removableObject = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos;
|
||||
DrawningObjectLocomotive removableObject = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos;
|
||||
if (removableObject != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
@@ -221,5 +221,20 @@
|
||||
}
|
||||
pictureBoxLocomotives.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||
}
|
||||
/// <summary>
|
||||
/// Вызов формы с последним удалённым элементом
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowLastRemovedObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapsCollection.RemovedObject == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormLocomotive formWithLastRemovedObject = new(_mapsCollection.RemovedObject._locomotive);
|
||||
formWithLastRemovedObject.Show();
|
||||
formWithLastRemovedObject.Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
_mapStorages = new Dictionary<string, MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
_removedObjects = new LinkedList<DrawningObjectLocomotive>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление карты
|
||||
@@ -90,11 +91,11 @@
|
||||
/// <summary>
|
||||
/// Коллекция удалённых объектов
|
||||
/// </summary>
|
||||
private LinkedList<IDrawningObject> _removedObjects;
|
||||
private LinkedList<DrawningObjectLocomotive> _removedObjects;
|
||||
/// <summary>
|
||||
/// Свойство для заполнения коллекции (добавляем в конец, и получаем из конца)
|
||||
/// </summary>
|
||||
public IDrawningObject RemovedObject
|
||||
public DrawningObjectLocomotive RemovedObject
|
||||
{
|
||||
set
|
||||
{
|
||||
@@ -102,6 +103,10 @@
|
||||
}
|
||||
get
|
||||
{
|
||||
if (_removedObjects.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _removedObjects.Last.Value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user