Пример #1
0
        private void CurrentViewModel_LongLoadingStartEvent(object sender, SimpleMvvmToolkit.NotificationEventArgs e)
        {
            systemTrayVisibleBck       = SystemTray.IsVisible;
            SystemTray.Opacity         = 0.3;
            SystemTray.BackgroundColor = Colors.Transparent;
            SystemTray.SetIsVisible(this, true);

            ProgressIndicator prog = new ProgressIndicator();

            prog.IsVisible       = true;
            prog.IsIndeterminate = true;
            prog.Text            = AppResources.LoadingIndicator;
            SystemTray.SetProgressIndicator(this, prog);
        }
Пример #2
0
        public async Task Save()
        {
            if (SelectedIndex >= 0 && SelectedIndex < ImagePosts.Count)
            {
                bool cantSave = false;

                Models.API.APIPost.FileTypes fileType = (ImagePosts[SelectedIndex] as ImageViewerPostViewModel).FileType;
                if (fileType == Models.API.APIPost.FileTypes.webm || fileType == Models.API.APIPost.FileTypes.swf || fileType == Models.API.APIPost.FileTypes.gif)
                {
                    cantSave = true;
                }

                ProgressIndicator progress = new ProgressIndicator
                {
                    IsVisible       = true,
                    IsIndeterminate = true,
                    Text            = cantSave ? AppResources.ImageViewerPage_CantSave : AppResources.ImageViewerPage_SavingImage
                };

                PhoneApplicationPage page = (App.Current.RootVisual as PhoneApplicationFrame).Content as PhoneApplicationPage;

                SystemTray.SetOpacity(page, 0.99);
                SystemTray.SetIsVisible(page, true);
                SystemTray.SetProgressIndicator(page, progress);

                if (cantSave)
                {
                    await Task.Delay(1000);
                }
                else
                {
                    bool result = await SaveInternal(ImagePosts[SelectedIndex] as ImageViewerPostViewModel);

                    if (result)
                    {
                        progress.Text = AppResources.ImageViewerPage_ImageSaved;
                        await Task.Delay(400);
                    }
                    else
                    {
                        progress.Text = AppResources.ImageViewerPage_ImageFailed;
                        await Task.Delay(1000);
                    }
                }

                SystemTray.SetProgressIndicator(page, null);
                SystemTray.SetIsVisible(page, false);
            }
        }
        /// <summary>
        /// Closes the control and reverts any changes made to the underlying page.
        /// </summary>
        private void Close()
        {
            _timer.Stop();
            _camera.Initialized -= Camera_Initialized;
            _camera.Dispose();
            _isDone = true;

            _frame.BackKeyPress -= Frame_BackKeyPress;

            SystemTray.SetIsVisible(_underPage, _underPageTrayVisible);
            _underPage.ApplicationBar.IsVisible = _underPageAppBarVisible;

            // No null check, we know it's always non-null
            CloseRequested(this, EventArgs.Empty);
        }
Пример #4
0
        public ImportTracks()
        {
            InitializeComponent();

            _fileIO        = new FileIO();
            _serializer    = new Serializer();
            _miscFunctions = new MiscFunctions();
            SystemTray.SetIsVisible(this, true);
            _prog = new ProgressIndicator();
            SystemTray.SetProgressIndicator(this, _prog);

            Routes = new ObservableCollection <ExternalStorageFile>();
            GetUserFolder();
            DataContext = this;
        }
