예제 #1
0
        public void CopyToClipboard(string str)
        {
            var dp = new Windows.ApplicationModel.DataTransfer.DataPackage();

            dp.SetText(str);
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dp);
        }
예제 #2
0
        internal static void CopyToClipboard(string text)
        {
            var pkg = new Windows.ApplicationModel.DataTransfer.DataPackage();

            pkg.SetText(text ?? "");
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(pkg);
        }
예제 #3
0
파일: Utils.cs 프로젝트: ytz4178/biliuwp
 public static void SetClipboard(string content)
 {
     Windows.ApplicationModel.DataTransfer.DataPackage pack = new Windows.ApplicationModel.DataTransfer.DataPackage();
     pack.SetText(content);
     Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(pack); // 保存 DataPackage 对象到剪切板
     Windows.ApplicationModel.DataTransfer.Clipboard.Flush();
 }
예제 #4
0
 private void btn_Share_Click(object sender, RoutedEventArgs e)
 {
     Windows.ApplicationModel.DataTransfer.DataPackage pack = new Windows.ApplicationModel.DataTransfer.DataPackage();
     pack.SetText(par.post_url);
     Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(pack); // 保存 DataPackage 对象到剪切板
     Windows.ApplicationModel.DataTransfer.Clipboard.Flush();
     messShow.Show("已将内容复制到剪切板", 2000);
 }
예제 #5
0
 private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
 {
     Windows.ApplicationModel.DataTransfer.DataPackage pack = new Windows.ApplicationModel.DataTransfer.DataPackage();
     pack.SetText((sender.DataContext as LiveVideoModel).item.share_url);
     Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(pack); // 保存 DataPackage 对象到剪切板
     Windows.ApplicationModel.DataTransfer.Clipboard.Flush();
     Utils.ShowMessageToast("已将内容复制到剪切板", 3000);
 }
예제 #6
0
 private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
 {
     Windows.ApplicationModel.DataTransfer.DataPackage pack = new Windows.ApplicationModel.DataTransfer.DataPackage();
     pack.SetText((sender as HyperlinkButton).Tag.ToString());
     Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(pack); // 保存 DataPackage 对象到剪切板
     Windows.ApplicationModel.DataTransfer.Clipboard.Flush();
     Utils.ShowMessageToast("已将内容复制到剪切板", 3000);
 }
예제 #7
0
 private void list_view_ItemClick(object sender, ItemClickEventArgs e)
 {
     Windows.ApplicationModel.DataTransfer.DataPackage pack = new Windows.ApplicationModel.DataTransfer.DataPackage();
     pack.SetText((e.ClickedItem as ChatModel).message);
     Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(pack); // 保存 DataPackage 对象到剪切板
     Windows.ApplicationModel.DataTransfer.Clipboard.Flush();
     messShow.Show("已将内容复制到剪切板", 3000);
 }
예제 #8
0
 private void btn_Share_Click(object sender, RoutedEventArgs e)
 {
     Windows.ApplicationModel.DataTransfer.DataPackage pack = new Windows.ApplicationModel.DataTransfer.DataPackage();
     pack.SetText("http://www.im9.com/community.html?community_id=" + par.id);
     Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(pack); // 保存 DataPackage 对象到剪切板
     Windows.ApplicationModel.DataTransfer.Clipboard.Flush();
     messShow.Show("已将链接复制到剪切板", 2000);
 }
예제 #9
0
 public async void DoClipboardShare()
 {
     Windows.ApplicationModel.DataTransfer.DataPackage pack = new Windows.ApplicationModel.DataTransfer.DataPackage();
     pack.SetText($"{VideoInfo.title} {VideoInfo.short_link}");
     Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(pack); // 保存 DataPackage 对象到剪切板
     Windows.ApplicationModel.DataTransfer.Clipboard.Flush();
     Utils.ShowMessageToast("已将内容复制到剪切板", 3000);
 }
        private void ButtonCopy_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var link = new Windows.ApplicationModel.DataTransfer.DataPackage();

            link.SetText("https://youtu.be/" + Constants.activeVideoID + "?t=" + Convert.ToInt32(controller.audioPlayer.PlaybackSession.Position.TotalSeconds) + "s");
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(link);
            Constants.MainPageRef.ShowNotifcation("Link copied to clipboard.");
        }
