Click here to Skip to main content
15,896,727 members
Articles / Desktop Programming / WPF

Solitaire and Spider Solitaire for WPF

Rate me:
Please Sign up or sign in to vote.
4.97/5 (89 votes)
26 Feb 2013CPOL24 min read 173.2K   15.5K   160  
Create Solitaire and Spider Solitaire for WPF, step by step.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SolitaireGames
{
    

    public class CardStackControl : ItemsControl
    {
        static CardStackControl()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(CardStackControl), new FrameworkPropertyMetadata(typeof(CardStackControl)));
        }
        
        private static readonly DependencyProperty FaceDownOffsetProperty =
          DependencyProperty.Register("FaceDownOffset", typeof(double), typeof(CardStackControl));

        public double FaceDownOffset
        {
            get { return (double)GetValue(FaceDownOffsetProperty); }
            set { SetValue(FaceDownOffsetProperty, value); }
        }

        private static readonly DependencyProperty FaceUpOffsetProperty =
          DependencyProperty.Register("FaceUpOffset", typeof(double), typeof(CardStackControl));

        public double FaceUpOffset
        {
            get { return (double)GetValue(FaceUpOffsetProperty); }
            set { SetValue(FaceUpOffsetProperty, value); }
        }

        
        private static readonly DependencyProperty OrientationProperty =
          DependencyProperty.Register("Orientation", typeof(Orientation), typeof(CardStackControl),
          new PropertyMetadata(Orientation.Horizontal));

        public Orientation Orientation
        {
            get { return (Orientation)GetValue(OrientationProperty); }
            set { SetValue(OrientationProperty, value); }
        }

        private static readonly DependencyProperty OffsetModeProperty =
          DependencyProperty.Register("OffsetMode", typeof(OffsetMode), typeof(CardStackControl),
          new PropertyMetadata(OffsetMode.EveryCard));

        public OffsetMode OffsetMode
        {
            get { return (OffsetMode)GetValue(OffsetModeProperty); }
            set { SetValue(OffsetModeProperty, value); }
        }

        private static readonly DependencyProperty NValueProperty =
          DependencyProperty.Register("NValue", typeof(int), typeof(CardStackControl),
          new PropertyMetadata(1));

        public int NValue
        {
            get { return (int)GetValue(NValueProperty); }
            set { SetValue(NValueProperty, value); }
        }
    }
}

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
Software Developer
United Kingdom United Kingdom
Follow my blog at www.dwmkerr.com and find out about my charity at www.childrenshomesnepal.org.

Comments and Discussions