Beispiel #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);
            }
        }
        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;
            }
        }