Пример #1
0
        public void back()
        {
            MenuComponentComposite f = this.currentSelectedComponent.getFather();

            if (f == this.menu.getChild(0))
            {
                return;
            }
            try
            {
                if (!this.currentSelectedComponent.isExpanded() && this.currentSelectedComponent.hasFocus())
                {
                    this.currentSelectedComponent.setFocus(false);
                    f.getFather().setExpanded(true);
                    f.getFather().validate();
                    f.setExpanded(false);
                    this.currentSelectedComponent = f;
                    this.currentComponentIndex    = this.componentsTraversedIndexes.Pop();
                    f.setFocus(true);
                    //  this.currentSelectedComponent.setFocus(true);
                }
                else
                {
                    //should be a container expanded without child
                    //   Console.WriteLine("Closing container expanded without child");
                    this.currentSelectedComponent.setFocus(true);
                    this.currentSelectedComponent.setExpanded(false);
                    f.setExpanded(true);
                    f.validate();
                }
            }
            catch (NoChildException e)
            {
            }
        }
Пример #2
0
        public MenuTraverser(RootMenuItem menu)
        {
            this.menu = menu;
            //    this.OnMenuActionCachedHandler = (action) => this.OnMenuAction(action);

            this.componentsTraversedIndexes = new Stack <int>();
            MenuComponentComposite firstChild = this.menu.getChild(0);


            if (firstChild != null)
            {
                firstChild.setExpanded(true);

                this.currentSelectedComponent = firstChild;
                this.currentComponentIndex    = 0;

                MenuComponentComposite c = firstChild.getChild(0);
                //first child of the first child of root is a container with at least one child. Start traversing from here
                if (c != null)
                {
                    this.componentsTraversedIndexes.Push(this.currentComponentIndex);
                    this.currentSelectedComponent = c;
                    this.currentSelectedComponent.setFocus(true);
                    this.currentComponentIndex = 0;
                    // this.currentSelectedComponent.setExpanded(true);
                }
                else
                {
                    firstChild.setFocus(true);
                }
            }
            else
            {
                //that's pretty strange. a root component should always have a child component
            }
        }
Пример #3
0
        private void goForward()
        {
            MenuComponentComposite t = this.currentSelectedComponent;

            MenuComponentComposite c = this.currentSelectedComponent.getChild(0);

            MenuComponentComposite containerChild = this.currentSelectedComponent;

            containerChild.setExpanded(true);
            // containerChild.setBounds(this.currentSelectedComponent.getFather().getBounds());
            MenuComponentComposite father = this.currentSelectedComponent.getFather();

            father.setExpanded(false);

            if (c != null)
            {
                //current component is a container..can go forward
                //if (c != this.menu)
                this.currentSelectedComponent.setFocus(false);

                //  Console.WriteLine("container child " + containerChild.);

                //close the previousopen container



                this.componentsTraversedIndexes.Push(this.currentComponentIndex);
                this.currentSelectedComponent = c;
                this.currentComponentIndex    = 0;
                this.currentSelectedComponent.setFocus(true);
            }
            else
            {
                //  this.currentSelectedComponent.setFocus(false);
            }
        }