Exemple #1
0
        private async void Pin(string imageUriString, string ID, string showname)
        {
            Uri logo = new Uri(imageUriString); // 方块图块的 Logo

            // 创建一个 SecondaryTile 对象
            SecondaryTile secondaryTile = new SecondaryTile();

            secondaryTile.TileId      = ID;
            secondaryTile.Arguments   = ID;
            secondaryTile.DisplayName = showname;
            secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
            secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;
            secondaryTile.VisualElements.BackgroundColor             = Color.FromArgb(0, 0, 0, 0);
            secondaryTile.VisualElements.ForegroundText     = ForegroundText.Light;
            secondaryTile.VisualElements.Square150x150Logo  = logo;
            secondaryTile.LockScreenDisplayBadgeAndTileText = true;


            // 请求固定此 SecondaryTile,并指定确认框的显示位置
            bool isPinned = await secondaryTile.RequestCreateAsync();
        }
Exemple #2
0
        private async void Remove_Click(object sender, RoutedEventArgs e)
        {
            Settings.RemoveAccount(app.Accounts, app.Account);
            Settings.SetAccounts(app.Accounts);
            app.HaveAccountsChanged = false;

            string tileId = app.Account.Id;

            app.Account = null;
            var tile = (await SecondaryTile.FindAllAsync()).FirstOrDefault(t => t.TileId == tileId);

            if (tile != null)
            {
                await tile.RequestDeleteAsync();
            }

            if (app.Accounts.Count == 0)
            {
                Frame.Navigate(typeof(AddAccountPage));
            }
        }
        public void UpdateSecondaryTile(string tileID, string backtitle, string backcontent)
        {
            if (string.IsNullOrEmpty(tileID) || string.IsNullOrEmpty(backcontent))
            {
                return;
            }
            if (!SecondaryTile.Exists(tileID))
            {
                return;
            }
            var tileContent = TileContentFactory.CreateTileSquare150x150PeekImageAndText02();

            tileContent.TextHeading.Text  = backtitle;
            tileContent.TextBodyWrap.Text = backcontent;
            tileContent.Image.Src         = "ms-appx:///Assets/Tile150x150.png";
            var         tileNotification = tileContent.CreateNotification();
            TileUpdater updater          = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileID);

            updater.EnableNotificationQueue(false);
            updater.Update(tileNotification);
        }
Exemple #4
0
        public async Task <int> updateLiveTile()
        {
            // create the instance of Tile Updater, which enables you to change the appearance of the calling app's tile
            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            // enables the tile to queue up to five notifications
            updater.EnableNotificationQueue(true);
            updater.Clear();
            ISquare310x310TileNotificationContent largeContent;
            LiveTileSty lts;

            if ((bool)localSettings.Values["TileClearSty"])
            {
                lts = new LiveTileSty(clearLiveTiles);
            }
            else
            {
                lts = new LiveTileSty(detailedLiveTiles);
            }
            largeContent = await lts(subscrSiteList[0]);

            // Create a new tile notification.
            updater.Update(new TileNotification(largeContent.GetXml()));

            foreach (var siteName in subscrSiteList.GetRange(1, subscrSiteList.Count - 1))
            {
                if (!SecondaryTile.Exists(siteName))
                {
                    continue;
                }
                var updater2 = TileUpdateManager.CreateTileUpdaterForSecondaryTile(siteName);
                updater2.EnableNotificationQueue(true);
                updater2.Clear();
                largeContent = await lts(siteName);

                updater2.Update(new TileNotification(largeContent.GetXml()));
            }

            return(0);
        }