Пример #5
0
        private void FetchList(GeoPositionChangedEventArgs <GeoCoordinate> arg)
        {
            progressIndicator.Text = AppResources.LoadingData;
            watcher.Stop();
            GeoCoordinate location = arg.Position.Location;

            Debug.WriteLine(location.Latitude + ", " + location.Longitude);

            List <BikeStopViewModel> temp     = new List <BikeStopViewModel>();
            List <string>            nameList = new List <string>();

            foreach (BikeStopViewModel m in App.ViewModel.Items)
            {
                temp.Add(new BikeStopViewModel()
                {
                    Name         = m.Name,
                    Address      = m.Address,
                    Availability = 0,
                    Capacity     = 0,
                    Distance     = string.Format("{0:0,0}", LatLngDistance(location.Latitude, location.Longitude, m.Latitude, m.Longitude)),
                    IconType     = "#FFB3E722",
                    Latitude     = m.Latitude,
                    Longitude    = m.Longitude
                });
                nameList.Add(m.Name);
            }

            // sorting
            temp.Sort(NearStopComparison);
            int len = temp.Count;

            for (int i = 0; i < len; ++i)
            {
                NearItems.Add(temp[i]);
            }

            nameList.Clear();
            temp.Clear();

            progressIndicator.IsVisible = false;
            SystemTray.SetIsVisible(this, false);

            HasFoundNear = true;
            IsFinding    = false;

            refreshIconButton.IsEnabled = true;
            mapsButton.IsEnabled        = true;
        }
        private void LoadAvailability(string stopId)
        {
            refreshButton.IsEnabled = false;
            SystemTray.SetIsVisible(this, true);
            progressIndicator.Text      = AppResources.Loading;
            progressIndicator.IsVisible = true;

            try
            {
                //string result = await App.ViewModel.LoadBikeStopDataById(stopId);

                WebClient client = new WebClient();
                client.DownloadStringCompleted += (s, e) =>
                {
                    if (e.Error == null)
                    {
                        Regex           regex   = new Regex(@"sbi\s*?\=\s*?'([0-9]+)?'[.\W\w]+?sus\s*?\=\s*?'([0-9]+)?';", RegexOptions.Multiline | RegexOptions.IgnoreCase);
                        MatchCollection matches = regex.Matches(e.Result);
                        if (matches.Count > 0)
                        {
                            Match match = matches[0];
                            BikeStopAvailable.Text = match.Groups[1].Value;
                            BikeStopCapacity.Text  = match.Groups[2].Value;
                        }
                    }
                    else
                    {
                        MessageBox.Show(AppResources.NetworkError, AppResources.NetworkErrorCaption, MessageBoxButton.OK);
                    }

                    progressIndicator.IsVisible = false;
                    SystemTray.SetIsVisible(this, false);
                    refreshButton.IsEnabled = true;
                };

                client.DownloadStringAsync(new Uri("http://www.youbike.com.tw/info3b.php?sno=" + stopId, UriKind.Absolute));
            }
            catch (Exception)
            {
                MessageBox.Show(AppResources.NetworkError, AppResources.NetworkErrorCaption, MessageBoxButton.OK);

                progressIndicator.IsVisible = false;
                SystemTray.SetIsVisible(this, false);
                refreshButton.IsEnabled = true;
            }
        }
Пример #7
0
        private async void loginButton_Click(object sender, RoutedEventArgs e)
        {
            if (email.Text.Trim() == string.Empty || password.Password.Trim() == string.Empty)
            {
                MessageBox.Show("Please enter both e-mail and password to login.", "Login failed", MessageBoxButton.OK);
                return;
            }

            progress.IsVisible       = true;
            progress.IsIndeterminate = true;
            SystemTray.SetIsVisible(this, true);
            SystemTray.SetOpacity(this, 0);
            await Login(email.Text.Trim(), password.Password);

            SystemTray.SetIsVisible(this, false);
            progress.IsVisible = false;
        }
Пример #8
0
        private async void Tracking()
        {
            // find your location
            SystemTray.SetIsVisible(this, true);
            progressIndicator.IsVisible = true;

            try
            {
                if (!appSettings.Contains(Constants.TRACKING) || (bool)appSettings[Constants.TRACKING])
                {
                    Geoposition position = await geolocator.GetGeopositionAsync(
                        maximumAge : TimeSpan.FromMinutes(5),
                        timeout : TimeSpan.FromSeconds(10)
                        );

                    GeoCoordinate myLocation = position.Coordinate.ToGeoCoordinate();


                    MyLocationMarker.GeoCoordinate = myLocation;
                    MyLocationMarker.Visibility    = Visibility.Visible;

                    MapsView.Center = myLocation;
                }
                else
                {
                    MapsView.Center = new GeoCoordinate(25.0380, 121.5487);
                }

                ObservableCollection <BikeStopViewModel> NearList = (ObservableCollection <BikeStopViewModel>)appSettings["NearListTemp"];
                foreach (BikeStopViewModel b in NearList)
                {
                    BikeStops.Add(new BikeStopPinModel()
                    {
                        Name       = String.Format("{0}", b.Name),
                        Coordinate = new GeoCoordinate(b.Latitude, b.Longitude)
                    });
                }
            }
            catch (Exception ex)
            {
                // TODO
                Debug.WriteLine("[MapsViewPage][Locating] " + ex.Message);
            }
            SystemTray.SetIsVisible(this, false);
            progressIndicator.IsVisible = false;
        }
Пример #9
0
        /// <summary>
        /// Initializes a new instance of the CaptionSettingsPage2 class.
        /// </summary>
        public CaptionSettingsPage2()
        {
            this.InitializeComponent();

            this.Control.Settings             = Settings;
            this.Control.ApplyCaptionSettings = ApplyCaptionSettings;
            this.Control.Style = ControlStyle;

            if (Options != null)
            {
                SystemTray.SetIsVisible(this, Options.IsSystemTrayVisible);

                this.SupportedOrientations = Options.SupportedOrientation;
                this.Orientation           = Options.Orientation;
            }

            this.Control.Page = this;
        }
