From c7f91cc6fa7a9f7470ddeb3ce1fb66654e3e2db6 Mon Sep 17 00:00:00 2001 From: h82258652 Date: Thu, 14 Jul 2016 13:31:02 +0800 Subject: [PATCH 1/5] should share storyboard is paused between all ControlStoryboardAction instances. --- .../Media/ControlStoryboardAction.cs | 278 +++++++++--------- 1 file changed, 142 insertions(+), 136 deletions(-) diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs index 8edbfaee..37b7559b 100644 --- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs +++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs @@ -2,139 +2,145 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace Microsoft.Xaml.Interactions.Media { - using Interactivity; - using Windows.UI.Xaml; - using Windows.UI.Xaml.Media.Animation; - - /// - /// An action that will change the state of the specified when executed. - /// - public sealed class ControlStoryboardAction : DependencyObject, IAction - { - /// - /// Identifies the dependency property. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly DependencyProperty ControlStoryboardOptionProperty = DependencyProperty.Register( - "ControlStoryboardOption", - typeof(ControlStoryboardOption), - typeof(ControlStoryboardAction), - new PropertyMetadata(ControlStoryboardOption.Play)); - - /// - /// Identifies the dependency property. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly DependencyProperty StoryboardProperty = DependencyProperty.Register( - "Storyboard", - typeof(Storyboard), - typeof(ControlStoryboardAction), - new PropertyMetadata(null, new PropertyChangedCallback(ControlStoryboardAction.OnStoryboardChanged))); - - private bool isPaused; - - /// - /// Gets or sets the action to execute on the . This is a dependency property. - /// - public ControlStoryboardOption ControlStoryboardOption - { - get - { - return (ControlStoryboardOption)this.GetValue(ControlStoryboardAction.ControlStoryboardOptionProperty); - } - set - { - this.SetValue(ControlStoryboardAction.ControlStoryboardOptionProperty, value); - } - } - - /// - /// Gets or sets the targeted . This is a dependency property. - /// - public Storyboard Storyboard - { - get - { - return (Storyboard)this.GetValue(ControlStoryboardAction.StoryboardProperty); - } - set - { - this.SetValue(ControlStoryboardAction.StoryboardProperty, value); - } - } - - /// - /// Executes the action. - /// - /// The that is passed to the action by the behavior. Generally this is or a target object. - /// The value of this parameter is determined by the caller. - /// True if the specified operation is invoked successfully; else false. - public object Execute(object sender, object parameter) - { - if (this.Storyboard == null) - { - return false; - } - - switch (this.ControlStoryboardOption) - { - case ControlStoryboardOption.Play: - this.Storyboard.Begin(); - break; - - case ControlStoryboardOption.Stop: - this.Storyboard.Stop(); - break; - - case ControlStoryboardOption.TogglePlayPause: - { - ClockState currentState = this.Storyboard.GetCurrentState(); - - if (currentState == ClockState.Stopped) - { - this.isPaused = false; - this.Storyboard.Begin(); - } - else if (this.isPaused) - { - this.isPaused = false; - this.Storyboard.Resume(); - } - else - { - this.isPaused = true; - this.Storyboard.Pause(); - } - } - - break; - - case ControlStoryboardOption.Pause: - this.Storyboard.Pause(); - break; - - case ControlStoryboardOption.Resume: - this.Storyboard.Resume(); - break; - - case ControlStoryboardOption.SkipToFill: - this.Storyboard.SkipToFill(); - break; - - default: - return false; - } - - return true; - } - - private static void OnStoryboardChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) - { - ControlStoryboardAction action = sender as ControlStoryboardAction; - if (action != null) - { - action.isPaused = false; - } - } - } -} + using Interactivity; + using Windows.UI.Xaml; + using Windows.UI.Xaml.Media.Animation; + + /// + /// An action that will change the state of the specified when executed. + /// + public sealed class ControlStoryboardAction : DependencyObject, IAction + { + /// + /// Identifies the dependency property. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly DependencyProperty ControlStoryboardOptionProperty = DependencyProperty.Register( + "ControlStoryboardOption", + typeof(ControlStoryboardOption), + typeof(ControlStoryboardAction), + new PropertyMetadata(ControlStoryboardOption.Play)); + + /// + /// Identifies the dependency property. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly DependencyProperty StoryboardProperty = DependencyProperty.Register( + "Storyboard", + typeof(Storyboard), + typeof(ControlStoryboardAction), + new PropertyMetadata(null, new PropertyChangedCallback(ControlStoryboardAction.OnStoryboardChanged))); + + private static readonly System.Collections.Generic.Dictionary _storyboardIsPaused = new System.Collections.Generic.Dictionary(); + + /// + /// Gets or sets the action to execute on the . This is a dependency property. + /// + public ControlStoryboardOption ControlStoryboardOption + { + get + { + return (ControlStoryboardOption)this.GetValue(ControlStoryboardAction.ControlStoryboardOptionProperty); + } + set + { + this.SetValue(ControlStoryboardAction.ControlStoryboardOptionProperty, value); + } + } + + /// + /// Gets or sets the targeted . This is a dependency property. + /// + public Storyboard Storyboard + { + get + { + return (Storyboard)this.GetValue(ControlStoryboardAction.StoryboardProperty); + } + set + { + this.SetValue(ControlStoryboardAction.StoryboardProperty, value); + } + } + + /// + /// Executes the action. + /// + /// The that is passed to the action by the behavior. Generally this is or a target object. + /// The value of this parameter is determined by the caller. + /// True if the specified operation is invoked successfully; else false. + public object Execute(object sender, object parameter) + { + if (this.Storyboard == null) + { + return false; + } + + switch (this.ControlStoryboardOption) + { + case ControlStoryboardOption.Play: + this.Storyboard.Begin(); + break; + + case ControlStoryboardOption.Stop: + this.Storyboard.Stop(); + break; + + case ControlStoryboardOption.TogglePlayPause: + { + ClockState currentState = this.Storyboard.GetCurrentState(); + + if (currentState == ClockState.Stopped) + { + _storyboardIsPaused[this.Storyboard] = false; + this.Storyboard.Begin(); + } + else if (_storyboardIsPaused[this.Storyboard]) + { + _storyboardIsPaused[this.Storyboard] = false; + this.Storyboard.Resume(); + } + else + { + _storyboardIsPaused[this.Storyboard] = true; + this.Storyboard.Pause(); + } + } + + break; + + case ControlStoryboardOption.Pause: + this.Storyboard.Pause(); + break; + + case ControlStoryboardOption.Resume: + this.Storyboard.Resume(); + break; + + case ControlStoryboardOption.SkipToFill: + this.Storyboard.SkipToFill(); + break; + + default: + return false; + } + + return true; + } + + private static void OnStoryboardChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) + { + Storyboard oldStoryboard = (Storyboard)args.OldValue; + if (oldStoryboard != null) + { + _storyboardIsPaused.Remove(oldStoryboard); + } + + Storyboard newStoryboard = (Storyboard)args.NewValue; + if (newStoryboard != null && _storyboardIsPaused.ContainsKey(newStoryboard) == false) + { + _storyboardIsPaused.Add(newStoryboard, true); + } + } + } +} \ No newline at end of file From d5ff83a35504ee6b69dfdb428db90552ee75147a Mon Sep 17 00:00:00 2001 From: h82258652 Date: Fri, 15 Jul 2016 08:50:54 +0800 Subject: [PATCH 2/5] Revert "should share storyboard is paused between all ControlStoryboardAction instances." This reverts commit c7f91cc6fa7a9f7470ddeb3ce1fb66654e3e2db6. --- .../Media/ControlStoryboardAction.cs | 278 +++++++++--------- 1 file changed, 136 insertions(+), 142 deletions(-) diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs index 37b7559b..8edbfaee 100644 --- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs +++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs @@ -2,145 +2,139 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace Microsoft.Xaml.Interactions.Media { - using Interactivity; - using Windows.UI.Xaml; - using Windows.UI.Xaml.Media.Animation; - - /// - /// An action that will change the state of the specified when executed. - /// - public sealed class ControlStoryboardAction : DependencyObject, IAction - { - /// - /// Identifies the dependency property. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly DependencyProperty ControlStoryboardOptionProperty = DependencyProperty.Register( - "ControlStoryboardOption", - typeof(ControlStoryboardOption), - typeof(ControlStoryboardAction), - new PropertyMetadata(ControlStoryboardOption.Play)); - - /// - /// Identifies the dependency property. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly DependencyProperty StoryboardProperty = DependencyProperty.Register( - "Storyboard", - typeof(Storyboard), - typeof(ControlStoryboardAction), - new PropertyMetadata(null, new PropertyChangedCallback(ControlStoryboardAction.OnStoryboardChanged))); - - private static readonly System.Collections.Generic.Dictionary _storyboardIsPaused = new System.Collections.Generic.Dictionary(); - - /// - /// Gets or sets the action to execute on the . This is a dependency property. - /// - public ControlStoryboardOption ControlStoryboardOption - { - get - { - return (ControlStoryboardOption)this.GetValue(ControlStoryboardAction.ControlStoryboardOptionProperty); - } - set - { - this.SetValue(ControlStoryboardAction.ControlStoryboardOptionProperty, value); - } - } - - /// - /// Gets or sets the targeted . This is a dependency property. - /// - public Storyboard Storyboard - { - get - { - return (Storyboard)this.GetValue(ControlStoryboardAction.StoryboardProperty); - } - set - { - this.SetValue(ControlStoryboardAction.StoryboardProperty, value); - } - } - - /// - /// Executes the action. - /// - /// The that is passed to the action by the behavior. Generally this is or a target object. - /// The value of this parameter is determined by the caller. - /// True if the specified operation is invoked successfully; else false. - public object Execute(object sender, object parameter) - { - if (this.Storyboard == null) - { - return false; - } - - switch (this.ControlStoryboardOption) - { - case ControlStoryboardOption.Play: - this.Storyboard.Begin(); - break; - - case ControlStoryboardOption.Stop: - this.Storyboard.Stop(); - break; - - case ControlStoryboardOption.TogglePlayPause: - { - ClockState currentState = this.Storyboard.GetCurrentState(); - - if (currentState == ClockState.Stopped) - { - _storyboardIsPaused[this.Storyboard] = false; - this.Storyboard.Begin(); - } - else if (_storyboardIsPaused[this.Storyboard]) - { - _storyboardIsPaused[this.Storyboard] = false; - this.Storyboard.Resume(); - } - else - { - _storyboardIsPaused[this.Storyboard] = true; - this.Storyboard.Pause(); - } - } - - break; - - case ControlStoryboardOption.Pause: - this.Storyboard.Pause(); - break; - - case ControlStoryboardOption.Resume: - this.Storyboard.Resume(); - break; - - case ControlStoryboardOption.SkipToFill: - this.Storyboard.SkipToFill(); - break; - - default: - return false; - } - - return true; - } - - private static void OnStoryboardChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) - { - Storyboard oldStoryboard = (Storyboard)args.OldValue; - if (oldStoryboard != null) - { - _storyboardIsPaused.Remove(oldStoryboard); - } - - Storyboard newStoryboard = (Storyboard)args.NewValue; - if (newStoryboard != null && _storyboardIsPaused.ContainsKey(newStoryboard) == false) - { - _storyboardIsPaused.Add(newStoryboard, true); - } - } - } -} \ No newline at end of file + using Interactivity; + using Windows.UI.Xaml; + using Windows.UI.Xaml.Media.Animation; + + /// + /// An action that will change the state of the specified when executed. + /// + public sealed class ControlStoryboardAction : DependencyObject, IAction + { + /// + /// Identifies the dependency property. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly DependencyProperty ControlStoryboardOptionProperty = DependencyProperty.Register( + "ControlStoryboardOption", + typeof(ControlStoryboardOption), + typeof(ControlStoryboardAction), + new PropertyMetadata(ControlStoryboardOption.Play)); + + /// + /// Identifies the dependency property. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly DependencyProperty StoryboardProperty = DependencyProperty.Register( + "Storyboard", + typeof(Storyboard), + typeof(ControlStoryboardAction), + new PropertyMetadata(null, new PropertyChangedCallback(ControlStoryboardAction.OnStoryboardChanged))); + + private bool isPaused; + + /// + /// Gets or sets the action to execute on the . This is a dependency property. + /// + public ControlStoryboardOption ControlStoryboardOption + { + get + { + return (ControlStoryboardOption)this.GetValue(ControlStoryboardAction.ControlStoryboardOptionProperty); + } + set + { + this.SetValue(ControlStoryboardAction.ControlStoryboardOptionProperty, value); + } + } + + /// + /// Gets or sets the targeted . This is a dependency property. + /// + public Storyboard Storyboard + { + get + { + return (Storyboard)this.GetValue(ControlStoryboardAction.StoryboardProperty); + } + set + { + this.SetValue(ControlStoryboardAction.StoryboardProperty, value); + } + } + + /// + /// Executes the action. + /// + /// The that is passed to the action by the behavior. Generally this is or a target object. + /// The value of this parameter is determined by the caller. + /// True if the specified operation is invoked successfully; else false. + public object Execute(object sender, object parameter) + { + if (this.Storyboard == null) + { + return false; + } + + switch (this.ControlStoryboardOption) + { + case ControlStoryboardOption.Play: + this.Storyboard.Begin(); + break; + + case ControlStoryboardOption.Stop: + this.Storyboard.Stop(); + break; + + case ControlStoryboardOption.TogglePlayPause: + { + ClockState currentState = this.Storyboard.GetCurrentState(); + + if (currentState == ClockState.Stopped) + { + this.isPaused = false; + this.Storyboard.Begin(); + } + else if (this.isPaused) + { + this.isPaused = false; + this.Storyboard.Resume(); + } + else + { + this.isPaused = true; + this.Storyboard.Pause(); + } + } + + break; + + case ControlStoryboardOption.Pause: + this.Storyboard.Pause(); + break; + + case ControlStoryboardOption.Resume: + this.Storyboard.Resume(); + break; + + case ControlStoryboardOption.SkipToFill: + this.Storyboard.SkipToFill(); + break; + + default: + return false; + } + + return true; + } + + private static void OnStoryboardChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) + { + ControlStoryboardAction action = sender as ControlStoryboardAction; + if (action != null) + { + action.isPaused = false; + } + } + } +} From 8ec17404bc559a4ad5afebc8b9d6295f9ed5f385 Mon Sep 17 00:00:00 2001 From: h82258652 Date: Fri, 15 Jul 2016 08:56:44 +0800 Subject: [PATCH 3/5] use attached property to share Storyboard is paused between all ControlStoryboardAction instances. --- .../Media/ControlStoryboardAction.cs | 271 +++++++++--------- 1 file changed, 136 insertions(+), 135 deletions(-) diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs index 8edbfaee..ce5ea249 100644 --- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs +++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs @@ -2,139 +2,140 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace Microsoft.Xaml.Interactions.Media { - using Interactivity; - using Windows.UI.Xaml; - using Windows.UI.Xaml.Media.Animation; - - /// - /// An action that will change the state of the specified when executed. - /// - public sealed class ControlStoryboardAction : DependencyObject, IAction - { - /// - /// Identifies the dependency property. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly DependencyProperty ControlStoryboardOptionProperty = DependencyProperty.Register( - "ControlStoryboardOption", - typeof(ControlStoryboardOption), - typeof(ControlStoryboardAction), - new PropertyMetadata(ControlStoryboardOption.Play)); - - /// - /// Identifies the dependency property. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly DependencyProperty StoryboardProperty = DependencyProperty.Register( - "Storyboard", - typeof(Storyboard), - typeof(ControlStoryboardAction), - new PropertyMetadata(null, new PropertyChangedCallback(ControlStoryboardAction.OnStoryboardChanged))); - - private bool isPaused; - - /// - /// Gets or sets the action to execute on the . This is a dependency property. - /// - public ControlStoryboardOption ControlStoryboardOption - { - get - { - return (ControlStoryboardOption)this.GetValue(ControlStoryboardAction.ControlStoryboardOptionProperty); - } - set - { - this.SetValue(ControlStoryboardAction.ControlStoryboardOptionProperty, value); - } - } - - /// - /// Gets or sets the targeted . This is a dependency property. - /// - public Storyboard Storyboard - { - get - { - return (Storyboard)this.GetValue(ControlStoryboardAction.StoryboardProperty); - } - set - { - this.SetValue(ControlStoryboardAction.StoryboardProperty, value); - } - } - - /// - /// Executes the action. - /// - /// The that is passed to the action by the behavior. Generally this is or a target object. - /// The value of this parameter is determined by the caller. - /// True if the specified operation is invoked successfully; else false. - public object Execute(object sender, object parameter) - { - if (this.Storyboard == null) - { - return false; - } - - switch (this.ControlStoryboardOption) - { - case ControlStoryboardOption.Play: - this.Storyboard.Begin(); - break; - - case ControlStoryboardOption.Stop: - this.Storyboard.Stop(); - break; - - case ControlStoryboardOption.TogglePlayPause: - { - ClockState currentState = this.Storyboard.GetCurrentState(); - - if (currentState == ClockState.Stopped) - { - this.isPaused = false; - this.Storyboard.Begin(); - } - else if (this.isPaused) - { - this.isPaused = false; - this.Storyboard.Resume(); - } - else - { - this.isPaused = true; - this.Storyboard.Pause(); - } - } - - break; - - case ControlStoryboardOption.Pause: - this.Storyboard.Pause(); - break; - - case ControlStoryboardOption.Resume: - this.Storyboard.Resume(); - break; - - case ControlStoryboardOption.SkipToFill: - this.Storyboard.SkipToFill(); - break; - - default: - return false; - } - - return true; - } - - private static void OnStoryboardChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) - { - ControlStoryboardAction action = sender as ControlStoryboardAction; - if (action != null) - { - action.isPaused = false; - } - } - } + using Interactivity; + using Windows.UI.Xaml; + using Windows.UI.Xaml.Media.Animation; + + /// + /// An action that will change the state of the specified when executed. + /// + public sealed class ControlStoryboardAction : DependencyObject, IAction + { + /// + /// Identifies the dependency property. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly DependencyProperty ControlStoryboardOptionProperty = DependencyProperty.Register( + "ControlStoryboardOption", + typeof(ControlStoryboardOption), + typeof(ControlStoryboardAction), + new PropertyMetadata(ControlStoryboardOption.Play)); + + /// + /// Identifies the dependency property. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly DependencyProperty StoryboardProperty = DependencyProperty.Register( + "Storyboard", + typeof(Storyboard), + typeof(ControlStoryboardAction), + new PropertyMetadata(null)); + + public static readonly DependencyProperty IsPausedProperty = DependencyProperty.RegisterAttached("IsPaused", typeof(bool), typeof(ControlStoryboardAction), new PropertyMetadata(false)); + + public static void SetIsPaused(Storyboard obj, bool value) + { + obj.SetValue(IsPausedProperty, value); + } + + public static bool GetIsPaused(Storyboard obj) + { + return (bool)obj.GetValue(IsPausedProperty); + } + + /// + /// Gets or sets the action to execute on the . This is a dependency property. + /// + public ControlStoryboardOption ControlStoryboardOption + { + get + { + return (ControlStoryboardOption)this.GetValue(ControlStoryboardAction.ControlStoryboardOptionProperty); + } + set + { + this.SetValue(ControlStoryboardAction.ControlStoryboardOptionProperty, value); + } + } + + /// + /// Gets or sets the targeted . This is a dependency property. + /// + public Storyboard Storyboard + { + get + { + return (Storyboard)this.GetValue(ControlStoryboardAction.StoryboardProperty); + } + set + { + this.SetValue(ControlStoryboardAction.StoryboardProperty, value); + } + } + + /// + /// Executes the action. + /// + /// The that is passed to the action by the behavior. Generally this is or a target object. + /// The value of this parameter is determined by the caller. + /// True if the specified operation is invoked successfully; else false. + public object Execute(object sender, object parameter) + { + if (this.Storyboard == null) + { + return false; + } + + switch (this.ControlStoryboardOption) + { + case ControlStoryboardOption.Play: + this.Storyboard.Begin(); + break; + + case ControlStoryboardOption.Stop: + this.Storyboard.Stop(); + break; + + case ControlStoryboardOption.TogglePlayPause: + { + ClockState currentState = this.Storyboard.GetCurrentState(); + + if (currentState == ClockState.Stopped) + { + SetIsPaused(this.Storyboard, false); + this.Storyboard.Begin(); + } + else if (GetIsPaused(this.Storyboard)) + { + SetIsPaused(this.Storyboard, false); + this.Storyboard.Resume(); + } + else + { + SetIsPaused(this.Storyboard, true); + this.Storyboard.Pause(); + } + } + + break; + + case ControlStoryboardOption.Pause: + this.Storyboard.Pause(); + break; + + case ControlStoryboardOption.Resume: + this.Storyboard.Resume(); + break; + + case ControlStoryboardOption.SkipToFill: + this.Storyboard.SkipToFill(); + break; + + default: + return false; + } + + return true; + } + } } From a66c5acbd7155fa2fc6b4d69167170e1f586c646 Mon Sep 17 00:00:00 2001 From: h82258652 Date: Fri, 15 Jul 2016 08:59:49 +0800 Subject: [PATCH 4/5] it seems the source code use tab not space --- .../Media/ControlStoryboardAction.cs | 272 +++++++++--------- 1 file changed, 136 insertions(+), 136 deletions(-) diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs index ce5ea249..794c1e66 100644 --- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs +++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs @@ -2,140 +2,140 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace Microsoft.Xaml.Interactions.Media { - using Interactivity; - using Windows.UI.Xaml; - using Windows.UI.Xaml.Media.Animation; - - /// - /// An action that will change the state of the specified when executed. - /// - public sealed class ControlStoryboardAction : DependencyObject, IAction - { - /// - /// Identifies the dependency property. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly DependencyProperty ControlStoryboardOptionProperty = DependencyProperty.Register( - "ControlStoryboardOption", - typeof(ControlStoryboardOption), - typeof(ControlStoryboardAction), - new PropertyMetadata(ControlStoryboardOption.Play)); - - /// - /// Identifies the dependency property. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly DependencyProperty StoryboardProperty = DependencyProperty.Register( - "Storyboard", - typeof(Storyboard), - typeof(ControlStoryboardAction), - new PropertyMetadata(null)); - - public static readonly DependencyProperty IsPausedProperty = DependencyProperty.RegisterAttached("IsPaused", typeof(bool), typeof(ControlStoryboardAction), new PropertyMetadata(false)); - - public static void SetIsPaused(Storyboard obj, bool value) - { - obj.SetValue(IsPausedProperty, value); - } - - public static bool GetIsPaused(Storyboard obj) - { - return (bool)obj.GetValue(IsPausedProperty); - } - - /// - /// Gets or sets the action to execute on the . This is a dependency property. - /// - public ControlStoryboardOption ControlStoryboardOption - { - get - { - return (ControlStoryboardOption)this.GetValue(ControlStoryboardAction.ControlStoryboardOptionProperty); - } - set - { - this.SetValue(ControlStoryboardAction.ControlStoryboardOptionProperty, value); - } - } - - /// - /// Gets or sets the targeted . This is a dependency property. - /// - public Storyboard Storyboard - { - get - { - return (Storyboard)this.GetValue(ControlStoryboardAction.StoryboardProperty); - } - set - { - this.SetValue(ControlStoryboardAction.StoryboardProperty, value); - } - } - - /// - /// Executes the action. - /// - /// The that is passed to the action by the behavior. Generally this is or a target object. - /// The value of this parameter is determined by the caller. - /// True if the specified operation is invoked successfully; else false. - public object Execute(object sender, object parameter) - { - if (this.Storyboard == null) - { - return false; - } - - switch (this.ControlStoryboardOption) - { - case ControlStoryboardOption.Play: - this.Storyboard.Begin(); - break; - - case ControlStoryboardOption.Stop: - this.Storyboard.Stop(); - break; - - case ControlStoryboardOption.TogglePlayPause: - { - ClockState currentState = this.Storyboard.GetCurrentState(); - - if (currentState == ClockState.Stopped) - { - SetIsPaused(this.Storyboard, false); - this.Storyboard.Begin(); - } - else if (GetIsPaused(this.Storyboard)) - { - SetIsPaused(this.Storyboard, false); - this.Storyboard.Resume(); - } - else - { - SetIsPaused(this.Storyboard, true); - this.Storyboard.Pause(); - } - } - - break; - - case ControlStoryboardOption.Pause: - this.Storyboard.Pause(); - break; - - case ControlStoryboardOption.Resume: - this.Storyboard.Resume(); - break; - - case ControlStoryboardOption.SkipToFill: - this.Storyboard.SkipToFill(); - break; - - default: - return false; - } - - return true; - } - } + using Interactivity; + using Windows.UI.Xaml; + using Windows.UI.Xaml.Media.Animation; + + /// + /// An action that will change the state of the specified when executed. + /// + public sealed class ControlStoryboardAction : DependencyObject, IAction + { + /// + /// Identifies the dependency property. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly DependencyProperty ControlStoryboardOptionProperty = DependencyProperty.Register( + "ControlStoryboardOption", + typeof(ControlStoryboardOption), + typeof(ControlStoryboardAction), + new PropertyMetadata(ControlStoryboardOption.Play)); + + /// + /// Identifies the dependency property. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly DependencyProperty StoryboardProperty = DependencyProperty.Register( + "Storyboard", + typeof(Storyboard), + typeof(ControlStoryboardAction), + new PropertyMetadata(null)); + + public static readonly DependencyProperty IsPausedProperty = DependencyProperty.RegisterAttached("IsPaused", typeof(bool), typeof(ControlStoryboardAction), new PropertyMetadata(false)); + + public static void SetIsPaused(Storyboard obj, bool value) + { + obj.SetValue(IsPausedProperty, value); + } + + public static bool GetIsPaused(Storyboard obj) + { + return (bool)obj.GetValue(IsPausedProperty); + } + + /// + /// Gets or sets the action to execute on the . This is a dependency property. + /// + public ControlStoryboardOption ControlStoryboardOption + { + get + { + return (ControlStoryboardOption)this.GetValue(ControlStoryboardAction.ControlStoryboardOptionProperty); + } + set + { + this.SetValue(ControlStoryboardAction.ControlStoryboardOptionProperty, value); + } + } + + /// + /// Gets or sets the targeted . This is a dependency property. + /// + public Storyboard Storyboard + { + get + { + return (Storyboard)this.GetValue(ControlStoryboardAction.StoryboardProperty); + } + set + { + this.SetValue(ControlStoryboardAction.StoryboardProperty, value); + } + } + + /// + /// Executes the action. + /// + /// The that is passed to the action by the behavior. Generally this is or a target object. + /// The value of this parameter is determined by the caller. + /// True if the specified operation is invoked successfully; else false. + public object Execute(object sender, object parameter) + { + if (this.Storyboard == null) + { + return false; + } + + switch (this.ControlStoryboardOption) + { + case ControlStoryboardOption.Play: + this.Storyboard.Begin(); + break; + + case ControlStoryboardOption.Stop: + this.Storyboard.Stop(); + break; + + case ControlStoryboardOption.TogglePlayPause: + { + ClockState currentState = this.Storyboard.GetCurrentState(); + + if (currentState == ClockState.Stopped) + { + SetIsPaused(this.Storyboard, false); + this.Storyboard.Begin(); + } + else if (GetIsPaused(this.Storyboard)) + { + SetIsPaused(this.Storyboard, false); + this.Storyboard.Resume(); + } + else + { + SetIsPaused(this.Storyboard, true); + this.Storyboard.Pause(); + } + } + + break; + + case ControlStoryboardOption.Pause: + this.Storyboard.Pause(); + break; + + case ControlStoryboardOption.Resume: + this.Storyboard.Resume(); + break; + + case ControlStoryboardOption.SkipToFill: + this.Storyboard.SkipToFill(); + break; + + default: + return false; + } + + return true; + } + } } From 3047966c777a55d50d97c2dce70d619f2ea3e26b Mon Sep 17 00:00:00 2001 From: h82258652 <842053625@qq.com> Date: Wed, 28 Oct 2020 13:08:34 +0800 Subject: [PATCH 5/5] fix merge error --- .../Media/ControlStoryboardAction.cs | 281 +++++++++--------- 1 file changed, 136 insertions(+), 145 deletions(-) diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs index cc6715cd..2d64f2b6 100644 --- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs +++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Media/ControlStoryboardAction.cs @@ -2,149 +2,140 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace Microsoft.Xaml.Interactions.Media { - using Interactivity; - using Windows.UI.Xaml; - using Windows.UI.Xaml.Media.Animation; - - /// - /// An action that will change the state of the specified when executed. - /// - public sealed class ControlStoryboardAction : DependencyObject, IAction - { - /// - /// Identifies the dependency property. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly DependencyProperty ControlStoryboardOptionProperty = DependencyProperty.Register( - "ControlStoryboardOption", - typeof(ControlStoryboardOption), - typeof(ControlStoryboardAction), - new PropertyMetadata(ControlStoryboardOption.Play)); - - /// - /// Identifies the dependency property. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly DependencyProperty StoryboardProperty = DependencyProperty.Register( - "Storyboard", - typeof(Storyboard), - typeof(ControlStoryboardAction), - new PropertyMetadata(null)); - - public static readonly DependencyProperty IsPausedProperty = DependencyProperty.RegisterAttached("IsPaused", typeof(bool), typeof(ControlStoryboardAction), new PropertyMetadata(false)); - - public static void SetIsPaused(Storyboard obj, bool value) - { - obj.SetValue(IsPausedProperty, value); - } - - public static bool GetIsPaused(Storyboard obj) - { - return (bool)obj.GetValue(IsPausedProperty); - } - - /// - /// Gets or sets the action to execute on the . This is a dependency property. - /// - public ControlStoryboardOption ControlStoryboardOption - { - get - { - return (ControlStoryboardOption)this.GetValue(ControlStoryboardAction.ControlStoryboardOptionProperty); - } - set - { - this.SetValue(ControlStoryboardAction.ControlStoryboardOptionProperty, value); - } - } - - /// - /// Gets or sets the targeted . This is a dependency property. - /// - public Storyboard Storyboard - { - get - { - return (Storyboard)this.GetValue(ControlStoryboardAction.StoryboardProperty); - } - set - { - this.SetValue(ControlStoryboardAction.StoryboardProperty, value); - } - } - - /// - /// Executes the action. - /// - /// The that is passed to the action by the behavior. Generally this is or a target object. - /// The value of this parameter is determined by the caller. - /// True if the specified operation is invoked successfully; else false. - public object Execute(object sender, object parameter) - { - if (this.Storyboard == null) - { - return false; - } - - switch (this.ControlStoryboardOption) - { - case ControlStoryboardOption.Play: - this.Storyboard.Begin(); - break; - - case ControlStoryboardOption.Stop: - this.Storyboard.Stop(); - break; - - case ControlStoryboardOption.TogglePlayPause: - { - ClockState currentState = this.Storyboard.GetCurrentState(); - - if (currentState == ClockState.Stopped) - { - SetIsPaused(this.Storyboard, false); - this.Storyboard.Begin(); - } - else if (GetIsPaused(this.Storyboard)) - { - SetIsPaused(this.Storyboard, false); - this.Storyboard.Resume(); - } - else - { - SetIsPaused(this.Storyboard, true); - this.Storyboard.Pause(); - } - } - - break; - - case ControlStoryboardOption.Pause: - this.Storyboard.Pause(); - break; - - case ControlStoryboardOption.Resume: - this.Storyboard.Resume(); - break; - - case ControlStoryboardOption.SkipToFill: - this.Storyboard.SkipToFill(); - break; - - default: - return false; - } - - return true; - } - - private static void OnStoryboardChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) - { - ControlStoryboardAction action = sender as ControlStoryboardAction; - if (action != null) - { - SetIsPaused(action, false); - } - } - } + using Interactivity; + using Windows.UI.Xaml; + using Windows.UI.Xaml.Media.Animation; + + /// + /// An action that will change the state of the specified when executed. + /// + public sealed class ControlStoryboardAction : DependencyObject, IAction + { + /// + /// Identifies the dependency property. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly DependencyProperty ControlStoryboardOptionProperty = DependencyProperty.Register( + "ControlStoryboardOption", + typeof(ControlStoryboardOption), + typeof(ControlStoryboardAction), + new PropertyMetadata(ControlStoryboardOption.Play)); + + /// + /// Identifies the dependency property. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly DependencyProperty StoryboardProperty = DependencyProperty.Register( + "Storyboard", + typeof(Storyboard), + typeof(ControlStoryboardAction), + new PropertyMetadata(null)); + + public static readonly DependencyProperty IsPausedProperty = DependencyProperty.RegisterAttached("IsPaused", typeof(bool), typeof(Storyboard), new PropertyMetadata(false)); + + public static void SetIsPaused(Storyboard obj, bool value) + { + obj.SetValue(IsPausedProperty, value); + } + + public static bool GetIsPaused(Storyboard obj) + { + return (bool)obj.GetValue(IsPausedProperty); + } + + /// + /// Gets or sets the action to execute on the . This is a dependency property. + /// + public ControlStoryboardOption ControlStoryboardOption + { + get + { + return (ControlStoryboardOption)this.GetValue(ControlStoryboardAction.ControlStoryboardOptionProperty); + } + set + { + this.SetValue(ControlStoryboardAction.ControlStoryboardOptionProperty, value); + } + } + + /// + /// Gets or sets the targeted . This is a dependency property. + /// + public Storyboard Storyboard + { + get + { + return (Storyboard)this.GetValue(ControlStoryboardAction.StoryboardProperty); + } + set + { + this.SetValue(ControlStoryboardAction.StoryboardProperty, value); + } + } + + /// + /// Executes the action. + /// + /// The that is passed to the action by the behavior. Generally this is or a target object. + /// The value of this parameter is determined by the caller. + /// True if the specified operation is invoked successfully; else false. + public object Execute(object sender, object parameter) + { + if (this.Storyboard == null) + { + return false; + } + + switch (this.ControlStoryboardOption) + { + case ControlStoryboardOption.Play: + this.Storyboard.Begin(); + break; + + case ControlStoryboardOption.Stop: + this.Storyboard.Stop(); + break; + + case ControlStoryboardOption.TogglePlayPause: + { + ClockState currentState = this.Storyboard.GetCurrentState(); + + if (currentState == ClockState.Stopped) + { + SetIsPaused(this.Storyboard, false); + this.Storyboard.Begin(); + } + else if (GetIsPaused(this.Storyboard)) + { + SetIsPaused(this.Storyboard, false); + this.Storyboard.Resume(); + } + else + { + SetIsPaused(this.Storyboard, true); + this.Storyboard.Pause(); + } + } + + break; + + case ControlStoryboardOption.Pause: + this.Storyboard.Pause(); + break; + + case ControlStoryboardOption.Resume: + this.Storyboard.Resume(); + break; + + case ControlStoryboardOption.SkipToFill: + this.Storyboard.SkipToFill(); + break; + + default: + return false; + } + + return true; + } + } }