Exemplo n.º 1
0
 private void Watcher_OnStatusChanged(object sender, GeoPositionStatusChangedEventArgs args)
 {
     if (args.Status != GeoPositionStatus.Ready)
     {
         return;
     }
     this.SetProgressIndicator(false);
     GeolocationHelper.HandleDisabledLocationSettings();
 }
Exemplo n.º 2
0
        private void Map_OnLoaded(object sender, RoutedEventArgs e)
        {
            MapsSettings.ApplicationContext.ApplicationId       = ("55677f7c-3dab-4a57-95b2-4efd44a0e692");
            MapsSettings.ApplicationContext.AuthenticationToken = ("1jh4FPILRSo9J1ADKx2CgA");
            MapLayer   mapLayer          = new MapLayer();
            MapOverlay mapOverlayPushpin = this._mapOverlayPushpin;

            ((Collection <MapOverlay>)mapLayer).Add(mapOverlayPushpin);
            this.Map.Layers.Add(mapLayer);
            if (this.ViewModel.GeoCoordinate != null)
            {
                this.SetPushpin(this.ViewModel.GeoCoordinate, true);
            }
            else
            {
                if (!this._canGetPlacement)
                {
                    return;
                }
                try
                {
                    GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
                    watcher.PositionChanged += ((EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >)((o, args) =>
                    {
                        if (!(this.ViewModel.GeoCoordinate == null))
                        {
                            return;
                        }
                        PageBase.SetInProgress(false);
                        this.SetPushpin(args.Position.Location, true);
                        watcher.Stop();
                    }));
                    watcher.StatusChanged += ((EventHandler <GeoPositionStatusChangedEventArgs>)((o, args) =>
                    {
                        if (args.Status != GeoPositionStatus.Ready)
                        {
                            return;
                        }
                        GeolocationHelper.HandleDisabledLocationSettings();
                    }));
                    watcher.Start();
                    PageBase.SetInProgress(true);
                }
                catch
                {
                }
            }
        }
Exemplo n.º 3
0
 protected override void HandleOnNavigatedTo(NavigationEventArgs e)
 {
     try
     {
         base.HandleOnNavigatedTo(e);
         if (!this._isInitialized)
         {
             base.DataContext = (new ViewModelBase());
             this._shouldPick = ((Page)this).NavigationContext.QueryString.ContainsKey("Pick") && ((Page)this).NavigationContext.QueryString["Pick"] == true.ToString();
             if (!this._shouldPick)
             {
                 this.MoveMapToPosition(new GeoCoordinate(double.Parse(((Page)this).NavigationContext.QueryString["latitude"], (IFormatProvider)CultureInfo.InvariantCulture), double.Parse(((Page)this).NavigationContext.QueryString["longitude"], (IFormatProvider)CultureInfo.InvariantCulture)));
                 return;
             }
             if (!AppGlobalStateManager.Current.GlobalState.AllowUseLocationQuestionAsked || !AppGlobalStateManager.Current.GlobalState.AllowUseLocation)
             {
                 bool flag = MessageBox.Show(CommonResources.MapAttachment_AllowUseLocation, CommonResources.AccessToLocation, (MessageBoxButton)1) == MessageBoxResult.OK;
                 AppGlobalStateManager.Current.GlobalState.AllowUseLocationQuestionAsked = true;
                 AppGlobalStateManager.Current.GlobalState.AllowUseLocation = flag;
             }
             this.InitializeAppBar();
             this._isInitialized = true;
         }
         if (!(this._lastPosition == null))
         {
             return;
         }
         if (!AppGlobalStateManager.Current.GlobalState.AllowUseLocation)
         {
             return;
         }
         try
         {
             if (this._watcher != null)
             {
                 this._watcher.PositionChanged -= new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(this.Watcher_OnPositionChanged);
                 this._watcher.StatusChanged   -= new EventHandler <GeoPositionStatusChangedEventArgs>(this.Watcher_OnStatusChanged);
             }
             this._watcher = new GeoCoordinateWatcher();
             this._watcher.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(this.Watcher_OnPositionChanged);
             this._watcher.StatusChanged   += new EventHandler <GeoPositionStatusChangedEventArgs>(this.Watcher_OnStatusChanged);
             GeoCoordinateWatcher watcher = this._watcher;
             if (watcher != null)
             {
                 // ISSUE: explicit non-virtual call
                 watcher.Start();
             }
             this.SetProgressIndicator(true);
         }
         catch (Exception ex)
         {
             this.SetProgressIndicator(false);
             if (ex.HResult != -2147467260)
             {
                 return;
             }
             GeolocationHelper.HandleDisabledLocationSettings();
         }
     }
     catch (Exception ex)
     {
         Logger.Instance.ErrorAndSaveToIso("Failed to OnNavigatedTo MapAttachmentPage", ex);
     }
 }
