private void OnAttributeChanged(object sender, AttributeChangedEventArgs e)
        {
            AttributePanel pnl = sender as AttributePanel;

            // The attribute panels sends the requested newValue in the event args. Need to validate that the
            // user has the points left to be able to make this change.
            int pointCost = this.GetPointCost(e.OldValue, e.NewValue);

            if ((this.AttributePoints + pointCost) < 0)
            {
                // Cancel the request.
                e.Cancel  = true;
                e.Message = "Not enough Attribute Points to change this Attribute.";
            }
            else if ((this.AttributePoints + pointCost) > MaxAttributePoints)
            {
                // Cancel the request.
                e.Cancel  = true;
                e.Message = "Not enough Attribute Points to increase this Attribute.";
            }
            else
            {
                // Accept the request, increment or decrement the points.
                this.AttributePoints += pointCost;
            }

            lblPoints.Text = this.AttributePoints.ToString();

            if (!e.Cancel)
            {
                // Bubble up the event.
                this.AttributeChanged(pnl, new AttributeChangedEventArgs(e.Name, e.OldValue, e.NewValue + pnl.AttributeMinimum));
            }
        }
 private void ResetMinValue(AttributePanel pnl, int minValue)
 {
     if (pnl.AttributeValue >= pnl.AttributeMinimum)
     {
         pnl.AttributeValue -= pnl.AttributeMinimum;
     }
     pnl.AttributeMinimum = minValue;
     pnl.AttributeValue  += pnl.AttributeMinimum;
     pnl.RefreshView();
 }