-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoreLauncher.cs
More file actions
123 lines (119 loc) · 3.43 KB
/
Copy pathStoreLauncher.cs
File metadata and controls
123 lines (119 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel;
namespace UniversalPlatformTools
{
/// <summary>
/// Provides methods to launch the Store App with custom parameters.
/// </summary>
public static class StoreLauncher
{
#region Const
private const string STOREURI_PDP_FORMAT = "ms-windows-store:PDP?PFN={0}";
private const string STOREURI_REVIEW_FORMAT = "ms-windows-store:REVIEW?PFN={0}";
#endregion
//APPS PAGES
/// <summary>
/// Launches the current App page using the specified launch type.
/// </summary>
public static async void LaunchAppPage(AppPageLaunchType launchType)
{
await LaunchAppPageAsync(string.Empty, launchType);
}
/// <summary>
/// Launches the specified App page using the specified launch type.
/// </summary>
public static async void LaunchAppPage(string packageFamilyName, AppPageLaunchType launchType)
{
await LaunchAppPageAsync(packageFamilyName, launchType);
}
//Private
private static async Task LaunchAppPageAsync(string packageFamilyName, AppPageLaunchType launchType)
{
if (string.IsNullOrWhiteSpace(packageFamilyName))
{
packageFamilyName = Package.Current.Id.FamilyName;
}
string format = launchType == AppPageLaunchType.ProductDetailsPage ? STOREURI_PDP_FORMAT : STOREURI_REVIEW_FORMAT;
string storeURI = string.Format(format, packageFamilyName);
await LaunchUriAsync(storeURI);
}
private static async Task LaunchUriAsync(string uri)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri(uri));
}
}
/// <summary>
///
/// </summary>
public enum StorePage
{
/// <summary>
/// The Home page
/// </summary>
Home = 0,
/// <summary>
/// The Apps page
/// </summary>
Apps = 2,
/// <summary>
/// The Games page
/// </summary>
Games = 4,
/// <summary>
/// The Music page
/// </summary>
Music = 8,
/// <summary>
/// The Video page
/// </summary>
Video = 16,
/// <summary>
/// The user's Download and Updates page
/// </summary>
DownloadsAndUpdates = 32,
/// <summary>
/// The Store Settings page
/// </summary>
Settings = 64
}
/// <summary>
/// The product types in the Windows Store
/// </summary>
public enum StoreProductType
{
/// <summary>
/// Apps
/// </summary>
Apps = 2,
/// <summary>
/// Games
/// </summary>
Games = 4,
/// <summary>
/// Music
/// </summary>
Music = 8,
/// <summary>
/// Videos
/// </summary>
Video = 16,
}
/// <summary>
///
/// </summary>
public enum AppPageLaunchType
{
/// <summary>
/// Specifies the launcher to open the product details page (PDP) for a product
/// </summary>
ProductDetailsPage,
/// <summary>
/// Specifies the launcher to open the write a review experience for a product.
/// </summary>
WriteAReview,
}
}