Exemplo n.º 1
0
        internal static async Task <bool> CanPinToStart()
        {
            AppListEntry entry       = (await Package.Current.GetAppListEntriesAsync())[0];
            bool         isSupported = StartScreenManager.GetDefault().SupportsAppListEntry(entry);

            return(isSupported);
        }
Exemplo n.º 2
0
        private async void FirstStartAppSuggestingAddLiveTile()
        {
            //ApplicationData.Current.LocalSettings.Values.Remove("IsNotFirstStart"); // remove after testing
            if (!ApplicationData.Current.LocalSettings.Values.ContainsKey("IsNotFirstStart"))
            {
                if (ApiInformation.IsTypePresent("Windows.UI.StartScreen.StartScreenManager"))
                {
                    AppListEntry entry = (await Package.Current.GetAppListEntriesAsync())[0];
                    bool         isSupportedStartScreen = StartScreenManager.GetDefault().SupportsAppListEntry(entry);

                    if (isSupportedStartScreen)
                    {
                        // Check if your app is currently pinned
                        bool isPinned = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(entry);

                        if (!isPinned)
                        {
                            // And pin it to Start
                            await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(entry);
                        }
                    }
                }
                ApplicationData.Current.LocalSettings.Values["IsNotFirstStart"] = true;
                //ApplicationData.Current.LocalSettings.Values.Remove("IsNotFirstStart"); // remove after testing
            }
        }
Exemplo n.º 3
0
        public static async Task <PinResult> PinSpecificAppToStartMenuAsync(AppListEntry entry)
        {
            var resultPinResult = PinResult.UnsupportedOs;

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

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

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

            return(resultPinResult);
        }
        /// <summary>
        ///     Pin the app to the start screen
        /// </summary>
        /// <param name="parameter">the parameter is not used.</param>
        public async void Execute(object parameter)
        {
            if (ApiInformation.IsTypePresent("Windows.UI.StartScreen.StartScreenManager"))
            {
                var entries = await Package.Current.GetAppListEntriesAsync();

                var firstEntry = entries.FirstOrDefault();
                if (firstEntry == null)
                {
                    return;
                }
                var startScreenmanager = StartScreenManager.GetDefault();
                var containsEntry      = await startScreenmanager.ContainsAppListEntryAsync(firstEntry);

                if (containsEntry)
                {
                    return;
                }
                if (await startScreenmanager.RequestAddAppListEntryAsync(firstEntry))
                {
                    _canExecute = false;
                    CanExecuteChanged?.Invoke(this, new EventArgs());
                }
            }
        }
Exemplo n.º 5
0
        internal static async Task <bool> IsPinnedToStart()
        {
            AppListEntry entry    = (await Package.Current.GetAppListEntriesAsync())[0];
            bool         isPinned = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(entry);

            return(isPinned);
        }
Exemplo n.º 6
0
        private async void LivePin(object sender, RoutedEventArgs e)
        {
            // Get your own app list entry
            // (which is always the first app list entry assuming you are not a multi-app package)
            AppListEntry entry = (await Package.Current.GetAppListEntriesAsync())[0];

            // Check if Start supports your app
            bool isSupported = StartScreenManager.GetDefault().SupportsAppListEntry(entry);

            if (isSupported)
            {
                if (ApiInformation.IsTypePresent("Windows.UI.StartScreen.StartScreenManager"))
                {
                    // Primary tile API's supported!
                    bool isPinned = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(entry);

                    if (isPinned)
                    {
                        await new MessageDialog("If not you can manually put the live tile on to the StartScreen", "You already have the live tile in your StartScreen").ShowAsync();
                    }
                    else
                    {
                        bool IsPinned = await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(entry);
                    }
                }
                else
                {
                    await new MessageDialog("You need to update your device to enable automatic pinning", "Update your device").ShowAsync();
                }
            }
            else
            {
                var t = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;
                switch (t)
                {
                case "Windows.IoT":
                    await new MessageDialog("It seems you are using a IoT device which doesn't support Primary tile API", "live tile failed").ShowAsync();
                    break;

                case "Windows.Team":
                    break;

                case "Windows.Holographic":
                    await new MessageDialog("It seems you are using hololens. Hololens doesn't support live tile", "live tile failed").ShowAsync();
                    break;

                case "Windows.Xbox":
                    await new MessageDialog("It seems you are using a xbox. Xbox doesn't support live tile", "live tile failed").ShowAsync();
                    break;

                default:
                    await new MessageDialog("It seems you are using a " + t + " device. This device does not support Primary tile API", "live tile failed").ShowAsync();
                    break;
                }
            }
        }
