Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        public static void RestoreSettings(EnvironmentSettings settings)
        {
            try
            {
                InstrumentManager.InstExclusiveLockObject.EnterWriteLock();

                if (settings.Instruments != null)
                {
                    foreach (int v in Enum.GetValues(typeof(InstrumentType)))
                    {
                        if (v < settings.Instruments.Count && settings.Instruments[v] != null)
                        {
                            try
                            {
                                Program.SoundUpdating();
                                //clear current insts
                                for (int i = instruments[v].Count - 1; i >= 0; i--)
                                {
                                    instruments[v][i].Dispose();
                                    instruments[v].RemoveAt(i);
                                }
                                //prepare new insts
                                foreach (InstrumentBase inst in settings.Instruments[v])
                                {
                                    inst.PrepareSound();
                                }
                                //set new insts
                                InstrumentManager.instruments[v] = settings.Instruments[v];
                            }
                            catch (Exception ex)
                            {
                                if (ex.GetType() == typeof(Exception))
                                {
                                    throw;
                                }
                                else if (ex.GetType() == typeof(SystemException))
                                {
                                    throw;
                                }


                                System.Windows.Forms.MessageBox.Show(ex.ToString());
                            }
                            finally
                            {
                                Program.SoundUpdated();
                            }
                        }
                    }
                }

                InstrumentChanged?.Invoke(typeof(InstrumentManager), EventArgs.Empty);
            }
            finally
            {
                InstrumentManager.InstExclusiveLockObject.ExitWriteLock();
            }
        }
Beispiel #2
0
 protected virtual void OnInstrumentChanged(EventArgs e)
 {
     InstrumentChanged?.Invoke(this, e);
 }