Коряга без нормальной отрисовки
This commit is contained in:
parent
33f74074d5
commit
ede02decf3
149
GasolineTanker/GasolineTanker/Form1.Designer.cs
generated
149
GasolineTanker/GasolineTanker/Form1.Designer.cs
generated
@ -28,94 +28,99 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.Window = new System.Windows.Forms.PictureBox();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.Window)).BeginInit();
|
||||
this.PictureBoxGasolineTanker = new System.Windows.Forms.PictureBox();
|
||||
this.ButtonCreate = new System.Windows.Forms.Button();
|
||||
this.ButtonRight = new System.Windows.Forms.Button();
|
||||
this.ButtonDown = new System.Windows.Forms.Button();
|
||||
this.ButtonLeft = new System.Windows.Forms.Button();
|
||||
this.ButtonUp = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PictureBoxGasolineTanker)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Window
|
||||
// PictureBoxGasolineTanker
|
||||
//
|
||||
this.Window.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.Window.Location = new System.Drawing.Point(0, 0);
|
||||
this.Window.Name = "Window";
|
||||
this.Window.Size = new System.Drawing.Size(884, 461);
|
||||
this.Window.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.Window.TabIndex = 0;
|
||||
this.Window.TabStop = false;
|
||||
this.PictureBoxGasolineTanker.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.PictureBoxGasolineTanker.Location = new System.Drawing.Point(0, 0);
|
||||
this.PictureBoxGasolineTanker.Name = "PictureBoxGasolineTanker";
|
||||
this.PictureBoxGasolineTanker.Size = new System.Drawing.Size(884, 461);
|
||||
this.PictureBoxGasolineTanker.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.PictureBoxGasolineTanker.TabIndex = 0;
|
||||
this.PictureBoxGasolineTanker.TabStop = false;
|
||||
//
|
||||
// buttonCreate
|
||||
// ButtonCreate
|
||||
//
|
||||
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreate.Location = new System.Drawing.Point(12, 426);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCreate.TabIndex = 1;
|
||||
this.buttonCreate.Text = "Создать";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.ButtonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.ButtonCreate.Location = new System.Drawing.Point(12, 426);
|
||||
this.ButtonCreate.Name = "ButtonCreate";
|
||||
this.ButtonCreate.Size = new System.Drawing.Size(75, 23);
|
||||
this.ButtonCreate.TabIndex = 1;
|
||||
this.ButtonCreate.Text = "Создать";
|
||||
this.ButtonCreate.UseVisualStyleBackColor = true;
|
||||
this.ButtonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||
//
|
||||
// buttonRight
|
||||
// ButtonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::GasolineTanker.Properties.Resources.right;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(842, 419);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 2;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.ButtonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonRight.BackgroundImage = global::GasolineTanker.Properties.Resources.right;
|
||||
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.ButtonRight.Location = new System.Drawing.Point(842, 419);
|
||||
this.ButtonRight.Name = "ButtonRight";
|
||||
this.ButtonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonRight.TabIndex = 2;
|
||||
this.ButtonRight.UseVisualStyleBackColor = true;
|
||||
this.ButtonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
// ButtonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::GasolineTanker.Properties.Resources.down;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(806, 419);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 3;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.ButtonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonDown.BackgroundImage = global::GasolineTanker.Properties.Resources.down;
|
||||
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.ButtonDown.Location = new System.Drawing.Point(806, 419);
|
||||
this.ButtonDown.Name = "ButtonDown";
|
||||
this.ButtonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonDown.TabIndex = 3;
|
||||
this.ButtonDown.UseVisualStyleBackColor = true;
|
||||
this.ButtonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
// ButtonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::GasolineTanker.Properties.Resources.left;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(770, 419);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 4;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.ButtonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonLeft.BackgroundImage = global::GasolineTanker.Properties.Resources.left;
|
||||
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.ButtonLeft.Location = new System.Drawing.Point(770, 419);
|
||||
this.ButtonLeft.Name = "ButtonLeft";
|
||||
this.ButtonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonLeft.TabIndex = 4;
|
||||
this.ButtonLeft.UseVisualStyleBackColor = true;
|
||||
this.ButtonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonUp
|
||||
// ButtonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::GasolineTanker.Properties.Resources.up;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(806, 383);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 5;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.ButtonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonUp.BackgroundImage = global::GasolineTanker.Properties.Resources.up;
|
||||
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.ButtonUp.Location = new System.Drawing.Point(806, 383);
|
||||
this.ButtonUp.Name = "ButtonUp";
|
||||
this.ButtonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonUp.TabIndex = 5;
|
||||
this.ButtonUp.UseVisualStyleBackColor = true;
|
||||
this.ButtonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// GasolineTanker
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(884, 461);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.Window);
|
||||
this.Controls.Add(this.ButtonUp);
|
||||
this.Controls.Add(this.ButtonLeft);
|
||||
this.Controls.Add(this.ButtonDown);
|
||||
this.Controls.Add(this.ButtonRight);
|
||||
this.Controls.Add(this.ButtonCreate);
|
||||
this.Controls.Add(this.PictureBoxGasolineTanker);
|
||||
this.Name = "GasolineTanker";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "GasolineTanker";
|
||||
((System.ComponentModel.ISupportInitialize)(this.Window)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PictureBoxGasolineTanker)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -123,11 +128,11 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox Window;
|
||||
private Button buttonCreate;
|
||||
private Button buttonRight;
|
||||
private Button buttonDown;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
private PictureBox PictureBoxGasolineTanker;
|
||||
private Button ButtonCreate;
|
||||
private Button ButtonRight;
|
||||
private Button ButtonDown;
|
||||
private Button ButtonLeft;
|
||||
private Button ButtonUp;
|
||||
}
|
||||
}
|
@ -2,9 +2,63 @@ namespace GasolineTanker
|
||||
{
|
||||
public partial class GasolineTanker : Form
|
||||
{
|
||||
private DrawningGasolineTanker? _drawningGasolineTanker;
|
||||
public GasolineTanker()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningGasolineTanker == null)
|
||||
return;
|
||||
|
||||
Bitmap bmp = new(PictureBoxGasolineTanker.Width, PictureBoxGasolineTanker.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningGasolineTanker.DrawTransport(gr);
|
||||
PictureBoxGasolineTanker.Image = bmp;
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawningGasolineTanker = new DrawningGasolineTanker();
|
||||
_drawningGasolineTanker.Init(random.Next(100, 300),
|
||||
random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
|
||||
random.Next(0, 256)),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
|
||||
random.Next(0, 256)),
|
||||
Convert.ToBoolean(random.Next(0, 2)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
||||
PictureBoxGasolineTanker.Width, PictureBoxGasolineTanker.Height);
|
||||
_drawningGasolineTanker.SetPosition(random.Next(10, 100),
|
||||
random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningGasolineTanker == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "ButtonUp":
|
||||
_drawningGasolineTanker.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "ButtonDown":
|
||||
_drawningGasolineTanker.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "ButtonLeft":
|
||||
_drawningGasolineTanker.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "ButtonRight":
|
||||
_drawningGasolineTanker.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user