示例#1
0
        public virtual void Update(GameTime gameTime)
        {
            if (autoArrangeChildren && invalidLayout)
            {
                if (orientation == NodeOrientation.Vertical)
                {
                    double newHeight = this.Height / Children.Count;
                    for (int i = 0; i < Children.Count; i++)
                    {
                        Children[i].VerticalAlignment       = VerticalAlignment.Top;
                        Children[i].HorizontalAlignment     = HorizontalAlignment.Left;
                        Children[i].PercentageX             = false;
                        Children[i].PercentageY             = false;
                        Children[i].PercentageHeight        = false;
                        Children[i].PercentageWidth         = false;
                        Children[i].DesiredHeight           = newHeight;
                        Children[i].DesiredRelativePosition = new Point(0, (int)Math.Round(i * newHeight));
                        Children[i].DesiredWidth            = this.Width;
                    }
                }
                else
                {
                    double newWidth = this.Width / Children.Count;
                    for (int i = 0; i < Children.Count; i++)
                    {
                        Children[i].VerticalAlignment       = VerticalAlignment.Top;
                        Children[i].HorizontalAlignment     = HorizontalAlignment.Left;
                        Children[i].PercentageX             = false;
                        Children[i].PercentageY             = false;
                        Children[i].PercentageHeight        = false;
                        Children[i].PercentageWidth         = false;
                        Children[i].DesiredWidth            = newWidth;
                        Children[i].DesiredRelativePosition = new Point((int)Math.Round(i * newWidth), 0);
                        Children[i].DesiredHeight           = this.Height;
                    }
                }
                invalidLayout = false;
            }

            foreach (MenuEvent ev in eventsToTrigger)
            {
                ev.Trigger(this);
            }
            eventsToTrigger.Clear();
            foreach (BaseAnimation anim in animations.Values)
            {
                if (anim.Enabled)
                {
                    if (anim is ColorAnimation)
                    {
                        ColorAnimation canim = anim as ColorAnimation;
                        canim.Tick(gameTime);
                    }
                    else if (anim is DoubleAnimation)
                    {
                        DoubleAnimation danim = anim as DoubleAnimation;
                        danim.Tick(gameTime);
                    }
                }
                else
                {
                    animationsToRemove.Add(anim);
                }
            }
            foreach (BaseAnimation anim in animationsToRemove)
            {
                animations.Remove(anim.Name);
            }
            animationsToRemove.Clear();
        }