Ejemplo n.º 1
0
        /// <summary>
        /// fetches the persisted microwave presests
        /// </summary>
        private void LoadSavedPresets()
        {
            XmlTextReader file = null;

            try
            {
                if (!File.Exists(FrequencyPresetsFilename))
                {
                    throw new FileNotFoundException("Presets file \"" + FrequencyPresetsFilename + "\" does not exist!");
                }

                XmlSerializer xmlSerializer = new XmlSerializer(typeof(UserPresetStore));
                file             = new XmlTextReader(FrequencyPresetsFilename);
                frequencyPresets = (UserPresetStore)xmlSerializer.Deserialize(file);
            }
            catch (Exception exc)
            {
                AppLogger.Dump(exc);
                frequencyPresets = new UserPresetStore();
            }
            finally
            {
                if (file != null)
                {
                    file.Close();
                }
            }
        }
Ejemplo n.º 2
0
        public void LoadSavedPositions()
        {
            XmlTextReader reader = null;

            try
            {
                if (!File.Exists(SavedPositionsFileName))
                {
                    throw new FileNotFoundException("The file \"" + SavedPositionsFileName + "\" does not exist.");
                }
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(UserPresetStore));
                reader      = new XmlTextReader(SavedPositionsFileName);
                PresetItems = (UserPresetStore)xmlSerializer.Deserialize(reader);
            }
            catch (Exception exc)
            {
                AppLogger.Dump(exc);
                PresetItems = new UserPresetStore();
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes any items that are not in the given UserPresetStore, and updates items that do exist, retaining any images
        /// </summary>
        /// <param name="userPresetStore">the presets to update from -- note: this object is altered!</param>
        public void UpdateItems(UserPresetStore userPresetStore)
        {
            Debug.WriteLine("UserPresetsControl.UpdateItems");

            if (userPresetStore == null)
            {
                return;
            }

            //Step 1: Remove items that no longer exist
            List <int> indexesToDelete = new List <int>();

            for (int i = 0; i < this.Items.Count; i++)
            {
                if (!userPresetStore.Contains(this.Items[i].Preset.ID))
                {
                    indexesToDelete.Add(i);
                }
            }
            //iterate these backwards so the list shrinks predictably, instead of accidently deleteing the wrong items
            for (int i = indexesToDelete.Count - 1; i >= 0; i--)
            {
                this.Delete(indexesToDelete[i]);
            }

            //Step 2: Update items that we still have
            foreach (UserPresetItemView i in this.Items)
            {
                if (userPresetStore.Contains(i.Preset.ID))
                {
                    i.Preset = userPresetStore[i.Preset.ID];
                    //remove items we already have, so we don't get duplicates
                    userPresetStore.Remove(i.Preset.ID);
                }
            }

            //Step 3: Add new items
            foreach (UserPresetItem i in userPresetStore)
            {
                UserPresetItemView view = new UserPresetItemView();
                view.Preset = i;
                this.Add(view);
            }
        }
Ejemplo n.º 4
0
 public void SavedPositionsChanged(UserPresetStore savedCameraPositions)
 {
     _ccc.PresetItems = savedCameraPositions;
 }
Ejemplo n.º 5
0
 public void SavedPresetsChanged(UserPresetStore presets)
 {
     parent.FrequencyPresets = presets;
 }