本文整理汇总了C#中Color.GetValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# Color.GetValueOrDefault方法的具体用法?C# Color.GetValueOrDefault怎么用?C# Color.GetValueOrDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.GetValueOrDefault方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawString
public void DrawString(string text, Vector2 pos, float size, float align = 0, Color? color = null)
{
var c = color.GetValueOrDefault(Color.LightYellow);
var valign = new Vector2(Font.MeasureString(text).X*align, 0);
size *= FontScaleRatio;
SpriteBatch.DrawString(
Font,
text,
pos + Vector2.One,
Color.Black*(c.A/255f),
0,
valign,
size,
SpriteEffects.None,
0);
SpriteBatch.DrawString(
Font,
text,
pos,
c,
0,
valign,
size,
SpriteEffects.None,
0);
}
示例2: logl
private void logl(string msg, Color? color = null)
{
int start = LogBox.TextLength;
LogBox.AppendText(msg);
int end = LogBox.TextLength;
LogBox.Select(start, end - start);
LogBox.SelectionColor = color.GetValueOrDefault(Color.Black);
LogBox.SelectionLength = 0;
}
示例3: WithSubTitleFont
public virtual INodeStyleSchema WithSubTitleFont(string font, int? fontsize, Color? color, FontStyle? style)
{
SubTitleFontStyle = style.GetValueOrDefault(SubTitleFontStyle);
SubTitleFontSize = fontsize.GetValueOrDefault(SubTitleFontSize);
SubTitleColor = color.GetValueOrDefault(SubTitleColor);
if (!string.IsNullOrEmpty(font))
SubTitleFont = font;
return this;
}
示例4: TextShadow
public static void TextShadow(SpriteBatch spritebatch, SpriteFont font, String text, Vector2 textPosition, Vector2? shadowPosition, Color textColor, Color? shadowColor)
{
if (shadowPosition == null)
{
shadowPosition = new Vector2(textPosition.X + 5, textPosition.Y + 5);
}
if (shadowColor == null)
{
shadowColor = Color.Black;
}
spritebatch.DrawString(font, text, shadowPosition.GetValueOrDefault(), shadowColor.GetValueOrDefault());
spritebatch.DrawString(font, text, textPosition, textColor);
}
示例5: TileButton
public TileButton(string text, int row, int column, EventHandler handler = null, Color? color = null)
: base(text, row, column)
{
this.color = color == null ? Color.White : color.GetValueOrDefault();
ClickMethod += handler;
label = new Label
{
Text = text,
ForeColor = this.color,
AutoSize = false,
TextAlign = ContentAlignment.MiddleCenter,
Dock = DockStyle.Fill,
Font = new Font("Century Gothic", 14)
};
label.Click += ClickMethod;
}
示例6: ToTransparentFromGrayScale
public static Color ToTransparentFromGrayScale(this Color color, Color? newRGBColor)
{
return Color.FromArgb(
color.ToGrayScale().R,
newRGBColor.GetValueOrDefault(color));
}
示例7: Draw
public void Draw(
Texture2D texture, Rectangle destRectangle,
Rectangle? sourceRectangle = null, Color? multiplyColor = null, Color addColor = default(Color),
float rotation = 0, float originX = 0, float originY = 0,
bool mirrorX = false, bool mirrorY = false, float sortKey = 0,
int? layer = null, bool? worldSpace = null,
BlendState blendState = null, SamplerState samplerState = null
)
{
var drawCall = new BitmapDrawCall(texture, new Vector2(destRectangle.X, destRectangle.Y));
if (sourceRectangle.HasValue) {
var sr = sourceRectangle.Value;
drawCall.TextureRegion = texture.BoundsFromRectangle(ref sr);
drawCall.Scale = new Vector2(destRectangle.Width / (float)sr.Width, destRectangle.Height / (float)sr.Height);
} else {
drawCall.Scale = new Vector2(destRectangle.Width / (float)texture.Width, destRectangle.Height / (float)texture.Height);
}
drawCall.MultiplyColor = multiplyColor.GetValueOrDefault(Color.White);
drawCall.AddColor = addColor;
drawCall.Rotation = rotation;
drawCall.Origin = new Vector2(originX, originY);
if (mirrorX || mirrorY)
drawCall.Mirror(mirrorX, mirrorY);
drawCall.SortKey = sortKey;
Draw(ref drawCall, layer: layer, worldSpace: worldSpace, blendState: blendState, samplerState: samplerState);
}
示例8: ShowOverlay
/// <summary>
/// Zeigt die Überlagerung an.
/// </summary>
/// <param name="bitmap">Im OSD anzuzeigende Daten.</param>
/// <param name="left">Relative Position des OSD (linker Rand).</param>
/// <param name="top">Relative Position des OSD (oberer Rand).</param>
/// <param name="right">Relative Position des OSD (rechter Rand).</param>
/// <param name="bottom">Relative Position des OSD (unterer Rand).</param>
/// <param name="alpha">Transparenz des OSD. Befindet sich die Anwendung nicht im
/// Vollbildmodus, wird dieser Parameter ignoriert und das OSD ist undurchsichtig.</param>
/// <param name="transparent">Optional durchsichtige Farbe.</param>
public void ShowOverlay( Bitmap bitmap, double left, double top, double right, double bottom, double? alpha, Color? transparent )
{
// Relative position
m_OSDSize = new RectangleF( (float) left, (float) top, (float) (right - left), (float) (bottom - top) );
// See if we are in full mode support
if (!UseLegacyOverlay)
{
// Set transparency
Opacity = alpha.GetValueOrDefault( 1 );
// Set transparency key
TransparencyKey = transparent.GetValueOrDefault( TTXPage.TransparentColor.Color );
BackColor = TransparencyKey;
}
// Load
using (picOSD.Image)
picOSD.Image = new Bitmap( bitmap );
// Call base
if (!Visible)
Show();
// Update
AdaptChanges( m_Reference, EventArgs.Empty );
}
示例9: ImageTinted
public ImageTinted(Texture2D tex, Rectangle? texCoords = null, Color? tint = null, Vector2? size = null)
: base(tex, texCoords, size)
{
Tint = tint.GetValueOrDefault(Color.White);
}