Exemple #5
0
        public static async Task PinPageToStart(string pageUrl, string title)
        {
            // TODO: Download and use album/artist/playlist image for tile, if applicable

            string tileId = Guid.NewGuid().ToString();

            string arguments = "pageUrl=" + WebUtility.UrlEncode(pageUrl);

            SecondaryTile tile = new SecondaryTile(
                tileId,
                title,
                arguments,
                new Uri("ms-appx:///Assets/Logo/Square150x150Logo.png"),
                TileSize.Default);

            // Enable wide and large tile sizes
            tile.VisualElements.Wide310x150Logo   = new Uri("ms-appx:///Assets/Logo/Wide310x150Logo.png");
            tile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/Logo/LargeTile.png");

            var images = await GetTileImages(pageUrl);

            if (images != null)
            {
                tile.VisualElements.Square150x150Logo = images.SquareImage;
                tile.VisualElements.Wide310x150Logo   = images.WideImage;
                tile.VisualElements.Square310x310Logo = images.SquareImage;
            }

            // Show the display name on all sizes
            tile.VisualElements.ShowNameOnSquare150x150Logo = true;
            tile.VisualElements.ShowNameOnWide310x150Logo   = true;
            tile.VisualElements.ShowNameOnSquare310x310Logo = true;

            var result = await tile.RequestCreateAsync();

            if (!result)
            {
                logger.Info("Tile creation failed");
            }
        }
Exemple #6
0
        public static async Task <bool> CreateOrReplaceSecondaryTile(VLCItemType type, int id, string title)
        {
            string tileId = "SecondaryTile-" + type.ToString() + "-" + id;

            if (!SecondaryTile.Exists(tileId))
            {
                var tileData = new SecondaryTile()
                {
                    TileId      = tileId,
                    DisplayName = title,
                    Arguments   = tileId
                };
                string subfolder = null;
                switch (type)
                {
                case VLCItemType.Album:
                    subfolder = "albumPic";
                    break;

                case VLCItemType.Artist:
                    subfolder = "artistPic";
                    break;
                }
                tileData.VisualElements.ShowNameOnSquare150x150Logo = true;
                tileData.DisplayName = title;
                tileData.VisualElements.Square150x150Logo =
                    new Uri("ms-appdata:///local/" + subfolder + "/" + id + ".jpg");
                bool success = await tileData.RequestCreateAsync();

                return(success);
            }
            else
            {
                SecondaryTile secondaryTile = new SecondaryTile(tileId);
                await secondaryTile.RequestDeleteForSelectionAsync(Window.Current.Bounds, Placement.Default);

                ToastHelper.Basic(Strings.TileRemoved);
                return(false);
            }
        }
        public static async Task UpdateTile(Route route, StopGroup stop, Grid containerGrid = null, SecondaryTile tile = null, bool doFlush = false)
        {
            DateTime now = DateTime.Now;
            int      routeId = route.ID, stopId = stop.ID;
            var      timeTable = TransitBaseComponent.Current.Logic.GetTimetable(route, stop, now);
            var      control   = await CreateStaticTileBackgroundControl(stop, route, timeTable, now);

            if (doFlush)
            {
                route     = null;
                stop      = null;
                timeTable = null;
                TransitBaseComponent.Current.Flush();
            }

            string      imageFileName = "stoproute" + stopId + "-" + routeId + ".png";
            StorageFile imageFile     = await ApplicationData.Current.LocalFolder.CreateFileAsync(imageFileName, Windows.Storage.CreationCollisionOption.ReplaceExisting);

            if (containerGrid != null)
            {
                containerGrid.Children.Insert(0, control);
            }
            await RenderTileImage(control, imageFile, control.Width, control.Height);

            if (containerGrid != null)
            {
                containerGrid.Children.Remove(control);
            }

            if (tile == null)
            {
                var tiles = await SecondaryTile.FindAllAsync();

                string tileArg = String.Format("{0}-{1}", routeId, stopId);
                tile = tiles.First(t => t.Arguments == tileArg);
            }

            tile.VisualElements.Square150x150Logo = new Uri("ms-appdata:///local/" + imageFileName);
            await tile.UpdateAsync();
        }
