-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form2.cs
83 lines (75 loc) · 3.14 KB
/
Form2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace raytraicing
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public Bitmap buf;
private void DrawPoints()
{
pictureBox1.Image = ((Owner as Form1).pic.Clone() as Image);
//int Radius = int.Parse(((Owner as Form1).Controls["HeadRad"] as TextBox).Text);
int Radius = int.Parse((((Owner as Form1).Controls["groupBox1"] as GroupBox).Controls["HeadRad"] as TextBox).Text);
Graphics.FromImage(pictureBox1.Image).DrawEllipse(
Pens.Pink,
int.Parse((((Owner as Form1).Controls["groupBox1"] as GroupBox).Controls["HeadX"] as TextBox).Text) - Radius,
int.Parse((((Owner as Form1).Controls["groupBox1"] as GroupBox).Controls["HeadY"] as TextBox).Text) - Radius,
2 * Radius,
2 * Radius);
int SourceCount = ((Owner as Form1).Controls["sourceBox"] as GroupBox).Controls.OfType<Label>().Sum(label => 1) - 2;
for (int i = 1; i <= SourceCount; ++i)
Graphics.FromImage(pictureBox1.Image).DrawEllipse(
new Pen(Color.Green, 5),
int.Parse((((Owner as Form1).Controls["sourceBox"] as GroupBox).Controls["FirstPointX" + i.ToString()] as TextBox).Text) - 1,
int.Parse((((Owner as Form1).Controls["sourceBox"] as GroupBox).Controls["FirstPointY" + i.ToString()] as TextBox).Text) - 1,
2,
2);
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
//pictureBox1.Image = buf;
//pictureBox1.Image = (Owner as Form1).room;
DrawPoints();
pictureBox1.Refresh();
}
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button.Equals(MouseButtons.Left))
{
switch (Control.ModifierKeys)
{
case Keys.Control:
(Owner as Form1).AddSource(e.X.ToString(), e.Y.ToString());
DrawPoints();
break;
case Keys.Alt:
(((Owner as Form1).Controls["groupBox1"] as GroupBox).Controls["HeadX"] as TextBox).Text = e.X.ToString();
(((Owner as Form1).Controls["groupBox1"] as GroupBox).Controls["HeadY"] as TextBox).Text = e.Y.ToString();
DrawPoints();
break;
default:
this.Close();
break;
}
}
}
private void Form2_Load(object sender, EventArgs e)
{
buf = new Bitmap((Owner as Form1).pic);
}
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
(Owner as Form1).pic = new Bitmap(buf);
}
}
}