Esempio n. 1
0
        private static string GetCurrentStateJson()
        {
            List <SaveableSoundRef> saveableSounds = new List <SaveableSoundRef>();

            if (MainWindow.Files.Count < 1)
            {
                return(null);
            }
            // Get current state
            foreach (var t in MainWindow.Files)
            {
                SaveableSoundRef s = new SaveableSoundRef();
                s.FilePath     = t.audioFile.FileName;
                s.IsLEDEnabled = t.IsLEDEnabled;
                if (t.LedColor == null)
                {
                    s.colorR = 140;
                    s.colorG = 140;
                    s.colorB = 140;
                }
                else
                {
                    s.colorR = ((SolidColorBrush)t.LedColor).Color.R;
                    s.colorG = ((SolidColorBrush)t.LedColor).Color.G;
                    s.colorB = ((SolidColorBrush)t.LedColor).Color.B;
                }
                saveableSounds.Add(s);
            }
            LibraryFile f = new LibraryFile();

            f.sounds       = saveableSounds;
            f.outputDevice = MainWindow.outputDevice.DeviceNumber;
            f.version      = Configs.Version;
            return(Newtonsoft.Json.JsonConvert.SerializeObject(f));
        }
Esempio n. 2
0
 private static void SetCurrentStateJson(string json)
 {
     try
     {
         LibraryFile import = Newtonsoft.Json.JsonConvert.DeserializeObject <LibraryFile>(json);
         MainWindow.outputDevice.DeviceNumber = import.outputDevice;
         MainWindow.AudioDevice = import.outputDevice;
         foreach (var s in import.sounds)
         {
             if (File.Exists(s.FilePath))
             {
                 var cd = MainWindow.AddSoundFile(s.FilePath);
                 if (s.IsLEDEnabled)
                 {
                     cd.LedColor = new SolidColorBrush(Color.FromRgb(s.colorR, s.colorG, s.colorB));
                     cd.EnableLED();
                 }
             }
         }
     } catch (Exception) { }
 }