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


C# Animation.Commit方法代码示例

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


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

示例1: OnStartAnimationButtonClicked

		void OnStartAnimationButtonClicked (object sender, EventArgs e)
		{
			SetIsEnabledButtonState (false, true);

			var animation = new Animation (v => image.Scale = v, 1, 2);
			animation.Commit (this, "SimpleAnimation", 16, 2000, Easing.Linear, (v, c) => image.Scale = 1, () => true);
		}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:7,代码来源:SimpleAnimationPageCS.cs

示例2: TranslateXTo

        public static Task<bool> TranslateXTo(this VisualElement view, double x, 
                                              uint length = 250, Easing easing = null) 
        { 
            easing = easing ?? Easing.Linear; 
 	        TaskCompletionSource<bool> taskCompletionSource = new TaskCompletionSource<bool>();
            WeakReference<VisualElement> weakViewRef = new WeakReference<VisualElement>(view);

            Animation animation = new Animation(
                (value) => 
                    {
                        VisualElement viewRef;
                        if (weakViewRef.TryGetTarget(out viewRef))
                        {
                            viewRef.TranslationX = value;
                        }
                    },              // callback
                view.TranslationX,  // start
                x,                  // end
                easing);            // easing

            animation.Commit(
                view,               // owner
                "TranslateXTo",     // name
                16,                 // rate
                length,             // length
                null,               // easing 
                (finalValue, cancelled) => 
                        taskCompletionSource.SetResult(cancelled)); // finished
 			 
 	        return taskCompletionSource.Task; 
        } 
开发者ID:xia101,项目名称:xamarin-forms-book-samples,代码行数:31,代码来源:MoreViewExtensions.cs

示例3: OnButton2Clicked

        void OnButton2Clicked(object sender, EventArgs args)
        {
            Button button = (Button)sender;

            Animation animation = new Animation(v => button.Scale = v, 1, 5);
            animation.Commit(this, "Animation2", 16, 1000, Easing.Linear,
                             (v, c) => button.Scale = 1,
                             () => true);
        }
开发者ID:jenart,项目名称:xamarin-forms-book-preview-2,代码行数:9,代码来源:ConcurrentAnimationsPage.xaml.cs

示例4: BezierPathTo

        public static Task<bool> BezierPathTo(this VisualElement view, 
                                              Point pt1, Point pt2, Point pt3, 
                                              uint length = 250, 
                                              BezierTangent bezierTangent = BezierTangent.None,
                                              Easing easing = null)
        {
            easing = easing ?? Easing.Linear;
            TaskCompletionSource<bool> taskCompletionSource = new TaskCompletionSource<bool>();
            WeakReference<VisualElement> weakViewRef = new WeakReference<VisualElement>(view);

            Rectangle bounds = view.Bounds;
            BezierSpline bezierSpline = new BezierSpline(bounds.Center, pt1, pt2, pt3);

            Action<double> callback = t =>
                {
                    VisualElement viewRef;
                    if (weakViewRef.TryGetTarget(out viewRef))
                    {
                        Point tangent;
                        Point point = bezierSpline.GetPointAtFractionLength(t, out tangent);
                        double x = point.X - bounds.Width / 2;
                        double y = point.Y - bounds.Height / 2;
                        viewRef.Layout(new Rectangle(new Point(x, y), bounds.Size));

                        if (bezierTangent != BezierTangent.None)
                        {
                            viewRef.Rotation = 180 * Math.Atan2(tangent.Y, tangent.X) / Math.PI;

                            if (bezierTangent == BezierTangent.Reversed)
                            {
                                viewRef.Rotation += 180;
                            }
                        }
                    }
                };

            Animation animation = new Animation(callback, 0, 1, easing);
            animation.Commit(view, "BezierPathTo", 16, length,
                finished: (value, cancelled) => taskCompletionSource.SetResult(cancelled));

            return taskCompletionSource.Task;
        }
开发者ID:jenart,项目名称:xamarin-forms-book-preview-2,代码行数:42,代码来源:MoreViewExtensions.cs

示例5: OnStartAnimationButtonClicked

		void OnStartAnimationButtonClicked(object sender, EventArgs e)
		{
			SetIsEnabledButtonState(false, true);

			var parentAnimation = new Animation();
			var scaleUpAnimation = new Animation(v => image.Scale = v, 1, 2, Easing.SpringIn);
			var rotateAnimation = new Animation(v => image.Rotation = v, 0, 360);
			var scaleDownAnimation = new Animation(v => image.Scale = v, 2, 1, Easing.SpringOut);

			parentAnimation.Add(0, 0.5, scaleUpAnimation);
			parentAnimation.Add(0, 1, rotateAnimation);
			parentAnimation.Add(0.5, 1, scaleDownAnimation);

			parentAnimation.Commit(this, "ChildAnimations", 16, 4000, null, (v, c) => SetIsEnabledButtonState(true, false));

			//			new Animation {
			//				{ 0, 0.5, new Animation (v => image.Scale = v, 1, 2) },
			//				{ 0, 1, new Animation (v => image.Rotation = v, 0, 360) },
			//				{ 0.5, 1, new Animation (v => image.Scale = v, 2, 1) }
			//			}.Commit (this, "ChildAnimations", 16, 4000, null, (v, c) => SetIsEnabledButtonState (true, false));
		}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:21,代码来源:ChildAnimationPage.xaml.cs

示例6: TranslateYTo

        public static Task<bool> TranslateYTo(this VisualElement view, double y,
                                              uint length = 250, Easing easing = null)
        {
            easing = easing ?? Easing.Linear;
            TaskCompletionSource<bool> taskCompletionSource = new TaskCompletionSource<bool>();
            WeakReference<VisualElement> weakViewRef = new WeakReference<VisualElement>(view);

            Animation animation = new Animation((value) =>
                {
                    VisualElement viewRef;
                    if (weakViewRef.TryGetTarget(out viewRef))
                    {
                        viewRef.TranslationY = value;
                    }
                }, view.TranslationY, y, easing);

            animation.Commit(view, "TranslateYTo", 16, length, null,
                             (v, c) => taskCompletionSource.SetResult(c));

            return taskCompletionSource.Task;
        }
开发者ID:xia101,项目名称:xamarin-forms-book-samples,代码行数:21,代码来源:MoreViewExtensions.cs

示例7: OnButton1Clicked

        void OnButton1Clicked(object sender, EventArgs args)
        {
            Button button = (Button)sender;

            Animation animation = new Animation(
                (double value) =>
                    {
                        button.Scale = value;
                    },              // callback
                1,                  // start
                5,                  // end
                Easing.Linear,      // easing
                () =>
                    {
                        Debug.WriteLine("finished");
                    }               // finished (but doesn't fire in this configuration)
                );

            animation.Commit(
                this,               // owner
                "Animation1",       // name
                16,                 // rate (but has no effect here)
                1000,               // length (in milliseconds)
                Easing.Linear,
                (double finalValue, bool wasCancelled) =>
                    {
                        Debug.WriteLine("finished: {0} {1}", finalValue, wasCancelled);
                        button.Scale = 1;
                    },              // finished
                () =>
                    {
                        Debug.WriteLine("repeat");
                        return false;
                    }                // repeat
                );
        }
开发者ID:jenart,项目名称:xamarin-forms-book-preview-2,代码行数:36,代码来源:ConcurrentAnimationsPage.xaml.cs

示例8: SetTranslationAsync

		/// <summary>
		/// Sets the translation.
		/// </summary>
		/// <param name="translation">Translation.</param>
		private Task SetTranslationAsync(double translation, bool animate, double delta,
			DateTime startTime, DateTime endTime)
		{
			if (Children.Count == 0)
				return Task.FromResult (true);
			
			var tcs = new TaskCompletionSource<bool> ();
			double speed = 250.0;

			// velocity:
			if(startTime != DateTime.MinValue)
			{
				var deltaT = (endTime - startTime).Milliseconds;
				double velocity_X = (double)deltaT / (double)delta;
				speed = Math.Abs((translation  -_childLayout.TranslationX) * velocity_X);
			}

			var animation = new Animation ();

			if (animate)
				animation.Add(0.0, 1.0, new Animation((d) => _childLayout.TranslationX = d,
					_childLayout.TranslationX, translation));
			else
				_childLayout.TranslationX = translation;			

			if (animate) 
			{
				var endAnimation = new Animation ((d) => {
				}, 0, 1, Easing.CubicInOut, () => {
					tcs.SetResult (true);
				});

				animation.Add (0.0, 1.0, endAnimation);
				animation.Commit (this, "Translate", 16, Math.Min (350, (uint)speed), Easing.CubicOut);
			} 
			else 
			{
				tcs.SetResult (true);
			}

			return tcs.Task;
		}
开发者ID:patridge,项目名称:NControl.Controls,代码行数:46,代码来源:GalleryView.cs

