private void Unload_Map(object sender, RoutedEventArgs e) { Points asd = Points.getObj(); ProcessingData.UnloadToXML(asd.Towns); lastAction.Text = "Выгружены города"; }
public void ComplementList(object sender, MouseButtonEventArgs e, Canvas theCanvas) { Point pt = e.GetPosition((UIElement)sender); HitTestResult hitResult = VisualTreeHelper.HitTest(MyCanvas, pt); DrawingVisual result = hitResult.VisualHit as DrawingVisual; if (result != null) { ProcessingData.SetWay(pt, out string lastActionText, theCanvas); lastAction.Text = lastActionText; } else { AddTown(pt, out string nameTown); lastAction.Text = "Добавлен город " + nameTown; } }
// Точка public void Draw(Point point, string text) { DrawingContext myVisualContext = myVisual.RenderOpen(); Pen ellipsePen = new Pen(Brushes.MediumTurquoise, 3); myVisualContext.DrawEllipse(ellipsePen.Brush, ellipsePen, point, 5, 5); string formattedTextPoint = ProcessingData.FromPointToString(point); FormattedText formattedText = new FormattedText(formattedTextPoint + "\n" + text, new CultureInfo("ru-RU"), FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.Black, VisualTreeHelper.GetDpi(this).PixelsPerDip); Point formattedPoint = new Point(point.X, point.Y + 10); myVisualContext.DrawText(formattedText, formattedPoint); myVisualContext.Close(); }
private void Upload_Map(object sender, RoutedEventArgs e) { (TownList <Point, string>, int)uploadedTowns = ProcessingData.UploadFromXML(); int countTowns = uploadedTowns.Item2; MyCanvas.Children.Clear(); Points points = Points.getObj(); points.Towns = uploadedTowns.Item1; TownList <Point, string> checkedTowns = points.Towns; for (int i = 0; i < countTowns; i++) { MyCanvas.Children.Add(new CustomCanvas(checkedTowns.GetObject(i).TownPoint, checkedTowns.GetElementName(i))); } lastAction.Text = "Загружены города"; }
public int GetIndex(Point pt) { if (head != null) { InsideDataTown <Point, string> current = head; int index = 0; while (current != null && current != ProcessingData.GetTown(pt, "obj")) { current = current.Next; index++; } return(index); } else { return(0); } }