private async void nuevoToolStripMenuItem_Click(object sender, EventArgs e) { CheckForModifications(); var session = new SoundSessionFile(); await _loadSession(session); }
/// <summary> /// Loads and returns a session file /// </summary> /// <param name="FileName"></param> /// <returns></returns> public static SoundSessionFile Load(String FileName) { using (StreamReader File = new StreamReader(FileName)) { String TextContent = File.ReadToEnd(); SoundSessionFile Session = JsonConvert.DeserializeObject <SoundSessionFile>(TextContent); Session.FileName = FileName; return(Session); } }
private async void LoadSession(String FileName) { try { var session = SoundSessionFile.Load(FileName); await _loadSession(session); } catch (Exception e) { MessageBox.Show("Ha ocurrido un problema", e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async Task _loadSession(SoundSessionFile session) { this.Session = session; this.Text = Path.GetFileName(session.FileName); _setModified(false); ClearAll(); // update the UI foreach (var pair in this.Session.FileList) { SoundCue soundCue; if (cues.TryGetValue(pair.Key, out soundCue)) { if (pair.Value != null) { await soundCue.LoadSound(pair.Value.FilePath); soundCue.SetVolume(pair.Value.volume); } } } }
public Main() { InitializeComponent(); this.Session = new SoundSessionFile(); this.cues = new Dictionary <char, SoundCue>(); // initialize cue controls String flow = "QAZWSXEDCRFVTGBYHN"; foreach (char n in flow.ToCharArray()) { var cueControl = new SoundCue(n.ToString()); cueControl.Modified += Cue_Modified; cueControl.VolumeChanged += Cue_Volume; cues.Add(n, cueControl); // add to data model lstCues.Controls.Add(cueControl); // add to UI } // initialize sound chart, comment graph = panelTransport.CreateGraphics(); graph.Clear(Color.Black); }