当前位置: 首页>>代码示例>>C#>>正文


C# DataPackage.SetHtmlFormat方法代码示例

本文整理汇总了C#中Windows.ApplicationModel.DataTransfer.DataPackage.SetHtmlFormat方法的典型用法代码示例。如果您正苦于以下问题:C# DataPackage.SetHtmlFormat方法的具体用法?C# DataPackage.SetHtmlFormat怎么用?C# DataPackage.SetHtmlFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.ApplicationModel.DataTransfer.DataPackage的用法示例。


在下文中一共展示了DataPackage.SetHtmlFormat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyButton_Click

        void CopyButton_Click(object sender, RoutedEventArgs e)
        {
            OutputText.Text = "";
            OutputResourceMapKeys.Text = "";
            OutputHtml.NavigateToString("<HTML></HTML>");

            // Set the content to DataPackage as html format
            string htmlFormat = HtmlFormatHelper.CreateHtmlFormat(this.htmlFragment);
            var dataPackage = new DataPackage();
            dataPackage.SetHtmlFormat(htmlFormat);

            // Set the content to DataPackage as (plain) text format
            string plainText = HtmlUtilities.ConvertToText(this.htmlFragment);
            dataPackage.SetText(plainText);

            // Populate resourceMap with StreamReference objects corresponding to local image files embedded in HTML
            var imgUri = new Uri(imgSrc);
            var imgRef = RandomAccessStreamReference.CreateFromUri(imgUri);
            dataPackage.ResourceMap[imgSrc] = imgRef;

            try
            {
                // Set the DataPackage to clipboard.
                Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
                OutputText.Text = "Text and HTML formats have been copied to clipboard. ";
            }
            catch (Exception ex)
            {
                // Copying data to Clipboard can potentially fail - for example, if another application is holding Clipboard open
                rootPage.NotifyUser("Error copying content to Clipboard: " + ex.Message + ". Try again", NotifyType.ErrorMessage);
            }
        }
开发者ID:COMIsLove,项目名称:Windows-universal-samples,代码行数:32,代码来源:CopyText.xaml.cs

示例2: ShareRequested

        private void ShareRequested(DataPackage dataPackage)
        {
            // Set as many data types as we can.
            dataPackage.Properties.Title = this.FeedItem.Title;

            // Add a Uri
            dataPackage.SetUri(this.FeedItem.Link);

            // Add a text only version
            var text = string.Format("Check this out! {0} ({1})", this.FeedItem.Title, this.FeedItem.Link);
            dataPackage.SetText(text);

            // Add an HTML version.
            var htmlBuilder = new StringBuilder();
            htmlBuilder.AppendFormat("<p>Check this out!</p>", this.FeedItem.Author);
            htmlBuilder.AppendFormat("<p><a href='{0}'>{1}</a></p>", this.FeedItem.Link, this.FeedItem.Title);
            var html = HtmlFormatHelper.CreateHtmlFormat(htmlBuilder.ToString());
            dataPackage.SetHtmlFormat(html);
        }
开发者ID:brentedwards,项目名称:Charmed,代码行数:19,代码来源:WindowsFeedItemViewModel.cs

示例3: Build

		public static void Build(SharedPoll poll, DataPackage dataPackage)
		{
			if (poll == null)
			{
				throw new ArgumentNullException("poll");
			}
			if (dataPackage == null)
			{
				throw new ArgumentNullException("dataPackage");
			}

			var url = string.Format("myvote://poll/{0}", poll.PollId);

			// Set as many data types as we can.
			dataPackage.Properties.Title = string.Format("MyVote Poll: {0}", poll.Question);

			// Add an HTML version.
			var htmlBuilder = new StringBuilder();
			htmlBuilder.AppendFormat("<h1>{0}</h1>", poll.Question);
			htmlBuilder.AppendFormat("<p>{0}</p>", poll.Description);
			htmlBuilder.Append("<ol>");
			foreach (var option in poll.Options)
			{
				htmlBuilder.AppendFormat("<li>{0}</li>", option);
			}
			htmlBuilder.Append("</ol>");
			htmlBuilder.AppendFormat("<p><a href='{0}'>Cast your vote!</a></p>", url);
			var html = HtmlFormatHelper.CreateHtmlFormat(htmlBuilder.ToString());
			dataPackage.SetHtmlFormat(html);

			// Add a text only version
			var text = string.Format("{0} Cast your vote! {1}", poll.Question, url);
			dataPackage.SetText(text);

			// Add a Uri
			dataPackage.SetApplicationLink(new Uri(url, UriKind.Absolute));
		}
开发者ID:JacobAtchley,项目名称:MyVote,代码行数:37,代码来源:SharedPollPackageBuilder.cs