예제 #11
0
        private void CopyPageLinkMenuFlyoutItem_Click(object sender, RoutedEventArgs e)
        {
            Windows.ApplicationModel.DataTransfer.DataPackage dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();
            dataPackage.SetText((MangaPages.SelectedItem as Models.Page).image_url);
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
            var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();

            ExampleInAppNotification.Show(resourceLoader.GetString("LinkIsCopyied"), 4000);
        }
예제 #12
0
        private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
        {
            var content = new Windows.ApplicationModel.DataTransfer.DataPackage();

            content.SetText(_clickedLink);
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(content);
            _clickedLink = null;
            Notification.Show("复制成功");
        }
예제 #13
0
        // ссылка на главу
        private void CopyChapterLink_Click(object sender, RoutedEventArgs e)
        {
            Windows.ApplicationModel.DataTransfer.DataPackage dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();
            dataPackage.SetText(chapter.Link);
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
            var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();

            ExampleInAppNotification.Show(resourceLoader.GetString("LinkIsCopyied"), 4000);
        }
예제 #14
0
        private void btn_Share_Click(object sender, RoutedEventArgs e)
        {
            var url = web.Source.AbsoluteUri;

            Windows.ApplicationModel.DataTransfer.DataPackage pack = new Windows.ApplicationModel.DataTransfer.DataPackage();
            pack.SetText(url);
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(pack);
            Windows.ApplicationModel.DataTransfer.Clipboard.Flush();
            Utils.ShowMessageToast("已将地址复制到剪切板", 3000);
        }
        private async void CopyLinkExecute(ProxyViewModel proxy)
        {
            var response = await ProtoService.SendAsync(new GetProxyLink(proxy.Id));

            if (response is Text text && Uri.TryCreate(text.TextValue, UriKind.Absolute, out Uri uri))
            {
                var dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();
                dataPackage.SetText(text.TextValue);
                ClipboardEx.TrySetContent(dataPackage);
                await MessagePopup.ShowAsync(Strings.Resources.LinkCopied, Strings.Resources.UseProxyTelegram, Strings.Resources.OK);
            }
        }
예제 #16
0
        public static void SetClipboardText(string Text)
        {
#if __IOS__
            ClipBoard.String = Text;
#elif __ANDROID__
            ClipBoard.Text = Text;
#elif NETFX_CORE
            var ItemToSet = new Windows.ApplicationModel.DataTransfer.DataPackage();
            ItemToSet.SetText(Text);
            ClipBoard.SetContent(ItemToSet);
#endif
        }
예제 #17
0
        private async void CopyRedirectUriToClipboard_Click(object sender, RoutedEventArgs e)
        {
            var redirectURI = AuthenticationHelper.GetAppRedirectURI();

            var dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();

            dataPackage.SetText(redirectURI);
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
            Windows.ApplicationModel.DataTransfer.Clipboard.Flush();

            var dialog = new Windows.UI.Popups.MessageDialog(redirectURI, "App Redirect URI copied to clipboard");
            await dialog.ShowAsync();
        }
예제 #18
0
 private void copy_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var data = new Windows.ApplicationModel.DataTransfer.DataPackage();
         data.SetText(text.Text);
         Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(data);
     }
     catch
     {
         text.Text = "Cant copy zero length PassPhrase";
     }
 }
 private void CopyToClipboard_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();
         dataPackage.SetText(InputTxtBox.Text);
         dataPackage.Properties.EnterpriseId = Scenario1.m_EnterpriseIdentity;
         Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
         rootPage.NotifyUser("Successfully SetContent to clipboard", NotifyType.StatusMessage);
     }
     catch (Exception ex)
     {
         rootPage.NotifyUser("Exception: " + ex.ToString(), NotifyType.ErrorMessage);
     }
 }
예제 #20
0
        public void ShareRequested(Windows.ApplicationModel.DataTransfer.DataPackage dataPackage)
        {
            var sharedPoll = new MyVote.UI.Models.SharedPoll
            {
                PollId   = this.PollResults.PollID,
                Question = this.PollResults.PollDataResults.Question
            };

            foreach (var response in this.PollResults.PollDataResults.Results)
            {
                sharedPoll.Options.Add(response.OptionText);
            }

            SharedPollPackageBuilder.Build(sharedPoll, dataPackage);
        }