Exemplo n.º 4
0
        protected override void HandleOnNavigatedTo(NavigationEventArgs e)
        {
            base.HandleOnNavigatedTo(e);
            if (this._isInitialized)
            {
                return;
            }
            PlacementSelectionViewModel viewModel = new PlacementSelectionViewModel(long.Parse(((Page)this).NavigationContext.QueryString["CommunityId"]), (Place)ParametersRepository.GetParameterForIdAndReset("PlacementSelectionPlace"));

            base.DataContext = viewModel;
            ApplicationBarIconButton applicationBarIconButton1 = new ApplicationBarIconButton();
            Uri uri1 = new Uri("/Resources/check.png", UriKind.Relative);

            applicationBarIconButton1.IconUri = uri1;
            string appBarMenuSave = CommonResources.AppBarMenu_Save;

            applicationBarIconButton1.Text = appBarMenuSave;
            int num = this.ViewModel.GeoCoordinate != null ? 1 : 0;

            applicationBarIconButton1.IsEnabled = (num != 0);
            ApplicationBarIconButton appBarButtonSave          = applicationBarIconButton1;
            ApplicationBarIconButton applicationBarIconButton2 = new ApplicationBarIconButton();
            Uri uri2 = new Uri("/Resources/appbar.cancel.rest.png", UriKind.Relative);

            applicationBarIconButton2.IconUri = uri2;
            string appBarCancel = CommonResources.AppBar_Cancel;

            applicationBarIconButton2.Text = appBarCancel;
            ApplicationBarIconButton applicationBarIconButton3 = applicationBarIconButton2;

            appBarButtonSave.Click += ((EventHandler)((p, f) =>
            {
                ((Control)this).Focus();
                viewModel.SaveChanges();
            }));
            applicationBarIconButton3.Click += ((EventHandler)((p, f) => Navigator.Current.GoBack()));
            this.ApplicationBar              = ((IApplicationBar)ApplicationBarBuilder.Build(new Color?(), new Color?(), 0.9));
            viewModel.PropertyChanged       += (PropertyChangedEventHandler)((p, f) => appBarButtonSave.IsEnabled = (viewModel.IsFormEnabled && viewModel.GeoCoordinate != null));
            this.ApplicationBar.Buttons.Add(appBarButtonSave);
            this.ApplicationBar.Buttons.Add(applicationBarIconButton3);
            try
            {
                if (!AppGlobalStateManager.Current.GlobalState.AllowUseLocationQuestionAsked || !AppGlobalStateManager.Current.GlobalState.AllowUseLocation)
                {
                    bool flag = MessageBox.Show(CommonResources.MapAttachment_AllowUseLocation, CommonResources.AccessToLocation, (MessageBoxButton)1) == MessageBoxResult.OK;
                    AppGlobalStateManager.Current.GlobalState.AllowUseLocationQuestionAsked = true;
                    AppGlobalStateManager.Current.GlobalState.AllowUseLocation = flag;
                }
                if (!AppGlobalStateManager.Current.GlobalState.AllowUseLocation)
                {
                    this._canGetPlacement = false;
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147467260)
                {
                    GeolocationHelper.HandleDisabledLocationSettings();
                    this._canGetPlacement = false;
                }
            }
            this._isInitialized = true;
        }