Пример #10
0
 private void ToggleButton_Unchecked(object sender, RoutedEventArgs e)
 {
     try
     {
         PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
         if (frame != null)
         {
             PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
             if (page != null)
             {
                 SystemTray.SetIsVisible(page, false);
             }
         }
     }
     catch
     {
     }
 }
Пример #11
0
        private void Sync(object sender, EventArgs e)
        {
            SystemTray.SetIsVisible(this, true);
            this.SetProgressBar("Synchronizing (0/4)...");

            App.ViewModel.Synchronize(
                () => SystemTray.SetIsVisible(this, false),
                (text, progress) =>
                SystemTray.SetProgressIndicator(this, new ProgressIndicator {
                Text      = text,
                Value     = progress,
                IsVisible = true
            }),
                err => {
                SystemTray.SetIsVisible(this, false);
                MessageBox.Show(err.Message);
            });
        }
Пример #12
0
        private async void LoadAvailability(string stopId)
        {
            refreshButton.IsEnabled = false;
            SystemTray.SetIsVisible(this, true);
            progressIndicator.Text      = AppResources.Loading;
            progressIndicator.IsVisible = true;

            // loading from youbike.com.tw
            try
            {
                string result = await App.ViewModel.LoadBikeStopDataById(stopId);

                Regex           regex   = new Regex(@"sbi\s*?\=\s*?'([0-9]+)?'[.\W\w]+?sus\s*?\=\s*?'([0-9]+)?';", RegexOptions.Multiline | RegexOptions.IgnoreCase);
                MatchCollection matches = regex.Matches(result);
                if (matches.Count > 0)
                {
                    Match match = matches[0];
                    BikeStopAvailable.Text = match.Groups[1].Value;
                    BikeStopCapacity.Text  = match.Groups[2].Value;
                }

                if (!appSettings.Contains(Constants.TRACKING) || (bool)appSettings[Constants.TRACKING])
                {
                    Geolocator geolocator = new Geolocator()
                    {
                        MovementThreshold = 10, DesiredAccuracyInMeters = 5000
                    };
                    Geoposition pos = await geolocator.GetGeopositionAsync(
                        maximumAge : TimeSpan.FromMinutes(5),
                        timeout : TimeSpan.FromSeconds(10));

                    YourPosition.GeoCoordinate = new GeoCoordinate(pos.Coordinate.Latitude, pos.Coordinate.Longitude);
                    YourPosition.Visibility    = Visibility.Visible;
                }
            }
            catch (Exception)
            {
                MessageBox.Show(AppResources.NetworkError, AppResources.NetworkErrorCaption, MessageBoxButton.OK);
            }

            progressIndicator.IsVisible = false;
            SystemTray.SetIsVisible(this, false);
            refreshButton.IsEnabled = true;
        }
Пример #13
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            btnalert.IsEnabled = true;

            SystemTray.SetIsVisible(this, true);
            SystemTray.SetOpacity(this, .9);

            prog                 = new ProgressIndicator();
            prog.IsVisible       = false;
            prog.IsIndeterminate = false;
            prog.Text            = "Getting GPS location...";

            SystemTray.SetProgressIndicator(this, prog);

            Addresses = new List <string>();
            GetSettings();
            BuildLocalizedApplicationBar();

            if (Rate.HasAppBeenRated().ToUpper() == "YES")
            {
                _rated         = true;
                App.gTextLimit = App.gTextLimitExtended;
            }
            else
            {
                _rated         = false;
                App.gTextLimit = App.gTextLimitTrial;
            }

            if ((Application.Current as App).IsTrial)
            {
                TextStatusMessage           = AppResources.TrialTextSent + App.gSentTextCount.ToString() + "/" + App.gTextLimit;
                TextStatusMessageVisibility = Visibility.Visible;
            }
            else
            {
                TextStatusMessage           = string.Empty;
                TextStatusMessageVisibility = Visibility.Collapsed;
            };

            this.DataContext = this;
        }
