Beispiel #1
0
        public void Save(CellField field)
        {
            // save = new SaveFileDialog();
            dl        = new OpenFileDialog();
            dl.Filter = "text documents (.txt)|*txt";
            dl.ShowDialog();
            Path = dl.FileName;
            byte[] buff;
            string position;

            try
            {
                Clear();
                file = new FileStream(dl.FileName, FileMode.Append, FileAccess.Write);


                StreamWriter sw = new StreamWriter(file, Encoding.Unicode);
                foreach (Cell cell in field)
                {
                    if (cell.Live)
                    {
                        position = $"{cell.Position[0]},{cell.Position[1]}\n";
                        buff     = System.Text.Encoding.Unicode.GetBytes(position);
                        file.Write(buff, 0, buff.Length);
                    }
                }
                file.Close();
            }
            catch (Exception ex)
            { Console.WriteLine(ex.Message); }
        }
 public View()
 {
     fileManeger = new FileManeger();
     cellField   = new CellField(20);
 }