private void ButtonOK_Click(object sender, EventArgs e) { Result = new AlermSettings.AlermData { IsEnabled = checkBox1.Checked, Time = dateTimePicker1.Value, Timing = CheckedListToTiming(), PlaylistNames = Playlist.CheckedItems.OfType <string>().ToList() }; DialogResult = DialogResult.OK; }
public FormAlermSetting(IEnumerable <string> playlists, AlermSettings.AlermData alerm) : this() { alerm = alerm ?? new AlermSettings.AlermData(); checkBox1.Checked = alerm.IsEnabled; dateTimePicker1.Value = alerm.Time; for (int i = 0; i < 7; i++) { TimingList.SetItemChecked(i, ((int)alerm.Timing & (1 << i)) != 0); } Playlist.Items.AddRange(playlists.ToArray()); foreach (var name in alerm.PlaylistNames) { var index = Playlist.Items.IndexOf(name); if (index != -1) { Playlist.SetItemChecked(index, true); } } }
private void ButtonCancel_Click(object sender, EventArgs e) { Result = null; DialogResult = DialogResult.Cancel; }