Exemplo n.º 1
0
        public static void SaveStyle(string filename, MapRenderer.Style style)
        {
            FileStream   f      = new FileStream(filename, FileMode.Create);
            StreamWriter writer = new StreamWriter(f);

            writer.WriteLine("GridIsOn={0}", style.GridIsOn.ToString());
            writer.WriteLine("GridColor={0}", style.Grid.Color.Name);
            writer.WriteLine("AliveCellColor={0}", style.AliveCell.Color.Name);
            writer.WriteLine("DeadCellColor={0}", style.DeadCell.Color.Name);

            writer.Close();
        }
Exemplo n.º 2
0
        public static void LoadStyle(string filename, ref MapRenderer.Style style)
        {
            FileStream   f      = new FileStream(filename, FileMode.Open);
            StreamReader reader = new StreamReader(f);
            string       str;

            while (!reader.EndOfStream)
            {
                str = reader.ReadLine();
                SetStyleAtribute(ref style, str);
            }
            reader.Close();
        }
Exemplo n.º 3
0
        private static void SetStyleAtribute(ref MapRenderer.Style style, string str)
        {
            string[] args = str.Split('=');
            if (args.Length < 2)
            {
                return;
            }
            string value = args[1];

            switch (args[0])
            {
            case "GridIsOn": {
                if (!bool.TryParse(value, out bool result))
                {
                    style.GridIsOn = false;
                    break;
                }
                style.GridIsOn = result;
                break;
            }

            case "GridColor": {
                style.GridColor = Color.FromName(value);
                break;
            }

            case "AliveCellColor": {
                style.AliveCellColor = Color.FromName(value);
                break;
            }

            case "DeadCellColor": {
                style.DeadCellColor = Color.FromName(value);
                break;
            }
            }
        }