コード例 #1
0
ファイル: Utility.cs プロジェクト: janwillemb/SharpMap
        /// <summary>
        /// Method to <see cref="Color"/> to get a random known color
        /// </summary>
        /// <returns>A random color form the <see cref="KnownColor"/> enumeration</returns>
        public static Color RandomKnownColor()
        {
#if !NETSTANDARD2_0
            return(Color.FromKnownColor(_knownColors[RND.Next(0, _knownColors.Count - 1)]));
#else
            return(SmColor.FromKnownColor(_knownColors[RND.Next(0, _knownColors.Count - 1)]));
#endif
        }
コード例 #2
0
        /// <summary>
        /// Factory method to create a random color from the <see cref="KnownColor"/>s enumeration
        /// </summary>
        /// <param name="alpha">An optional alpha value.</param>
        /// <returns></returns>
        public static Color CreateRandomKnownColor(int alpha = 255)
        {
            var kc = (KnownColor)_rnd.Next(28, 168);

            return(alpha == 255
                ? SmColor.FromKnownColor(kc)
                : Color.FromArgb(alpha, SmColor.FromKnownColor(kc)));
        }