예제 #1
0
 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;
 }
예제 #3
0
        ////////// 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;
        }
예제 #4
0
 public SimulationData(Project project, List<VehicleData> primary, List<VehicleData> secondary)
 {
     Project = project;
     PrimaryData = primary;
     SecondaryData = secondary;
     Date = DateTime.Now;
 }
예제 #5
0
 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();
     }
 }
예제 #6
0
 // 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;
 }
예제 #7
0
 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;
 }
예제 #9
0
 public GUIToolEditNode(Node node, Project project)
 {
     Node = node;
     Project = project;
     Setup();
     Load += ReadData;
     FormClosing += SaveData;
 }
예제 #10
0
 public GUIMenuSimulationRun(Project project)
 {
     Project = project;
     Setup();
     Simulation = new Simulation(project);
     Simulation.PrimaryWorker.ProgressChanged += PrimaryProgressChanged;
     Simulation.SecondaryWorker.ProgressChanged += SecondaryProgressChanged;
     Simulation.SimulationDone += OnSimulationDone;
     FormClosing += OnFormClosing;
 }
예제 #11
0
 private void CreateClick(object sender, EventArgs args)
 {
     if (ProjectName.Text.Length > 0)
     {
         NewProject = new Project(ProjectName.Text);
         Close();
     }
     else
     {
         ProjectNameLabel.ForeColor = Color.DarkRed;
     }
 }
예제 #12
0
        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;
 }
예제 #14
0
 public Viewport(Project project) : base()
 {
     InitControls();
     DoubleBuffered = true;
     Project = project;
 }
예제 #15
0
 private Node FindEnd(Project project)
 {
     if (Destination == null) return FindOutbound(project);
     else return FindParking(project);
 }
 public GUIMenuSettingsSimulation(Project project)
 {
     Project = project;
     Setup();
     SetValuesToProject();
 }
예제 #17
0
 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];
 }
예제 #18
0
 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();
 }
예제 #20
0
 private static void ConvertNodes(Project project)
 {
     foreach (Node node in project.Nodes)
         Vertices.Add(new Vertex(node));
 }
예제 #21
0
 public GUIMenuTypesRoads(Project project)
 {
     Project = project;
     Setup();
     Load += ReadData;
 }