当前位置: 首页>>代码示例>>C#>>正文


C# Storyboard.GetCurrentState方法代码示例

本文整理汇总了C#中System.Windows.Media.Animation.Storyboard.GetCurrentState方法的典型用法代码示例。如果您正苦于以下问题:C# Storyboard.GetCurrentState方法的具体用法?C# Storyboard.GetCurrentState怎么用?C# Storyboard.GetCurrentState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Animation.Storyboard的用法示例。


在下文中一共展示了Storyboard.GetCurrentState方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: stackPanel_Loaded

        private void stackPanel_Loaded(object sender, RoutedEventArgs e)
        {
            var storyboard = new Storyboard();
            var animation = new DoubleAnimation
            {
                From = 900,
                To = 0,
                Duration = new Duration(TimeSpan.FromMilliseconds(500))
            };

            var translatTransform = new TranslateTransform
            {
                Y = 900
            };

            var panel = (StackPanel)sender;
            panel.RenderTransform = translatTransform;

            Storyboard.SetTarget(animation, translatTransform);
            Storyboard.SetTargetProperty(animation, new PropertyPath("Y"));
            storyboard.Children.Add(animation);
            storyboard.Begin();
            
            while (storyboard.GetCurrentState() == ClockState.Active)
            {
            }
            
            this.Storyboard2.Begin();
        }
开发者ID:shegg77,项目名称:Messaging,代码行数:29,代码来源:SignIn.xaml.cs

示例2: Navigate

        private void Navigate(Directory newDirectory, Storyboard outAnimation, Storyboard inAnimation)
        {
            outAnimation.Begin();

            _curr = newDirectory;
            Action BeginInAnimation = () =>
            {
                inAnimation.Begin();
            };
            Action WorkToDo = () =>
            {
                UpdateItems(BeginInAnimation);
            };
            outAnimation.Completed += new EventHandler((object sender, EventArgs e) =>
            {
                UpdateView(BeginInAnimation);
            });
            Action<object, RunWorkerCompletedEventArgs> RunWorkerCompletedEvent = (object sender, RunWorkerCompletedEventArgs e) =>
            {
                if (outAnimation.GetCurrentState() != ClockState.Active)
                {
                    UpdateView(BeginInAnimation);
                    outAnimation.Stop();
                }
            };

            CreateNewBackgroundWorker(WorkToDo, RunWorkerCompletedEvent)
                .RunWorkerAsync();
        }
开发者ID:hmehart,项目名称:Notepad,代码行数:29,代码来源:Listings.xaml.cs

示例3: BeginNameNotAttached2

		public void BeginNameNotAttached2 ()
		{
			Storyboard sb = new Storyboard ();
			Storyboard.SetTargetName (sb, "TARGET");
			sb.Begin ();
			Assert.AreEqual (ClockState.Stopped, sb.GetCurrentState ());
			Enqueue (() => sb.Stop ());
			EnqueueTestComplete ();
		}
开发者ID:snorp,项目名称:moon,代码行数:9,代码来源:StoryboardTest.cs

示例4: BeginNoNameOrTarget

		public void BeginNoNameOrTarget ()
		{
			Storyboard sb = new Storyboard ();
			sb.Begin ();
			Assert.AreEqual (ClockState.Stopped, sb.GetCurrentState ());
			Enqueue (() => sb.Stop ());
			EnqueueTestComplete ();
		}
开发者ID:snorp,项目名称:moon,代码行数:8,代码来源:StoryboardTest.cs

示例5: AddRunningStoryboard

		public void AddRunningStoryboard ()
		{
			Canvas c = CreateStoryboard ();
			Storyboard sb = (Storyboard) c.Resources ["Storyboard"];

			Storyboard child = new Storyboard { };
			DoubleAnimation animation = new DoubleAnimation { Duration = new Duration (TimeSpan.FromSeconds (1)), From = 10, To = 100 };
			Storyboard.SetTargetName (animation, "A");
			Storyboard.SetTargetProperty (animation, new PropertyPath ("Width"));
			child.Children.Add (animation);

			TestPanel.Children.Add (c);

			Enqueue (delegate {
				// The TargetName isn't resolvable
				Assert.Throws<InvalidOperationException>(() => child.Begin (), "TargetName should not be resolvable");
				Storyboard.SetTargetName (animation, null);
				Assert.Throws<InvalidOperationException> (() => child.Begin (), "Target is not specified");
				Storyboard.SetTarget (child, c.Children [0]);
				child.Begin ();
			});

			Enqueue (delegate {
				Assert.AreEqual (ClockState.Active, child.GetCurrentState (), "Active");
				sb.Children.Add (child);
			});

			Enqueue (delegate {
				Assert.AreEqual (ClockState.Active, child.GetCurrentState (), "#1");
				Assert.AreEqual (ClockState.Stopped, sb.GetCurrentState (), "#2");
			});

			Enqueue (() => { TestPanel.Children.Clear (); TestPanel.Resources.Clear (); });
			EnqueueTestComplete ();
		}
开发者ID:snorp,项目名称:moon,代码行数:35,代码来源:StoryboardTest.cs

