Rev 19 | Blame | Compare with Previous | Last modification | View Log | RSS feed
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NITNavComm {
public partial class NITAudioSelForm : Form {
private NITAudioSelDevice device = null;
public NITAudioSelForm() {
InitializeComponent();
this.controlStatus(false);
this.lstAudioDevices.Items.Clear();
}
private void controlStatus(bool status) {
cmdUpdate.Enabled = status;
inputTimer.Enabled = status;
}
public void UpdateDevice() {
this.UpdateInput();
this.UpdateDisplay();
}
public void UpdateDisplay() {
}
public void UpdateInput() {
device.updateInput();
button0.Checked = device.isButtonSet(0);
button1.Checked = device.isButtonSet(1);
button2.Checked = device.isButtonSet(2);
button3.Checked = device.isButtonSet(3);
button4.Checked = device.isButtonSet(4);
button5.Checked = device.isButtonSet(5);
button6.Checked = device.isButtonSet(6);
button7.Checked = device.isButtonSet(7);
this.led0.On = device.isLedSet(0);
this.led1.On = device.isLedSet(1);
this.led2.On = device.isLedSet(2);
this.led3.On = device.isLedSet(3);
this.led4.On = device.isLedSet(4);
this.led5.On = device.isLedSet(5);
this.led6.On = device.isLedSet(6);
this.led7.On = device.isLedSet(7);
this.ledPwr.On = device.isLedPwrSet();
float setVolume = NITPanels.map_f(device.analogValue, NITAudioSelDevice.DEV_ANALOG_MIN, 255, 0.00F, 1.00F);
float devVolume = device.volcontrol.getDeviceVolume();
if (setVolume != devVolume)
device.volcontrol.setDeviceVolume(setVolume);
uint volPercent = NITPanels.map_ui(this.device.analogValue, NITAudioSelDevice.DEV_ANALOG_MIN, 255, 0, 100);
txtVol.Text = Convert.ToString(volPercent);
}
public void setDevice(NITAudioSelDevice audiosel) {
this.device = audiosel;
foreach (string audio in device.volcontrol.devices) {
lstAudioDevices.Items.Add(audio);
}
lstAudioDevices.SelectedIndex = (int)device.volcontrol.selectedDeviceIndex;
if (!this.device.isOpen())
this.device.Open();
if (this.device.isOpen())
this.controlStatus(true);
}
private void cmdUpdate_Click(object sender, EventArgs e) {
/*
uint selectedAudioDevice = (uint)this.lstAudioDevices.SelectedIndex;
txtAnalog.Text = Convert.ToString(device.analogValue);
float volume = map_f(device.analogValue, 5, 255, 0.00F, 1.00F);
txtScalar.Text = Convert.ToString(volume);
device.volcontrol.setDeviceVolume(selectedAudioDevice, volume);
txtVol.Text = Convert.ToString(device.volcontrol.getDeviceVolume(selectedAudioDevice));
*/
this.device.UpdateDisplay();
}
private void inputTimer_Tick(object sender, EventArgs e) {
this.UpdateInput();
}
private void cmdClose_Click(object sender, EventArgs e) {
if (this.device != null && device.isOpen()) {
device.ClearDisplay();
}
this.Close();
}
private void led0_Click(object sender, EventArgs e) {
bool status = this.device.isLedSet(0);
this.device.setLed(0, !status);
this.device.UpdateDisplay();
}
private void led1_Click(object sender, EventArgs e) {
bool status = this.device.isLedSet(1);
this.device.setLed(1, !status);
this.device.UpdateDisplay();
}
private void led2_Click(object sender, EventArgs e) {
bool status = this.device.isLedSet(2);
this.device.setLed(2, !status);
this.device.UpdateDisplay();
}
private void led3_Click(object sender, EventArgs e) {
bool status = this.device.isLedSet(3);
this.device.setLed(3, !status);
this.device.UpdateDisplay();
}
private void led4_Click(object sender, EventArgs e) {
bool status = this.device.isLedSet(4);
this.device.setLed(4, !status);
this.device.UpdateDisplay();
}
private void led5_Click(object sender, EventArgs e) {
bool status = this.device.isLedSet(5);
this.device.setLed(5, !status);
this.device.UpdateDisplay();
}
private void led6_Click(object sender, EventArgs e) {
bool status = this.device.isLedSet(6);
this.device.setLed(6, !status);
this.device.UpdateDisplay();
}
private void led7_Click(object sender, EventArgs e) {
bool status = this.device.isLedSet(7);
this.device.setLed(7, !status);
this.device.UpdateDisplay();
}
private void ledPwr_Click(object sender, EventArgs e) {
bool status = this.device.isLedPwrSet();
this.device.setLedPwr(!status);
this.device.UpdateDisplay();
}
private void lstAudioDevices_SelectedIndexChanged(object sender, EventArgs e) {
device.volcontrol.selectedDeviceIndex = (uint)lstAudioDevices.SelectedIndex;
Properties.Settings.Default.volcontroldevice = device.volcontrol.getDeviceName();
Properties.Settings.Default.Save();
}
}
}