示例#1
0
        // *******************************************************
        public bool Load(string p = "")
        {
            bool     ret  = false;
            JsonPref pref = new JsonPref();

            try
            {
                if (p == "")
                {
                    p = Path.GetFileNameWithoutExtension(Application.ExecutablePath);
                    p = Path.Combine(Application.UserAppDataPath, p + "_color.json");
                }
                ret  = pref.Load(p);
                path = p;
                if (ret == false)
                {
                    return(ret);
                }
                bool ok   = false;
                int  r    = pref.GetInt("Rows", out ok);
                int  c    = 0;
                var  cols = new object[0];
                if (ok)
                {
                    c = pref.GetInt("Cols", out ok);
                }
                if (ok)
                {
                    cols = pref.GetObjectArray("Colors", out ok);
                }
                if (ok)
                {
                    InitColors(r, c);
                    for (int i = 0; i < Count; i++)
                    {
                        Items[i].AE_Color.FromJson(cols[i]);
                        Items[i].Invalidate();
                    }
                    ret = true;
                }
            }
            catch
            {
                ret = false;
            }
            return(ret);
        }