Exemplo n.º 7
0
        private async void ShowLiveTileTipIfNeeded()
        {
            try
            {
                // You should  check if you've already shown this tip before,
                // and if so, don't show the tip to the user again.
                if (ApplicationData.Current.LocalSettings.Values.Any(i => i.Key.Equals("ShownLiveTileTip")))
                {
                    // But for purposes of this Quickstart, we'll always show the tip
                    //return;
                }

                // Store that you've shown this tip, so you don't show it again
                ApplicationData.Current.LocalSettings.Values["ShownLiveTileTip"] = true;

                // If Start screen manager API's aren't present
                if (!ApiInformation.IsTypePresent("Windows.UI.StartScreen.StartScreenManager"))
                {
                    ShowMessage("StartScreenManager API isn't present on this build.");
                    return;
                }

                // Get your own app list entry (which is the first entry assuming you have a single-app package)
                var appListEntry = (await Package.Current.GetAppListEntriesAsync())[0];

                // Get the Start screen manager
                var startScreenManager = StartScreenManager.GetDefault();

                // Check if Start supports pinning your app
                bool supportsPin = startScreenManager.SupportsAppListEntry(appListEntry);

                // If Start doesn't support pinning, don't show the tip
                if (!supportsPin)
                {
                    ShowMessage("Start doesn't support pinning.");
                    return;
                }

                // Check if you're pinned
                bool isPinned = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(appListEntry);

                // If the tile is already pinned, don't show the tip
                if (isPinned)
                {
                    ShowMessage("The tile is already pinned to Start!");
                    return;
                }

                // Otherwise, show the tip
                FlyoutPinTileTip.ShowAt(ButtonShowTip);
            }
            catch (Exception ex)
            {
                ShowMessage(ex.ToString());
            }
        }
