From: Bellai Ádám Date: Mon, 13 Nov 2017 14:40:07 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=19210deee45b2b8d5f2a92c65f122bc11076291b;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30721 --- diff --git a/client/AudioRecorder/App.config b/client/AudioRecorder/App.config index 0b1c1c84..83f62baf 100644 --- a/client/AudioRecorder/App.config +++ b/client/AudioRecorder/App.config @@ -1,12 +1,24 @@ - - - + + - - - + + + + - + + + + + + + + + + + + + \ No newline at end of file diff --git a/client/AudioRecorder/AudioRecorder.csproj b/client/AudioRecorder/AudioRecorder.csproj index 6abccf7a..d2381272 100644 --- a/client/AudioRecorder/AudioRecorder.csproj +++ b/client/AudioRecorder/AudioRecorder.csproj @@ -16,6 +16,21 @@ SAK SAK SAK + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -27,6 +42,7 @@ prompt 4 false + ManagedMinimumRules.ruleset AnyCPU @@ -79,6 +95,7 @@ maestro.ico + @@ -93,6 +110,7 @@ + @@ -143,6 +161,9 @@ + + Component + AudioDeviceSelectorForm.cs @@ -201,6 +222,18 @@ OctopusClient + + + False + Microsoft .NET Framework 4.6.1 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + diff --git a/client/AudioRecorder/MainForm.Designer.cs b/client/AudioRecorder/MainForm.Designer.cs index 49a53749..ea1c0188 100644 --- a/client/AudioRecorder/MainForm.Designer.cs +++ b/client/AudioRecorder/MainForm.Designer.cs @@ -34,11 +34,11 @@ namespace AudioRecorder { this.groupBox4 = new System.Windows.Forms.GroupBox(); this.pauseButton = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.volumePanel = new System.Windows.Forms.Panel(); this.customTrackBar1 = new AudioRecorder.CustomTrackBar(); this.fileNameLabel = new System.Windows.Forms.Label(); this.playButton = new System.Windows.Forms.Button(); this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.verticalProgressBar1 = new AudioRecorder.VerticalProgressBar(); this.groupBox1.SuspendLayout(); this.groupBox4.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -139,7 +139,7 @@ namespace AudioRecorder { // // groupBox2 // - this.groupBox2.Controls.Add(this.volumePanel); + this.groupBox2.Controls.Add(this.verticalProgressBar1); this.groupBox2.Controls.Add(this.customTrackBar1); this.groupBox2.Location = new System.Drawing.Point(262, 12); this.groupBox2.Name = "groupBox2"; @@ -147,16 +147,6 @@ namespace AudioRecorder { this.groupBox2.TabIndex = 6; this.groupBox2.TabStop = false; // - // volumePanel - // - this.volumePanel.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.volumePanel.AutoSize = true; - this.volumePanel.BackColor = System.Drawing.Color.Transparent; - this.volumePanel.Location = new System.Drawing.Point(14, 72); - this.volumePanel.Name = "volumePanel"; - this.volumePanel.Size = new System.Drawing.Size(15, 150); - this.volumePanel.TabIndex = 4; - // // customTrackBar1 // this.customTrackBar1.Location = new System.Drawing.Point(39, 15); @@ -199,6 +189,15 @@ namespace AudioRecorder { this.groupBox3.TabIndex = 10; this.groupBox3.TabStop = false; // + // verticalProgressBar1 + // + this.verticalProgressBar1.BackColor = System.Drawing.Color.White; + this.verticalProgressBar1.ForeColor = System.Drawing.Color.White; + this.verticalProgressBar1.Location = new System.Drawing.Point(18, 19); + this.verticalProgressBar1.Name = "verticalProgressBar1"; + this.verticalProgressBar1.Size = new System.Drawing.Size(15, 203); + this.verticalProgressBar1.TabIndex = 12; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -221,7 +220,6 @@ namespace AudioRecorder { this.groupBox1.PerformLayout(); this.groupBox4.ResumeLayout(false); this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); this.groupBox3.ResumeLayout(false); this.ResumeLayout(false); @@ -239,9 +237,9 @@ namespace AudioRecorder { private System.Windows.Forms.Button playButton; private System.Windows.Forms.Button pauseButton; private System.Windows.Forms.GroupBox groupBox3; - private System.Windows.Forms.Panel volumePanel; private System.Windows.Forms.GroupBox groupBox4; private CustomTrackBar customTrackBar1; + private VerticalProgressBar verticalProgressBar1; } } diff --git a/client/AudioRecorder/MainForm.cs b/client/AudioRecorder/MainForm.cs index 9bcda0ff..41b19f47 100644 --- a/client/AudioRecorder/MainForm.cs +++ b/client/AudioRecorder/MainForm.cs @@ -5,7 +5,7 @@ using System.Drawing; using NAudio.CoreAudioApi; using System.Windows.Forms; using System.IO; - +using System.Runtime.InteropServices; namespace AudioRecorder { public delegate void RefreshPanelDelegate(); @@ -13,6 +13,9 @@ namespace AudioRecorder public partial class MainForm : Form, IMainForm { + [DllImport("user32.dll")] + public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam); + private const String CONFIG_FILE = "Resources/configuration.json"; private IRecorder recorder; @@ -37,9 +40,7 @@ namespace AudioRecorder { InitializeComponent(); InitializeControlTexts(); - volumePanel.Paint += panelPaintEvent; customTrackBar1.MainForm = this; - setVolumePanelData(); try { settings = JsonSettings.GetInstance(CONFIG_FILE); @@ -77,14 +78,6 @@ namespace AudioRecorder } } - private void setVolumePanelData() - { - originalPanelLocation = volumePanel.Location; - startingPanelLocation = volumePanel.Location; - startingPanelLocation.X = 12; - startingPanelLocation.Y = 230; - } - private void saveAudioDeviceToConfig() { if (String.IsNullOrEmpty(settings.getAudioDeviceName())) @@ -116,47 +109,21 @@ namespace AudioRecorder public void setPanelSizeHeight(float height) { - Debug.WriteLine(String.Format("height {0}", height)); volumeHeight = height; - //volumePanel.Invalidate(); - //volumePanel.Update(); - if (volumePanel.InvokeRequired) { + if (verticalProgressBar1.InvokeRequired) { refreshPanel = RefreshVolumePanel; this.Invoke(refreshPanel); } else { - volumePanel.Refresh(); + RefreshVolumePanel(); } } private void RefreshVolumePanel() { - volumePanel.Refresh(); - } - - private void panelPaintEvent(object sender, PaintEventArgs e) - { - //Debug.WriteLine(String.Format("volumeHeight {0}", volumeHeight)); - //if (volumeHeight >= 200) - // return; - if (!recording) - { - volumePanel.Controls.Clear(); - return; - } - if (volumeHeight > 500) - return; - float volumePercent = 100 / (200 / volumeHeight);// / 10; - Graphics g = e.Graphics; - Point panelLocation = startingPanelLocation; - panelLocation.Y = panelLocation.Y - (int)volumeHeight; - volumePanel.Location = panelLocation; - //volumeHeightnak mennyi a max értéke? akkor már tudnám, hogy az adott érték az hány %, és azt - //hasonlítanám össze a getLoudValue()-val - Color color = (volumePercent > settings.getLoudValue()) ? Color.Red : Color.Chartreuse; - SolidBrush brush = new SolidBrush(color); - //itt is a Rectangle.height értéke a volumeHeight százalékból lenne kiszámolva - //ha 70% a volumeHeight akkor a magasság is 70%-a lenne a területnek - Rectangle rectangle = new Rectangle(0, -10, 500, (int)volumeHeight); - g.FillRectangle(brush, rectangle); + if(volumeHeight > settings.getLoudValue()) + SendMessage(verticalProgressBar1.Handle, 1040, 2, 0); + else + SendMessage(verticalProgressBar1.Handle, 1040, 1, 0); + verticalProgressBar1.Value = (int)volumeHeight; } private void Form1_Load(object sender, EventArgs e) @@ -178,12 +145,12 @@ namespace AudioRecorder stopButton.Enabled = false; selectAudioButton.Enabled = true; pauseButton.Enabled = false; + verticalProgressBar1.Value = 0; recorder.StopRecording(); timeCodeWorker.Stop(); playButton.Enabled = true; stopButton.BackColor = Color.White; recordButton.BackColor = Color.Lime; - volumePanel.Refresh(); copyFileToUncPath(); } catch (Exception e) diff --git a/client/AudioRecorder/Program.cs b/client/AudioRecorder/Program.cs index 9aec5d11..1c9899f6 100644 --- a/client/AudioRecorder/Program.cs +++ b/client/AudioRecorder/Program.cs @@ -7,7 +7,7 @@ namespace AudioRecorder { /// /// The main entry point for the application. /// - [STAThread] + [MTAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); diff --git a/client/AudioRecorder/Resources/configuration.json b/client/AudioRecorder/Resources/configuration.json index 626a9e1c..e6202afb 100644 --- a/client/AudioRecorder/Resources/configuration.json +++ b/client/AudioRecorder/Resources/configuration.json @@ -2,9 +2,9 @@ "audio_device_name": "", "unc_path": "c:\\temp", "working_dir": "C:\\temp", - "loud_percent": 30, + "loud_percent": 10, "address": "http://10.10.1.28/services/rest/octopus/", "userName": "dani", "password": "dani", "timeout": 1000 -} +} \ No newline at end of file diff --git a/client/AudioRecorder/VerticalProgressBar.cs b/client/AudioRecorder/VerticalProgressBar.cs new file mode 100644 index 00000000..04ccaca7 --- /dev/null +++ b/client/AudioRecorder/VerticalProgressBar.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AudioRecorder { + class VerticalProgressBar : ProgressBar { + + protected override CreateParams CreateParams { + get { + CreateParams cp = base.CreateParams; + cp.Style |= 0x04; + return cp; + } + } + } +} diff --git a/client/AudioRecorder/WavRecorder.cs b/client/AudioRecorder/WavRecorder.cs index 7fd38ca2..f80d3184 100644 --- a/client/AudioRecorder/WavRecorder.cs +++ b/client/AudioRecorder/WavRecorder.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using NAudio.Wave; using NAudio.CoreAudioApi; using System.Diagnostics; +using System.Linq; namespace AudioRecorder { public class WavRecorder : IRecorder { @@ -26,8 +27,9 @@ namespace AudioRecorder { public void StartRecording(String filePath) { this.filePath = filePath; - //sourceStream = newWaveIn(); sourceStream = new WasapiCapture(device); + //sourceStream = newWaveIn(); + sourceStream.DataAvailable += newEventHandler(); waveWriter = newWavFileWriter(); sourceStream.StartRecording(); @@ -57,9 +59,9 @@ namespace AudioRecorder { waveWriter.Write(e.Buffer, 0, e.BytesRecorded); waveWriter.Flush(); try { - //float panelHeight = device.AudioEndpointVolume.MasterVolumeLevelScalar * 100;//(device.AudioMeterInformation.MasterPeakValue + device.AudioSessionManager.SimpleAudioVolume.Volume) * 100; - //Debug.WriteLine(string.Format("panelHeight {0}", panelHeight) ); - //mainForm.setPanelSizeHeight(panelHeight); + int panelHeight = (int)Math.Round(device.AudioMeterInformation.MasterPeakValue * 100);//(device.AudioMeterInformation.MasterPeakValue) * 100; + Debug.WriteLine(string.Format("panelHeight {0}", panelHeight)); + mainForm.setPanelSizeHeight(panelHeight); } catch (Exception ex) { Debug.WriteLine(ex.Message);