Пример #14
0
        private void Tracking()
        {
            try
            {
                if (!appSettings.Contains(Constants.TRACKING) || (bool)appSettings[Constants.TRACKING])
                {
                    // find your location
                    SystemTray.SetIsVisible(this, true);
                    progressIndicator.IsVisible = true;

                    watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
                    watcher.MovementThreshold = 20;
                    watcher.PositionChanged  += (s, e) =>
                    {
                        MainMapsView.Center = e.Position.Location;

                        SystemTray.SetIsVisible(this, false);
                        progressIndicator.IsVisible = false;
                    };
                    watcher.Start();
                }
                else
                {
                    MainMapsView.Center = new GeoCoordinate(25.0380, 121.5487);
                }

                ObservableCollection <BikeStopViewModel> NearList = (ObservableCollection <BikeStopViewModel>)appSettings["NearListTemp"];
                foreach (BikeStopViewModel b in NearList)
                {
                    Pushpin p = new Pushpin();

                    p.Content  = b.Name;
                    p.Location = new GeoCoordinate(b.Latitude, b.Longitude);

                    MarkerLayer.Children.Add(p);
                }
            }
            catch (Exception)
            {
            }
            SystemTray.SetIsVisible(this, false);
            progressIndicator.IsVisible = false;
        }
Пример #15
0
    public MainPage()
    {
        InitializeComponent();

        _progressIndicator = new ProgressIndicator
        {
            IsIndeterminate = true,
            Text            = "Loading...",
            IsVisible       = true,
        };

        SystemTray.SetIsVisible(this, true);
        SystemTray.SetProgressIndicator(this, _progressIndicator);
        SystemTray.SetOpacity(this, 1);

        //something is a very long here

        _progressIndicator.IsVisible = false;
        SystemTray.SetIsVisible(this, false);
    }
Пример #16
0
        void DeleteSet(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to delete this group? It can't be undone!", "", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
            {
                return;
            }

            var set = (sender as FrameworkElement).DataContext as SetViewModel;

            this.SetProgressBar("Deleting group...");
            SystemTray.SetIsVisible(this, true);

            App.ViewModel.Delete(
                set,
                () => SystemTray.SetIsVisible(this, false),
                err => {
                SystemTray.SetIsVisible(this, false);
                MessageBox.Show(err.Message);
            });
        }
Пример #17
0
 private void setting_Click(object sender, System.EventArgs e)
 {
     try
     {
         ink1.Visibility = Visibility.Visible;
         PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
         if (frame != null)
         {
             PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
             if (page != null)
             {
                 SystemTray.SetIsVisible(page, false);
             }
         }
         ApplicationBar.IsVisible = false;
     }
     catch
     {
     }
 }
Пример #18
0
        //Constructor
        public TracksPiv()
        {
            _miscFunctions   = new MiscFunctions();
            _unitConversions = new UnitConversions();
            _fileio          = new FileIO();
            _mapUnitIndex    = App.UserSettings.GetSetting(AppResources.UserSettingsMapUnits, 0);
            _loc             = new LocationManager();

            _trackDb = new TrackDataContext(TrackDataContext.DBConnectionString);

            DataContext = this;

            InitializeComponent();
            BuildLocalizedApplicationBar();

            SystemTray.SetIsVisible(this, true);
            _prog = new ProgressIndicator();
            SystemTray.SetProgressIndicator(this, _prog);

            App.Timer.timer.Tick += Timer_Tick;
        }
Пример #19
0
        /// <summary>
        ///
        /// </summary>
        public Save()
        {
            InitializeComponent();

            _fileIO  = new FileIO();
            _ser     = new Serializer();
            _trackDB = new TrackDataContext(TrackDataContext.DBConnectionString);

            // Data context and observable collection are children of the main page.
            DataContext = this;

            // Define the query to gather all of the to-do items.
            var tracksInDB = from TrackDataBase trk in _trackDB.TrackTable select trk;

            // Execute the query and place the results into a collection.
            TrackDataBases = new ObservableCollection <TrackDataBase>(tracksInDB);

            SystemTray.SetIsVisible(this, true);
            _prog = new ProgressIndicator();
            SystemTray.SetProgressIndicator(this, _prog);
        }
Пример #20
0
        void AttachHardwareButtonHandlers()
        {
            PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;

            if (frame != null)
            {
                PhoneApplicationPage page = frame.Content as PhoneApplicationPage;

                if (page != null)
                {
                    page.BackKeyPress += new EventHandler <CancelEventArgs>(page_BackKeyPress);
                    // CB-2347 -jm
                    string fullscreen  = configHandler.GetPreference("fullscreen");
                    bool   bFullScreen = false;
                    if (bool.TryParse(fullscreen, out bFullScreen) && bFullScreen)
                    {
                        SystemTray.SetIsVisible(page, false);
                    }
                }
            }
        }
Пример #21
0
    void activateProgressIndicator()
    {
        // In theory, you should not need to use Dispatcher here with async/await.
        // But without a complete code example, it's impossible for me to
        // say for sure, so I've left it as-is.
        Deployment.Current.Dispatcher.BeginInvoke(() =>
        {
            var currentPage = App.RootFrame.Content as PhoneApplicationPage;
            SystemTray.SetIsVisible(currentPage, true);
            SystemTray.SetOpacity(currentPage, 0.5);
            SystemTray.SetBackgroundColor(currentPage, Colors.White);
            SystemTray.SetForegroundColor(currentPage, Colors.Black);

            progressIndicator                 = new ProgressIndicator();
            progressIndicator.IsVisible       = true;
            progressIndicator.IsIndeterminate = true;
            progressIndicator.Text            = message;

            SystemTray.SetProgressIndicator(currentPage, progressIndicator);
        });
    }
Пример #22
0
        public void Cadastrar()
        {
            ParseObject cadastro = new ParseObject("Usuarios");

            cadastro["Nome"]  = txt_nome.Text;
            cadastro["Email"] = txt_email.Text;
            cadastro["Senha"] = txt_senha.Password;

            if (chk_foodtruck.IsChecked == true)
            {
                cadastro["foodtruck"] = true;
            }
            else
            {
                cadastro["foodtruck"] = false;

                SystemTray.SetIsVisible(this, true);
                SystemTray.SetOpacity(this, 1);

                ProgressIndicator progresso = new ProgressIndicator
                {
                    IsVisible       = true,
                    IsIndeterminate = true,
                    Text            = "Aguarde um instante..."
                };

                this.DataContext = null;
                SystemTray.SetProgressIndicator(this, progresso);

                cadastro.SaveAsync();

                MessageBoxResult resultado = MessageBox.Show("Cadastro realizado com sucesso", "Seja Bem-Vindo!", MessageBoxButton.OK);

                if (resultado == MessageBoxResult.OK)
                {
                    NavigationService.GoBack();
                }
            }
        }
Пример #23
0
        void ProgressEnableUI()
        {
            Dispatcher.BeginInvoke(delegate
            {
                //Disable progressbar
                SystemTray.SetIsVisible(this, true);
                vProgressIndicator.IsVisible = false;
                SystemTray.SetProgressIndicator(this, vProgressIndicator);

                //Enable UI buttons
                Scrobble.IsEnabled = true;
                Loved.IsEnabled    = true;
                Recent.IsEnabled   = true;
                Artists.IsEnabled  = true;
                //Like.IsEnabled = true;
                Settings.IsEnabled = true;
                Ignore.IsEnabled   = true;
            });

            //Allow application lock screen
            vPhoneApplicationService.UserIdleDetectionMode = IdleDetectionMode.Enabled;
            return;
        }
Пример #24
0
        private void SetLoadingTray()
        {
            _isShowingTray = true;

            var page = (PhoneApplicationPage)((PhoneApplicationFrame)Application.Current.RootVisual).Content;

            if (_currentIndicator != null && SystemTray.GetProgressIndicator(page) == _currentIndicator)
            {
                return;
            }

            _oldIndicator = SystemTray.GetProgressIndicator(page);
            _oldIsVisible = SystemTray.GetIsVisible(page);

            _currentIndicator = new ProgressIndicator
            {
                IsIndeterminate = true,
                IsVisible       = true,
                Text            = CommonResources.Loading
            };
            SystemTray.SetProgressIndicator(page, _currentIndicator);
            SystemTray.SetIsVisible(page, true);
        }
Пример #25
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();


            #region trial Check
            if (App.IsTrial == true)
            {
                // enable ads
                adControl.Visibility = System.Windows.Visibility.Visible;
                //adControl.IsAutoRefreshEnabled = true;
                adControl.IsEnabled             = true;
                adControl.IsAutoCollapseEnabled = false;
            }
            else
            {
                // disables ads
                adControl.Visibility = System.Windows.Visibility.Collapsed;
                //adControl.IsAutoRefreshEnabled = false;
                adControl.IsEnabled             = false;
                adControl.IsAutoCollapseEnabled = false;
            }
            #endregion


            OrientationChanged += new EventHandler <OrientationChangedEventArgs>(MainPage_OrientationChanged);

            // initially check
            PageOrientation po = this.Orientation;
            if (po == PageOrientation.Portrait || po == PageOrientation.PortraitDown || po == PageOrientation.PortraitUp)
            {
                // return pivot to original position
                MapHeight           = 800;
                MainPivot.Margin    = new Thickness(0, 125, 0, 0);
                AllPivot.Header     = "all";
                FreewayPivot.Header = "highways";
                RoadPivot.Header    = "roads";

                // this.ApplicationBar.IsVisible = this.ApplicationBar.IsVisible;
            }
            else if (po == PageOrientation.Landscape || po == PageOrientation.LandscapeLeft || po == PageOrientation.LandscapeRight)
            {
                // hiding pivot header in landscape mode
                MapHeight           = 480;
                MainPivot.Margin    = new Thickness(0, 30, 0, 0);
                AllPivot.Header     = "";
                FreewayPivot.Header = "";
                RoadPivot.Header    = "";
                //    this.ApplicationBar.IsVisible = !this.ApplicationBar.IsVisible;
            }



            isolatedStorageSettings = IsolatedStorageSettings.ApplicationSettings;


            // disable lock screen timer
            Microsoft.Phone.Shell.PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

            // References:
            // http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx
            // http://msdn.microsoft.com/en-us/library/hh441726.aspx
            // http://json.codeplex.com
            // Bing Maps REST Services API Reference: http://msdn.microsoft.com/en-us/library/ff701722.aspx
            // Adding Tile Layers (overlays) http://msdn.microsoft.com/en-us/library/ee681902.aspx

            wc = new WebClient();
            wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(REST_traffic);
            //wc.DownloadStringAsync(new Uri("http://dev.virtualearth.net/REST/v1/Traffic/Incidents/37,-105,45,-94?key=" + Id));

            // caching
            Current_Location.CacheMode = new BitmapCache();
            mMap.ZoomLevel             = 10;
            //mMap.ZoomBarVisibility = System.Windows.Visibility.Visible;
            Current_Location.Style          = (Style)(Application.Current.Resources["PushpinStyle"]);
            Current_Location.PositionOrigin = PositionOrigin.Center;

            MyPreviousLocation.X = 0; MyPreviousLocation.Y = 0;
            #region Progress Indicator
            SystemTray.SetIsVisible(this, true);
            SystemTray.SetOpacity(this, 0.5);
            SystemTray.SetBackgroundColor(this, Colors.Black);
            SystemTray.SetForegroundColor(this, Colors.White);
            prog = new ProgressIndicator();
            prog.IsIndeterminate = true;
            prog.IsVisible       = true;
            SystemTray.SetProgressIndicator(this, prog);

            #endregion
        }
Пример #26
0
        private async void FoundNear()
        {
            if (appSettings.Contains(Constants.TRACKING) && !(bool)appSettings[Constants.TRACKING])
            {
                MessageBox.Show(AppResources.TrackingOff, AppResources.LocationConsentCaption, MessageBoxButton.OK);
                return;
            }

            if (IsFinding)
            {
                return;
            }

            IsFinding = true;

            SystemTray.SetIsVisible(this, true);
            progressIndicator.IsVisible = true;

            refreshIconButton.IsEnabled = false;
            mapsButton.IsEnabled        = false;

            progressIndicator.Text = AppResources.Locating;

            double latitude  = 100,
                   longitude = 200;

            // Geolocate
            try
            {
                geolocator = new Geolocator()
                {
                    MovementThreshold = 10, DesiredAccuracyInMeters = 5000
                };
                Geoposition position = await geolocator.GetGeopositionAsync(
                    maximumAge : TimeSpan.FromMinutes(5),
                    timeout : TimeSpan.FromSeconds(10)
                    );

                latitude  = position.Coordinate.Latitude;
                longitude = position.Coordinate.Longitude;

                progressIndicator.Text = AppResources.LoadingData;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("[Locating Error] " + ex.Message);
            }

            if (latitude != 100 && longitude != 200)
            {
                try
                {
                    NearItems.Clear();

                    List <BikeStopViewModel> temp     = new List <BikeStopViewModel>();
                    List <string>            nameList = new List <string>();

                    foreach (BikeStopViewModel m in App.ViewModel.Items)
                    {
                        temp.Add(new BikeStopViewModel()
                        {
                            Name         = m.Name,
                            Address      = m.Address,
                            Availability = 0,
                            Capacity     = 0,
                            Distance     = string.Format("{0:0,0}", LatLngDistance(latitude, longitude, m.Latitude, m.Longitude)),
                            IconType     = "#FFB3E722",
                            Latitude     = m.Latitude,
                            Longitude    = m.Longitude
                        });
                        nameList.Add(m.Name);
                    }


                    // sorting
                    temp.Sort(NearStopComparison);
                    int len = temp.Count;
                    for (int i = 0; i < len; ++i)
                    {
                        NearItems.Add(temp[i]);
                    }

                    nameList.Clear();
                    temp.Clear();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(AppResources.NetworkError, AppResources.NetworkErrorCaption, MessageBoxButton.OK);
                    Debug.WriteLine(ex.Message);
                }
            }

            progressIndicator.IsVisible = false;
            SystemTray.SetIsVisible(this, false);

            HasFoundNear = true;
            IsFinding    = false;

            refreshIconButton.IsEnabled = true;
            mapsButton.IsEnabled        = true;
        }
Пример #27
0
        private void ShowInAppBrowser(string url)
        {
            Uri loc = new Uri(url, UriKind.RelativeOrAbsolute);

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (browser != null)
                {
                    //browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
                    browser.Navigate2(loc);
                }
                else
                {
                    PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
                    if (frame != null)
                    {
                        PhoneApplicationPage page = frame.Content as PhoneApplicationPage;

                        if (!(System.Environment.OSVersion.Version.Major == 8 && System.Environment.OSVersion.Version.Minor == 0))
                        {
                            SystemTray.SetIsVisible(page, false);
                        }

                        string baseImageUrl = "/www/Images/";

                        if (page != null)
                        {
                            Grid grid = page.FindName("LayoutRoot") as Grid;
                            if (grid != null)
                            {
                                browser = new WebBrowser();
                                browser.IsScriptEnabled = true;
                                browser.Background      = new SolidColorBrush(Colors.Black);
                                browser.LoadCompleted  += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted);

                                browser.Navigating       += new EventHandler <NavigatingEventArgs>(browser_Navigating);
                                browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed);
                                browser.Navigated        += new EventHandler <System.Windows.Navigation.NavigationEventArgs>(browser_Navigated);
                                browser.Navigate2(loc);

                                //if (StartHidden)
                                //{
                                //    browser.Visibility = Visibility.Collapsed;
                                //}

                                grid.Background = new SolidColorBrush(Colors.Black);

                                var rowDef    = new RowDefinition();
                                rowDef.Height = GridLength.Auto;
                                grid.RowDefinitions.Insert(0, rowDef);

                                buttons = new StackPanel();
                                buttons.HorizontalAlignment = HorizontalAlignment.Right;
                                buttons.Orientation         = Orientation.Horizontal;
                                buttons.Visibility          = Visibility.Collapsed;

                                var backBitmapImage    = new BitmapImage(new Uri(baseImageUrl + "ic_action_back.png", UriKind.Relative));
                                var backImage          = new Image();
                                backImage.Source       = backBitmapImage;
                                backButton             = new Button();
                                backButton.Content     = backImage;
                                backButton.Width       = 100;
                                backButton.BorderBrush = new SolidColorBrush(Colors.Black);
                                //backButton.Text = "Back";
                                //backButton.IconUri = new Uri(baseImageUrl + "appbar.back.rest.png", UriKind.Relative);
                                backButton.Click += new RoutedEventHandler(backButton_Click);
                                buttons.Children.Add(backButton);


                                var reloadBitmapImage    = new BitmapImage(new Uri(baseImageUrl + "ic_action_refresh.png", UriKind.Relative));
                                var reloadImage          = new Image();
                                reloadImage.Source       = reloadBitmapImage;
                                reloadButton             = new Button();
                                reloadButton.Content     = reloadImage;
                                reloadButton.Width       = 100;
                                reloadButton.BorderBrush = new SolidColorBrush(Colors.Black);
                                //reloadButton.IconUri = new Uri(baseImageUrl + "appbar.next.rest.png", UriKind.Relative);
                                reloadButton.Click += new RoutedEventHandler(reloadButton_Click);
                                buttons.Children.Add(reloadButton);

                                Grid.SetRow(buttons, 0);
                                grid.Children.Add(buttons);


                                //browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
                                Grid.SetRow(browser, 1);
                                grid.Children.Add(browser);
                            }

                            //if (ShowLocation)
                            //{
                            //    ApplicationBar bar = new ApplicationBar();
                            //    bar.BackgroundColor = Colors.Black;
                            //    bar.IsMenuEnabled = false;


                            //    //ApplicationBarIconButton closeBtn = new ApplicationBarIconButton();
                            //    //closeBtn.Text = "Close";
                            //    //closeBtn.IconUri = new Uri(baseImageUrl + "appbar.close.rest.png", UriKind.Relative);
                            //    //closeBtn.Click += new EventHandler(closeBtn_Click);
                            //    //bar.Buttons.Add(closeBtn);

                            //    page.ApplicationBar = bar;
                            //    bar.IsVisible = !StartHidden;
                            //    AppBar = bar;
                            //}

                            page.BackKeyPress += page_BackKeyPress;
                        }
                    }
                }
            });
        }
Пример #28
0
        private async Task LoadFeed()
        {
            try
            {
                SystemTray.SetIsVisible(this, true);
                SystemTray.SetOpacity(this, 0);
                progress.IsVisible = true;
                string url        = string.Format(FEED_URI, Keys.WP_CLIENT_ID);
                var    httpClient = new HttpClient(new HttpClientHandler());
                var    request    = new HttpRequestMessage(HttpMethod.Get, new Uri(url));
                request.Headers.Add("Authorization", "Bearer " + LoginService.SignInToken);
                request.Headers.Add("If-Modified-Since", DateTime.UtcNow.ToString("r"));
                HttpResponseMessage response = await httpClient.SendAsync(request);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var responseString = await response.Content.ReadAsStringAsync();

                    httpClient.Dispose();
                    JObject jobj     = JObject.Parse(responseString);
                    JArray  jlist    = (JArray)jobj["feed"];
                    var     feedList = new List <FeedItem>();
                    foreach (JObject obj in jlist)
                    {
                        var    item               = new FeedItem();
                        string action             = obj["action"] != null ? obj["action"].ToString() : "";
                        string type               = obj["type"] != null ? obj["type"].ToString() : "";
                        string object_type        = obj["object_type"] != null ? obj["object_type"].ToString() : "";
                        string object_key         = obj["object_key"] != null ? obj["object_key"].ToString() : "";
                        string object_value       = obj["object_value"] != null ? obj["object_value"].ToString() : "";
                        string image_url          = obj["image_url"] != null ? obj["image_url"].ToString() : "";
                        string image_key          = obj["image_key"] != null ? obj["image_key"].ToString() : "";
                        string main_description   = obj["main_description"] != null ? obj["main_description"].ToString() : "";
                        string detail_description = obj["detail_description"] != null ? obj["detail_description"].ToString() : "";
                        string created_at         = obj["created_at"] != null ? obj["created_at"].ToString() : null;
                        string started_at         = obj["started_at"] != null ? obj["started_at"].ToString() : null;
                        string updated_at         = obj["updated_at"] != null ? obj["updated_at"].ToString() : null;
                        string id          = obj["id"] != null ? obj["id"].ToString() : "";
                        int    nbr_objects = obj["nbr_objects"] != null ? (int)obj["nbr_objects"] : 0;

                        string user = obj["user"] != null ? obj["user"].ToString() : "";
                        bool   open = obj["open"] != null ? (bool)obj["open"] : false;

                        var dtcreated_at = created_at != null ? new DateTime(1970, 1, 1, 0, 0, 0).AddMilliseconds(Convert.ToDouble(created_at)) : DateTime.MinValue;
                        var dtstarted_at = started_at != null ? new DateTime(1970, 1, 1, 0, 0, 0).AddMilliseconds(Convert.ToDouble(started_at)) : DateTime.MinValue;
                        var dtupdated_at = updated_at != null ? new DateTime(1970, 1, 1, 0, 0, 0).AddMilliseconds(Convert.ToDouble(updated_at)) : DateTime.MinValue;

                        item.Action            = action;
                        item.Type              = type;
                        item.ObjectType        = object_type;
                        item.ObjectKey         = object_key;
                        item.ObjectValue       = object_value;
                        item.ImageUrl          = image_url;
                        item.ImageKey          = image_key;
                        item.MainDescription   = main_description;
                        item.DetailDescription = detail_description;
                        item.CreatedAt         = dtcreated_at;
                        item.StartedAt         = started_at;
                        item.UpdatedAt         = updated_at;
                        item.Id         = id;
                        item.NbrObjects = nbr_objects;
                        item.User       = user == LoginService.SignInEmail ? "You" : user;
                        item.Open       = open;
                        item.FirstLine  = item.User + " " + item.MainDescription;
                        if (dtstarted_at.DayOfYear == DateTime.Now.DayOfYear && dtstarted_at.Year == DateTime.Now.Year)
                        {
                            item.SecondLine = "Today";
                        }
                        else
                        {
                            item.SecondLine = dtstarted_at.ToShortDateString();
                        }

                        if (dtstarted_at == DateTime.MinValue)
                        {
                            item.SecondLine = "";
                        }

                        feedList.Add(item);
                    }

                    eventList.ItemsSource = feedList;
                    App.EventListCache    = feedList;
                    App.FeedLastRefreshed = DateTime.Now;
                }
                else
                {
                    //MessageBox.Show("An error occurred while getting your feed. Please try again.", "Error", MessageBoxButton.OK);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("An error occurred while getting your feed: " + ex.Message, "Error", MessageBoxButton.OK);
            }

            ShowHideList(App.EventListCache != null && App.EventListCache.Count > 0);
            SystemTray.SetIsVisible(this, false);
            progress.IsVisible = false;
        }
Пример #29
0
 internal static void Hide(PhoneApplicationPage page)
 {
     SystemTray.SetIsVisible(page, false);
     SystemTray.SetOpacity(page, 1);
     SystemTray.SetProgressIndicator(page, null);
 }
Пример #30
0
 private void CurrentViewModel_LongLoadingStopEvent(object sender, SimpleMvvmToolkit.NotificationEventArgs e)
 {
     SystemTray.SetProgressIndicator(this, null);
     SystemTray.SetIsVisible(this, systemTrayVisibleBck);
 }