zoukankan      html  css  js  c++  java
  • WPF 位置转化和动画

    位置转化

            private void DrawScale()
            {
                double majorTickUnitValue = this.ScaleSweepLenth / this.MajorDivisionsCount;
                double minorTickUnitValue = this.ScaleSweepLenth / this.MinorDivisionsCount;
                double correctionOffset = this.rootGrid.Width / 2 ;
    
                Double minvalue = MinValue; ;
    
                //画主刻度
                for (int i = 0; i < this.MajorDivisionsCount; i++)
                {
                    Rectangle majorTickRect = new Rectangle();
                    majorTickRect.Height = this.MajorTickSize.Height;
                    majorTickRect.Width = this.MajorTickSize.Width;
                    majorTickRect.Fill = new SolidColorBrush(this.MajorTickColor);
    
                    TransformGroup majorTickTransformGroup = new TransformGroup();
                    TranslateTransform majorTickTranslateTransform = new TranslateTransform();
    
                    majorTickTranslateTransform.X = i * majorTickUnitValue - correctionOffset;
                    majorTickTranslateTransform.Y = this.MajorMinorDivisionOffset;
    
                    majorTickTransformGroup.Children.Add(majorTickTranslateTransform);
                    majorTickRect.RenderTransform = majorTickTransformGroup;
    
                    this.rootGrid.Children.Add(majorTickRect);
                }
    
            }

    动画

            private void MovePointerUsingAnimate(double oldValue, double newValue)
            {
                if (null != this.pointer)
                {
                    double distanceOldAndNew = Math.Abs(newValue - oldValue);
                    DoubleAnimation doubleAnimation = new DoubleAnimation();
                    double animDuration = 0.0f;
                    Storyboard movingPointerStoryboard = new Storyboard();
                    TransformGroup transformGroup = new TransformGroup();
                    TranslateTransform transform = new TranslateTransform();
               
                    doubleAnimation.From = oldValue;
                    doubleAnimation.To = newValue;
                    animDuration = distanceOldAndNew * animatingSpeedFactor;
                    doubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(animDuration));
    
                    movingPointerStoryboard.Completed +=new EventHandler(MovingPointerStoryboardStoryboard_Completed);
                    movingPointerStoryboard.Children.Add(doubleAnimation);
                    Storyboard.SetTarget(doubleAnimation, this.pointer);
    
                    transformGroup.Children.Add(transform);
                    this.pointer.RenderTransform = transformGroup;
    
                    Storyboard.SetTargetProperty(doubleAnimation,
                        new PropertyPath("(Path.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)"));
    
                    if (Math.Abs(oldValue - newValue) > 0)
                    {
                        movingPointerStoryboard.Begin();
                    }
    
                }
            }
  • 相关阅读:
    读操作
    读锁与写锁
    Mvcc
    readView
    版本链
    事务的隔离性
    索引的代价
    keras backend的修改
    caffe 笔记
    菜品识别 SDK调用
  • 原文地址:https://www.cnblogs.com/easy5weikai/p/3335519.html
Copyright © 2011-2022 走看看