Esempio n. 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)
            {
            }
        }
Esempio n. 2
0
        override public MenuComponentComposite removeChildComponent(int index)
        {
            MenuComponentComposite c = this.getChild(index);

            if (c != null)
            {
                this.removeChildComponent(c);
                c.setFather(null);
            }
            return(c);
        }
Esempio n. 3
0
        override public void addChildComponent(MenuComponentComposite c)
        {
            //   Console.WriteLine("list add child component " + this.children.Count);
            //var name = c.getName();
            //float W = this.font.MeasureString(name).X;
            Rectangle b = new Rectangle(this.leftMargin, this.firstChildDeltaY + this.bounds.Y + (this.childHeight * this.children.Count),
                                        this.bounds.Width - this.leftMargin, this.childHeight);

            //  this.bounds.Width - t, this.childHeight);
            c.setBounds(b);
            c.setExpandedBounds(this.expandedBounds);
            base.addChildComponent(c);
        }
Esempio n. 4
0
 new public void setFocus(bool state)
 {
     if (this.expanded)
     {
         MenuComponentComposite c = this.getChild(0);
         if (c != null && state == true)
         {
             c.setFocus(true);
         }
     }
     else
     {
         base.setFocus(state);
     }
 }
Esempio n. 5
0
        public void down()
        {
            MenuComponentComposite f = this.currentSelectedComponent.getFather();

            if (f != null)
            {
                this.currentSelectedComponent.setFocus(false);
                IList <MenuComponentComposite> sibling = f.getAllChildren();
                this.currentComponentIndex    = (this.currentComponentIndex + 1) % (sibling.Count);
                this.currentSelectedComponent = sibling[this.currentComponentIndex];
                this.currentSelectedComponent.setFocus(true);

                if (Menu.soundEnabled)
                {
                    MenuSoundManager.playMoveDown();
                }
            }
        }
Esempio n. 6
0
        override public void addChildComponent(MenuComponentComposite c)
        {
            //  Console.WriteLine("Root addChildComponent ");
            if (this.children.Count > 0)
            {
                return; // max one child
            }
            int x = (this.bounds.Width * this.childDeltaX) / 100;
            int y = (this.bounds.Height * this.childDeltaY) / 100;


            Rectangle childBounds = new Rectangle(this.bounds.X + x, this.bounds.Y + y,
                                                  //this.bounds.Width - x *2, this.bounds.Height - y *2);
                                                  this.bounds.Width, this.bounds.Height - y * 2);

            c.setBounds(childBounds);
            c.setExpandedBounds(this.bounds);
            base.addChildComponent(c);
        }
Esempio n. 7
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
            }
        }
Esempio n. 8
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);
            }
        }
Esempio n. 9
0
 public void setFather(MenuComponentComposite father)
 {
     this.father = father;
 }
Esempio n. 10
0
 override public void removeChildComponent(MenuComponentComposite c)
 {
     this.children.Remove(c);
     c.setFather(null);
 }
Esempio n. 11
0
 override public void addChildComponent(MenuComponentComposite c)
 {
     c.setFather(this);
     this.children.Add(c);
 }
Esempio n. 12
0
 override public void removeChildComponent(MenuComponentComposite c)
 {
     throw new NoChildException();
 }
Esempio n. 13
0
 public abstract void addChildComponent(MenuComponentComposite c);
Esempio n. 14
0
 public abstract void removeChildComponent(MenuComponentComposite c);