-
Notifications
You must be signed in to change notification settings - Fork 0
/
ControlForm.cs
41 lines (33 loc) · 1.22 KB
/
ControlForm.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
namespace Gravity_Simulation
{
public class ControlForm : Form
{
private readonly MainForm mainForm;
private TrackBar scaleTrackBar;
public ControlForm(MainForm mainForm)
{
this.mainForm = mainForm;
InitializeComponents();
StartPosition = FormStartPosition.Manual;
Location = new Point(Screen.AllScreens[1].WorkingArea.X, Screen.AllScreens[1].WorkingArea.Y); // Устанавливаем положение на втором экране
}
private void InitializeComponents()
{
scaleTrackBar = new TrackBar
{
Minimum = 1,
Maximum = 100
};
int initialValue = Math.Clamp((int)(mainForm.Scale * 1e7), scaleTrackBar.Minimum, scaleTrackBar.Maximum);
scaleTrackBar.Value = initialValue;
scaleTrackBar.Dock = DockStyle.Fill;
scaleTrackBar.Scroll += ScaleTrackBar_Scroll;
Controls.Add(scaleTrackBar);
}
private void ScaleTrackBar_Scroll(object sender, EventArgs e)
{
float newScale = scaleTrackBar.Value / 1e7f;
mainForm.UpdateScale(newScale);
}
}
}