Example #1
0
        public static ColorItemPersist[] GetAll()
        {
            string dir = AppDomain.CurrentDomain.BaseDirectory + "LinearColorTable";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string[] fnames = System.IO.Directory.GetFiles(dir);
            if (fnames == null || fnames.Length == 0)
            {
                return(null);
            }
            List <ColorItemPersist> ps = new List <ColorItemPersist>();

            foreach (string f in fnames)
            {
                ColorItemPersist p = GetByName(Path.GetFileNameWithoutExtension(f));
                if (p == null)
                {
                    continue;
                }
                ps.Add(p);
            }
            return(ps.ToArray());
        }
Example #2
0
        public static void SaveToFile(ColorItem[] colorItems, string name)
        {
            ColorItemPersist colorPersist = new ColorItemPersist();

            colorPersist.ColorItems = colorItems;
            colorPersist.Name       = name;
            string dir = AppDomain.CurrentDomain.BaseDirectory + "LinearColorTable";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string fname = dir + "\\" + name + ".lgt";

            ObjectToDisk.SerializeClassToBinary(colorPersist, fname);
        }
Example #3
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem == null)
            {
                return;
            }
            string           name = listBox1.SelectedItem.ToString();
            ColorItemPersist p    = LinearGradientTableFactory.GetByName(name);

            if (p == null)
            {
                return;
            }
            textBox1.Text = p.Name;
            ucLinearColorRampEditor1.Apply(p.ColorItems);
        }