From 1047be1e085dd2e559c59f41bda38584d03cfe3c Mon Sep 17 00:00:00 2001 From: Ivan_Starostin Date: Sun, 3 Dec 2023 18:15:35 +0400 Subject: [PATCH] Upload files to 'lainer/Lainer1' --- lainer/Lainer1/LainerForm.Designer.cs | 136 ++++++++++++++++++++++++++ lainer/Lainer1/LainerForm.cs | 70 +++++++++++++ lainer/Lainer1/LainerForm.resx | 120 +++++++++++++++++++++++ lainer/Lainer1/Program.cs | 17 ++++ 4 files changed, 343 insertions(+) create mode 100644 lainer/Lainer1/LainerForm.Designer.cs create mode 100644 lainer/Lainer1/LainerForm.cs create mode 100644 lainer/Lainer1/LainerForm.resx create mode 100644 lainer/Lainer1/Program.cs diff --git a/lainer/Lainer1/LainerForm.Designer.cs b/lainer/Lainer1/LainerForm.Designer.cs new file mode 100644 index 0000000..aadae36 --- /dev/null +++ b/lainer/Lainer1/LainerForm.Designer.cs @@ -0,0 +1,136 @@ +namespace ProjectLainer +{ + partial class LainerForm : Form + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + pictureBoxLainer = new PictureBox(); + buttonCreate = new Button(); + buttonRight = new Button(); + buttonLeft = new Button(); + buttonDown = new Button(); + buttonUp = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxLainer).BeginInit(); + SuspendLayout(); + // + // pictureBoxLainer + // + pictureBoxLainer.Dock = DockStyle.Fill; + pictureBoxLainer.Location = new Point(0, 0); + pictureBoxLainer.Name = "pictureBoxLainer"; + pictureBoxLainer.Size = new Size(729, 397); + pictureBoxLainer.SizeMode = PictureBoxSizeMode.AutoSize; + pictureBoxLainer.TabIndex = 0; + pictureBoxLainer.TabStop = false; + // + // buttonCreate + // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreate.Location = new Point(12, 356); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(94, 29); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += buttonCreate_Click; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Lainer1.Properties.Resources._3042406; + buttonRight.BackgroundImageLayout = ImageLayout.Zoom; + buttonRight.Location = new Point(659, 315); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(30, 30); + buttonRight.TabIndex = 2; + buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += buttonMove_Click; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Lainer1.Properties.Resources._2; + buttonLeft.BackgroundImageLayout = ImageLayout.Zoom; + buttonLeft.Location = new Point(587, 315); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(30, 30); + buttonLeft.TabIndex = 3; + buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += buttonMove_Click; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Lainer1.Properties.Resources._1; + buttonDown.BackgroundImageLayout = ImageLayout.Zoom; + buttonDown.Location = new Point(623, 344); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(30, 30); + buttonDown.TabIndex = 4; + buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += buttonMove_Click; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Lainer1.Properties.Resources._3; + buttonUp.BackgroundImageLayout = ImageLayout.Zoom; + buttonUp.Location = new Point(623, 287); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(30, 30); + buttonUp.TabIndex = 5; + buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += buttonMove_Click; + // + // LainerForm + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(729, 397); + Controls.Add(buttonUp); + Controls.Add(buttonDown); + Controls.Add(buttonLeft); + Controls.Add(buttonRight); + Controls.Add(buttonCreate); + Controls.Add(pictureBoxLainer); + Name = "LainerForm"; + Text = "LainerField"; + ((System.ComponentModel.ISupportInitialize)pictureBoxLainer).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private PictureBox pictureBoxLainer; + private Button buttonCreate; + private Button buttonRight; + private Button buttonLeft; + private Button buttonDown; + private Button buttonUp; + } +} \ No newline at end of file diff --git a/lainer/Lainer1/LainerForm.cs b/lainer/Lainer1/LainerForm.cs new file mode 100644 index 0000000..debdbcd --- /dev/null +++ b/lainer/Lainer1/LainerForm.cs @@ -0,0 +1,70 @@ +namespace ProjectLainer +{ + public partial class LainerForm : Form + { + + private DrawningLainer? _drawningLainer; + + public LainerForm() + { + InitializeComponent(); + + } + + private void Draw() + { + if (_drawningLainer == null) + { + return; + } + Bitmap bmp = new(pictureBoxLainer.Width, + pictureBoxLainer.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningLainer.DrawTransport(gr); + pictureBoxLainer.Image = bmp; + } + + private void buttonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningLainer = new DrawningLainer(); + _drawningLainer.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)), + pictureBoxLainer.Width, pictureBoxLainer.Height); + _drawningLainer.SetPosition(random.Next(10, 100), + random.Next(10, 100)); + Draw(); + } + + private void buttonMove_Click(object sender, EventArgs e) + { + if (_drawningLainer == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _drawningLainer.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + _drawningLainer.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + _drawningLainer.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + _drawningLainer.MoveTransport(DirectionType.Right); + break; + } + Draw(); + } + } +} \ No newline at end of file diff --git a/lainer/Lainer1/LainerForm.resx b/lainer/Lainer1/LainerForm.resx new file mode 100644 index 0000000..0f362c9 --- /dev/null +++ b/lainer/Lainer1/LainerForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/lainer/Lainer1/Program.cs b/lainer/Lainer1/Program.cs new file mode 100644 index 0000000..bd98bf8 --- /dev/null +++ b/lainer/Lainer1/Program.cs @@ -0,0 +1,17 @@ +namespace ProjectLainer +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new LainerForm()); + } + } +} \ No newline at end of file