Subversion Repositories group.electronics

Rev

Rev 156 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
156 pfowler 1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Linq;
7
using System.Text;
8
using System.Threading.Tasks;
9
using System.Windows.Forms;
10
 
11
namespace NITNavComm {
12
    public partial class NITAudioSelForm : Form {
13
 
157 pfowler 14
        private NITAudioSelDevice device = null;
156 pfowler 15
 
16
        public NITAudioSelForm() {
17
            InitializeComponent();
18
 
19
            this.controlStatus(false);
20
        }
21
 
22
        private void controlStatus(bool status) {
23
            cmdUpdate.Enabled = status;
24
            inputTimer.Enabled = status;
25
        }
26
 
27
        public void UpdateDevice() {
28
            this.UpdateInput();
29
            this.UpdateDisplay();
30
        }
31
 
32
        public void UpdateDisplay() {
33
 
34
        }
35
 
36
        public void UpdateInput() {
157 pfowler 37
            device.updateInput();
38
            button0.Checked = device.isButtonSet(0);
39
            button1.Checked = device.isButtonSet(1);
40
            button2.Checked = device.isButtonSet(2);
41
            button3.Checked = device.isButtonSet(3);
42
            button4.Checked = device.isButtonSet(4);
43
            button5.Checked = device.isButtonSet(5);
44
            button6.Checked = device.isButtonSet(6);
45
            button7.Checked = device.isButtonSet(7);
156 pfowler 46
 
157 pfowler 47
            this.led0.On = device.isLedSet(0);
48
            this.led1.On = device.isLedSet(1);
49
            this.led2.On = device.isLedSet(2);
50
            this.led3.On = device.isLedSet(3);
51
            this.led4.On = device.isLedSet(4);
52
            this.led5.On = device.isLedSet(5);
53
            this.led6.On = device.isLedSet(6);
54
            this.led7.On = device.isLedSet(7);
156 pfowler 55
        }
56
 
57
        public void setDevice(NITAudioSelDevice audiosel) {
157 pfowler 58
            this.device = audiosel;
156 pfowler 59
 
157 pfowler 60
            if (!this.device.isOpen())
61
                this.device.Open();
156 pfowler 62
 
157 pfowler 63
            if (this.device.isOpen())
156 pfowler 64
                this.controlStatus(true);
65
        }
66
 
67
        private void inputTimer_Tick(object sender, EventArgs e) {
68
            this.UpdateInput();
69
        }
70
 
71
        private void cmdClose_Click(object sender, EventArgs e) {
157 pfowler 72
            if (this.device != null && device.isOpen()) {
73
                device.ClearDisplay();
74
            }
156 pfowler 75
            this.Close();
76
        }
77
 
78
        private void led0_Click(object sender, EventArgs e) {
157 pfowler 79
            bool status = this.device.isLedSet(0);
80
            this.device.setLed(0, !status);
81
            this.device.UpdateDisplay();
156 pfowler 82
        }
83
 
84
        private void led1_Click(object sender, EventArgs e) {
157 pfowler 85
            bool status = this.device.isLedSet(1);
86
            this.device.setLed(1, !status);
87
            this.device.UpdateDisplay();
156 pfowler 88
        }
89
 
90
        private void led2_Click(object sender, EventArgs e) {
157 pfowler 91
            bool status = this.device.isLedSet(2);
92
            this.device.setLed(2, !status);
93
            this.device.UpdateDisplay();
156 pfowler 94
        }
95
 
96
        private void led3_Click(object sender, EventArgs e) {
157 pfowler 97
            bool status = this.device.isLedSet(3);
98
            this.device.setLed(3, !status);
99
            this.device.UpdateDisplay();
156 pfowler 100
        }
101
 
102
        private void led4_Click(object sender, EventArgs e) {
157 pfowler 103
            bool status = this.device.isLedSet(4);
104
            this.device.setLed(4, !status);
105
            this.device.UpdateDisplay();
156 pfowler 106
        }
107
 
108
        private void led5_Click(object sender, EventArgs e) {
157 pfowler 109
            bool status = this.device.isLedSet(5);
110
            this.device.setLed(5, !status);
111
            this.device.UpdateDisplay();
156 pfowler 112
        }
113
 
114
        private void led6_Click(object sender, EventArgs e) {
157 pfowler 115
            bool status = this.device.isLedSet(6);
116
            this.device.setLed(6, !status);
117
            this.device.UpdateDisplay();
156 pfowler 118
        }
119
 
120
        private void led7_Click(object sender, EventArgs e) {
157 pfowler 121
            bool status = this.device.isLedSet(7);
122
            this.device.setLed(7, !status);
123
            this.device.UpdateDisplay();
156 pfowler 124
        }
125
 
126
    }
127
}