Пример #1
0
        public virtual void Update(Microsoft.Xna.Framework.Vector2 position)
        {
            position = Screen.RelationToPosition(position-offset);
            var pos = Mouse.GetState();
            if (pos.X > position.X && pos.X < position.X + Width
                &&
                pos.Y > position.Y && pos.Y < position.Y + Height)
            {
                if (focus != this)
                {
                    if (MouseEnter != null)
                        MouseEnter(this, new EventArgs());
                }
                focus = this;

                if (pos.LeftButton == ButtonState.Pressed
                    && msButState != pos.LeftButton)
                {
                    if (MouseClick != null)
                        MouseClick(this, new EventArgs());
                }
                msButState = pos.LeftButton;
            }
            else
            {
                if (focus == this)
                {
                    focus = null;
                    if (MouseLeave != null)
                        MouseLeave(this, new EventArgs());
                }
            }
        }
Пример #2
0
 public UIElement Add(UIElement elm)
 {
     children.Add(elm);
     return children.Last();
 }