Пример #1
0
        private void DisplayMenu(String id)
        {
            View view;

            switch (id)
            {
            case "conversations":
                if (conversationsPanel == null)
                {
                    conversationsPanel = new ConversationsPanel();
                }

                conversationsPanel.Initialize();
                view = conversationsPanel;
                break;

            case "contacts":
                if (contactsPanel == null)
                {
                    contactsPanel = new ContactsPanel();
                }

                contactsPanel.Initialize();
                view = contactsPanel;
                break;

            default:
                view = new Label()
                {
                    Text = id + " - TO DO", HorizontalOptions = new LayoutOptions(LayoutAlignment.Center, false), VerticalOptions = new LayoutOptions(LayoutAlignment.Center, false), BackgroundColor = Color.White
                };
                break;
            }

            if (gridMainContent != null)
            {
                if (currentView != null)
                {
                    gridMainContent.Children.Remove(currentView);
                }

                currentView = view;
                gridMainContent.Children.Add(currentView, 0, 0);
            }
        }
Пример #2
0
        /// <summary>
        /// Lazy loading of pivot tabs for perf.
        /// only load a tab when a user access it
        /// Naturally all pivots are loaded when the control is created (we dont want this)
        /// </summary>
        private void UpdateTabInfoOnPivotLoading(Pivot sender, PivotItemEventArgs args)
        {
            int currentTabIndex = PhoneTabs.SelectedIndex;

            //Set device oritentation based on tab
            switch (currentTabIndex)
            {
            //For the contact and dialer tabs, we should disable landscape
            case 1:
            case 2:
                DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;
                break;

            //Other tabs can be both portrait and landscape
            default:
                DisplayInformation.AutoRotationPreferences =
                    DisplayOrientations.Portrait | DisplayOrientations.Landscape |
                    DisplayOrientations.PortraitFlipped | DisplayOrientations.LandscapeFlipped;
                break;
            }

            //Update content as its already loaded
            if (args.Item.Content != null)
            {
                //Content loaded already, perform an update instead and exit
                UpdateTabInfo(currentTabIndex);
                return;
            }

            //Lazy load the tabs. Only load when accessed
            UserControl CurrentPanel;

            switch (currentTabIndex)
            {
            case 0:
                statusVM            = ViewModelDispatcher.StatusViewModel;
                CurrentPanel        = new StatusPanel();
                CurrentPanel.Height = Double.NaN;     //Auto height
                args.Item.Content   = CurrentPanel;
                break;

            case 1:
                CurrentPanel        = new ContactsPanel();
                CurrentPanel.Height = Double.NaN;     //Auto height
                args.Item.Content   = CurrentPanel;
                break;

            case 2:
                CurrentPanel        = new DialerPanel();
                CurrentPanel.Height = Double.NaN;     //Auto height
                args.Item.Content   = CurrentPanel;
                break;

            case 3:
                voicemailVM         = ViewModelDispatcher.VoicemailViewModel;
                CurrentPanel        = new VoicemailPanel();
                CurrentPanel.Height = Double.NaN;     //Auto height
                args.Item.Content   = CurrentPanel;
                break;

            default:
                break;
            }
        }