/// <summary> /// Returns true if the other WaveFileInfo object is equal to this by content. (not necessarily by reference) /// Instead of overriding the Equals -method, I made this to avoid confusion and erroneous comparisons. /// </summary> /// <param name="another"></param> /// <returns></returns> public bool ValueEquals(WaveFileInfo another) { if (another != null) { return(RelativePath == another.RelativePath); } return(false); }
public void SetWave(WaveFileInfo wave, bool initialize = true) { if (wave != null) { Wave = wave; if (initialize) { InitializeWave(); } } }
void RefreshWaveCombo() { WaveFileInfo previouslySelected = (comboBoxWave.SelectedItem as WaveFileInfo); SkipFlaggedEventHandlers = true; Enabled = false; comboBoxWave.DataSource = null; comboBoxWave.DataSource = WaveFilePool.GetAvailableWaves(); Enabled = true; object matchToPreviouslySelected = null; foreach (var item in comboBoxWave.Items) { if ((item as WaveFileInfo).ValueEquals(previouslySelected)) { matchToPreviouslySelected = item; } } object matchToCurrentWave = null; foreach (var item in comboBoxWave.Items) { if ((item as WaveFileInfo).ValueEquals(TheWave?.Wave)) { matchToCurrentWave = item; } } if (matchToPreviouslySelected != null) { comboBoxWave.SelectedItem = matchToPreviouslySelected; } else if (matchToCurrentWave != null) { comboBoxWave.SelectedItem = matchToCurrentWave; } else if (previouslySelected != null) { TheWave.SetWave(previouslySelected); } SkipFlaggedEventHandlers = false; CheckNoWaveState(); }