/// <summary> /// Navigate to specific latitude and longitude. /// </summary> /// <param name="name">Label to display</param> /// <param name="latitude">Lat</param> /// <param name="longitude">Long</param> /// <param name="navigationType">Type of navigation</param> public async void NavigateTo(string name, double latitude, double longitude, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; // Get the values required to specify the destination. var driveOrWalk = navigationType == NavigationType.Walking ? "ms-walk-to" : "ms-drive-to"; // Assemble the Uri to launch. var uri = new Uri(driveOrWalk + ":?destination.latitude=" + latitude.ToString(CultureInfo.InvariantCulture) + "&destination.longitude=" + longitude.ToString(CultureInfo.InvariantCulture) + "&destination.name=" + name); // Launch the Uri. var success = await Windows.System.Launcher.LaunchUriAsync(uri); if (success) { return; } var mapsDirectionsTask = new MapsDirectionsTask(); // You can specify a label and a geocoordinate for the end point. var location = new GeoCoordinate(latitude, longitude); var lml = new LabeledMapLocation(name, location); mapsDirectionsTask.End = lml; mapsDirectionsTask.Show(); }
/// <summary> /// Navigate to specific latitude and longitude. /// </summary> /// <param name="name">Label to display</param> /// <param name="latitude">Lat</param> /// <param name="longitude">Long</param> /// <param name="navigationType">Type of navigation</param> public Task<bool> NavigateTo(string name, double latitude, double longitude, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; try { NSDictionary dictionary = null; var mapItem = new MKMapItem(new MKPlacemark(new CLLocationCoordinate2D(latitude, longitude), dictionary)); mapItem.Name = name; MKLaunchOptions launchOptions = null; if (navigationType != NavigationType.Default) { launchOptions = new MKLaunchOptions { DirectionsMode = navigationType == NavigationType.Driving ? MKDirectionsMode.Driving : MKDirectionsMode.Walking }; } var mapItems = new[] { mapItem }; MKMapItem.OpenMaps(mapItems, launchOptions); return Task.FromResult(true); } catch (Exception ex) { Debug.WriteLine("Unable to launch maps: " + ex); return Task.FromResult(false); } }
/// <summary> /// Navigate to an address /// </summary> /// <param name="name">Label to display</param> /// <param name="street">Street</param> /// <param name="city">City</param> /// <param name="state">Sate</param> /// <param name="zip">Zip</param> /// <param name="country">Country</param> /// <param name="countryCode">Country Code if applicable</param> /// <param name="navigationType">Navigation type</param> public async Task<bool> NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; if (string.IsNullOrWhiteSpace(street)) street = string.Empty; if (string.IsNullOrWhiteSpace(city)) city = string.Empty; if (string.IsNullOrWhiteSpace(state)) state = string.Empty; if (string.IsNullOrWhiteSpace(zip)) zip = string.Empty; if (string.IsNullOrWhiteSpace(country)) country = string.Empty; try { return await Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("bingmaps:?where={0}%20{1}%20{2}%20{3}%20{4}", street, city, state, zip, country))); } catch (Exception ex) { Debug.WriteLine("Unable to launch maps: " + ex); return false; } }
/// <summary> /// Navigate to an address /// </summary> /// <param name="name">Label to display</param> /// <param name="street">Street</param> /// <param name="city">City</param> /// <param name="state">Sate</param> /// <param name="zip">Zip</param> /// <param name="country">Country</param> /// <param name="countryCode">Country Code if applicable</param> /// <param name="navigationType">Navigation type</param> public void NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; if (string.IsNullOrWhiteSpace(street)) street = string.Empty; if (string.IsNullOrWhiteSpace(city)) city = string.Empty; if (string.IsNullOrWhiteSpace(state)) state = string.Empty; if (string.IsNullOrWhiteSpace(zip)) zip = string.Empty; if (string.IsNullOrWhiteSpace(country)) country = string.Empty; var mapsDirectionsTask = new MapsDirectionsTask(); // If you set the geocoordinate parameter to null, the label parameter is used as a search term. var lml = new LabeledMapLocation(string.Format("{0}%20{1},%20{2}%20{3}%20{4}", street, city, state, zip, country), null); mapsDirectionsTask.End = lml; // If mapsDirectionsTask.Start is not set, the user's current location is used as the start point. mapsDirectionsTask.Show(); }
/// <summary> /// Navigate to specific latitude and longitude. /// </summary> /// <param name="name">Label to display</param> /// <param name="latitude">Lat</param> /// <param name="longitude">Long</param> /// <param name="navigationType">Type of navigation</param> public Task<bool> NavigateTo(string name, double latitude, double longitude, NavigationType navigationType = NavigationType.Default) { var uri = string.Empty; if(string.IsNullOrWhiteSpace(name)) uri = string.Format("http://maps.google.com/maps?&daddr={0},{1}", latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture)); else uri = string.Format("http://maps.google.com/maps?&daddr={0},{1} ({2})", latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), name); var intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri)); intent.SetClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); if (TryIntent(intent)) return Task.FromResult(true); var uri2 = string.Empty; if (string.IsNullOrWhiteSpace(name)) uri2 = string.Format("geo:{0},{1}?q={0},{1}", latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture)); else uri2 = string.Format("geo:{0},{1}?q={0},{1}({2})", latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), name); if (TryIntent(new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri2)))) return Task.FromResult(true); if (TryIntent(new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri)))) return Task.FromResult(true); Debug.WriteLine("No map apps found, unable to navigate"); return Task.FromResult(false); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object" /> class. /// </summary> public EntityRelationSide(EntityInfo entity, NavigationPropertyEntityInfo property, NavigationType navigationType, SimplePropertyEntityInfo[] keyColumns) { Property = property; NavigationType = navigationType; KeyColumns = keyColumns; Entity = entity; }
/// <summary> /// Navigate to an address /// </summary> /// <param name="name">Label to display</param> /// <param name="street">Street</param> /// <param name="city">City</param> /// <param name="state">Sate</param> /// <param name="zip">Zip</param> /// <param name="country">Country</param> /// <param name="countryCode">Country Code if applicable</param> /// <param name="navigationType">Navigation type</param> public async void NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; if (string.IsNullOrWhiteSpace(street)) street = string.Empty; if (string.IsNullOrWhiteSpace(city)) city = string.Empty; if (string.IsNullOrWhiteSpace(state)) state = string.Empty; if (string.IsNullOrWhiteSpace(zip)) zip = string.Empty; if (string.IsNullOrWhiteSpace(country)) country = string.Empty; var placemarkAddress = new MKPlacemarkAddress { City = city, Country = country, State = state, Street = street, Zip = zip, CountryCode = countryCode }; var coder = new CLGeocoder(); var placemarks = await coder.GeocodeAddressAsync(placemarkAddress.Dictionary); if(placemarks.Length == 0) { Debug.WriteLine("Unable to get geocode address from address"); return; } CLPlacemark placemark = placemarks[0]; var mapItem = new MKMapItem(new MKPlacemark(placemark.Location.Coordinate, placemarkAddress)); mapItem.Name = name; MKLaunchOptions launchOptions = null; if (navigationType != NavigationType.Default) { launchOptions = new MKLaunchOptions { DirectionsMode = navigationType == NavigationType.Driving ? MKDirectionsMode.Driving : MKDirectionsMode.Walking }; } var mapItems = new[] { mapItem }; MKMapItem.OpenMaps(mapItems, launchOptions); }
public static async Task DeactivateViewModelAsync(object target, NavigationType navigationType, DeactivationParameters parameters) { var deactivate = target as IDeactivate; if (deactivate != null) { await deactivate.DeactivateAsync(navigationType, parameters); } }
public void Activate(NavigationType navigationType) { this.Groups.Clear(); foreach (var group in this.store.GetGroups()) { this.Groups.Add(group); } }
public static void ActivatingViewModel(object target, NavigationType navigationType, object data) { if (target.GetType().GetInterfaces().Where(i => i.GetTypeInfo().IsGenericType).Select(i => i.GetGenericTypeDefinition()).Any(i => i.Equals(typeof(IActivating<>)))) { var method = target.GetType().GetRuntimeMethod("Activating", new[] { typeof(NavigationType), data.GetType() }); method?.Invoke(target, new[] { navigationType, data }); } }
/// <summary> /// Navigate to specific latitude and longitude. /// </summary> /// <param name="name">Label to display</param> /// <param name="latitude">Lat</param> /// <param name="longitude">Long</param> /// <param name="navigationType">Type of navigation</param> public async void NavigateTo(string name, double latitude, double longitude, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; await Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("bingmaps:?collection=point.{0}_{1}_{2}", latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), name))); }
public NavigationEventArgs(NavigationType navigationType, Type originalViewModelType, Type originalViewType, Type viewModelType, Type viewType, object activationData) { this.NavigationType = navigationType; this.OriginalViewModelType = originalViewModelType; this.OriginalViewType = originalViewType; this.ViewModelType = viewModelType; this.ViewType = viewType; this.ActivationData = activationData; }
public bool Navigate(Type pageType, NavigationType navigationType = NavigationType.Default) { var navigated = this.navigationFrame.Navigate(pageType, navigationType); if (navigated) { this.OnNavigated(new NavigationEventArgs(pageType, null)); } return navigated; }
public ActionResult Add(int id, int nestedId, NavigationType nestedNavigation) { var operation = db.Operations.Find(id); if (operation == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } object nestedProperty = null; switch (nestedNavigation) { case NavigationType.Users: nestedProperty = db.Users.Find(nestedId); break; case NavigationType.Machines: nestedProperty = db.Machines.Find(nestedId); break; case NavigationType.Operations: nestedProperty = db.Operations.Find(nestedId); break; case NavigationType.PosteTravails: nestedProperty = db.PosteTravails.Find(nestedId); break; case NavigationType.Realisations: nestedProperty = db.Realisations.Find(nestedId); if (nestedProperty == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } if (!operation.Realisations.Any(a => a.Id == ((Realisation)nestedProperty).Id)) { operation.Realisations.Add((Realisation)nestedProperty); } break; case NavigationType.Stocks: nestedProperty = db.Stocks.Find(nestedId); break; case NavigationType.Gammes: nestedProperty = db.Gammes.Find(nestedId); if (nestedProperty == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } if (!operation.Gammes.Any(a => a.Id == ((Gamme)nestedProperty).Id)) { operation.Gammes.Add((Gamme)nestedProperty); } break; case NavigationType.Services: nestedProperty = db.Services.Find(nestedId); break; default: break; } db.SaveChanges(); return RedirectToAction("Index"); }
public bool OnBeforeBrowse(IWebBrowser browser, IRequest request, NavigationType naigationvType, bool isRedirect) { string url = request.Url; if (url.Contains("access_denied")) view.Invoke(view.Close); if (!url.Contains("pin=")) return false; pin = url.Split('=')[1]; view.Invoke(view.Close); return false; }
/// <summary> /// Initializes a new instance of the <see cref="NavigationContext" /> class. /// </summary> public NavigationContext([NotNull] NavigationType type, NavigationMode navigationMode, [CanBeNull] IViewModel viewModelFrom, [CanBeNull] IViewModel viewModelTo, [CanBeNull] object navigationProvider) { Should.NotBeNull(type, "type"); _type = type; _navigationMode = navigationMode; _navigationProvider = navigationProvider; _viewModelFrom = viewModelFrom; _viewModelTo = viewModelTo; }
/// <summary> /// Initializes a new instance of the <see cref="NavigationContext" /> class. /// </summary> public NavigationContext([NotNull] NavigationType type, NavigationMode navigationMode, [CanBeNull] IViewModel viewModelFrom, [CanBeNull] IViewModel viewModelTo, [CanBeNull] object navigationProvider, [CanBeNull] IDataContext parameters = null) { Should.NotBeNull(type, "type"); _type = type; _navigationMode = navigationMode; _navigationProvider = navigationProvider; _viewModelFrom = viewModelFrom; _viewModelTo = viewModelTo; if (parameters != null) Merge(parameters); }
public static async Task<bool> CanDeactivateViewModelAsync(object target, NavigationType navigationType, DeactivationParameters parameters) { var query = target as IDeactivateQuery; if (query != null) { if (!await query.CanDeactivateAsync(navigationType, parameters)) { return false; } } return true; }
/// <summary> /// Deletes a navigation node from the quickLaunch or top navigation bar /// </summary> /// <param name="web">Site to be processed - can be root web or sub site</param> /// <param name="nodeTitle">the title of node to delete</param> /// <param name="parentNodeTitle">if string.Empty, then will delete this node as top level node</param> /// <param name="navigationType">the type of navigation, quick launch, top navigation or search navigation</param> public static void DeleteNavigationNode(this Web web, string nodeTitle, string parentNodeTitle, NavigationType navigationType) { web.Context.Load(web, w => w.Navigation.QuickLaunch, w => w.Navigation.TopNavigationBar); web.Context.ExecuteQueryRetry(); NavigationNode deleteNode = null; try { if (navigationType == NavigationType.QuickLaunch) { var quickLaunch = web.Navigation.QuickLaunch; if (string.IsNullOrEmpty(parentNodeTitle)) { deleteNode = quickLaunch.SingleOrDefault(n => n.Title == nodeTitle); } else { foreach (var nodeInfo in quickLaunch) { if (nodeInfo.Title != parentNodeTitle) { continue; } web.Context.Load(nodeInfo.Children); web.Context.ExecuteQueryRetry(); deleteNode = nodeInfo.Children.SingleOrDefault(n => n.Title == nodeTitle); } } } else if (navigationType == NavigationType.TopNavigationBar) { var topLink = web.Navigation.TopNavigationBar; deleteNode = topLink.SingleOrDefault(n => n.Title == nodeTitle); } else if (navigationType == NavigationType.SearchNav) { NavigationNodeCollection nodeCollection = web.LoadSearchNavigation(); deleteNode = nodeCollection.SingleOrDefault(n => n.Title == nodeTitle); } } finally { if (deleteNode != null) { deleteNode.DeleteObject(); } web.Context.ExecuteQueryRetry(); } }
/// <summary> /// Navigate to specific latitude and longitude. /// </summary> /// <param name="name">Label to display</param> /// <param name="latitude">Lat</param> /// <param name="longitude">Long</param> /// <param name="navigationType">Type of navigation</param> public async Task<bool> NavigateTo(string name, double latitude, double longitude, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; try { return await Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("bingmaps:?collection=point.{0}_{1}_{2}", latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), name))); } catch (Exception ex) { Debug.WriteLine("Unable to launch maps: " + ex); return false; } }
/// <summary> /// Navigate to an address /// </summary> /// <param name="name">Label to display</param> /// <param name="street">Street</param> /// <param name="city">City</param> /// <param name="state">Sate</param> /// <param name="zip">Zip</param> /// <param name="country">Country</param> /// <param name="countryCode">Country Code if applicable</param> /// <param name="navigationType">Navigation type</param> public void NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; if (string.IsNullOrWhiteSpace(street)) street = string.Empty; if (string.IsNullOrWhiteSpace(city)) city = string.Empty; if (string.IsNullOrWhiteSpace(state)) state = string.Empty; if (string.IsNullOrWhiteSpace(zip)) zip = string.Empty; if (string.IsNullOrWhiteSpace(country)) country = string.Empty; var uri = String.Format("http://maps.google.com/maps?q={0} {1}, {2} {3} {4}", street, city, state, zip, country); var intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri)); intent.SetClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); if (TryIntent(intent)) return; var uri2 = String.Format("geo:0,0?q={0} {1} {2} {3} {4}", street, city, state, zip, country); if (TryIntent(new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri2)))) return; if (TryIntent(new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri)))) return; Toast.MakeText(Android.App.Application.Context, "Please install a maps application", ToastLength.Long).Show(); }
/// <summary> /// Navigate to an address /// </summary> /// <param name="name">Label to display</param> /// <param name="street">Street</param> /// <param name="city">City</param> /// <param name="state">Sate</param> /// <param name="zip">Zip</param> /// <param name="country">Country</param> /// <param name="countryCode">Country Code if applicable</param> /// <param name="navigationType">Navigation type</param> public Task<bool> NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; if (string.IsNullOrWhiteSpace(street)) street = string.Empty; if (string.IsNullOrWhiteSpace(city)) city = string.Empty; if (string.IsNullOrWhiteSpace(state)) state = string.Empty; if (string.IsNullOrWhiteSpace(zip)) zip = string.Empty; if (string.IsNullOrWhiteSpace(country)) country = string.Empty; var uri = String.Format("http://maps.google.com/maps?q={0} {1}, {2} {3} {4}", street, city, state, zip, country); var intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri)); intent.SetClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); if (TryIntent(intent)) return Task.FromResult(true); var uri2 = String.Format("geo:0,0?q={0} {1} {2} {3} {4}", street, city, state, zip, country); if (TryIntent(new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri2)))) return Task.FromResult(true); if (TryIntent(new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri)))) return Task.FromResult(true); Debug.WriteLine("No map apps found, unable to navigate"); return Task.FromResult(false); }
/// <summary> /// Add a node to quick launch, top navigation bar or search navigation. The node will be added as the last node in the /// collection. /// </summary> /// <param name="web">Site to be processed - can be root web or sub site</param> /// <param name="nodeTitle">the title of node to add</param> /// <param name="nodeUri">the url of node to add</param> /// <param name="parentNodeTitle">if string.Empty, then will add this node as top level node</param> /// <param name="navigationType">the type of navigation, quick launch, top navigation or search navigation</param> public static void AddNavigationNode(this Web web, string nodeTitle, Uri nodeUri, string parentNodeTitle, NavigationType navigationType) { web.Context.Load(web, w => w.Navigation.QuickLaunch, w => w.Navigation.TopNavigationBar); web.Context.ExecuteQueryRetry(); NavigationNodeCreationInformation node = new NavigationNodeCreationInformation { AsLastNode = true, Title = nodeTitle, Url = nodeUri != null ? nodeUri.OriginalString : string.Empty }; try { if (navigationType == NavigationType.QuickLaunch) { var quickLaunch = web.Navigation.QuickLaunch; if (string.IsNullOrEmpty(parentNodeTitle)) { quickLaunch.Add(node); return; } NavigationNode parentNode = quickLaunch.SingleOrDefault(n => n.Title == parentNodeTitle); if (parentNode != null) { parentNode.Children.Add(node); } } else if (navigationType == NavigationType.TopNavigationBar) { var topLink = web.Navigation.TopNavigationBar; topLink.Add(node); } else if (navigationType == NavigationType.SearchNav) { var searchNavigation = web.LoadSearchNavigation(); searchNavigation.Add(node); } } finally { web.Context.ExecuteQueryRetry(); } }
/// <summary> /// Navigate to an address /// </summary> /// <param name="name">Label to display</param> /// <param name="street">Street</param> /// <param name="city">City</param> /// <param name="state">Sate</param> /// <param name="zip">Zip</param> /// <param name="country">Country</param> /// <param name="countryCode">Country Code if applicable</param> /// <param name="navigationType">Navigation type</param> public Task<bool> NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default) { try { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; if (string.IsNullOrWhiteSpace(street)) street = string.Empty; if (string.IsNullOrWhiteSpace(city)) city = string.Empty; if (string.IsNullOrWhiteSpace(state)) state = string.Empty; if (string.IsNullOrWhiteSpace(zip)) zip = string.Empty; if (string.IsNullOrWhiteSpace(country)) country = string.Empty; var mapsDirectionsTask = new MapsDirectionsTask(); // If you set the geocoordinate parameter to null, the label parameter is used as a search term. var lml = new LabeledMapLocation(string.Format("{0}%20{1},%20{2}%20{3}%20{4}", street, city, state, zip, country), null); mapsDirectionsTask.End = lml; // If mapsDirectionsTask.Start is not set, the user's current location is used as the start point. mapsDirectionsTask.Show(); } catch (Exception ex) { Debug.WriteLine("Unable to launch maps: " + ex); return Task.FromResult(false); } return Task.FromResult(true); }
/// <summary> /// Navigate to specific latitude and longitude. /// </summary> /// <param name="name">Label to display</param> /// <param name="latitude">Lat</param> /// <param name="longitude">Long</param> /// <param name="navigationType">Type of navigation</param> public void NavigateTo(string name, double latitude, double longitude, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; NSDictionary dictionary = null; var mapItem = new MKMapItem(new MKPlacemark(new CLLocationCoordinate2D(latitude, longitude), dictionary)); mapItem.Name = name; MKLaunchOptions launchOptions = null; if(navigationType != NavigationType.Default) { launchOptions = new MKLaunchOptions { DirectionsMode = navigationType == NavigationType.Driving ? MKDirectionsMode.Driving : MKDirectionsMode.Walking }; } var mapItems = new[] { mapItem }; MKMapItem.OpenMaps(mapItems, launchOptions); }
/// <summary> /// Navigate to specific latitude and longitude. /// </summary> /// <param name="name">Label to display</param> /// <param name="latitude">Lat</param> /// <param name="longitude">Long</param> /// <param name="navigationType">Type of navigation</param> public void NavigateTo(string name, double latitude, double longitude, NavigationType navigationType = NavigationType.Default) { var uri = String.Format("http://maps.google.com/maps?&daddr={0},{1} ({2})", latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), name); var intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri)); intent.SetClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); if (TryIntent(intent)) return; var uri2 = string.Format("geo:{0},{1}?q={0},{1}({2})", latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), name); if (TryIntent(new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri2)))) return; if (TryIntent(new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri)))) return; Toast.MakeText(Android.App.Application.Context, "Please install a maps application", ToastLength.Long).Show(); }
/// <summary> /// Navigate to an address /// </summary> /// <param name="name">Label to display</param> /// <param name="street">Street</param> /// <param name="city">City</param> /// <param name="state">Sate</param> /// <param name="zip">Zip</param> /// <param name="country">Country</param> /// <param name="countryCode">Country Code if applicable</param> /// <param name="navigationType">Navigation type</param> public async void NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) name = string.Empty; if (string.IsNullOrWhiteSpace(street)) street = string.Empty; if (string.IsNullOrWhiteSpace(city)) city = string.Empty; if (string.IsNullOrWhiteSpace(state)) state = string.Empty; if (string.IsNullOrWhiteSpace(zip)) zip = string.Empty; if (string.IsNullOrWhiteSpace(country)) country = string.Empty; await Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("bingmaps:?where={0}%20{1}%20{2}%20{3}%20{4}", street, city, state, zip, country))); }
public static Task <bool> TryCloseAsync([NotNull] this IViewModel viewModel, [CanBeNull] object parameter, [CanBeNull] INavigationContext context, NavigationType type = null) { Should.NotBeNull(viewModel, nameof(viewModel)); if (context == null) { context = parameter as INavigationContext ?? new NavigationContext(type ?? NavigationType.Undefined, NavigationMode.Back, viewModel, viewModel.GetParentViewModel(), null); } if (parameter == null) { parameter = context; } //NOTE: Close view model only on back navigation. ICloseableViewModel closeableViewModel = context.NavigationMode == NavigationMode.Back ? viewModel as ICloseableViewModel : null; var navigableViewModel = viewModel as INavigableViewModel; if (closeableViewModel == null && navigableViewModel == null) { return(Empty.TrueTask); } if (closeableViewModel != null && navigableViewModel != null) { Task <bool> navigatingTask = navigableViewModel.OnNavigatingFrom(context); if (navigatingTask.IsCompleted) { if (navigatingTask.Result) { return(closeableViewModel.CloseAsync(parameter)); } return(Empty.FalseTask); } return(navigatingTask .TryExecuteSynchronously(task => { if (task.Result) { return closeableViewModel.CloseAsync(parameter); } return Empty.FalseTask; }).Unwrap()); } if (closeableViewModel == null) { return(navigableViewModel.OnNavigatingFrom(context)); } return(closeableViewModel.CloseAsync(parameter)); }
/// <summary> /// Called when the view is being pushed under or popped off of the top of the view stack. /// Returning a value of <c>false</c> will cancel the navigation. /// </summary> /// <param name="link">A <see cref="Link"/> containing the destination and any other relevant information regarding the navigation taking place.</param> /// <param name="type">The type of navigation that was initiated.</param> /// <returns><c>true</c> to proceed with the navigation; otherwise, <c>false</c>.</returns> protected virtual bool ShouldNavigateFrom(Link link, NavigationType type) { return(true); }
/// <summary> /// Add a node to quick launch, top navigation bar or search navigation. The node will be added as the last node in the /// collection. /// </summary> /// <param name="web">Site to be processed - can be root web or sub site</param> /// <param name="nodeTitle">the title of node to add</param> /// <param name="nodeUri">the url of node to add</param> /// <param name="parentNodeTitle">if string.Empty, then will add this node as top level node</param> /// <param name="navigationType">the type of navigation, quick launch, top navigation or search navigation</param> /// <param name="isExternal">true if the link is an external link</param> /// <param name="asLastNode">true if the link should be added as the last node of the collection</param> public static void AddNavigationNode(this Web web, string nodeTitle, Uri nodeUri, string parentNodeTitle, NavigationType navigationType, bool isExternal = false, bool asLastNode = true) { web.Context.Load(web, w => w.Navigation.QuickLaunch, w => w.Navigation.TopNavigationBar); web.Context.ExecuteQueryRetry(); NavigationNodeCreationInformation node = new NavigationNodeCreationInformation { AsLastNode = asLastNode, Title = nodeTitle, Url = nodeUri != null ? nodeUri.OriginalString : string.Empty, IsExternal = isExternal }; try { if (navigationType == NavigationType.QuickLaunch) { var quickLaunch = web.Navigation.QuickLaunch; if (string.IsNullOrEmpty(parentNodeTitle)) { quickLaunch.Add(node); return; } NavigationNode parentNode = quickLaunch.SingleOrDefault(n => n.Title == parentNodeTitle); if (parentNode != null) { parentNode.Children.Add(node); } } else if (navigationType == NavigationType.TopNavigationBar) { var topLink = web.Navigation.TopNavigationBar; if (!string.IsNullOrEmpty(parentNodeTitle)) { var parentNode = topLink.FirstOrDefault(n => n.Title == parentNodeTitle); if (parentNode != null) { parentNode.Children.Add(node); } } else { topLink.Add(node); } } else if (navigationType == NavigationType.SearchNav) { var searchNavigation = web.LoadSearchNavigation(); searchNavigation.Add(node); } } finally { web.Context.ExecuteQueryRetry(); } }
//private void OnModelPropertyChanged(object sender, PropertyChangedEventArgs e) //{ // switch (e.PropertyName) // { // case "Title": // uiThreadInvoke(() => view.SetTitle(model.Title)); // break; // case "Address": // uiThreadInvoke(() => view.SetAddress(model.Address)); // break; // case "CanGoBack": // uiThreadInvoke(() => view.SetCanGoBack(model.CanGoBack)); // break; // case "CanGoForward": // uiThreadInvoke(() => view.SetCanGoForward(model.CanGoForward)); // break; // case "IsLoading": // uiThreadInvoke(() => view.SetIsLoading(model.IsLoading)); // break; // } //} // private void OnModelConsoleMessage(object sender, ConsoleMessageEventArgs e) // { // uiThreadInvoke(() => view.DisplayOutput(e.Message)); // } // private void OnViewShowDevToolsActivated(object sender, EventArgs e) // { // model.ShowDevTools(); // } // private void OnViewCloseDevToolsActivated(object sender, EventArgs e) // { // model.CloseDevTools(); // } // private void OnViewExitActivated(object sender, EventArgs e) // { // var disposableModel = model as IDisposable; // if (disposableModel != null) // { // disposableModel.Dispose(); // } // Cef.Shutdown(); // Environment.Exit(0); // } // void OnViewUndoActivated(object sender, EventArgs e) // { // model.Undo(); // } // void OnViewRedoActivated(object sender, EventArgs e) // { // model.Redo(); // } // void OnViewCutActivated(object sender, EventArgs e) // { // model.Cut(); // } // void OnViewCopyActivated(object sender, EventArgs e) // { // model.Copy(); // } // void OnViewPasteActivated(object sender, EventArgs e) // { // model.Paste(); // } // void OnViewDeleteActivated(object sender, EventArgs e) // { // model.Delete(); // } // void OnViewSelectAllActivated(object sender, EventArgs e) // { // model.SelectAll(); // } // private void OnViewTestResourceLoadActivated(object sender, EventArgs e) // { // //model.Load(resource_url); // } // private void OnViewTestSchemeLoadActivated(object sender, EventArgs e) // { // //model.Load(scheme_url); // } // private void OnViewTestExecuteScriptActivated(object sender, EventArgs e) // { // var script = String.Format("document.body.style.background = '{0}'", // colors[color_index++]); // if (color_index >= colors.Length) // { // color_index = 0; // } // view.ExecuteScript(script); // } // private void OnViewTestEvaluateScriptActivated(object sender, EventArgs e) // { // var rand = new Random(); // var x = rand.Next(1, 10); // var y = rand.Next(1, 10); // var script = String.Format("{0} + {1}", x, y); // var result = view.EvaluateScript(script); // var output = String.Format("{0} => {1}", script, result); // uiThreadInvoke(() => view.DisplayOutput(output)); // } // private void OnViewTestBindActivated(object sender, EventArgs e) // { // //model.Load(bind_url); // } // private void OnViewTestConsoleMessageActivated(object sender, EventArgs e) // { // var script = "console.log('Hello, world!')"; // view.ExecuteScript(script); // } // private void OnViewTestTooltipActivated(object sender, EventArgs e) // { // //model.Load(tooltip_url); // } // private void OnViewTestPopupActivated(object sender, EventArgs e) // { // //model.Load(popup_url); // } // private void OnViewTestLoadStringActivated(object sender, EventArgs e) // { // model.LoadHtml(string.Format("<html><body><a href='{0}'>CefSharp Home</a></body></html>", DefaultUrl)); // } // private void OnViewTestCookieVisitorActivated(object sender, EventArgs e) // { // Cef.VisitAllCookies(this); // } // TODO: This one might be needed... //private void OnViewUrlActivated(object sender, string address) //{ // model.Load(address); //} // private void OnViewBackActivated(object sender, EventArgs e) // { // model.Back(); // } // private void OnViewForwardActivated(object sender, EventArgs e) // { // model.Forward(); // } bool IRequestHandler.OnBeforeBrowse(IWebBrowser browser, IRequest request, NavigationType naigationvType, bool isRedirect) { return(false); }
public Task NavigateToAsync <TViewModel>(object parameter, NavigationType type = NavigationType.Normal) where TViewModel : IABaseViewModel => InternalNavigateToAsync(typeof(TViewModel), type, null, parameter);
public NavigationEvent() { Target = Names.UnknownGeneral; Location = Names.UnknownGeneral; TypeOfNavigation = NavigationType.Unknown; }
private async Task <bool> CanChangePage(Type requestingViewModel, XamlNav.NavigationMode navigationMode, NavigationType navigationType) { // We will do this for the UWP only interface INavigable var navigableViewModel = this.ContentDataContext as INavigable; if (navigableViewModel != null) { var args = new NavigatingInfo(navigationMode, navigationType, requestingViewModel); await navigableViewModel.OnNavigatingFrom(args); return(!args.Cancel); } // And also for the interface that also exist for desktop for compatibility reasons var frameAware = this.ContentDataContext as IFrameAware; if (frameAware != null) { return(frameAware.CanClose()); } return(true); }
/// <summary> /// Add a node to quick launch, top navigation bar or search navigation. The node will be added as the last node in the /// collection. /// </summary> /// <param name="web">Site to be processed - can be root web or sub site</param> /// <param name="nodeTitle">the title of node to add</param> /// <param name="nodeUri">the URL of node to add</param> /// <param name="parentNodeTitle">if string.Empty, then will add this node as top level node. Contains the title of the immediate parent node, for third level nodes, providing <paramref name="l1ParentNodeTitle"/> is required.</param> /// <param name="navigationType">the type of navigation, quick launch, top navigation or search navigation</param> /// <param name="isExternal">true if the link is an external link</param> /// <param name="asLastNode">true if the link should be added as the last node of the collection</param> /// <param name="l1ParentNodeTitle">title of the first level parent, if this node is a third level navigation node</param> /// <returns>Newly added NavigationNode</returns> public static NavigationNode AddNavigationNode(this Web web, string nodeTitle, Uri nodeUri, string parentNodeTitle, NavigationType navigationType, bool isExternal = false, bool asLastNode = true, string l1ParentNodeTitle = null) { web.Context.Load(web, w => w.Navigation.QuickLaunch, w => w.Navigation.TopNavigationBar); web.Context.ExecuteQueryRetry(); var node = new NavigationNodeCreationInformation { AsLastNode = asLastNode, Title = nodeTitle, Url = nodeUri != null ? nodeUri.OriginalString : string.Empty, IsExternal = isExternal }; NavigationNode navigationNode = null; try { if (navigationType == NavigationType.QuickLaunch) { var quickLaunch = web.Navigation.QuickLaunch; if (string.IsNullOrEmpty(parentNodeTitle)) { navigationNode = quickLaunch.Add(node); } else { navigationNode = CreateNodeAsChild(web, quickLaunch, node, parentNodeTitle, l1ParentNodeTitle); } } else if (navigationType == NavigationType.TopNavigationBar) { var topLink = web.Navigation.TopNavigationBar; if (!string.IsNullOrEmpty(parentNodeTitle)) { navigationNode = CreateNodeAsChild(web, topLink, node, parentNodeTitle, l1ParentNodeTitle); } else { navigationNode = topLink.Add(node); } } else if (navigationType == NavigationType.SearchNav) { var searchNavigation = web.LoadSearchNavigation(); navigationNode = searchNavigation.Add(node); } } finally { web.Context.ExecuteQueryRetry(); } return(navigationNode); }
/// <summary> /// Navigate to an address /// </summary> /// <param name="name">Label to display</param> /// <param name="street">Street</param> /// <param name="city">City</param> /// <param name="state">Sate</param> /// <param name="zip">Zip</param> /// <param name="country">Country</param> /// <param name="countryCode">Country Code if applicable</param> /// <param name="navigationType">Navigation type</param> public async Task <bool> NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) { name = string.Empty; } if (string.IsNullOrWhiteSpace(street)) { street = string.Empty; } if (string.IsNullOrWhiteSpace(city)) { city = string.Empty; } if (string.IsNullOrWhiteSpace(state)) { state = string.Empty; } if (string.IsNullOrWhiteSpace(zip)) { zip = string.Empty; } if (string.IsNullOrWhiteSpace(country)) { country = string.Empty; } CLPlacemark[] placemarks = null; MKPlacemarkAddress placemarkAddress = null; try { placemarkAddress = new MKPlacemarkAddress { City = city, Country = country, State = state, Street = street, Zip = zip, CountryCode = countryCode }; var coder = new CLGeocoder(); placemarks = await coder.GeocodeAddressAsync(placemarkAddress.Dictionary); } catch (Exception ex) { Debug.WriteLine("Unable to get geocode address from address: " + ex); return(false); } if ((placemarks?.Length ?? 0) == 0) { Debug.WriteLine("No locations exist, please check address."); return(false); } try { var placemark = placemarks[0]; var mapItem = new MKMapItem(new MKPlacemark(placemark.Location.Coordinate, placemarkAddress)); mapItem.Name = name; MKLaunchOptions launchOptions = null; if (navigationType != NavigationType.Default) { launchOptions = new MKLaunchOptions { DirectionsMode = navigationType == NavigationType.Driving ? MKDirectionsMode.Driving : MKDirectionsMode.Walking }; } var mapItems = new[] { mapItem }; MKMapItem.OpenMaps(mapItems, launchOptions); } catch (Exception ex) { Debug.WriteLine("Unable to launch maps: " + ex); } return(true); }
/// <summary> /// Navigate to specific latitude and longitude. /// </summary> /// <param name="name">Label to display</param> /// <param name="latitude">Lat</param> /// <param name="longitude">Long</param> /// <param name="navigationType">Type of navigation</param> public Task <bool> NavigateTo(string name, double latitude, double longitude, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) { name = string.Empty; } try { NSDictionary dictionary = null; var mapItem = new MKMapItem(new MKPlacemark(new CLLocationCoordinate2D(latitude, longitude), dictionary)); mapItem.Name = name; MKLaunchOptions launchOptions = null; if (navigationType != NavigationType.Default) { launchOptions = new MKLaunchOptions { DirectionsMode = navigationType == NavigationType.Driving ? MKDirectionsMode.Driving : MKDirectionsMode.Walking }; } var mapItems = new[] { mapItem }; MKMapItem.OpenMaps(mapItems, launchOptions); return(Task.FromResult(true)); } catch (Exception ex) { Debug.WriteLine("Unable to launch maps: " + ex); return(Task.FromResult(false)); } }
/// <summary> /// Navigate to an address /// </summary> /// <param name="name">Label to display</param> /// <param name="street">Street</param> /// <param name="city">City</param> /// <param name="state">Sate</param> /// <param name="zip">Zip</param> /// <param name="country">Country</param> /// <param name="countryCode">Country Code if applicable</param> /// <param name="navigationType">Navigation type</param> public void NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) { name = string.Empty; } if (string.IsNullOrWhiteSpace(street)) { street = string.Empty; } if (string.IsNullOrWhiteSpace(city)) { city = string.Empty; } if (string.IsNullOrWhiteSpace(state)) { state = string.Empty; } if (string.IsNullOrWhiteSpace(zip)) { zip = string.Empty; } if (string.IsNullOrWhiteSpace(country)) { country = string.Empty; } var mapsDirectionsTask = new MapsDirectionsTask(); // If you set the geocoordinate parameter to null, the label parameter is used as a search term. var lml = new LabeledMapLocation(string.Format("{0}%20{1},%20{2}%20{3}%20{4}", street, city, state, zip, country), null); mapsDirectionsTask.End = lml; // If mapsDirectionsTask.Start is not set, the user's current location is used as the start point. mapsDirectionsTask.Show(); }
public void UpdateOpenedViewModels(NavigationType type, IList <IOpenedViewModelInfo> viewModelInfos, IDataContext context = null) { Should.NotBeNull(type, nameof(type)); Should.NotBeNull(viewModelInfos, nameof(viewModelInfos)); UpdateOpenedViewModelsInternal(type, viewModelInfos, context ?? DataContext.Empty); }
/// <summary> /// Navigate to page /// </summary> /// <param name="sourcePageType">Type of <see cref="AppercodePage"/> to Navigate</param> /// <param name="parameter">Parameter to put on <see cref="AppercodePage"/> when navigated to</param> /// <returns>was <see cref="AppercodePage"/> navigated to or it was canceled</returns> public bool Navigate(Type sourcePageType, object parameter, NavigationType navigationType) { if (sourcePageType == null) { throw new ArgumentNullException("sourcePageType", "sourcePageType must not be null"); } if (!sourcePageType.IsSubclassOf(typeof(AppercodePage)) && sourcePageType != typeof(AppercodePage)) { throw new ArgumentException("sourcePageType must be an AppercodePage", "sourcePageType"); } if (this.IsNavigationInProgress) { return false; } return BooleanBoxes.TrueBox == this.Dispatcher.Invoke( (Func<Type, object, NavigationType, object>)this.NavigateInternal, sourcePageType, parameter, navigationType); }
public IList <IOpenedViewModelInfo> GetOpenedViewModels(NavigationType type, IDataContext context = null) { Should.NotBeNull(type, nameof(type)); return(GetOpenedViewModelsInternal(type, context ?? DataContext.Empty)); }
/// <summary> /// Set Type /// </summary> /// <typeparam name="TResponse"></typeparam> /// <param name="navigationResponse"></param> /// <param name="navigationType">Navigation Type</param> /// <param name="responseType">Response Type</param> public static void SetTypes <TResponse>(this NavigationResponse <TResponse> navigationResponse, NavigationType navigationType, object responseType) { if (navigationResponse != null) { navigationResponse.NavigationType = navigationType; navigationResponse.Type = responseType; } }
internal async Task <bool> Navigate(Type viewModelType, object[] arguments, XamlNav.NavigationMode navigationMode, NavigationType navigationType) { if (!await this.CanChangePage(viewModelType, navigationMode, navigationType)) { return(false); } FrameworkElement view = null; IViewModel viewModel = null; // Create a view if (navigationMode == XamlNav.NavigationMode.Back || navigationMode == XamlNav.NavigationMode.Forward || navigationMode == XamlNav.NavigationMode.New) { view = GetView(viewModelType); } // Create a view model if (navigationMode == XamlNav.NavigationMode.Back || navigationMode == XamlNav.NavigationMode.Forward || navigationMode == XamlNav.NavigationMode.Refresh) { viewModel = Factory.Create(viewModelType, arguments).As <IViewModel>(); // Use Factory create here so that the factory extensions are invoked } // Bind the IsLoading if implemented if (view != null) { view.SetBinding(Control.IsEnabledProperty, new Binding { Path = new PropertyPath(nameof(IViewModel.IsLoading)), Converter = new BooleanInvertConverter() }); } if (navigationMode == XamlNav.NavigationMode.Back || navigationMode == XamlNav.NavigationMode.Forward) { // Setup the page transition animations if (view.Transitions != null && view.Transitions.Count > 0) { this.ContentTransitions = view.Transitions; } else { this.ContentTransitions = this.DefaultChildrenTransitions; } // we need to keep our old datacontext to dispose them properly later on var oldDataContext = this.ContentDataContext; var oldView = this.Content.As <FrameworkElement>(); // Assign our new content this.Content = view; await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => view.DataContext = viewModel); // Invoke the Navigation stuff in the current datacontext await AsyncHelper.NullGuard(viewModel.As <INavigable>()?.OnNavigatedTo(new NavigationInfo(navigationMode, navigationType, oldDataContext?.GetType()))); // Remove the reference of the old vm from the old view oldView.IsNotNull(x => x.DataContext = null); // Now invoke the navigated from on our old data context await AsyncHelper.NullGuard(oldDataContext?.As <INavigable>()?.OnNavigatedFrom(new NavigationInfo(navigationMode, navigationType, viewModelType))); // dispose the old viewmodel oldDataContext?.TryDispose(); } else if (navigationMode == XamlNav.NavigationMode.New) { // NavigationMode.New means recreate the view but preserve the viewmodel // we need to keep our current datacontext for later reassigning var currentDataContext = this.ContentDataContext; var oldView = this.Content.As <FrameworkElement>(); // cancel this if the oldview and the new view are the same if (oldView.GetType() == view.GetType()) { return(false); } // Assign our content this.Content = view; await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => view.DataContext = currentDataContext); // Invoke the Navigation stuff in the current datacontext await AsyncHelper.NullGuard(currentDataContext.As <INavigable>()?.OnNavigatedTo(new NavigationInfo(navigationMode, navigationType, currentDataContext.GetType()))); // Remove the reference of the current viewmodel from the old view oldView.IsNotNull(x => x.DataContext = null); } else if (navigationMode == XamlNav.NavigationMode.Refresh) { // we need to keep our old datacontext to dispose them properly later on var oldDataContext = this.ContentDataContext; // NavigationMode.Refresh means recreate the view model but preserve the view viewModel = Factory.Create(viewModelType, arguments).As <IViewModel>(); await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => view.DataContext = viewModel); // Invoke the Navigation stuff in the current datacontext await AsyncHelper.NullGuard(viewModel.As <INavigable>()?.OnNavigatedTo(new NavigationInfo(navigationMode, navigationType, viewModelType))); // dispose the old viewmodel oldDataContext?.TryDispose(); } // Refresh the stacks if (navigationMode == XamlNav.NavigationMode.Forward) { // we have to check if the current viewmodel is the same as the one the top of the forwardstack // if that is the case we remove it from the stack // if that is not the case, then we clear the stack if (this.ForwardStack.Count > 0) { var stackEntry = this.ForwardStack[0]; // Remove the stack if equal if (viewModelType == stackEntry.ViewModelType && ((stackEntry.Parameters != null && arguments != null && stackEntry.Parameters.SequenceEqual(arguments)) || (stackEntry.Parameters == null && arguments == null))) { this.ForwardStack.RemoveAt(0); } else { this.ForwardStack.Clear(); } } } if (navigationMode == XamlNav.NavigationMode.Back || navigationMode == XamlNav.NavigationMode.Forward) { this.BackStack.Add(new PageStackEntry(viewModelType, arguments)); } // remove entries from stack if (this.MaxStackSize > 1) { if (this.BackStack.Count > this.MaxStackSize + 1) { this.BackStack.RemoveAt(0); } if (this.ForwardStack.Count > this.MaxStackSize) { this.ForwardStack.RemoveAt(this.ForwardStack.Count - 1); } } this.CanGoBack = this.BackStack.Count > 1; this.CanGoForward = this.ForwardStack.Count > 0; this.Navigated?.Invoke(this, EventArgs.Empty); return(true); }
public ProductsBundle(string categoryId, string categoryName, string searchText, NavigationType navigationType) : base(navigationType, new Dictionary <string, string> { { nameof(categoryId), categoryId }, { nameof(categoryName), categoryName }, { nameof(searchText), searchText } }) { }
public NavigationEventArgs(string current, string next, NavigationType type) { Current = current; Next = next; Type = type; }
/// <summary> /// Get Navigation Type /// </summary> /// <param name="navigationType">Navigation Type</param> /// <returns>Navigate Type</returns> public static NavigateType GetNavigationType(NavigationType navigationType) => (NavigateType)(navigationType);
public OrderFieldAutocompleteBundle(IOrderFieldItemVM orderField, Dictionary <string, string> dependentFieldsValues, NavigationType navigationType = NavigationType.Push) : base(navigationType, new Dictionary <string, string> { { nameof(Id), orderField.Id }, { nameof(Name), orderField.Name }, { nameof(Value), orderField.Value }, { nameof(Type), ((int)orderField.Type).ToString() }, { nameof(IsRequired), orderField.IsRequired.ToString() }, { nameof(AutocompleteStartIndex), orderField.AutocompleteStartIndex.ToString(NumberFormatInfo.InvariantInfo) }, { nameof(DependentFieldsValues), JsonConvert.SerializeObject(dependentFieldsValues) } }) { Id = orderField.Id; Name = orderField.Name; Value = orderField.Value; Type = orderField.Type; IsRequired = orderField.IsRequired; AutocompleteStartIndex = orderField.AutocompleteStartIndex; DependentFieldsValues = dependentFieldsValues; }
bool IRequestHandler.OnBeforeBrowse(IWebBrowser browser, IRequest request, NavigationType naigationvType, bool isRedirect) { //System.Diagnostics.Debug.WriteLine("OnBeforeBrowse"); return(false); }
public bool OnNavigationItemSelected(int itemPosition, long itemId) { navigationType = (NavigationType)itemPosition; SetActionBar(); return(true); }
/// <summary> /// Navigate to an address /// </summary> /// <param name="name">Label to display</param> /// <param name="street">Street</param> /// <param name="city">City</param> /// <param name="state">Sate</param> /// <param name="zip">Zip</param> /// <param name="country">Country</param> /// <param name="countryCode">Country Code if applicable</param> /// <param name="navigationType">Navigation type</param> public void NavigateTo(string name, string street, string city, string state, string zip, string country, string countryCode, NavigationType navigationType = NavigationType.Default) { if (string.IsNullOrWhiteSpace(name)) { name = string.Empty; } if (string.IsNullOrWhiteSpace(street)) { street = string.Empty; } if (string.IsNullOrWhiteSpace(city)) { city = string.Empty; } if (string.IsNullOrWhiteSpace(state)) { state = string.Empty; } if (string.IsNullOrWhiteSpace(zip)) { zip = string.Empty; } if (string.IsNullOrWhiteSpace(country)) { country = string.Empty; } Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("bingmaps:?where={0}%20{1}%20{2}%20{3}%20{4}", street, city, state, zip, country))); }
private async Task <bool> DeactivatePreviousViewModelsAsync(NavigationType navigationType, Type newViewModelTypeOverride, DeactivationParameters parameters) { IEnumerable <State> stack = await this.statePersistor.GetAllStatesAsync(); bool navigationTypeOverriden = false; if (stack.Any()) { var viewModelsToDeactivate = stack .SkipWhile(i => i.ViewModelType != newViewModelTypeOverride) .Select(i => i.ViewModelType) .Reverse() .ToList(); if (viewModelsToDeactivate.Count == 0) { viewModelsToDeactivate.Add(stack.Last().ViewModelType); } else { // target ViewModel already exists on the stack, meaning from the perspective of the existing ViewModels, the navigation is going back navigationType = NavigationType.Backward; navigationTypeOverriden = true; } // first check if all can deactivate foreach (var viewModelType in viewModelsToDeactivate) { var viewModel = await this.viewModelLocator.GetInstanceAsync(viewModelType); if (!await ViewModelActivator.CanDeactivateViewModelAsync(viewModel, navigationType, parameters)) { return(false); } } // if all can deactivate, do so foreach (var viewModelType in viewModelsToDeactivate) { var viewModel = await this.viewModelLocator.GetInstanceAsync(viewModelType); await ViewModelActivator.DeactivateViewModelAsync(viewModel, navigationType, parameters); } if (navigationTypeOverriden) { foreach (var viewModelType in viewModelsToDeactivate) { // pop the extra ViewModels from the persistence stack await this.statePersistor.PopStateAsync(); // when navigating forward to existing ViewModel (large screen with the first View visible) we must manually unhook existing ViewTypes, since they are no longer active var viewType = await this.viewLocator.GetViewTypeAsync(viewModelType); //this.platformNavigator.UnhookType(viewType); this.platformNavigator.GoBack(viewModelType, viewType); } } } return(true); }
/// <summary> /// Supported navigability of this navigation property. /// </summary> /// <param name="navigability">The value to set</param> /// <returns><see cref="NavigationPropertyRestrictionConfiguration"/></returns> public NavigationPropertyRestrictionConfiguration HasNavigability(NavigationType navigability) { _navigability = navigability; return(this); }
/// <summary> /// Deletes a navigation node from the quickLaunch or top navigation bar /// </summary> /// <param name="web">Site to be processed - can be root web or sub site</param> /// <param name="nodeTitle">the title of node to delete</param> /// <param name="parentNodeTitle">if string.Empty, then will delete this node as top level node</param> /// <param name="navigationType">the type of navigation, quick launch, top navigation or search navigation</param> public static void DeleteNavigationNode(this Web web, string nodeTitle, string parentNodeTitle, NavigationType navigationType) { web.Context.Load(web, w => w.Navigation.QuickLaunch, w => w.Navigation.TopNavigationBar); web.Context.ExecuteQueryRetry(); NavigationNode deleteNode = null; try { if (navigationType == NavigationType.QuickLaunch) { var quickLaunch = web.Navigation.QuickLaunch; if (string.IsNullOrEmpty(parentNodeTitle)) { deleteNode = quickLaunch.SingleOrDefault(n => n.Title == nodeTitle); } else { foreach (var nodeInfo in quickLaunch) { if (nodeInfo.Title != parentNodeTitle) { continue; } web.Context.Load(nodeInfo.Children); web.Context.ExecuteQueryRetry(); deleteNode = nodeInfo.Children.SingleOrDefault(n => n.Title == nodeTitle); } } } else if (navigationType == NavigationType.TopNavigationBar) { var topLink = web.Navigation.TopNavigationBar; if (string.IsNullOrEmpty(parentNodeTitle)) { deleteNode = topLink.SingleOrDefault(n => n.Title == nodeTitle); } else { foreach (var nodeInfo in topLink) { if (nodeInfo.Title != parentNodeTitle) { continue; } web.Context.Load(nodeInfo.Children); web.Context.ExecuteQueryRetry(); deleteNode = nodeInfo.Children.SingleOrDefault(n => n.Title == nodeTitle); } } } else if (navigationType == NavigationType.SearchNav) { NavigationNodeCollection nodeCollection = web.LoadSearchNavigation(); deleteNode = nodeCollection.SingleOrDefault(n => n.Title == nodeTitle); } } finally { if (deleteNode != null) { deleteNode.DeleteObject(); } web.Context.ExecuteQueryRetry(); } }
private void Navigate(Uri oldValue, Uri newValue, NavigationType navigationType) { Debug.WriteLine("Navigating from '{0}' to '{1}'", oldValue, newValue); // set IsLoadingContent state SetValue(IsLoadingContentPropertyKey, true); // cancel previous load content task (if any) // note: no need for thread synchronization, this code always executes on the UI thread if (this.tokenSource != null) { this.tokenSource.Cancel(); this.tokenSource = null; } // push previous source onto the history stack (only for new navigation types) if (oldValue != null && navigationType == NavigationType.New) { this.history.Push(oldValue); } object newContent = null; if (newValue != null) { // content is cached on uri without fragment var newValueNoFragment = NavigationHelper.RemoveFragment(newValue); if (navigationType == NavigationType.Refresh || !this.contentCache.TryGetValue(newValueNoFragment, out newContent)) { var localTokenSource = new CancellationTokenSource(); this.tokenSource = localTokenSource; // load the content (asynchronous!) var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); var task = this.ContentLoader.LoadContentAsync(newValue, this.tokenSource.Token); task.ContinueWith(t => { try { if (t.IsCanceled || localTokenSource.IsCancellationRequested) { Debug.WriteLine("Cancelled navigation to '{0}'", newValue); } else if (t.IsFaulted) { // raise failed event var failedArgs = new NavigationFailedEventArgs { Frame = this, Source = newValue, Error = t.Exception.InnerException, Handled = false }; OnNavigationFailed(failedArgs); // if not handled, show error as content newContent = failedArgs.Handled ? null : failedArgs.Error; SetContent(newValue, navigationType, newContent, true); } else { newContent = t.Result; if (ShouldKeepContentAlive(newContent)) { // keep the new content in memory this.contentCache[newValueNoFragment] = newContent; } SetContent(newValue, navigationType, newContent, false); } } finally { // clear global tokenSource to avoid a Cancel on a disposed object if (this.tokenSource == localTokenSource) { this.tokenSource = null; } // and dispose of the local tokensource localTokenSource.Dispose(); } }, scheduler); return; } } // newValue is null or newContent was found in the cache SetContent(newValue, navigationType, newContent, false); }
private static void Register(NavigationType type, Type dto, Type service) { DTO_TO_SERVICE.Add(dto, service); TYPE_TO_DTO.Add(type, dto); }
public WeakOpenedViewModelInfo(IViewModel viewModel, object provider, NavigationType navigationType) { _viewModelReference = ToolkitServiceProvider.WeakReferenceFactory(viewModel); _providerReference = ToolkitServiceProvider.WeakReferenceFactory(provider); NavigationType = navigationType; }
/// <summary> /// Navigate to page /// </summary> /// <param name="sourcePageType">Type of <see cref="AppercodePage"/> to Navigate</param> /// <returns>was <see cref="AppercodePage"/> navigated to or it was canceled</returns> public bool Navigate(Type sourcePageType, NavigationType navigationType) { return this.Navigate(sourcePageType, null, navigationType); }
public NavigatingFromEventArgs( NavigationType navigationType, Uri uri) { NavigationType = navigationType; Uri = uri; }
private object NavigateInternal(Type sourcePageType, object parameter, NavigationType navigationType) { this.IsNavigationInProgress = true; // navigating from if (this.CurrentPage != null) { var navigatingCancelEventArgs = new NavigatingCancelEventArgs(sourcePageType, NavigationMode.New); this.CurrentPage.InternalOnNavigatingFrom(navigatingCancelEventArgs); if (navigatingCancelEventArgs.Cancel) { this.IsNavigationInProgress = false; return BooleanBoxes.FalseBox; } } // navigated from var navigationEventArgs = new NavigationEventArgs(sourcePageType, parameter); if (this.CurrentPage != null) { this.CurrentPage.InternalOnNavigatedFrom(navigationEventArgs); this.backStack.Push(this.CurrentPage); } // Create page var pageConstructorInfo = sourcePageType.GetConstructor(new Type[] { }); AppercodePage pageInstance; try { pageInstance = (AppercodePage)pageConstructorInfo.Invoke(new object[] { }); } catch (TargetInvocationException e) { this.IsNavigationInProgress = false; throw e.InnerException; } pageInstance.NavigationService = this.NavigationService; this.visualRoot.Child = pageInstance; this.NativeShowPage(pageInstance, NavigationMode.New, navigationType); this.modalIsDisplayed |= navigationType == NavigationType.Modal; // navigated to pageInstance.InternalOnNavigatedTo(navigationEventArgs); this.CurrentPage = pageInstance; this.IsNavigationInProgress = false; return BooleanBoxes.TrueBox; }
public NavigateWithFavoritePlaceArgs(IPlace navigationPlace, NavigationType navigationType, int?intermediateIndex = null) { Place = navigationPlace; PlaceNavigationType = navigationType; IntermediateIndex = intermediateIndex; }