Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Full Screen WPF Application with a Low-Level Keyboard Hook

, 26 Nov 2008
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 triangle.
    /// </summary>
    class Triangle : IShape
    {
        #region Private Members

        PointCollection _points;
        Polygon _primitive;
        TranslateTransform _translateTransform;

        #endregion

        #region IShape Members

        public PointCollection Points
        {
            get { return _points; }
        }

        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 Triangle()
        {
            _points = new PointCollection(3);
            _points.Add(new Point(0, 2));
            _points.Add(new Point(1, 0));
            _points.Add(new Point(2, 2));

            _translateTransform = new TranslateTransform(0, 0);

            _primitive = new Polygon();
            _primitive.Points = _points;
            _primitive.RenderTransform = _translateTransform;
            _primitive.Stretch = Stretch.Fill;
            _primitive.Stroke = Brushes.Black;
            _primitive.StrokeThickness = 2;
        }

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

        public Triangle(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.

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