public ToolController(ToolStripItemCollection collection, Viewport viewport, Project project) { Tools = collection; Viewport = viewport; Viewport.Input.MouseClick += ViewportClick; Project = project; }
public GUIMenuSettingsDistribution(Project project) { Project = project; Setup(); Load += ReadData; FormClosing += OnClosing; }
////////// CONSTRUCTOR ////////// public Vehicle(Project project, Node home, Destination dest, VehicleType type, int toDestTime, int toHomeTime) { _settings = project.Settings; ToDestRecord = new List<PointD>(); ToHomeRecord = new List<PointD>(); Home = home; Destination = dest; Type = type; if (ToDestTime > ToHomeTime) throw new ArgumentException("ToDestinationTime cannot be later than ToHomeTime"); ToDestTime = toDestTime; ToHomeTime = toHomeTime; _toDestStarted = false; _toHomeStarted = false; Node end = FindEnd(project); _toDestPath = Pathfinder.FindPath(Home, end); _toHomePath = Pathfinder.FindPath(end, Home); Active = false; Speed = 0; }
public SimulationData(Project project, List<VehicleData> primary, List<VehicleData> secondary) { Project = project; PrimaryData = primary; SecondaryData = secondary; Date = DateTime.Now; }
static public void SaveProject(Project project) { FileStream file = null; try { SaveFileDialog fileSave = new SaveFileDialog(); fileSave.AddExtension = true; fileSave.DefaultExt = "tsp"; fileSave.Filter = "TSP Files|*.tsp"; if (fileSave.ShowDialog() == DialogResult.OK) { BinaryFormatter formatter = new BinaryFormatter(); file = new FileStream(fileSave.FileName, FileMode.Create); formatter.Serialize(file, project); } } catch (Exception e) { MessageBox.Show("Error: " + e.Message); } finally { if (file != null) file.Close(); } }
// SetProject takes a project and converts the nodes and roads to vertices and edges. Only has to be done once. public static void SetProject(Project project, Partitions partition) { Vertices = new List<Vertex>(); ConvertNodes(project); ConvertRoads(project, partition); MaxSpeed = project.RoadTypes.Max().Speed; }
private static void ConvertRoads(Project project, Partitions partition) { foreach (Node node in project.Nodes) foreach (Road road in node.Roads) foreach (Vertex vertex in Vertices) if (road.From.Position == vertex.Position && (road.Partition == partition || road.Partition == Partitions.Shared)) vertex.Edges.Add(new Edge(road, vertex, Vertices.Find(v => v.Position == road.To.Position))); }
public GUIToolEditDestination(Destination dest, Project project) { Destination = dest; Project = project; Setup(); Load += ReadData; FormClosing += SaveData; }
public GUIToolEditNode(Node node, Project project) { Node = node; Project = project; Setup(); Load += ReadData; FormClosing += SaveData; }
public GUIMenuSimulationRun(Project project) { Project = project; Setup(); Simulation = new Simulation(project); Simulation.PrimaryWorker.ProgressChanged += PrimaryProgressChanged; Simulation.SecondaryWorker.ProgressChanged += SecondaryProgressChanged; Simulation.SimulationDone += OnSimulationDone; FormClosing += OnFormClosing; }
private void CreateClick(object sender, EventArgs args) { if (ProjectName.Text.Length > 0) { NewProject = new Project(ProjectName.Text); Close(); } else { ProjectNameLabel.ForeColor = Color.DarkRed; } }
public Simulation(Project project) { Project = project; PrimaryProject = project.Clone() as Project; SecondaryProject = project.Clone() as Project; PrimaryWorker = new BackgroundWorker(); PrimaryWorker.WorkerReportsProgress = true; PrimaryWorker.WorkerSupportsCancellation = true; PrimaryWorker.DoWork += Simulate; PrimaryWorker.RunWorkerCompleted += SimulationCompleted; SecondaryWorker = new BackgroundWorker(); SecondaryWorker.WorkerReportsProgress = true; SecondaryWorker.WorkerSupportsCancellation = true; SecondaryWorker.DoWork += Simulate; SecondaryWorker.RunWorkerCompleted += SimulationCompleted; _primaryVehicles = new List<Vehicle>(); _secondaryVehicles = new List<Vehicle>(); }
public GUIMenuTypesDestinations(Project project) { Project = project; Setup(); Load += ReadData; }
public Viewport(Project project) : base() { InitControls(); DoubleBuffered = true; Project = project; }
private Node FindEnd(Project project) { if (Destination == null) return FindOutbound(project); else return FindParking(project); }
public GUIMenuSettingsSimulation(Project project) { Project = project; Setup(); SetValuesToProject(); }
private Node FindParking(Project project) { List<Node> parkingNodes = project.Nodes.FindAll(n => n.Type == NodeTypes.Parking); double closestDistance = double.MaxValue; int closestIndex = 0; for (int i = 0; i < parkingNodes.Count; i++) { double distance = MathExtension.Distance(parkingNodes[i].Position, Destination.Position); if (distance < closestDistance) { closestIndex = i; closestDistance = distance; } } return parkingNodes[closestIndex]; }
private Node FindOutbound(Project project) { Random random = new Random(); List<Node> OutboundNodes = project.Nodes.FindAll(n => n.Type == NodeTypes.Outbound); if (OutboundNodes.Count == 0) throw new Exception("No Outbound Nodes"); return OutboundNodes[random.Next(OutboundNodes.Count - 1)]; }
public GUIMenuSettingsProject(Project project) { Project = project; Setup(); }
private static void ConvertNodes(Project project) { foreach (Node node in project.Nodes) Vertices.Add(new Vertex(node)); }
public GUIMenuTypesRoads(Project project) { Project = project; Setup(); Load += ReadData; }