Exemple #1
0
        public void Load()
        {
            var fileDialogService = new FileDialogService();

            fileDialogService.OpenFileDialog("CSV (*.csv)|*.csv", "Save Dartboard", out var fileName);
            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            ClearDartboard();
            var content = File.ReadAllText(fileName);
            var lines   = content.Replace("\r\n", "\n").Split('\n');

            foreach (var line in lines)
            {
                var cells = line.Split(';');
                if (cells.Length != 2)
                {
                    continue;
                }
                var x = int.Parse(cells[0]);
                var y = int.Parse(cells[1]);
                Hit(x, y);
            }
        }
Exemple #2
0
        public void Save()
        {
            var fileDialogService = new FileDialogService();
            var filename          = fileDialogService.SaveFileDialog("CSV (*.csv)|*.csv", "Save Dartboard");

            if (string.IsNullOrEmpty(filename))
            {
                return;
            }

            var content = new StringBuilder();

            foreach (var field in Fields)
            {
                foreach (var hit in field.Hits)
                {
                    content.Append(hit.X + ";" + hit.Y + "\r\n");
                }
            }
            File.WriteAllText(filename, content.ToString());
        }