コード例 #1
0
        void LaunchTask()
        {
            if (textBox.Text.Length > 5)
            {
                string searchString = textBox.Text.Trim();

                if (!string.Equals(_lastCheck, searchString, StringComparison.InvariantCultureIgnoreCase))
                {
                    _lastCheck = searchString;

                    if (null != _executeTask)
                    {
                        _executeTask.Cancel();
                        _executeTask = null;
                    }

                    listBox.Visibility = System.Windows.Visibility.Collapsed;
                    loadingLabel.Visibility = System.Windows.Visibility.Visible;
                    loadingLabel.Text = "Loading Results...";

                    _executeTask = new AsyncTask(this.Dispatcher, () => WaitXSeconds(1), (ex) => GetMatchingAddress(ex));
                    _executeTask.Execute();
                }
            }
        }
コード例 #2
0
        void AddRoutes()
        {
            pushpinCanvas.Children.Clear();
            _routeLayer.Children.Clear();

            _finalRect = null;

            for (int i = 0; i < this.Source.Routes.Count; ++i)
            {
                Microsoft.Phone.Controls.Maps.MapPolyline line = new Microsoft.Phone.Controls.Maps.MapPolyline();
                line.Locations = new Microsoft.Phone.Controls.Maps.LocationCollection();
                Random rng = new Random();

                if (this.Source.Routes[i].RoutePoints.Count > 0)
                {
                    double maxLat = this.Source.Routes[i].RoutePoints[0].Latitude;
                    double minLat = this.Source.Routes[i].RoutePoints[0].Latitude;
                    double maxLon = this.Source.Routes[i].RoutePoints[0].Longitude;
                    double minLon = this.Source.Routes[i].RoutePoints[0].Longitude;

                    foreach (MobileSrc.Commuter.Shared.GpsLocation location in this.Source.Routes[i].RoutePoints)
                    {
                        line.Locations.Add(new System.Device.Location.GeoCoordinate(location.Latitude, location.Longitude, location.Altitude));

                        maxLat = Math.Max(maxLat, location.Latitude);
                        minLat = Math.Min(minLat, location.Latitude);
                        maxLon = Math.Max(maxLon, location.Longitude);
                        minLon = Math.Min(minLon, location.Longitude);
                    }

                    Color color = RouteColors[i % RouteColors.Count()];

                    line.Opacity = 0.65;
                    line.StrokeThickness = 5;
                    line.Visibility = System.Windows.Visibility.Visible;
                    line.Stroke = new System.Windows.Media.SolidColorBrush(color);
                    _routeLayer.Children.Add(line);
                    Microsoft.Phone.Controls.Maps.LocationRect rect = new Microsoft.Phone.Controls.Maps.LocationRect(maxLat, minLon, minLat, maxLon);

                    if (null == _finalRect)
                    {
                        _finalRect = rect;
                    }
                    else
                    {
                        _finalRect.West = Math.Min(_finalRect.West, rect.West);
                        _finalRect.North = Math.Max(_finalRect.North, rect.North);

                        _finalRect.East = Math.Max(_finalRect.East, rect.East);
                        _finalRect.South = Math.Min(_finalRect.South, rect.South);
                    }
                }
            }

            if (null != _finalRect)
            {
                AsyncTask executeTask = new AsyncTask(this.Dispatcher, () => WaitForStopDownloading(), (ex) => WaitForStopDownloadingComplete(ex));
                executeTask.Execute();
            }

            for (int i = 0; i < this.Source.Routes.Count; ++i)
            {
                if (this.Source.Routes[i].RoutePoints.Count > 0)
                {
                    Color color = RouteColors[i % RouteColors.Count()];

                    Microsoft.Phone.Controls.Maps.Pushpin pushPin = new Microsoft.Phone.Controls.Maps.Pushpin();
                    pushPin.Background = new SolidColorBrush(color);
                    pushPin.Content = this.Source.Routes[i].Name;

                    MobileSrc.Commuter.Shared.GpsLocation prevPushpinLoc = this.Source.Routes[i].RoutePoints[this.Source.Routes[i].RoutePoints.Count / 2 - 5];
                    MobileSrc.Commuter.Shared.GpsLocation pushpinLoc = this.Source.Routes[i].RoutePoints[this.Source.Routes[i].RoutePoints.Count / 2];
                    pushPin.Location = new System.Device.Location.GeoCoordinate(pushpinLoc.Latitude, pushpinLoc.Longitude);

                    string name = this.Source.Routes[i].Name;

                    Border border = new Border();
                    border.BorderBrush = new SolidColorBrush(Colors.Orange);
                    border.BorderThickness = new Thickness(0);
                    border.Background = new SolidColorBrush(Colors.White);
                    border.Width = 21;
                    border.Height = 21;
                    border.Opacity = .5;
                    border.CornerRadius = new CornerRadius(10.5);

                    pushPin.Opacity = .60;

                    Button tooltipBorder = new Button();
                    tooltipBorder.Style = (Style)LayoutRoot.Resources["PhoneTransparentButton"];
                    tooltipBorder.DataContext = this.Source.Routes[i];
                    tooltipBorder.Background = new SolidColorBrush(color);
                    tooltipBorder.FontSize = 16;
                    tooltipBorder.Foreground = new SolidColorBrush(Colors.White);
                    tooltipBorder.Content = name;
                    tooltipBorder.Padding = new Thickness(5);
                    tooltipBorder.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    tooltipBorder.Margin = new Thickness(4);
                    tooltipBorder.BorderBrush = new SolidColorBrush(Colors.White);
                    tooltipBorder.BorderThickness = new Thickness(2);

                    pushpinCanvas.Children.Add(tooltipBorder);
                }
            }
        }
