Skip to content

Instantly share code, notes, and snippets.

@ertugrulozcan
Last active November 24, 2015 21:19
Show Gist options
  • Save ertugrulozcan/1832483bb9aea62f14d7 to your computer and use it in GitHub Desktop.
Save ertugrulozcan/1832483bb9aea62f14d7 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
namespace Snake.Components
{
public sealed partial class Pixel : UserControl, INotifyPropertyChanged
{
/// <summary>
/// Kutu rengi
/// </summary>
public SolidColorBrush PixelColor
{
get
{
switch(this.PixelType)
{
case PixelTypes.Empty : return this.EMPTY_BOX;
case PixelTypes.Snake : return this.SNAKE_BOX;
case PixelTypes.Food : return this.FOOD_BOX;
case PixelTypes.Wall : return this.WALL_BOX;
default : return this.EMPTY_BOX;
}
}
}
private readonly SolidColorBrush EMPTY_BOX = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
private readonly SolidColorBrush SNAKE_BOX = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));
private readonly SolidColorBrush FOOD_BOX = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
private readonly SolidColorBrush WALL_BOX = new SolidColorBrush(Color.FromArgb(50, 255, 255, 255));
private PixelTypes pixelType;
public PixelTypes PixelType
{
get
{
return this.pixelType;
}
set
{
this.pixelType = value;
RaisePropertyChanged("PixelColor");
}
}
/// <summary>
/// Constructor
/// </summary>
public Pixel()
{
this.DataContext = this;
this.InitializeComponent();
this.PixelType = PixelTypes.Empty;
}
#region NotifyPropertyChanged Metodu
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(String propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (null != handler)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}
public enum PixelTypes
{
Empty, Snake, Food, Wall
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment