Немного доработанная форма
This commit is contained in:
parent
d19cbf92bb
commit
4b867003e2
@ -29,17 +29,17 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.groupBoxTools = new System.Windows.Forms.GroupBox();
|
this.groupBoxTools = new System.Windows.Forms.GroupBox();
|
||||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||||
|
this.buttonRemoveWarship = new System.Windows.Forms.Button();
|
||||||
|
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||||
|
this.buttonAddWarship = new System.Windows.Forms.Button();
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
this.buttonAddWarship = new System.Windows.Forms.Button();
|
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
this.buttonRemoveWarship = new System.Windows.Forms.Button();
|
|
||||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
|
||||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
|
||||||
this.groupBoxTools.SuspendLayout();
|
this.groupBoxTools.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -64,26 +64,54 @@
|
|||||||
this.groupBoxTools.TabStop = false;
|
this.groupBoxTools.TabStop = false;
|
||||||
this.groupBoxTools.Text = "Tools";
|
this.groupBoxTools.Text = "Tools";
|
||||||
//
|
//
|
||||||
// pictureBox
|
// buttonShowOnMap
|
||||||
//
|
//
|
||||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.buttonShowOnMap.Location = new System.Drawing.Point(13, 431);
|
||||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||||
this.pictureBox.Name = "pictureBox";
|
this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35);
|
||||||
this.pictureBox.Size = new System.Drawing.Size(787, 593);
|
this.buttonShowOnMap.TabIndex = 18;
|
||||||
this.pictureBox.TabIndex = 1;
|
this.buttonShowOnMap.Text = "Show map";
|
||||||
this.pictureBox.TabStop = false;
|
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||||
//
|
//
|
||||||
// comboBoxSelectorMap
|
// buttonShowStorage
|
||||||
//
|
//
|
||||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.buttonShowStorage.Location = new System.Drawing.Point(13, 323);
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
this.buttonShowStorage.Size = new System.Drawing.Size(175, 35);
|
||||||
"Простая карта",
|
this.buttonShowStorage.TabIndex = 17;
|
||||||
"Преграды-линии"});
|
this.buttonShowStorage.Text = "Show storage";
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(13, 22);
|
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
|
//
|
||||||
this.comboBoxSelectorMap.TabIndex = 9;
|
// buttonRemoveWarship
|
||||||
|
//
|
||||||
|
this.buttonRemoveWarship.Location = new System.Drawing.Point(13, 208);
|
||||||
|
this.buttonRemoveWarship.Name = "buttonRemoveWarship";
|
||||||
|
this.buttonRemoveWarship.Size = new System.Drawing.Size(175, 35);
|
||||||
|
this.buttonRemoveWarship.TabIndex = 16;
|
||||||
|
this.buttonRemoveWarship.Text = "Remove warship";
|
||||||
|
this.buttonRemoveWarship.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRemoveWarship.Click += new System.EventHandler(this.ButtonRemoveWarship_Click);
|
||||||
|
//
|
||||||
|
// maskedTextBoxPosition
|
||||||
|
//
|
||||||
|
this.maskedTextBoxPosition.Location = new System.Drawing.Point(13, 177);
|
||||||
|
this.maskedTextBoxPosition.Mask = "00";
|
||||||
|
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
|
||||||
|
this.maskedTextBoxPosition.TabIndex = 15;
|
||||||
|
this.maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||||
|
//
|
||||||
|
// buttonAddWarship
|
||||||
|
//
|
||||||
|
this.buttonAddWarship.Location = new System.Drawing.Point(13, 114);
|
||||||
|
this.buttonAddWarship.Name = "buttonAddWarship";
|
||||||
|
this.buttonAddWarship.Size = new System.Drawing.Size(175, 35);
|
||||||
|
this.buttonAddWarship.TabIndex = 14;
|
||||||
|
this.buttonAddWarship.Text = "Add warship";
|
||||||
|
this.buttonAddWarship.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddWarship.Click += new System.EventHandler(this.ButtonAddWarship_Click);
|
||||||
//
|
//
|
||||||
// buttonRight
|
// buttonRight
|
||||||
//
|
//
|
||||||
@ -137,54 +165,27 @@
|
|||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonAddWarship
|
// comboBoxSelectorMap
|
||||||
//
|
//
|
||||||
this.buttonAddWarship.Location = new System.Drawing.Point(13, 114);
|
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.buttonAddWarship.Name = "buttonAddWarship";
|
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||||
this.buttonAddWarship.Size = new System.Drawing.Size(175, 35);
|
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
this.buttonAddWarship.TabIndex = 14;
|
"Простая карта",
|
||||||
this.buttonAddWarship.Text = "Add warship";
|
"Преграды-линии"});
|
||||||
this.buttonAddWarship.UseVisualStyleBackColor = true;
|
this.comboBoxSelectorMap.Location = new System.Drawing.Point(13, 22);
|
||||||
this.buttonAddWarship.Click += new System.EventHandler(this.ButtonAddWarship_Click);
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
|
||||||
|
this.comboBoxSelectorMap.TabIndex = 9;
|
||||||
|
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// maskedTextBoxPosition
|
// pictureBox
|
||||||
//
|
//
|
||||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(13, 177);
|
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.maskedTextBoxPosition.Mask = "00";
|
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
this.pictureBox.Name = "pictureBox";
|
||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
|
this.pictureBox.Size = new System.Drawing.Size(787, 593);
|
||||||
this.maskedTextBoxPosition.TabIndex = 15;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.maskedTextBoxPosition.ValidatingType = typeof(int);
|
this.pictureBox.TabStop = false;
|
||||||
//
|
|
||||||
// buttonRemoveWarship
|
|
||||||
//
|
|
||||||
this.buttonRemoveWarship.Location = new System.Drawing.Point(13, 208);
|
|
||||||
this.buttonRemoveWarship.Name = "buttonRemoveWarship";
|
|
||||||
this.buttonRemoveWarship.Size = new System.Drawing.Size(175, 35);
|
|
||||||
this.buttonRemoveWarship.TabIndex = 16;
|
|
||||||
this.buttonRemoveWarship.Text = "Remove warship";
|
|
||||||
this.buttonRemoveWarship.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRemoveWarship.Click += new System.EventHandler(this.ButtonRemoveWarship_Click);
|
|
||||||
//
|
|
||||||
// buttonShowStorage
|
|
||||||
//
|
|
||||||
this.buttonShowStorage.Location = new System.Drawing.Point(13, 323);
|
|
||||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
|
||||||
this.buttonShowStorage.Size = new System.Drawing.Size(175, 35);
|
|
||||||
this.buttonShowStorage.TabIndex = 17;
|
|
||||||
this.buttonShowStorage.Text = "Show storage";
|
|
||||||
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
|
||||||
//
|
|
||||||
// buttonShowOnMap
|
|
||||||
//
|
|
||||||
this.buttonShowOnMap.Location = new System.Drawing.Point(13, 431);
|
|
||||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
|
||||||
this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35);
|
|
||||||
this.buttonShowOnMap.TabIndex = 18;
|
|
||||||
this.buttonShowOnMap.Text = "Show map";
|
|
||||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
|
||||||
//
|
//
|
||||||
// FormMapWithSetWarships
|
// FormMapWithSetWarships
|
||||||
//
|
//
|
||||||
|
@ -24,6 +24,28 @@ namespace AircraftCarrier
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
AbstractMap map = null;
|
||||||
|
switch (comboBoxSelectorMap.Text)
|
||||||
|
{
|
||||||
|
case "Простая карта":
|
||||||
|
map = new SimpleMap();
|
||||||
|
break;
|
||||||
|
case "Преграды-линии":
|
||||||
|
map = new LineMap();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (map != null)
|
||||||
|
{
|
||||||
|
_mapWarshipsCollectionGeneric = new MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap>(
|
||||||
|
pictureBox.Width, pictureBox.Height, map);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_mapWarshipsCollectionGeneric = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта
|
/// Добавление объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -40,6 +40,12 @@ namespace AircraftCarrier
|
|||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
_warship = new DrawingWarship(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
_warship = new DrawingWarship(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
@ -87,9 +93,19 @@ namespace AircraftCarrier
|
|||||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_warship = new DrawingAircraftCarrier(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
ColorDialog dialog = new();
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
|
ColorDialog dialogDop = new();
|
||||||
|
if (dialogDop.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
dopColor = dialogDop.Color;
|
||||||
|
}
|
||||||
|
_warship = new DrawingAircraftCarrier(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
|
||||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
|
@ -167,8 +167,13 @@ namespace AircraftCarrier
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < _setWarships.Count; i++)
|
for (int i = 0; i < _setWarships.Count; i++)
|
||||||
{
|
{
|
||||||
// TODO установка позиции
|
for (int k = 0; k < _pictureWidth / _placeSizeWidth; k++)
|
||||||
|
{
|
||||||
|
for (int l = 0; l < _pictureHeight / _placeSizeHeight + 1; ++l)
|
||||||
|
{
|
||||||
|
_setWarships.Get(i)?.SetObject(k * _placeSizeWidth, l * _placeSizeHeight, _pictureWidth, _pictureHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
_setWarships.Get(i)?.DrawningObject(g);
|
_setWarships.Get(i)?.DrawningObject(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user