Beispiel #1
0
        public PresetCollection()
        {
            Preset.AutoUpdateTimePointBaseTimes = true;

            _presetSerializableCollection = new PresetSerializableObservableCollection();
            Presets = new ReadOnlyObservableCollection <Preset>(_presetSerializableCollection);
        }
Beispiel #2
0
        /// <summary>
        /// Deserialies presets
        /// </summary>
        private void DeserializePresets(string fileName)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(PresetSerializableObservableCollection));

            using (FileStream fStream = File.OpenRead(fileName))
            {
                PresetSerializableObservableCollection presets;

                try {
                    presets = ( PresetSerializableObservableCollection )xmlSerializer.Deserialize(fStream);
                }
                catch (InvalidOperationException) {
                    presets = new PresetSerializableObservableCollection();
                }

                if (presets.Count > 0)
                {
                    foreach (var preset in presets)
                    {
                        _presetSerializableCollection.Add(preset);
                    }
                }
            }
        }