public DrawCrossroadCommand(object sender, ForestPaths forestPaths, CrossroadContext context) { canvas = (Canvas)sender; this.forestPaths = forestPaths; this.context = context; crossroad = context.Сrossroad; }
public DrawConnectionCommand(object sender, Ellipse firstEllipse, Ellipse secondEllipse, ForestPaths forestPaths) { canvas = (Canvas)sender; this.forestPaths = forestPaths; this.firstEllipse = firstEllipse; this.secondEllipse = secondEllipse; firstKey = firstEllipse.Name; secondKey = secondEllipse.Name; }
public EditTypeCommand(object sender, Ellipse ellipse, ForestPaths forestPaths, CrossroadContext context) { canvas = (Canvas)sender; this.ellipse = ellipse; this.forestPaths = forestPaths; key = ellipse.Name; this.context = context; drawParams = context.GetDrawInformation(); crossroad = forestPaths.GetCrossroad(key); newCrossroad = context.Сrossroad; point = forestPaths.GetCrossroad(key).Position; DrawParamsInit(); }
public MainWindow() { InitializeComponent(); InitializeLegend(); GlobalRangeTree = new TwoDRangeTree <ICrossroad, double>(comparerByX, comparerByY); using (FileStream fs = new FileStream("./sample.txt", FileMode.Open)) { BinaryFormatter formatter = new BinaryFormatter(); ForestPaths newForestPath = (ForestPaths)formatter.Deserialize(fs); GlobalForestPaths.Update(newForestPath); DrawForrestPaths(); BuildRangeTree(); } }
public LineBuilder BuildLine(ForestPaths forestPaths, string firstKey, string secondKey) { x1 = forestPaths.GetCrossroad(firstKey).Position.X; y1 = forestPaths.GetCrossroad(firstKey).Position.Y; x2 = forestPaths.GetCrossroad(secondKey).Position.X; y2 = forestPaths.GetCrossroad(secondKey).Position.Y; double weight = forestPaths.GetRoadWeight(firstKey, secondKey); string formatWeight = string.Format("{0:0.##}", weight); LineBuilder builder = new LineBuilder(); builder.BuildName($"{firstKey}_{secondKey}"); builder.BuildStroke(Brushes.Gray); builder.BuildStrokeThickness(3); builder.BuildCursor(Cursors.Hand); builder.BuildCoordinates(x1, x2, y1, y2); builder.BuildToolTip($"{firstKey}_{secondKey} ({formatWeight})"); return(builder); }
private void OpenButton_Click(object sender, RoutedEventArgs e) { BinaryFormatter formatter = new BinaryFormatter(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == true) { using (FileStream fs = new FileStream(openFileDialog.FileName, FileMode.Open)) { try { ForestPaths newForestPath = (ForestPaths)formatter.Deserialize(fs); GlobalForestPaths.Update(newForestPath); DrawForrestPaths(); BuildRangeTree(); } catch (SerializationException) { MessageBox.Show($"Unacceptable file", "Error"); } } } }
public static CrossroadDrawInformation GetDrawInformation(this Ellipse ellipse, ForestPaths forestPaths) { return(forestPaths.GetCrossroad(ellipse.Name).GetDrawInformation()); }
public static void Unhighlight(this Ellipse ellipse, ForestPaths forestPaths) { var drawParams = ellipse.GetDrawInformation(forestPaths); DrawEllipse(ellipse, drawParams); }
public EllipseBuilder() { Reset(); forestPaths = mainWindow.GlobalForestPaths; }
public List <ICrossroad> FindWay(ForestPaths forestPaths, CampCrossroad start, BusStopCrossroad goal) { Comparer comparer = new Comparer(estimateFullPathLength); var openSet = new IntervalHeap <ICrossroad>(comparer); var closedSet = new List <ICrossroad>(); cameFrom.Add(start, null); pathLengthFromStart.Add(start, 0); heuristicEstimatePathLength.Add(start, forestPaths. GetDistanceBetweenCrossroad(start, goal)); estimateFullPathLength.Add(start, GetEstimateFullPathLength(start)); openSet.Add(start); while (openSet.Count > 0) { ICrossroad current = openSet.DeleteMin(); if (current == goal) { return(GetPathForCrossroad(current)); } closedSet.Add(current); foreach (var next in forestPaths.GetNextCrossroads(current)) { double newPathLengthFromStart = pathLengthFromStart[current] + forestPaths.GetDistanceBetweenCrossroad(current, next); if (closedSet.Contains(next)) { continue; } if (!pathLengthFromStart.ContainsKey(next) || newPathLengthFromStart < pathLengthFromStart[next]) { if (!pathLengthFromStart.ContainsKey(next)) { pathLengthFromStart.Add(next, default); } pathLengthFromStart[next] = newPathLengthFromStart; if (!heuristicEstimatePathLength.ContainsKey(next)) { heuristicEstimatePathLength.Add(next, forestPaths. GetDistanceBetweenCrossroad(next, goal)); } if (!estimateFullPathLength.ContainsKey(next)) { estimateFullPathLength.Add(next, default); } estimateFullPathLength[next] = GetEstimateFullPathLength(next); if (!cameFrom.ContainsKey(next)) { cameFrom.Add(next, default); } cameFrom[next] = current; if (!openSet.Contains(next)) { openSet.Add(next); } } } } return(null); }
public DeleteConnectionCommand(object sender, Line line, ForestPaths forestPaths) { canvas = (Canvas)sender; this.line = line; this.forestPaths = forestPaths; }
public DeleteCrossroadCommand(object sender, Ellipse ellipse, ForestPaths forestPaths) { canvas = (Canvas)sender; this.ellipse = ellipse; this.forestPaths = forestPaths; }