public void Share(DataRequest request) { // We work with a copy of the list of document references List<DocumentReference> list = null; if (DocumentReferences != null) { list = DocumentReferences.ToList(); } request.Data.Properties.Title = SearchResultInfo; // request.Data.Properties.Description = ...; if (list != null) { var stb = new StringBuilder(); stb.AppendLine(); stb.Append("Suchresultate:\r\n"); foreach (var docref in list) { stb.AppendFormat("{0}, {1}\r\nRIS Bundesrecht Österreich URL: risdok://{2}/\r\nWeb URL: {3}\r\n\r\n", docref.ArtikelParagraphAnlage, docref.Kurzinformation, docref.Dokumentnummer, docref.DokumentUrl); } request.Data.SetText(stb.ToString()); } else { request.FailWithDisplayText("Keine Resultate für Sharing vorhanden"); } }
public void OnShareRequested(DataRequest dataRequest) { dataRequest.Data.Properties.Title = "Share Source Example"; dataRequest.Data.Properties.Description = "An example of sharing data from a view model"; dataRequest.Data.SetUri(new Uri("http://www.markermetro.com")); }
private void SetShareContent(DataRequest request, IModel model) { DataPackage requestData = request.Data; Platform.Current.Logger.Log(LogLevels.Information, "SetShareContent - Model: {0}", model?.GetType().Name); // Sharing is based on the model data that was passed in. Perform customized sharing based on the type of the model provided. if (model is ContentItemBase) { var m = model as ContentItemBase; requestData.Properties.Title = m.Title; requestData.Properties.Description = m.Description; var args = Platform.Current.GenerateModelArguments(model); requestData.Properties.ContentSourceApplicationLink = new Uri(Platform.Current.AppInfo.GetDeepLink(args), UriKind.Absolute); string body = m.Title + Environment.NewLine + m.Description; requestData.SetText(body); } else { requestData.Properties.Title = Core.Strings.Resources.ApplicationName; requestData.Properties.Description = Core.Strings.Resources.ApplicationDescription; requestData.Properties.ContentSourceApplicationLink = new Uri(Platform.Current.AppInfo.StoreURL, UriKind.Absolute); string body = string.Format(Core.Strings.Resources.ApplicationSharingBodyText, Core.Strings.Resources.ApplicationName, Platform.Current.AppInfo.StoreURL); requestData.SetText(body); } }
protected override bool GetShareContent(DataRequest request) { bool succeeded = false; if (this.imageFile != null) { DataPackage requestData = request.Data; requestData.Properties.Title = TitleInputBox.Text; requestData.Properties.Description = DescriptionInputBox.Text; // The description is optional. requestData.Properties.ContentSourceApplicationLink = ApplicationLink; // It's recommended to use both SetBitmap and SetStorageItems for sharing a single image // since the target app may only support one or the other. List<IStorageItem> imageItems = new List<IStorageItem>(); imageItems.Add(this.imageFile); requestData.SetStorageItems(imageItems); RandomAccessStreamReference imageStreamRef = RandomAccessStreamReference.CreateFromFile(this.imageFile); requestData.Properties.Thumbnail = imageStreamRef; requestData.SetBitmap(imageStreamRef); succeeded = true; } else { request.FailWithDisplayText("Select an image you would like to share and try again."); } return succeeded; }
protected override bool GetShareContent(DataRequest request) { bool succeeded = false; Uri selectedApplicationLink = ApplicationLinkComboBox.SelectedItem as Uri; if (selectedApplicationLink != null) { DataPackage requestData = request.Data; requestData.Properties.Title = TitleInputBox.Text; requestData.Properties.Description = DescriptionInputBox.Text; // The description is optional. requestData.Properties.ContentSourceApplicationLink = ApplicationLink; requestData.SetApplicationLink(selectedApplicationLink); // Place the selected logo and the background color in the data package properties if (MicrosoftLogo.IsChecked.Value) { requestData.Properties.Square30x30Logo = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///assets/microsoftLogo.png")); requestData.Properties.LogoBackgroundColor = GetLogoBackgroundColor(); } else if (VisualStudioLogo.IsChecked.Value) { requestData.Properties.Square30x30Logo = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///assets/visualStudioLogo.png")); requestData.Properties.LogoBackgroundColor = GetLogoBackgroundColor(); } succeeded = true; } else { request.FailWithDisplayText("Select the application link you would like to share and try again."); } return succeeded; }
protected override bool GetShareContent(DataRequest request) { bool succeeded = false; string dataPackageFormat = DataFormatInputBox.Text; if (!String.IsNullOrEmpty(dataPackageFormat)) { string dataPackageText = CustomDataTextBox.Text; if (!String.IsNullOrEmpty(dataPackageText)) { DataPackage requestData = request.Data; requestData.Properties.Title = TitleInputBox.Text; requestData.Properties.Description = DescriptionInputBox.Text; // The description is optional. requestData.Properties.ContentSourceApplicationLink = ApplicationLink; requestData.SetData(dataPackageFormat, dataPackageText); succeeded = true; } else { request.FailWithDisplayText("Enter the custom data you would like to share and try again."); } } else { request.FailWithDisplayText("Enter a custom data format and try again."); } return succeeded; }
public ShareRequestAdapter(DataRequest dataRequest, Guid id) { _dataRequest = dataRequest; _data = _dataRequest.Data; _properties = _data.Properties; _properties.ApplicationName = "ExampleApplication.WinRT"; Id = id; }
protected override bool GetShareContent(DataRequest request) { string errorMessage = CustomErrorText.Text; if (String.IsNullOrEmpty(errorMessage)) { errorMessage = "Enter a failure display text and try again."; } request.FailWithDisplayText(errorMessage); return false; }
protected override bool GetShareContent(DataRequest request) { var link = ResultsGridView.SelectedItem as Link; if (link != null) { DataPackage dataPackage = request.Data; dataPackage.Properties.Title = link.Name + " Shared via Linky!"; dataPackage.Properties.Description = link.Name + " Shared via Linky!"; dataPackage.SetUri(link.Uri); return true; } return true; }
protected void ShareContent(DataRequest dataRequest, ItemViewModel item, bool supportsHtml) { try { if (item != null) { dataRequest.Data.Properties.Title = string.IsNullOrEmpty(item.Title) ? Title : item.Title; if (!string.IsNullOrEmpty(item.SubTitle)) { SetContent(dataRequest, item.SubTitle, false); } if (!string.IsNullOrEmpty(item.Description)) { SetContent(dataRequest, item.Description, supportsHtml); } if (!string.IsNullOrEmpty(item.Content)) { SetContent(dataRequest, item.Content, supportsHtml); } if (!string.IsNullOrEmpty(item.Source)) { dataRequest.Data.SetWebLink(new Uri(item.Source)); } var imageUrl = item.ImageUrl; if (!string.IsNullOrEmpty(imageUrl)) { if (imageUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { if (string.IsNullOrEmpty(item.Source)) { dataRequest.Data.SetWebLink(new Uri(imageUrl)); } } else { imageUrl = string.Format("ms-appx://{0}", imageUrl); } dataRequest.Data.SetBitmap(Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(new Uri(imageUrl))); } } } catch (UriFormatException) { } }
public void OnShareRequested(DataRequest dataRequest) { dataRequest.Data.Properties.Title = "Bingo Patterns Won!"; var strBuilder = new StringBuilder(); foreach (var patternCount in PatternCounts) { strBuilder.AppendFormat("<strong>{0}</strong>: {1}</br></br>", patternCount.Name, patternCount.Count); } var html = HtmlFormatHelper.CreateHtmlFormat(strBuilder.ToString()); dataRequest.Data.SetHtmlFormat(html); }
public static void Share(DataRequest request) { if (ShareInfo != null) { request.Data.Properties.Title = ShareInfo.Title; request.Data.Properties.Description = "PPTV 网络电视"; request.Data.SetText( string.Format(Constants.ShareTips, ShareInfo.Title, PPTVData.Utils.DataCommonUtils.ConvertToWebSite(ShareInfo.Id))); var reference = RandomAccessStreamReference.CreateFromUri(new Uri(ShareInfo.ImageUri)); request.Data.Properties.Thumbnail = reference; var deferral = request.GetDeferral(); request.Data.SetBitmap(reference); deferral.Complete(); } }
protected override bool GetShareContent(DataRequest request) { bool succeeded = false; if (storageItems != null) { DataPackage requestData = request.Data; requestData.Properties.Title = TitleInputBox.Text; requestData.Properties.Description = DescriptionInputBox.Text; // The description is optional. requestData.Properties.ContentSourceApplicationLink = ApplicationLink; requestData.SetStorageItems(this.storageItems); succeeded = true; } else { request.FailWithDisplayText("Select the files you would like to share and try again."); } return succeeded; }
// This function is implemented by each scenario to share the content specific to that scenario (text, link, image, etc.). protected bool GetShareContent(DataRequest request) { bool succeeded = false; var app = Application.Current as App; if (!String.IsNullOrEmpty(app.SharingTitle)) { DataPackage requestData = request.Data; requestData.Properties.Title = app.SharingTitle; requestData.Properties.Description = app.SharingText; // The description is optional. requestData.SetUri(new Uri(app.SharingLink)); succeeded = true; } else { request.FailWithDisplayText("nothing to share"); } return succeeded; }
protected override bool GetShareContent(DataRequest request) { bool succeeded = false; if (this.selectedImage != null) { DataPackage requestData = request.Data; requestData.Properties.Title = "Delay rendered image"; requestData.Properties.Description = "Resized image from the Share Source sample"; requestData.Properties.ContentSourceApplicationLink = ApplicationLink; requestData.Properties.Thumbnail = RandomAccessStreamReference.CreateFromFile(this.selectedImage); requestData.SetDataProvider(StandardDataFormats.Bitmap, providerRequest => this.OnDeferredImageRequestedHandler(providerRequest, this.selectedImage)); succeeded = true; } else { request.FailWithDisplayText("Select an image you would like to share and try again."); } return succeeded; }
protected override bool GetShareContent(DataRequest request) { bool succeeded = false; // The URI used in this sample is provided by the user so we need to ensure it's a well formatted absolute URI // before we try to share it. rootPage.NotifyUser("", NotifyType.StatusMessage); Uri dataPackageUri = ValidateAndGetUri(UriToShare.Text); if (dataPackageUri != null) { DataPackage requestData = request.Data; requestData.Properties.Title = TitleInputBox.Text; requestData.Properties.Description = DescriptionInputBox.Text; // The description is optional. requestData.Properties.ContentSourceApplicationLink = ApplicationLink; requestData.SetWebLink(dataPackageUri); succeeded = true; } else { request.FailWithDisplayText("Enter the web link you would like to share and try again."); } return succeeded; }
protected override bool GetShareContent(DataRequest request) { // Get the user's selection from the WebView. Since this is an asynchronous operation we need to acquire the deferral first. DataRequestDeferral deferral = request.GetDeferral(); // Make sure to always call Complete when done with the deferral. try { var requestDataOperation = ShareWebView.CaptureSelectedContentToDataPackageAsync(); requestDataOperation.Completed += (asyncInfo, status) => { DataPackage requestData = asyncInfo.GetResults(); if ((requestData != null) && (requestData.GetView().AvailableFormats.Count > 0)) { requestData.Properties.Title = "A web snippet for you"; requestData.Properties.Description = "HTML selection from a WebView control"; // The description is optional. requestData.Properties.ContentSourceApplicationLink = ApplicationLink; requestData.Properties.ContentSourceWebLink = new Uri("http://msdn.microsoft.com"); request.Data = requestData; deferral.Complete(); } else { // FailWithDisplayText calls Complete on the deferral. request.FailWithDisplayText("Make a selection in the WebView control and try again."); } }; } catch (Exception) { deferral.Complete(); } // At this point, we haven't populated the data package yet. It's done asynchronously above. return false; }
private void SetContent(DataRequest dataRequest, string data, bool supportsHtml) { if (supportsHtml) { dataRequest.Data.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(data)); } else { dataRequest.Data.SetText(data.DecodeHtml()); } }
public bool GetShareContent(DataRequest request) { bool succeeded = false; string dataPackageText = "I started using my fashion assistant ! it's very useful and free \n "; if (!String.IsNullOrEmpty(dataPackageText)) { DataPackage requestData = request.Data; requestData.Properties.Title = "My Fashion assistant"; requestData.Properties.Description = "My Fashion assistant it's a free application that helps you to get better dressed"; // The description is optional. //requestData.Properties.ContentSourceApplicationLink = ApplicationLink; requestData.SetText(dataPackageText); succeeded = true; } else { request.FailWithDisplayText("Enter the text you would like to share and try again."); } return succeeded; }
// This function is implemented by each scenario to share the content specific to that scenario (text, link, image, etc.). protected abstract bool GetShareContent(DataRequest request);
public void OnShareRequested(DataRequest dataRequest) { }
internal DataRequestedEventArgs(Action <DataRequest> deferralComplete) { Request = new DataRequest(deferralComplete); }
abstract public void GetShareContent(DataRequest dataRequest);
public SettableDataRequest(DataRequest dataRequest) { Data = dataRequest.Data; _deferral = new Lazy<IDeferral>(() => new DataRequestDeferralAdapter(dataRequest.GetDeferral())); }
private void TextSharingHandler(DataPackagePropertySet properties, DataRequest request) { properties.Title = "Compartiendo texto desde el Share Charm"; properties.Description = "Se supone que estoy compartiendo la descirpcion con el Share Charm"; request.Data.SetText("Hola Mundo desde Share Charm"); }
private void LinkSharingHandler(DataPackagePropertySet properties, DataRequest request) { properties.Title = "Compartiendo un link desde el Share Charm"; properties.Description = "Se supone que estoy compartiendo la descirpcion con el Share Charm"; request.Data.SetUri(new Uri("http://www.google.com")); }
private async void ImageSharingHandler(DataPackagePropertySet properties, DataRequest request) { properties.Title = "Compartiendo una imagen desde el Share Charm"; properties.Description = "Se supone que estoy compartiendo la descirpcion con el Share Charm"; // TODO Deferral espera abierta en el sistema // TODO Cuando se esten cargando cosas de manera asincrona debemos llamar el deferrel // TODO para que el sistema espere a la carga de los archivos antes de disparar el proceso completo. var deferral = request.GetDeferral(); // Ctrl + k + s, genera el envoltorio de try try { var thumbFile = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\Logo.png"); properties.Thumbnail = RandomAccessStreamReference.CreateFromFile(thumbFile); var imageFile = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\Logo.png"); request.Data.SetBitmap(RandomAccessStreamReference.CreateFromFile(imageFile)); } finally { deferral.Complete(); } }
private async void FileSharingHandler(DataPackagePropertySet properties, DataRequest request) { properties.Title = "Compartiendo un conjunto de archivos desde el Share Charm"; properties.Description = "Se supone que estoy compartiendo la descirpcion con el Share Charm"; var deferral = request.GetDeferral(); try { var sampleFile = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\casilleros.xlsx"); // Archivo no existe var sampleFile2 = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\Logo.png"); var storageFilesList = new List<IStorageItem>(); storageFilesList.Add(sampleFile); request.Data.SetStorageItems(storageFilesList); } finally { deferral.Complete(); } }
private async void OnShareRequested(DataRequest request) { var defferal = request.GetDeferral(); await ApplicationData.Current.ClearAsync(ApplicationDataLocality.Temporary); var from = From.Date; var until = Until.Date.AddDays(1).AddMilliseconds(-1); var exportFiles = GetExportFiles(from, until).ToArray(); if (exportFiles.Any()) { request.Data.Properties.Title = "Exported SensorCore files"; request.Data.Properties.Description = "Exported SensorCore files"; request.Data.SetStorageItems(await Task.WhenAll(exportFiles)); } else { request.FailWithDisplayText("Nothing selected to Export."); } defferal.Complete(); }
private void HtmlSharingHandler(DataPackagePropertySet properties, DataRequest request) { properties.Title = "Compartiendo un documento de html5 desde el Share Charm"; properties.Description = "Se supone que estoy compartiendo la descirpcion con el Share Charm"; var localImagePath = "ms-appx:///Assets/Logo.png"; string htmlContent = @"<p> hola esto es un <strong> parrafo de HTML </strong> :) </p> <p>Y esto es una imagen: <img source='"+ localImagePath +"'/></p>"; var htmlFormatString = HtmlFormatHelper.CreateHtmlFormat(htmlContent); request.Data.ResourceMap[localImagePath] = RandomAccessStreamReference.CreateFromUri(new Uri(localImagePath)); request.Data.SetHtmlFormat(htmlFormatString); }
private void ProvideSharingDataFromWebView(DataRequest request) { try { var html = new StringBuilder(webView.InvokeScript("eval", new string[] { "document.documentElement.outerHTML;" })); // Fix Urls to base Urls otherwise it won't look right (css, js et cetera missing) - really, really simple html.Replace("src=\"/", "src=\"http://www.ris.bka.gv.at/"); html.Replace("href=\"/", "href=\"http://www.ris.bka.gv.at/"); request.Data.Properties.Title = ViewModel.PageTitle; request.Data.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(html.ToString())); } catch { request.FailWithDisplayText("Es gibt keine Inhalte die geteilt werden können"); } }