Exemplo n.º 1
0
        /// <summary>
        /// Create a Pivot and PivotItem, and fill with place info
        /// </summary>
        /// <param name="place">Place instance</param>
        private async void CreatePivotItem(string place)
        {
            // Get address of a Geopoint location
            MainGrid.Children.Clear();
            string[] split    = place.Split(new Char[] { '\n', ',' });
            Geopoint geoPoint = new Geopoint(new BasicGeoposition()
            {
                Latitude  = Convert.ToDouble(split[1]),
                Longitude = Convert.ToDouble(split[2])
            });
            var newPivot = new Pivot {
                Title = "MICROSOFT SENSORCORE SAMPLE", Margin = new Thickness(0, 12, 0, 0), Foreground = new SolidColorBrush(Colors.Black)
            };
            var pivotItem = new PivotItem {
                Header = split[0].ToString(), Foreground = new SolidColorBrush(Colors.Black), FontSize = 20
            };
            var stackPanel = new StackPanel();
            // Get address of a Geopoint location
            var addressTask = GeoLocationHelper.GetAddress(geoPoint);

            stackPanel.Children.Add(CreateTextBlock("Latitude:", split[1].ToString()));
            stackPanel.Children.Add(CreateTextBlock("Longitude:", split[2].ToString()));
            stackPanel.Children.Add(CreateTextBlock("Radius:", split[3].ToString() + " m"));
            stackPanel.Children.Add(CreateTextBlock("Length of stay:", split[4].ToString()));
            stackPanel.Children.Add(CreateTextBlock("Total length of stay:", split[5].ToString()));
            stackPanel.Children.Add(CreateTextBlock("Total visit count:", split[6].ToString()));
            pivotItem.Content = stackPanel;
            newPivot.Items.Add(pivotItem);
            MainGrid.Children.Add(newPivot);
            _addressString = await addressTask;
            //Add address to the pivot
            stackPanel.Children.Add(CreateTextBlock("Address:", _addressString));
        }