Exemplo n.º 1
0
        /// <summary>
        /// Create the secondary tile
        /// </summary>
        /// <param name="element">Element to pin</param>
        public async Task PinAsync(PinnableObject element)
        {
            SecondaryTile tile = new SecondaryTile
            {
                TileId      = element.Id,
                ShortName   = element.Title,
                DisplayName = element.Title,
                Arguments   = element.Id,
                TileOptions = TileOptions.ShowNameOnLogo,
                Logo        = new Uri("ms-appx:///Assets/Logo.png")
            };

            if (await tile.RequestCreateAsync())
            {
                // Tile template definition
                ITileSquarePeekImageAndText04 squareContent = TileContentFactory.CreateTileSquarePeekImageAndText04();
                squareContent.TextBodyWrap.Text = element.Content;
                squareContent.Image.Src         = element.ImageUrl;
                squareContent.Image.Alt         = element.Content;

                // Tile creation
                TileNotification tileNotification = squareContent.CreateNotification();

                // Send the notification
                TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(element.Id);
                tileUpdater.Update(tileNotification);
            }
        }
Exemplo n.º 2
0
        private static void SetDefaultValues(ModelBindingContext bindingContext, object model)
        {
            // When sending a wide tile in a notification, the payload also includes a square tile
            // because it is not guaranteed which will be displayed; the user has the option to choose
            // either representation in their Start screen.
            var wideTile = model as IWideTileNotificationContent;

            if (wideTile != null)
            {
                var tileImageUrl = bindingContext.ValueProvider.GetValue("AlternativeTileImage");
                var tileText     = bindingContext.ValueProvider.GetValue("AlternativeTileText");

                if (tileImageUrl != null && tileText != null)
                {
                    var squareTile = TileContentFactory.CreateTileSquarePeekImageAndText04();
                    squareTile.Image.Src         = tileImageUrl.AttemptedValue;
                    squareTile.TextBodyWrap.Text = tileText.AttemptedValue;
                    wideTile.SquareContent       = squareTile;
                    return;
                }

                if (tileImageUrl != null)
                {
                    var squareTile = TileContentFactory.CreateTileSquareImage();
                    squareTile.Image.Src   = tileImageUrl.AttemptedValue;
                    wideTile.SquareContent = squareTile;
                    return;
                }

                if (tileText != null)
                {
                    var squareTile = TileContentFactory.CreateTileSquareText04();
                    squareTile.TextBodyWrap.Text = tileText.AttemptedValue;
                    wideTile.SquareContent       = squareTile;
                }
            }

            // When sending a toast notification that has looping audio src, the Audio.Loop property should be set to true
            // and the Duration property should be set to Long, as specified by the WNS model.
            var toast = model as IToastNotificationContent;

            if (toast != null)
            {
                var result = bindingContext.ValueProvider.GetValue("Audio.Content");
                if (result != null)
                {
                    ToastAudioContent audioContent;
                    if (Enum.TryParse <ToastAudioContent>(result.AttemptedValue, out audioContent))
                    {
                        toast.Audio.Loop = audioContent == ToastAudioContent.LoopingAlarm || audioContent == ToastAudioContent.LoopingAlarm2 ||
                                           audioContent == ToastAudioContent.LoopingCall || audioContent == ToastAudioContent.LoopingCall2;
                        if (toast.Audio.Loop)
                        {
                            toast.Duration = ToastDuration.Long;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static ITileSquarePeekImageAndText04 GetSquateTempalte(PlaybackNotificationOptions options)
        {
            var tile = TileContentFactory.CreateTileSquarePeekImageAndText04();

            tile.Image.Src         = options.ImageUrl;
            tile.TextBodyWrap.Text = string.Format("{0} - {1}", options.Title, options.Subtitle);

            return(tile);
        }
Exemplo n.º 4
0
        public async void SearchText(string query)
        {
            try
            {
                // create the square template and attach it to the wide template
                ITileSquarePeekImageAndText04 squareContent = TileContentFactory.CreateTileSquarePeekImageAndText04();
                squareContent.TextBodyWrap.Text = query;
                squareContent.Image.Src         = "ms-appx:///Assets/Logo.png";
                squareContent.Branding          = TileBranding.None;

                // send the notification
                TileUpdateManager.CreateTileUpdaterForApplication().Update(squareContent.CreateNotification());
            }
            catch { }


            //Show loader:
            //LoadingPanel.Visibility = Windows.UI.Xaml.Visibility.Visible;
            //LoadingPanel2.Visibility = Windows.UI.Xaml.Visibility.Visible;

            var result = await DataLoader.LoadAsync(() => SearchService.SearchAsync(query));

            //TODO Hide loader
            //LoadingPanel.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            //LoadingPanel2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;


            if (result != null)
            {
                if (result.Results != null && result.Results.Count > 0)
                {
                    //ResultPanel.Visibility = Windows.UI.Xaml.Visibility.Visible;
                    //ResultPanel2.Visibility = Windows.UI.Xaml.Visibility.Visible;

                    //ResultGrid.DataContext = result;
                    //SnapGrid.DataContext = result;
                    SearchWord = result;

                    //ResultList.ItemsSource = result.Results;

                    var historyList = await HistoryService.GetHistory();

                    HistoryList = historyList;

                    //Scroller.Focus(Windows.UI.Xaml.FocusState.Programmatic);
                    Right = true;
                    //Scroller.ScrollToHorizontalOffset(double.MaxValue);
                }
                else
                {
                    //TODO: Show niet in woordenboek
                    SearchWord = null;

                    //NotAvailablePanel.Visibility = Windows.UI.Xaml.Visibility.Visible;
                    //NotAvailablePanel2.Visibility = Windows.UI.Xaml.Visibility.Visible;
                }
            }
            else
            {
                //TODO: Show error
                DataLoader.LoadingState = LoadingState.Error;
                //ErrorPanel.Visibility = Windows.UI.Xaml.Visibility.Visible;
                //ErrorPanel2.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
        }