Subversion Repositories group.NITPanels

Rev

Rev 19 | 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);
        }

        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);
        }

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

            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();
        }

    }
}