DrawingContext.PushOpacity Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Envoie (push) le paramètre d’opacité spécifié dans le contexte de dessin.
Surcharges
| Nom | Description |
|---|---|
| PushOpacity(Double) |
Envoie (push) le paramètre d’opacité spécifié dans le contexte de dessin. |
| PushOpacity(Double, AnimationClock) |
Envoie (push) le paramètre d’opacité spécifié dans le contexte de dessin et applique l’horloge d’animation spécifiée. |
PushOpacity(Double)
Envoie (push) le paramètre d’opacité spécifié dans le contexte de dessin.
public:
abstract void PushOpacity(double opacity);
public abstract void PushOpacity(double opacity);
abstract member PushOpacity : double -> unit
Public MustOverride Sub PushOpacity (opacity As Double)
Paramètres
- opacity
- Double
Facteur d’opacité à appliquer aux commandes de dessin suivantes. Ce facteur est cumulatif avec les opérations précédentes PushOpacity(Double) .
Exemples
L’exemple suivant illustre les commandes et PushOpacityPushEffect les Popcommandes.
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Effects;
namespace SDKSample
{
public class PushEffectExample : Page
{
public PushEffectExample()
{
Pen shapeOutlinePen = new Pen(Brushes.Black, 2);
shapeOutlinePen.Freeze();
// Create a DrawingGroup
DrawingGroup dGroup = new DrawingGroup();
// Obtain a DrawingContext from
// the DrawingGroup.
using (DrawingContext dc = dGroup.Open())
{
// Draw a rectangle at full opacity.
dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, new Rect(0, 0, 25, 25));
// Push an opacity change of 0.5.
// The opacity of each subsequent drawing will
// will be multiplied by 0.5.
dc.PushOpacity(0.5);
// This rectangle is drawn at 50% opacity.
dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, new Rect(25, 25, 25, 25));
}
// Display the drawing using an image control.
Image theImage = new Image();
DrawingImage dImageSource = new DrawingImage(dGroup);
theImage.Source = dImageSource;
this.Content = theImage;
}
}
}
Imports System.Windows.Media.Animation
Imports System.Windows.Media.Effects
Namespace SDKSample
Public Class PushEffectExample
Inherits Page
Public Sub New()
Dim shapeOutlinePen As New Pen(Brushes.Black, 2)
shapeOutlinePen.Freeze()
' Create a DrawingGroup
Dim dGroup As New DrawingGroup()
' Obtain a DrawingContext from
' the DrawingGroup.
Using dc As DrawingContext = dGroup.Open()
' Draw a rectangle at full opacity.
dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, New Rect(0, 0, 25, 25))
' Push an opacity change of 0.5.
' The opacity of each subsequent drawing will
' will be multiplied by 0.5.
dc.PushOpacity(0.5)
' This rectangle is drawn at 50% opacity.
dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, New Rect(25, 25, 25, 25))
End Using
' Display the drawing using an image control.
Dim theImage As New Image()
Dim dImageSource As New DrawingImage(dGroup)
theImage.Source = dImageSource
Me.Content = theImage
End Sub
End Class
End Namespace
Remarques
L’opacité est fusionnée dans toutes les commandes de dessin suivantes jusqu’à ce qu’elle soit supprimée par la Pop commande.
S’applique à
PushOpacity(Double, AnimationClock)
Envoie (push) le paramètre d’opacité spécifié dans le contexte de dessin et applique l’horloge d’animation spécifiée.
public:
abstract void PushOpacity(double opacity, System::Windows::Media::Animation::AnimationClock ^ opacityAnimations);
public abstract void PushOpacity(double opacity, System.Windows.Media.Animation.AnimationClock opacityAnimations);
abstract member PushOpacity : double * System.Windows.Media.Animation.AnimationClock -> unit
Public MustOverride Sub PushOpacity (opacity As Double, opacityAnimations As AnimationClock)
Paramètres
- opacity
- Double
Facteur d’opacité à appliquer aux commandes de dessin suivantes. Ce facteur est cumulatif avec les opérations précédentes PushOpacity(Double) .
- opacityAnimations
- AnimationClock
Horloge avec laquelle animer la valeur d’opacité, ou null pour aucune animation. Cette horloge doit être créée à partir d’une AnimationTimeline horloge qui peut animer Double des valeurs.
Remarques
L’opacité est fusionnée dans toutes les commandes de dessin suivantes jusqu’à ce qu’elle soit supprimée par la Pop commande.