Exemple #1
0
        private async void BuildingSearch(string name)
        {

            if (buildLoaded)
            {
                foreach (var obj in _poisByBuilding.pois)
                {
                    if (obj.name.Equals(name) || obj.description.Equals(name))
                    {
                        _selectedBuild = obj.buid;
                        _selectedFloor = obj.floor_number;

                        Dispatcher.BeginInvoke(() =>
                        {
                            txt_cur.Text = _selectedFloor;
                        });

                        _wmstileprovider = new WMSTiles();
                        _wmstileprovider.setBuidAndFloor(_selectedBuild, _selectedFloor);
                        if (Mymap.TileSources.Contains(_wmstileprovider))
                            Mymap.TileSources.Remove(_wmstileprovider);
                        Mymap.TileSources.Add(_wmstileprovider);

                        ChangeFloor();
                        if (directions_grid.Visibility == Visibility.Visible)
                            GetRouteOfTheCurrentFloor();
                        foreach (var o in poisByFloor_layer)
                        {
                            var x = o.Content as Image;

                            if (o.GeoCoordinate == new GeoCoordinate(double.Parse(obj.coordinates_lat, CultureInfo.InvariantCulture), double.Parse(obj.coordinates_lon, CultureInfo.InvariantCulture)))
                                buildingImg_tap(x.DataContext as FloorPoisDetails);
                        }

                        Mymap.SetView(new GeoCoordinate(double.Parse(obj.coordinates_lat, CultureInfo.InvariantCulture), double.Parse(obj.coordinates_lon, CultureInfo.InvariantCulture)), 20);

                        _foundBuilding = true;

                        break;
                    }
                }

            }



            foreach (var obj in _worldbuildings.buildings)
            {
                if (obj.name.Equals(name))
                {
                    var floor_num = "";
                    var lat = double.Parse(obj.coordinates_lat, CultureInfo.InvariantCulture);
                    var lon = double.Parse(obj.coordinates_lon, CultureInfo.InvariantCulture);

                    var settings1 = IsolatedStorageFile.GetUserStoreForApplication();
                    if (settings1.DirectoryExists(obj.buid) && checkCompleted(obj.buid))
                    {
                        // load staff to the map
                        clear();
                        ReadAllBuildingFloorsFromIsolatedStorage(obj.buid);
                        ReadPoisByBuildingFromIsolatedStorage(obj.buid);
                        addBuildingsToMap(obj.buid);

                        buildLoaded = true;
                        loadBuidingToMap(obj.buid);
                        createAppBarMenuItem();
                    }
                    else
                    {
                        isDownloading = true;
                        //ApplicationBar.IsVisible = false;
                        //downloading.Visibility = Visibility.Visible;

                        loading.Visibility = Visibility.Visible;
                        loading.IsIndeterminate = true;

                        clear();
                        // download staff and show them to the map
                        var fsdf = await DownloadPoisBuildStaff(obj.buid);
                        ReadAllBuildingFloorsFromIsolatedStorage(obj.buid);
                        ReadPoisByBuildingFromIsolatedStorage(obj.buid);

                        addBuildingsToMap(obj.buid);
                        buildLoaded = true;
                        loadBuidingToMap(obj.buid);

                        loading.Visibility = Visibility.Collapsed;
                        loading.IsIndeterminate = false;

                        createAppBarMenuItem();
                        isDownloading = false;
                    }


                    Mymap.SetView(new GeoCoordinate(lat, lon), 20, MapAnimationKind.Parabolic);

                    SystemTray.IsVisible = false;

                    _foundBuilding = true;
                    break;
                }
            }
        }
Exemple #2
0
        public MainPage()
        {

            InitializeComponent();


            // rotation
            _rotateGesture = new MapRotationGesture(Mymap);


            //initialize settings
            GetSettings();

            _wmstileprovider = new WMSTiles();
            _wmstileprovider.setBuidAndFloor("", "");

            // tracking current position
            LocalizeGeoWatcher();

            _buildingSearch = "";

            // read data from storage
            IsolatedStorageDataRead();

            // set curren position to 0,0
            mypositionlayer = new MapLayer();
            mypositionoverlay = new MapOverlay
            {
                GeoCoordinate = new GeoCoordinate(0, 0),
                PositionOrigin = new Point(0.5, 1.0)
            };

            Mymap.Height = Application.Current.Host.Content.ActualHeight - 50;

            double width = Application.Current.Host.Content.ActualWidth;
            stack.MaxWidth = width;
            stack.Width = width;
            grid_search.Width = width;
            grid_search.MaxWidth = width;

            addBuildingsToMap(null);
            AddBuildingToSearch();
        }
Exemple #3
0
        private void MapView_Loaded(object sender, RoutedEventArgs e)
        {
            // make transparent the notification bar then hide it
            SystemTray.Opacity = 0.0;
            SystemTray.IsVisible = false;

            if (!_loaded)
            {
                _loaded = true;
                // set the zoom level
                Mymap.ZoomLevel = 2;
            }

            _wmstileprovider = new WMSTiles();
            _wmstileprovider.setBuidAndFloor("", "");

            if (_tilesCheck)
                Mymap.TileSources.Add(_wmstileprovider);

            var settings1 = IsolatedStorageFile.GetUserStoreForApplication();
            if (!settings1.FileExists("WorldBuilding"))
            {
                //var result = MessageBox.Show("You have to download the required maps to use all the features. Download now?", "Download Required Maps", MessageBoxButton.OKCancel);

                //if (result == MessageBoxResult.OK)
                //{
                    var isNetwork = NetworkInterface.GetIsNetworkAvailable();

                    if (isNetwork)
                    {
                        if (isDownloading)
                            return;
                        isDownloading = true;
                        loading.Visibility = Visibility.Visible;
                        loading.IsIndeterminate = true;
                        DownloadRequireStaff();
                        
                    }
                    //else
                    //    MessageBox.Show("No Internet Connection. Please check your internet connection and try again!");
                //}
            }
        }