本文整理汇总了C#中Duration类的典型用法代码示例。如果您正苦于以下问题:C# Duration类的具体用法?C# Duration怎么用?C# Duration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Duration类属于命名空间,在下文中一共展示了Duration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getUnionDuration
public Duration getUnionDuration(Duration duration)
{
DateTime start = (this.startDate <= duration.getStartDate()) ? this.startDate : duration.getStartDate();
DateTime end = this.endDate >= duration.getEndDate() ? this.endDate : duration.getEndDate();
return new Duration(start, end);
}
示例2: QuadPointEasingAnimation
/// <summary>
/// Set Properties
/// </summary>
/// <param name="from">Start Point</param>
/// <param name="to">End Point</param>
/// <param name="easeInMethod">Easing method equation</param>
/// <param name="duration">Duration for the animation</param>
public QuadPointEasingAnimation(Point from, Point to, PointEasingMode easeInMethod, Duration duration)
{
FromValue = from;
ToValue = to;
Duration = duration;
EaseFunction = easeInMethod;
}
示例3: Load
public override bool Load(ConfigNode configNode)
{
// Load base class
bool valid = base.Load(configNode);
valid &= ConfigNodeUtil.ParseValue<Vessel.Situations>(configNode, "situation", x => situation = x, this, Vessel.Situations.ORBITING, ValidateSituations);
valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minAltitude", x => minAltitude = x, this, 0.0, x => Validation.GE(x, 0.0));
valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxAltitude", x => maxAltitude = x, this, double.MaxValue, x => Validation.GE(x, 0.0));
valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minApA", x => minApoapsis = x, this, 0.0, x => Validation.GE(x, 0.0));
valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxApA", x => maxApoapsis = x, this, double.MaxValue, x => Validation.GE(x, 0.0));
valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minPeA", x => minPeriapsis = x, this, 0.0, x => Validation.GE(x, 0.0));
valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxPeA", x => maxPeriapsis = x, this, double.MaxValue, x => Validation.GE(x, 0.0));
valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minEccentricity", x => minEccentricity = x, this, 0.0, x => Validation.GE(x, 0.0));
valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxEccentricity", x => maxEccentricity = x, this, double.MaxValue, x => Validation.GE(x, 0.0));
valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minInclination", x => minInclination = x, this, 0.0, x => Validation.Between(x, 0.0, 180.0));
valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxInclination", x => maxInclination = x, this, 180.0, x => Validation.Between(x, 0.0, 180.0));
valid &= ConfigNodeUtil.ParseValue<Duration>(configNode, "minPeriod", x => minPeriod = x, this, new Duration(0.0));
valid &= ConfigNodeUtil.ParseValue<Duration>(configNode, "maxPeriod", x => maxPeriod = x, this, new Duration(double.MaxValue));
// Validate target body
valid &= ValidateTargetBody(configNode);
// Validation minimum and groupings
valid &= ConfigNodeUtil.AtLeastOne(configNode, new string[] { "minAltitude", "maxAltitude", "minApA", "maxApA", "minPeA", "maxPeA",
"minEccentricity", "maxEccentricity", "minInclination", "maxInclination", "minPeriod", "maxPeriod" }, this);
valid &= ConfigNodeUtil.MutuallyExclusive(configNode, new string[] { "minAltitude", "maxAltitude" },
new string[] { "minApA", "maxApA", "minPeA", "maxPeA" }, this);
return valid;
}
示例4: Advance
/// <summary>
/// Advances the clock by the given duration.
/// </summary>
/// <param name="duration">The duration to advance the clock by (or if negative, the duration to move it back
/// by).</param>
public void Advance(Duration duration)
{
lock (mutex)
{
now += duration;
}
}
示例5: DismissEVHUD
public void DismissEVHUD()
{
if (evHUDView == null)
{
return;
}
Storyboard storyboard = new Storyboard();
Duration duration = new Duration(TimeSpan.FromSeconds(0.3));
storyboard.Duration = duration;
DoubleAnimation panelAnimation = new DoubleAnimation();
panelAnimation.Duration = duration;
panelAnimation.To = evHUDView.Width;
panelAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
Storyboard.SetTarget(panelAnimation, evHUDView);
Storyboard.SetTargetProperty(panelAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
storyboard.Children.Add(panelAnimation);
storyboard.Begin();
storyboard.Completed += (sender, e) =>
{
evHUDView.Visibility = Visibility.Collapsed;
if (Orientation == PageOrientation.LandscapeLeft || Orientation == PageOrientation.LandscapeRight)
{
ShowLandscapeShutterButton();
}
};
}
示例6: AnimateEntry
private void AnimateEntry(Size targetSize)
{
var svi = GuiHelpers.GetParentObject<ScatterViewItem>(this, false);
if (svi != null)
{
// Easing function provide a more natural animation
IEasingFunction ease = new BackEase {EasingMode = EasingMode.EaseOut, Amplitude = 0.3};
var duration = new Duration(TimeSpan.FromMilliseconds(500));
var w = new DoubleAnimation(0.0, targetSize.Width, duration) {EasingFunction = ease};
var h = new DoubleAnimation(0.0, targetSize.Height, duration) {EasingFunction = ease};
var o = new DoubleAnimation(0.0, 1.0, duration);
// Remove the animation after it has completed so that its possible to manually resize the scatterviewitem
w.Completed += (s, e) => svi.BeginAnimation(ScatterViewItem.WidthProperty, null);
h.Completed += (s, e) => svi.BeginAnimation(ScatterViewItem.HeightProperty, null);
// Set the size manually, otherwise once the animation is removed the size will revert back to the minimum size
// Since animation has higher priority for DP's, this setting won't have effect until the animation is removed
svi.Width = targetSize.Width;
svi.Height = targetSize.Height;
svi.BeginAnimation(ScatterViewItem.WidthProperty, w);
svi.BeginAnimation(ScatterViewItem.HeightProperty, h);
svi.BeginAnimation(ScatterViewItem.OpacityProperty, o);
}
}
示例7: PerformTranstition
public override void PerformTranstition(UserControl newPage, UserControl oldPage)
{
this.newPage = newPage;
this.oldPage = oldPage;
Duration duration = new Duration(TimeSpan.FromSeconds(1));
DoubleAnimation animation = new DoubleAnimation();
animation.Duration = duration;
switch (direction)
{
case WipeDirection.LeftToRight:
animation.To = oldPage.ActualWidth;
break;
case WipeDirection.RightToLeft:
animation.To = -oldPage.ActualWidth;
break;
}
Storyboard sb = new Storyboard();
sb.Duration = duration;
sb.Children.Add(animation);
sb.Completed += sb_Completed;
TranslateTransform sc = new TranslateTransform();
oldPage.RenderTransform = sc;
Storyboard.SetTarget(animation, sc);
Storyboard.SetTargetProperty(animation, new PropertyPath("X"));
//oldPage.Resources.Add(sb);
sb.Begin();
}
示例8: Discard
private void Discard(ListBox menu)
{
menu.IsEnabled = false;
var duration = new Duration(TimeSpan.FromMilliseconds(400));
DoubleAnimation
posXAnimation = new DoubleAnimation { Duration = duration, To = -80 },
posYAnimation = new DoubleAnimation { Duration = duration, To = -80 },
scaleXAnimation = new DoubleAnimation { Duration = duration, To = 1.5 },
scaleYAnimation = new DoubleAnimation { Duration = duration, To = 1.5 },
opacityAnimation = new DoubleAnimation { Duration = duration, To = 0 }
;
var translateTransform = ((TransformGroup)menu.RenderTransform).Children[0];
var scaleTransform = ((TransformGroup)menu.RenderTransform).Children[1];
translateTransform.BeginAnimation(TranslateTransform.XProperty, posXAnimation);
translateTransform.BeginAnimation(TranslateTransform.YProperty, posYAnimation);
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleXAnimation);
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleYAnimation);
opacityAnimation.Completed += (object sender, EventArgs e) =>
{
menu.Visibility = Visibility.Collapsed;
menu.IsEnabled = true;
translateTransform.BeginAnimation(TranslateTransform.XProperty, null);
translateTransform.BeginAnimation(TranslateTransform.YProperty, null);
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, null);
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, null);
menu.BeginAnimation(OpacityProperty, null);
};
menu.BeginAnimation(OpacityProperty, opacityAnimation);
}
示例9: Entry
public Entry(DateTime date, double duration, string activity, string note)
{
Date = date;
Activity = activity;
Duration = new Duration(duration);
Note = note;
}
示例10: MatrixAnimation
public MatrixAnimation(Matrix fromValue, Matrix toValue, Duration duration, FillBehavior fillBehavior)
{
From = fromValue;
To = toValue;
Duration = duration;
FillBehavior = fillBehavior;
}
示例11: Tween
public Tween(Equations type, double from, double to, Duration duration)
{
Equation = type;
From = from;
To = to;
Duration = duration;
}
示例12: QuestionFadeInAnimation
public QuestionFadeInAnimation()
{
To = 1;
From = 0;
Duration = new Duration(TimeSpan.FromMilliseconds(500));
Storyboard.SetTargetProperty(this, new PropertyPath("Opacity"));
}
示例13: IsLessThan
/// <summary>
/// Checks that the actual duration is less (strictly) than a comparand.
/// </summary>
/// <param name="check">The fluent check to be extended.</param>
/// <param name="comparand">The value to compare to.</param>
/// <returns>A check link.</returns>
/// <exception cref="FluentCheckException">The actual value is not less than the provided comparand.</exception>
public static ICheckLink<ICheck<TimeSpan>> IsLessThan(this ICheck<TimeSpan> check, TimeSpan comparand)
{
var checker = ExtensibilityHelper.ExtractChecker(check);
var unit = TimeHelper.DiscoverUnit(comparand);
var testedDuration = new Duration(checker.Value, unit);
var expected = new Duration(comparand, unit);
var notMessage =
checker.BuildMessage("The {0} is not more than the limit.")
.On(testedDuration)
.And.Expected(expected)
.Comparison("more than or equal to");
var message =
checker.BuildMessage("The {0} is more than the limit.")
.On(testedDuration)
.And.Expected(expected).Comparison("less than");
return checker.ExecuteCheck(
() =>
{
if (testedDuration >= expected)
{
throw new FluentCheckException(message.ToString());
}
},
notMessage.ToString());
}
示例14: DoubleAnimation
public DoubleAnimation(double from, double to, Duration duration, FillBehavior fillBehavior)
{
this.From = from;
this.To = to;
this.Duration = duration;
this.FillBehavior = fillBehavior;
}
示例15: DefaultValues
public void DefaultValues ()
{
Duration d = new Duration ();
Assert.AreEqual (false, d.HasTimeSpan, "HasTimeSpan");
Assert.Throws<InvalidOperationException> (() => { object o = d.TimeSpan; GC.KeepAlive(o); }, "TimeSpan");
Assert.AreEqual ("Automatic", d.ToString (), "ToString");
}