本文整理汇总了C#中Windows.UI.Xaml.Media.Brush.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Brush.GetType方法的具体用法?C# Brush.GetType怎么用?C# Brush.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Media.Brush
的用法示例。
在下文中一共展示了Brush.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsEqualTo
/// <summary>
/// Verifies if the given brush is the same as the otherBrush.
/// </summary>
/// <param name="brush">Brush</param>
/// <param name="otherBrush">Brush</param>
/// <returns>true if yes, otherwise false</returns>
public static bool IsEqualTo(this Brush brush, Brush otherBrush)
{
if (brush.GetType() != otherBrush.GetType())
return false;
if (ReferenceEquals(brush, otherBrush))
return true;
// Are both instances of SolidColorBrush
var solidBrushA = brush as SolidColorBrush;
var solidBrushB = otherBrush as SolidColorBrush;
if ((solidBrushA != null) && (solidBrushB != null))
{
return (solidBrushA.Color == solidBrushB.Color)
&& solidBrushA.Opacity.IsCloseTo(solidBrushB.Opacity);
}
// Are both instances of LinearGradientBrush
var linGradBrushA = brush as LinearGradientBrush;
var linGradBrushB = otherBrush as LinearGradientBrush;
if ((linGradBrushA != null) && (linGradBrushB != null))
{
var result = (linGradBrushA.ColorInterpolationMode == linGradBrushB.ColorInterpolationMode)
&& (linGradBrushA.EndPoint == linGradBrushB.EndPoint)
&& (linGradBrushA.MappingMode == linGradBrushB.MappingMode)
&& linGradBrushA.Opacity.IsCloseTo(linGradBrushB.Opacity)
&& (linGradBrushA.StartPoint == linGradBrushB.StartPoint)
&& (linGradBrushA.SpreadMethod == linGradBrushB.SpreadMethod)
&& (linGradBrushA.GradientStops.Count == linGradBrushB.GradientStops.Count);
if (!result)
return false;
for (var i = 0; i < linGradBrushA.GradientStops.Count; i++)
{
result = (linGradBrushA.GradientStops[i].Color == linGradBrushB.GradientStops[i].Color)
&& linGradBrushA.GradientStops[i].Offset.IsCloseTo(linGradBrushB.GradientStops[i].Offset);
if (!result)
break;
}
return result;
}
// Are both instances of RadialGradientBrush
//var radGradBrushA = brush as RadialGradientBrush;
//var radGradBrushB = otherBrush as RadialGradientBrush;
//if ((radGradBrushA != null) && (radGradBrushB != null))
//{
// var result = (radGradBrushA.ColorInterpolationMode == radGradBrushB.ColorInterpolationMode)
// && (radGradBrushA.GradientOrigin == radGradBrushB.GradientOrigin)
// && (radGradBrushA.MappingMode == radGradBrushB.MappingMode)
// && radGradBrushA.Opacity.IsCloseTo(radGradBrushB.Opacity)
// && radGradBrushA.RadiusX.IsCloseTo(radGradBrushB.RadiusX)
// && radGradBrushA.RadiusY.IsCloseTo(radGradBrushB.RadiusY)
// && (radGradBrushA.SpreadMethod == radGradBrushB.SpreadMethod)
// && (radGradBrushA.GradientStops.Count == radGradBrushB.GradientStops.Count);
// if (!result)
// return false;
// for (var i = 0; i < radGradBrushA.GradientStops.Count; i++)
// {
// result = (radGradBrushA.GradientStops[i].Color == radGradBrushB.GradientStops[i].Color)
// && radGradBrushA.GradientStops[i].Offset.IsCloseTo(radGradBrushB.GradientStops[i].Offset);
// if (!result)
// break;
// }
// return result;
//}
// Are both instances of ImageBrush
var imgBrushA = brush as ImageBrush;
var imgBrushB = otherBrush as ImageBrush;
if ((imgBrushA != null) && (imgBrushB != null))
{
var result = (imgBrushA.AlignmentX == imgBrushB.AlignmentX)
&& (imgBrushA.AlignmentY == imgBrushB.AlignmentY)
&& imgBrushA.Opacity.IsCloseTo(imgBrushB.Opacity)
&& (imgBrushA.Stretch == imgBrushB.Stretch)
//&& (imgBrushA.TileMode == imgBrushB.TileMode)
//&& (imgBrushA.Viewbox == imgBrushB.Viewbox)
//&& (imgBrushA.ViewboxUnits == imgBrushB.ViewboxUnits)
//&& (imgBrushA.Viewport == imgBrushB.Viewport)
//&& (imgBrushA.ViewportUnits == imgBrushB.ViewportUnits)
&& (imgBrushA.ImageSource == imgBrushB.ImageSource);
return result;
}
//.........这里部分代码省略.........