Диплом (1222543), страница 13
Текст из файла (страница 13)
this.label2.Name = "label2";
this.label2.Size = new Size(35, 13);
this.label2.TabIndex = 3;
this.label2.Text = "x0 км";
this.AutoScaleDimensions = new SizeF(6f, 13f);
this.AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new Size(265, 105);
this.ControlBox = false;
this.Controls.Add((Control) this.label2);
this.Controls.Add((Control) this.textBox1);
this.Controls.Add((Control) this.button1);
this.Controls.Add((Control) this.label1);
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "EnterForm";
this.StartPosition = FormStartPosition.CenterScreen;
this.Text = "Размер участка";
this.ResumeLayout(false);
this.PerformLayout();
}
public unsafe sbyte* SystemStringToChar(string @string)
{
return (sbyte*) (void*) Marshal.StringToHGlobalAnsi(@string);
}
private unsafe void button1_Click(object sender, EventArgs e)
{
EnterForm enterForm = this;
string text = enterForm.textBox1.Text;
\u003CModule\u003E.Setka\u002EEnterFormValue = enterForm.SystemStringToChar(text);
this.Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
this.label2.Text = 120.ToString() + this.textBox1.Text + " км";
}
[HandleProcessCorruptedStateExceptions]
protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool A_0)
{
if (A_0)
{
try
{
this.\u007EEnterForm();
}
finally
{
base.Dispose(true);
}
}
else
base.Dispose(false);
}
}
}
MyForm.cs
using std;
using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Setka
{
public class MyForm : Form
{
private Button button2;
private ComboBox comboBox1;
public float PointX;
public float PointY;
public int step;
public int program_status;
public Graphics PictureLoad;
public Graphics SetkaLoad;
private OpenFileDialog openFileDialog1;
private ComboBox comboBox2;
private Label label1;
private Label label2;
private ComboBox comboBox3;
private Label label3;
private Button button3;
private OpenFileDialog openFileDialog2;
public int[,] _PaintedType;
private Button button1;
private PictureBox pictureBox1;
private IContainer components;
public MyForm()
{
// ISSUE: fault handler
try
{
this.InitializeComponent();
int num = (int) this.openFileDialog1.ShowDialog();
}
__fault
{
base.Dispose(true);
}
}
private void \u007EMyForm()
{
if (this.components == null)
return;
IDisposable disposable = (IDisposable) this.components;
int num;
if (disposable != null)
{
disposable.Dispose();
num = 0;
}
else
num = 0;
}
private void InitializeComponent()
{
this.button1 = new Button();
this.pictureBox1 = new PictureBox();
this.button2 = new Button();
this.comboBox1 = new ComboBox();
this.openFileDialog1 = new OpenFileDialog();
this.comboBox2 = new ComboBox();
this.label1 = new Label();
this.label2 = new Label();
this.comboBox3 = new ComboBox();
this.label3 = new Label();
this.button3 = new Button();
this.openFileDialog2 = new OpenFileDialog();
((ISupportInitialize) this.pictureBox1).BeginInit();
this.SuspendLayout();
this.button1.Enabled = false;
this.button1.Location = new Point(12, 519);
this.button1.Name = "button1";
this.button1.Size = new Size(114, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Создать матрицу";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new EventHandler(this.button1_Click);
this.pictureBox1.Location = new Point(12, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new Size(500, 500);
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
this.pictureBox1.MouseClick += new MouseEventHandler(this.mouseClick);
this.button2.Enabled = false;
this.button2.Location = new Point(12, 548);
this.button2.Name = "button2";
this.button2.Size = new Size(114, 23);
this.button2.TabIndex = 2;
this.button2.Text = "Записать в файл";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new EventHandler(this.button2_Click);
this.comboBox1.Enabled = false;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[5]
{
(object) "10",
(object) "20",
(object) "30",
(object) "40",
(object) "50"
});
this.comboBox1.Location = new Point(132, 520);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new Size(45, 21);
this.comboBox1.TabIndex = 3;
this.comboBox1.Tag = (object) "";
this.comboBox1.Text = "10";
this.comboBox1.TextUpdate += new EventHandler(this.comboBox1_TextUpdate);
this.openFileDialog1.Filter = "Изображения (*.jpg, *.jpeg, *.bmp, *.png, *.gif) | *.jpg; *.jpeg; *.bmp; *.png; *gif|Bce файлы|*.*";
this.openFileDialog1.InitialDirectory = "C:\\";
this.openFileDialog1.RestoreDirectory = true;
this.openFileDialog1.FileOk += new CancelEventHandler(this.openFileDialog1_FileOk);
this.comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;
this.comboBox2.Enabled = false;
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Items.AddRange(new object[3]
{
(object) "500",
(object) "700",
(object) "900"
});
this.comboBox2.Location = new Point(467, 548);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new Size(45, 21);
this.comboBox2.TabIndex = 5;
this.comboBox2.Tag = (object) "";
this.comboBox2.SelectedIndexChanged += new EventHandler(this.comboBox2_SelectedIndexChanged);
this.label1.AutoSize = true;
this.label1.Location = new Point(394, 552);
this.label1.Name = "label1";
this.label1.Size = new Size(70, 13);
this.label1.TabIndex = 6;
this.label1.Text = "Рамер окна:";
this.label2.AutoSize = true;
this.label2.Location = new Point(329, 522);
this.label2.Name = "label2";
this.label2.Size = new Size(45, 13);
this.label2.TabIndex = 7;
this.label2.Text = "Режим:";
this.comboBox3.DropDownStyle = ComboBoxStyle.DropDownList;
this.comboBox3.Enabled = false;
this.comboBox3.FormattingEnabled = true;
this.comboBox3.Items.AddRange(new object[2]
{
(object) "Месторождение",
(object) "Недоступные участки"
});
this.comboBox3.Location = new Point(377, 518);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new Size(135, 21);
this.comboBox3.TabIndex = 8;
this.comboBox3.Tag = (object) "";
this.label3.AutoSize = true;
this.label3.Location = new Point(180, 525);
this.label3.Name = "label3";
this.label3.Size = new Size(24, 13);
this.label3.TabIndex = 9;
this.label3.Text = "x10";
this.button3.Enabled = false;
this.button3.Location = new Point(132, 548);
this.button3.Name = "button3";
this.button3.Size = new Size(72, 23);
this.button3.TabIndex = 10;
this.button3.Text = "Загрузить";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new EventHandler(this.button3_Click_1);
this.openFileDialog2.FileName = "matrix";
this.openFileDialog2.Filter = "Текстовый файл (*.txt) | *.txt|Bce файлы|*.*";
this.openFileDialog2.InitialDirectory = "C:\\";
this.openFileDialog2.FileOk += new CancelEventHandler(this.openFileDialog2_FileOk);
this.AutoScaleDimensions = new SizeF(6f, 13f);
this.AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new Size(527, 573);
this.Controls.Add((Control) this.button3);
this.Controls.Add((Control) this.label3);
this.Controls.Add((Control) this.comboBox3);
this.Controls.Add((Control) this.label2);
this.Controls.Add((Control) this.label1);
this.Controls.Add((Control) this.comboBox2);
this.Controls.Add((Control) this.comboBox1);
this.Controls.Add((Control) this.button2);
this.Controls.Add((Control) this.pictureBox1);
this.Controls.Add((Control) this.button1);
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MyForm";
this.StartPosition = FormStartPosition.CenterScreen;
this.Text = "MyForm";
MyForm myForm = this;
EventHandler eventHandler = new EventHandler(myForm.MyForm_Load);
myForm.Load += eventHandler;
((ISupportInitialize) this.pictureBox1).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private void DrawSetka()
{
SolidBrush solidBrush = (SolidBrush) null;
Bitmap bitmap = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
this.pictureBox1.Image = (Image) bitmap;
MyForm myForm1 = this;
Graphics graphics = Graphics.FromImage(myForm1.pictureBox1.Image);
myForm1.SetkaLoad = graphics;
Pen pen = new Pen(Color.Black, 2f);
solidBrush = new SolidBrush(Color.Orange);
MyForm myForm2 = this;
double num = (double) ((float) myForm2.pictureBox1.Width / (float) this.step);
myForm2.PointX = (float) num;
MyForm myForm3 = this;
int[,] numArray = new int[myForm3.step, this.step];
myForm3._PaintedType = numArray;
for (int index1 = 0; index1 < this.step; ++index1)
{
for (int index2 = 0; index2 < this.step; ++index2)
{
this._PaintedType[index1, index2] = 1;
this.SetkaLoad.DrawRectangle(pen, (float) index2 * this.PointX, (float) index1 * this.PointX, this.PointX, this.PointX);
}
}
this.pictureBox1.Image = (Image) bitmap;
}
private void mouseClick(object __unnamed000, MouseEventArgs e)
{
if (this.program_status != 1)
return;
if (e.Button == MouseButtons.Left && this.comboBox3.Text.Length > 0)
{
for (int index1 = 0; index1 < this.step; ++index1)
{
for (int index2 = 0; index2 < this.step; ++index2)
{
float x = (float) index2 * this.PointX;
float y = (float) index1 * this.PointX;
if ((double) e.X < (double) x || (double) e.X > (double) x + (double) this.PointX || ((double) e.Y < (double) y || (double) e.Y > (double) y + (double) this.PointX))
continue;
if (this.comboBox3.SelectedIndex == 0)
{
this._PaintedType[index1, index2] = 4;
this.SetkaLoad.FillRectangle(Brushes.Green, x, y, this.PointX, this.PointX);
}
else
{
this._PaintedType[index1, index2] = 0;
this.SetkaLoad.FillRectangle(Brushes.Orange, x, y, this.PointX, this.PointX);
}
this.pictureBox1.Refresh();
}
}
}
else
{
if (e.Button != MouseButtons.Right)
return;
for (int index1 = 0; index1 < this.step; ++index1)
{
for (int index2 = 0; index2 < this.step; ++index2)
{
float x = (float) index2 * this.PointX;
float y = (float) index1 * this.PointX;
if ((double) e.X < (double) x || (double) e.X > (double) x + (double) this.PointX || ((double) e.Y < (double) y || (double) e.Y > (double) y + (double) this.PointX))
continue;
this.SetkaLoad.FillRectangle(Brushes.Transparent, x, y, this.PointX, this.PointX);
this.pictureBox1.Refresh();
}
}
}
}
private void button1_Click(object sender, EventArgs e)
{
if (this.program_status != 1)
{
MyForm myForm = this;
int num1 = (int) short.Parse(myForm.comboBox1.Text);
myForm.step = num1;
this.DrawSetka();
this.comboBox3.Enabled = true;
this.button2.Enabled = true;
int num2 = (int) MessageBox.Show("Выберите режим и нажмите на точку на сетке!", "Процесс");
this.button1.Text = "Изменить сетку";
this.program_status = 1;















