예제 #1
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            loading = true;

            // Allow saved page state to override the initial item to display
            if (pageState != null && pageState.ContainsKey("SelectedItem"))
            {
                navigationParameter = pageState["SelectedItem"];
            }


            _item = ThinkDataSource.GetItem((String)navigationParameter);

            this.DefaultViewModel["Group"] = _item.Group;
            this.DefaultViewModel["Items"] = _item.Group.Items;

            this.flipView.SelectedItem = _item;

            string back = App.Current.RequestedTheme == ApplicationTheme.Light ? App.Current.Resources["LightBackground"] as string : App.Current.Resources["DarkBackground"] as string;

            rootGrid.Background = new SolidColorBrush(App.GetColorFromHexString(back));

            App.startArguments = "";
            CheckAppBarButtons();

            loading = false;
        }
예제 #2
0
        public void unfavButton_Click(object sender, RoutedEventArgs e)
        {
            //Remove da lista de favoritos
            ThinkDataSource.Instance.RemoveItemFromFavoriteGroup(_item);

            CheckAppBarButtons();
            ThinkDataSource.SaveLocalDataAsync();
        }
예제 #3
0
        public void favButton_Click(object sender, RoutedEventArgs e)
        {
            //Adiciona na lista de favoritos
            ThinkDataSource.Instance.AddItemToFavoriteGroup(_item);

            CheckAppBarButtons();
            ThinkDataSource.SaveLocalDataAsync();
        }
예제 #4
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected async override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            var queryText = navigationParameter as String;

            this.DefaultViewModel["QuoteDataSource"] = ThinkDataSource.Instance;
            this.DefaultViewModel["BackgroundColor"] = App.Current.RequestedTheme == ApplicationTheme.Light ? App.Current.Resources["LightBackground"] as string : App.Current.Resources["DarkBackground"] as string;

            // TODO: Application-specific searching logic.  The search process is responsible for
            //       creating a list of user-selectable result categories:
            //
            //       filterList.Add(new Filter("<filter name>", <result count>));
            //
            //       Only the first filter, typically "All", should pass true as a third argument in
            //       order to start in an active state.  Results for the active filter are provided
            //       in Filter_SelectionChanged below.

            var filterList = new List <Filter>();

            filterList.Add(new Filter(loader.GetString("SearchAllFilter"), 0, true));

            // Search recipes and tabulate results
            string query = queryText.ToLower();
            var    all   = new List <QuoteItem>();

            _results.Add(loader.GetString("SearchAllFilter"), all);


            while (ThinkDataSource.GetStatusLoad() == 0)
            {
                await Task.Delay(20);
            }

            foreach (var group in ThinkDataSource.GetGroups("AllGroups"))
            {
                var items = new List <QuoteItem>();
                _results.Add(group.Title, items);

                foreach (var item in group.Items)
                {
                    if (item.Autor.ToLower().Contains(query) || item.Quote.ToLower().Contains(query))
                    {
                        all.Add(item);
                        items.Add(item);
                    }
                }

                filterList.Add(new Filter(group.Title, items.Count, false));
            }

            filterList[0].Count = all.Count;


            // Communicate results through the view model
            this.DefaultViewModel["QueryText"]   = '\u201c' + queryText + '\u201d';
            this.DefaultViewModel["CanGoBack"]   = this._previousContent != null;
            this.DefaultViewModel["Filters"]     = filterList;
            this.DefaultViewModel["ShowFilters"] = filterList.Count > 1;
        }
