本文整理汇总了C#中System.Drawing.Color类的典型用法代码示例。如果您正苦于以下问题:C# Color类的具体用法?C# Color怎么用?C# Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Color类属于System.Drawing命名空间,在下文中一共展示了Color类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: averageColor
private static Color averageColor(Color one, Color two, Color three, Color four)
{
int r = (one.R + two.R + three.R + four.R) / 4;
int g = (one.G + two.G + three.G + four.G) / 4;
int b = (one.B + two.B + three.B + four.B) / 4;
return Color.FromArgb(r, g, b);
}
示例2: ScrollBarThumb
public ScrollBarThumb(ScrollBarThumbDefaults type)
{
this._imageAttributes = new ImageAttributes();
this._imageAttributes.ClearColorKey();
this._gripImageAttributes = new ImageAttributes();
this._gripImageAttributes.ClearColorKey();
switch (type)
{
case ScrollBarThumbDefaults.Normal:
this._color = SystemColors.ScrollBar;
this._gripColor = SystemColors.ControlText;
break;
case ScrollBarThumbDefaults.Highlight:
this._color = SystemColors.ControlText;
this._gripColor = SystemColors.HighlightText;
break;
}
this._borderStyle = ScrollBarBorderStyle.Solid;
this._borderColor = SystemColors.ControlText;
this._gradientColor = new Resco.Controls.ScrollBar.GradientColor(FillDirection.Horizontal);
this._gradientColor.PropertyChanged += new EventHandler(this.GradientColor_PropertyChanged);
this._image = null;
this._imageLayout = ScrollBarThumbImageLayout.Stretch;
this._imageTransparentColor = System.Drawing.Color.Transparent;
this._gripStyle = ScrollBarThumbGripStyle.Lines;
this._gripImage = null;
this._gripImageTransparentColor = System.Drawing.Color.Transparent;
this._gripLines = 3;
}
示例3: CalculateGraphicsPathFromBitmap
// From http://edu.cnzz.cn/show_3281.html
public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap, Color colorTransparent)
{
GraphicsPath graphicsPath = new GraphicsPath();
if (colorTransparent == Color.Empty)
colorTransparent = bitmap.GetPixel(0, 0);
for (int row = 0; row < bitmap.Height; row++)
{
int colOpaquePixel = 0;
for (int col = 0; col < bitmap.Width; col++)
{
if (bitmap.GetPixel(col, row) != colorTransparent)
{
colOpaquePixel = col;
int colNext = col;
for (colNext = colOpaquePixel; colNext < bitmap.Width; colNext++)
if (bitmap.GetPixel(colNext, row) == colorTransparent)
break;
graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1));
col = colNext;
}
}
}
return graphicsPath;
}
示例4: HSLColor
public HSLColor(Color color)
{
RGB = color;
H = (byte)((color.GetHue() / 360.0f) * 255);
S = (byte)(color.GetSaturation() * 255);
L = (byte)(color.GetBrightness() * 255);
}
示例5: CustomBitmapRenderer
public CustomBitmapRenderer()
{
BackgroundGradientColor = Color.Aqua;
Background = Color.GreenYellow;
ForegroundGradientColor = Color.RoyalBlue;
Foreground = Color.MidnightBlue;
}
示例6: SeparatorWidget
public SeparatorWidget(string separator = "|", Color? backgroundColor = null, Color? foregroundColor = null)
{
this.separator = separator;
this.backgroundColor = backgroundColor ?? Color.White;
this.foregroundColor = foregroundColor ?? Color.Black;
}
示例7: OptionsWindow_Load
private void OptionsWindow_Load(object sender, System.EventArgs e)
{
hourColor = Properties.Settings.Default.HourColor;
minuteColor = Properties.Settings.Default.MinuteColor;
secondColor = Properties.Settings.Default.SecondColor;
backColor = Properties.Settings.Default.BackColor;
brushWeight = Properties.Settings.Default.Weight;
spacing = Properties.Settings.Default.Spacing;
_24HourFormat = Settings.Default.TimeFormat;
btnSecondColor.BackColor = secondColor;
btnHourColor.BackColor = hourColor;
btnMinuteColor.BackColor = minuteColor;
btnBackColor.BackColor = backColor;
txtBrushWeight.Text = brushWeight.ToString();
txtSpacing.Text = spacing.ToString();
btnMinuteColor.Text = minuteColor.Name;
btnHourColor.Text = hourColor.Name;
btnSecondColor.Text = secondColor.Name;
btnBackColor.Text = backColor.Name;
chk24Hour.Checked = _24HourFormat;
}
示例8: ConvertImage
public static void ConvertImage(Bitmap image, Graphics g, Color ForeColor, Color BackColor, bool isActive)
{
using (ImageAttributes imageAttributes = new ImageAttributes())
{
ColorMap[] colorMap = new ColorMap[2];
colorMap[0] = new ColorMap();
colorMap[0].OldColor = Color.FromArgb(0, 0, 0);
colorMap[0].NewColor = ForeColor;
colorMap[1] = new ColorMap();
colorMap[1].OldColor = image.GetPixel(0, 0);
colorMap[1].NewColor = isActive ? BackColor : Color.Transparent;
imageAttributes.SetRemapTable(colorMap);
g.DrawImage(
image,
new Rectangle(0, 0, image.Width, image.Height),
0, 0,
image.Width,
image.Height,
GraphicsUnit.Pixel,
imageAttributes);
}
}
示例9: AreEqual
public static void AreEqual(Color expected, Color actual)
{
Assert.AreEqual(expected.R, actual.R, "R is not equal");
Assert.AreEqual(expected.G, actual.G, "G is not equal");
Assert.AreEqual(expected.B, actual.B, "B is not equal");
Assert.AreEqual(expected.A, actual.A, "A is not equal");
}
示例10: Write
public void Write(uint x, uint y, Color colour)
{
Pen p = new Pen(colour);
lock (image) {
image.SetPixel((int)x, (int)(Height - y - 1), colour);
}
}
示例11: Pixel
public Pixel( Color c )
{
B = c.B;
G = c.G;
R = c.R;
A = c.A;
}
示例12: DrawItem
// For Ownder Drawn TreeViews
public static void DrawItem(this DrawTreeNodeEventArgs e, Color channelColor, TreeView treeView, bool useCheckmark)
{
if (treeView == null) {
e.DrawDefault = true;
return;
}
if (e.Bounds.Left < 0 || e.Bounds.Top < 0) {
return;
}
var fillRect = new Rectangle(e.Node.Bounds.X, e.Node.Bounds.Y, treeView.Width - e.Node.Bounds.Left, e.Node.Bounds.Height);
GenericBrush.Color = channelColor;
bool selected;
var view = treeView as MultiSelectTreeview;
if (view != null) {
selected = view.SelectedNodes.Contains(e.Node);
}
else {
selected = (e.State & TreeNodeStates.Selected) != 0;
}
var rectBrush = selected && !useCheckmark ? SystemBrushes.Highlight : GenericBrush;
e.Graphics.FillRectangle(rectBrush, fillRect);
var stringBrush = selected && !useCheckmark ? SystemBrushes.HighlightText : channelColor.GetTextColor();
e.Graphics.DrawString(e.Node.Text, treeView.Font, stringBrush, e.Bounds.Left, e.Bounds.Top);
if (selected && useCheckmark) {
e.Graphics.DrawString(Checkmark, treeView.Font, channelColor.GetTextColor(), fillRect.Right - 40, e.Bounds.Top);
}
}
示例13: DrawTextCentered
public static void DrawTextCentered(this Font font,
string text,
Obj_AI_Base target,
Color color,
bool outline = false)
{
var measure = GetMeasured(font, text);
var position = Drawing.WorldToScreen(target.Position);
if (outline)
{
font.DrawText(
null, text, (int)(position.X + 1 - measure.Width * 0.5f),
(int)(position.Y + 1 - measure.Height * 0.5f), XDColor.Black);
font.DrawText(
null, text, (int)(position.X - 1 - measure.Width * 0.5f),
(int)(position.Y - 1 - measure.Height * 0.5f), XDColor.Black);
font.DrawText(
null, text, (int)(position.X + 1 - measure.Width * 0.5f),
(int)(position.Y - measure.Height * 0.5f), XDColor.Black);
font.DrawText(
null, text, (int)(position.X - 1 - measure.Width * 0.5f),
(int)(position.Y - measure.Height * 0.5f), XDColor.Black);
}
font.DrawText(
null, text, (int)(position.X - measure.Width * 0.5f), (int)(position.Y - measure.Height * 0.5f), new XDColor(color.R, color.G, color.B, color.A));
}
示例14: GetColor
public static Color GetColor(float alpha, Color baseColor)
{
if (alpha >= 1) return baseColor;
else if (alpha < 0) return Color.Transparent;
return Color.FromArgb((int)(alpha * 255), baseColor);
}
示例15: Move
public new void Move(float Dx, float Dy, float Dlg, float Dlv, Color BackColor, Graphics G)
{
RePain(Dlg, Dlv, BackColor, BorderWidth, 1, G);
Xn += Dx;
Yn += Dy;
RePain(Dlg, Dlv, false, 1, G);
}