Exemplo n.º 1
0
        public IEnumerable<IExerciseSheet> GetAllSheets()
        {
            Load();

            var sheets = new List<IExerciseSheet>();

            var sheetsXml = from s in _doc.Descendants("sheets").Single()
                                .Descendants("sheet")
                            select s;

            foreach (var sheetXml in sheetsXml)
            {
                var sheet = new ExerciseSheet(sheetXml.Attribute("name").Value);

                var exercisesXml = from ex in sheetXml.Descendants("exercise")
                                   select ex;

                foreach (var exerciseXml in exercisesXml)
                {
                    sheet.AddExercise(exerciseXml.Attribute("type").Value);
                }

                sheets.Add(sheet);
            }

            return sheets;
        }
        public IExerciseSheet ShowWindow(IWindow parent)
        {
            _exercises = new List<string>();

            _sheet = null;

            _window.Loaded += Loaded;
            _window.AddExerciseButtonClicked += AddExerciseButtonClicked;
            _window.ExerciseSelected += ExerciseSelected;
            _window.ExerciseUnselected += ExerciseUnselected;
            _window.SaveButtonClicked += SaveButtonClicked;
            _window.CancelButtonClicked += CancelButtonClicked;

            _window.ShowDialog(parent);

            _window.Loaded -= Loaded;
            _window.AddExerciseButtonClicked -= AddExerciseButtonClicked;
            _window.ExerciseSelected -= ExerciseSelected;
            _window.ExerciseUnselected -= ExerciseUnselected;
            _window.SaveButtonClicked -= SaveButtonClicked;
            _window.CancelButtonClicked -= CancelButtonClicked;

            _window.Clear();

            return _sheet;
        }
Exemplo n.º 3
0
        public IExerciseSheet GetExerciseSheet(string name)
        {
            Load();

            var sheet = new ExerciseSheet(name);

            var sheetXml = (from s in _doc.Descendants("sheets").Single()
                               .Descendants("sheet")
                           where s.Attribute("name").Value == name
                           select s).Single();

            foreach (var exerciseXml in sheetXml.Descendants("exercise"))
            {
                var exerciseName = exerciseXml.Attribute("type").Value;

                sheet.AddExercise(exerciseName);
            }

            return sheet;
        }