Example #1
0
        private void Timeline_TweetEvent(object sender, EventArgs e)
        {
            ViewTweet tweet = new ViewTweet((Status)sender, Mobile);

            tweet.BackEvent += Tweet_BackEvent;

            if (Mobile)
            {
                PivotItem pi = (PivotItem)twarpPivot.Items[twarpPivot.SelectedIndex];
                tweet.timeline = (TwarpTimeline)pi.Content;
                pi.Content     = tweet;
            }
            else
            {
                foreach (var item in mainStack.Children)
                {
                    if (item is TwarpTimeline && ((TwarpTimeline)item).active)
                    {
                        var index = mainStack.Children.IndexOf(item);
                        tweet.timeline = (TwarpTimeline)mainStack.Children[index];
                        Grid.SetColumn(tweet, index);
                        mainStack.Children[index] = tweet;
                        break;
                    }
                }
            }
            // enable back button - mobile only
            if (Mobile)
            {
                stage = app_stage.tweet;
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            }
        }
Example #2
0
        public MainPage()
        {
            this.InitializeComponent();

            Application.Current.Resuming += Current_Resuming;

            // check if we're on a mobile device:
            Mobile  = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile";
            Desktop = !Mobile;

            // create menu for desktop version
            if (Desktop)
            {
                // desktop version of the app - create the menu:
                menuContent.Children.Insert(0, favHist);
                // menuContent.Children.Insert(1, twarpSettings);
            }

            // initialise favourites and wire up events:
            favHist.init();
            favHist.FavouriteEvent += Favourites_FavouriteEvent;
            favHist.HistoryEvent   += Favourites_HistoryEvent;

            // add event handler for pivot item change:
            twarpPivot.SelectionChanged += TwarpPivot_SelectionChanged;

            // load feed selection user control and wire up handler:
            // mainContent.Content = feed;
            FeedSelector feed = new FeedSelector();

            feed.TwarpEvent  += Feed_TwarpEvent;
            feed.AddFavEvent += Feed_AddFavEvent;

            // add feed to first item of pivot:
            if (Mobile)
            {
                mainContent.Content = twarpPivot;

                // twarpPivot.Margin = new Thickness { Top = -25 };
                PivotItem pi = new PivotItem()
                {
                    Header = "New feed"
                };
                pi.Content = feed;
                twarpPivot.Items.Add(pi);
                twarpPivot.SelectedIndex = 0;
            }
            else
            {
                mainStack.Children.Add(feed);
                Grid.SetColumn(feed, 0);
            }


            SystemNavigationManager.GetForCurrentView().BackRequested += (s, e) =>
            {
                // mobile only...

                // Restore to previous stage:
                switch (stage)
                {
                case app_stage.tweet:
                    PivotItem pItem = (PivotItem)twarpPivot.Items[twarpPivot.SelectedIndex];
                    ViewTweet tweet = (ViewTweet)pItem.Content;
                    pItem.Content = tweet.timeline;
                    stage         = app_stage.timeline;
                    // SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
                    e.Handled = true;
                    break;

                case app_stage.timeline:
                    // return to feed selector:
                    PivotItem pItem2 = (PivotItem)twarpPivot.Items[twarpPivot.SelectedIndex];
                    pItem2.Header  = "New feed";
                    pItem2.Content = ((TwarpTimeline)pItem2.Content).feeder;
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
                    stage     = app_stage.feeder;
                    e.Handled = true;
                    break;

                case app_stage.settings:
                case app_stage.fav:
                    mainContent.Content = twarpPivot;
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
                    stage     = app_stage.main;
                    e.Handled = true;
                    break;

                default:
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
                    e.Handled = false;
                    break;
                }
            };
        }