Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Runtime.InteropServices.WindowsRuntime;
- using Windows.Foundation;
- using Windows.Foundation.Collections;
- using Windows.UI.Xaml;
- using Windows.UI.Xaml.Controls;
- using Windows.UI.Xaml.Controls.Primitives;
- using Windows.UI.Xaml.Data;
- using Windows.UI.Xaml.Input;
- using Windows.UI.Xaml.Media;
- using Windows.UI.Xaml.Navigation;
- using Windows.UI.Xaml.Controls.Maps;
- using Windows.Devices.Geolocation;
- using Windows.UI;
- using System.Diagnostics;
- // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
- namespace App4
- {
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public sealed partial class MainPage : Page
- {
- public MainPage()
- {
- this.InitializeComponent();
- }
- private void AppBarButton_Click(object sender, RoutedEventArgs e)
- {
- MapElementsLayer item = new MapElementsLayer();
- MapPolygon shape1 = new MapPolygon();
- 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 } }));
- shape1.FillColor = Colors.Purple;
- item.MapElements.Add(shape1);
- MapView.Layers.Add(item);
- // new Int32[] { 1, 3, 4, 5 }
- }
- private void AppBarButton_Click2(object sender, RoutedEventArgs e)
- {
- MapElementsLayer item = new MapElementsLayer();
- MapPolygon item1 = new MapPolygon();
- 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 } }));
- item1.FillColor = Colors.Red;
- item.MapElements.Add(item1);
- MapView.Layers.Add(item);
- }
- private void AppBarButton_Click_1(object sender, RoutedEventArgs e)
- {
- var layer = (MapElementsLayer)(MapView.Layers[0]);
- Random random = new Random();
- Byte[] b = new Byte[4];
- random.NextBytes(b);
- foreach (MapPolygon shape in layer.MapElements)
- {
- shape.FillColor = Color.FromArgb(128, b[0], b[1], b[2]);
- shape.StrokeColor = Colors.Black;
- shape.StrokeThickness = 10;
- }
- }
- private void AppBarButton_Click_2(object sender, RoutedEventArgs e)
- {
- var ls = new ListView();
- ls.IsItemClickEnabled = true;
- ls.ItemClick += Lb_ItemClick;
- ls.Width = 100;
- ls.Height = 300;
- var pop = new Popup();
- ls.Items.Add(new ActionItem("3D", () => { Debug.WriteLine("3D"); pop.IsOpen = true; MapView.Style = MapStyle.Aerial3D; }));
- ls.Items.Add(new ActionItem("2D", () => { Debug.WriteLine("2D"); pop.IsOpen = true; MapView.Style = MapStyle.Aerial; }));
- pop.IsLightDismissEnabled = false;
- pop.Child = ls;
- pop.IsOpen = true;
- }
- private void Lb_ItemClick(object sender, ItemClickEventArgs e)
- {
- ((ActionItem)e.ClickedItem).Action();
- }
- private void AppBarButton_Click_3(object sender, RoutedEventArgs e)
- {
- int i = MapView.Layers.Count - 1;
- while (i >= 0)
- {
- var layer = (MapElementsLayer)(MapView.Layers[i]);
- layer.MapElements.Clear();
- i--;
- }
- // MapView.Layers.Clear();
- }
- }
- public class ActionItem
- {
- public ActionItem(String label, Action action)
- {
- Label = label;
- Action = action;
- }
- public string Label { get; }
- public Action Action { get; }
- public override string ToString()
- {
- return Label;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement