CompositionScopedBatch クラス

定義

アクティブなアニメーションまたは効果の明示的に作成されたグループ。

public ref class CompositionScopedBatch sealed : CompositionObject
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 131072)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class CompositionScopedBatch final : CompositionObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 131072)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class CompositionScopedBatch : CompositionObject
Public NotInheritable Class CompositionScopedBatch
Inherits CompositionObject
継承
Object Platform::Object IInspectable CompositionObject CompositionScopedBatch
属性

Windows の要件

デバイス ファミリ
Windows 10 (10.0.10586.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v2.0 で導入)

スコープ付きバッチ

// The Green Square's completion events for the Offset and Opacity animations are aggregated
// The Rotation animation completion event is not aggregated
// When the aggregated events are completed OnBatchCompleted method is executed
public void BatchAnimations()
{
    // Create a Scoped batch to capture animation completion events
    _batch = _compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

    // Executing the Offset animation and aggregating completion event
    ApplyOffsetAnimation(_greenSquare);

    // Suspending to exclude the following Rotation animation from the batch
    _batch.Suspend();

    // Executing the Rotation animation 
    ApplyRotationAnimation(_greenSquare);

    // Resuming the batch to collect additional animations
    _batch.Resume();

    // Executing the Opacity animation and aggregating completion event
    ApplyOpacityAnimation(_greenSquare);

    // Batch is ended and no objects can be added
    _batch.End();

    // Method triggered when batch completion event fires
    _batch.Completed += OnBatchCompleted;
}

注釈

アクティブなアニメーションまたは効果のグループを表し、グループのすべてのメンバーが完了したときにコールバックをトリガーします。 CompositionScopedBatch は明示的に作成され、1 つのスコープ付きバッチに含める特定のオブジェクトを指定するために使用されます。

複数の CompositionScopedBatch インスタンスを作成でき、オブジェクトを複数のバッチで同時に集計できます。

作成

アニメーションの特定のグループを集計したり、単一のアニメーションの完了イベントをターゲットにしたりするには、スコープ付きバッチを作成します。 スコープ付きバッチは 、Compositor.CreateScopedBatch を使用して明示的に作成され、1 つのバッチに含める特定のオブジェクトを指定するために使用されます。 スコープ付きバッチは、任意のスレッドで作成でき、コンポジション スレッドに関連付けられません。 スコープバッチは、作成されたスレッド内のオブジェクトのみを集計します。

CompositionScopedBatch myScopedBatch = _compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

中断と再開

スコープ付きバッチを作成した後、開始されたすべてのアニメーションは、バッチが明示的に中断されるか、Suspend 関数または End 関数を使用して終了するまで集計されます。

CompositionScopedBatch は、そのバッチからオブジェクトを除外するために 、Suspend で明示的に一時停止できます。 バッチが中断されると、 Resume を呼び出して再度開くことができます。 Suspend 関数を呼び出すと、Resume が呼び出されるまでアニメーションの終了状態の集計が停止します。 これにより、特定のバッチから明示的にコンテンツを除外することができます。

次の例では、VisualA の Offset プロパティをターゲットとするアニメーションは、バッチに含まれていません。

myScopedBatch.Suspend();
VisualA.StartAnimation("Offset", myAnimation);
myScopeBatch.Resume();

End

CompositionScopedBatch は 、End を使用して明示的に閉じる必要があります。 いったん閉じた後は、中断または再開できません。 バッチを完了するには、End() を呼び出す必要があります。 End を呼び出さない場合、バッチは開いたまま、オブジェクトの収集を継続します。

次のコード スニペットと図は、バッチがアニメーションを集計して終了状態を追跡する方法の例を示しています。

この例では、アニメーション 1、3、4 はこのバッチにより終了状態が追跡されますが、アニメーション 2 の終了状態は追跡されません。

myScopedBatch.End();
CompositionScopedBatch myScopedBatch = 	_compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
// Start Animation1
[…]
myScopedBatch.Suspend();
// Start Animation2 
[…]
myScopedBatch.Resume();
// Start Animation3
[…]
// Start Animation4
[…]
myScopedBatch.End();

