|
1 | | -using System; |
2 | | -using System.IO; |
3 | | -using System.Media; |
4 | | -using System.Resources; |
5 | | - |
6 | | -namespace DragWheel |
7 | | -{ |
8 | | - internal static class Sounds |
9 | | - { |
10 | | - //-------------------------------------------------------------- |
11 | | - static SoundPlayer s_playerIdleStop = null; |
12 | | - static SoundPlayer s_playerBurnerDetentUp = null; |
13 | | - static SoundPlayer s_playerBurnerDetentDown = null; |
14 | | - static SoundPlayer s_playerMaxBurner = null; |
15 | | - |
16 | | - static Sounds( ) |
17 | | - { |
18 | | - ResourceManager resmgr = new ResourceManager(typeof(Sounds)); |
19 | | - |
20 | | - string soundIdleStop = Config.IdleStopSound; |
21 | | - if (!String.IsNullOrEmpty(soundIdleStop)) |
22 | | - { |
23 | | - Stream wavStream = resmgr.GetStream(soundIdleStop); |
24 | | - s_playerIdleStop = new SoundPlayer(wavStream); |
25 | | - } |
26 | | - |
27 | | - string soundBurnerDetentUp = Config.BurnerDetentUpSound; |
28 | | - if (!String.IsNullOrEmpty(soundBurnerDetentUp)) |
29 | | - { |
30 | | - Stream wavStream = resmgr.GetStream(soundBurnerDetentUp); |
31 | | - s_playerBurnerDetentUp = new SoundPlayer(wavStream); |
32 | | - } |
33 | | - |
34 | | - string soundBurnerDetentDown = Config.BurnerDetentDownSound; |
35 | | - if (!String.IsNullOrEmpty(soundBurnerDetentDown)) |
36 | | - { |
37 | | - Stream wavStream = resmgr.GetStream(soundBurnerDetentDown); |
38 | | - s_playerBurnerDetentDown = new SoundPlayer(wavStream); |
39 | | - } |
40 | | - |
41 | | - string soundMaxBurner = Config.MaxBurnerSound; |
42 | | - if (!String.IsNullOrEmpty(soundMaxBurner)) |
43 | | - { |
44 | | - Stream wavStream = resmgr.GetStream(soundMaxBurner); |
45 | | - s_playerMaxBurner = new SoundPlayer(wavStream); |
46 | | - } |
47 | | - } |
48 | | - |
49 | | - //---------------------------------------- |
50 | | - public static void PlayIdleStop( ) |
51 | | - { |
52 | | - if (s_playerIdleStop != null) |
53 | | - s_playerIdleStop.Play(); |
54 | | - } |
55 | | - |
56 | | - //---------------------------------------- |
57 | | - public static void PlayBurnerDetentUp( ) |
58 | | - { |
59 | | - if (s_playerBurnerDetentUp != null) |
60 | | - s_playerBurnerDetentUp.Play(); |
61 | | - } |
62 | | - |
63 | | - //---------------------------------------- |
64 | | - public static void PlayBurnerDetentDown( ) |
65 | | - { |
66 | | - if (s_playerBurnerDetentDown != null) |
67 | | - s_playerBurnerDetentDown.Play(); |
68 | | - } |
69 | | - |
70 | | - //---------------------------------------- |
71 | | - public static void PlayMaxBurner( ) |
72 | | - { |
73 | | - if (s_playerMaxBurner != null) |
74 | | - s_playerMaxBurner.Play(); |
75 | | - } |
76 | | - |
77 | | - } |
78 | | - |
79 | | - //------------------------------------------------------------------ |
80 | | - internal static partial class Tests |
81 | | - { |
82 | | - internal static void PlaySound( ) |
83 | | - { |
84 | | - Sounds.PlayIdleStop(); |
85 | | - Sounds.PlayBurnerDetentUp(); |
86 | | - Sounds.PlayBurnerDetentDown(); |
87 | | - Sounds.PlayMaxBurner(); |
88 | | - } |
89 | | - } |
90 | | -} |
| 1 | +using System; |
| 2 | +using System.IO; |
| 3 | +using System.Media; |
| 4 | + |
| 5 | +namespace DragWheel |
| 6 | +{ |
| 7 | + internal static class Sounds |
| 8 | + { |
| 9 | + //-------------------------------------------------------------- |
| 10 | + static SoundPlayer s_playerIdleStop = null; |
| 11 | + static SoundPlayer s_playerBurnerDetentUp = null; |
| 12 | + static SoundPlayer s_playerBurnerDetentDown = null; |
| 13 | + static SoundPlayer s_playerMaxBurner = null; |
| 14 | + |
| 15 | + static Sounds( ) |
| 16 | + { |
| 17 | + ResourceLoader resloader = new ResourceLoader(); |
| 18 | + |
| 19 | + string soundIdleStop = Config.IdleStopSound; |
| 20 | + if (!String.IsNullOrEmpty(soundIdleStop)) |
| 21 | + { |
| 22 | + Stream wavStream = resloader.TryLoadResourceBinary(soundIdleStop); |
| 23 | + s_playerIdleStop = new SoundPlayer(wavStream); |
| 24 | + } |
| 25 | + |
| 26 | + string soundBurnerDetentUp = Config.BurnerDetentUpSound; |
| 27 | + if (!String.IsNullOrEmpty(soundBurnerDetentUp)) |
| 28 | + { |
| 29 | + Stream wavStream = resloader.TryLoadResourceBinary(soundBurnerDetentUp); |
| 30 | + s_playerBurnerDetentUp = new SoundPlayer(wavStream); |
| 31 | + } |
| 32 | + |
| 33 | + string soundBurnerDetentDown = Config.BurnerDetentDownSound; |
| 34 | + if (!String.IsNullOrEmpty(soundBurnerDetentDown)) |
| 35 | + { |
| 36 | + Stream wavStream = resloader.TryLoadResourceBinary(soundBurnerDetentDown); |
| 37 | + s_playerBurnerDetentDown = new SoundPlayer(wavStream); |
| 38 | + } |
| 39 | + |
| 40 | + string soundMaxBurner = Config.MaxBurnerSound; |
| 41 | + if (!String.IsNullOrEmpty(soundMaxBurner)) |
| 42 | + { |
| 43 | + Stream wavStream = resloader.TryLoadResourceBinary(soundMaxBurner); |
| 44 | + s_playerMaxBurner = new SoundPlayer(wavStream); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + //---------------------------------------- |
| 49 | + public static void PlayIdleStop( ) |
| 50 | + { |
| 51 | + if (s_playerIdleStop != null) |
| 52 | + s_playerIdleStop.Play(); |
| 53 | + } |
| 54 | + |
| 55 | + //---------------------------------------- |
| 56 | + public static void PlayBurnerDetentUp( ) |
| 57 | + { |
| 58 | + if (s_playerBurnerDetentUp != null) |
| 59 | + s_playerBurnerDetentUp.Play(); |
| 60 | + } |
| 61 | + |
| 62 | + //---------------------------------------- |
| 63 | + public static void PlayBurnerDetentDown( ) |
| 64 | + { |
| 65 | + if (s_playerBurnerDetentDown != null) |
| 66 | + s_playerBurnerDetentDown.Play(); |
| 67 | + } |
| 68 | + |
| 69 | + //---------------------------------------- |
| 70 | + public static void PlayMaxBurner( ) |
| 71 | + { |
| 72 | + if (s_playerMaxBurner != null) |
| 73 | + s_playerMaxBurner.Play(); |
| 74 | + } |
| 75 | + |
| 76 | + } |
| 77 | + |
| 78 | + //------------------------------------------------------------------ |
| 79 | + internal static partial class Tests |
| 80 | + { |
| 81 | + internal static void PlaySound( ) |
| 82 | + { |
| 83 | + Sounds.PlayIdleStop(); |
| 84 | + Sounds.PlayBurnerDetentUp(); |
| 85 | + Sounds.PlayBurnerDetentDown(); |
| 86 | + Sounds.PlayMaxBurner(); |
| 87 | + } |
| 88 | + } |
| 89 | +} |
0 commit comments