Exemple #8
0
        private void btsetting_Click(object sender, RoutedEventArgs e)
        {
            if (gdRectVisibility == null)
            {
                this.FindName("gdRectVisibility");
                if (UtilityData.isFluentDesign && spContentSplitView.Background is SolidColorBrush)
                {
                    spContentSplitView.Background = new AcrylicBrush()
                    {
                        FallbackColor    = ((SolidColorBrush)spContentSplitView.Background).Color,
                        TintColor        = ((SolidColorBrush)spContentSplitView.Background).Color,
                        TintOpacity      = 0.6,
                        BackgroundSource = AcrylicBackgroundSource.Backdrop
                    };
                }
            }

            //if (ApplicationData.Current.LocalSettings.Values.ContainsKey("NoOfDevClick"))
            //{
            //    string strNoOfClick = ApplicationData.Current.LocalSettings.Values["NoOfDevClick"].ToString();

            //    int noOfClick = Convert.ToInt32(strNoOfClick);
            //    if (noOfClick >= 5)
            //    {
            //        this.FindName("btRefreshDarkMode");
            //        btRefreshDarkMode.Visibility = Visibility.Visible;
            //    }
            //}
            ContentSplitView.IsPaneOpen = !ContentSplitView.IsPaneOpen;
            if (SecondaryTile.Exists("secRedditId"))
            {
                tbTransparentTileIcon.Text = "\uE77A";
                tbTransparentTile.Text     = "Unpin from Start";
            }
            else
            {
                tbTransparentTileIcon.Text = "\uE840";
                tbTransparentTile.Text     = "Pin to Start";
            }
        }
Exemple #9
0
        private async Task PinTile(string style)
        {
            SecondaryTile tile = TilesHelper.GenerateSecondaryTile(style);

            tile.VisualElements.ShowNameOnSquare150x150Logo = true;
            tile.VisualElements.ShowNameOnSquare310x310Logo = true;
            tile.VisualElements.ShowNameOnWide310x150Logo   = true;

            await tile.RequestCreateAsync();

            string xml = $@"
                <tile version='3'>
                    <visual>
       
                        <binding template='TileSmall'>
                            <text hint-style='{style}'>This is a string of text that will be styled to the desired effect</text>
                        </binding>

                        <binding template='TileMedium'>
                            <text hint-style='{style}'>This is a string of text that will be styled to the desired effect</text>
                        </binding>

                        <binding template='TileWide'>
                            <text hint-style='{style}'>This is a string of text that will be styled to the desired effect</text>
                        </binding>

                        <binding template='TileLarge'>
                            <text hint-style='{style}'>This is a string of text that will be styled to the desired effect</text>
                        </binding>
                    </visual>
                </tile>";

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            TileNotification notification = new TileNotification(doc);

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(notification);
        }
        private async void OnPinToStart(object sender, RoutedEventArgs e)
        {
            try
            {
                var fixedtitle = Regex.Replace(Scenario.Title, @"\W", "-");
                if (PinToStart.IsOn)
                {
                    if (string.IsNullOrWhiteSpace(fixedtitle))
                    {
                        PinToStart.IsOn = false;
                    }
                    else if (!SecondaryTile.Exists(fixedtitle))
                    {
                        Uri logo = new Uri(@"ms-appx:///Assets/Square150x150Logo.scale-200.png");
                        var tile = new SecondaryTile(fixedtitle,
                                                     Scenario.Title,
                                                     Scenario.Title,
                                                     logo,
                                                     TileSize.Default);

                        await tile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender));
                    }
                }
                else if (!string.IsNullOrWhiteSpace(fixedtitle))
                {
                    if (SecondaryTile.Exists(fixedtitle))
                    {
                        SecondaryTile               secondaryTile = new SecondaryTile(fixedtitle);
                        Windows.Foundation.Rect     rect          = GetElementRect((FrameworkElement)sender);
                        Windows.UI.Popups.Placement placement     = Windows.UI.Popups.Placement.Above;
                        bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(rect, placement);
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                throw;
            }
        }
        public static async void UpdateAllNoteTilesBackgroundColor(bool transparentTile = false)
        {
            var tiles = await SecondaryTile.FindAllAsync();

            if (tiles == null)
            {
                return;
            }

            foreach (var tile in tiles)
            {
                Note note = AppData.TryGetNoteById(tile.TileId);
                if (note == null)
                {
                    continue;
                }

                //var tile = new SecondaryTile(t.TileId);
                tile.VisualElements.BackgroundColor = transparentTile ? Colors.Transparent : note.Color.DarkColor.Color;
                await tile.UpdateAsync();
            }
        }
