本文整理汇总了C#中System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleAnimationUsingKeyFrames.SetValue方法的具体用法?C# DoubleAnimationUsingKeyFrames.SetValue怎么用?C# DoubleAnimationUsingKeyFrames.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames
的用法示例。
在下文中一共展示了DoubleAnimationUsingKeyFrames.SetValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResetNorth
private void ResetNorth( )
{
Storyboard sb = new Storyboard();
sb.Duration = TimeSpan.FromMilliseconds(500.0);
DoubleAnimationUsingKeyFrames frames= new DoubleAnimationUsingKeyFrames();
SplineDoubleKeyFrame frame2 = new SplineDoubleKeyFrame();
frame2.KeyTime = sb.Duration.TimeSpan;
frame2.Value = 0.0;
KeySpline spline = new KeySpline();
spline.ControlPoint1 = new Point(0.0 , 0.1);
spline.ControlPoint2 = new Point(0.1 , 1.0);
frame2.KeySpline = spline;
SplineDoubleKeyFrame frame = frame2;
frames.KeyFrames.Add(frame);
if (this.Map.Angle > 180)
{
frame.Value = 360.0;
}//正转到北
if (this.Map.Angle <= 180)
{
frame.Value = 0.0;
}//转回去
frames.SetValue(Storyboard.TargetPropertyProperty , new PropertyPath("Angle"));
sb.Children.Add(frames);
Storyboard.SetTarget(frames , this.Map);
sb.Begin();
}
示例2: ResetRotation_Click
private void ResetRotation_Click(object sender, RoutedEventArgs e)
{
Storyboard s = new Storyboard {
Duration = TimeSpan.FromMilliseconds(500.0)
};
DoubleAnimationUsingKeyFrames frames = new DoubleAnimationUsingKeyFrames();
SplineDoubleKeyFrame frame2 = new SplineDoubleKeyFrame {
KeyTime = s.Duration.TimeSpan,
Value = 0.0
};
KeySpline spline = new KeySpline {
ControlPoint1 = new Point(0.0, 0.1),
ControlPoint2 = new Point(0.1, 1.0)
};
frame2.KeySpline = spline;
SplineDoubleKeyFrame keyFrame = frame2;
frames.KeyFrames.Add(keyFrame);
keyFrame.Value = 0.0;
frames.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Rotation", new object[0]));
s.Children.Add(frames);
Storyboard.SetTarget(frames, this.Map);
s.Completed += delegate (object sender2, EventArgs e2) {
s.Stop();
this.Map.Rotation = 0.0;
};
s.Begin();
}
示例3: SelectItem
public void SelectItem(int index)
{
if (index == -1)
{
selectedIndex = -1;
return;
}
Viewport2DVisual3D vis = _models[index];
int totalPeicesDeep = (int)Math.Floor(Children.Count / (PeicesPerSide * 3.0));
int depthOfModel = (int)Math.Floor((double)((_models.IndexOf(vis)) / (PeicesPerSide * 3)));
double currentDepth = totalPeicesDeep * ScrollPosition;
double scrollDistancePerPiece = 1.0 / totalPeicesDeep;
double scrollTo = double.IsInfinity(scrollDistancePerPiece) ? (depthOfModel * 0) : (depthOfModel * scrollDistancePerPiece);
var scrollAnim = new DoubleAnimationUsingKeyFrames();
scrollAnim.KeyFrames.Add(new SplineDoubleKeyFrame(scrollTo, new TimeSpan(0, 0, 1)));
scrollAnim.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(TunnelPanel3D.ScrollPositionProperty));
scrollAnim.SetValue(Storyboard.TargetProperty, this);
// If the Selected Item is not currently built on the screen then only animate the "ScrollPosition" into position
if (index > ViewingRangeStopIndex || index < ViewRangeStartIndex)
{
this.BeginAnimation(TunnelPanel3D.ScrollPositionProperty, scrollAnim);
selectedIndex = selectedIndex == index ? -1 : index;
return;
}
//Clear Previous Selected Item
if (selectedIndex >= 0 || selectedIndex == index)
{
ClearItem((selectedIndex == index), selectedIndex);
if (selectedIndex == index)
{ return; }
}
//Bring Selected Item into view
ResourceDictionary rd = new ResourceDictionary();
rd.Source = new Uri("pack://application:,,,/V3DControls;component/Themes/Generic.xaml");
Storyboard sb = ((Storyboard)rd["MovePeiceStoryboard"]).Clone();
var transformGroup = vis.Transform as Transform3DGroup;
if (selectedIndex != index && transformGroup != null)
{
transformGroup.Children[0].BeginAnimation(TranslateTransform3D.OffsetXProperty, null);
transformGroup.Children[0].BeginAnimation(TranslateTransform3D.OffsetYProperty, null);
transformGroup.Children[0].BeginAnimation(TranslateTransform3D.OffsetZProperty, null);
transformGroup.Children[1].BeginAnimation(RotateTransform3D.RotationProperty, null);
transformGroup.Children[1].BeginAnimation(RotateTransform3D.CenterXProperty, null);
transformGroup.Children[1].BeginAnimation(RotateTransform3D.CenterYProperty, null);
sb.Children[0].SetValue(Storyboard.TargetProperty, vis);
sb.Children[1].SetValue(Storyboard.TargetProperty, vis);
sb.Children[2].SetValue(Storyboard.TargetProperty, vis);
(((sb.Children[2] as DoubleAnimationUsingKeyFrames).KeyFrames[0]) as SplineDoubleKeyFrame).Value = (transformGroup.Children[0] as TranslateTransform3D).OffsetZ + PeicesPerSide - 1;
sb.Children[3].SetValue(Storyboard.TargetProperty, vis);
sb.Children[4].SetValue(Storyboard.TargetProperty, vis);
sb.Children[5].SetValue(Storyboard.TargetProperty, vis);
sb.Children.Add(scrollAnim);
isMoveingPeiceIntoView = true;
needsUpdate = true;
sb.Completed -= new EventHandler(sbSelectItem_Completed);
sb.Completed += new EventHandler(sbSelectItem_Completed);
sb.Begin(this, true);
}
selectedIndex = selectedIndex == index ? -1 : index;
MoveItems_SetItemsOwnerSelectedItem();
}
示例4: OnClosing
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
if (IsClosing)
{
e.Cancel = !AllowClose;
}
else
{
IsClosing = true;
AllowClose = false;
e.Cancel = true;
if (PopupBoard is Storyboard)
{
PopupBoard.Stop(this);
PopupBoard = null;
}
HideBoard = new Storyboard();
HideBoard.Completed += new EventHandler((od, ed) =>
{
AllowClose = true;
Close();
});
var rect = DockIcon.IconRect;
var delay = Config.HideDelay;
if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift)
{
delay = 5000;
}
for (var i = 0; i < spContent.Children.Count; i++)
{
var ctrl = spContent.Children[i] as FanIconControl;
ctrl.GridContent.Effect = null;
var animRotate = new DoubleAnimationUsingKeyFrames();
animRotate.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
animRotate.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)"));
animRotate.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
animRotate.DecelerationRatio = 0.8;
var animMargin = new ThicknessAnimationUsingKeyFrames();
animMargin.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
animMargin.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Margin)"));
animMargin.KeyFrames.Add(new SplineThicknessKeyFrame(
new Thickness(0),
KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
animMargin.DecelerationRatio = 0.8;
var animOpacity = new DoubleAnimationUsingKeyFrames();
animOpacity.SetValue(Storyboard.TargetNameProperty, ctrl.BorderTitle.Tag);
animOpacity.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Opacity)"));
animOpacity.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
animOpacity.DecelerationRatio = 1;
var animIconSize = new Int32AnimationUsingKeyFrames();
animIconSize.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
animIconSize.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.IconSize)"));
animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(rect.Width, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
animIconSize.DecelerationRatio = 1;
HideBoard.Children.Add(animRotate);
HideBoard.Children.Add(animMargin);
HideBoard.Children.Add(animOpacity);
HideBoard.Children.Add(animIconSize);
}
HideBoard.Begin(this);
}
base.OnClosing(e);
}
示例5: Window_Activated
private void Window_Activated(object sender, EventArgs e)
{
if (IsClosing || IsOpened)
{
return;
}
IsOpened = true;
DockIcon.IconName = App.StartupPath + "Container-Opened.png";
PopupBoard = new Storyboard();
PopupBoard.Completed += new EventHandler(PopupAnimation_Completed);
var rect = DockIcon.IconRect;
var delay = Config.PopupDelay;
if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift)
{
delay = 5000;
}
for (var i = 0; i < spContent.Children.Count; i++)
{
var ctrl = spContent.Children[i] as FanIconControl;
var k = (double)(spContent.Children.Count - 1 - i) / MaxItems;
var animRotate = new DoubleAnimationUsingKeyFrames();
animRotate.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
animRotate.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)"));
animRotate.KeyFrames.Add(new SplineDoubleKeyFrame(k * Angle, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
animRotate.DecelerationRatio = 0.8;
var animMargin = new ThicknessAnimationUsingKeyFrames();
animMargin.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
animMargin.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Margin)"));
animMargin.KeyFrames.Add(new SplineThicknessKeyFrame(
new Thickness(0, 0, -IconSize / 2 * (1 - Math.Sin((1 - k) * Math.PI / 2)) - (IconSize - rect.Width) / 2,
rect.Height + IconSize * (spContent.Children.Count - 1 - i)),
KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
animMargin.DecelerationRatio = 0.8;
var animOpacity = new DoubleAnimationUsingKeyFrames();
animOpacity.SetValue(Storyboard.TargetNameProperty, ctrl.BorderTitle.Tag);
animOpacity.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Opacity)"));
animOpacity.KeyFrames.Add(new SplineDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
animOpacity.DecelerationRatio = 1;
var animIconSize = new Int32AnimationUsingKeyFrames();
animIconSize.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
animIconSize.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.IconSize)"));
animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(rect.Width, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0))));
animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(IconSize, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
animIconSize.DecelerationRatio = 1;
PopupBoard.Children.Add(animRotate);
PopupBoard.Children.Add(animMargin);
PopupBoard.Children.Add(animOpacity);
PopupBoard.Children.Add(animIconSize);
}
PopupBoard.Begin(this);
}
示例6: PopupAnimation_Completed
private void PopupAnimation_Completed(object sender, EventArgs e)
{
if (HideBoard == null)
{
var board = new Storyboard();
foreach (FanIconControl ctrl in spContent.Children)
{
if (spContent.Children.IndexOf(ctrl) < spContent.Children.Count - 1)
{
ctrl.GridContent.Effect = ShadowEffect;
var anim = new DoubleAnimationUsingKeyFrames();
anim.SetValue(Storyboard.TargetNameProperty, ctrl.GridContent.Tag);
anim.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Effect).(Opacity)"));
anim.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0))));
anim.KeyFrames.Add(new SplineDoubleKeyFrame(0.3, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(800))));
board.Children.Add(anim);
}
if (!ctrl.IsRendered)
{
ctrl.Render();
}
}
board.Begin(this);
Activate();
}
}
示例7: SendToLocation
private void SendToLocation(DragablzItem dragablzItem, double location)
{
double activeTarget;
if (Math.Abs(_getLocation(dragablzItem) - location) < 1.0
||
_activeStoryboardTargetLocations.TryGetValue(dragablzItem, out activeTarget)
&& Math.Abs(activeTarget - location) < 1.0)
{
return;
}
_activeStoryboardTargetLocations[dragablzItem] = location;
var storyboard = new Storyboard {FillBehavior = FillBehavior.Stop};
storyboard.WhenComplete(sb =>
{
_setLocation(dragablzItem, location);
sb.Remove(dragablzItem);
_activeStoryboardTargetLocations.Remove(dragablzItem);
});
var timeline = new DoubleAnimationUsingKeyFrames();
timeline.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(_canvasDependencyProperty));
timeline.KeyFrames.Add(
new EasingDoubleKeyFrame(location, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200)))
{
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }
});
storyboard.Children.Add(timeline);
storyboard.Begin(dragablzItem, true);
}
示例8: ResetRotation_Click
private void ResetRotation_Click(object sender, RoutedEventArgs e)
{
Storyboard s = new Storyboard();
s.Duration = TimeSpan.FromMilliseconds(500);
DoubleAnimationUsingKeyFrames anim = new DoubleAnimationUsingKeyFrames();
SplineDoubleKeyFrame spline = new SplineDoubleKeyFrame() { KeyTime = s.Duration.TimeSpan, Value = 0, KeySpline = new KeySpline() { ControlPoint1 = new System.Windows.Point(0, 0.1), ControlPoint2 = new System.Windows.Point(0.1, 1) } };
anim.KeyFrames.Add(spline);
spline.Value = 0;
anim.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Rotation"));
s.Children.Add(anim);
Storyboard.SetTarget(anim, Map);
s.Completed += (sender2, e2) =>
{
s.Stop();
Map.Rotation = 0;
};
s.Begin();
}