本文整理匯總了C#中Animation.LimitedNewTime方法的典型用法代碼示例。如果您正苦於以下問題:C# Animation.LimitedNewTime方法的具體用法?C# Animation.LimitedNewTime怎麽用?C# Animation.LimitedNewTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Animation
的用法示例。
在下文中一共展示了Animation.LimitedNewTime方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreateAnimationOfOperations
private static Animation CreateAnimationOfOperations(Interval renderInterval, Interval targetInterval, params Operation[] operations)
{
var keyNodes = new Dictionary<int, Tuple<NestingDepthTreeNode, Interval, NestingDepthTreeNode>>();
var activeOperation = default(Operation);
var dt = 1.0;
var ani = new Animation();
ani.Add(new TextDesc("Using a Tree to Track Referenced Intervals", new Point(250, 5), new Point(0, 0), fontSize:20));
ani.Add(new TextDesc("Referenced" + Environment.NewLine + "Intervals", new Point(10, 80)));
ani.Add(new TextDesc("Tree", new Point(10, 220)));
ani.Add(new TextDesc("Nesting" + Environment.NewLine + "Depth", new Point(10, 350)));
ani.Add(new LineSegmentDesc(new Point(0, 30).Sweep(new Vector(10000, 0)), Brushes.Black, 1));
ani.Add(new LineSegmentDesc(new Point(0, 100).Sweep(new Vector(10000, 0)), Brushes.Black, 1));
ani.Add(new LineSegmentDesc(new Point(0, 300).Sweep(new Vector(10000, 0)), Brushes.Black, 1));
ani.Add(new LineSegmentDesc(new Point(75, 0).Sweep(new Vector(0, 10000)), Brushes.Black, 1));
var i = 0.0;
var dealloced = new HashSet<int>();
for (var i2 = 0; i2 < renderInterval.Length; i2++) {
if (i2 + renderInterval.Offset < targetInterval.Offset || i2 + renderInterval.Offset >= targetInterval.Offset + targetInterval.Length) {
dealloced.Add(i2 + renderInterval.Offset);
}
}
var x = 100;
var y = 90;
Func<double, Animation> addFrame = focus => {
var roots = keyNodes.Select(e => NestingDepthTreeNode.RootOf(e.Value.Item1)).Distinct().ToArray();
var a = new Animation();
var s = 10;
if (!double.IsNaN(focus) && !double.IsInfinity(focus)) {
var dx = focus - renderInterval.Offset;
a.Add(new LineSegmentDesc(new LineSegment(new Point(x + dx*s, 0), new Point(x + dx*s, 10000)), activeOperation.Interval.HasValue ? Brushes.Green : Brushes.Red, 1, 1.0));
}
foreach (var r in roots) a.Add(RenderTree(renderInterval, r, dealloced));
ani.LimitedNewTime(i.Seconds(), (i + dt).Seconds()).Add(a);
i += dt;
var bb = 0;
foreach (var e in keyNodes) {
Brush brush;
if (e.Key == activeOperation.Key && !double.IsInfinity(focus)) {
brush = activeOperation.Interval.HasValue ? Brushes.Green : Brushes.Red;
} else {
brush = Brushes.Yellow;
}
var inv = e.Value.Item2;
var dx = inv.Offset - renderInterval.Offset;
a.Add(new RectDesc(new Rect(x + dx * s, y - (bb+1) * s*1.1, s*inv.Length, s), fill: brush, stroke: Brushes.Black, strokeThickness: 1));
bb += 1;
}
return a;
};
foreach (var e in operations) {
activeOperation = e;
var affectedRoot =
e.Interval.HasValue ?
keyNodes.Select(n => NestingDepthTreeNode.RootOf(n.Value.Item1)).FirstOrDefault(n => NestingDepthTreeNode.GetInterval(n).Overlaps(e.Interval.Value))
: NestingDepthTreeNode.RootOf(keyNodes[e.Key].Item1);
if (e.Interval.HasValue) {
keyNodes.Add(e.Key, Tuple.Create((NestingDepthTreeNode)null, e.Interval.Value, (NestingDepthTreeNode)null));
addFrame(double.NaN);
addFrame(e.Interval.Value.Offset);
var a1 = NestingDepthTreeNode.Include(affectedRoot, e.Interval.Value.Offset, +1, +1);
a1.AdjustedNode._fakeRefCount += 2;
keyNodes[e.Key] = Tuple.Create(a1.AdjustedNode, e.Interval.Value, (NestingDepthTreeNode)null);
addFrame(e.Interval.Value.Offset);
addFrame(e.Interval.Value.Offset + e.Interval.Value.Length);
var a2 = NestingDepthTreeNode.Include(a1.NewRoot, e.Interval.Value.Offset + e.Interval.Value.Length, -1, +1);
a2.AdjustedNode._fakeRefCount += 2;
keyNodes[e.Key] = Tuple.Create(a1.AdjustedNode, e.Interval.Value, a2.AdjustedNode);
addFrame(e.Interval.Value.Offset + e.Interval.Value.Length);
addFrame(double.PositiveInfinity);
}
else {
var xs = keyNodes[e.Key];
var r = NestingDepthTreeNode.RootOf(xs.Item1);
r = NestingDepthTreeNode.Include(r, xs.Item2.Offset + xs.Item2.Length, +1, 0).NewRoot;
r = NestingDepthTreeNode.Include(r, xs.Item2.Offset, -1, 0).NewRoot;
var hh = new HashSet<int>();
foreach (var ex in NestingDepthTreeNode.FindHolesIn(NestingDepthTreeNode.GetInterval(r), r)) {
for (var ii = ex.Offset; ii < ex.Offset + ex.Length; ii++) {
hh.Add(ii);
}
}
r = NestingDepthTreeNode.Include(r, xs.Item2.Offset + xs.Item2.Length, -1, 0).NewRoot;
r = NestingDepthTreeNode.Include(r, xs.Item2.Offset, +1, 0).NewRoot;
//.........這裏部分代碼省略.........