/// <summary>
        /// Gets the points.
        /// </summary>
        /// <param name="symmetry">The symmetry.</param>
        /// <param name="basePoints">The base points.</param>
        /// <returns>System.Boolean[][].</returns>
        private bool[,] ConvertBasePointsToBmpPoints(IconSymmetry symmetry, bool[] basePoints)
        {
            bool[,] result = new bool[iconSize, iconSize];

            //var points = GetBasePoints(guid, symmetry);

            switch (symmetry)
            {
            case IconSymmetry.Vertical:
                break;

            case IconSymmetry.Horizontal:
                break;

            case IconSymmetry.LeftDiagonal:
                break;

            case IconSymmetry.RightDiagonal:
                break;

            default:
                break;
            }

            return(result);
        }
        /// <summary>
        /// Gets the base points.
        /// This method just calculate the image bit hit by Icon Symmetry, whose count is not equals to the image size.
        /// <example>
        /// GUID: {E947B991-8115-43A1-9AE6-85E817D26D8E}
        /// Hex String = 9AE685E817D26D8E
        /// According to icon size is 5x5 to 8x8, so array size would be from 15 to 36 (
        /// Icon size would be: ((0x81 ^ 0x15) % 4) + 3 = 5
        /// </example>
        /// </summary>
        /// <param name="hexString">The hexadecimal string.</param>
        /// <param name="symmetry">The symmetry.</param>
        /// <returns>System.Boolean[].</returns>
        private bool[] GetBasePoints(string hexString, IconSymmetry symmetry)
        {
            int arraySize;

            if (symmetry == IconSymmetry.Horizontal || symmetry == IconSymmetry.Vertical)
            {
                arraySize = (((int)(iconSize / 2)) + (iconSize % 2)) * iconSize;
            }
            else
            {
                arraySize = ((iconSize) * (iconSize - 1) / 2) + iconSize;
            }

            bool[] result = new bool[arraySize];

            var value     = Convert.ToInt64(hexString, 16) & ((long)Math.Pow(2, arraySize) - 1);
            var bitString = Convert.ToString(value, 2);

            if (bitString.Length < arraySize)
            {
                bitString = (new string('0', arraySize - bitString.Length)) + bitString;
            }

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = bitString[i] == '1';
            }

            return(result);
        }
        /// <summary>
        /// Generates the icon.
        /// </summary>
        /// <param name="guid">The unique identifier.</param>
        /// <param name="symmetry">The symmetry.</param>
        /// <param name="unitSquareSize">Size of the unit square.</param>
        /// <returns>Bitmap.</returns>
        private Bitmap GenerateIcon(Guid guid, IconSymmetry symmetry, int unitSquareSize)
        {
            bool[,] imagePoints = GetPoints(guid, symmetry);
            Color color = GetColorByGuid(guid);

            return(DrawIcon(color, imagePoints, unitSquareSize));
        }
        /// <summary>
        /// Gets the factor.
        /// </summary>
        /// <param name="guid">The unique identifier.</param>
        /// <param name="color">The color.</param>
        /// <param name="symmetry">The symmetry.</param>
        /// <param name="points">The points.</param>
        /// <returns>System.Int32 for icon size (5- 8).</returns>
        private int GetFactor(Guid guid, out Color color, out IconSymmetry symmetry, out bool[] points)
        {
            var segments = guid.ToString().Split('-');

            string segment1 = segments[0];
            string segment2 = segments[1];
            string segment3 = segments[2];

            color = HexToRGB(segment1);
            var _iconSize = 3 + ((Convert.ToInt32(segment2.Substring(0, 2)) ^ Convert.ToInt32(segment2.Substring(2, 2))) % 4);

            symmetry = (IconSymmetry)((Convert.ToInt32(segment3.Substring(0, 2)) ^ Convert.ToInt32(segment3.Substring(2, 2))) % 4);
            points   = GetBasePoints(segments[3] + segments[4], symmetry);

            return(_iconSize);
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the points.
        /// </summary>
        /// <param name="basePoints">The base points.</param>
        /// <param name="iconSize">Size of the icon.</param>
        /// <param name="symmetry">The symmetry.</param>
        /// <returns>System.Boolean[][].</returns>
        private bool[,] GetPoints(bool[] basePoints, int iconSize, IconSymmetry symmetry)
        {
            bool[,] result = new bool[iconSize, iconSize];

            int halfLength = ((int)(iconSize / 2)) + (iconSize % 2);
            int sum = 0;

            switch (symmetry)
            {
                case IconSymmetry.Vertical:
                    for (int i = 0; i < iconSize; i++)
                    {
                        for (int j = 0; j < halfLength; j++)
                        {
                            result[i, iconSize - 1 - j] = result[i, j] = basePoints[i * halfLength + j];
                        }
                    }
                    break;
                case IconSymmetry.Horizontal:
                    for (int j = 0; j < halfLength; j++)
                    {
                        for (int i = 0; i < iconSize; i++)
                        {
                            result[iconSize - 1 - j, i] = result[j, i] = basePoints[i * halfLength + j];
                        }
                    }
                    break;
                case IconSymmetry.LeftDiagonal:
                    for (int i = 0; i < iconSize; i++)
                    {
                        for (int j = i; j < iconSize; j++)
                        {
                            result[j, i] = result[i, j] = basePoints[sum];
                            sum++;
                        }
                    }
                    break;
                case IconSymmetry.RightDiagonal:
                    for (int i = 0; i < iconSize; i++)
                    {
                        for (int j = iconSize - i - 1; j > 0; j--)
                        {
                            result[i, j] = result[iconSize - j - 1, iconSize - i - 1] = basePoints[sum];
                            sum++;
                        }
                    }
                    break;
                default:
                    break;
            }

            return result;
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the factor.
        /// </summary>
        /// <param name="guid">The unique identifier.</param>
        /// <param name="color">The color.</param>
        /// <param name="symmetry">The symmetry.</param>
        /// <param name="points">The points.</param>
        /// <returns>System.Int32 for icon size (7- 11).</returns>
        private int GetFactor(Guid guid, out Color color, out IconSymmetry symmetry, out bool[] points)
        {
            var segments = guid.ToString().Split('-');

            string segment1 = segments[0];
            string segment2 = segments[1];
            string segment3 = segments[2];

            color = HexToRGB(segment1);
            var _iconSize = 7 + ((Convert.ToInt32(segment2.Substring(0, 2), 16) ^ Convert.ToInt32(segment2.Substring(2, 2), 16)) % 4);
            symmetry = (IconSymmetry)((Convert.ToInt32(segment3.Substring(0, 2), 16) ^ Convert.ToInt32(segment3.Substring(2, 2), 16)) % 4);
            points = GetBasePoints(segments[3] + segments[4], _iconSize, symmetry);

            return _iconSize;
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the base points.
        /// This method just calculate the image bit hit by Icon Symmetry, whose count is not equals to the image size.
        /// <example>
        /// GUID: {E947B991-8115-43A1-9AE6-85E817D26D8E}
        /// Hex String = 9AE685E817D26D8E
        /// According to icon size is 5x5 to 8x8, so array size would be from 15 to 36 (
        /// Icon size would be: ((0x81 ^ 0x15) % 4) + 3 = 5
        /// </example>
        /// </summary>
        /// <param name="hexString">The hexadecimal string.</param>
        /// <param name="iconSize">Size of the icon.</param>
        /// <param name="symmetry">The symmetry.</param>
        /// <returns>System.Boolean[].</returns>
        private bool[] GetBasePoints(string hexString, int iconSize, IconSymmetry symmetry)
        {
            int arraySize;

            if (symmetry == IconSymmetry.Horizontal || symmetry == IconSymmetry.Vertical)
            {
                arraySize = (((int)(iconSize / 2)) + (iconSize % 2)) * iconSize;
            }
            else
            {
                arraySize = ((iconSize) * (iconSize - 1) / 2) + iconSize;
            }

            bool[] result = new bool[arraySize];

            var value = Convert.ToInt64(hexString, 16) & ((long)Math.Pow(2, arraySize) - 1);
            var bitString = Convert.ToString(value, 2);

            if (bitString.Length < arraySize)
            {
                bitString = (new string('0', arraySize - bitString.Length)) + bitString;
            }

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = bitString[i] == '1';
            }

            return result;
        }