public static IPlayerControl GetSoundControl(ISoundState soundState) { IPlayerControl playerControl; if(soundState is AmbientState) { playerControl = new AmbientPlayerControl(); } else if(soundState is IntervalSoundState) { playerControl = new IntervalSoundPlayerControl(); } else { throw new Exception(string.Format("Unable to bind state [{0}] to control", soundState.SoundTypeIdentifier)); } playerControl.PopulateFromState(soundState); return playerControl; }
void ambientPlayerToolStripMenuItem_Click(object sender, System.EventArgs e) { var columnRow = GetColumnRowFromControl(contextSourceControl); tablePanel.Controls.Remove(contextSourceControl); var ambientPlayer = new AmbientPlayerControl(); ambientPlayer.ColumnPosition = columnRow.X; ambientPlayer.RowPosition = columnRow.Y; ambientPlayer.ContextMenuStrip = playerContextMenuStrip; tablePanel.Controls.Add(ambientPlayer, columnRow.X, columnRow.Y); }