private async Task HandleSelectMenuItemActivation(Guid localAccountId, NavigationManager.MainMenuSelections menuItem)
        {
            // If we already have a current account and it matches the specified (or unspecified) account ID
            if (CurrentAccount != null && (localAccountId == Guid.Empty || CurrentAccount.LocalAccountId == localAccountId))
            {
                var mainScreen = GetMainScreenViewModel();
                if (mainScreen != null)
                {
                    Popups.Clear();
                    mainScreen.Popups.Clear();
                    if (mainScreen.AvailableItems.Contains(menuItem))
                    {
                        mainScreen.SelectedItem = menuItem;
                    }
                }
            }

            // Otherwise it's a fresh boot, or wrong account
            else
            {
                if (localAccountId != Guid.Empty)
                {
                    AccountsManager.SetLastLoginIdentifier(localAccountId);
                }
                NavigationManager.MainMenuSelection = menuItem;
                await HandleNormalLaunchActivation();
            }
        }
        private async Task HandleSelectMenuItemActivation(Guid localAccountId, NavigationManager.MainMenuSelections menuItem)
        {
            if (CurrentAccount != null && (localAccountId == Guid.Empty || CurrentAccount.LocalAccountId == localAccountId))
            {
                var mainScreen = GetMainScreenViewModel();
                if (mainScreen != null)
                {
                    Popups.Clear();
                    mainScreen.Popups.Clear();
                    if (mainScreen.AvailableItems.Contains(menuItem))
                    {
                        mainScreen.SelectedItem = menuItem;
                    }
                }
            }

            else
            {
                if (localAccountId != Guid.Empty)
                {
                    AccountsManager.SetLastLoginIdentifier(localAccountId);
                }
                NavigationManager.MainMenuSelection = menuItem;
                await HandleNormalLaunchActivation();
            }
        }
Exemple #3
0
        private void setSelectedItem(NavigationManager.MainMenuSelections value)
        {
            if (!AvailableItems.Contains(value))
            {
                return;
            }

            // If already selected, do nothing
            if (value == SelectedItem)
            {
                return;
            }

            NavigationManager.MainMenuSelection = value;

            updateAvailableItems();

            switch (value)
            {
            case NavigationManager.MainMenuSelections.Calendar:
                SetContent(new CalendarViewModel(this, CurrentLocalAccountId, CurrentSemester));
                break;

            case NavigationManager.MainMenuSelections.Day:
                SetContent(new DayViewModel(this, CurrentLocalAccountId, CurrentSemester));
                break;

            case NavigationManager.MainMenuSelections.Agenda:
                SetContent(new AgendaViewModel(this, CurrentLocalAccountId, CurrentSemester, DateTime.Today));
                break;

            case MainMenuSelections.Schedule:
                SetContent(new ScheduleViewModel(this));
                break;

            case MainMenuSelections.Classes:

                if (this.SelectedClass != null)
                {
                    SetContent(new ClassViewModel(this, CurrentLocalAccountId, SelectedClass.Identifier, DateTime.Today, CurrentSemester));
                }
                else
                {
                    SetContent(new ClassesViewModel(this));
                }

                break;

            case MainMenuSelections.Years:
                SetContent(new YearsViewModel(this));
                break;

            case MainMenuSelections.Settings:
                SetContent(new SettingsViewModel(this));
                break;
            }
        }
Exemple #4
0
        protected override DataTemplate SelectTemplateCore(object item)
        {
            if (item is NavigationManager.MainMenuSelections)
            {
                NavigationManager.MainMenuSelections selection = (NavigationManager.MainMenuSelections)item;

                if (selection == NavigationManager.MainMenuSelections.Classes)
                {
                    return(ClassesTemplate);
                }

                return(NormalTemplate);
            }

            return(base.SelectTemplateCore(item));
        }
 private void AddMenuItem(NavigationManager.MainMenuSelections selection, string localizedId, int icon)
 {
     _bottomNav.Menu.Add(Menu.None, (int)selection, Menu.None, PowerPlannerResources.GetString(localizedId)).SetIcon(icon);
 }
