Click here to Skip to main content
15,881,092 members
Articles / Web Development / HTML

MVC Bricks for ASP.net

Rate me:
Please Sign up or sign in to vote.
4.96/5 (120 votes)
4 May 2011CPOL11 min read 218.2K   6.4K   155  
Learn how to create a simple game using ASP.net MVC, jQuery, State Machine and CSS3 gradients
using System;
using System.Collections.Generic;
using System.Text;
using MVCBricks.Core.Shapes;
using System.Drawing;

namespace MVCBricks.Core
{
    public class Brick : IBrick
    {
        private double x = 0;
        private double y = 0;
        private double left = 0;
        private double top = 0;
        private double leftMargin = 4;
        private double topMargin = 4;
        private double brickSize = 20;
        private Color color = Color.White;


        public Brick(double x, double y, Color color)
        {
            this.x = x;
            this.y = y;
            this.color = color;
        }

        public double X
        {
            get { return x; }
            set
            {
                x = value;
                Left = x * brickSize + leftMargin;
            }
        }

        public double Y
        {
            get { return y; }
            set
            {
                y = value;
                Top = y * brickSize + topMargin;
            }
        }

        public Color Color
        {
            get
            {
                return color;
            }
            set
            {
                color = value;
                OnPropertyChanged("Color");
            }
        }

        public double Left
        {
            get { return left; }
            set
            {
                left = value;
                PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs("Left"));
                OnPropertyChanged("Left");
            }
        }

        public double Top
        {
            get { return top; }
            set
            {
                top = value;
                PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs("Top"));
                OnPropertyChanged("Top");
            }
        }

        #region INotifyPropertyChanged Members
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this,
                    new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }
        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Instructor / Trainer Alura Cursos Online
Brazil Brazil

Comments and Discussions