예제 #1
0
        public static async Task <PinResult> PinUserSpecificAppToStartMenuAsync(User user, AppListEntry entry)
        {
            var resultPinResult = PinResult.UnsupportedOs;

            if (!ApiInformation.IsTypePresent("Windows.UI.StartScreen.StartScreenManager"))
            {
                return(resultPinResult);
            }

            if (StartScreenManager.GetForUser(user).SupportsAppListEntry(entry))
            {
                if (await StartScreenManager.GetForUser(user).ContainsAppListEntryAsync(entry))
                {
                    resultPinResult = PinResult.PinAlreadyPresent;
                }
                else
                {
                    var result = await StartScreenManager.GetForUser(user).RequestAddAppListEntryAsync(entry);

                    resultPinResult = result ? PinResult.PinPresent : PinResult.PinOperationFailed;
                }
            }
            else
            {
                resultPinResult = PinResult.UnsupportedDevice;
            }

            return(resultPinResult);
        }