Наследование: IQuickLink
Пример #1
0
        private async void btnOK_Tapped(object sender, TappedRoutedEventArgs e)
        {
            _shareOperation.ReportStarted();

            QuickLink ql = new QuickLink()
            {
                Id = "myid",
                Title = _shareOperation.Data.Properties["Title"].ToString(),
                SupportedFileTypes = { "*" },
                SupportedDataFormats =
                    {
                        StandardDataFormats.Text,
                        StandardDataFormats.WebLink,
                        StandardDataFormats.Bitmap
                    }
            };

            if (_shareOperation.Data.Properties.Thumbnail != null)
            {
                var s = await _shareOperation.Data.Properties.Thumbnail.OpenReadAsync();
                ql.Thumbnail = RandomAccessStreamReference.CreateFromStream(s);
            }
            _shareOperation.ReportCompleted(ql);
        }
        async void ReportCompleted_Click(object sender, RoutedEventArgs e)
        {
            if (AddQuickLink.IsChecked.Equals(true))
            {
                QuickLink quickLinkInfo = new QuickLink
                {
                    Id = QuickLinkId.Text,
                    Title = QuickLinkTitle.Text,

                    // For QuickLinks, the supported FileTypes and DataFormats are set independently from the manifest.
                    SupportedFileTypes = { "*" },
                    SupportedDataFormats =
                    {
                        StandardDataFormats.Text,
                        StandardDataFormats.WebLink,
                        StandardDataFormats.ApplicationLink,
                        StandardDataFormats.Bitmap,
                        StandardDataFormats.StorageItems,
                        StandardDataFormats.Html,
                        dataFormatName
                    }
                };

                try
                {
                    StorageFile iconFile = await Package.Current.InstalledLocation.CreateFileAsync("assets\\squareTile-sdk.png", CreationCollisionOption.OpenIfExists);
                    quickLinkInfo.Thumbnail = RandomAccessStreamReference.CreateFromFile(iconFile);
                    this.shareOperation.ReportCompleted(quickLinkInfo);
                }
                catch (Exception)
                {
                    // Even if the QuickLink cannot be created it is important to call ReportCompleted. Otherwise, if this is a long-running share,
                    // the app will stick around in the long-running share progress list.
                    this.shareOperation.ReportCompleted();
                    throw;
                }
            }
            else
            {
                this.shareOperation.ReportCompleted();
            }
        }
Пример #3
0
 public void ReportCompleted(QuickLink quicklink)
 {
     shareOperation.ReportCompleted(quicklink);
 }
        private void SaveContent()
        {
            var quickLink = new QuickLink
                                {
                                    Id = "LL.ShareTarge",
                                    Title = "Share Target"
                                };

            _shareOperation.ReportCompleted(quickLink);
        }
Пример #5
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary<string, object> state)
        {
            var key = parameter as StateItemKey;
            if (key != null && SessionState.Contains(key))
            {
                ShareOperation = SessionState.Get<ShareOperation>(key);
            }
            else
            {
                Content = "Opened without using share";
                return;
            }

            try
            {
                if (this.ShareOperation.Data.Contains(StandardDataFormats.Html))
                { Content = (await ShareOperation.Data.GetHtmlFormatAsync()).ToString(); }
                else if (ShareOperation.Data.Contains(StandardDataFormats.Text))
                { Content = (await ShareOperation.Data.GetTextAsync()).ToString(); }
                else if (ShareOperation.Data.Contains(StandardDataFormats.WebLink))
                { Content = (await ShareOperation.Data.GetWebLinkAsync()).AbsoluteUri; }
                else if (ShareOperation.Data.Contains(StandardDataFormats.ApplicationLink))
                { Content = (await ShareOperation.Data.GetApplicationLinkAsync()).AbsoluteUri; }
                else if (ShareOperation.Data.Contains(StandardDataFormats.Bitmap))
                {
                    Content = nameof(StandardDataFormats.Bitmap);
                    var bitmap = await ShareOperation.Data.GetBitmapAsync();
                    using (var stream = await bitmap.OpenReadAsync())
                    {
                        Bitmap = new BitmapImage();
                        Bitmap.SetSource(stream);
                    }
                }
                else if (ShareOperation.Data.Contains(StandardDataFormats.StorageItems))
                {
                    Content = nameof(StandardDataFormats.StorageItems);
                    foreach (var item in await ShareOperation.Data.GetStorageItemsAsync())
                    {
                        Content += item.Path + Environment.NewLine;
                    }
                }
                else
                {
                    Content = "Some unsupported share type.";
                    return;
                }

                QuickLink = ShareOperation.QuickLinkId ?? "None set";

                if (ShareOperation.Data.Properties.Square30x30Logo != null)
                {
                    using (var stream = await ShareOperation.Data.Properties.Square30x30Logo.OpenReadAsync())
                    {
                        Logo = new BitmapImage();
                        Logo.SetSource(stream);
                    }
                }

                if (ShareOperation.Data.Properties.Thumbnail != null)
                {
                    using (var stream = await ShareOperation.Data.Properties.Thumbnail.OpenReadAsync())
                    {
                        Thumbnail = new BitmapImage();
                        Thumbnail.SetSource(stream);
                    }
                }
            }
            catch (Exception e) { Content = e.Message; }
            finally
            {
                var folder = await Package.Current.InstalledLocation.GetFolderAsync("Assets");
                var file = await folder.GetFileAsync("T10 56x56.png");
                var reference = RandomAccessStreamReference.CreateFromFile(file);
                var quick = new QuickLink()
                {
                    Id = "Template10 QuickLink",
                    Title = "Template10 QuickLink",
                    Thumbnail = reference,
                };
                quick.SupportedFileTypes.Clear();
                quick.SupportedFileTypes.Add(StandardDataFormats.Text);
                quick.SupportedFileTypes.Add(StandardDataFormats.WebLink);
                quick.SupportedFileTypes.Add(StandardDataFormats.ApplicationLink);
                quick.SupportedFileTypes.Add(StandardDataFormats.Bitmap);
                quick.SupportedFileTypes.Add(StandardDataFormats.Html);
                ShareOperation.ReportCompleted(quick);
            }
        }
Пример #6
0
 public void ReportCompleted(QuickLink quicklink)
 {
     throw new NotImplementedException();
 }