Exemple #12
0
        public async void PinItemSecondaryTile()
        {
            var tile = new SecondaryTile(
                Item.Id.ToString(),
                Item.Title,
                JsonConvert.SerializeObject(Item),
                new Uri("ms-appx:///Assets/SmallTile.png"),
                TileSize.Square150x150);

            tile.VisualElements.Wide310x150Logo =
                new Uri("ms-appx:///Assets/LargeTile.png");
            tile.VisualElements.ShowNameOnSquare150x150Logo = true;
            tile.VisualElements.ShowNameOnWide310x150Logo   = true;
            tile.VisualElements.ShowNameOnSquare310x310Logo = true;

            var success = await tile.RequestCreateAsync();

            if (success)
            {
                RaisePropertyChanged(nameof(IsItemPinned));
            }
        }
        private async void PinVisitCommandExecute(Rect rect)
        {
            var pictureUri     = new Uri(PINLOGO_PATH);
            var pictureWideUri = new Uri(PINLOGOWIDE_PATH);

            string tileActivationArguments = string.Format("{0}{1}", VISIT, visitItem.VisitId);

            var loader      = new ResourceLoader();
            var displayName = string.Format("{0}. {1} {2}", loader.GetString("AppName"), this.Visit.VisitorName, Visit.VisitFormattedDate);

            // Windows 8.1
            var tile = new SecondaryTile(visitItem.VisitId.ToString(), displayName, tileActivationArguments, pictureUri, TileSize.Wide310x150);

            tile.VisualElements.ForegroundText              = ForegroundText.Light;
            tile.VisualElements.Wide310x150Logo             = pictureWideUri;
            tile.VisualElements.ShowNameOnSquare150x150Logo = true;
            tile.VisualElements.ShowNameOnWide310x150Logo   = true;

            await tile.RequestCreateForSelectionAsync(rect, Placement.Above);

            this.tilesService.UpdatePinTile(this.visitItem, tile);
        }
        private void UpdateSecondaryTile(string tileId)
        {
            var exists = SecondaryTile.Exists(tileId);

            if (exists == secondaryTileExits)
            {
                return;
            }

            if (exists)
            {
                buttonPinReport.Content = "";
                AutomationProperties.SetName(buttonPinReport, StiLocalization.Get("NavigatorRT", "Unpin"));
            }
            else
            {
                buttonPinReport.Content = "";
                AutomationProperties.SetName(buttonPinReport, StiLocalization.Get("NavigatorRT", "Pin"));
            }

            secondaryTileExits = exists;
        }
Exemple #15
0
        /// <summary>
        /// Updates menu and app bar icons
        /// </summary>
        private void UpdateMenuAndAppBarIcons()
        {
            // Show unpin or pin button
            ApplicationBarIconButton btn = (ApplicationBarIconButton)ApplicationBar.Buttons[2];

            if (!SecondaryTile.Exists(TILE_ID))
            {
                btn.IconUri = new Uri("Assets/Images/pin-48px.png", UriKind.Relative);
                btn.Text    = "Pin";
            }
            else
            {
                btn.IconUri = new Uri("Assets/Images/unpin-48px.png", UriKind.Relative);
                btn.Text    = "Unpin";
            }
            ApplicationBarIconButton back = (ApplicationBarIconButton)ApplicationBar.Buttons[0];

            back.IsEnabled = _model.DayOffset != 6;
            ApplicationBarIconButton next = (ApplicationBarIconButton)ApplicationBar.Buttons[1];

            next.IsEnabled = _model.DayOffset != 0;
        }