コード例 #3
0
        void AddRoutes()
        {
            pushpinCanvas.Children.Clear();
            _routeLayer.Children.Clear();

            _finalRect = null;

            for (int i = 0; i < this.Source.Routes.Count; ++i)
            {
                Microsoft.Phone.Controls.Maps.MapPolyline line = new Microsoft.Phone.Controls.Maps.MapPolyline();
                line.Locations = new Microsoft.Phone.Controls.Maps.LocationCollection();
                Random rng = new Random();

                if (this.Source.Routes[i].RoutePoints.Count > 0)
                {
                    double maxLat = this.Source.Routes[i].RoutePoints[0].Latitude;
                    double minLat = this.Source.Routes[i].RoutePoints[0].Latitude;
                    double maxLon = this.Source.Routes[i].RoutePoints[0].Longitude;
                    double minLon = this.Source.Routes[i].RoutePoints[0].Longitude;

                    foreach (MobileSrc.Commuter.Shared.GpsLocation location in this.Source.Routes[i].RoutePoints)
                    {
                        line.Locations.Add(new System.Device.Location.GeoCoordinate(location.Latitude, location.Longitude, location.Altitude));

                        maxLat = Math.Max(maxLat, location.Latitude);
                        minLat = Math.Min(minLat, location.Latitude);
                        maxLon = Math.Max(maxLon, location.Longitude);
                        minLon = Math.Min(minLon, location.Longitude);
                    }

                    Color color = RouteColors[i % RouteColors.Count()];

                    line.Opacity         = 0.65;
                    line.StrokeThickness = 5;
                    line.Visibility      = System.Windows.Visibility.Visible;
                    line.Stroke          = new System.Windows.Media.SolidColorBrush(color);
                    _routeLayer.Children.Add(line);
                    Microsoft.Phone.Controls.Maps.LocationRect rect = new Microsoft.Phone.Controls.Maps.LocationRect(maxLat, minLon, minLat, maxLon);

                    if (null == _finalRect)
                    {
                        _finalRect = rect;
                    }
                    else
                    {
                        _finalRect.West  = Math.Min(_finalRect.West, rect.West);
                        _finalRect.North = Math.Max(_finalRect.North, rect.North);

                        _finalRect.East  = Math.Max(_finalRect.East, rect.East);
                        _finalRect.South = Math.Min(_finalRect.South, rect.South);
                    }
                }
            }

            if (null != _finalRect)
            {
                AsyncTask executeTask = new AsyncTask(this.Dispatcher, () => WaitForStopDownloading(), (ex) => WaitForStopDownloadingComplete(ex));
                executeTask.Execute();
            }

            for (int i = 0; i < this.Source.Routes.Count; ++i)
            {
                if (this.Source.Routes[i].RoutePoints.Count > 0)
                {
                    Color color = RouteColors[i % RouteColors.Count()];

                    Microsoft.Phone.Controls.Maps.Pushpin pushPin = new Microsoft.Phone.Controls.Maps.Pushpin();
                    pushPin.Background = new SolidColorBrush(color);
                    pushPin.Content    = this.Source.Routes[i].Name;

                    MobileSrc.Commuter.Shared.GpsLocation prevPushpinLoc = this.Source.Routes[i].RoutePoints[this.Source.Routes[i].RoutePoints.Count / 2 - 5];
                    MobileSrc.Commuter.Shared.GpsLocation pushpinLoc     = this.Source.Routes[i].RoutePoints[this.Source.Routes[i].RoutePoints.Count / 2];
                    pushPin.Location = new System.Device.Location.GeoCoordinate(pushpinLoc.Latitude, pushpinLoc.Longitude);

                    string name = this.Source.Routes[i].Name;

                    Border border = new Border();
                    border.BorderBrush     = new SolidColorBrush(Colors.Orange);
                    border.BorderThickness = new Thickness(0);
                    border.Background      = new SolidColorBrush(Colors.White);
                    border.Width           = 21;
                    border.Height          = 21;
                    border.Opacity         = .5;
                    border.CornerRadius    = new CornerRadius(10.5);

                    pushPin.Opacity = .60;

                    Button tooltipBorder = new Button();
                    tooltipBorder.Style               = (Style)LayoutRoot.Resources["PhoneTransparentButton"];
                    tooltipBorder.DataContext         = this.Source.Routes[i];
                    tooltipBorder.Background          = new SolidColorBrush(color);
                    tooltipBorder.FontSize            = 16;
                    tooltipBorder.Foreground          = new SolidColorBrush(Colors.White);
                    tooltipBorder.Content             = name;
                    tooltipBorder.Padding             = new Thickness(5);
                    tooltipBorder.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    tooltipBorder.Margin              = new Thickness(4);
                    tooltipBorder.BorderBrush         = new SolidColorBrush(Colors.White);
                    tooltipBorder.BorderThickness     = new Thickness(2);

                    pushpinCanvas.Children.Add(tooltipBorder);
                }
            }
        }