Ich denke ich muss wohl doch ein eigenes Gradient erstellen. Ich poste mal ausschnitte aus LinearGradientBrush laut .NET Reflector:
Dies ist die einzige Methode die das eigendliche Zeichnen antriggert:
[SecurityCritical, SecurityTreatAsSafe]
internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
{
this.ManualUpdateResource(channel, skipOnChannelCheck);//<-eigendlicher Zeichenvorgang
base.UpdateResource(channel, skipOnChannelCheck);
}
Wenn das jetzt nicht internal wäre könnte ich UpdateResource ja auch überschreiben und dort ein Gradient malen. Diese Methode ist für mich jedoch leider nicht sichtbar....
Hier das eigendilche Zeichnen:
[SecurityTreatAsSafe, SecurityCritical]
private unsafe void ManualUpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
{
if (skipOnChannelCheck || this._duceResource.IsOnChannel(channel))
{
DUCE.ResourceHandle handle;
DUCE.ResourceHandle @null;
DUCE.MILCMD_LINEARGRADIENTBRUSH milcmd_lineargradientbrush;
Transform objA = base.Transform;
Transform relativeTransform = base.RelativeTransform;
GradientStopCollection gradientStops = base.GradientStops;
if ((objA == null) || object.ReferenceEquals(objA, Transform.Identity))
{
@null = DUCE.ResourceHandle.Null;
}
else
{
@null = ((DUCE.IResource) objA).GetHandle(channel);
}
if ((relativeTransform == null) || object.ReferenceEquals(relativeTransform, Transform.Identity))
{
handle = DUCE.ResourceHandle.Null;
}
else
{
handle = ((DUCE.IResource) relativeTransform).GetHandle(channel);
}
DUCE.ResourceHandle animationResourceHandle = base.GetAnimationResourceHandle(Brush.OpacityProperty, channel);
DUCE.ResourceHandle handle4 = base.GetAnimationResourceHandle(StartPointProperty, channel);
DUCE.ResourceHandle handle3 = base.GetAnimationResourceHandle(EndPointProperty, channel);
milcmd_lineargradientbrush.Type = MILCMD.MilCmdLinearGradientBrush;
milcmd_lineargradientbrush.Handle = this._duceResource.GetHandle(channel);
double opacity = base.Opacity;
DUCE.CopyBytes((byte*) &milcmd_lineargradientbrush.Opacity, (byte*) &opacity, 8);
milcmd_lineargradientbrush.hOpacityAnimations = animationResourceHandle;
milcmd_lineargradientbrush.hTransform = @null;
milcmd_lineargradientbrush.hRelativeTransform = handle;
milcmd_lineargradientbrush.ColorInterpolationMode = base.ColorInterpolationMode;
milcmd_lineargradientbrush.MappingMode = base.MappingMode;
milcmd_lineargradientbrush.SpreadMethod = base.SpreadMethod;
Point startPoint = this.StartPoint;
DUCE.CopyBytes((byte*) &milcmd_lineargradientbrush.StartPoint, (byte*) &startPoint, 0x10);
milcmd_lineargradientbrush.hStartPointAnimations = handle4;
Point endPoint = this.EndPoint;
DUCE.CopyBytes((byte*) &milcmd_lineargradientbrush.EndPoint, (byte*) &endPoint, 0x10);
milcmd_lineargradientbrush.hEndPointAnimations = handle3;
int num2 = (gradientStops == null) ? 0 : gradientStops.Count;
milcmd_lineargradientbrush.GradientStopsSize = (uint) (sizeof(DUCE.MIL_GRADIENTSTOP) * num2);
channel.BeginCommand((byte*) &milcmd_lineargradientbrush, sizeof(DUCE.MILCMD_LINEARGRADIENTBRUSH), sizeof(DUCE.MIL_GRADIENTSTOP) * num2);
//Hier werden wohl die Gradientstops durchlaufen
for (int i = 0; i < num2; i++)
{
DUCE.MIL_GRADIENTSTOP mil_gradientstop;
GradientStop stop = gradientStops.Internal_GetItem(i);
double offset = stop.Offset;
DUCE.CopyBytes((byte*) &mil_gradientstop.Position, (byte*) &offset, 8);
mil_gradientstop.Color = CompositionResourceManager.ColorToMilColorF(stop.Color);
channel.AppendCommandData((byte*) &mil_gradientstop, sizeof(DUCE.MIL_GRADIENTSTOP));
}
channel.EndCommand();
}
}