当前位置: 首页>>代码示例>>C#>>正文


C# Color.GetValueOrDefault方法代码示例

本文整理汇总了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);
 }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:26,代码来源:LarvContent.cs

示例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;
 }
开发者ID:pboettcher,项目名称:SqlToUtf8,代码行数:9,代码来源:Form1.cs

示例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;
 }
开发者ID:InvertGames,项目名称:uFrame.Editor,代码行数:9,代码来源:NodeStyleSchema.cs

示例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);
        }
开发者ID:DeadlyBrad42,项目名称:ludumdare-25,代码行数:15,代码来源:DrawHelper.cs

示例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;
 }
开发者ID:klonage,项目名称:nlt-gcs,代码行数:16,代码来源:Tiles.cs

示例6: ToTransparentFromGrayScale

 public static Color ToTransparentFromGrayScale(this Color color, Color? newRGBColor)
 {
     return Color.FromArgb(
         color.ToGrayScale().R,
         newRGBColor.GetValueOrDefault(color));
 }
开发者ID:CHiiLD,项目名称:net-toolkit,代码行数:6,代码来源:ColorExtensions.cs

示例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);
        }
开发者ID:pakoito,项目名称:Fracture,代码行数:27,代码来源:Convenience.cs

示例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 );
        }
开发者ID:davinx,项目名称:DVB.NET---VCR.NET,代码行数:38,代码来源:OverlayWindow.cs

示例9: ImageTinted

 public ImageTinted(Texture2D tex, Rectangle? texCoords = null, Color? tint = null, Vector2? size = null)
     : base(tex, texCoords, size)
 {
     Tint = tint.GetValueOrDefault(Color.White);
 }
开发者ID:zdawson,项目名称:Marooned,代码行数:5,代码来源:Image.cs


注:本文中的Color.GetValueOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。