예제 #5
0
        public async void pinButton_Click(object sender, RoutedEventArgs e)
        {
            this.BottomAppBar.IsSticky = true;

            _item.IsPin = true;

            var logo      = new Uri("ms-appx:///Assets/Logo.png");
            var logoWide  = new Uri("ms-appx:///Assets/WideLogo.png");
            Uri smallLogo = new Uri("ms-appx:///Assets/SmallLogo.png");


            SecondaryTile tile = new SecondaryTile(
                _item.UniqueId,                 // Tile ID
                "Think",                        // Tile short name
                _item.Autor,                    // Tile display name
                _item.UniqueId,                 // Activation argument
                TileOptions.ShowNameOnLogo | TileOptions.ShowNameOnWideLogo,
                logo,                           // Tile logo
                logoWide
                );

            // Specify a foreground text value.
            // The tile background color is inherited from the parent unless a separate value is specified.
            tile.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.
            tile.SmallLogo = smallLogo;


            bool created = await tile.RequestCreateAsync();

            if (created)
            {
                // Note: This sample contains an additional reference, NotificationsExtensions, which you can use in your apps
                ITileWideText09 tileContent = TileContentFactory.CreateTileWideText09();
                tileContent.TextHeading.Text  = _item.Autor;
                tileContent.TextBodyWrap.Text = _item.Quote;


                ITileSquareText04 squareContent = TileContentFactory.CreateTileSquareText04();
                squareContent.TextBodyWrap.Text = _item.Quote;
                tileContent.SquareContent       = squareContent;


                // Send the notification to the secondary tile by creating a secondary tile updater
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(_item.UniqueId).Update(tileContent.CreateNotification());
            }

            // Show pin button in the appbar
            CheckAppBarButtons();

            this.BottomAppBar.IsSticky = false;
            ThinkDataSource.SaveLocalDataAsync();
        }
        private async void refreshButton_Click(object sender, RoutedEventArgs e)
        {
            syncButton.IsEnabled = false;
            ThinkDataSource.StartLoadingStatus();
            LoadingAsync();
            await ThinkDataSource.Instance.LoadNewRemoteDataAsync();

            ThinkDataSource.SaveLocalDataAsync();
            ThinkDataSource.StopLoadingStatus();
            syncButton.IsEnabled = true;
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var groups = ThinkDataSource.GetGroups((String)navigationParameter);

            this.DefaultViewModel["Groups"]          = groups;
            this.DefaultViewModel["ThinkDataSource"] = ThinkDataSource.Instance;

            this.DefaultViewModel["BackgroundColor"] = App.Current.RequestedTheme == ApplicationTheme.Light ? App.Current.Resources["LightBackground"] as string : App.Current.Resources["DarkBackground"] as string;

            LoadingAsync();
        }
예제 #8
0
        public async void unpinButton_Click(object sender, RoutedEventArgs e)
        {
            this.BottomAppBar.IsSticky = true;

            _item.IsPin = false;

            // First prepare the tile to be unpinned
            SecondaryTile secondaryTile = new SecondaryTile(_item.UniqueId);
            // Now make the delete request.
            bool isUnpinned = await secondaryTile.RequestDeleteAsync();

            // Show pin button in the appbar
            CheckAppBarButtons();


            this.BottomAppBar.IsSticky = false;
            ThinkDataSource.SaveLocalDataAsync();
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var group = ThinkDataSource.GetGroup((String)navigationParameter);

            if (group == null)
            {
                this.Frame.Navigate(typeof(GroupedItemsPage), "AllGroups");
            }
            else
            {
                this.DefaultViewModel["Group"] = group;
                this.DefaultViewModel["Items"] = group.Items;

                string back = App.Current.RequestedTheme == ApplicationTheme.Light ? App.Current.Resources["LightBackground"] as string : App.Current.Resources["DarkBackground"] as string;
                rootGrid.Background = new SolidColorBrush(App.GetColorFromHexString(back));
            }
        }
        public async void LoadingAsync()
        {
            progressRing.IsActive = true;

            while (ThinkDataSource.GetStatusLoad() == ThinkDataSource.Loading)
            {
                await Task.Delay(100);
            }

            progressRing.IsActive = false;


            if (ThinkDataSource.Instance.AllGroups.Count == 0)
            {
                VisualStateManager.GoToState(this, "AllHaveNoItems", true);
            }
            else
            {
                VisualStateManager.GoToState(this, "AllHaveItems", true);
            }


            if (ThinkDataSource.GetStatusLoad() == ThinkDataSource.InternetError)
            {
                VisualStateManager.GoToState(this, "InternetError", true);
            }
            else if (ThinkDataSource.GetStatusLoad() == ThinkDataSource.XMLCorruptedError)
            {
                VisualStateManager.GoToState(this, "CorruptedXMLError", true);
            }
            else
            {
                VisualStateManager.GoToState(this, "NoError", true);
            }

            while (groupedItemsViewSource.View == null)
            {
                await Task.Delay(100);
            }
            (zoomItemLandscape.ZoomedOutView as ListViewBase).ItemsSource = groupedItemsViewSource.View.CollectionGroups;
            (zoomItemPortrait.ZoomedOutView as ListViewBase).ItemsSource  = groupedItemsViewSource.View.CollectionGroups;
        }