Exemple #16
0
        public static async Task <bool> PinSecondaryTile(LocationItem location)
        {
            var id                   = ConvertLocationNameToTileId(location.Name);
            var displayName          = location.Name;
            var activationArguments  = id;
            var uriSquare150x150Logo = new Uri("ms-appx:///Assets/Square150x150Logo.scale-100.png");
            var desiredSize          = TileSize.Square150x150;

            var tile = new SecondaryTile(id, displayName, activationArguments, uriSquare150x150Logo, desiredSize);

            tile.VisualElements.ShowNameOnSquare150x150Logo = false;
            tile.VisualElements.Square310x310Logo           = new Uri("ms-appx:///Assets/LargeTile.scale-100.png");
            tile.VisualElements.Wide310x150Logo             = new Uri("ms-appx:///Assets/Wide310x150Logo.scale-100.png");

            var isPineed = await tile.RequestCreateAsync();

            if (!isPineed)
            {
                return(false);
            }
            return(true);
        }
Exemple #17
0
        /// <summary>
        /// Create or delete secondary tile for activities
        /// </summary>
        public async void SecTileManageAsync()
        {
            if (SecondaryTile.Exists(SecTile.TileId))
            {
                await SecTile.RequestDeleteAsync();

                StartTileAdded = false;
            }
            else
            {
                SecTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                SecTile.VisualElements.ForegroundText = ForegroundText.Light;
                SecTile.RoamingEnabled = true;

                await SecTile.RequestCreateAsync();

                if (SecondaryTile.Exists(SecTile.TileId))
                {
                    StartTileAdded = true;
                }
            }
        }
Exemple #18
0
        private async void PinUnpinAppBarButton_Click(object sender, RoutedEventArgs e)
        {
            if (SecondaryTile.Exists(tileId))
            {
                SecondaryTile secondaryTile = new SecondaryTile(tileId);
                bool          isUnpinned    = await secondaryTile.RequestDeleteAsync();

                ToggleAppBarButton(isUnpinned);
            }
            else
            {
                string displayName    = GlobalVariables.CurrentTVShow.Label;
                string activationArgs = "tvShow_" + GlobalVariables.CurrentTVShow.Title;
                Uri    logoUri        = new Uri("ms-appx:///Assets/Square71x71Logo.scale-240.png");

                SecondaryTile tvShowTile = new SecondaryTile(tileId, displayName, activationArgs, logoUri, TileSize.Wide310x150);
                tvShowTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/WideLogo.scale-240.png");

                ToggleAppBarButton(false);
                bool pinned = await tvShowTile.RequestCreateAsync();
            }
        }
Exemple #19
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            error.Visibility = Visibility.Collapsed;
            _aid             = (e.Parameter as object[])[0].ToString();
            txt_Header.Text  = "AV" + _aid;

            await GetFavBox();
            await LoadVideo();

            if (SecondaryTile.Exists(_aid))
            {
                btn_unPin.Visibility = Visibility.Visible;
                btn_Pin.Visibility   = Visibility.Collapsed;
            }
            else
            {
                btn_unPin.Visibility = Visibility.Collapsed;
                btn_Pin.Visibility   = Visibility.Visible;
            }
        }
Exemple #20
0
        async void pinToAppBar_Click(object sender, RoutedEventArgs e)
        {
            string selectedApp = selectedAppObject.ToString();

            SecondaryTileAppBar.IsSticky = true;
            if (SecondaryTile.Exists(selectedApp))
            {
                SecondaryTile secondaryTile = new SecondaryTile(selectedApp);
                bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);

                ToggleAppBarButton(isUnpinned);
            }
            else
            {
                Uri logo = Helpers.GetSnappedURI(Helpers.selectImage(selectedAppObject, true));
                string tileActivationArguments = selectedApp;

                SecondaryTile secondaryTile = new SecondaryTile(selectedApp,
                                                                App.Apps.UnitConverter.ToString() + " - " + selectedApp,
                                                                tileActivationArguments,
                                                                logo,
                                                                TileSize.Default
                                                                );

                secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;
                secondaryTile.VisualElements.Square44x44Logo = Helpers.GetSnappedURI(Helpers.selectImage(selectedAppObject, true));

                bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);

                ToggleAppBarButton(!isPinned);

                // uncheck the items in mainscape
                MainScape.UnselectCurrentItem();


            }
            SecondaryTileAppBar.IsSticky = false;
            SecondaryTileAppBar.IsOpen = false;
        }