Exemplo n.º 8
0
        private async void LivePin(object sender, RoutedEventArgs e)
        {
            // Get your own app list entry
            // (which is always the first app list entry assuming you are not a multi-app package)
            AppListEntry entry = (await Package.Current.GetAppListEntriesAsync())[0];

            // Check if Start supports your app
            bool isSupported = StartScreenManager.GetDefault().SupportsAppListEntry(entry);

            if (isSupported)
            {
                if (ApiInformation.IsTypePresent("Windows.UI.StartScreen.StartScreenManager"))
                {
                    // Primary tile API's supported!
                    bool isPinned = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(entry);

                    if (isPinned)
                    {
                        await new MessageDialog("AlreadyTileDesc".GetLocalized(), "AlreadyTile".GetLocalized()).ShowAsync();
                    }
                    else
                    {
                        bool IsPinned = await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(entry);
                    }
                }
                else
                {
                    await new MessageDialog("UpdateToTile".GetLocalized(), "UpdateDevice".GetLocalized()).ShowAsync();
                }
            }
            else
            {
                var t = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;
                switch (t)
                {
                case "Windows.IoT":
                    await new MessageDialog("IoTTileFail".GetLocalized(), "LiveTileFailed".GetLocalized()).ShowAsync();
                    break;

                case "Windows.Team":
                    break;

                case "Windows.Holographic":
                    await new MessageDialog("HololensTileFail".GetLocalized(), "LiveTileFailed".GetLocalized()).ShowAsync();
                    break;

                case "Windows.Xbox":
                    await new MessageDialog("XboxTileFail".GetLocalized(), "LiveTileFailed".GetLocalized()).ShowAsync();
                    break;

                default:
                    await new MessageDialog(string.Format("OtherTileFail".GetLocalized(), t), "LiveTileFailed".GetLocalized()).ShowAsync();
                    break;
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// TODO: 2. Pin to Start
        /// </summary>
        private async void PinToStart_Click(object sender, RoutedEventArgs e)
        {
            // Find the app in the current package
            var appListEntry = (await Package.Current.GetAppListEntriesAsync()).FirstOrDefault();

            if (appListEntry != null)
            {
                await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(appListEntry);
            }
        }
Exemplo n.º 10
0
 public static async Task <bool?> RequestPinToStartMenu()
 {
     if (IsPinToStartMenuEnabled)
     {
         AppListEntry entry = (await Package.Current.GetAppListEntriesAsync())[0];
         return(await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(entry));
     }
     else
     {
         return(null);
     }
 }
 public async Task<bool> PinAsync()
 {
     bool isPinned = false;
     AppListEntry entry = (await Package.Current.GetAppListEntriesAsync()).FirstOrDefault();
     if (entry != null)
     {
         isPinned = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(entry);
     }
     if (!isPinned)
     {
         isPinned = await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(entry);
     }
     return isPinned;
 }
Exemplo n.º 12
0
        public static async Task <bool> TryAddPrimaryTile()
        {
            if (!IsUwp() && !PrimaryTileSupport)
            {
                return(false);
            }

            ListEntry = (await Package.Current.GetAppListEntriesAsync())[0];

            if (!StartScreenManager.GetDefault().SupportsAppListEntry(ListEntry))
            {
                return(false);
            }

            return(await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(ListEntry));
        }
Exemplo n.º 13
0
        public static async Task SendTileNotificationAsync(string appName, string subject, string body)
        {
            // Construct the tile content
            TileContent content = GenerateTileContent(appName, subject, body);

            AppListEntry entry   = (await Package.Current.GetAppListEntriesAsync())[0];
            bool         isPined = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(entry);

            if (!isPined)
            {
                await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(entry);
            }

            TileNotification notification = new TileNotification(content.GetXml());

            TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
        }
Exemplo n.º 14
0
        private async void ShowLiveTileTipIfNeeded()
        {
            try
            {
                //检查以前是否已经展示过这个技巧,
                //如果是这样,不要再向用户显示提示
                if (ApplicationData.Current.LocalSettings.Values.Any(i => i.Key.Equals("ShownLiveTileTile")))
                {
                    //始终展示
                }
                ApplicationData.Current.LocalSettings.Values["ShownLiveTileTip"] = true;
                //如果启动屏幕管理器API不存在
                if (!ApiInformation.IsTypePresent("Windows.UI.StartScreen.StartScreenManager"))
                {
                    ShowMessage("StartScreenManager API isn't present on this build.");
                    return;
                }
                //获取应用程序列表条目
                var appListEntry = (await Package.Current.GetAppListEntriesAsync())[0];
                //获取开始屏幕管理器
                var startScreenManager = StartScreenManager.GetDefault();
                //检查Start是否支持固定应用程序
                bool supportsPin = startScreenManager.SupportsAppListEntry(appListEntry);
                if (!supportsPin)
                {
                    ShowMessage("Start doesn't support pinning.");
                    return;
                }
                //固定
                bool isPinned = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(appListEntry);

                //如果已经固定上
                if (isPinned)
                {
                    ShowMessage("The tile is already pinned to Start!");
                    return;
                }

                // Otherwise, show the tip
                FlyoutPinTileTip.ShowAt(ButtonShowTip);
            }
            catch (Exception ex)
            {
                ShowMessage(ex.ToString());
            }
        }
        //pin primary tile to Start if system can do it or primary tile existing
        private async void PinFirstTile()
        {
            // Get your own app list entry
            AppListEntry entry = (await Package.Current.GetAppListEntriesAsync())[0];
            // Check if Start supports your app
            bool isSupported = StartScreenManager.GetDefault().SupportsAppListEntry(entry);
            // Check if your app is currently pinned
            bool isPinned = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(entry);

            if (isPinned)
            {
                await GoToLanding();
            }

            // If tile isn't pinned and app can do it - send request to user
            if (isSupported)
            {
                // And pin it to Start
                var tileState = await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(entry);

                if (tileState)
                {
                    DisplayResult.Text = "Плитка успешно закреплена в меню Пуск";
                    await Task.Delay(1900);

                    Application.Current.Exit();
                }
                //возможно этот блок можна убрать:
                else
                {
                    DisplayResult.Text = "Пожалуйста, закрепите плитку в меню Пуск";
                    await Task.Delay(2300);
                    await GoToLanding();
                }
            }
            // Send mesage if app can't pin tile to Start (and maybe if user has rejected request)
            else
            {
                //will have to testing:
                DisplayResult.Text = "Пожалуйста, закрепите плитку в меню Пуск";
                await GoToLanding();
            }
        }
        private async void Current_Activated(object sender, WindowActivatedEventArgs e)
        {
            var entries = await Package.Current.GetAppListEntriesAsync();

            var firstEntry = entries.FirstOrDefault();

            if (firstEntry == null)
            {
                _canExecute = false;
                return;
            }
            if (ApiInformation.IsTypePresent("Windows.UI.StartScreen.StartScreenManager"))
            {
                var startScreenmanager = StartScreenManager.GetDefault();
                _canExecute = !await startScreenmanager.ContainsAppListEntryAsync(firstEntry);

                CanExecuteChanged?.Invoke(this, new EventArgs());
            }
        }
Exemplo n.º 17
0
        public async void Pin()
        {
            if (ApiInformation.IsTypePresent("Windows.UI.StartScreen.StartScreenManager"))
            {
                StartupTask startupTask = await StartupTask.GetAsync("AhnacSolutions");

                StartupTaskState state = await startupTask.RequestEnableAsync();

                var entry = (await Package.Current.GetAppListEntriesAsync())[0];

                var startScreenManager = StartScreenManager.GetDefault();

                bool supportsPin = startScreenManager.SupportsAppListEntry(entry);

                if (supportsPin)
                {
                    var  appListEntry = (await Package.Current.GetAppListEntriesAsync())[0];
                    bool didPin       = await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(appListEntry);
                }
            }
        }
Exemplo n.º 18
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();

            var entry = (await Package.Current.GetAppListEntriesAsync())[0];

            var isSupported = StartScreenManager.GetDefault().SupportsAppListEntry(entry);
            var isPinned    = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(entry);

            if (isSupported && isPinned)
            {
                var trending = await GetTrendingList();

                if (trending.Count == 5)
                {
                    UpdateTile(trending);
                }
            }

            deferral.Complete();
        }
Exemplo n.º 19
0
        private async void PinButton_Click(object sender, RoutedEventArgs e)
        {
            // Get your own app list entry
            AppListEntry entry     = (await Package.Current.GetAppListEntriesAsync())[0];
            bool         isPinned1 = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(entry);

            // And pin it to Start
            bool isPinned = await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(entry);

            if (isPinned1 == true)
            {
                PopupNotice popupNotice = new PopupNotice("应用已固定在开始菜单");
                popupNotice.ShowAPopup();
            }
            else
            {
                if (isPinned == true)
                {
                    PopupNotice popupNotice = new PopupNotice("固定成功");
                    popupNotice.ShowAPopup();
                }
            }
        }
Exemplo n.º 20
0
        private async void ButtonPinTile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //获取自己的应用程序列表条目
                var appListEntry = (await Package.Current.GetAppListEntriesAsync())[0];

                // And pin your app
                bool didPin = await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(appListEntry);

                if (didPin)
                {
                    ShowMessage("Success! Tile was pinned!");
                }
                else
                {
                    ShowMessage("Tile was NOT pinned, did you click no on the dialog?");
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex.ToString());
            }
        }