示例9: OnButton3Clicked

        void OnButton3Clicked(object sender, EventArgs args)
        {
            Button button = (Button)sender;

            // Create parent animation object.
            Animation parentAnimation = new Animation();

            // Create "up" animation and add to parent.
            Animation upAnimation = new Animation(
                v => button.Scale = v,
                1, 5, Easing.SpringIn,
                () => Debug.WriteLine("up finished"));

            parentAnimation.Add(0, 0.5, upAnimation);

            // Create "down" animation and add to parent.
            Animation downAnimation = new Animation(
                v => button.Scale = v,
                5, 1, Easing.SpringOut,
                () => Debug.WriteLine("down finished"));

            parentAnimation.Insert(0.5, 1, downAnimation);

            // Commit parent animation
            parentAnimation.Commit(
                this, "Animation3", 16, 5000, null,
                (v, c) => Debug.WriteLine("parent finished: {0} {1}", v, c));
        }
开发者ID:jenart,项目名称:xamarin-forms-book-preview-2,代码行数:28,代码来源:ConcurrentAnimationsPage.xaml.cs

示例10: OnButton5Clicked

 void OnButton5Clicked(object sender, EventArgs args)
 {
     Animation animation = new Animation(v => dotLabel.Text = new string('.', (int)v), 0, 10);
     animation.Commit(this, "Animation5", 16, 3000, null,
                      (v, cancelled) => dotLabel.Text = "",
                      () => keepAnimation5Running);
     keepAnimation5Running = true;
 }
开发者ID:jenart,项目名称:xamarin-forms-book-preview-2,代码行数:8,代码来源:ConcurrentAnimationsPage.xaml.cs

示例11: TextEntry_TextChanged

		/// <summary>
		/// Texts the entry text changed.
		/// </summary>
		/// <param name="sender">Sender.</param>
		/// <param name="e">E.</param>
		private void TextEntry_TextChanged (object sender, TextChangedEventArgs e)
		{
			double startY, stopY;
			double startAlpha, stopAlpha;

			if (string.IsNullOrWhiteSpace (e.OldTextValue) && !string.IsNullOrWhiteSpace (e.NewTextValue)) {
				// We have text - move label out
				startY = -12;
				stopY = -18;
				startAlpha = 0.0;
				stopAlpha = 1.0;

			} else if (!string.IsNullOrWhiteSpace (e.OldTextValue) && string.IsNullOrWhiteSpace (e.NewTextValue)) {
				// Text is empty, move label in
				startY = -18;
				stopY = -12;
				startAlpha = 1.0;
				stopAlpha = 0.0;
			} 
			else
				return;

			// Animate y position
			var yAnimation = new Animation ((d) => _floatingLabel.TranslationY = d,
				startY, stopY, Easing.CubicOut);

			var alphaAnimation = new Animation ((d) => _floatingLabel.Opacity = d,
				startAlpha, stopAlpha, Easing.CubicOut);
			
			yAnimation.WithConcurrent (alphaAnimation);
			yAnimation.Commit (_floatingLabel, "AnimateLabel");

			UpdatePlaceholderColor ();

		}
开发者ID:chrisva,项目名称:NControl.Controls,代码行数:40,代码来源:FloatingLabelControl.cs

示例12: Activate

		/// <summary>
		/// Initializes a new instance of the <see cref="NControl.Controls.TabStripControl"/> class.
		/// </summary>
		/// <param name="view">View.</param>
		public void Activate (TabItem tabChild, bool animate)
		{
			var existingChild = Children.FirstOrDefault (t => t.View == 
				_contentView.Children.FirstOrDefault (v => v.IsVisible));

			if (existingChild == tabChild)
				return;

			var idxOfExisting = existingChild != null ? Children.IndexOf (existingChild) : -1;
			var idxOfNew = Children.IndexOf (tabChild);

			if (idxOfExisting > -1 && animate) 
			{
				_inTransition = true;

				// Animate
				var translation = idxOfExisting < idxOfNew ? 
					_contentView.Width : - _contentView.Width;

				tabChild.View.TranslationX = translation;
				if (tabChild.View.Parent != _contentView)
					_contentView.Children.Add(tabChild.View);
				else
					tabChild.View.IsVisible = true;

				var newElementWidth = _buttonStack.Children.ElementAt (idxOfNew).Width;
				var newElementLeft = _buttonStack.Children.ElementAt (idxOfNew).X;

				var animation = new Animation ();
				var existingViewOutAnimation = new Animation ((d) => existingChild.View.TranslationX = d,
					0, -translation, Easing.CubicInOut, () => {
						existingChild.View.IsVisible = false;
						_inTransition = false;
					});

				var newViewInAnimation = new Animation ((d) => tabChild.View.TranslationX = d,
					translation, 0, Easing.CubicInOut);

				var existingTranslation = _indicator.TranslationX;

				var indicatorTranslation = newElementLeft;
				var indicatorViewAnimation = new Animation ((d) => _indicator.TranslationX = d,
					existingTranslation, indicatorTranslation, Easing.CubicInOut);

				var startWidth = _indicator.Width;
				var indicatorSizeAnimation = new Animation ((d) => _indicator.WidthRequest = d,
					startWidth, newElementWidth, Easing.CubicInOut);

				animation.Add (0.0, 1.0, existingViewOutAnimation);
				animation.Add (0.0, 1.0, newViewInAnimation);
				animation.Add (0.0, 1.0, indicatorViewAnimation);
				animation.Add (0.0, 1.0, indicatorSizeAnimation);
				animation.Commit (this, "TabAnimation");
			} 
			else 
			{
				// Just set first view
				_contentView.Children.Clear();
				_contentView.Children.Add(tabChild.View);
			}

			foreach (var tabBtn in _buttonStack.Children)
				((TabBarButton)tabBtn).IsSelected = _buttonStack.Children.IndexOf(tabBtn) == idxOfNew;

			if (TabActivated != null)
				TabActivated(this, idxOfNew);
		}
开发者ID:patridge,项目名称:NControl.Controls,代码行数:71,代码来源:TabStripControl.cs

示例13: AnimateToplabels

		void AnimateToplabels (int LabelIndex)
		{
			if (LabelIndex == 0) {
				if (topCloseBtn.Rotation != 0) 
				{
					sliderFeedbackStack.IsVisible = false;
					feelingFeedbackStack.IsVisible = false;
					eventFeedbackStack.IsVisible = false;

					var animate = new Animation (d => topLabelBg.HeightRequest = d, topLabelBg.Height, 0, Easing.SpringIn);
					animate.Commit (topLabelBg, "BarGraph", 16, 200);
					animate = null;

					topCloseBtn.Rotation = 0;

					return;
				} else {

					AnimateToplabels (1);
					AnimateToplabels (2);
					AnimateToplabels (3);
					return;
				}
			}

			int heightReq = 0;
			heightReq += string.IsNullOrEmpty (emotionTextLabel.Text) ? 0 : (int)emotionTextLabel.Height;
			heightReq += string.IsNullOrEmpty (eventTextLabel.Text) ? 0 : 25;
			heightReq += slider.CurrentValue == 0 ? 0 : (int)sliderValueImage.Height;

			topLabelsContainer.HeightRequest = heightReq + topCloseBtn.Height;

			if (heightReq > 20) {
				topCloseBtn.Rotation = 180;
				topCloseBtn.IsVisible = true;
			} else {
				topCloseBtn.Rotation = 0;
				topCloseBtn.IsVisible = false;
			}
			//topLabelBg.HeightRequest = heightReq;

			{
				var animate = new Animation(d => topLabelBg.HeightRequest = d,topLabelBg.Height, heightReq + 3, Easing.SpringIn);
				animate.Commit(topLabelBg, "BarGraph", 16, 500);
				animate = null;
			}

			var sliderFeedbackStackH = sliderFeedbackStack.Height;


			if (slider.CurrentValue != 0 && LabelIndex == 1) {
				sliderFeedbackStack.IsVisible = true;
				var animate = new Animation(d => sliderFeedbackStack.HeightRequest = d, 0, sliderValueImage.Height, Easing.SpringIn);
				animate.Commit(sliderFeedbackStack, "BarGraph", 16, 500);
				animate = null;
			}

			if (!string.IsNullOrEmpty (emotionTextLabel.Text)  && LabelIndex == 2) {
				feelingFeedbackStack.IsVisible = true;
				var animate = new Animation(d => feelingFeedbackStack .HeightRequest = d, 0, emotionTextLabel.Height  , Easing.SpringIn);
				animate.Commit(feelingFeedbackStack , "BarGraph", 16, 500);
				animate = null;
			}

			if (!string.IsNullOrEmpty (eventTextLabel.Text)  && LabelIndex == 3) {
				eventFeedbackStack.IsVisible = true;
				var animate = new Animation(d => eventFeedbackStack.HeightRequest = d, 0,23, Easing.SpringIn);
				animate.Commit(eventFeedbackStack, "BarGraph", 16, 500);
				animate = null;
			}

			GC.Collect ();
		}
开发者ID:praveenmohanmm,项目名称:PurposeColor_Bkp_Code,代码行数:73,代码来源:FeelingNowPage.cs


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