Rev 16 | Go to most recent revision | 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();
}
private void cmdUpdate_Click(object sender, EventArgs e) {
uint selectAudioDevice = (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(selectAudioDevice, volume);
txtVol.Text = Convert.ToString(device.volcontrol.getDeviceVolume(selectAudioDevice));
this.device.powerLedStatus = 0;
this.device.UpdateDisplay();
}
private float map_f(uint x, uint in_min, uint in_max, float out_min, float out_max) {
float var = (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
return var;
}
public void setDevice(NITAudioSelDevice audiosel) {
this.device = audiosel;
foreach (string audio in device.volcontrol.devices) {
lstAudioDevices.Items.Add(audio);
}
if (!this.device.isOpen())
this.device.Open();
if (this.device.isOpen())
this.controlStatus(true);
}
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();
}
}
}