本文整理汇总了C#中System.Windows.Media.Brush.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Brush.Equals方法的具体用法?C# Brush.Equals怎么用?C# Brush.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Brush
的用法示例。
在下文中一共展示了Brush.Equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BrushToColor
private Color BrushToColor(Brush brush)
{
if (brush.Equals(Brushes.Red))
return Color.Red;
if (brush.Equals(Brushes.Orange))
return Color.Orange;
if (brush.Equals(Brushes.Yellow))
return Color.Yellow;
if (brush.Equals(Brushes.Green))
return Color.Green;
if (brush.Equals(Brushes.Blue))
return Color.Blue;
return Color.Purple;
}
示例2: UpdateCircleColour
private void UpdateCircleColour(Brush brush, Ellipse circle)
{
if (!brush.Equals(Gray) && !circle.Fill.Equals(Gray))
circle.Fill = Violet;
else
circle.Fill = brush;
}
示例3: Equals
public static bool Equals(Brush a, Brush b) {
if (a == b)
return true;
if (a == null || b == null)
return false;
if (a.Opacity == 0 && b.Opacity == 0)
return true;
var sa = a as SolidColorBrush;
var sb = b as SolidColorBrush;
if (sa != null && sb != null) {
if (sa.Color.A == 0 && sb.Color.A == 0)
return true;
return sa.Color.A == sb.Color.A && sa.Color.R == sb.Color.R && sa.Color.G == sb.Color.G && sa.Color.B == sb.Color.B;
}
return a.Equals(b);
}
示例4: CreateTextMaterial
/// <summary>
/// Creates the text material.
/// </summary>
/// <param name="items">The items.</param>
/// <param name="createElement">The create element.</param>
/// <param name="background">The background.</param>
/// <param name="elementMap">The element map.</param>
/// <param name="elementPositions">The element positions.</param>
/// <returns>A text material.</returns>
public static Material CreateTextMaterial(
IEnumerable<TextItem> items,
Func<string, FrameworkElement> createElement,
Brush background,
out Dictionary<string, FrameworkElement> elementMap,
out Dictionary<FrameworkElement, Rect> elementPositions)
{
var panel = new WrapPanel();
elementMap = new Dictionary<string, FrameworkElement>();
double maxWidth = 16;
foreach (var item in items)
{
if (elementMap.ContainsKey(item.Text))
{
continue;
}
var e = createElement(item.Text);
e.Measure(new Size(2048, 2048));
maxWidth = Math.Max(maxWidth, e.DesiredSize.Width);
elementMap[item.Text] = e;
panel.Children.Add(e);
}
var pw = (int)OptimizeSize(panel, maxWidth, 1024);
var ph = (int)Math.Min(pw, panel.ActualHeight);
elementPositions = new Dictionary<FrameworkElement, Rect>();
foreach (FrameworkElement element in panel.Children)
{
var loc = element.TranslatePoint(new Point(0, 0), panel);
double x = (int)Math.Floor(loc.X);
double y = (int)Math.Floor(loc.Y);
double x2 = (int)Math.Ceiling(loc.X + element.RenderSize.Width);
double y2 = (int)Math.Ceiling(loc.Y + element.RenderSize.Height);
elementPositions[element] = new Rect(x / pw, y / ph, (x2 - x) / pw, (y2 - y) / ph);
}
// Create the bitmap
var rtb = new RenderTargetBitmap(pw, ph, 96, 96, PixelFormats.Pbgra32);
rtb.Render(panel);
rtb.Freeze();
var ib = new ImageBrush(rtb)
{
Stretch = Stretch.Fill,
ViewboxUnits = BrushMappingMode.RelativeToBoundingBox,
Viewbox = new Rect(0, 0, 1, 1),
ViewportUnits = BrushMappingMode.Absolute,
Viewport = new Rect(0, 0, 1, 1),
TileMode = TileMode.None,
AlignmentX = AlignmentX.Left,
AlignmentY = AlignmentY.Top
};
if (background != null && !background.Equals(Brushes.Transparent))
{
var mg = new MaterialGroup();
mg.Children.Add(new DiffuseMaterial(Brushes.Black));
mg.Children.Add(new EmissiveMaterial(ib));
return mg;
}
return new DiffuseMaterial(ib) { Color = Colors.White };
}
示例5: Prompt
/// <summary>
/// Prompts with specified colors.
/// </summary>
/// <param name="background">The background.</param>
/// <param name="foreground">The foreground.</param>
/// <param name="prompt">The prompt text.</param>
public void Prompt(Brush foreground, Brush background, string prompt)
{
TrimCurrentParagraph();
//currentParagraph.ContentStart.GetOffsetToPosition(currentParagraph.ContentEnd) + PromptPadding.Length;
Run prmt = new Run(prompt);
if( !background.Equals( this.Background ) ) prmt.Background = background;
prmt.Foreground = foreground;
currentParagraph.Inlines.Add(prmt);
SetPrompt();
// toggle undo to prevent "undo"ing past this point.
IsUndoEnabled = false;
IsUndoEnabled = true;
promptInlines = currentParagraph.Inlines.Count;
}
示例6: Equals
static bool Equals(Brush a, Brush b) {
if (a == b)
return true;
if (a == null || b == null)
return false;
if (a.Opacity == 0 && b.Opacity == 0)
return true;
var sa = a as SolidColorBrush;
var sb = b as SolidColorBrush;
if (sa != null && sb != null) {
var ca = sa.Color;
var cb = sb.Color;
return ca == cb || (ca.A == 0 && cb.A == 0);
}
return a.Equals(b);
}
示例7: CompareBrushes
private bool CompareBrushes(Brush brush1, Brush brush2)
{
return !brush1.Equals(brush2);
}
示例8: Equals
private static bool Equals(Brush a, Brush b)
{
if (a == null)
return b == null;
return a.Equals(b);
}