예제 #21
0
 public static bool SetClipboard(string content)
 {
     try
     {
         Windows.ApplicationModel.DataTransfer.DataPackage pack = new Windows.ApplicationModel.DataTransfer.DataPackage();
         pack.SetText(content);
         Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(pack);
         Windows.ApplicationModel.DataTransfer.Clipboard.Flush();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #22
0
        private async void MenuFlyoutItem_Click_1(object sender, RoutedEventArgs e)
        {
            var item = await Core.Api.ShortUrl.Info(_clickedLink);

            if (item?.Urls.FirstOrDefault()?.UrlLong == null)
            {
                return;
            }
            var content = new Windows.ApplicationModel.DataTransfer.DataPackage();

            content.SetText(item.Urls.FirstOrDefault().UrlLong);
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(content);
            _clickedLink = null;
            Notification.Show("复制成功");
        }
 private void CopyToClipboard_Click(object sender, RoutedEventArgs e)
 {
     var dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();
     dataPackage.SetText(InputTxtBox.Text);
     dataPackage.Properties.EnterpriseId = Scenario1.m_enterpriseId;
     Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
     if (dataPackage.Properties.EnterpriseId != Scenario1.m_enterpriseId)
     {
         rootPage.NotifyUser("Failed to mark data package to EnterpiseId=" + Scenario1.m_enterpriseId, NotifyType.ErrorMessage);
     }
     else
     {
         rootPage.NotifyUser("Successfully SetContent to clipboard using EnterpriseId=" + Scenario1.m_enterpriseId, NotifyType.StatusMessage);
     }
 }
        private void CopyToClipboard_Click(object sender, RoutedEventArgs e)
        {
            var dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();

            dataPackage.SetText(InputTxtBox.Text);
            dataPackage.Properties.EnterpriseId = Scenario1.m_enterpriseId;
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
            if (dataPackage.Properties.EnterpriseId != Scenario1.m_enterpriseId)
            {
                rootPage.NotifyUser("Failed to mark data package to EnterpiseId=" + Scenario1.m_enterpriseId, NotifyType.ErrorMessage);
            }
            else
            {
                rootPage.NotifyUser("Successfully SetContent to clipboard using EnterpriseId=" + Scenario1.m_enterpriseId, NotifyType.StatusMessage);
            }
        }
예제 #25
0
        public async Task When_PutAndGet()
        {
            string testString = "some text which should be intact";

            // setting clipboard
            var oClipCont = new Windows.ApplicationModel.DataTransfer.DataPackage();

            oClipCont.SetText(testString);
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(oClipCont);

            // and reading from clipboard
            var    clipView            = Windows.ApplicationModel.DataTransfer.Clipboard.GetContent();
            string stringFromClipboard = await clipView.GetTextAsync();

            Assert.AreEqual(stringFromClipboard, testString, false, "text was changed while putting and reading from Clipboard - error in tested methods");
        }
예제 #26
0
        private async void CopySvgToClipboard()
        {
            var svgFileUri = new Uri("ms-appx:///Assets/Test.svg");
            var svgFile    = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(svgFileUri);

            var svgText = await Windows.Storage.FileIO.ReadTextAsync(svgFile);

            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(svgText);

            var stream = new Windows.Storage.Streams.InMemoryRandomAccessStream();
            await stream.WriteAsync(bytes.AsBuffer());

            stream.Seek(0);

            var dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();

            dataPackage.SetData("image/svg+xml", stream);

            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
        }
        private async void Popup_CommandHandler_OfficeClipboard(FlyoutCommand command)
        {
            try
            {
                MimeType[] mimeTypes = null;

                if (_lastSelectedBlock != null)
                {
                    mimeTypes = _editor.GetSupportedExportMimeTypes(_lastSelectedBlock);
                }

                if (mimeTypes != null && mimeTypes.Contains(MimeType.OFFICE_CLIPBOARD))
                {
                    // export block to a file
                    var localFolder   = ApplicationData.Current.LocalFolder.Path;
                    var clipboardPath = System.IO.Path.Combine(localFolder.ToString(), "tmp/clipboard.gvml");
                    var drawer        = new ImageDrawer(_editor.Renderer.DpiX, _editor.Renderer.DpiY);

                    drawer.ImageLoader = UcEditor.ImageLoader;

                    _editor.Export_(_lastSelectedBlock, clipboardPath.ToString(), MimeType.OFFICE_CLIPBOARD, drawer);

                    // read back exported data
                    var clipboardData   = File.ReadAllBytes(clipboardPath);
                    var clipboardStream = new MemoryStream(clipboardData);

                    // store the data into clipboard
                    Windows.ApplicationModel.DataTransfer.Clipboard.Clear();
                    var clipboardContent = new Windows.ApplicationModel.DataTransfer.DataPackage();
                    clipboardContent.SetData(MimeTypeF.GetTypeName(MimeType.OFFICE_CLIPBOARD), clipboardStream.AsRandomAccessStream());
                    Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(clipboardContent);
                }
            }
            catch (Exception ex)
            {
                MessageDialog msgDialog = new MessageDialog(ex.ToString());
                await msgDialog.ShowAsync();
            }
        }
예제 #28
0
        private async void copyIds()
        {
            string tmp = string.Empty;

            foreach (var ticket in history.Items)
            {
                if (ticket.IsSent)
                {
                    tmp += ticket.Id + "\n";
                }
            }

            try
            {
                Windows.ApplicationModel.DataTransfer.DataPackage dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();
                dataPackage.RequestedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
                dataPackage.SetText(tmp);
                Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
            }
            catch (Exception e)
            {
                await new MessageDialog(e.Message, "Clipboard error").ShowAsync();
            }
        }
예제 #29
0
 public void SetContent(Windows​.ApplicationModel​.DataTransfer.DataPackage content) =>
 Windows​.ApplicationModel​.DataTransfer.Clipboard.SetContent(content);
예제 #30
0
        private async void copyIds()
        {
            string tmp = string.Empty;

            foreach (var ticket in history.Items)
            {
                if (ticket.IsSent)
                {
                    tmp += ticket.Id + "\n";
                }
            }

            try
            {
                Windows.ApplicationModel.DataTransfer.DataPackage dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();
                dataPackage.RequestedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
                dataPackage.SetText(tmp);
                Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
            }
            catch (Exception e)
            {
                await new MessageDialog(e.Message, "Clipboard error").ShowAsync();
            }
        }
예제 #31
0
 private void Copy(NameValue nv)
 {
     Windows.ApplicationModel.DataTransfer.DataPackage dp =
         new Windows.ApplicationModel.DataTransfer.DataPackage();
     dp.SetText(nv.Value);
     Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dp);
     textBoxAPI_Params.Text = nv.Value;
 }
예제 #32
0
 public void CopyToClipboard(string str)
 {
     var dp = new Windows.ApplicationModel.DataTransfer.DataPackage();
     dp.SetText(str);
     Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dp);
 }
예제 #33
0
		private void RenderPage_KeyDown(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.KeyEventArgs args)
        {
            if(args.VirtualKey == Windows.System.VirtualKey.Control)
            {
                ctrlDown = true;
            }
            else if(args.VirtualKey == Windows.System.VirtualKey.C && ctrlDown == true)
            {
                Windows.ApplicationModel.DataTransfer.DataPackage dp = new Windows.ApplicationModel.DataTransfer.DataPackage();
                dp.RequestedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
                string selectText = getSelectText();
                dp.SetText(selectText);
                Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dp);
            }
        }
예제 #34
0
        void DoHolding(object sender)
        {
            if (((sender as StackPanel).DataContext as MyRenderItem).Word != -1)
            {
                Flyout ContextFlyout = new Flyout();
                StackPanel Panel = new StackPanel();
                //Panel.SetValue(NameProperty, "TopLevel");
                //Panel.Name = "TopLevel";
                Panel.DataContext = this;
                ContextFlyout.Content = Panel;
                Panel.Children.Add(new ItemsControl() { ItemsPanel = Resources["VirtualPanelTemplate"] as ItemsPanelTemplate, ItemTemplate = Resources["WrapTemplate"] as DataTemplate, ItemsSource = VirtualizingWrapPanelAdapter.GroupRenderModels(System.Linq.Enumerable.Select(AppSettings.ChData.GetMorphologicalDataForWord(((sender as StackPanel).DataContext as MyRenderItem).Chapter, ((sender as StackPanel).DataContext as MyRenderItem).Verse, ((sender as StackPanel).DataContext as MyRenderItem).Word).Items, (Arr) => new MyRenderItem((XMLRender.RenderArray.RenderItem)Arr)).ToList(), UIChanger.MaxWidth) });
                VirtualizingStackPanel.SetVirtualizationMode((Panel.Children.Last() as ItemsControl), VirtualizationMode.Recycling);
                Panel.Children.Add(new Button() { Content = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("CopyToClipboard/Text") });
                (Panel.Children.Last() as Button).Click += (object _sender, RoutedEventArgs _e) =>
                {
#if WINDOWS_APP || WINDOWS_UWP
                    Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage(); package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(package);
#else
                    global::Windows.System.LauncherOptions options = new global::Windows.System.LauncherOptions(); 
                    options.PreferredApplicationDisplayName = "Clipboarder"; 
                    options.PreferredApplicationPackageFamilyName = "InTheHandLtd.Clipboarder"; 
                    options.DisplayApplicationPicker = false; 
                    global::Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("clipboard:Set?Text={0}", Uri.EscapeDataString(string.Empty))), options); 
#endif
                };
                Panel.Children.Add(new Button() { Content = new TextBlock() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Share/Text") } });
                (Panel.Children.Last() as Button).Click += (object _sender, RoutedEventArgs _e) =>
                {
//#if WINDOWS_APP
                Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage();
                    package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText);
                    Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested += (Windows.ApplicationModel.DataTransfer.DataTransferManager __sender, Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs __e) =>
                    {
                        __e.Request.Data.Properties.Title = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("DisplayName");
                        __e.Request.Data.Properties.Description = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Description");
                        __e.Request.Data.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText);
                        Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested -= null;
                    };
                    Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI();
                //#else
                //            Microsoft.Phone.Tasks.ShareStatusTask shareStatusTask = new Microsoft.Phone.Tasks.ShareStatusTask(); 
                //            shareStatusTask.Status = string.Empty;
                //            shareStatusTask.Show(); 
                //#endif
                };
                FlyoutBase.SetAttachedFlyout(sender as StackPanel, ContextFlyout);
                FlyoutBase.ShowAttachedFlyout(sender as StackPanel);
            }
            else if (((sender as StackPanel).DataContext as MyRenderItem).Chapter != -1)
            {
                MenuFlyout ContextFlyout = new MenuFlyout();
                int idxMark = Array.FindIndex(AppSettings.Bookmarks, (Item) => Item[0] == Division && Item[1] == Selection && Item[2] == ((sender as StackPanel).DataContext as MyRenderItem).Chapter && Item[3] == ((sender as StackPanel).DataContext as MyRenderItem).Verse);
                ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString((idxMark == -1 ? "AddBookmark" : "RemoveBookmark") + "/Text") });
                (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) =>
                {
                    List<int[]> marks = AppSettings.Bookmarks.ToList();
                    if (idxMark != -1) {
                        marks.RemoveAt(idxMark);
                    } else {
                        marks.Add(new int[] { Division, Selection, ((sender as StackPanel).DataContext as MyRenderItem).Chapter, ((sender as StackPanel).DataContext as MyRenderItem).Verse });
                    }
                    AppSettings.Bookmarks = marks.ToArray();
                };
                ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("CopyToClipboard/Text") });
                (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) =>
                {
#if WINDOWS_APP || WINDOWS_UWP
                    Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage(); package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(package);
#else
                    global::Windows.System.LauncherOptions options = new global::Windows.System.LauncherOptions(); 
                    options.PreferredApplicationDisplayName = "Clipboarder"; 
                    options.PreferredApplicationPackageFamilyName = "InTheHandLtd.Clipboarder"; 
                    options.DisplayApplicationPicker = false; 
                    global::Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("clipboard:Set?Text={0}", Uri.EscapeDataString(string.Empty))), options); 
