private void Map_UpdateView(double zoomLevel) { m_MapLayerContainer.HideMapLayer(); if (zoomLevel >= 3) { int mid = GetMapByCenter(ArenaNetMap.Project(Map.Center, ArenaNetMap.MaxZoomLevel)); m_MapLayerContainer.ShowMapLayer(mid); } ZoomInButton.IsEnabled = (zoomLevel < ArenaNetMap.MaxZoomLevel); ZoomOutButton.IsEnabled = (zoomLevel > ArenaNetMap.MinZoomLevel); }
private void DrawPolyKeyDownHandler(object sender, KeyEventArgs e) { if (e.Key == Key.LeftCtrl && !e.IsRepeat && !m_DrawingPolygon) { m_DrawingPolygon = true; if (m_DrawingPolygonItem != null) { Map.Children.Remove(m_DrawingPolygonItem); } m_DrawingPolygonItem = null; m_DrawingPolylineItem = new MapPolyline(); m_DrawingPolylineItem.Locations = new LocationCollection(); m_DrawingPolylineItem.Opacity = 0.7; m_DrawingPolylineItem.Stroke = System.Windows.Media.Brushes.Blue; m_DrawingPolylineItem.StrokeThickness = 3; Map.Children.Add(m_DrawingPolylineItem); e.Handled = true; } if (e.Key == Key.RightCtrl && !e.IsRepeat && m_DrawingPolygonItem != null) { StringBuilder sb = new StringBuilder(); sb.Append("double[,] points = new double[,] {"); for (int i = 0, n = m_DrawingPolygonItem.Locations.Count; i < n; i++) { Point p = ArenaNetMap.Project(m_DrawingPolygonItem.Locations[i], ArenaNetMap.MaxZoomLevel); sb.AppendFormat("{0}{{{1}, {2}}}", (i == 0 ? string.Empty : ", "), p.X, p.Y); } sb.Append("};"); Window textBoxWindow = new Window(); textBoxWindow.Width = 320; textBoxWindow.Height = 240; TextBox textBox = new TextBox(); textBox.Text = sb.ToString(); textBox.TextWrapping = TextWrapping.WrapWithOverflow; textBoxWindow.Content = textBox; textBoxWindow.Show(); } }