示例6: CompletedEvent

		public void CompletedEvent ()
		{
			List<ManualResetEvent> handles = new List<ManualResetEvent> ();
			Canvas c = new Canvas ();

			Storyboard sb = new Storyboard { Duration = new Duration (TimeSpan.FromMilliseconds (500)) };
			ManualResetEvent handle = new ManualResetEvent (false);
			handles.Add (handle);
			bool fillingWhenComplete = false;
			bool childrenNotSignalled = true;
			sb.Completed += delegate {
				fillingWhenComplete = ClockState.Filling == sb.GetCurrentState ();
				//Assert.AreEqual (sb.Duration.TimeSpan, sb.GetCurrentTime (), "#1");
				for (int i = 1; i < handles.Count; i++)
					if (handles [i].WaitOne (0))
						childrenNotSignalled = false;
				handle.Set ();
			};
			c.Resources.Add ("Storyboard", sb);

			for (int i = 0; i < 2; i++) {
				DoubleAnimation anim = new DoubleAnimation { From = 10, To = 50 };
				Storyboard child = new Storyboard { Duration = new Duration (TimeSpan.FromMilliseconds (500)) };

				ManualResetEvent h = new ManualResetEvent (false);
				handles.Add (h);
				child.Completed += delegate {
					int count = i;
					h.Set ();
					Assert.AreEqual (ClockState.Filling, child.GetCurrentState (), "#4." + count);
				};

				child.Children.Add (anim);
				sb.Children.Add (child);
				Rectangle r = new Rectangle ();
				Storyboard.SetTarget (child, r);
				Storyboard.SetTargetProperty (child, new PropertyPath ("Width"));
				c.Children.Add (r);
			}

			TestPanel.Children.Add (c);

			Enqueue (() => handles.ForEach (h => h.Reset ()));
			Enqueue (() => sb.Begin ());
			Enqueue (() => {
				Assert.AreEqual ( ClockState.Active, sb.GetCurrentState (), "#1");
			});
			EnqueueConditional (() => handle.WaitOne (0));
			Enqueue (() => Assert.IsTrue (fillingWhenComplete, "Filling when complete"));
			Enqueue (() => Assert.IsTrue (childrenNotSignalled, "Children not signalled"));
			Enqueue (() => {
				for (int i = 0; i < handles.Count; i++)
					Assert.IsTrue (handles [i].WaitOne (10), "#2");
			});
			Enqueue (() => Assert.AreEqual (ClockState.Filling, sb.GetCurrentState (), "Still filling"));

			Enqueue (() => { TestPanel.Children.Clear (); TestPanel.Resources.Clear (); });
			EnqueueTestComplete ();
		}
开发者ID:snorp,项目名称:moon,代码行数:59,代码来源:StoryboardTest.cs

示例7: ManagedVisualStates2

		public void ManagedVisualStates2 ()
		{
			Rectangle r = new Rectangle { Width = 0 };
			VisualStateGroup group = new VisualStateGroup ();
			group.SetValue (FrameworkElement.NameProperty, "group2");

			// Create the first visual state
			VisualState vstate = new VisualState ();
			vstate.SetValue (FrameworkElement.NameProperty, "state2");

			DoubleAnimation anim = new DoubleAnimation { From = 100, To = 200, Duration = TimeSpan.FromSeconds (1) };
			Storyboard.SetTarget (anim, r);
			Storyboard.SetTargetProperty (anim, new PropertyPath ("Width"));

			Storyboard sb = new Storyboard ();
			sb.Children.Add (anim);
			vstate.Storyboard = sb;
			group.States.Add (vstate);

			// Create the second visual state
			VisualState vstate2 = new VisualState ();
			vstate2.SetValue (FrameworkElement.NameProperty, "state3");

			Storyboard sb2 = new Storyboard ();
			Storyboard.SetTarget (sb2, r);
			Storyboard.SetTargetProperty (sb2, new PropertyPath ("Width"));

			vstate2.Storyboard = sb2;
			group.States.Add (vstate2);

			// Ensure that the values reset correct
			Enqueue (() => TestPanel.Children.Add (r));
			Enqueue (() => VisualStateManager.GetVisualStateGroups ((FrameworkElement)TestPanel.Parent).Add (group));
			Enqueue (() => Assert.AreEqual(0, r.Width, "#1"));
			Enqueue (() => Assert.IsTrue (VisualStateManager.GoToState (TestPage, "state2", false), "#2"));
			Enqueue (() => Assert.IsGreater (99, r.Width, "#3"));
			Enqueue (() => Assert.IsTrue (VisualStateManager.GoToState (TestPage, "state3", false), "#3"));
			Enqueue (() => Assert.AreEqual (0, r.Width, "#4"));
			Enqueue (() => Assert.AreEqual (ClockState.Filling, sb2.GetCurrentState (), "#5"));
			Enqueue (() => TestPanel.Children.Clear ());
			Enqueue (() => VisualStateManager.GetVisualStateGroups (TestPage).Clear ());
			EnqueueTestComplete();
		}
开发者ID:kangaroo,项目名称:moon,代码行数:43,代码来源:VisualStateManagerTest.cs


注:本文中的System.Windows.Media.Animation.Storyboard.GetCurrentState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。