Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
完成分享功能
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiichiamane committed Apr 25, 2019
1 parent a21009b commit b751dff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PixivFSUWP/IllustDetailPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</Button>
<Button x:Name="btnShare" Style="{StaticResource ButtonRevealStyle}"
Margin="5,0,0,0" Background="#99F3F3F3" BorderThickness="1.5" Height="70"
Width="70">
Width="70" Click="BtnShare_Click">
<StackPanel Margin="5">
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}"
FontSize="20" Glyph="&#xE72D;"/>
Expand Down
18 changes: 18 additions & 0 deletions PixivFSUWP/IllustDetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.ApplicationModel.DataTransfer;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
Expand Down Expand Up @@ -36,6 +37,18 @@ public sealed partial class IllustDetailPage : Page
public IllustDetailPage()
{
this.InitializeComponent();
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += DataTransferManager_DataRequested;
}

private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
var request = args.Request;
request.Data.SetText(string.Format("Pixiv作品\n{0} by {1}\n" +
"网页链接:https://www.pixiv.net/member_illust.php?mode=medium&illust_id=" + "{2}\n" +
"PixivFSUWP:pixiv:illust:{2}", illust.Title, illust.Author, illustID));
request.Data.Properties.Title = String.Format("分享:{0} by {1}", illust.Title, illust.Author);
request.Data.Properties.Description = "该图片页面的链接将被分享";
}

protected override void OnNavigatedTo(NavigationEventArgs e)
Expand Down Expand Up @@ -231,5 +244,10 @@ private async void BtnFollow_Click(object sender, RoutedEventArgs e)
btnSender.IsEnabled = true;
}
}

private void BtnShare_Click(object sender, RoutedEventArgs e)
{
DataTransferManager.ShowShareUI();
}
}
}

0 comments on commit b751dff

Please sign in to comment.