Subversion Repositories group.NITPanels

Rev

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

Rev Author Line No. Line
16 pfowler 1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Runtime.InteropServices;
7
 
8
namespace NITNavComm {
9
 
10
    public class VolumeControl {
11
 
12
        [DllImport("VolControlLib.dll")]
13
        public static extern int _getDevCount(out uint count);
14
 
15
        [DllImport("VolControlLib.dll",CharSet = CharSet.Ansi,CallingConvention=CallingConvention.StdCall)]
16
        [return: MarshalAs(UnmanagedType.LPWStr)]
17
        public static extern string _getDevName(uint dev);
18
 
19
        [DllImport("VolControlLib.dll")]
20
        public static extern uint _getDevVolume(uint dev, out float volume);
21
 
22
        [DllImport("VolControlLib.dll")]
23
        public static extern uint _setDevVolume(uint dev, float volume);
24
 
25
        public uint deviceCount { get; set; }
26
        public List<string> devices { get; set; }
27
 
22 pfowler 28
        public uint selectedDeviceIndex { get; set; }
16 pfowler 29
 
22 pfowler 30
 
16 pfowler 31
        public VolumeControl() {
32
            uint count = 0;
33
            _getDevCount(out count);
34
            this.deviceCount = count;
35
 
36
            devices = new List<string>();
37
            if (this.deviceCount > 0) {
38
                for (uint i = 0; i < this.deviceCount; i++) {
39
                    this.devices.Add(this.getDeviceName(i));
40
                }
41
            }
42
 
43
        }
44
 
45
        public String getDeviceName(uint dev) {
46
            string s = _getDevName(dev);
47
            return s;
48
        }
49
 
22 pfowler 50
        public String getDeviceName() {
51
            return this.getDeviceName(this.selectedDeviceIndex);
52
        }
53
 
16 pfowler 54
        public float getDeviceVolume(uint dev) {
55
            float volume = 0.0F;
56
            _getDevVolume(dev, out volume);
57
            return volume;
58
        }
59
 
22 pfowler 60
        public float getDeviceVolume() {
61
            return this.getDeviceVolume(this.selectedDeviceIndex);
62
        }
63
 
16 pfowler 64
        public void setDeviceVolume(uint dev, float volume) {
65
            _setDevVolume(dev, volume);
66
        }
67
 
22 pfowler 68
        public void setDeviceVolume(float volume) {
69
            this.setDeviceVolume(this.selectedDeviceIndex, volume);
70
        }
71
 
16 pfowler 72
    }
73
}