Exemple #6
0
            public MenuItemCreator(ViewGroup root, NavigationManager.MainMenuSelections mainMenuSelection, MainScreenView mainScreenView)
            {
                _mainScreenView    = mainScreenView;
                _mainMenuSelection = mainMenuSelection;
                _mainScreenView.ViewModel.PropertyChanged += new WeakEventHandler <PropertyChangedEventArgs>(ViewModel_PropertyChanged1).Handler;

                TextView textView = new TextView(root.Context)
                {
                    Text             = PowerPlannerResources.GetStringMenuItem(mainMenuSelection),
                    TextSize         = 20,
                    Clickable        = true,
                    LayoutParameters = new LinearLayout.LayoutParams(
                        LinearLayout.LayoutParams.MatchParent,
                        LinearLayout.LayoutParams.WrapContent)
                };

                textView.SetTextColor(new Color(255, 255, 255));

                int paddingTopBottom = ThemeHelper.AsPx(root.Context, 11);
                int paddingLeft      = ThemeHelper.AsPx(root.Context, MENU_ITEM_PADDING_LEFT_PX);

                textView.SetPaddingRelative(paddingLeft, paddingTopBottom, 0, paddingTopBottom);

                textView.Click += delegate
                {
                    _mainScreenView.ViewModel.SelectedItem = mainMenuSelection;

                    if (mainMenuSelection != NavigationManager.MainMenuSelections.Classes)
                    {
                        _mainScreenView._drawerLayout.CloseDrawers();
                    }
                };

                if (mainMenuSelection == NavigationManager.MainMenuSelections.Classes)
                {
                    LinearLayout linearLayout = new LinearLayout(root.Context)
                    {
                        Orientation      = Orientation.Vertical,
                        LayoutParameters = new LinearLayout.LayoutParams(
                            LinearLayout.LayoutParams.MatchParent,
                            LinearLayout.LayoutParams.WrapContent)
                    };

                    LinearLayout layoutClassesHeaderAndAddButton = new LinearLayout(root.Context)
                    {
                        Orientation      = Orientation.Horizontal,
                        LayoutParameters = new LinearLayout.LayoutParams(
                            LinearLayout.LayoutParams.MatchParent,
                            LinearLayout.LayoutParams.WrapContent)
                    };

                    // This width will stretch
                    textView.LayoutParameters.Width = 0;
                    (textView.LayoutParameters as LinearLayout.LayoutParams).Weight = 1;

                    layoutClassesHeaderAndAddButton.AddView(textView);

                    // And then the add class button
                    ImageButton addClassButton = new ImageButton(root.Context)
                    {
                        LayoutParameters = new LinearLayout.LayoutParams(
                            LinearLayout.LayoutParams.WrapContent,
                            LinearLayout.LayoutParams.MatchParent),
                        Visibility = ViewStates.Invisible
                    };
                    addClassButton.Background = ThemeHelper.GetAttributeDrawable(root.Context, Resource.Attribute.selectableItemBackground);
                    addClassButton.SetImageDrawable(ContextCompat.GetDrawable(root.Context, Android.Resource.Drawable.IcInputAdd));
                    if (Android.OS.Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                    {
                        addClassButton.ImageTintList = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { new Color(255, 255, 255) });
                    }
                    addClassButton.Click += AddClassButton_Click;

                    _mainScreenView._classAddButtonReference = new WeakReference <View>(addClassButton);
                    layoutClassesHeaderAndAddButton.AddView(addClassButton);



                    linearLayout.AddView(layoutClassesHeaderAndAddButton);


                    LinearLayout classesViewGroup = new LinearLayout(root.Context)
                    {
                        Orientation      = Orientation.Vertical,
                        LayoutParameters = new LinearLayout.LayoutParams(
                            LinearLayout.LayoutParams.MatchParent,
                            LinearLayout.LayoutParams.WrapContent),
                        Visibility = ViewStates.Gone
                    };

                    _itemsWrapperClasses = new ItemsControlWrapper(classesViewGroup)
                    {
                        ItemsSource  = _mainScreenView.ViewModel.Classes,
                        ItemTemplate = new CustomDataTemplate <ViewItemClass>(_mainScreenView.CreateClassMenuItem)
                    };

                    _mainScreenView._classesViewGroupReference = new WeakReference <View>(classesViewGroup);

                    linearLayout.AddView(classesViewGroup);

                    View = linearLayout;
                }

                else
                {
                    View = textView;
                }

                UpdateIsSelected();
            }
Exemple #7
0
 private View CreateMenuItem(ViewGroup root, NavigationManager.MainMenuSelections mainMenuSelection)
 {
     return(new MenuItemCreator(root, mainMenuSelection, this).View);
 }
 public static string GetStringMenuItem(NavigationManager.MainMenuSelections menuItem)
 {
     return(GetString("MainMenuItem_" + menuItem));
 }