本文整理汇总了C#中System.Windows.Media.Color类的典型用法代码示例。如果您正苦于以下问题:C# Color类的具体用法?C# Color怎么用?C# Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Color类属于System.Windows.Media命名空间,在下文中一共展示了Color类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateBlockBox
public static Border CreateBlockBox(FrameworkElement child, double width, double height, double x, double y, Color backgroundColor)
{
var border = new Border()
{
BorderThickness = new Thickness(1, 1, 1, 1),
BorderBrush = Brushes.Silver,
Background = new SolidColorBrush(backgroundColor),
Width = width,
Height = height,
Margin = new Thickness(x, y, 0, 0),
Child = child
};
border.MouseEnter += (s, e) =>
{
border.Width = Math.Max(width, child.ActualWidth);
border.Height = Math.Max(height, child.ActualHeight);
Panel parent = (Panel)border.Parent;
border.TopMost();
};
border.MouseLeave += (s, e) =>
{
border.Width = width;
border.Height = height;
};
return border;
}
示例2: CellColorActionViewModel
public CellColorActionViewModel(string name, string description, char code, Color backgroundColor)
{
Name = name;
Description = description;
Code = code;
BackgroundBrush = new SolidColorBrush(backgroundColor);
}
示例3: Dipolar
public static IColorSequence Dipolar(Color negativeColor, Color positiveColor, int halfStepCount)
{
return new Ir1ColorSequence(
new ColorSequenceImpl(positiveColor.LessFadingSpread(halfStepCount)),
new ColorSequenceImpl(negativeColor.LessFadingSpread(halfStepCount))
);
}
示例4: ToGradient
/// <summary>Creates a gradient brush with the given colors flowing in the specified direction.</summary>
/// <param name="direction">The direction of the gradient.</param>
/// <param name="start">The starting color.</param>
/// <param name="end">The ending color.</param>
public static LinearGradientBrush ToGradient(this Direction direction, Color start, Color end)
{
// Create the brush.
var brush = new LinearGradientBrush();
switch (direction)
{
case Direction.Down:
case Direction.Up:
brush.StartPoint = new Point(0.5, 0);
brush.EndPoint = new Point(0.5, 1);
break;
case Direction.Right:
case Direction.Left:
brush.StartPoint = new Point(0, 0.5);
brush.EndPoint = new Point(1, 0.5);
break;
}
// Configure colors.
var gradientStart = new GradientStop { Color = start };
var gradientEnd = new GradientStop { Color = end };
gradientStart.Offset = direction == Direction.Up || direction == Direction.Left ? 1 : 0;
gradientEnd.Offset = direction == Direction.Down || direction == Direction.Right ? 1 : 0;
// Insert colors.
brush.GradientStops.Add(gradientStart);
brush.GradientStops.Add(gradientEnd);
// Finish up.
return brush;
}
示例5: CustomStartEndLineStyle
public CustomStartEndLineStyle(PointSymbolType startType, Color startColor, int startSize,
PointSymbolType endType, Color endColor, int endSize,
Color lineColor, float lineSize)
: this(new PointStyle(startType, new GeoSolidBrush(GeoColor.FromArgb(startColor.A, startColor.R, startColor.G, startColor.B)), startSize),
new PointStyle(endType, new GeoSolidBrush(GeoColor.FromArgb(endColor.A, endColor.R, endColor.G, endColor.B)), endSize),
new LineStyle(new GeoPen(GeoColor.FromArgb(lineColor.A, lineColor.R, lineColor.G, lineColor.B), lineSize)))
{ }
示例6: AdministrationViewModel
public AdministrationViewModel(ICustomAppearanceManager appearanceManager, IAppSettings appSettings)
{
this.appearanceManager = appearanceManager;
this.appSettings = appSettings;
selectedAccentColor = appearanceManager.AccentColor;
selectedTextColor = appearanceManager.TextColor;
}
示例7: LogFile
public LogFile(string path, Color color, string timestampPattern, LogOffset offset)
{
Path = path;
Color = color;
TimestampPattern = timestampPattern;
Offset = offset;
}
示例8: AlternatingListBoxBackground
public AlternatingListBoxBackground(Color color1, Color color2)
{
var setter = new Setter();
setter.Property = ListBoxItem.BackgroundProperty;
setter.Value = new SolidColorBrush(color1);
var trigger = new Trigger();
trigger.Property = ItemsControl.AlternationIndexProperty;
trigger.Value = 0;
trigger.Setters.Add(setter);
var setter2 = new Setter();
setter2.Property = ListBoxItem.BackgroundProperty;
setter2.Value = new SolidColorBrush(color2);
var trigger2 = new Trigger();
trigger2.Property = ItemsControl.AlternationIndexProperty;
trigger2.Value = 1;
trigger2.Setters.Add(setter2);
var listBoxStyle = new Style(typeof(ListBoxItem));
listBoxStyle.Triggers.Add(trigger);
listBoxStyle.Triggers.Add(trigger2);
_listBoxStyle = listBoxStyle;
}
示例9: ColorRange
public ColorRange(Color lowColor, Color highColor, float lowHeight, float highHeight)
{
LowColor = lowColor;
HighColor = highColor;
LowHeight = lowHeight;
HighHeight = highHeight;
}
示例10: Dijkstra
public Dijkstra(Color main, Color temp, Color search, Color next)
{
mainColor=new SolidColorBrush(main);
tempColor=new SolidColorBrush(temp);
nextColor=new SolidColorBrush(next);
searchColor=new SolidColorBrush(search);
}
示例11: DrawingToMediaColor
} // DrawingToMediaColor()
/// <summary>
/// Converts a System.Windows.Media.Color value to a
/// System.Drawing.Color value.
/// </summary>
/// <param name="color">A System.Windows.Media.Color value.</param>
/// <returns>A System.Drawing.Color value.</returns>
public static System.Drawing.Color MediaToDrawingColor(Color color)
{
System.Drawing.Color colorNew = System.Drawing.Color.FromArgb(
color.A, color.R, color.G, color.B);
return colorNew;
} // MediaToDrawingColor()
示例12: Color
/// <summary>
/// Initializes a new instance of the <see cref="Color"/> class.
/// </summary>
/// <param name="mediaColor">The color.</param>
/// <param name="invariantName">The culture-insensitive name of the color. (Optional.)</param>
/// <param name="name">The localized friendly name of the color. (Optional.)</param>
/// <param name="isBuiltIn">A value indicating whether this color is defined in the assembly. (Optional.)</param>
public Color(System.Windows.Media.Color mediaColor, string invariantName = null, string name = null, bool isBuiltIn = false)
{
this.name = name;
this.identifier = isBuiltIn ? ("resource:" + invariantName) : ("color:" + mediaColor);
this.isBuiltIn = isBuiltIn;
this.mediaColor = mediaColor;
}
示例13: DualBrushes
public static IZ1BrushSequence DualBrushes(Color positiveColor, Color negativeColor, int steps)
{
return new Z1BrushSequence(
positiveBrushes: positiveColor.FadingSpread(steps + 1).ToBrushes(),
negativeBrushes: negativeColor.FadingSpread(steps + 1).ToBrushes()
);
}
示例14: CleanCodeRank
public CleanCodeRank(Color color, string name)
{
Color = new SolidColorBrush(color);
Name = " " + name;
Principles = new ObservableCollection<CleanCodePrinciple>();
Practices = new ObservableCollection<CleanCodePractice>();
}
示例15: ErrorTextMarker
public ErrorTextMarker(int startOffset, int length, string message, Color markerColor)
{
StartOffset = startOffset;
Length = length;
Message = message;
MarkerColor = markerColor;
}