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


C# DataPackage.SetBitmap方法代码示例

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


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

示例1: CopyImage_Click

 private void CopyImage_Click(object sender, RoutedEventArgs e)
 {
     var data = new DataPackage();
     var bi = FirstImage.Source as BitmapImage;
     var uri = bi.UriSource;
     data.SetBitmap(RandomAccessStreamReference.CreateFromUri(uri));
     Clipboard.SetContent(data);
 }
开发者ID:caschw,项目名称:WelcomingWindows10,代码行数:8,代码来源:MainPage.xaml.cs

示例2: SetBitmap

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

            var random = content.AsRandomAccessStream();

            var reference = RandomAccessStreamReference.CreateFromStream(random);

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

示例3: 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

示例4: GetShareContent

        private bool GetShareContent(DataRequest request)
        {
            bool succeeded = false;

            if (this.flipView.SelectedItem != null)
            {
                var item = (Item)this.flipView.SelectedItem;

                //                string customData = @"{
                //                    ""type"" : ""http://schema.org/Product"",
                //                    ""properties"" :
                //                    {
                //                    ""url"" : ""#URL#"",
                //                    ""description"" : ""#DESC#"",
                //                    ""name"" : ""#NAME#"",
                //                    ""model"" : ""#MODEL#"",
                //                    ""price"" : ""#PRICE#""
                //                    }
                //                }";

                //                customData = customData.Replace("#URL#", item.Uri).Replace("#DESC#", item.Descricao).Replace("#NAME#", item.Nome).Replace("#MODEL#", item.Categoria.Nome).Replace("#PRICE#", "R$ " + item.Valor);

                requestData = request.Data;
                //requestData.SetData("http://schema.org/Product", customData);
                requestData.Properties.Title = item.Nome == null ? "Imagem compartilhada" : item.Nome;
                requestData.Properties.Description = item.Descricao;

                RandomAccessStreamReference imageStreamRef = null;
                imageStreamRef = RandomAccessStreamReference.CreateFromUri(new Uri(_baseUri, item.ImageUrl));

                if (imageStreamRef != null)
                {

                    requestData.SetUri(new Uri(_baseUri, item.ImageUrl));
                    requestData.Properties.Title = string.Format("{0} - {1}", Win8CatalogApplication.Instance.Empresa.Nome, item.Nome);
                    requestData.Properties.Description = item.Descricao;
                    requestData.SetText(item.Descricao);

                    requestData.Properties.Thumbnail = imageStreamRef;
                    requestData.SetBitmap(imageStreamRef);

                    succeeded = true;
                }
            }
            else
            {
                request.FailWithDisplayText("Selecione a imagem que deseja compartilhar e tente novamente.");

            }
            return succeeded;
        }
开发者ID:eduavila,项目名称:Win8AppTERA,代码行数:51,代码来源:ItemPage.xaml.cs

示例5: CopyBitmap

        async private void CopyBitmap(bool isDelayRendered)
        {
            var imagePicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary,
                FileTypeFilter = { ".jpg", ".png", ".bmp", ".gif", ".tif" }
            };

            var imageFile = await imagePicker.PickSingleFileAsync();
            if (imageFile != null)
            {
                var dataPackage = new DataPackage();

                // Use one click handler for two operations: regular copy and copy using delayed rendering
                // Differentiate the case by the button name
                if (isDelayRendered)
                {
                    dataPackage.SetDataProvider(StandardDataFormats.Bitmap, request => OnDeferredImageRequestedHandler(request, imageFile));
                    OutputText.Text = "Image has been copied using delayed rendering";
                }
                else
                {
                    dataPackage.SetBitmap(RandomAccessStreamReference.CreateFromFile(imageFile));
                    OutputText.Text = "Image has been copied";
                }

                try
                {
                    Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
                }
                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);
                }
            }
            else
            {
                OutputText.Text = "No image was selected.";
            }
        }
开发者ID:oldnewthing,项目名称:old-Windows8-samples,代码行数:42,代码来源:CopyImage.xaml.cs

示例6: CopyToClipboard

 /// <summary>
 /// Скопировать в клипоборд.
 /// </summary>
 public async Task CopyToClipboard()
 {
     var dp = new DataPackage();
     var storage = ServiceLocator.Current.GetServiceOrThrow<IStorageService>();
     var f = await storage.FullSizeMediaFiles.GetFromMediaStorage(link);
     dp.SetBitmap(RandomAccessStreamReference.CreateFromFile(f));
     Clipboard.SetContent(dp);
     Clipboard.Flush();
 }
开发者ID:Opiumtm,项目名称:DvachBrowser3,代码行数:12,代码来源:BigMediaSourceViewModel.cs

示例7: CopyCommands

        private async void CopyCommands(object sender, TappedRoutedEventArgs e)
        {
            var dataPackage = new DataPackage();
            dataPackage.RequestedOperation = DataPackageOperation.Copy;

            var image = SelectedPod.CurrentImage;

            var uri = await Q42.WinRT.Data.WebDataCache.GetLocalUriAsync(new Uri(image.URL));

            var m = sender as MenuItem;
            switch (m.Text)
            {
                case COPY_IMAGE:
                    dataPackage.SetBitmap(RandomAccessStreamReference.CreateFromUri(uri));
                    break;
                case COPY_PLAIN:
                    dataPackage.SetText(image.Alt);
                    break;
                case COPY_URL:
                    dataPackage.SetText(image.URL);
                    break;
            }

            Clipboard.SetContent(dataPackage);
        }
开发者ID:grdaneault,项目名称:the-alpha,代码行数:25,代码来源:DetailPopup.xaml.cs


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