Subversion Repositories group.electronics

Rev

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 audiosel = null;

        public NITAudioSelForm() {
            InitializeComponent();

            this.controlStatus(false);
        }

        private void controlStatus(bool status) {
            cmdUpdate.Enabled = status;
            inputTimer.Enabled = status;
        }

        public void UpdateDevice() {
            this.UpdateInput();
            this.UpdateDisplay();
        }

        public void UpdateDisplay() {

        }

        public void UpdateInput() {
            audiosel.updateInput();
            button0.Checked = audiosel.isButtonSet(0);
            button1.Checked = audiosel.isButtonSet(1);
            button2.Checked = audiosel.isButtonSet(2);
            button3.Checked = audiosel.isButtonSet(3);
            button4.Checked = audiosel.isButtonSet(4);
            button5.Checked = audiosel.isButtonSet(5);
            button6.Checked = audiosel.isButtonSet(6);
            button7.Checked = audiosel.isButtonSet(7);

            this.led0.On = audiosel.isLedSet(0);
            this.led1.On = audiosel.isLedSet(1);
            this.led2.On = audiosel.isLedSet(2);
            this.led3.On = audiosel.isLedSet(3);
            this.led4.On = audiosel.isLedSet(4);
            this.led5.On = audiosel.isLedSet(5);
            this.led6.On = audiosel.isLedSet(6);
            this.led7.On = audiosel.isLedSet(7);
        }

        public void setDevice(NITAudioSelDevice audiosel) {
            this.audiosel = audiosel;

            if (!audiosel.isOpen())
                audiosel.Open();

            if (audiosel.isOpen())
                this.controlStatus(true);
        }

        private void inputTimer_Tick(object sender, EventArgs e) {
            this.UpdateInput();
        }

        private void cmdClose_Click(object sender, EventArgs e) {
            this.Close();
        }

        private void led0_Click(object sender, EventArgs e) {
            bool status = this.audiosel.isLedSet(0);
            this.audiosel.setLed(0, !status);
            this.audiosel.UpdateDisplay();
        }

        private void led1_Click(object sender, EventArgs e) {
            bool status = this.audiosel.isLedSet(1);
            this.audiosel.setLed(1, !status);
            this.audiosel.UpdateDisplay();
        }

        private void led2_Click(object sender, EventArgs e) {
            bool status = this.audiosel.isLedSet(2);
            this.audiosel.setLed(2, !status);
            this.audiosel.UpdateDisplay();
        }

        private void led3_Click(object sender, EventArgs e) {
            bool status = this.audiosel.isLedSet(3);
            this.audiosel.setLed(3, !status);
            this.audiosel.UpdateDisplay();
        }

        private void led4_Click(object sender, EventArgs e) {
            bool status = this.audiosel.isLedSet(4);
            this.audiosel.setLed(4, !status);
            this.audiosel.UpdateDisplay();
        }

        private void led5_Click(object sender, EventArgs e) {
            bool status = this.audiosel.isLedSet(5);
            this.audiosel.setLed(5, !status);
            this.audiosel.UpdateDisplay();
        }

        private void led6_Click(object sender, EventArgs e) {
            bool status = this.audiosel.isLedSet(6);
            this.audiosel.setLed(6, !status);
            this.audiosel.UpdateDisplay();
        }

        private void led7_Click(object sender, EventArgs e) {
            bool status = this.audiosel.isLedSet(7);
            this.audiosel.setLed(7, !status);
            this.audiosel.UpdateDisplay();
        }

    }
}