Exemplo n.º 21
0
        private static async Task <bool> IsPinToStartMenuSupported()
        {
            AppListEntry entry = (await Package.Current.GetAppListEntriesAsync())[0];

            return(StartScreenManager.GetDefault().SupportsAppListEntry(entry));
        }
Exemplo n.º 22
0
        private async Task PinApplicationToTaskBarAsync()
        {
            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("IsPinToTaskBar"))
            {
                if (!ApplicationData.Current.RoamingSettings.Values.ContainsKey("IsRated"))
                {
                    await RequestRateApplication().ConfigureAwait(false);
                }
            }
            else
            {
                ApplicationData.Current.LocalSettings.Values["IsPinToTaskBar"] = true;

                TaskbarManager     BarManager    = TaskbarManager.GetDefault();
                StartScreenManager ScreenManager = StartScreenManager.GetDefault();

                bool PinStartScreen = false, PinTaskBar = false;

                AppListEntry Entry = (await Package.Current.GetAppListEntriesAsync())[0];
                if (ScreenManager.SupportsAppListEntry(Entry) && !await ScreenManager.ContainsAppListEntryAsync(Entry))
                {
                    PinStartScreen = true;
                }
                if (BarManager.IsPinningAllowed && !await BarManager.IsCurrentAppPinnedAsync())
                {
                    PinTaskBar = true;
                }

                if (PinStartScreen && PinTaskBar)
                {
                    PinTip.ActionButtonClick += async(s, e) =>
                    {
                        s.IsOpen = false;
                        _        = await BarManager.RequestPinCurrentAppAsync();

                        _ = await ScreenManager.RequestAddAppListEntryAsync(Entry);
                    };
                }
                else if (PinStartScreen && !PinTaskBar)
                {
                    PinTip.ActionButtonClick += async(s, e) =>
                    {
                        s.IsOpen = false;
                        _        = await ScreenManager.RequestAddAppListEntryAsync(Entry);
                    };
                }
                else if (!PinStartScreen && PinTaskBar)
                {
                    PinTip.ActionButtonClick += async(s, e) =>
                    {
                        s.IsOpen = false;
                        _        = await BarManager.RequestPinCurrentAppAsync();
                    };
                }
                else
                {
                    PinTip.ActionButtonClick += (s, e) =>
                    {
                        s.IsOpen = false;
                    };
                }

                PinTip.Closed += async(s, e) =>
                {
                    s.IsOpen = false;
                    await RequestRateApplication().ConfigureAwait(true);
                };

                PinTip.Subtitle = Globalization.GetString("TeachingTip_PinToMenu_Subtitle");
                PinTip.IsOpen   = true;
            }
        }
Exemplo n.º 23
0
        public static async Task <bool> IsPinned()
        {
            var entry = (await Package.Current.GetAppListEntriesAsync())[0];

            return(await StartScreenManager.GetDefault().ContainsAppListEntryAsync(entry));
        }
Exemplo n.º 24
0
 public async Task <bool> UnpinFromStartAsync(string path)
 {
     return(await StartScreenManager.GetDefault().TryRemoveSecondaryTileAsync(GetTileID(path)));
 }
Exemplo n.º 25
0
 internal static async Task PinToStart()
 {
     AppListEntry entry    = (await Package.Current.GetAppListEntriesAsync())[0];
     bool         isPinned = await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(entry);
 }