スコープ指定されたバッチにはアニメーション 1、アニメーション 3、アニメーション 4 が含まれ、アニメーション 2 はスコープ指定されたバッチから除外されます。

1 つのアニメーションの完了イベントを一括処理

1 つのアニメーションがいつ終了するかを知りたい場合は、対象とするアニメーションのみを含むスコープ付きバッチを作成する必要があります。

次に例を示します。

CompositionScopedBatch myScopedBatch = 	_compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
Visual.StartAnimation("Opacity", myAnimation);
myScopedBatch.End();

バッチの完了イベントの取得

アニメーションまたは複数のアニメーションを一括処理する場合、バッチの完了イベントは同様に取得されます。 対象となるバッチの Completed イベントのイベント処理メソッドを登録します。

myScopedBatch.Completed += OnBatchCompleted;

バッチの状態

既存のバッチの状態を判断するために使用できるプロパティは 2 つあります。 IsActiveIsEnded

IsActive プロパティは、ターゲットのバッチが開いており、アニメーションを集計している場合、true を返します。 バッチが中断または終了している場合、IsActive は false を返します。

IsEnded プロパティは、特定のバッチにアニメーションを追加できない場合に true を返します。 特定のバッチに対して End を明示的に呼び出すと、バッチが終了します。

プロパティ

Comment

CompositionObject に関連付ける文字列。

(継承元 CompositionObject)
Compositor

この CompositionObject の作成に使用されるコンポジター

(継承元 CompositionObject)
Dispatcher

CompositionObject のディスパッチャー。

(継承元 CompositionObject)
DispatcherQueue

CompostionObject の DispatcherQueue を取得します。

(継承元 CompositionObject)
ImplicitAnimations

このオブジェクトにアタッチされた暗黙的なアニメーションのコレクション。

(継承元 CompositionObject)
IsActive

集計するオブジェクトに 対して CompositionScopedBatch が現在開かれているかどうかを示します。

IsEnded

CompositionScopedBatch が閉じられ、変更を受け入れなくなったかどうかを示します。

Properties

CompositionObject に関連付けられているプロパティのコレクション。

(継承元 CompositionObject)

メソッド

Close()

CompositionObject を閉じ、システム リソースを解放します。

(継承元 CompositionObject)
ConnectAnimation(String, CompositionAnimation)

接続とアニメーション。

(継承元 CompositionObject)
DisconnectAnimation(String)

アニメーションを切断します。

(継承元 CompositionObject)
Dispose()

アンマネージ リソースの解放またはリセットに関連付けられているアプリケーション定義のタスクを実行します。

(継承元 CompositionObject)
End()

CompositionScopedBatch を閉じます。 CompositionScopedBatch が閉じられたら、中断したり再開したりすることはできません。

PopulatePropertyInfo(String, AnimationPropertyInfo)

アニメーション化できるプロパティを定義します。

(継承元 CompositionObject)
Resume()

CompositionScopedBatch 内のオブジェクトの集計を再開します。

StartAnimation(String, CompositionAnimation)

アニメーションをオブジェクトの指定したプロパティに接続し、アニメーションを開始します。

(継承元 CompositionObject)
StartAnimation(String, CompositionAnimation, AnimationController)

アニメーションをオブジェクトの指定したプロパティに接続し、アニメーションを開始します。

(継承元 CompositionObject)
StartAnimationGroup(ICompositionAnimationBase)

アニメーション グループを開始します。

CompositionObject の StartAnimationGroup メソッドを使用すると、CompositionAnimationGroup を開始できます。 グループ内のすべてのアニメーションは、オブジェクトで同時に開始されます。

(継承元 CompositionObject)
StopAnimation(String)

指定したプロパティからアニメーションを切断し、アニメーションを停止します。

(継承元 CompositionObject)
StopAnimationGroup(ICompositionAnimationBase)

アニメーション グループを停止します。

(継承元 CompositionObject)
Suspend()

CompositionScopedBatch 内のオブジェクトの集約を中断します。

TryGetAnimationController(String)

指定したプロパティで実行されているアニメーションの AnimationController を返します。

(継承元 CompositionObject)

イベント

Completed

CompositionScopedBatch 内のすべてのアニメーションと効果が完了するとトリガーされるイベント。

適用対象

こちらもご覧ください