/
Program.cs
executable file
·59 lines (57 loc) · 2.38 KB
/
Program.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
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Structures;
using UI;
using static Program.Constants;
using Gtk;
using Gdk;
using Cairo;
using Graphics;
namespace Program {
static class Program {
public static PlanetarySystem activesys {get; set;}
public static SystemView sys_view {get; set;}
public static UI.Menu menu {get; set;}
public static double timestep {get; set;}
//public static List<Boolean> RadioOptions {get; set;}
public static int line_max {get; set;}
public static double radius_multiplier {get; set;}
public static List<Body> CustomBodies {get; set;} = new List<Body>();
public static List<bool> CustomCenters {get; set;} = new List<bool>();
public static Gtk.Window mainWindow {get; set;}
public static void StartSimulation() {
activesys = new Structures.PlanetarySystem(CustomBodies);
if (activesys.centers == null) activesys.centers = new List<int>();
activesys.centers.Clear();
for (int i = 0; i < CustomCenters.Count; i++) {
if (CustomCenters[i]) activesys.centers.Add(i);
}
mainWindow = new Gtk.Window("Astrodynamics Simulation");
mainWindow.SetDefaultSize(1280,720);
mainWindow.Events |= EventMask.PointerMotionMask | EventMask.ScrollMask;
mainWindow.DeleteEvent += delegate { Application.Quit (); };
mainWindow.KeyPressEvent += Input.OnKeyPress;
mainWindow.MotionNotifyEvent += Input.OnMouseMovement;
mainWindow.ScrollEvent += Input.OnScrollMovement;
sys_view = new SystemView(activesys);
sys_view.radius_multiplier = radius_multiplier;
sys_view.line_max = line_max;
mainWindow.Add(sys_view);
activesys.StartAsync(step: timestep); // Start Mechanics
sys_view.PlayAsync(interval: 0); // Start Display
mainWindow.ShowAll();
}
static void Main(string[] args) {
try {
Application.Init();
menu = new UI.Menu();
Application.Run();
} catch (Exception e) {
Console.WriteLine("An unexpected error occured");
Console.WriteLine($"{e.Message}\n{e.StackTrace}");
}
}
}
}