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

WPF Alien Sokoban

, 16 Jun 2008 BSD
A fun implementation of the game Sokoban, written to showcase some features of WPF, C# 3.0, Expression Design, and Visual Studio 2008.
wpfsokobandemo.zip
WpfSokobanDemo
Levels
Level000.skbn
Level000.skbn.test
Level001.skbn
Level002.skbn
Level003.skbn
Level004.skbn
Level005.skbn
Level006.skbn
Level007.skbn
Level008.skbn
Level009.skbn
Level010.skbn
Level011.skbn
Level012.skbn
Level013.skbn
Level014.skbn
Level015.skbn
Level016.skbn
Level017.skbn
Level018.skbn
Level019.skbn
Level020.skbn
Level021.skbn
Level022.skbn
Level023.skbn
Level024.skbn
Level025.skbn
Level026.skbn
Level027.skbn
Level028.skbn
Level029.skbn
Level030.skbn
Level031.skbn
Level032.skbn
Level033.skbn
Level034.skbn
Level035.skbn
Level036.skbn
Level037.skbn
Level038.skbn
Level039.skbn
Level040.skbn
Level041.skbn
Level042.skbn
Level043.skbn
Level044.skbn
Level045.skbn
Level046.skbn
Level047.skbn
Level048.skbn
Level049.skbn
Level050.skbn
Source
WpfSokoban
Audio
DingDong.wav
DullClapping.mp3
Footstep.wav
Intro.wav
Movement_from_NEO_Sounds.mp3
TreasurePush.wav
bin
Release
Orpius.Sokoban.dll
WpfSokoban.exe
WpfSokoban.vshost.exe
WpfSokoban.vshost.exe.manifest
Images
AppIcon.ico
AppIcon.png
wpfsokobansource.zip
WpfSokobanSource
Graphics
Banner.design
Cell.design
Levels
Level000.skbn
Level000.skbn.test
Level001.skbn
Level002.skbn
Level003.skbn
Level004.skbn
Level005.skbn
Level006.skbn
Level007.skbn
Level008.skbn
Level009.skbn
Level010.skbn
Level011.skbn
Level012.skbn
Level013.skbn
Level014.skbn
Level015.skbn
Level016.skbn
Level017.skbn
Level018.skbn
Level019.skbn
Level020.skbn
Level021.skbn
Level022.skbn
Level023.skbn
Level024.skbn
Level025.skbn
Level026.skbn
Level027.skbn
Level028.skbn
Level029.skbn
Level030.skbn
Level031.skbn
Level032.skbn
Level033.skbn
Level034.skbn
Level035.skbn
Level036.skbn
Level037.skbn
Level038.skbn
Level039.skbn
Level040.skbn
Level041.skbn
Level042.skbn
Level043.skbn
Level044.skbn
Level045.skbn
Level046.skbn
Level047.skbn
Level048.skbn
Level049.skbn
Level050.skbn
Source
Orpius.Sokoban
bin
CellContents
Cells
Commands
Diagrams
All.cd
GameLevelCell.cd
Properties
WpfSokoban
Audio
DingDong.wav
DullClapping.mp3
Footstep.wav
Intro.wav
Movement_from_NEO_Sounds.mp3
TreasurePush.wav
bin
Commands
Controls
Images
AppIcon.ico
AppIcon.png
Properties
Settings.settings
ResourceDictionaries
WpfSokoban.csproj.user
wpfsokoban_1_1.zip
WpfSokoban
Documentation
Graphics
BackgroundControl.design
Banner.design
Cell.design
Levels
Level000.skbn
Level000.skbn.test
Level001.skbn
Level002.skbn
Level003.skbn
Level004.skbn
Level005.skbn
Level006.skbn
Level007.skbn
Level008.skbn
Level009.skbn
Level010.skbn
Level011.skbn
Level012.skbn
Level013.skbn
Level014.skbn
Level015.skbn
Level016.skbn
Level017.skbn
Level018.skbn
Level019.skbn
Level020.skbn
Level021.skbn
Level022.skbn
Level023.skbn
Level024.skbn
Level025.skbn
Level026.skbn
Level027.skbn
Level028.skbn
Level029.skbn
Level030.skbn
Level031.skbn
Level032.skbn
Level033.skbn
Level034.skbn
Level035.skbn
Level036.skbn
Level037.skbn
Level038.skbn
Level039.skbn
Level040.skbn
Level041.skbn
Level042.skbn
Level043.skbn
Level044.skbn
Level045.skbn
Level046.skbn
Level047.skbn
Level048.skbn
Level049.skbn
Level050.skbn
Source
Orpius.Sokoban
bin
Debug
Release
CellContents
Actor
Cells
Commands
Diagrams
All.cd
GameLevelCell.cd
Moves
PathFinders
Properties
WpfSokoban
Audio
DingDong.wav
DullClapping.mp3
Footstep.wav
Intro.wav
Movement_from_NEO_Sounds.mp3
TreasurePush.wav
bin
Debug
WpfSokoban.exe
WpfSokoban.vshost.exe
Release
WpfSokoban.exe
WpfSokoban.vshost.exe
WpfSokoban.vshost.exe.manifest
Commands
Controls
Images
AppIcon.ico
AppIcon.png
Properties
Settings.settings
ResourceDictionaries
#region File and License Information
/*
<File>
	<Copyright>Copyright © 2007, Daniel Vaughan. All rights reserved.</Copyright>
	<License see="prj:///Documentation/License.txt"/>
	<Owner Name="Daniel Vaughan" Email="dbvaughan@gmail.com"/>
	<CreationDate>2008-06-09 15:39:47Z</CreationDate>
	<LastSubmissionDate>$Date: $</LastSubmissionDate>
	<Version>$Revision: $</Version>
</File>
*/
#endregion

