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!";
 }
Exemple #3
0
 public virtual void OnFocusLost(Control c)
 {
     HasFocus = false;
     if(FocusLost != null)
         FocusLost(c);
 }
Exemple #4
0
 public virtual void OnFocusGain(Control c)
 {
     HasFocus = true;
     if(FocusGain != null)
         FocusGain(c);
 }
Exemple #5
0
 public virtual void OnFocusChange(Control c)
 {
     if (c.Equals(this))
         OnFocusGain(this);
     else
         OnFocusLost(c);
 }
Exemple #6
0
 public override void OnFocusLost(Control c)
 {
     base.OnFocusLost(c);
 }
Exemple #7
0
 public override void OnFocusGain(Control c)
 {
     base.OnFocusGain(c);
 }
 public bool TestMouseCollision(Control c)
 {
     return c.Body.BoundingRect.Contains(new Point((int)MouseService.Cursor.Position.X, (int)MouseService.Cursor.Position.Y));
 }
        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);
        }
        public void OnFocusChange(Control c)
        {
            if (FocusChanged != null)
                FocusChanged(c);

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