Advertisement
Guest User

Untitled

a guest
Mar 27th, 2018
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.36 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Runtime.InteropServices.WindowsRuntime;
  6. using Windows.Foundation;
  7. using Windows.Foundation.Collections;
  8. using Windows.UI.Xaml;
  9. using Windows.UI.Xaml.Controls;
  10. using Windows.UI.Xaml.Controls.Primitives;
  11. using Windows.UI.Xaml.Data;
  12. using Windows.UI.Xaml.Input;
  13. using Windows.UI.Xaml.Media;
  14. using Windows.UI.Xaml.Navigation;
  15. using Windows.UI.Xaml.Controls.Maps;
  16. using Windows.Devices.Geolocation;
  17. using Windows.UI;
  18. using System.Diagnostics;
  19.  
  20. // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
  21.  
  22. namespace App4
  23. {
  24.     /// <summary>
  25.     /// An empty page that can be used on its own or navigated to within a Frame.
  26.     /// </summary>
  27.     public sealed partial class MainPage : Page
  28.     {
  29.         public MainPage()
  30.         {
  31.             this.InitializeComponent();
  32.         }
  33.  
  34.         private void AppBarButton_Click(object sender, RoutedEventArgs e)
  35.         {
  36.             MapElementsLayer item = new MapElementsLayer();
  37.            
  38.             MapPolygon shape1 = new MapPolygon();
  39.            
  40.             shape1.Paths.Add(new Geopath(new BasicGeoposition[] { new BasicGeoposition() { Latitude = 0, Longitude = 0 }, new BasicGeoposition() { Latitude = 20, Longitude = 20 }, new BasicGeoposition() { Latitude = 0, Longitude = 20 } }));
  41.          
  42.             shape1.FillColor = Colors.Purple;
  43.             item.MapElements.Add(shape1);
  44.             MapView.Layers.Add(item);
  45.            
  46.             // new Int32[] { 1, 3, 4, 5 }
  47.         }
  48.  
  49.         private void AppBarButton_Click2(object sender, RoutedEventArgs e)
  50.         {
  51.             MapElementsLayer item = new MapElementsLayer();
  52.  
  53.             MapPolygon item1 = new MapPolygon();
  54.  
  55.             item1.Paths.Add(new Geopath(new BasicGeoposition[] { new BasicGeoposition() { Latitude = 0, Longitude = 0 }, new BasicGeoposition() { Latitude = 60, Longitude = 40 }, new BasicGeoposition() { Latitude = 0, Longitude = 50 } }));
  56.  
  57.             item1.FillColor = Colors.Red;
  58.             item.MapElements.Add(item1);
  59.             MapView.Layers.Add(item);
  60.         }
  61.        
  62.         private void AppBarButton_Click_1(object sender, RoutedEventArgs e)
  63.         {
  64.             var layer = (MapElementsLayer)(MapView.Layers[0]);
  65.             Random random = new Random();
  66.             Byte[] b = new Byte[4];
  67.             random.NextBytes(b);
  68.             foreach (MapPolygon shape in layer.MapElements)
  69.             {
  70.                 shape.FillColor = Color.FromArgb(128, b[0], b[1], b[2]);
  71.                 shape.StrokeColor = Colors.Black;
  72.                 shape.StrokeThickness = 10;
  73.  
  74.                
  75.             }
  76.            
  77.         }
  78.        
  79.         private void AppBarButton_Click_2(object sender, RoutedEventArgs e)
  80.         {
  81.            
  82.             var ls = new ListView();
  83.  
  84.             ls.IsItemClickEnabled = true;
  85.             ls.ItemClick += Lb_ItemClick;
  86.  
  87.             ls.Width = 100;
  88.             ls.Height = 300;
  89.            
  90.             var pop = new Popup();
  91.             ls.Items.Add(new ActionItem("3D", () => { Debug.WriteLine("3D"); pop.IsOpen = true; MapView.Style = MapStyle.Aerial3D; }));
  92.             ls.Items.Add(new ActionItem("2D", () => { Debug.WriteLine("2D"); pop.IsOpen = true; MapView.Style = MapStyle.Aerial; }));
  93.             pop.IsLightDismissEnabled = false;
  94.             pop.Child = ls;
  95.             pop.IsOpen = true;
  96.  
  97.         }
  98.  
  99.         private void Lb_ItemClick(object sender, ItemClickEventArgs e)
  100.         {
  101.             ((ActionItem)e.ClickedItem).Action();
  102.         }
  103.  
  104.         private void AppBarButton_Click_3(object sender, RoutedEventArgs e)
  105.         {
  106.             int i = MapView.Layers.Count - 1;
  107.             while (i >= 0)
  108.             {
  109.  
  110.                 var layer = (MapElementsLayer)(MapView.Layers[i]);
  111.                 layer.MapElements.Clear();
  112.                 i--;
  113.             }
  114.  
  115.             // MapView.Layers.Clear();  
  116.  
  117.          
  118.            
  119.         }
  120.     }
  121.  
  122.     public class ActionItem
  123.     {
  124.         public ActionItem(String label, Action action)
  125.         {
  126.             Label = label;
  127.             Action = action;
  128.         }
  129.  
  130.         public string Label { get; }
  131.         public Action Action { get; }
  132.  
  133.         public override string ToString()
  134.         {
  135.             return Label;
  136.         }
  137.     }
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement