Commits

Ron Huang committed 5226b20

Fixed issue with progress indicator showing at incorrect time.

Comments (0)

Files changed (4)

WhereIsMakkah/MainPage.xaml.cs

 
                     SystemTray.SetProgressIndicator(this, progressIndicator);
 
-                    // Bind progress indicator to LocationDetermined property
-                    var binding = new Binding("LocationDetermined") { Source = this.LayoutRoot.DataContext, Converter = new InverseBooleanConverter() };
+                    // Bind progress indicator to Busy property
+                    var binding = new Binding("Busy") { Source = this.LayoutRoot.DataContext };
                     BindingOperations.SetBinding(progressIndicator, ProgressIndicator.IsVisibleProperty, binding);
 
                     // Localize the text on application bar.
 
                     SystemTray.SetProgressIndicator(this, null);
 
-                    // Unbind progress indicator to LocationDetermined property
+                    // Unbind progress indicator to Busy property
                     BindingOperations.SetBinding(progressIndicator, ProgressIndicator.IsVisibleProperty, null);
                 };
 

WhereIsMakkah/Util/InverseBooleanConverter.cs

-using System;
-using System.Windows.Data;
-using System.Globalization;
-
-namespace WhereIsMakkah.Util
-{
-    public class InverseBooleanConverter : IValueConverter
-    {
-        #region IValueConverter Members
-
-        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            if (targetType != typeof(bool))
-                throw new InvalidOperationException("The target must be a boolean");
-
-            return !(bool)value;
-        }
-
-        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            throw new NotSupportedException();
-        }
-
-        #endregion
-    }
-}

WhereIsMakkah/ViewModel/MainViewModel.cs

 
                 // Update bindings, no broadcast
                 RaisePropertyChanged(DirectionDeterminedPropertyName);
+                RaisePropertyChanged(BusyPropertyName);
                 RaisePropertyChanged(FeedbackPropertyName);
             }
         }
 
                 // Update bindings, no broadcast
                 RaisePropertyChanged(DirectionDeterminedPropertyName);
+                RaisePropertyChanged(BusyPropertyName);
             }
         }
 
         }
 
         /// <summary>
+        /// The <see cref="Busy" /> property's name.
+        /// </summary>
+        public const string BusyPropertyName = "Busy";
+
+        /// <summary>
+        /// Gets the Busy property.
+        /// Changes to that property's value raise the PropertyChanged event. 
+        /// This property's value is broadcasted by the Messenger's default instance when it changes.
+        /// </summary>
+        public bool Busy
+        {
+            get
+            {
+                return _locationServiceSetting ? !(_locationDetermined && _motionDetermined) : false;
+            }
+        }
+
+        /// <summary>
         /// The <see cref="CurrentMatrix" /> property's name.
         /// </summary>
         public const string CurrentMatrixPropertyName = "CurrentMatrix";
 
                 // Update bindings, no broadcast
                 RaisePropertyChanged(DirectionDeterminedPropertyName);
+                RaisePropertyChanged(BusyPropertyName);
                 RaisePropertyChanged(FeedbackPropertyName);
             }
         }
                 case GeoPositionStatus.Ready:
                     GeoCoordinate loc = _watcher.Position.Location;
 
-                    Feedback = "";
                     Distance = GeoDistanceCalculator.DistanceInKilometers(loc.Latitude, loc.Longitude, Makkah.Latitude, Makkah.Longitude);
 
                     var destZ = 360.0 - GeoDistanceCalculator.InitialBearing(loc.Latitude, loc.Longitude, Makkah.Latitude, Makkah.Longitude); // counter-clockwise

WhereIsMakkah/WhereIsMakkah.csproj

     <Compile Include="Lang\LocalizedStrings.cs" />
     <Compile Include="Model\AppSettings.cs" />
     <Compile Include="Util\BooleanToVisibilityConverter.cs" />
-    <Compile Include="Util\InverseBooleanConverter.cs" />
     <Compile Include="Util\SettingsChangedMessage.cs" />
     <Compile Include="Util\GoToPageMessage.cs" />
     <Compile Include="Util\GeoDistanceCalculator.cs" />
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.