Beispiel #1
0
        public static RRSettings DeserializeXml(XElement settingsXml)
        {
            var settings = new RRSettings();

            if (settingsXml.HasElements)
            {
                int xmlPort;
                var preEles = settingsXml.Element("presets").Elements("rrpreset");

                if (int.TryParse(settingsXml.Element("port").Value, out xmlPort))
                {
                    settings.Port = xmlPort;
                }

                settings.Name = settingsXml.Element("name").Value;
                settings.Deck1ArtistPointer = settingsXml.Element("d1aptr").Value;
                settings.Deck1TitlePointer  = settingsXml.Element("d1tptr").Value;
                settings.Deck2ArtistPointer = settingsXml.Element("d2aptr").Value;
                settings.Deck2TitlePointer  = settingsXml.Element("d2tptr").Value;
                settings.Deck3ArtistPointer = settingsXml.Element("d3aptr").Value;
                settings.Deck3TitlePointer  = settingsXml.Element("d3tptr").Value;
                settings.Deck4ArtistPointer = settingsXml.Element("d4aptr").Value;
                settings.Deck4TitlePointer  = settingsXml.Element("d4tptr").Value;
                settings.MasterDeckPointer  = settingsXml.Element("mdptr").Value;

                foreach (var pre in preEles)
                {
                    var preset = RRPreset.DeserializeXml(pre);
                    settings.Presets[preset.Name] = preset;
                }
            }

            return(settings);
        }
Beispiel #2
0
        public RRPreset(RRSettings settings)
        {
            var props = typeof(RRSettings).GetProperties();

            foreach (var p in props)
            {
                p.SetValue(this, p.GetValue(settings));
            }
        }
Beispiel #3
0
        public static RRSettings LoadFile()
        {
            var settings = new RRSettings();

            try
            {
                var settingsText = File.ReadAllText(GetSettingsFilename());
                var xe           = XElement.Parse(settingsText);
                settings = DeserializeXml(xe);
            }
            catch
            { } // eh... settings file probably not found, just give an empty instance

            return(settings);
        }
Beispiel #4
0
        public void LoadSettings()
        {
            if (!File.Exists(RRSettings.GetSettingsFilename()))
            {
                using (Stream presetStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("RekordboxReader.Resources.presets.xml"),
                       settFileStream = new FileStream(RRSettings.GetSettingsFilename(), FileMode.CreateNew))
                {
                    presetStream.CopyTo(settFileStream);
                }
            }

            settings = RRSettings.LoadFile();
            if (pointerPatterns == null)
            {
                pointerPatterns = new Dictionary <string, string>();
            }

            ReloadSettings();
        }
Beispiel #5
0
 public SettingsForm(RRSettings settings)
 {
     _settings = settings;
     InitializeComponent();
 }