private void SetFocusToSection(FocusSection focusSection) { Console.WriteLine("SetFocusToSection:{0}", focusSection.ToString("G")); if (currentlyFocusedSection != focusSection) { // Focus out actions switch (currentlyFocusedSection) { case FocusSection.OptionsBar: { bottomBar.UnFocused(); break; } case FocusSection.CatagoryPane: { Animation scaleAnimation = new Animation(); scaleAnimation.SetDuration(.2f); scaleAnimation.AnimateTo(categoryPane, "Scale", new Size(1.0f, 1.0f, 1.0f)); scaleAnimation.Play(); break; } default: { break; } } currentlyFocusedSection = focusSection; // focus in actions switch (currentlyFocusedSection) { case FocusSection.OptionsBar: { bottomBar.Focused(); break; } case FocusSection.CatagoryPane: { Animation scaleAnimation = new Animation(); scaleAnimation.SetDuration(.2f); scaleAnimation.AnimateTo(categoryPane, "Scale", new Size(1.1f, 1.1f, 1.0f)); scaleAnimation.Play(); break; } default: { break; } } } }
private void InitializeMainScreen() { View mainScreen = new View(); var layout = new LinearLayout(); layout.LinearOrientation = LinearLayout.Orientation.Vertical; mainScreen.Layout = layout; mainScreen.WidthSpecification = LayoutParamPolicies.MatchParent; mainScreen.HeightSpecification = LayoutParamPolicies.MatchParent; mainScreen.Background = CreateGradientVisual().OutputVisualMap; TextLabel title = new TextLabel("Food Shopper"); title.PointSize = 58; title.Margin = new Extents(10, 10, 5, 5); mainScreen.Add(title); // Create Centre Content Pane, scrolling content relevant to categories. ContentPane contentPane = new ContentPane(); contentPane.Name = "centreContentPane"; mainScreen.Add(contentPane); scrollingContent = new Scrolling.ScrollingView(); // Create content before adding to ScrollingView currentCategoryIndex = 2; CreateContent0(); CreateContent1(); CreateContent2(); CreateContent3(); CreateContent4(); contentPane.Add(scrollingContent); scrollingContent.Add(fruitContentGroup); // Create Category Pane, scrolling categories at lower part of screen. scrollingCategories = new Scrolling.ScrollingView(); mainScreen.Add(scrollingCategories); categoryPane = new CategoryPane(); categoryPane.Name = "categoryPane"; scrollingCategories.Add(categoryPane); // Create Persistant bottom bar, settings and checkout bottomBar = new PersistantBar(); bottomBar.Name = "bottomBar"; mainScreen.Add(bottomBar); CreateClusterButtons(); Window.Instance.Add(mainScreen); keyboardFocusManager = FocusManager.Instance; keyboardFocusManager.PreFocusChange += OnKeyboardPreFocusChangeSignal; keyboardFocusManager.FocusChanged += CategoryChanged; keyboardFocusManager.SetAsFocusGroup(scrollingCategories, true); keyboardFocusManager.SetAsFocusGroup(scrollingContent, true); FocusManager.Instance.SetCurrentFocusView(scrollingCategories); Window.Instance.KeyEvent += WindowKeyEvent; currentlyFocusedSection = FocusSection.TitleBar; nextFocusSection = FocusSection.CatagoryPane; SetFocusToSection(nextFocusSection); }
/// Move focus to the section below current focus. Does not wrap; private void FocusSectionDown() { nextFocusSection = (FocusSection)Math.Min((int)(currentlyFocusedSection + 1), Enum.GetNames(typeof(FocusSection)).Length - 1); SetFocusToSection(nextFocusSection); }
/// Move focus to the section above current focus. Does not wrap. /// Uses FocusSection, upmost section is 0 private void FocusSectionUp() { nextFocusSection = (FocusSection)Math.Max((int)(currentlyFocusedSection - 1), 0); SetFocusToSection(nextFocusSection); }