#endif
                };
                ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Share/Text") });
                (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) =>
                {
//#if WINDOWS_APP
                    Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage();
                    package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText);
                    Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested += (Windows.ApplicationModel.DataTransfer.DataTransferManager __sender, Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs __e) =>
                    {
                        __e.Request.Data.Properties.Title = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("DisplayName");
                        __e.Request.Data.Properties.Description = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Description");
                        __e.Request.Data.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText);
                        Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested -= null;
                    };
                    Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI();
//#else
//            Microsoft.Phone.Tasks.ShareStatusTask shareStatusTask = new Microsoft.Phone.Tasks.ShareStatusTask(); 
//            shareStatusTask.Status = string.Empty;
//            shareStatusTask.Show(); 
//#endif
                };
                ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("SetPlaybackVerse/Text") });
                (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) =>
                {
                    ViewModel.CurrentVerse = (sender as StackPanel).DataContext as MyRenderItem;
                    for (int count = 0; count <= ViewModel.VerseReferences.Count() - 1; count++)
                    {
                        if (ViewModel.VerseReferences[count] == ViewModel.CurrentVerse) { CurrentPlayingItem = count; break; }
                        VersePlayer.Source = null;
                    }
                };
                //ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("ShowExegesis/Text") });
                //(ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) => { };
                FlyoutBase.SetAttachedFlyout(sender as StackPanel, ContextFlyout);
                FlyoutBase.ShowAttachedFlyout(sender as StackPanel);
            }
        }