using System.ComponentModel;
using System.Threading;

namespace Orpius.Sokoban
{
	/// <summary>
	/// Base implementaion for all content within
	/// the <see cref="Level"/> grid.
	/// </summary>
	public abstract class LevelContentBase : INotifyPropertyChanged
	{
		SynchronizationContext context = SynchronizationContext.Current;

		/// <summary>
		/// Gets or sets the context used to post 
		/// to the main UI thread.
		/// </summary>
		/// <value>The context used to post to the main
		/// UI thread.</value>
		protected SynchronizationContext Context
		{
			get
			{
				if (context == null)
				{
					context = SynchronizationContext.Current;
				}
				return context;
			}
			set
			{
				context = value;
			}
		}

		protected LevelContentBase()
		{
		}

		#region PropertyChangedEventHandler
		event PropertyChangedEventHandler propertyChanged;

		/// <summary>
		/// Occurs when a property value changes.
		/// </summary>
		public event PropertyChangedEventHandler PropertyChanged
		{
			add
			{
				propertyChanged += value;
			}
			remove
			{
				propertyChanged -= value;
			}
		}

		/// <summary>
		/// Raises the <see cref="E:PropertyChanged"/> event.
		/// </summary>
		/// <param name="e">The <see cref="System.ComponentModel.PropertyChangedEventArgs"/> 
		/// instance containing the event data.</param>
		void OnPropertyChanged(PropertyChangedEventArgs e)
		{
			if (propertyChanged != null)
			{
				propertyChanged(this, e);
			}
		}

		/// <summary>
		/// Raises the <see cref="E:PropertyChanged"/> event.
		/// </summary>
		/// <param name="property">The name of the property that changed.</param>
		protected void OnPropertyChanged(string property)
		{
			/* We use the SynchronizationContext context
			 to ensure that we don't cause an InvalidOperationException
			 if the property change triggers something occuring
			 in the main UI thread. */
			if (context == null)
			{
				OnPropertyChanged(new PropertyChangedEventArgs(property));
			}
			else
			{
				context.Send(delegate
				{
					OnPropertyChanged(new PropertyChangedEventArgs(property));
				}, null);
			}
		}
		#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 BSD License

Share

About the Author

Daniel Vaughan
President Outcoder
Switzerland Switzerland
Daniel Vaughan is a Microsoft MVP and co-founder of Outcoder, a Swiss software and consulting company dedicated to creating best-of-breed user experiences and leading-edge back-end solutions, using the Microsoft stack of technologies--in particular WPF, WinRT, Windows Phone, and also Xamarin.Forms.
 
Daniel is the author of Windows Phone 8 Unleashed and Windows Phone 7.5 Unleashed, both published by SAMS.
 
Daniel is the developer behind several acclaimed Windows Phone apps including Surfy, Intellicam, and Splashbox; and is the creator of a number of popular open-source projects including Calcium SDK, and Clog.
 
Would you like Daniel to bring value to your organisation? Please contact

Daniel's Blog | MVP profile | Follow on Twitter
 
Windows Phone Experts
Follow on   Twitter   Google+   LinkedIn

| Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 16 Jun 2008
Article Copyright 2007 by Daniel Vaughan
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid