Lusien_Lashans

Form1 Designer

Jun 30th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.00 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.Drawing;
  3. using System.IO;
  4.  
  5. namespace WindowsFormsApp1
  6. {
  7.     partial class Form1
  8.     {
  9.         private System.ComponentModel.IContainer components = null;
  10.  
  11.         protected override void Dispose(bool disposing)
  12.         {
  13.             if (disposing && (components != null))
  14.             {
  15.                 components.Dispose();
  16.             }
  17.             base.Dispose(disposing);
  18.         }
  19.  
  20.         private void InitializeComponent()
  21.         {
  22.             //загрузка кнопок
  23.             this.buttonsMap = LoadButtons("buttons.txt");
  24.            
  25.             this.components = new System.ComponentModel.Container();
  26.             this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  27.             this.pictureBox1 = new System.Windows.Forms.PictureBox();
  28.             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
  29.             this.SuspendLayout();
  30.             //
  31.             // imageList1
  32.             //
  33.             this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  34.             this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
  35.             this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  36.             //
  37.             // pictureBox1
  38.             //
  39.             this.pictureBox1.Image = global::WindowsFormsApp2.Properties.Resources.кока;
  40.             this.pictureBox1.Location = new System.Drawing.Point(-1, -1);
  41.             this.pictureBox1.Name = "pictureBox1";
  42.             this.pictureBox1.Size = new System.Drawing.Size(1709, 936);
  43.             this.pictureBox1.TabIndex = 1;
  44.             this.pictureBox1.TabStop = false;
  45.             this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.DrawLinePoints);
  46.             //
  47.             // Form1
  48.             //
  49.             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  50.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  51.             this.ClientSize = new System.Drawing.Size(1370, 749);
  52.             this.Controls.Add(this.pictureBox1);
  53.             this.Name = "Form1";
  54.             this.Text = "Form1";
  55.             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  56.             this.ResumeLayout(false);
  57.  
  58.         }
  59.  
  60.         public System.Windows.Forms.Button[] LoadButtons(string path)
  61.         {
  62.             var text = File.ReadAllText(path).Split('\n');
  63.             var result = new System.Windows.Forms.Button[text.Length];
  64.  
  65.             for (int i = 0; i < text.Length; i++)
  66.             {
  67.                 var str = text[i].Split(' ');
  68.  
  69.                 var point = new Point(int.Parse(str[0]), int.Parse(str[1]));
  70.  
  71.                 result[i] = CreateButton(point, i);
  72.             }
  73.  
  74.             return result;
  75.         }
  76.  
  77.         private System.Windows.Forms.Button CreateButton(Point point, int buttonIndex)
  78.         {
  79.             var button = new System.Windows.Forms.Button();
  80.  
  81.             button.Location = point;
  82.             button.Size = new Size(27, 25);
  83.             button.TabIndex = buttonIndex + 3;
  84.             button.Tag = buttonIndex;
  85.             button.Name = "button" + buttonIndex.ToString();
  86.             button.Text = buttonIndex.ToString();
  87.             button.UseVisualStyleBackColor = true;
  88.             button.Click += new System.EventHandler(this.ButtonMap_Click);
  89.             this.Controls.Add(button);
  90.  
  91.             return button;
  92.         }
  93.  
  94.         private System.Windows.Forms.ImageList imageList1;
  95.         private System.Windows.Forms.PictureBox pictureBox1;
  96.         private System.Windows.Forms.Button[] buttonsMap;
  97.     }
  98. }
Add Comment
Please, Sign In to add comment