This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class GeoPositionWatcherExtensions | |
| { | |
| public static IObservable<IEvent<GeoPositionStatusChangedEventArgs>> GetStatusChangedEventObservable<T>(this IGeoPositionWatcher<T> watcher) | |
| { | |
| return Observable.FromEvent<GeoPositionStatusChangedEventArgs>(ev => watcher.StatusChanged += ev, ev => watcher.StatusChanged -= ev); | |
| } | |
| public static IObservable<IEvent<GeoPositionChangedEventArgs<T>>> GetPositionChangedEventObservable<T>(this IGeoPositionWatcher<T> watcher) | |
| { | |
| return Observable.FromEvent<GeoPositionChangedEventArgs<T>>(ev => watcher.PositionChanged += ev, ev => watcher.PositionChanged -= ev); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var statusChanged = from sc in watcher.GetStatusChangedEventObservable() | |
| select sc.EventArgs; | |
| statusChanged.Subscribe(item => Deployment.Current.Dispatcher.BeginInvoke(() => { | |
| // update your status textblock | |
| TextBlock.Text = Enum.GetName(typeof(GeoPositionStatus), item.Status); | |
| if (item.Status == GeoPositionStatus.Ready) | |
| { | |
| // f.e. hide your loading bar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var statusChangedToReady = from sc in statusChanged | |
| where sc.Status == GeoPositionStatus.Ready | |
| select sc; | |
| var positionChanged = from _ in statusChangedToReady | |
| from pc in watcher.GetPositionChangedEventObservable() | |
| where !pc.EventArgs.Position.Location.IsUnknown | |
| select pc.EventArgs.Position; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| positionChanged.Skip(1).Zip(positionChanged, (lhs, rhs) => new | |
| { | |
| Position1 = rhs, | |
| Position2 = lhs, | |
| Distance = lhs.Location.GetDistanceTo(rhs.Location) | |
| }).Subscribe(item => Deployment.Current.Dispatcher.BeginInvoke(() => | |
| { | |
| // handle position ... f.e. add to a map's location collection | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IDependencyResolver | |
| { | |
| object GetService(Type serviceType); | |
| IEnumerable<object> GetServices(Type serviceType); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class NinjectDependencyResolver : IDependencyResolver | |
| { | |
| private IKernel _kernel; | |
| public NinjectDependencyResolver(IKernel kernel) | |
| { | |
| _kernel = kernel; | |
| } | |
| public object GetService(Type serviceType) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected void Application_Start() | |
| { | |
| IKernel kernel = new StandardKernel(new YourNinjectModule()); | |
| DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel)); | |
| // register global filters, routes, ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| yourListBox.Opacity = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for (int i = 0; i < yourListBox.Items.Count; i++) | |
| { | |
| ListBoxItem item = (ListBoxItem)yourListBox.ItemContainerGenerator.ContainerFromIndex(i); | |
| if (item != null) | |
| { | |
| VisualStateManager.GoToState(item, "BeforeLoaded", false); | |
| } | |
| } | |
| yourListBox.Opacity = 1.0; |
OlderNewer