Beispiel #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="value">Field value</param>
        public FieldView(GameModel.FieldValue value)
        {
            InitializeBackground();
            InitializeTextBlock();
            InitializeContentBox();

            UpdateField(value);
        }
 /// <summary>
 /// Method returns color correlated to the value of the field
 /// </summary>
 /// <param name="value">Field value</param>
 /// <returns>Color</returns>
 public static Color GetColorForFieldBackground(GameModel.FieldValue value)
 {
     if (value == GameModel.GameBoardModel.emptyField)
     {
         return(availableFieldBackgroundColors[0]);
     }
     else if (GameModel.GameBoardModel.firstFieldValue <= value &&
              value <= GameModel.GameBoardModel.lastFieldValue)
     {
         int index = (int)Math.Log((int)value, 2);
         return(availableFieldBackgroundColors[index]);
     }
     else
     {
         return(availableFieldBackgroundColors[availableFieldBackgroundColors.Count - 1]);
     }
 }
Beispiel #3
0
 /////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Method updates field value at specified position
 /// </summary>
 /// <param name="value">new field value</param>
 /// <param name="x">x-position</param>
 /// <param name="y">y-position</param>
 private void UpdateField(GameModel.FieldValue value, int x, int y)
 {
     fields[x, y].UpdateField(value);
 }
Beispiel #4
0
 /////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Method sets field value
 /// </summary>
 /// <param name="value"></param>
 private void SetFieldValue(GameModel.FieldValue value)
 {
     this.fieldValue = value;
 }
Beispiel #5
0
 /// <summary>
 /// Method updates value of field
 /// </summary>
 /// <param name="value">New value</param>
 public void UpdateField(GameModel.FieldValue value)
 {
     SetFieldValue(value);
     FillBackground();
     UpdateTextBlock();
 }