示例4: SetHtml

        /// <summary>
        /// Sets the current HTML text content that is stored in the clipboard.
        /// </summary>
        /// <param name="content">The HTML text content that is stored in the clipboard.</param>
        public virtual void SetHtml(string content)
        {
            var package = new DataPackage();

            package.SetHtmlFormat(content);

            Clipboard.SetContent(package);
        }
开发者ID:Cimbalino,项目名称:Cimbalino-Toolkit,代码行数:12,代码来源:ClipboardService.cs

示例5: FillPackage

		private static void FillPackage(StorageFile[] files, DataPackage package, object subShareItem)
		{
			if (subShareItem != null)
			{
				switch (subShareItem.GetType().Name)
				{
					case nameof(TextShareItem):
						{
							package.SetText((subShareItem as TextShareItem).Text);
						}
						break;
					case nameof(ApplicationLinkShareItem):
						{
							var sitm = subShareItem as ApplicationLinkShareItem;
							package.SetApplicationLink(sitm.ApplicationLink);
						}
						break;

					case nameof(DelayRenderedImageShareItem):
						{
							var sitm = subShareItem as DelayRenderedImageShareItem;
							package.SetBitmap(RandomAccessStreamReference.CreateFromStream(sitm.SelectedImage.GetRandowmAccessStream()));
						}
						break;

					case nameof(FilesShareItem):
						{
							StorageFile[] resultArray = files;
							package.SetStorageItems(resultArray);
						}
						break;
					case nameof(HtmlShareItem):
						{
							var sitm = subShareItem as HtmlShareItem;

							var fmt = HtmlFormatHelper.CreateHtmlFormat(sitm.HtmlFragment);
							package.SetHtmlFormat(fmt);
							package.SetText(sitm.HtmlFragment);

						}
						break;
					case nameof(WebLinkShareItem):
						{
							var sitm = subShareItem as WebLinkShareItem;
							package.SetWebLink(sitm.WebLink);
							package.SetText(sitm.WebLink?.ToString());

						}
						break;

					default:
						break;
				}

			}
		}
开发者ID:waynebaby,项目名称:GreaterShareUWP,代码行数:56,代码来源:DefaultShareService.cs

示例6: GetHtmlContent

        private async Task GetHtmlContent(DataPackage requestData, Empresa empresa, Item item)
        {
            var xml = new XmlDocument();
            var body = xml.CreateElement("DIV");

            xml.AppendChild(body);

            //Dados da empresa
            string Telefones = Utils.GetTelefoneNumeros(empresa.Telefones);

            string empresaShareText = empresa.ShareTexto.Replace("#TELEFONE#", Telefones).Replace("#URL#", empresa.Website);


            var empresaData = xml.CreateElement("P");
            empresaData.InnerText = empresaShareText;
            body.AppendChild(empresaData);

            body.AppendChild(xml.CreateElement("HR"));


            //Dados do Item compartilhado

            var Image = xml.CreateElement("IMG");
            Image.SetAttribute("SRC", new Uri(_baseUri, item.ImageUrl).ToString());
            body.AppendChild(Image);

            var Itemtipo = xml.CreateElement("H2");
            Itemtipo.InnerText = item.SubTitulo;

            var breakline = xml.CreateElement("BR");
            Itemtipo.AppendChild(breakline);

            var bold = xml.CreateElement("b");
            bold.InnerText = string.Format("R$ {0}", item.Valor);
            Itemtipo.AppendChild(bold);

            body.AppendChild(Itemtipo);

            var ImageDescription = xml.CreateElement("P");
            ImageDescription.InnerText = item.Descricao;
            body.AppendChild(ImageDescription);

            var localImage = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(item.ImageUrl.Replace("/", "\\"));

            requestData.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(xml.GetXml()));
            requestData.ResourceMap[new Uri(_baseUri, item.ImageUrl).ToString()] = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromFile(localImage);
        }
开发者ID:eduavila,项目名称:Win8AppTERA,代码行数:47,代码来源:ItemPage.xaml.cs

示例7: ShareCharm

 private void ShareCharm(DataPackage d)
 {
     // share charm
     if (Notes == null || Notes.Count == 0)
         return;
     d.Properties.Title = "Sharing Note - " + Notes[0].Title;
     d.SetText(Notes[0].TextFormat());
     d.SetHtmlFormat(Notes[0].HtmlFormat());
 }
开发者ID:noriike,项目名称:xaml-106136,代码行数:9,代码来源:MainPageViewModel.cs


注:本文中的Windows.ApplicationModel.DataTransfer.DataPackage.SetHtmlFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。