Немного доработанная форма
This commit is contained in:
parent
d19cbf92bb
commit
4b867003e2
@ -29,17 +29,17 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBoxTools = new System.Windows.Forms.GroupBox();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||
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.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonAddWarship = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonRemoveWarship = new System.Windows.Forms.Button();
|
||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.groupBoxTools.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -64,26 +64,54 @@
|
||||
this.groupBoxTools.TabStop = false;
|
||||
this.groupBoxTools.Text = "Tools";
|
||||
//
|
||||
// pictureBox
|
||||
// buttonShowOnMap
|
||||
//
|
||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(787, 593);
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
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);
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
// buttonShowStorage
|
||||
//
|
||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||
"Простая карта",
|
||||
"Преграды-линии"});
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(13, 22);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
|
||||
this.comboBoxSelectorMap.TabIndex = 9;
|
||||
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);
|
||||
//
|
||||
// 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
|
||||
//
|
||||
@ -137,54 +165,27 @@
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonAddWarship
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
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);
|
||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||
"Простая карта",
|
||||
"Преграды-линии"});
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(13, 22);
|
||||
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.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);
|
||||
//
|
||||
// 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);
|
||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(787, 593);
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// FormMapWithSetWarships
|
||||
//
|
||||
|
@ -24,6 +24,28 @@ namespace AircraftCarrier
|
||||
{
|
||||
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>
|
||||
|
@ -40,6 +40,12 @@ namespace AircraftCarrier
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
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)));
|
||||
SetData();
|
||||
Draw();
|
||||
@ -87,9 +93,19 @@ namespace AircraftCarrier
|
||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_warship = new DrawingAircraftCarrier(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
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)),
|
||||
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;
|
||||
}
|
||||
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)));
|
||||
SetData();
|
||||
Draw();
|
||||
|
@ -167,8 +167,13 @@ namespace AircraftCarrier
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user