Конец шестой
This commit is contained in:
parent
7dfb6b2606
commit
e785755a98
@ -97,7 +97,7 @@ namespace ProjectTractor.DrawningObjects
|
||||
|
||||
public void ChangeAdditionalColor(Color color)
|
||||
{
|
||||
((EntityBulldoser)EntityTractor).AdditionalColor = color;
|
||||
((EntityBulldoser)EntityTractor).setAdditionalColor(color);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ namespace ProjectTractor.DrawningObjects {
|
||||
{
|
||||
return;
|
||||
}
|
||||
EntityTractor.BodyColor = color;
|
||||
EntityTractor.setBodyColor(color);
|
||||
}
|
||||
|
||||
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
|
||||
|
@ -14,7 +14,7 @@ namespace ProjectTractor.Entities
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; set; }
|
||||
public Color AdditionalColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия обвеса
|
||||
/// </summary>
|
||||
@ -41,6 +41,11 @@ namespace ProjectTractor.Entities
|
||||
WheelsOrnament = wheelsOrnament;
|
||||
Blade = blade;
|
||||
}
|
||||
|
||||
public void setAdditionalColor(Color color)
|
||||
{
|
||||
AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace ProjectTractor.Entities
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения автомобиля
|
||||
/// </summary>
|
||||
@ -39,5 +39,10 @@ namespace ProjectTractor.Entities
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
public void setBodyColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace ProjectTractor.DrawningObjects
|
||||
return new DrawningTractor(Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
||||
}
|
||||
if (strs.Length == 7)
|
||||
if (strs.Length == 6)
|
||||
{
|
||||
return new DrawningBulldoser(Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]),
|
||||
@ -43,7 +43,7 @@ namespace ProjectTractor.DrawningObjects
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл
|
||||
/// </summary>
|
||||
/// <param name="drawningTractor">Сохраняемый объект</param>
|
||||
/// <param name="drawingTractor">Сохраняемый объект</param>
|
||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||
/// <returns>Строка с данными по объекту</returns>
|
||||
public static string GetDataForSave(this DrawningTractor drawningTractor,
|
||||
@ -54,15 +54,13 @@ namespace ProjectTractor.DrawningObjects
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var str =
|
||||
$"{tractor.Speed}{separatorForObject}{tractor.Weight}{separatorForObject}{tractor.BodyColor.Name}";
|
||||
var str = $"{tractor.Speed}{separatorForObject}{tractor.Weight}{separatorForObject}{tractor.BodyColor.Name}";
|
||||
if (tractor is not EntityBulldoser bulldoser)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return
|
||||
$"{str}{separatorForObject}{bulldoser.AdditionalColor.Name}{separatorForObject}{bulldoser.Blade}{separatorForObject}{bulldoser.WheelsOrnament}";
|
||||
$"{str}{separatorForObject}{bulldoser.AdditionalColor.Name}{separatorForObject}{bulldoser.WheelsOrnament}{separatorForObject}{bulldoser.Blade}";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ namespace ProjectTractor
|
||||
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
|
||||
listBoxStorages.SelectedItems.Clear();
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
@ -185,6 +186,52 @@ namespace ProjectTractor
|
||||
}
|
||||
pictureBoxCollection.Image = obj.ShowTractors();
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия "Сохранение"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void toolStripMenuItemSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_storage.SaveData(saveFileDialog.FileName))
|
||||
{
|
||||
MessageBox.Show("Сохранение прошло успешно",
|
||||
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не сохранилось", "Результат",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия "Загрузка"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void toolStripMenuItemload_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_storage.LoadData(openFileDialog.FileName))
|
||||
{
|
||||
MessageBox.Show("Загрузка прошла успешно",
|
||||
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
foreach (var collection in _storage.Keys)
|
||||
{
|
||||
listBoxStorages.Items.Add(collection);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось загрузить", "Результат",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||
@ -198,9 +245,15 @@ namespace ProjectTractor
|
||||
this.ButtonRemoveTractor = new System.Windows.Forms.Button();
|
||||
this.ButtonAddTractor = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
|
||||
this.file = new System.Windows.Forms.MenuStrip();
|
||||
this.toolStripMenuItemSave = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemload = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||
this.groupBox.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.file.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxCollection
|
||||
@ -208,7 +261,7 @@ namespace ProjectTractor
|
||||
this.pictureBoxCollection.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(620, 536);
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(620, 532);
|
||||
this.pictureBoxCollection.TabIndex = 1;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
@ -219,9 +272,10 @@ namespace ProjectTractor
|
||||
this.groupBox.Controls.Add(this.ButtonRemoveTractor);
|
||||
this.groupBox.Controls.Add(this.ButtonAddTractor);
|
||||
this.groupBox.Controls.Add(this.maskedTextBoxNumber);
|
||||
this.groupBox.Controls.Add(this.file);
|
||||
this.groupBox.Location = new System.Drawing.Point(626, 12);
|
||||
this.groupBox.Name = "groupBox";
|
||||
this.groupBox.Size = new System.Drawing.Size(255, 522);
|
||||
this.groupBox.Size = new System.Drawing.Size(255, 524);
|
||||
this.groupBox.TabIndex = 2;
|
||||
this.groupBox.TabStop = false;
|
||||
this.groupBox.Text = "Инструменты";
|
||||
@ -232,7 +286,7 @@ namespace ProjectTractor
|
||||
this.groupBox1.Controls.Add(this.listBoxStorages);
|
||||
this.groupBox1.Controls.Add(this.ButtonAddObject);
|
||||
this.groupBox1.Controls.Add(this.textBoxStorageName);
|
||||
this.groupBox1.Location = new System.Drawing.Point(16, 29);
|
||||
this.groupBox1.Location = new System.Drawing.Point(16, 54);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(224, 279);
|
||||
this.groupBox1.TabIndex = 9;
|
||||
@ -278,7 +332,7 @@ namespace ProjectTractor
|
||||
//
|
||||
// ButtonRefreshCollection
|
||||
//
|
||||
this.ButtonRefreshCollection.Location = new System.Drawing.Point(28, 464);
|
||||
this.ButtonRefreshCollection.Location = new System.Drawing.Point(28, 463);
|
||||
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||
this.ButtonRefreshCollection.Size = new System.Drawing.Size(203, 35);
|
||||
this.ButtonRefreshCollection.TabIndex = 8;
|
||||
@ -288,7 +342,7 @@ namespace ProjectTractor
|
||||
//
|
||||
// ButtonRemoveTractor
|
||||
//
|
||||
this.ButtonRemoveTractor.Location = new System.Drawing.Point(28, 390);
|
||||
this.ButtonRemoveTractor.Location = new System.Drawing.Point(28, 410);
|
||||
this.ButtonRemoveTractor.Name = "ButtonRemoveTractor";
|
||||
this.ButtonRemoveTractor.Size = new System.Drawing.Size(203, 33);
|
||||
this.ButtonRemoveTractor.TabIndex = 7;
|
||||
@ -298,7 +352,7 @@ namespace ProjectTractor
|
||||
//
|
||||
// ButtonAddTractor
|
||||
//
|
||||
this.ButtonAddTractor.Location = new System.Drawing.Point(28, 317);
|
||||
this.ButtonAddTractor.Location = new System.Drawing.Point(28, 337);
|
||||
this.ButtonAddTractor.Name = "ButtonAddTractor";
|
||||
this.ButtonAddTractor.Size = new System.Drawing.Size(203, 34);
|
||||
this.ButtonAddTractor.TabIndex = 6;
|
||||
@ -308,14 +362,49 @@ namespace ProjectTractor
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(28, 357);
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(28, 377);
|
||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(203, 27);
|
||||
this.maskedTextBoxNumber.TabIndex = 5;
|
||||
//
|
||||
// file
|
||||
//
|
||||
this.file.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.file.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItemSave,
|
||||
this.toolStripMenuItemload});
|
||||
this.file.Location = new System.Drawing.Point(3, 23);
|
||||
this.file.Name = "file";
|
||||
this.file.Size = new System.Drawing.Size(249, 28);
|
||||
this.file.TabIndex = 10;
|
||||
this.file.Text = "файл";
|
||||
//
|
||||
// toolStripMenuItemSave
|
||||
//
|
||||
this.toolStripMenuItemSave.Name = "toolStripMenuItemSave";
|
||||
this.toolStripMenuItemSave.Size = new System.Drawing.Size(97, 24);
|
||||
this.toolStripMenuItemSave.Text = "Сохранить";
|
||||
this.toolStripMenuItemSave.Click += new System.EventHandler(this.toolStripMenuItemSave_Click);
|
||||
//
|
||||
// toolStripMenuItemload
|
||||
//
|
||||
this.toolStripMenuItemload.Name = "toolStripMenuItemload";
|
||||
this.toolStripMenuItemload.Size = new System.Drawing.Size(83, 24);
|
||||
this.toolStripMenuItemload.Text = "Загрузка";
|
||||
this.toolStripMenuItemload.Click += new System.EventHandler(this.toolStripMenuItemload_Click);
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.FileName = "openFileDialog";
|
||||
this.openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormTractorCollection
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(893, 536);
|
||||
this.ClientSize = new System.Drawing.Size(893, 532);
|
||||
this.Controls.Add(this.groupBox);
|
||||
this.Controls.Add(this.pictureBoxCollection);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
@ -328,6 +417,8 @@ namespace ProjectTractor
|
||||
this.groupBox.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.file.ResumeLayout(false);
|
||||
this.file.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -342,6 +433,11 @@ namespace ProjectTractor
|
||||
private ListBox listBoxStorages;
|
||||
private Button ButtonAddObject;
|
||||
private MaskedTextBox textBoxStorageName;
|
||||
private MenuStrip file;
|
||||
private ToolStripMenuItem toolStripMenuItemSave;
|
||||
private ToolStripMenuItem toolStripMenuItemload;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private PictureBox pictureBoxCollection;
|
||||
}
|
||||
}
|
||||
|
@ -57,4 +57,16 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="file.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>94, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>261, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
</metadata>
|
||||
</root>
|
@ -86,6 +86,10 @@ namespace ProjectTractor.Generics
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объектов коллекции
|
||||
/// </summary>
|
||||
public IEnumerable<T?> GetCars => _collection.GetTractors();
|
||||
/// <summary>
|
||||
/// Получение объекта IMoveableObject
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
@ -144,6 +148,7 @@ namespace ProjectTractor.Generics
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,11 +124,11 @@ namespace ProjectTractor
|
||||
fs.Write(info, 0, info.Length);
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка информации по автомобилям в хранилище из файла
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||
/// <summary>
|
||||
/// Загрузка информации по автомобилям в хранилище из файла
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
|
3
RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/набор №1.txt
Normal file
3
RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/набор №1.txt
Normal file
@ -0,0 +1,3 @@
|
||||
TractorStorage
|
||||
апр|100:100:White;100:100:ff0000c0:Yellow:True:True;
|
||||
fff|100:100:White:Yellow:False:True;100:100:White:Black:False:True;
|
Loading…
Reference in New Issue
Block a user