forked from naudio/NAudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingsForm.cs
74 lines (65 loc) · 2.24 KB
/
SettingsForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NAudio.Wave;
using MarkHeath.AudioUtils.Properties;
namespace MarkHeath.AudioUtils
{
public partial class SettingsForm : Form
{
public SettingsForm()
{
InitializeComponent();
}
private void SettingsForm_Load(object sender, EventArgs e)
{
comboBoxOutputDevice.ValueMember = "DeviceNumber";
comboBoxOutputDevice.DisplayMember = "DeviceName";
comboBoxOutputDevice.Items.Add(new WaveOutComboItem("(Default)",-1));
for (int n = 0; n < WaveOut.DeviceCount; n++)
{
WaveOutCapabilities waveOutCaps = WaveOut.GetCapabilities(n);
comboBoxOutputDevice.Items.Add(new WaveOutComboItem(waveOutCaps.ProductName, n));
}
Settings settings = Settings.Default;
textBoxSkipBackSeconds.Text = settings.SkipBackSeconds.ToString();
checkBoxUseAllSlots.Checked = settings.UseAllSlots;
comboBoxOutputDevice.SelectedValue = settings.WaveOutDevice;
}
private void buttonOK_Click(object sender, EventArgs e)
{
Settings settings = Settings.Default;
int skipBackSeconds = 5;
bool parsed = Int32.TryParse(textBoxSkipBackSeconds.Text, out skipBackSeconds);
if (!parsed || skipBackSeconds <= 0)
{
MessageBox.Show("Please enter a valid number of skip back seconds");
textBoxSkipBackSeconds.Focus();
return;
}
this.Close();
}
}
class WaveOutComboItem
{
string deviceName;
int deviceNumber;
public WaveOutComboItem(string deviceName, int deviceNumber)
{
this.deviceName = deviceName;
this.deviceNumber = deviceNumber;
}
public int DeviceNumber
{
get { return deviceNumber; }
}
public string DeviceName
{
get { return deviceName; }
}
}
}