Click here to Skip to main content
12,297,215 members (63,455 online)
Click here to Skip to main content

Stats

81K views
2.4K downloads
48 bookmarked
Posted

Full Screen WPF Application with a Low-Level Keyboard Hook

, 26 Nov 2008 CPOL
This application displays shapes of random sizes and colors. It's perfect for babies and toddlers who love to sit and press away at the keyboard.
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;

namespace ShapeShow.Library
{
    /// <summary>
    /// Represents a circle or ellipse.
    /// </summary>
    class Circle : IShape
    {
        #region Private Members

        Ellipse _primitive;
        TranslateTransform _translateTransform;

        #endregion

        #region IShape Members

        public PointCollection Points
        {
            get { return null; }
        }

        public Double Height
        {
            get { return _primitive.Height; }
            set { _primitive.Height = value; }
        }

        public Double Width
        {
            get { return _primitive.Width; }
            set { _primitive.Width = value; }
        }

        public Double Top
        {
            get { return _translateTransform.Y; }
            set { _translateTransform.Y = value; }
        }

        public Double Left
        {
            get { return _translateTransform.X; }
            set { _translateTransform.X = value; }
        }

        public Brush FillBrush
        {
            get { return _primitive.Fill; }
            set { _primitive.Fill = value; }
        }

        public Double OutlineWidth
        {
            get { return _primitive.StrokeThickness; }
            set { _primitive.StrokeThickness = value; }
        }

        public Brush OutlineBrush
        {

            get { return _primitive.Stroke; }
            set { _primitive.Stroke = value; }
        }

        public UIElement UIElement
        {
            get { return _primitive; }
        }

        #endregion

        #region Constructors

        public Circle()
        {
            _translateTransform = new TranslateTransform(0, 0);

            _primitive = new Ellipse();
            _primitive.Height = 1;
            _primitive.Width = 1;
            _primitive.RenderTransform = _translateTransform;
            _primitive.Stretch = Stretch.Fill;
            _primitive.Stroke = Brushes.Black;
            _primitive.StrokeThickness = 2;
        }

        public Circle(Double height, Double width) : this()
        {
            Height = height;
            Width = width;
        }

        public Circle(Double height, Double width, Double top, Double left) : this(height, width)
        {
            Top = top;
            Left = left;
        }

        #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)

Share

About the Author

Barry Dorman
Software Developer
United States United States
Barry Dorman is a software engineer from the Birmingham, AL area. His primary focus is ASP.NET. Barry graduated with a BS in Electrical Engineering from The University of Alabama at Birmingham in 2006. Since then, he has kept himself busy working in the healthcare industry.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160525.2 | Last Updated 26 Nov 2008
Article Copyright 2008 by Barry Dorman
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid