Open pabermod opened 8 years ago
I managed to do it when a button is clicked, by creating public properties for the DoubleAnimation
and the StoryBoard
.
Then in the click event of a button:
private void Button_Click(object sender, RoutedEventArgs e)
{
rotaryWheelDemo.Storyboard.Stop();
Random Rnd = new Random();
int Selected = Rnd.Next(0, rotaryWheelDemo.Slices.Count() - 1);
int Angle = 360 / rotaryWheelDemo.Slices.Count();
rotaryWheelDemo.Animation.To = 360 * 4 + rotaryWheelDemo.Angle + Angle * Selected;
rotaryWheelDemo.Animation.Duration = new Duration(new TimeSpan(0, 0, 3));
CircleEase CE = new CircleEase();
CE.EasingMode = EasingMode.EaseOut;
rotaryWheelDemo.Animation.EasingFunction = CE;
rotaryWheelDemo.Storyboard.Begin();
}
This could easily be made by creating a public method in RotatoryWheel
like public void Rotate(double Degrees, TimeSpan duration)
But what i also wnat to do is what I stated in my previous post, I don't see the way to achieve it
Edited: Added random selection angle
The layoutRoot_ManipulationCompleted
is where the callback happens when a user releases the wheel. During that callback, you can adjust the animation to make it longer or to change the final position.
The problem in the layoutRoot_ManipulationComplete
event is that ir fires when wheel rotation stops, not when when I release the finger/mouse.
I almost achieved by doing this:
private void layoutRoot_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
storyBoard.Stop();
Angle = QuadrantHelper.GetAngle(e.Position, RenderSize);
// If it is not and intertia is occuring, stop the manipulation.
if (e.IsInertial)
{
//Animation.From = Angle;
Animation.To = 360 * 4 + Angle;
Animation.Duration = new Windows.UI.Xaml.Duration(new System.TimeSpan(0, 0, 3));
CircleEase CE = new CircleEase();
CE.EasingMode = EasingMode.EaseOut;
Animation.EasingFunction = CE;
e.Complete();
storyBoard.Begin();
}
}
and commenting the content of the layoutRoot_ManipulationCompleted
event
It works good the first time, but the successive times I spin it if I start dragging the Wheel slowly it suddeny changes the angle like 90º and then speens correctly
Cheers
Try this for rotating wheel programmatically https://github.com/ersuman/RotaryWheel/tree/ersuman-patch-1
Hi,
Thanks for this great Rotatory Wheel. I'm trying to rotate the wheel programmatically (on a UWP App), so when a user rotates it manually it keeps spinning for a defined amount of time
I'm kind of new to Manipulation...
How can I achieve it?
Thanks