CompositionScopedBatch クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
アクティブなアニメーションまたは効果の明示的に作成されたグループ。
public ref class CompositionScopedBatch sealed : CompositionObject
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.LiftedContract, 65536)]
/// [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.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65536)]
class CompositionScopedBatch final : CompositionObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.LiftedContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class CompositionScopedBatch : CompositionObject
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65536)]
public sealed class CompositionScopedBatch : CompositionObject
Public NotInheritable Class CompositionScopedBatch
Inherits CompositionObject
- 継承
- 属性
例
スコープ付きバッチ
// 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 インスタンスを作成でき、オブジェクトを複数のバッチで同時に集計できます。
Create
特定のアニメーション グループを集計したり、単一のアニメーションの完了イベントを対象にしたりするには、スコープ付きバッチを作成します。 スコープ付きバッチは 、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 つのアニメーションの完了イベントのバッチ処理
1 つのアニメーションがいつ終了するかを知りたい場合は、対象とするアニメーションのみを含むスコープ付きバッチを作成する必要があります。
例えば次が挙げられます。
CompositionScopedBatch myScopedBatch = _compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
Visual.StartAnimation("Opacity", myAnimation);
myScopedBatch.End();
バッチの完了イベントの取得
アニメーションまたは複数のアニメーションをバッチ処理する場合は、バッチの完了イベントを同じ方法で取得します。 対象となるバッチの Completed イベントのイベント処理メソッドを登録します。
myScopedBatch.Completed += OnBatchCompleted;
バッチ状態
既存のバッチの状態を判断するために使用できるプロパティは 2 つあります。 IsActive と IsEnded。
IsActive プロパティは、対象のバッチがアニメーションの集計を開いている場合に true を返します。 IsActive は、バッチが中断または終了されたときに false を返します。
IsEnded プロパティは、その特定のバッチにアニメーションを追加できない場合に true を返します。 特定のバッチに対して End を明示的に呼び出すと、バッチは終了します。
プロパティ
| 名前 | 説明 |
|---|---|
| Comment |
CompositionObject に関連付ける文字列。 (継承元 CompositionObject) |
| Compositor |
この CompositionObject の作成に使用するコンポジター。 (継承元 CompositionObject) |
| DispatcherQueue |
CompositionObject の DispatcherQueue を取得します。 (継承元 CompositionObject) |
| ImplicitAnimations |
このオブジェクトにアタッチされている暗黙的なアニメーションのコレクション。 (継承元 CompositionObject) |
| IsActive |
集計するオブジェクトに 対して CompositionScopedBatch が現在開かれているかどうかを示します。 |
| IsEnded |
CompositionScopedBatch が閉じられ、変更を受け入れなくなったかどうかを示します。 |
| Properties |
CompositionObject に関連付けられているプロパティのコレクション。 (継承元 CompositionObject) |
メソッド
イベント
| 名前 | 説明 |
|---|---|
| Completed |
CompositionScopedBatch 内のすべてのアニメーションと効果が完了するとトリガーされるイベント。 |
適用対象
こちらもご覧ください
- CompositionObject
- コンポジション アニメーションの概要
- IClosable の