Click here to Skip to main content
15,896,557 members
Articles / Programming Languages / C#

Article Two: Building a UI Platform in C# - Testing via UI Animation

,
Rate me:
Please Sign up or sign in to vote.
4.20/5 (7 votes)
3 Mar 20055 min read 51.4K   927   33  
Describes an implementation of UI animation for the support of Test-Driven Development.
// (c) 2003-2005 Datron, Inc.  All rights reserved. http://www.blix.net

using System;

namespace freeBlix
{
	public abstract class DragBot
	{
		#region Fields
		private Control _Control;
		private ControlSystem _ControlSystem;
		private DragMouseTrap _DragTrap;
		private Tweak _Tweak;
		#endregion

		#region DragBot(aControl)
		public DragBot(Control aControl)
		{
			_Control = aControl;
		
			_DragTrap = new DragMouseTrap(aControl);
			_DragTrap.DragCycle.Enter += new DragCycleEnterDelegate(EnterHandler);
			_DragTrap.DragCycle.Leave += new DragCycleLeaveDelegate(LeaveHandler);
			_DragTrap.DragCycle.Start += new DragCycleStartDelegate(StartHandler);
			_DragTrap.DragCycle.Drag += new DragCycleDragDelegate(DragHandler);
			_DragTrap.DragCycle.End += new DragCycleEndDelegate(EndHandler);
			_DragTrap.DragCycle.Cancel += new DragCycleCancelDelegate(CancelHandler);
		}
		#endregion		

		#region EnterHandler
		private void EnterHandler()
		{
			Enter();
		}	
		#endregion
		#region LeaveHandler
		private void LeaveHandler()
		{
			Leave();
		}	
		#endregion
		#region StartHandler
		private void StartHandler()
		{
			ControlSystem.DragManifest.Start(this);
		}	
		#endregion
		#region DragHandler
		private void DragHandler(Point aCumulativeDelta)
		{
			if (_Tweak != null)
				_Tweak.Apply(aCumulativeDelta);

			ControlSystem.DragManifest.Drag(this, aCumulativeDelta);				
		}
		#endregion
		#region EndHandler
		private void EndHandler()
		{
			ControlSystem.DragManifest.End(this);
		}
		#endregion
		#region CancelHandler
		private void CancelHandler()
		{
			ControlSystem.DragManifest.Cancel(this);
		}
		#endregion

		#region Enter
		public virtual void Enter()
		{
		}	
		#endregion
		#region Leave
		public virtual void Leave()
		{
		}	
		#endregion

		#region Start
		public virtual void Start()
		{
		}	
		#endregion
		#region Land
		public virtual void Land(DropSite aDropSite)
		{
		}	
		#endregion
		#region Drag
		public virtual void Drag(Point aCumulativeDelta)
		{
		}
		#endregion		
		#region End
		public virtual void End()
		{
		}
		#endregion
		#region Cancel
		public virtual void Cancel()
		{
		}
		#endregion			
		
		#region Tweak
		public Tweak Tweak
		{
			get
			{
				return _Tweak;
			}
			set
			{
				_Tweak = value;
			}
		}
		#endregion
		#region Control
		public Control Control
		{
			get
			{
				return _Control;
			}
		}
		#endregion
		#region ControlSystem
		public ControlSystem ControlSystem
		{
			get
			{
				return _ControlSystem;
			}
			set
			{
				if (_ControlSystem != null)
					_ControlSystem.Mouse.RemoveTrap(_DragTrap);

				_ControlSystem = value;

				if (_ControlSystem != null)
					_ControlSystem.Mouse.AddTrap(_DragTrap);
			}
		}
		#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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
CEO Sagerion, LLC
United States United States
I read About Face by Alan Cooper in 1995 and immediately recognized it as a founding document for the future of software. I also recognized we had a long, long way to go - and yes, even with the advent of iOS, we are still not there yet.

At my company, Sagerion (say-jair-ee-on), we can take a look at your planned or existing software and suggest ways of making it better - lots better. We can develop down-to-the-pixel blueprints showing exactly what our suggestions mean. We can help manage on-going development to make sure the top-notch user-experience we've suggested really does get built. Now, honestly, how often have you ever seen all those things happen?

You may or may not already have great development going on - but what does that matter if you don't have great design driving it?

Feel free to contact me at tom@sagerion.com, I would love to hear about your next ground-breaking project.

Written By
Founder Sagerion LLC
United States United States
www.filoshare.com
-It is a fresh and free distributed source control system.

Comments and Discussions