Exemple #21
0
        private async void PinToStart_Click(object sender, RoutedEventArgs e)
        {
            PFeedItem feeditem = (PFeedItem)((FrameworkElement)sender).DataContext;
            string    TileId   = feeditem.GetTileId();

            SecondaryTile secondaryTile = new SecondaryTile(
                TileId,
                "myFeed Article",
                feeditem.link,
                new Uri("ms-appx:///Assets/Square150x150Logo.scale-200.png"),
                TileSize.Square150x150
                );

            await secondaryTile.RequestCreateAsync();

            string contents = string.Format(@"
                <tile>
                    <visual>
                        <binding template='TileMedium'>
                            <text hint-wrap='true' hint-maxLines='2' hint-style='caption'>{0}</text>
                            <text hint-style='captionSubtle'>{1}</text>
                            <text hint-style='captionSubtle'>{2}</text>
                        </binding>
                        <binding template='TileWide'>
                            <text hint-wrap='true' hint-maxLines='3' hint-style='caption'>{0}</text>
                            <text hint-style='captionSubtle'>{1}</text>
                            <text hint-style='captionSubtle'>{3}</text>
                        </binding>
                    </visual>
                </tile> ", feeditem.title, feeditem.feed, feeditem.PublishedDate.ToString("dd.MM.yyyy"),
                                            feeditem.PublishedDate.ToString("dd.MM.yyyy HH: mm"));

            Windows.Data.Xml.Dom.XmlDocument xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
            xmlDoc.LoadXml(contents);

            TileNotification notifyTile = new TileNotification(xmlDoc);

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(TileId).Update(notifyTile);
        }
        private async void PinExecute()
        {
            IsPinned = false;

            if (PinSymbol == Symbol.Pin)
            {
                var tileOnShow = new SecondaryTile(Guid.NewGuid().ToString(), $"{ShowedPerson.Name} {ShowedPerson.LastName}", ShowedPerson.Id, new Uri("ms-appx:///Assets/LogoForTile.png"), TileSize.Square150x150);
                IsPinned = await _tileService.RequestCreate(tileOnShow);

                PinSymbol = Symbol.UnPin;
            }
            else
            {
                _tileService.RequestDelete(ShowedPerson.Id);
                PinSymbol = Symbol.Pin;
            }

            if (IsPinned)
            {
                PinSymbol = Symbol.UnPin;
            }
        }
        /// <summary>
        /// This method unpins the existing secondary tile.
        /// The user is shown a message informing whether the tile is unpinned successfully
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="vm">The Current Product View Model.</param>
        /// <returns></returns>
        private async Task UnpinSecondaryTile(object sender, ViewProductViewModel vm)
        {
            try
            {
                if (SecondaryTile.Exists(vm.ProductDetails.Id))
                {
                    SecondaryTile secondaryTile = new SecondaryTile(vm.ProductDetails.Id);

                    //nb: should always return true as we checked with Exists()
                    if (secondaryTile != null)
                    {
                        bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(GetElementRect((FrameworkElement)sender), Placement.Above);

                        vm.SetPinnedState(!isUnpinned);

                        if (isUnpinned)
                        {
                            MessageDialog dialog = new MessageDialog("Product " + vm.ProductDetails.Name + " successfully unpinned.");
                            await dialog.ShowAsync();
                        }
                        else
                        {
                            MessageDialog dialog = new MessageDialog("Product " + vm.ProductDetails.Name + " not unpinned.");
                            await dialog.ShowAsync();
                        }
                    }
                }
                else
                {
                    MessageDialog dialog = new MessageDialog("The tile for Product " + vm.ProductDetails.Name + " was not located.");
                    await dialog.ShowAsync();
                }
            }
            catch (Exception e)
            {
                MessageDialog dialog = new MessageDialog("There was an error unpinning this tile. \n\n Message : " + (e.Message ?? "(Error Details Unavailable)"), "Error Unpinning Tile");
                await dialog.ShowAsync();
            }
        }
        /// <summary>
        /// This is the click handler for the 'Other' button.  You would replace this with your own handler
        /// if you have a button or buttons on this page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SendBadgeNotification_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                if (SecondaryTile.Exists(MainPage.dynamicTileId))
                {
                    BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6);

                    // Send the notification to the secondary tile
                    BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(MainPage.dynamicTileId).Update(badgeContent.CreateNotification());

                    rootPage.NotifyUser("Badge notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage);
                }
                else
                {
                    ToggleButtons(false);
                    rootPage.NotifyUser(MainPage.dynamicTileId + " not pinned.", NotifyType.ErrorMessage);
                }
            }
        }
        private async void PinTile()
        {
            SecondaryTile tile = new SecondaryTile(DateTime.Now.Ticks.ToString())
            {
                DisplayName = "WeatherSample",
                Arguments   = "args"
            };

            tile.VisualElements.ShowNameOnSquare150x150Logo = true;
            tile.VisualElements.ShowNameOnSquare310x310Logo = true;
            tile.VisualElements.ShowNameOnWide310x150Logo   = true;
            tile.VisualElements.Square150x150Logo           = Constants.Square150x150Logo;
            tile.VisualElements.Wide310x150Logo             = Constants.Wide310x150Logo;
            tile.VisualElements.Square310x310Logo           = Constants.Square310x310Logo;

            if (!await tile.RequestCreateAsync())
            {
                return;
            }

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(new TileNotification(_tileContent.GetXml()));
        }
