HamBook – Diff between revs 14 and 15

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 14 Rev 15
Line 33... Line 33...
33 private const UInt32 SWP_NOMOVE = 0x0002; 33 private const UInt32 SWP_NOMOVE = 0x0002;
34 private const UInt32 SWP_NOACTIVATE = 0x0010; 34 private const UInt32 SWP_NOACTIVATE = 0x0010;
Line 35... Line 35...
35   35  
Line 36... Line 36...
36 #endregion 36 #endregion
37   37  
38 private Configuration.Configuration _configuration; 38 private Configuration.Configuration Configuration { get; set; }
39 private CancellationToken _cancellationToken; 39 private CancellationToken _cancellationToken;
40 SpectrogramGenerator _spectrogramGenerator; 40 SpectrogramGenerator _spectrogramGenerator;
41 private WaveIn _waveIn; 41 private WaveIn _waveIn;
Line 55... Line 55...
55 55
Line 56... Line 56...
56 } 56 }
57   57  
58 public SpectrogramForm(Configuration.Configuration configuration, CancellationToken cancellationToken) : this() 58 public SpectrogramForm(Configuration.Configuration configuration, CancellationToken cancellationToken) : this()
59 { 59 {
Line 60... Line 60...
60 _configuration = configuration; 60 Configuration = configuration;
61 _cancellationToken = cancellationToken; 61 _cancellationToken = cancellationToken;
Line 62... Line 62...
62   62  
63 _spectrogramGenerator = new SpectrogramGenerator(_configuration.Visualisations.Spectrogram.SampleRate, fftSize: _configuration.Visualisations.Spectrogram.FFTSamples, stepSize: _configuration.Visualisations.Spectrogram.FFTSamples / _configuration.Visualisations.Spectrogram.AudioBufferTimespan); 63 _spectrogramGenerator = new SpectrogramGenerator(Configuration.Visualisations.Spectrogram.SampleRate, fftSize: Configuration.Visualisations.Spectrogram.FFTSamples, stepSize: Configuration.Visualisations.Spectrogram.FFTSamples / Configuration.Visualisations.Spectrogram.AudioBufferTimespan);
Line 92... Line 92...
92 base.Dispose(disposing); 92 base.Dispose(disposing);
93 } 93 }
Line 94... Line 94...
94   94  
95 private void SpectrogramForm_Load(object sender, EventArgs e) 95 private void SpectrogramForm_Load(object sender, EventArgs e)
96 { 96 {
Line 97... Line 97...
97 pinToDesktopToolStripMenuItem.Checked = _configuration.Visualisations.Spectrogram.PinToDesktop; 97 pinToDesktopToolStripMenuItem.Checked = Configuration.Visualisations.Spectrogram.PinToDesktop;
98   98  
99 if (_configuration.Visualisations.Spectrogram.PinToDesktop) 99 if (Configuration.Visualisations.Spectrogram.PinToDesktop)
100 { 100 {
101 _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), () => 101 _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), () =>
102 { 102 {
Line 108... Line 108...
108 } 108 }
Line 109... Line 109...
109   109  
110 foreach (var deviceNumber in Enumerable.Range(0, WaveIn.DeviceCount)) 110 foreach (var deviceNumber in Enumerable.Range(0, WaveIn.DeviceCount))
111 { 111 {
112 var capabilities = WaveIn.GetCapabilities(deviceNumber); 112 var capabilities = WaveIn.GetCapabilities(deviceNumber);
113 if(!string.Equals(capabilities.ProductName, _configuration.Audio.InputDeviceFriendlyName)) 113 if(!string.Equals(capabilities.ProductName, Configuration.Audio.InputDeviceFriendlyName))
114 { 114 {
115 continue; 115 continue;
Line 116... Line 116...
116 } 116 }
117   117  
118 _waveIn = new WaveIn(); 118 _waveIn = new WaveIn();
Line 119... Line 119...
119 _waveIn.DeviceNumber = deviceNumber; 119 _waveIn.DeviceNumber = deviceNumber;
120 _waveIn.BufferMilliseconds = _configuration.Visualisations.Spectrogram.AudioBufferTimespan; 120 _waveIn.BufferMilliseconds = Configuration.Visualisations.Spectrogram.AudioBufferTimespan;
121   121  
122 _waveIn.DataAvailable += _waveIn_DataAvailable; 122 _waveIn.DataAvailable += _waveIn_DataAvailable;
Line 150... Line 150...
150 } 150 }
Line 151... Line 151...
151   151  
152 _spectrogramGenerator.Process(); 152 _spectrogramGenerator.Process();
153 _spectrogramGenerator.SetFixedWidth(pictureBox1.Width); 153 _spectrogramGenerator.SetFixedWidth(pictureBox1.Width);
154 var bmpSpec = new Bitmap(_spectrogramGenerator.Width, _spectrogramGenerator.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); 154 var bmpSpec = new Bitmap(_spectrogramGenerator.Width, _spectrogramGenerator.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
155 using (var bmpSpecIndexed = _spectrogramGenerator.GetBitmap(_configuration.Visualisations.Spectrogram.SpectrumIntensity)) 155 using (var bmpSpecIndexed = _spectrogramGenerator.GetBitmap(Configuration.Visualisations.Spectrogram.SpectrumIntensity))
156 using (var gfx = Graphics.FromImage(bmpSpec)) 156 using (var gfx = Graphics.FromImage(bmpSpec))
157 using (var pen = new Pen(Color.White)) 157 using (var pen = new Pen(Color.White))
158 { 158 {
159 gfx.DrawImage(bmpSpecIndexed, 0, 0); 159 gfx.DrawImage(bmpSpecIndexed, 0, 0);
Line 237... Line 237...
237 //SetWindowPos(Handle, HWND_BOTTOM, 0, 0, Location.X, Location.Y, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); 237 //SetWindowPos(Handle, HWND_BOTTOM, 0, 0, Location.X, Location.Y, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
238 } 238 }
Line 239... Line 239...
239   239  
240 private void SpectrogramForm_MouseEnter(object sender, EventArgs e) 240 private void SpectrogramForm_MouseEnter(object sender, EventArgs e)
241 { 241 {
242 if (_configuration.Visualisations.Spectrogram.PinToDesktop) 242 if (Configuration.Visualisations.Spectrogram.PinToDesktop)
243 { 243 {
244 _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), () => 244 _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), () =>
245 { 245 {
246 this.InvokeIfRequired(form => 246 this.InvokeIfRequired(form =>
Line 251... Line 251...
251 } 251 }
252 } 252 }
Line 253... Line 253...
253   253  
254 private void SpectrogramForm_MouseLeave(object sender, EventArgs e) 254 private void SpectrogramForm_MouseLeave(object sender, EventArgs e)
255 { 255 {
256 if (_configuration.Visualisations.Spectrogram.PinToDesktop) 256 if (Configuration.Visualisations.Spectrogram.PinToDesktop)
257 { 257 {
258 _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), () => 258 _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), () =>
259 { 259 {
260 this.InvokeIfRequired(form => 260 this.InvokeIfRequired(form =>
Line 271... Line 271...
271 var toolStripMenuItem = (ToolStripMenuItem)sender; 271 var toolStripMenuItem = (ToolStripMenuItem)sender;
Line 272... Line 272...
272   272  
273 switch(toolStripMenuItem.CheckState) 273 switch(toolStripMenuItem.CheckState)
274 { 274 {
275 case CheckState.Checked: 275 case CheckState.Checked:
276 _configuration.Visualisations.Spectrogram.PinToDesktop = true; 276 Configuration.Visualisations.Spectrogram.PinToDesktop = true;
277 break; 277 break;
278 case CheckState.Unchecked: 278 case CheckState.Unchecked:
279 _configuration.Visualisations.Spectrogram.PinToDesktop = false; 279 Configuration.Visualisations.Spectrogram.PinToDesktop = false;
280 break; 280 break;
281 } 281 }
282 } 282 }
283 } 283 }