예제 #35
0
        public static void Source(this Windows.ApplicationModel.DataTransfer.DataPackage dataPackage, IMimeItemCollection mimeItemCollection)
        {
            dataPackage.RequestedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;

            var properties = dataPackage.Properties;

            if (mimeItemCollection.Description != null)
            {
                properties.Description = mimeItemCollection.Description ?? Forms9Patch.ApplicationInfoService.Name;
            }
            properties.ApplicationName = Forms9Patch.ApplicationInfoService.Name;

            properties.Title = mimeItemCollection.Description ?? "Share " + Forms9Patch.ApplicationInfoService.Name + " data ...";


            var storageItems = new List <IStorageItem>();

            var textSet = false;
            var htmlSet = false;
            var rtfSet  = false;
            var uriSet  = false;

            //var htmlItems = mimeItemCollection.GetMimeItems<string>("text/html");


            foreach (var item in mimeItemCollection.Items)
            {
                var mimeType = item.MimeType.ToLower();
                if (mimeType == "text/plain" && !textSet && item.AsString() is string text)
                {
                    dataPackage.SetText(text);
                    textSet = true;
                }
                // else if (mimeType == "text/html" && !htmlSet && item.AsString() is string html)
                else if (mimeType == "text/html" && !htmlSet && item.AsWindowsHtmlFragment() is string html)
                {
                    dataPackage.SetHtmlFormat(html);
                    htmlSet = true;
                }
                else if ((mimeType == "text/rtf" ||
                          mimeType == "text/richtext" ||
                          mimeType == "application/rtf" ||
                          mimeType == "application/x-rtf") &&
                         !rtfSet && item.AsString() is string rtf)
                {
                    dataPackage.SetRtf(rtf);
                    rtfSet = true;
                }
                else if (item.Value is Uri uri && !uriSet && uri.Scheme.StartsWith("http", StringComparison.OrdinalIgnoreCase))
                {
                    dataPackage.SetWebLink(uri);
                    uriSet = true;
                }

                if (item.ToStorageFile() is StorageFile storageFile)
                {
                    storageItems.Add(storageFile);
                }
                else
                {
                    properties.Add(GetFormatId(item.MimeType), item.Value);
                }
            }

            if (storageItems.Count > 0)
            {
                dataPackage.SetStorageItems(storageItems);
            }
        }
예제 #36
0
        private async void CopyRedirectUriToClipboard_Click(object sender, RoutedEventArgs e)
        {
            var redirectURI = AuthenticationHelper.GetAppRedirectURI();

            var dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();
            dataPackage.SetText(redirectURI);
            Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
            Windows.ApplicationModel.DataTransfer.Clipboard.Flush();

            var dialog = new Windows.UI.Popups.MessageDialog(redirectURI, "App Redirect URI copied to clipboard");
            await dialog.ShowAsync();

        }