Compare commits
1 Commits
LabWork_07
...
LabWork_03
| Author | SHA1 | Date | |
|---|---|---|---|
| 172e62e1f3 |
@@ -119,10 +119,5 @@ namespace WarmlyShip
|
||||
{
|
||||
return (_startPosX, _startPosX + _warmlyShipWidth, _startPosY, _startPosY + _warmlyShipHeight);
|
||||
}
|
||||
|
||||
public DrawingWarmlyShip ModifShip(int? speed = null, float? weight = null, Color? bodyColor = null)
|
||||
{
|
||||
return new DrawingWarmlyShip(speed ?? warmlyShip.Speed, weight ?? warmlyShip.Weight, bodyColor ?? warmlyShip.BodyColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,10 +40,5 @@ namespace WarmlyShip
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY + 25, 25, 20);
|
||||
}
|
||||
}
|
||||
|
||||
public DrawningMotorShip ModifShip(int? speed = null, float? weight = null, Color? bodyColor = null, Color? dopColor = null, bool? tubes = null, bool? cistern = null)
|
||||
{
|
||||
return new DrawningMotorShip(speed ?? warmlyShip.Speed, weight ?? warmlyShip.Weight, bodyColor ?? warmlyShip.BodyColor, dopColor ?? ((EntityMotorShip)warmlyShip).DopColor, tubes ?? ((EntityMotorShip)warmlyShip).Tubes, cistern ?? ((EntityMotorShip)warmlyShip).Cistern);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,9 +36,5 @@ namespace WarmlyShip
|
||||
{
|
||||
_warmlyShip?.SetPosition(x, y, width, height);
|
||||
}
|
||||
|
||||
public string GetInfo() => _warmlyShip?.GetDataForSave();
|
||||
|
||||
public static IDrawningObject Create(string data) => new DrawningObjectShip(data.CreateDrawningShip());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace WarmlyShip
|
||||
public EntityWarmlyShip(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random random = new Random();
|
||||
Speed = speed <= 0 ? random.Next(100, 300) : speed;
|
||||
Weight = weight <= 0 ? random.Next(1000, 2000) : weight;
|
||||
Speed = speed <= 0 ? random.Next(50, 150) : speed;
|
||||
Weight = weight <= 0 ? random.Next(40, 70) : weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
internal static class ExtentionShip
|
||||
{
|
||||
|
||||
private static readonly char _separatorForObject = ':';
|
||||
|
||||
public static DrawingWarmlyShip CreateDrawningShip(this string info)
|
||||
{
|
||||
string[] strs = info.Split(_separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawingWarmlyShip(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]));
|
||||
}
|
||||
if (strs.Length == 6)
|
||||
{
|
||||
return new DrawningMotorShip(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5]));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetDataForSave(this DrawingWarmlyShip warmlyShip)
|
||||
{
|
||||
var ship = warmlyShip.warmlyShip;
|
||||
var str = $"{ship.Speed}{_separatorForObject}{ship.Weight}{_separatorForObject}{ship.BodyColor.Name}";
|
||||
if (ship is not EntityMotorShip motorShip)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return $"{str}{_separatorForObject}{motorShip.DopColor.Name}{_separatorForObject}{motorShip.Tubes}{_separatorForObject}{motorShip.Cistern}";
|
||||
}
|
||||
}
|
||||
}
|
||||
75
WarmlyShip/WarmlyShip/FormMapWithSetShip.Designer.cs
generated
75
WarmlyShip/WarmlyShip/FormMapWithSetShip.Designer.cs
generated
@@ -45,16 +45,9 @@
|
||||
this.buttonRemoveShip = new System.Windows.Forms.Button();
|
||||
this.buttonAddShip = new System.Windows.Forms.Button();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.файлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBoxMaps.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
@@ -70,9 +63,9 @@
|
||||
this.groupBox1.Controls.Add(this.buttonRemoveShip);
|
||||
this.groupBox1.Controls.Add(this.buttonAddShip);
|
||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBox1.Location = new System.Drawing.Point(815, 24);
|
||||
this.groupBox1.Location = new System.Drawing.Point(815, 0);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(200, 624);
|
||||
this.groupBox1.Size = new System.Drawing.Size(200, 648);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Инструменты";
|
||||
@@ -139,6 +132,7 @@
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(176, 23);
|
||||
this.comboBoxSelectorMap.TabIndex = 0;
|
||||
//this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
@@ -153,7 +147,7 @@
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::WarmlyShip.Properties.Resources.todown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(75, 565);
|
||||
this.buttonDown.Location = new System.Drawing.Point(75, 589);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(50, 50);
|
||||
this.buttonDown.TabIndex = 10;
|
||||
@@ -165,7 +159,7 @@
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::WarmlyShip.Properties.Resources.toleft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(19, 565);
|
||||
this.buttonLeft.Location = new System.Drawing.Point(19, 589);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(50, 50);
|
||||
this.buttonLeft.TabIndex = 9;
|
||||
@@ -177,7 +171,7 @@
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::WarmlyShip.Properties.Resources.totop;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(75, 509);
|
||||
this.buttonUp.Location = new System.Drawing.Point(75, 533);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(50, 50);
|
||||
this.buttonUp.TabIndex = 8;
|
||||
@@ -189,7 +183,7 @@
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::WarmlyShip.Properties.Resources.toright;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(131, 565);
|
||||
this.buttonRight.Location = new System.Drawing.Point(131, 589);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(50, 50);
|
||||
this.buttonRight.TabIndex = 7;
|
||||
@@ -239,52 +233,12 @@
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 24);
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(815, 624);
|
||||
this.pictureBox.Size = new System.Drawing.Size(815, 648);
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.файлToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(1015, 24);
|
||||
this.menuStrip.TabIndex = 2;
|
||||
//
|
||||
// файлToolStripMenuItem
|
||||
//
|
||||
this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SaveToolStripMenuItem,
|
||||
this.LoadToolStripMenuItem});
|
||||
this.файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||
this.файлToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
|
||||
this.файлToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.SaveToolStripMenuItem.Text = "Сохранение";
|
||||
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
||||
//
|
||||
// LoadToolStripMenuItem
|
||||
//
|
||||
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.LoadToolStripMenuItem.Text = "Загрузка";
|
||||
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormMapWithSetShip
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
@@ -292,8 +246,6 @@
|
||||
this.ClientSize = new System.Drawing.Size(1015, 648);
|
||||
this.Controls.Add(this.pictureBox);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Name = "FormMapWithSetShip";
|
||||
this.Text = "FormMapWithSetShip";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
@@ -301,10 +253,7 @@
|
||||
this.groupBoxMaps.ResumeLayout(false);
|
||||
this.groupBoxMaps.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@@ -327,11 +276,5 @@
|
||||
private ListBox listBoxMaps;
|
||||
private Button buttonAddMap;
|
||||
private TextBox textBoxNewMapName;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem файлToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@@ -24,12 +23,9 @@ namespace WarmlyShip
|
||||
|
||||
private readonly MapsCollection _mapsCollection;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public FormMapWithSetShip(ILogger<FormMapWithSetShip> logger)
|
||||
public FormMapWithSetShip()
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||
comboBoxSelectorMap.Items.Clear();
|
||||
foreach (var elem in _mapsDict)
|
||||
@@ -70,7 +66,6 @@ namespace WarmlyShip
|
||||
}
|
||||
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
|
||||
ReloadMaps();
|
||||
_logger.LogInformation($"Добавлена карта {textBoxNewMapName.Text}");
|
||||
}
|
||||
|
||||
private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||
@@ -86,43 +81,31 @@ namespace WarmlyShip
|
||||
}
|
||||
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ??
|
||||
string.Empty);
|
||||
ReloadMaps();
|
||||
_logger.LogInformation("Удалена карта {0}", listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormShipConfig formShipConfig = new();
|
||||
formShipConfig.AddEvent(AddShip);
|
||||
formShipConfig.Show();
|
||||
}
|
||||
|
||||
private void AddShip(DrawingWarmlyShip ship)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
FormClass form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectShip(ship) > -1)
|
||||
DrawningObjectShip ship = new(form.SelectedShip);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + ship > -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
_logger.LogInformation($"Добавлен объект: {ship} на карте: {listBoxMaps.SelectedItem}");
|
||||
}
|
||||
}
|
||||
catch (StorageOverflowException ex)
|
||||
{
|
||||
_logger.LogWarning($"Ошибка переполнения при добавлении объекта: {ex.Message}");
|
||||
MessageBox.Show($"Ошибка переполнения: {ex.Message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning($"Неизвестная ошибка при добавлении объекта: {ex.Message}");
|
||||
MessageBox.Show($"Неизвестная ошибка: {ex.Message}");
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,29 +124,15 @@ namespace WarmlyShip
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
try
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||
{
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
_logger.LogInformation($"Удален объект с позиции: [{pos}] на карте: {listBoxMaps.SelectedItem}");
|
||||
}
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image =
|
||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
catch (ShipNotFoundException ex)
|
||||
else
|
||||
{
|
||||
_logger.LogWarning($"Ошибка при удалении объекта на позиции: {ex.Message}");
|
||||
MessageBox.Show($"Ошибка удаления: {ex.Message} ");
|
||||
}
|
||||
catch (StorageOverflowException ex)
|
||||
{
|
||||
_logger.LogWarning($"Ошибка при удалении объекта на позиции: {ex.Message}");
|
||||
MessageBox.Show($"Превышение размерности: {ex.Message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning($"Неизвестная ошибка при удалении объекта на позиции: {ex.Message}");
|
||||
MessageBox.Show($"Неизвестная ошибка: {ex.Message} ");
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +143,6 @@ namespace WarmlyShip
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
_logger.LogInformation($"Переход в хранилище: {listBoxMaps.SelectedItem}");
|
||||
}
|
||||
|
||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||
@@ -184,7 +152,6 @@ namespace WarmlyShip
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||
_logger.LogInformation($"Переход на карту: {listBoxMaps.SelectedItem}");
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
@@ -213,42 +180,5 @@ namespace WarmlyShip
|
||||
}
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||
}
|
||||
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mapsCollection.SaveData(saveFileDialog.FileName);
|
||||
_logger.LogInformation($"Карта успешно сохранена в файл: {saveFileDialog.FileName}");
|
||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning($"Не сохранилось в файл: {saveFileDialog.FileName}");
|
||||
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mapsCollection.LoadData(openFileDialog.FileName);
|
||||
_logger.LogInformation($"Карта успешно загружена из файла: {openFileDialog.FileName}");
|
||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
ReloadMaps();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning($"Не загрузилось из файла: {openFileDialog.FileName}");
|
||||
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,13 +57,4 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip.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>125, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>265, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
352
WarmlyShip/WarmlyShip/FormShipConfig.Designer.cs
generated
352
WarmlyShip/WarmlyShip/FormShipConfig.Designer.cs
generated
@@ -1,352 +0,0 @@
|
||||
namespace WarmlyShip
|
||||
{
|
||||
partial class FormShipConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBoxConfig = new System.Windows.Forms.GroupBox();
|
||||
this.labelModifiedObject = new System.Windows.Forms.Label();
|
||||
this.labelSimpleObject = new System.Windows.Forms.Label();
|
||||
this.groupBoxColors = new System.Windows.Forms.GroupBox();
|
||||
this.panelBlack = new System.Windows.Forms.Panel();
|
||||
this.panelWhite = new System.Windows.Forms.Panel();
|
||||
this.panelBlue = new System.Windows.Forms.Panel();
|
||||
this.panelYellow = new System.Windows.Forms.Panel();
|
||||
this.panelCyan = new System.Windows.Forms.Panel();
|
||||
this.panelGreen = new System.Windows.Forms.Panel();
|
||||
this.panelRed = new System.Windows.Forms.Panel();
|
||||
this.panelPink = new System.Windows.Forms.Panel();
|
||||
this.checkBoxCistern = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxTubes = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelWeight = new System.Windows.Forms.Label();
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelSpeed = new System.Windows.Forms.Label();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.panelObject = new System.Windows.Forms.Panel();
|
||||
this.labelDopColor = new System.Windows.Forms.Label();
|
||||
this.labelBaseColor = new System.Windows.Forms.Label();
|
||||
this.buttonAddShip = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBoxConfig.SuspendLayout();
|
||||
this.groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||
this.panelObject.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxConfig
|
||||
//
|
||||
this.groupBoxConfig.Controls.Add(this.labelModifiedObject);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
|
||||
this.groupBoxConfig.Controls.Add(this.groupBoxColors);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxCistern);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxTubes);
|
||||
this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
|
||||
this.groupBoxConfig.Controls.Add(this.labelWeight);
|
||||
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSpeed);
|
||||
this.groupBoxConfig.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBoxConfig.Name = "groupBoxConfig";
|
||||
this.groupBoxConfig.Size = new System.Drawing.Size(454, 259);
|
||||
this.groupBoxConfig.TabIndex = 0;
|
||||
this.groupBoxConfig.TabStop = false;
|
||||
this.groupBoxConfig.Text = "Параметры";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelModifiedObject.Location = new System.Drawing.Point(339, 149);
|
||||
this.labelModifiedObject.Name = "labelModifiedObject";
|
||||
this.labelModifiedObject.Size = new System.Drawing.Size(100, 23);
|
||||
this.labelModifiedObject.TabIndex = 8;
|
||||
this.labelModifiedObject.Text = "Продвинутый";
|
||||
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelSimpleObject.Location = new System.Drawing.Point(233, 149);
|
||||
this.labelSimpleObject.Name = "labelSimpleObject";
|
||||
this.labelSimpleObject.Size = new System.Drawing.Size(100, 23);
|
||||
this.labelSimpleObject.TabIndex = 7;
|
||||
this.labelSimpleObject.Text = "Простой";
|
||||
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
this.groupBoxColors.Controls.Add(this.panelBlack);
|
||||
this.groupBoxColors.Controls.Add(this.panelWhite);
|
||||
this.groupBoxColors.Controls.Add(this.panelBlue);
|
||||
this.groupBoxColors.Controls.Add(this.panelYellow);
|
||||
this.groupBoxColors.Controls.Add(this.panelCyan);
|
||||
this.groupBoxColors.Controls.Add(this.panelGreen);
|
||||
this.groupBoxColors.Controls.Add(this.panelRed);
|
||||
this.groupBoxColors.Controls.Add(this.panelPink);
|
||||
this.groupBoxColors.Location = new System.Drawing.Point(239, 22);
|
||||
this.groupBoxColors.Name = "groupBoxColors";
|
||||
this.groupBoxColors.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
this.groupBoxColors.Size = new System.Drawing.Size(194, 113);
|
||||
this.groupBoxColors.TabIndex = 6;
|
||||
this.groupBoxColors.TabStop = false;
|
||||
this.groupBoxColors.Text = "Цвета";
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
this.panelBlack.Location = new System.Drawing.Point(147, 67);
|
||||
this.panelBlack.Name = "panelBlack";
|
||||
this.panelBlack.Size = new System.Drawing.Size(41, 39);
|
||||
this.panelBlack.TabIndex = 1;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
this.panelWhite.BackColor = System.Drawing.Color.White;
|
||||
this.panelWhite.Location = new System.Drawing.Point(100, 67);
|
||||
this.panelWhite.Name = "panelWhite";
|
||||
this.panelWhite.Size = new System.Drawing.Size(41, 39);
|
||||
this.panelWhite.TabIndex = 1;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||
this.panelBlue.Location = new System.Drawing.Point(53, 67);
|
||||
this.panelBlue.Name = "panelBlue";
|
||||
this.panelBlue.Size = new System.Drawing.Size(41, 39);
|
||||
this.panelBlue.TabIndex = 1;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||
this.panelYellow.Location = new System.Drawing.Point(6, 69);
|
||||
this.panelYellow.Name = "panelYellow";
|
||||
this.panelYellow.Size = new System.Drawing.Size(41, 39);
|
||||
this.panelYellow.TabIndex = 4;
|
||||
//
|
||||
// panelCyan
|
||||
//
|
||||
this.panelCyan.BackColor = System.Drawing.Color.Cyan;
|
||||
this.panelCyan.Location = new System.Drawing.Point(147, 22);
|
||||
this.panelCyan.Name = "panelCyan";
|
||||
this.panelCyan.Size = new System.Drawing.Size(41, 39);
|
||||
this.panelCyan.TabIndex = 3;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
this.panelGreen.BackColor = System.Drawing.Color.Lime;
|
||||
this.panelGreen.Location = new System.Drawing.Point(100, 22);
|
||||
this.panelGreen.Name = "panelGreen";
|
||||
this.panelGreen.Size = new System.Drawing.Size(41, 39);
|
||||
this.panelGreen.TabIndex = 2;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||
this.panelRed.Location = new System.Drawing.Point(53, 22);
|
||||
this.panelRed.Name = "panelRed";
|
||||
this.panelRed.Size = new System.Drawing.Size(41, 39);
|
||||
this.panelRed.TabIndex = 1;
|
||||
//
|
||||
// panelPink
|
||||
//
|
||||
this.panelPink.BackColor = System.Drawing.Color.Fuchsia;
|
||||
this.panelPink.Location = new System.Drawing.Point(6, 22);
|
||||
this.panelPink.Name = "panelPink";
|
||||
this.panelPink.Size = new System.Drawing.Size(41, 39);
|
||||
this.panelPink.TabIndex = 0;
|
||||
//
|
||||
// checkBoxCistern
|
||||
//
|
||||
this.checkBoxCistern.AutoSize = true;
|
||||
this.checkBoxCistern.Location = new System.Drawing.Point(32, 116);
|
||||
this.checkBoxCistern.Name = "checkBoxCistern";
|
||||
this.checkBoxCistern.Size = new System.Drawing.Size(180, 19);
|
||||
this.checkBoxCistern.TabIndex = 5;
|
||||
this.checkBoxCistern.Text = "Признак наличия цистерны";
|
||||
this.checkBoxCistern.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxTubes
|
||||
//
|
||||
this.checkBoxTubes.AutoSize = true;
|
||||
this.checkBoxTubes.Location = new System.Drawing.Point(32, 91);
|
||||
this.checkBoxTubes.Name = "checkBoxTubes";
|
||||
this.checkBoxTubes.Size = new System.Drawing.Size(151, 19);
|
||||
this.checkBoxTubes.TabIndex = 4;
|
||||
this.checkBoxTubes.Text = "Признак наличия труб";
|
||||
this.checkBoxTubes.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(100, 51);
|
||||
this.numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
this.numericUpDownWeight.Size = new System.Drawing.Size(120, 23);
|
||||
this.numericUpDownWeight.TabIndex = 3;
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
this.labelWeight.AutoSize = true;
|
||||
this.labelWeight.Location = new System.Drawing.Point(32, 53);
|
||||
this.labelWeight.Name = "labelWeight";
|
||||
this.labelWeight.Size = new System.Drawing.Size(29, 15);
|
||||
this.labelWeight.TabIndex = 2;
|
||||
this.labelWeight.Text = "Вес:";
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(100, 22);
|
||||
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
this.numericUpDownSpeed.Size = new System.Drawing.Size(120, 23);
|
||||
this.numericUpDownSpeed.TabIndex = 1;
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
this.labelSpeed.AutoSize = true;
|
||||
this.labelSpeed.Location = new System.Drawing.Point(32, 24);
|
||||
this.labelSpeed.Name = "labelSpeed";
|
||||
this.labelSpeed.Size = new System.Drawing.Size(62, 15);
|
||||
this.labelSpeed.TabIndex = 0;
|
||||
this.labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
this.pictureBoxObject.Location = new System.Drawing.Point(3, 32);
|
||||
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(429, 185);
|
||||
this.pictureBoxObject.TabIndex = 1;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
this.panelObject.AllowDrop = true;
|
||||
this.panelObject.Controls.Add(this.labelDopColor);
|
||||
this.panelObject.Controls.Add(this.labelBaseColor);
|
||||
this.panelObject.Controls.Add(this.pictureBoxObject);
|
||||
this.panelObject.Location = new System.Drawing.Point(472, 22);
|
||||
this.panelObject.Name = "panelObject";
|
||||
this.panelObject.Size = new System.Drawing.Size(435, 220);
|
||||
this.panelObject.TabIndex = 2;
|
||||
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
//
|
||||
// labelDopColor
|
||||
//
|
||||
this.labelDopColor.AllowDrop = true;
|
||||
this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelDopColor.Location = new System.Drawing.Point(225, 6);
|
||||
this.labelDopColor.Name = "labelDopColor";
|
||||
this.labelDopColor.Size = new System.Drawing.Size(100, 23);
|
||||
this.labelDopColor.TabIndex = 9;
|
||||
this.labelDopColor.Text = "Доп. Цвет";
|
||||
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
|
||||
//
|
||||
this.labelBaseColor.AllowDrop = true;
|
||||
this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelBaseColor.Location = new System.Drawing.Point(119, 6);
|
||||
this.labelBaseColor.Name = "labelBaseColor";
|
||||
this.labelBaseColor.Size = new System.Drawing.Size(100, 23);
|
||||
this.labelBaseColor.TabIndex = 8;
|
||||
this.labelBaseColor.Text = "Цвет";
|
||||
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);
|
||||
//
|
||||
// buttonAddShip
|
||||
//
|
||||
this.buttonAddShip.Location = new System.Drawing.Point(616, 248);
|
||||
this.buttonAddShip.Name = "buttonAddShip";
|
||||
this.buttonAddShip.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonAddShip.TabIndex = 3;
|
||||
this.buttonAddShip.Text = "Добавить";
|
||||
this.buttonAddShip.UseVisualStyleBackColor = true;
|
||||
this.buttonAddShip.Click += new System.EventHandler(this.ButtonOk_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(697, 248);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 4;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormShipConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(919, 283);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonAddShip);
|
||||
this.Controls.Add(this.panelObject);
|
||||
this.Controls.Add(this.groupBoxConfig);
|
||||
this.Name = "FormShipConfig";
|
||||
this.Text = "Создание объекта";
|
||||
this.groupBoxConfig.ResumeLayout(false);
|
||||
this.groupBoxConfig.PerformLayout();
|
||||
this.groupBoxColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.panelObject.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxConfig;
|
||||
private CheckBox checkBoxTubes;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private Label labelWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label labelSpeed;
|
||||
private CheckBox checkBoxCistern;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelBlack;
|
||||
private Panel panelWhite;
|
||||
private Panel panelBlue;
|
||||
private Panel panelYellow;
|
||||
private Panel panelCyan;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private Panel panelPink;
|
||||
private Label labelSimpleObject;
|
||||
private Label labelModifiedObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel panelObject;
|
||||
private Label labelDopColor;
|
||||
private Label labelBaseColor;
|
||||
private Button buttonAddShip;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
public partial class FormShipConfig : Form
|
||||
{
|
||||
|
||||
DrawingWarmlyShip _warmlyShip = null;
|
||||
|
||||
private Action<DrawingWarmlyShip> EventAddShip;
|
||||
|
||||
public FormShipConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelPink.MouseDown += PanelColor_MouseDown;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelCyan.MouseDown += PanelColor_MouseDown;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
private void DrawShip()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_warmlyShip?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
_warmlyShip?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
public void AddEvent(Action<DrawingWarmlyShip> ev)
|
||||
{
|
||||
if (EventAddShip == null)
|
||||
{
|
||||
EventAddShip = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddShip += ev;
|
||||
}
|
||||
}
|
||||
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_warmlyShip = new DrawingWarmlyShip((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_warmlyShip = new DrawningMotorShip((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxTubes.Checked, checkBoxCistern.Checked);
|
||||
break;
|
||||
}
|
||||
DrawShip();
|
||||
}
|
||||
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void LabelBaseColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_warmlyShip == null) return;
|
||||
|
||||
if (_warmlyShip is DrawningMotorShip)
|
||||
{
|
||||
_warmlyShip = ((DrawningMotorShip)_warmlyShip).ModifShip(bodyColor: (Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
else
|
||||
{
|
||||
_warmlyShip = _warmlyShip.ModifShip(bodyColor: (Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
|
||||
DrawShip();
|
||||
}
|
||||
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_warmlyShip == null || !(_warmlyShip is DrawningMotorShip)) return;
|
||||
|
||||
_warmlyShip = ((DrawningMotorShip)_warmlyShip).ModifShip(dopColor: (Color)e.Data.GetData(typeof(Color)));
|
||||
|
||||
DrawShip();
|
||||
}
|
||||
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddShip?.Invoke(_warmlyShip);
|
||||
Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -13,7 +13,5 @@ namespace WarmlyShip
|
||||
void MoveObject(Direction direction);
|
||||
void DrawningObject(Graphics g);
|
||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
||||
|
||||
string GetInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,24 +65,6 @@ namespace WarmlyShip
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
|
||||
public string GetData(char separatorType, char separatorData)
|
||||
{
|
||||
string data = $"{_map.GetType().Name}{separatorType}";
|
||||
foreach (var ship in _setShips.GetShips())
|
||||
{
|
||||
data += $"{ship.GetInfo()}{separatorData}";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public void LoadData(string[] records)
|
||||
{
|
||||
foreach (var rec in records)
|
||||
{
|
||||
_setShips.Insert(DrawningObjectShip.Create(rec) as T);
|
||||
}
|
||||
}
|
||||
|
||||
private void Shaking()
|
||||
{
|
||||
int j = _setShips.Count - 1;
|
||||
@@ -125,6 +107,17 @@ namespace WarmlyShip
|
||||
|
||||
private void DrawShips(Graphics g)
|
||||
{
|
||||
/*for (int i = 0; i < _setShips.Count; ++i)
|
||||
{
|
||||
if (_setShips[i] != null )
|
||||
{
|
||||
int temp = 0;
|
||||
if (_setShips[i].GetCurrentPosition().Bottom - _setShips[i].GetCurrentPosition().Top < 75) temp = (int)(_setShips[i].GetCurrentPosition().Bottom - _setShips[i].GetCurrentPosition().Top);
|
||||
_setShips[i].SetObject((_pictureWidth / _placeSizeWidth - (i % (_pictureWidth / _placeSizeWidth)) - 1) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight + temp, _pictureWidth, _pictureHeight);
|
||||
_setShips[i].DrawningObject(g);
|
||||
}
|
||||
}*/
|
||||
|
||||
int i = 0;
|
||||
foreach (var ship in _setShips.GetShips())
|
||||
{
|
||||
@@ -138,5 +131,6 @@ namespace WarmlyShip
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.DirectoryServices.ActiveDirectory;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -10,7 +9,7 @@ namespace WarmlyShip
|
||||
{
|
||||
internal class MapsCollection
|
||||
{
|
||||
readonly Dictionary<string, MapWithSetShipGeneric<IDrawningObject, AbstractMap>> _mapStorages;
|
||||
readonly Dictionary<string, MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>> _mapStorages;
|
||||
|
||||
public List<string> Keys => _mapStorages.Keys.ToList();
|
||||
|
||||
@@ -18,13 +17,9 @@ namespace WarmlyShip
|
||||
|
||||
private readonly int _pictureHeight;
|
||||
|
||||
private readonly char separatorDict = '|';
|
||||
|
||||
private readonly char separatorData = ';';
|
||||
|
||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_mapStorages = new Dictionary<string, MapWithSetShipGeneric<IDrawningObject, AbstractMap>>();
|
||||
_mapStorages = new Dictionary<string, MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
@@ -32,7 +27,7 @@ namespace WarmlyShip
|
||||
public void AddMap(string name, AbstractMap map)
|
||||
{
|
||||
if (_mapStorages.ContainsKey(name)) return;
|
||||
_mapStorages.Add(name, new MapWithSetShipGeneric<IDrawningObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
_mapStorages.Add(name, new MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
}
|
||||
|
||||
public void DelMap(string name)
|
||||
@@ -41,7 +36,7 @@ namespace WarmlyShip
|
||||
_mapStorages.Remove(name);
|
||||
}
|
||||
|
||||
public MapWithSetShipGeneric<IDrawningObject, AbstractMap> this[string ind]
|
||||
public MapWithSetShipGeneric<DrawningObjectShip, AbstractMap> this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -50,68 +45,5 @@ namespace WarmlyShip
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
using (StreamWriter sw = new(filename))
|
||||
{
|
||||
sw.Write($"MapsCollection{Environment.NewLine}");
|
||||
foreach (var storage in _mapStorages)
|
||||
{
|
||||
|
||||
sw.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new FileNotFoundException("Файл не найден");
|
||||
}
|
||||
using (StreamReader sr = new(filename))
|
||||
{
|
||||
string bufferStr;
|
||||
bool firstIn = true;
|
||||
while ((bufferStr = sr.ReadLine()) != null)
|
||||
{
|
||||
if (firstIn)
|
||||
{
|
||||
if (!bufferStr.Contains("MapsCollection"))
|
||||
{
|
||||
throw new FormatException("Формат данных в файле не правильный");
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapStorages.Clear();
|
||||
}
|
||||
firstIn = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var elem = bufferStr.Split(separatorDict);
|
||||
AbstractMap map = null;
|
||||
switch (elem[1])
|
||||
{
|
||||
case "SimpleMap":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "SecondMap":
|
||||
map = new SecondMap();
|
||||
break;
|
||||
case "LastMap":
|
||||
map = new LastMap();
|
||||
break;
|
||||
}
|
||||
_mapStorages.Add(elem[0], new MapWithSetShipGeneric<IDrawningObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
_mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
internal static class Program
|
||||
@@ -16,31 +11,7 @@ namespace WarmlyShip
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
using (ServiceProvider serviceProvider =
|
||||
services.BuildServiceProvider())
|
||||
{
|
||||
Application.Run(serviceProvider.GetRequiredService<FormMapWithSetShip>());
|
||||
}
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormMapWithSetShip>().AddLogging(option =>
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile(path: "serilogConfig.json", optional: false, reloadOnChange: true)
|
||||
.Build();
|
||||
|
||||
var logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.CreateLogger();
|
||||
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddSerilog(logger);
|
||||
});
|
||||
}
|
||||
}
|
||||
Application.Run(new FormMapWithSetShip());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,16 +27,15 @@ namespace WarmlyShip
|
||||
|
||||
public int Insert(T ship, int position)
|
||||
{
|
||||
if (position < 0 || position > Count || Count == _maxCount) throw new StorageOverflowException(_maxCount);
|
||||
if (position < 0 || position > Count || Count == _maxCount) return -1;
|
||||
_places.Insert(position, ship);
|
||||
return position;
|
||||
}
|
||||
|
||||
public T Remove(int position)
|
||||
{
|
||||
if (position >= _maxCount || position >= _places.Count) throw new ShipNotFoundException(position);
|
||||
T DelElement = _places[position];
|
||||
_places.Remove(DelElement);
|
||||
_places[position] = null;
|
||||
return DelElement;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
[Serializable]
|
||||
internal class ShipNotFoundException : Exception
|
||||
{
|
||||
public ShipNotFoundException(int i) : base($"Не найден объект по позиции { i}") { }
|
||||
public ShipNotFoundException() : base() { }
|
||||
public ShipNotFoundException(string message) : base(message) { }
|
||||
public ShipNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||
protected ShipNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
[Serializable]
|
||||
internal class StorageOverflowException : Exception
|
||||
{
|
||||
public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: { count}") { }
|
||||
public StorageOverflowException() : base() { }
|
||||
public StorageOverflowException(string message) : base(message) { }
|
||||
public StorageOverflowException(string message, Exception exception) : base(message, exception) { }
|
||||
protected StorageOverflowException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
||||
@@ -8,30 +8,6 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="serilogConfig.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="serilogConfig.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Settings.Delegates" Version="1.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Information",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/log_.log",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user