Exemple #26
0
        public async Task <bool> PinPoll(FrameworkElement anchorElement, int pollId, string question)
        {
            var isPinned = false;
            Uri logoUri  = new Uri("ms-appx:///Assets/Logo.png");

            var tileId = string.Format(SecondaryPinner.TileIdFormat, pollId);

            if (!SecondaryTile.Exists(tileId))
            {
                var secondaryTile = new SecondaryTile(
                    tileId,
                    question,
                    pollId.ToString(),
                    logoUri,
                    TileSize.Default);

                isPinned = await secondaryTile.RequestCreateForSelectionAsync(
                    GetElementRect(anchorElement), Placement.Above);
            }

            return(isPinned);
        }
Exemple #27
0
        protected override async void OnRun(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

            try {
                /// Register services (Background task can't access services from the UWP)
                Ioc.Default.ConfigureServices(
                    new ServiceCollection()
                    .AddSingleton(RestService.For <ICryptoCompare>("https://min-api.cryptocompare.com/"))
                    .AddTransient <LocalSettings>()
                    .BuildServiceProvider());


                var tiles = await SecondaryTile.FindAllAsync();

                foreach (var tile in tiles)
                {
                    try {
                        await LiveTileUpdater.AddSecondaryTile(tile.TileId);
                    }
                    catch (Exception ex) {
                        var z = ex.Message;
                    }
                }

                /// Check price alerts
                await CheckAlerts();
            }
            catch (Exception ex) {
                Analytics.TrackEvent("BackgroundTask-error",
                                     new Dictionary <string, string>()
                {
                    { "Exception", ex.Message }
                });
            }


            deferral.Complete();
        }
Exemple #28
0
        async void OnPinSecondaryTile(object sender, RoutedEventArgs e)
        {
            var tileName = "App2";
            var tiles    = await SecondaryTile.FindAllAsync();

            if (tiles.Count(t => t.DisplayName == tileName) == 0)
            {
                Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
                Uri wide310x150Logo   = new Uri("ms-appx:///Assets/wide310x150Tile-sdk.png");
                Uri square310x310Logo = new Uri("ms-appx:///Assets/square310x310Tile-sdk.png");

                // Create a medium size Secondary tile
                SecondaryTile secondaryTile = new SecondaryTile(
                    tileName,
                    "Title text shown on the tile",
                    "my arguments",
                    square150x150Logo,
                    TileSize.Square150x150);

                // To have the larger tile sizes available the assets must be provided.
                secondaryTile.VisualElements.Wide310x150Logo   = wide310x150Logo;
                secondaryTile.VisualElements.Square310x310Logo = square310x310Logo;

                // The display of the app name can be controlled for each tile size.
                // The default is false.
                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                secondaryTile.VisualElements.ShowNameOnWide310x150Logo   = true;
                secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;

                // Specify a foreground text value.
                // The tile background color is inherited from the parent unless a separate value is specified.
                secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

                // OK, the tile is created and we can now attempt to pin the tile.
                // Note that the status message is updated when the async operation to pin the tile completes.
                bool isPinned = await secondaryTile.RequestCreateAsync();
            }
        }
        private async void OnPinSecondTileClick(object sender, RoutedEventArgs e)
        {
            Uri logo      = new Uri("ms-appx:///Assets/logo150x150.png");
            Uri smallLogo = new Uri("ms-appx:///Assets/logo24x24.png");

            // During creation of secondary tile, an application may set additional arguments on the tile that will be passed in during activation.
            // These arguments should be meaningful to the application. In this sample, we'll pass in the date and time the secondary tile was pinned.
            string tileActivationArguments = MainPage.SecondaryTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

            // Create a 1x1 Secondary tile
            SecondaryTile secondaryTile = new SecondaryTile(MainPage.SecondaryTileId,
                                                            "SecondaryTile",
                                                            "Secondary Tile",
                                                            tileActivationArguments,
                                                            TileOptions.ShowNameOnLogo,
                                                            logo);

            // Specify a foreground text value.
            // The tile background color is inherited from the parent unless a separate value is specified.
            secondaryTile.ForegroundText = ForegroundText.Light;

            // Like the background color, the small tile logo is inherited from the parent application tile by default. Let's override it, just to see how that's done.
            secondaryTile.SmallLogo = smallLogo;

            // OK, the tile is created and we can now attempt to pin the tile.
            // Note that the status message is updated when the async operation to pin the tile completes.
            bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);

            if (isPinned)
            {
                this.SetSuccessStatus("Secondary tile was successfully pinned.");
                this.IsSecondaryTilePinned = true;
            }
            else
            {
                this.SetErrorMessage("Secondary tile is not pinned.");
            }
        }
        private async void AddToStartMenu_ClickAsync(object sender, RoutedEventArgs e)
        {
            var element = (FrameworkElement)sender;

            if (!(element.DataContext is AccountViewModel account))
            {
                return;
            }

            var liveTileManager = new LiveTileManager(ServiceLocator.Current.GetInstance <ICrudServicesAsync>());

            int  id       = account.Id;
            bool isPinned = SecondaryTile.Exists(id.ToString(CultureInfo.InvariantCulture));

            if (!isPinned)
            {
                SecondaryTile tile = new SecondaryTile(id.ToString(CultureInfo.InvariantCulture), Strings.ApplicationTitle, "a", new Uri(SMALL_150_TILE_ICON), TileSize.Default);
                tile.VisualElements.ShowNameOnSquare150x150Logo = false;
                tile.VisualElements.ShowNameOnSquare310x310Logo = true;
                tile.VisualElements.ShowNameOnWide310x150Logo   = false;
                tile.VisualElements.Square310x310Logo           = new Uri(SQUARE_310_TILE_ICON);
                tile.VisualElements.Square150x150Logo           = new Uri(SQUARE_150_TILE_ICON);
                tile.VisualElements.Wide310x150Logo             = new Uri(WIDE_310_TILE_ICON);
                tile.VisualElements.Square71x71Logo             = new Uri(SQUARE_71_TILE_ICON);
                bool successfulPinned = await tile.RequestCreateAsync();

                if (successfulPinned)
                {
                    await liveTileManager.UpdateSecondaryLiveTiles();
                }
            }
            else
            {
                await liveTileManager.UpdateSecondaryLiveTiles();

                await liveTileManager.UpdatePrimaryLiveTile();
            }
        }