/// <summary>
        /// 現在のオブジェクトからPlugin.DataRowオブジェクトを生成します。
        /// </summary>
        /// <param title="host">生成先のPlugin.IPluginHost</param>
        /// <returns>新しいPlugin.DataRow</returns>
        public Plugin.DataRow CreateDataRow(Plugin.IPluginHost host)
        {
            IList <string> labelList = GetLabelTexts();
            // 自動色付け
            Dictionary <string, Color> colors = new Dictionary <string, Color>();

            for (int i = 0; i < labelList.Count; i++)
            {
                colors[labelList[i]] = ColorEx.ColorFromHSV((float)(Math.PI * 2 * i / labelList.Count), 0.1f, (i % 2) == 0 ? 1f : 0.9f);
            }
            return(CreateDataRow(host, colors));
        }
예제 #2
0
        /// <summary>
        /// 境界名に対するデフォルトの色を生成します
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Color GetDefaultColorFor(string name)
        {
            System.Security.Cryptography.SHA256Managed __sha256 = new System.Security.Cryptography.SHA256Managed();
            byte[] mainName = __sha256.ComputeHash(Encoding.UTF8.GetBytes(name.Substring(0, 3 > name.Length ? name.Length : 3)));
            byte[] subName  = __sha256.ComputeHash(Encoding.UTF8.GetBytes(name));
            int    hueInt   = (mainName[7] / 16) * 4096 + subName[9] * 16 + subName[17] / 16;
            float  hue      = (float)(Math.PI * 2) * hueInt / 65536;
            int    satInt   = mainName[13] + subName[3];
            float  sat      = 0.1f + 0.8f * satInt / 510;
            long   valueInt = (255 - (int)subName[0] * subName[2] * subName[7] / 255 / 255)
                              + (255 - (int)subName[1] * subName[4] * subName[18] / 255 / 255)
                              + (255 - (int)subName[17] * subName[12] * subName[30] / 255 / 255)
                              + (255 - (int)subName[21] * subName[22] * subName[8] / 255 / 255);
            float value = (float)valueInt / 1020;

            return(ColorEx.ColorFromHSV(hue, sat, value));
        }