/// <summary> /// Jump to the smart link /// </summary> /// <param name="value"></param> private async void JumpToSmartLink(SingleSmartLink value) { // Give some time to the current context; allowing for handling/ending the UI interaction before initiating changes (via DataBinding) // (or more direct: give the UI-thread time to finish the selection in the list before driving the selection itself from here.) await TaskFunctions.Yield(); // Make sure we are removed from display SmartLinks = null; if (value != null) { // And put the request on the databus HandleSingleSmartLinkActivation(_smartLinksSender, _smartLinksFeature, _smartLinksField, value); } }
/// <summary> /// Single smart-link activation, actually activating some bits dependent on the type of Smart Link /// </summary> private async void HandleSingleSmartLinkActivation(object sender, Feature feature, FeatureFieldDescriptor field, SingleSmartLink smartLink) { if (smartLink != null) { switch (smartLink.SmartLinkType.PhysicalType) { case FeaturePhysicalFieldType.SmartLinkToWebPage: if (smartLink.Url != null) { try { var location = smartLink.Url; if (!location.StartsWith("http")) { location = string.Concat("http://", location); } var uri = new Uri(location); string str = Guid.NewGuid().ToString("N"); //string features = "directories=no,location=no,menubar=no,status=no,toolbar=no"; HtmlPage.Window.Navigate(uri, str); } catch (InvalidOperationException) { } catch (UriFormatException) { } } break; case FeaturePhysicalFieldType.SmartLinkToMailAddress: if (smartLink.Url != null) { var location = new Uri(string.Format("mailto:{0}", smartLink.Url)); string str = Guid.NewGuid().ToString("N"); //string features = "directories=no,location=no,menubar=no,status=no,toolbar=no"; try { HtmlPage.Window.Navigate(location, str); } catch (InvalidOperationException) { //var uriActivator = new InternalHyperlinkButton(location); //uriActivator.Activate(); } } break; case FeaturePhysicalFieldType.SmartLinkToDocument: if (smartLink.Url != null && smartLink.ServiceProvider != null) { var serviceProvider = smartLink.ServiceProvider; var service = serviceProvider.GetService <IServerDocumentService>(); var document = await service.GetServerDocumentAsync(smartLink.Url); if (document != null) { var viewModel = new DocumentViewModel(document); // Open the document viewModel.View(); } } break; case FeaturePhysicalFieldType.SmartLinkToWorld: var smartLinkToWorld = smartLink as SmartLinkToWorld; var world = smartLinkToWorld.World; if (world != null) { Messenger.Send(new LiteGoToWorldRequestMessage(sender, world, feature)); } break; } } }