Пример #1
0
        public void AddControl(Control c)
        {
            DestroyEvent += c.Destroy;

            //Resize the collection to the appropriate size
            if (c.TabPosition.X >= MaxTabX && c.TabPosition.Y >= MaxTabY)
                ResizeControlCollection(c.TabPosition.X + 1, c.TabPosition.Y + 1);
            else if (c.TabPosition.X >= MaxTabX)
                ResizeControlCollection(c.TabPosition.X + 1, MaxTabY + 1);
            else if (c.TabPosition.Y >= MaxTabY)
                ResizeControlCollection(MaxTabX + 1, c.TabPosition.Y + 1);

            //Find out if anything is at that space
            if (_controls[c.TabPosition.X, c.TabPosition.Y] != null)
            {
                //We have to move the control to the slot to the right of it.
                //This will move evry control in that row because setting the
                //Control.TabPosition property triggers an AddControl and RemoveControl.
                //Essentially, this is recurrsive so don't worry about it.
                _controls[c.TabPosition.X, c.TabPosition.Y].TabPosition = new Point(c.TabPosition.X + 1, c.TabPosition.Y);
            }

            FocusChanged += c.OnFocusChange;
            _controls[c.TabPosition.X, c.TabPosition.Y] = c;

            EntityGame.Log.Write("Control " + c.Name + " added", this, Alert.Info);
        }
 public void OnSelected(Control c)
 {
     _actionLabelText = "Control " + c.Name + " was clicked!";
 }
Пример #3
0
 public virtual void OnFocusLost(Control c)
 {
     HasFocus = false;
     if(FocusLost != null)
         FocusLost(c);
 }
Пример #4
0
 public virtual void OnFocusGain(Control c)
 {
     HasFocus = true;
     if(FocusGain != null)
         FocusGain(c);
 }
Пример #5
0
 public virtual void OnFocusChange(Control c)
 {
     if (c.Equals(this))
         OnFocusGain(this);
     else
         OnFocusLost(c);
 }
Пример #6
0
 public override void OnFocusLost(Control c)
 {
     base.OnFocusLost(c);
 }
Пример #7
0
 public override void OnFocusGain(Control c)
 {
     base.OnFocusGain(c);
 }
Пример #8
0
 public bool TestMouseCollision(Control c)
 {
     return c.Body.BoundingRect.Contains(new Point((int)MouseService.Cursor.Position.X, (int)MouseService.Cursor.Position.Y));
 }
Пример #9
0
        public void RemoveControl(Control c)
        {
            FocusChanged -= c.OnFocusChange;
            if (_controls[c.TabPosition.X, c.TabPosition.Y] != null)
            {
                _controls[c.TabPosition.X, c.TabPosition.Y].Destroy();
                _controls[c.TabPosition.X, c.TabPosition.Y] = null;
            }

            c.Destroy(this);
        }
Пример #10
0
        public void OnFocusChange(Control c)
        {
            if (FocusChanged != null)
                FocusChanged(c);

            EntityGame.Log.Write("Focus changed to " + c.Name, this, Alert.Trivial);
        }
Пример #11
0
 public override void OnFocusLost(Control c)
 {
     base.OnFocusLost(c);
     Render.Color = Color;
 }
Пример #12
0
 public override void OnFocusGain(Control c)
 {
     base.OnFocusGain(c);
     Render.Color = SelectedColor;
 }