Would be nice to have a "StartRotate() / StopRotate()" method that allowed rotation to be controlled from code. Or did I miss something *really* obvious??
Attached the class for anyone interested...the thread class provides "runOneLoop" which is invoked every ThreadLoopSleep intervals. Starting / stopping the thread is handled in the base thread class. But it's easy enough to build these things just using CLR threads now...
/// <summary>
/// Spin the cube...
/// </summary>
internal class Spinner : Abr.CodeLibrary.Utils.Threading.BaseThread
{
// from caller
private System.Threading.SynchronizationContext _currentContext;
private Telerik.Windows.Controls.RadCube _cube;
private Abr.CodeLibrary.Utils.Logger.LoggerHolder _lh;
/// <summary>
/// Create object
/// </summary>
/// <param name="currentContext">UI context for updating</param>
/// <param name="cube">The cube to spin</param>
/// <param name="lh">Logging facilities</param>
public Spinner(
System.Threading.SynchronizationContext currentContext,
Telerik.Windows.Controls.RadCube cube,
Abr.CodeLibrary.Utils.Logger.LoggerHolder lh
)
: base("Spinner", lh.LoggerOrNull)
{
_currentContext = currentContext;
_cube = cube;
_lh = lh;
// not sure about this
this.ThreadLoopSleep = (int)(300 / _cube.RotateSpeed);
} //ctor
/// <summary>
/// Start the spinning
/// </summary>
public void Start() {
// start the spinner
Abr.CodeLibrary.Utils.Threading.ThreadStartArgs tsa = new Abr.CodeLibrary.Utils.Threading.ThreadStartArgs();
Start(tsa);
} //Start
/// <summary>
/// Run the spinner
/// </summary>
protected override void threadRunOneLoop()
{
Abr.CodeLibrary.Sl.Utils.Global.UpdateUIThread(
_currentContext,
new System.Threading.SendOrPostCallback(
delegate(object state)
{
if (_cube.SelectedIndex >= 5)
{
_cube.SelectedIndex = 0;
}
else
{
_cube.SelectedIndex += 1;
} //if
}),
_lh
);
} //threadRunOneLoop
} //Spinner