From: Vásáry Dániel Date: Fri, 24 Nov 2017 16:35:16 +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=55b04adcef8fb596b01ea9d6f443ae7f12f3ff39;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30767 --- diff --git a/client/AudioRecorder/AudioDeviceSelectorForm.Designer.cs b/client/AudioRecorder/AudioDeviceSelectorForm.Designer.cs index 22426b7c..6ce3a5bd 100644 --- a/client/AudioRecorder/AudioDeviceSelectorForm.Designer.cs +++ b/client/AudioRecorder/AudioDeviceSelectorForm.Designer.cs @@ -24,7 +24,6 @@ /// private void InitializeComponent() { this.audioDevicesComboBox = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.cancelButton = new System.Windows.Forms.Button(); this.okButton = new System.Windows.Forms.Button(); @@ -33,37 +32,27 @@ // // audioDevicesComboBox // + this.audioDevicesComboBox.BackColor = System.Drawing.Color.White; this.audioDevicesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.audioDevicesComboBox.FormattingEnabled = true; - this.audioDevicesComboBox.Location = new System.Drawing.Point(9, 32); + this.audioDevicesComboBox.Location = new System.Drawing.Point(9, 27); this.audioDevicesComboBox.Name = "audioDevicesComboBox"; - this.audioDevicesComboBox.Size = new System.Drawing.Size(359, 21); + this.audioDevicesComboBox.Size = new System.Drawing.Size(355, 21); this.audioDevicesComboBox.TabIndex = 0; // - // label1 - // - this.label1.AutoEllipsis = true; - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(10, 7); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(101, 13); - this.label1.TabIndex = 2; - this.label1.Text = "Select audio device"; - // // groupBox1 // - this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.audioDevicesComboBox); - this.groupBox1.Location = new System.Drawing.Point(2, 2); + this.groupBox1.Location = new System.Drawing.Point(4, 2); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(376, 69); + this.groupBox1.Size = new System.Drawing.Size(372, 69); this.groupBox1.TabIndex = 4; this.groupBox1.TabStop = false; // // cancelButton // this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(214, 91); + this.cancelButton.Location = new System.Drawing.Point(214, 85); this.cancelButton.Name = "cancelButton"; this.cancelButton.Size = new System.Drawing.Size(75, 23); this.cancelButton.TabIndex = 3; @@ -73,7 +62,7 @@ // // okButton // - this.okButton.Location = new System.Drawing.Point(295, 91); + this.okButton.Location = new System.Drawing.Point(295, 85); this.okButton.Name = "okButton"; this.okButton.Size = new System.Drawing.Size(75, 23); this.okButton.TabIndex = 1; @@ -86,17 +75,19 @@ this.AcceptButton = this.okButton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(381, 127); + this.ClientSize = new System.Drawing.Size(381, 118); this.ControlBox = false; this.Controls.Add(this.okButton); this.Controls.Add(this.groupBox1); this.Controls.Add(this.cancelButton); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Name = "AudioDeviceSelectorForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "AudioRecorder input device selector"; + this.TopMost = true; this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); this.ResumeLayout(false); } @@ -104,7 +95,6 @@ #endregion private System.Windows.Forms.ComboBox audioDevicesComboBox; - private System.Windows.Forms.Label label1; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button cancelButton; private System.Windows.Forms.Button okButton; diff --git a/client/AudioRecorder/AudioDeviceSelectorForm.cs b/client/AudioRecorder/AudioDeviceSelectorForm.cs index a0fb7437..77386177 100644 --- a/client/AudioRecorder/AudioDeviceSelectorForm.cs +++ b/client/AudioRecorder/AudioDeviceSelectorForm.cs @@ -1,92 +1,57 @@ using System; using System.Collections.Generic; -using NAudio.CoreAudioApi; using System.Windows.Forms; namespace AudioRecorder { - public partial class AudioDeviceSelectorForm : Form, IAudioDeviceSelectorForm { + public partial class AudioDeviceSelectorForm : Form { - private IAudioDevicesDetector devicesDetector; - private List deviceNames = new List(); - private IMainForm mainForm; - private bool deviceConnected; + private List deviceNames; + private AudioRecorderSettings parameters; - public AudioDeviceSelectorForm(IMainForm mainForm) { + public AudioDeviceSelectorForm() { InitializeComponent(); InitializeControlTexts(); - StartPosition = FormStartPosition.CenterParent; - devicesDetector = new AudioDevicesDetector(); - this.mainForm = mainForm; + audioDevicesComboBox.KeyDown += (sender, args) => { if (args.KeyCode == Keys.Return) - okButton.PerformClick(); + Close(); }; audioDevicesComboBox.KeyDown += (sender, args) => { if (args.KeyCode == Keys.Escape) - { - Dispose(); - } + Close(); }; - findDevicesAnd(); } - private void InitializeControlTexts() - { + private void InitializeControlTexts() { cancelButton.Text = Resources.MEGSE; - label1.Text = Resources.VALASSZON_MIKROFONT; - this.Text = Resources.MIKROFON_VALASZTAS; - } - - public AudioDeviceSelectorForm(IMainForm mainForm, IAudioDevicesDetector devicesDetector) { - InitializeComponent(); - this.devicesDetector = devicesDetector; - this.mainForm = mainForm; - findDevicesAnd(); + this.Text = Resources.VALASSZON_MIKROFONT; } - private void findDevicesAnd() { - devicesDetector.findDevices(); - deviceNames = devicesDetector.getDeviceNames(); - foreach (String actual in deviceNames) - audioDevicesComboBox.Items.Add(actual); - if (deviceNames.Count > 0) { + public int Open(List deviceNames, int selectedIndex, ref AudioRecorderSettings parameters) { + this.deviceNames = deviceNames; + audioDevicesComboBox.DataSource = deviceNames; + + if (selectedIndex < deviceNames.Count - 1 && selectedIndex > -1) + audioDevicesComboBox.SelectedIndex = selectedIndex; + if (selectedIndex == -1 && deviceNames.Count > 0) audioDevicesComboBox.SelectedIndex = 0; - okButton.Enabled = true; - deviceConnected = true; - } else { - DialogResult result = MessageBox.Show(StringResources.CONNECT_AUDIO_DEVICE, StringResources.ERROR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); - deviceConnected = false; - mainForm.disableRecordButton(); - Dispose(); - } + this.parameters = parameters; + if (ShowDialog() == DialogResult.OK) + return audioDevicesComboBox.SelectedIndex; + else + return selectedIndex; } private void okButton_Click(object sender, EventArgs e) { - int index = audioDevicesComboBox.SelectedIndex; - String value = deviceNames[index]; - mainForm.initWavRecorder(index, value); - Dispose(); - } - - public List getDeviceNames() { - return deviceNames; + DialogResult = DialogResult.OK; + parameters.audio_device_name = deviceNames[audioDevicesComboBox.SelectedIndex]; + Close(); } - public bool isDeviceConnected() { - return deviceConnected; + private void cancelButton_Click(object sender, EventArgs e) { + DialogResult = DialogResult.Cancel; + Close(); } - public bool isDisposed() { - return IsDisposed; - } - - public List getDevices() { - return devicesDetector.getDevices(); - } - - private void cancelButton_Click(object sender, EventArgs e) - { - Dispose(); - } } } diff --git a/client/AudioRecorder/AudioRecorder.csproj b/client/AudioRecorder/AudioRecorder.csproj index 399ee87e..53fd4f12 100644 --- a/client/AudioRecorder/AudioRecorder.csproj +++ b/client/AudioRecorder/AudioRecorder.csproj @@ -122,6 +122,7 @@ AudioDeviceSelectorForm.cs + UserControl @@ -135,11 +136,8 @@ FileNameForm.cs - - - Form @@ -151,6 +149,12 @@ + + Component + + + PeakMeterCtrl.cs + @@ -202,7 +206,7 @@ True - PreserveNewest + Always @@ -212,6 +216,7 @@ + diff --git a/client/AudioRecorder/AudioRecorderSettings.cs b/client/AudioRecorder/AudioRecorderSettings.cs new file mode 100644 index 00000000..c7d2549c --- /dev/null +++ b/client/AudioRecorder/AudioRecorderSettings.cs @@ -0,0 +1,28 @@ +using System; +using Newtonsoft.Json; +using System.IO; +using System.Windows.Forms; + +namespace AudioRecorder { + public class AudioRecorderSettings { + public String audio_device_name { get; set; } + public String unc_path { get; set; } + public int loud_percent { get; set; } + public String working_dir { get; set; } + + public Uri address { get; set; } + public String userName { get; set; } + public String password { get; set; } + public int timeout { get; set; } + + + public void Save(string fileName) { + try { + File.WriteAllText(fileName, JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented)); + } + catch (Exception e) { + MessageBox.Show(e.Message); + } + } + } +} diff --git a/client/AudioRecorder/Configuration/audiorecorder.json b/client/AudioRecorder/Configuration/audiorecorder.json index 4b8317be..720bf366 100644 --- a/client/AudioRecorder/Configuration/audiorecorder.json +++ b/client/AudioRecorder/Configuration/audiorecorder.json @@ -1,8 +1,22 @@ { "audio_device_name": "", - "unc_path": "I:\\", "working_dir": "C:\\temp", - "loud_percent": 30, + "loud_percent": 200, + "target" : { + "label": "Octopus mappába küldés", + "processor": "FTPTargetProcessor", + "tag": "Betöltés", + "outputFormat": "%ID%", + "subFolderFormat": "%IDROOT%-%TEXT%", + "killDateDays": 7, + "saveArchiveMetadata": false, + "remote": { + "address": "ftp://10.10.1.100/OCTOPUS", + "userName": "mediacube", + "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy", + "timeout": 1000 + } + }, "address": "http://10.10.1.27/services/rest/octopus/", "userName": "dani", "password": "dani", diff --git a/client/AudioRecorder/CustomTrackBar.Designer.cs b/client/AudioRecorder/CustomTrackBar.Designer.cs index 07cce022..6048f847 100644 --- a/client/AudioRecorder/CustomTrackBar.Designer.cs +++ b/client/AudioRecorder/CustomTrackBar.Designer.cs @@ -28,21 +28,11 @@ /// private void InitializeComponent() { - this.trackBar1 = new System.Windows.Forms.TrackBar(); this.tickLabel = new System.Windows.Forms.Label(); + this.trackBar1 = new System.Windows.Forms.TrackBar(); ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit(); this.SuspendLayout(); // - // trackBar1 - // - this.trackBar1.Location = new System.Drawing.Point(0, 0); - this.trackBar1.Name = "trackBar1"; - this.trackBar1.Orientation = System.Windows.Forms.Orientation.Vertical; - this.trackBar1.Size = new System.Drawing.Size(45, 214); - this.trackBar1.TabIndex = 0; - this.trackBar1.TickFrequency = 0; - this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged); - // // tickLabel // this.tickLabel.AutoSize = true; @@ -53,6 +43,16 @@ this.tickLabel.TabIndex = 1; this.tickLabel.Text = "_"; // + // trackBar1 + // + this.trackBar1.Location = new System.Drawing.Point(0, 0); + this.trackBar1.Name = "trackBar1"; + this.trackBar1.Orientation = System.Windows.Forms.Orientation.Vertical; + this.trackBar1.Size = new System.Drawing.Size(45, 214); + this.trackBar1.TabIndex = 0; + this.trackBar1.TickFrequency = 0; + this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged); + // // CustomTrackBar // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -69,7 +69,7 @@ #endregion - private System.Windows.Forms.TrackBar trackBar1; private System.Windows.Forms.Label tickLabel; + private System.Windows.Forms.TrackBar trackBar1; } } diff --git a/client/AudioRecorder/FileNameForm.cs b/client/AudioRecorder/FileNameForm.cs index ee798766..74392add 100644 --- a/client/AudioRecorder/FileNameForm.cs +++ b/client/AudioRecorder/FileNameForm.cs @@ -5,25 +5,22 @@ using MaestroShared.Configuration; namespace AudioRecorder { public partial class FileNameForm : Form { - private String result; - private IMainForm mainForm; - private ISettings settings; + private MainForm mainForm; private String id; - public FileNameForm(IMainForm mainForm, ISettings settings) { + public FileNameForm(MainForm mainForm, AudioRecorderSettings settings) { InitializeComponent(); - this.settings = settings; this.mainForm = mainForm; octopusIDSelector1.IDChangedEvent = IdChangedEvent; octopusIDSelector1.Parameters = new OctopusParameters() { UserName = "Hangalámondó", Configuration = new OctopusMetadata() { Server = new Connection() { - Address = settings.getAddress(), - Password = settings.getPassword(), - UserName = settings.getUserName(), - Timeout = settings.getTimeout() + Address = settings.address, + Password = settings.password, + UserName = settings.userName, + Timeout = settings.timeout } } }; diff --git a/client/AudioRecorder/FileWorker.cs b/client/AudioRecorder/FileWorker.cs index b35bd472..1e7c22aa 100644 --- a/client/AudioRecorder/FileWorker.cs +++ b/client/AudioRecorder/FileWorker.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using System.IO; namespace AudioRecorder { diff --git a/client/AudioRecorder/IAudioDeviceSelectorForm.cs b/client/AudioRecorder/IAudioDeviceSelectorForm.cs deleted file mode 100644 index 9367c14b..00000000 --- a/client/AudioRecorder/IAudioDeviceSelectorForm.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using NAudio.CoreAudioApi; -using System.Windows.Forms; -namespace AudioRecorder { - public interface IAudioDeviceSelectorForm { - DialogResult ShowDialog(); - List getDeviceNames(); - bool isDeviceConnected(); - bool isDisposed(); - List getDevices(); - } -} diff --git a/client/AudioRecorder/ISettings.cs b/client/AudioRecorder/ISettings.cs deleted file mode 100644 index 4fd1085e..00000000 --- a/client/AudioRecorder/ISettings.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace AudioRecorder { - public interface ISettings { - String getAudioDeviceName(); - String getUncPath(); - int getLoudValue(); - String getWorkingDir(); - Uri getAddress(); - String getUserName(); - String getPassword(); - int getTimeout(); - void addSelectedAudio(String value, String fileName); - } -} diff --git a/client/AudioRecorder/JsonSettings.cs b/client/AudioRecorder/JsonSettings.cs deleted file mode 100644 index 02ba3df6..00000000 --- a/client/AudioRecorder/JsonSettings.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using System.IO; -namespace AudioRecorder -{ - public class JsonSettings : ISettings - { - public String audio_device_name { get; set; } - public String unc_path { get; set; } - public int loud_percent { get; set; } - public String working_dir { get; set; } - - public Uri address; - public String userName; - public String password; - public int timeout; - - private JsonSettings() - { - - } - - public static JsonSettings GetInstance(string configFileName) - { - string configuration = File.ReadAllText(configFileName); - KnownTypesBinder knownTypesBinder = new KnownTypesBinder - { - KnownTypes = new List { typeof(String), typeof(String), typeof(String), typeof(int), } - }; - JsonSerializerSettings settings = new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.Objects, - SerializationBinder = knownTypesBinder, - }; - - return JsonConvert.DeserializeObject(configuration, settings); - } - - //public void addSelectedAudio(String value, String fileName) { } - public String getAudioDeviceName() - { - return audio_device_name; - } - public String getUncPath() - { - return unc_path; - } - - public int getLoudValue() - { - return loud_percent; - } - - public String getWorkingDir() - { - return working_dir; - } - - Uri ISettings.getAddress() - { - return address; - } - - string ISettings.getUserName() - { - return userName; - } - - string ISettings.getPassword() - { - return password; - } - - int ISettings.getTimeout() - { - return timeout; - } - - public void addSelectedAudio(string value, string fileName) - { - try - { - string json = File.ReadAllText(fileName); - dynamic jsonObj = JsonConvert.DeserializeObject(json); - jsonObj["audio_device_name"] = value; - string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented); - File.Delete(fileName); - File.WriteAllText(fileName, output); - } - catch (Exception e) { } - } - } -} diff --git a/client/AudioRecorder/MainForm.Designer.cs b/client/AudioRecorder/MainForm.Designer.cs index 20994f0b..f87baebf 100644 --- a/client/AudioRecorder/MainForm.Designer.cs +++ b/client/AudioRecorder/MainForm.Designer.cs @@ -29,49 +29,48 @@ namespace AudioRecorder { this.recordButton = new System.Windows.Forms.Button(); this.stopButton = new System.Windows.Forms.Button(); this.timecodeLabel = new System.Windows.Forms.Label(); - this.selectAudioButton = new System.Windows.Forms.Button(); + this.btnSelectAudio = new System.Windows.Forms.Button(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.groupBox4 = new System.Windows.Forms.GroupBox(); this.pauseButton = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.verticalProgressBar1 = new AudioRecorder.VerticalProgressBar(); - this.customTrackBar1 = new AudioRecorder.CustomTrackBar(); + this.pmVolume = new Ernzo.WinForms.Controls.PeakMeterCtrl(); this.fileNameLabel = new System.Windows.Forms.Label(); this.playButton = new System.Windows.Forms.Button(); this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.tbVolume = new System.Windows.Forms.TrackBar(); this.groupBox1.SuspendLayout(); - this.groupBox4.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tbVolume)).BeginInit(); this.SuspendLayout(); // // recordButton // + this.recordButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.recordButton.BackColor = System.Drawing.Color.White; this.recordButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.recordButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.recordButton.Image = ((System.Drawing.Image)(resources.GetObject("recordButton.Image"))); - this.recordButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; - this.recordButton.Location = new System.Drawing.Point(15, 14); + this.recordButton.Location = new System.Drawing.Point(51, 85); this.recordButton.Name = "recordButton"; - this.recordButton.Size = new System.Drawing.Size(181, 56); + this.recordButton.Size = new System.Drawing.Size(129, 56); this.recordButton.TabIndex = 0; this.recordButton.Text = "Record"; this.recordButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.recordButton.UseVisualStyleBackColor = false; - this.recordButton.Click += new System.EventHandler(this.record_Click); + this.recordButton.Click += new System.EventHandler(this.OnRecordClick); // // stopButton // + this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.stopButton.BackColor = System.Drawing.Color.White; this.stopButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.stopButton.Enabled = false; this.stopButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.stopButton.Image = ((System.Drawing.Image)(resources.GetObject("stopButton.Image"))); - this.stopButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; - this.stopButton.Location = new System.Drawing.Point(15, 115); + this.stopButton.Location = new System.Drawing.Point(51, 186); this.stopButton.Name = "stopButton"; - this.stopButton.Size = new System.Drawing.Size(181, 38); + this.stopButton.Size = new System.Drawing.Size(129, 38); this.stopButton.TabIndex = 1; this.stopButton.Text = "Stop "; this.stopButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; @@ -80,57 +79,49 @@ namespace AudioRecorder { // // timecodeLabel // - this.timecodeLabel.AutoSize = true; + this.timecodeLabel.Dock = System.Windows.Forms.DockStyle.Top; this.timecodeLabel.Font = new System.Drawing.Font("Calibri", 28F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.timecodeLabel.Location = new System.Drawing.Point(9, 15); + this.timecodeLabel.Location = new System.Drawing.Point(3, 16); this.timecodeLabel.Name = "timecodeLabel"; - this.timecodeLabel.Size = new System.Drawing.Size(202, 46); + this.timecodeLabel.Size = new System.Drawing.Size(241, 46); this.timecodeLabel.TabIndex = 2; this.timecodeLabel.Text = "00:00:00:00"; + this.timecodeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // selectAudioButton + // btnSelectAudio // - this.selectAudioButton.BackColor = System.Drawing.Color.White; - this.selectAudioButton.Location = new System.Drawing.Point(8, 19); - this.selectAudioButton.Name = "selectAudioButton"; - this.selectAudioButton.Size = new System.Drawing.Size(307, 23); - this.selectAudioButton.TabIndex = 3; - this.selectAudioButton.Text = "Select audio"; - this.selectAudioButton.UseVisualStyleBackColor = false; - this.selectAudioButton.Click += new System.EventHandler(this.selectAudioButton_Click); + this.btnSelectAudio.BackColor = System.Drawing.Color.White; + this.btnSelectAudio.Location = new System.Drawing.Point(8, 19); + this.btnSelectAudio.Name = "btnSelectAudio"; + this.btnSelectAudio.Size = new System.Drawing.Size(307, 23); + this.btnSelectAudio.TabIndex = 3; + this.btnSelectAudio.Text = "Select audio"; + this.btnSelectAudio.UseVisualStyleBackColor = false; + this.btnSelectAudio.Click += new System.EventHandler(this.selectAudioButton_Click); // // groupBox1 // - this.groupBox1.Controls.Add(this.groupBox4); + this.groupBox1.Controls.Add(this.pauseButton); + this.groupBox1.Controls.Add(this.recordButton); + this.groupBox1.Controls.Add(this.stopButton); this.groupBox1.Controls.Add(this.timecodeLabel); this.groupBox1.Location = new System.Drawing.Point(15, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(228, 240); + this.groupBox1.Size = new System.Drawing.Size(247, 240); this.groupBox1.TabIndex = 5; this.groupBox1.TabStop = false; // - // groupBox4 - // - this.groupBox4.Controls.Add(this.pauseButton); - this.groupBox4.Controls.Add(this.recordButton); - this.groupBox4.Controls.Add(this.stopButton); - this.groupBox4.Location = new System.Drawing.Point(8, 62); - this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(214, 163); - this.groupBox4.TabIndex = 11; - this.groupBox4.TabStop = false; - // // pauseButton // + this.pauseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.pauseButton.BackColor = System.Drawing.Color.White; this.pauseButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.pauseButton.Enabled = false; this.pauseButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold); this.pauseButton.Image = ((System.Drawing.Image)(resources.GetObject("pauseButton.Image"))); - this.pauseButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; - this.pauseButton.Location = new System.Drawing.Point(15, 77); + this.pauseButton.Location = new System.Drawing.Point(51, 148); this.pauseButton.Name = "pauseButton"; - this.pauseButton.Size = new System.Drawing.Size(181, 32); + this.pauseButton.Size = new System.Drawing.Size(129, 32); this.pauseButton.TabIndex = 3; this.pauseButton.Text = "Pause "; this.pauseButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; @@ -139,31 +130,31 @@ namespace AudioRecorder { // // groupBox2 // - this.groupBox2.Controls.Add(this.verticalProgressBar1); - this.groupBox2.Controls.Add(this.customTrackBar1); - this.groupBox2.Location = new System.Drawing.Point(262, 12); + this.groupBox2.Controls.Add(this.tbVolume); + this.groupBox2.Controls.Add(this.pmVolume); + this.groupBox2.Location = new System.Drawing.Point(272, 12); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(85, 240); + this.groupBox2.Size = new System.Drawing.Size(75, 240); this.groupBox2.TabIndex = 6; this.groupBox2.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.Step = 1; - this.verticalProgressBar1.TabIndex = 12; - // - // customTrackBar1 - // - this.customTrackBar1.Location = new System.Drawing.Point(39, 15); - this.customTrackBar1.MainForm = null; - this.customTrackBar1.Name = "customTrackBar1"; - this.customTrackBar1.Size = new System.Drawing.Size(40, 213); - this.customTrackBar1.TabIndex = 11; + // pmVolume + // + this.pmVolume.BandsCount = 1; + this.pmVolume.ColorHigh = System.Drawing.Color.Red; + this.pmVolume.ColorHighBack = System.Drawing.Color.White; + this.pmVolume.ColorMedium = System.Drawing.Color.Yellow; + this.pmVolume.ColorMediumBack = System.Drawing.Color.White; + this.pmVolume.ColorNormal = System.Drawing.Color.Green; + this.pmVolume.ColorNormalBack = System.Drawing.Color.White; + this.pmVolume.FalloffColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180))))); + this.pmVolume.GridColor = System.Drawing.Color.Gainsboro; + this.pmVolume.LEDCount = 17; + this.pmVolume.Location = new System.Drawing.Point(6, 19); + this.pmVolume.Name = "pmVolume"; + this.pmVolume.Size = new System.Drawing.Size(15, 207); + this.pmVolume.TabIndex = 12; + this.pmVolume.Text = "pmVolume"; // // fileNameLabel // @@ -186,11 +177,11 @@ namespace AudioRecorder { this.playButton.Text = "Play"; this.playButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.playButton.UseVisualStyleBackColor = false; - this.playButton.Click += new System.EventHandler(this.playButton_Click); + this.playButton.Click += new System.EventHandler(this.OnPlayClick); // // groupBox3 // - this.groupBox3.Controls.Add(this.selectAudioButton); + this.groupBox3.Controls.Add(this.btnSelectAudio); this.groupBox3.Controls.Add(this.playButton); this.groupBox3.Controls.Add(this.fileNameLabel); this.groupBox3.Location = new System.Drawing.Point(15, 258); @@ -199,6 +190,20 @@ namespace AudioRecorder { this.groupBox3.TabIndex = 10; this.groupBox3.TabStop = false; // + // tbVolume + // + this.tbVolume.LargeChange = 10; + this.tbVolume.Location = new System.Drawing.Point(27, 16); + this.tbVolume.Maximum = 100; + this.tbVolume.Name = "tbVolume"; + this.tbVolume.Orientation = System.Windows.Forms.Orientation.Vertical; + this.tbVolume.Size = new System.Drawing.Size(45, 220); + this.tbVolume.SmallChange = 2; + this.tbVolume.TabIndex = 13; + this.tbVolume.TickFrequency = 10; + this.tbVolume.TickStyle = System.Windows.Forms.TickStyle.Both; + this.tbVolume.ValueChanged += new System.EventHandler(this.OnVolumeChanged); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -216,12 +221,12 @@ namespace AudioRecorder { this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "AudioRecorder"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); - this.Load += new System.EventHandler(this.Form1_Load); + this.Shown += new System.EventHandler(this.OnMainShown); this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.groupBox4.ResumeLayout(false); this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); this.groupBox3.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.tbVolume)).EndInit(); this.ResumeLayout(false); } @@ -231,16 +236,15 @@ namespace AudioRecorder { private System.Windows.Forms.Button recordButton; private System.Windows.Forms.Button stopButton; private System.Windows.Forms.Label timecodeLabel; - private System.Windows.Forms.Button selectAudioButton; + private System.Windows.Forms.Button btnSelectAudio; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.Label fileNameLabel; private System.Windows.Forms.Button playButton; private System.Windows.Forms.Button pauseButton; private System.Windows.Forms.GroupBox groupBox3; - private System.Windows.Forms.GroupBox groupBox4; - private CustomTrackBar customTrackBar1; - private VerticalProgressBar verticalProgressBar1; + private Ernzo.WinForms.Controls.PeakMeterCtrl pmVolume; + private System.Windows.Forms.TrackBar tbVolume; } } diff --git a/client/AudioRecorder/MainForm.cs b/client/AudioRecorder/MainForm.cs index 76ae5b82..ad857351 100644 --- a/client/AudioRecorder/MainForm.cs +++ b/client/AudioRecorder/MainForm.cs @@ -5,164 +5,204 @@ using System.Drawing; using NAudio.CoreAudioApi; using System.Windows.Forms; using System.IO; +using MaestroShared.Configuration; +using System.ComponentModel; namespace AudioRecorder { public delegate void RefreshPanelDelegate(); - public partial class MainForm : Form, IMainForm { + public partial class MainForm : Form { - //private const String CONFIG_FILE = "Resources/configuration.json"; private const String CONFIG_FILE = "Configuration/audiorecorder.json"; - private IRecorder recorder; - private ISettings settings; + private IAudioDevicesDetector devicesDetector; + private List audioDevicesNames; + private int selectedDeviceIndex = -1; + private WavRecorder recorder; + private AudioRecorderSettings parameters; private ITimeCodeWorker timeCodeWorker; - private IAudioDeviceSelectorForm selectorForm; private IFileWorker fileWorker; - private String selectedAudioName; private String currentFileName; private String currentFilePath; private bool recording; - private System.Windows.Forms.Timer countDownTimer; + private Timer countDownTimer; private int countDown = 3; private MMDevice currentDevice; private bool pausing; - private float volumeHeight; - private RefreshPanelDelegate refreshPanel; + private BackgroundWorker volumeMonitor; public MainForm() { InitializeComponent(); InitializeControlTexts(); - customTrackBar1.MainForm = this; + } + + public int SelectedDeviceIndex { + get => selectedDeviceIndex; + set { + selectedDeviceIndex = value; + if (selectedDeviceIndex > -1) + CurrentDevice = devicesDetector.getDevices()[SelectedDeviceIndex]; + else + CurrentDevice = null; + } + } + + public MMDevice CurrentDevice { + get => currentDevice; + set { + if (currentDevice == value) + return; + Cleanup(); + currentDevice = value; + if (currentDevice != null) + Initialize(); + UpdateGUI(); + } + } + + private void Cleanup() { + if (CurrentDevice != null) + CurrentDevice.AudioEndpointVolume.OnVolumeNotification -= AudioEndpointVolume_OnVolumeNotification; + if (recorder != null) + recorder = null; + } + + private void OnMainShown(object sender, EventArgs e) { + try { - settings = JsonSettings.GetInstance(CONFIG_FILE); + parameters = Loader.Get(CONFIG_FILE); + UpdateGUI(); + fileWorker = new FileWorker(); - countDownTimer = new System.Windows.Forms.Timer(); + timeCodeWorker = new TimeCodeWorker(timecodeLabel); + countDownTimer = new Timer(); countDownTimer.Interval = 1000; countDownTimer.Tick += new EventHandler(timer_Tick); - selectorForm = new AudioDeviceSelectorForm(this); - if (selectorForm.isDeviceConnected()) - saveAudioDeviceToConfig(); - timeCodeWorker = new TimeCodeWorker(timecodeLabel); - //CreatenewThreadToListenMasterPeekVolume(); - + devicesDetector = new AudioDevicesDetector(); + devicesDetector.findDevices(); + audioDevicesNames = devicesDetector.getDeviceNames(); + if (!String.IsNullOrEmpty(parameters.audio_device_name) && audioDevicesNames != null) + SelectedDeviceIndex = audioDevicesNames.IndexOf(parameters.audio_device_name); + if (SelectedDeviceIndex < 0) + ShowAudioDeviceSelectorForm(); } - catch (Exception e) { - MessageBox.Show(e.Message, StringResources.ERROR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); + catch (Exception ex) { + MessageBox.Show(ex.Message, StringResources.ERROR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); } } - //private void CreatenewThreadToListenMasterPeekVolume() { - // new Thread(() => { - // while (true) { - // try { - // int panelHeight = (int)Math.Round(currentDevice.AudioMeterInformation.MasterPeakValue * 100); - // Debug.WriteLine(String.Format("panelHeight {0}", panelHeight)); - // // int panelHeight = (int)Math.Floor(currentDevice.AudioMeterInformation.MasterPeakValue * 79); - // setPanelSizeHeight(panelHeight); - // Thread.Sleep(1); - // } - // catch (Exception e) { - // Console.WriteLine(e.Message); - // } - // } - // }).Start(); - //} + private void OnMonitorVolume(object sender, DoWorkEventArgs e) { + while (!e.Cancel) { + try { + float value = currentDevice.AudioMeterInformation.MasterPeakValue * 1000; + int[] levels = { (int) Math.Floor(value) }; + Debug.WriteLine(String.Format($"Values {levels[0]}")); + pmVolume.SetData(levels, 0, 1); + System.Threading.Thread.Sleep(100); + } catch (Exception ex) { + Debug.WriteLine(ex.Message); + } + } + } + + private void UpdateGUI() { + if (CurrentDevice == null) { + int steps = parameters.loud_percent; + pmVolume.SetRange(steps * 3, steps * 4, steps * 5); + pmVolume.SetData(new int[] { 0 }, 0, 1); + recordButton.Enabled = false; + recordButton.BackColor = SystemColors.Control; + if (volumeMonitor != null) + volumeMonitor.CancelAsync(); + } else { + tbVolume.Minimum = (int)Math.Floor(CurrentDevice.AudioEndpointVolume.VolumeRange.MinDecibels); + tbVolume.Maximum = (int)Math.Floor(CurrentDevice.AudioEndpointVolume.VolumeRange.MaxDecibels); + tbVolume.Value = (int)Math.Round(CurrentDevice.AudioEndpointVolume.MasterVolumeLevel); + Debug.WriteLine($"Levels {CurrentDevice.AudioEndpointVolume.VolumeRange.MinDecibels} {CurrentDevice.AudioEndpointVolume.VolumeRange.MaxDecibels} V {CurrentDevice.AudioEndpointVolume.MasterVolumeLevel}"); + recordButton.Enabled = true; + recordButton.BackColor = Color.Lime; + btnSelectAudio.Text = parameters.audio_device_name; + volumeMonitor = new BackgroundWorker(); + volumeMonitor.WorkerSupportsCancellation = true; + volumeMonitor.DoWork += OnMonitorVolume; + volumeMonitor.RunWorkerAsync(); + } + } private void InitializeControlTexts() { recordButton.Text = Resources.FELVETEL; stopButton.Text = Resources.LEALLITAS; pauseButton.Text = Resources.SZUNET; - selectAudioButton.Text = Resources.VALASSZON_MIKROFONT; + btnSelectAudio.Text = Resources.VALASSZON_MIKROFONT; playButton.Text = Resources.LEJATSZAS; } - private void setVolumeTrackerEdgesAndValue() { - if (currentDevice != null) { - customTrackBar1.setMinimumMaximumSizesAndVolume((int)currentDevice.AudioEndpointVolume.VolumeRange.MinDecibels, - (int)currentDevice.AudioEndpointVolume.VolumeRange.MaxDecibels, - (int)currentDevice.AudioEndpointVolume.MasterVolumeLevel); - } - } - - private void saveAudioDeviceToConfig() { - if (String.IsNullOrEmpty(settings.getAudioDeviceName())) - recordButton.Enabled = false; - else { - List devices = selectorForm.getDeviceNames(); - int indexOfDeviceName = devices.IndexOf(settings.getAudioDeviceName()); - if (indexOfDeviceName == -1) - showAudioDeviceSelectorForm(); - else - initWavRecorder(indexOfDeviceName, settings.getAudioDeviceName()); - } - } - - public void initWavRecorder(int index, String selectedAudioName) { - int inputDeviceIndex = index; - this.selectedAudioName = selectedAudioName; - currentDevice = selectorForm.getDevices()[index]; + public void Initialize() { currentDevice.AudioEndpointVolume.OnVolumeNotification += AudioEndpointVolume_OnVolumeNotification; - recorder = new WavRecorder(inputDeviceIndex, currentDevice, this); - recordButton.Enabled = true; - recordButton.BackColor = Color.Lime; - selectAudioButton.Text = selectedAudioName; - settings.addSelectedAudio(selectedAudioName, CONFIG_FILE); - setVolumeTrackerEdgesAndValue(); - customTrackBar1.setTickLabelLocationByPercentage(settings.getLoudValue()); + recorder = new WavRecorder(SelectedDeviceIndex, CurrentDevice, this); } void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { - customTrackBar1.SetValue((int)currentDevice.AudioEndpointVolume.MasterVolumeLevel); + //customTrackBar1.SetValue((int)CurrentDevice.AudioEndpointVolume.MasterVolumeLevel); } - public void setPanelSizeHeight(float height) { - volumeHeight = height; - if (verticalProgressBar1.InvokeRequired) { - refreshPanel = RefreshVolumePanel; - this.Invoke(refreshPanel); - } else - RefreshVolumePanel(); - } - private void RefreshVolumePanel() { - try { - if (recording) { - if (volumeHeight >= settings.getLoudValue()) - //SendMessage(verticalProgressBar1.Handle, 1040, 2, 0); - verticalProgressBar1.ForeColor = Color.Red; - else - // SendMessage(verticalProgressBar1.Handle, 1040, 1, 0); - verticalProgressBar1.ForeColor = Color.Green; - verticalProgressBar1.Value = (int)volumeHeight; - } - } catch (Exception e) { - Console.WriteLine(e.Message); - } - } - - private void Form1_Load(object sender, EventArgs e) { + //private void RefreshVolumePanel() { + // try { + // if (recording) { + // if (volumeHeight >= parameters.loud_percent) + // //SendMessage(verticalProgressBar1.Handle, 1040, 2, 0); + // verticalProgressBar1.ForeColor = Color.Red; + // else + // // SendMessage(verticalProgressBar1.Handle, 1040, 1, 0); + // verticalProgressBar1.ForeColor = Color.Green; + // verticalProgressBar1.Value = (int)volumeHeight; + // } + // } catch (Exception e) { + // Console.WriteLine(e.Message); + // } + //} - } private void stop_Click(object sender, EventArgs e) { stopRecording(); } + + private void startRecord() { + try { + recording = true; + currentFilePath = Path.Combine(parameters.working_dir, "1.wav"); + recorder.StartRecording(currentFilePath); + timeCodeWorker.Start(); + pauseButton.Enabled = true; + recordButton.Enabled = false; + stopButton.Enabled = true; + btnSelectAudio.Enabled = false; + playButton.Enabled = false; + stopButton.BackColor = Color.Red; + recordButton.BackColor = Color.White; + } + catch (Exception e) { + MessageBox.Show(e.Message, StringResources.ERROR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void stopRecording() { try { recording = false; recordButton.Enabled = true; stopButton.Enabled = false; - selectAudioButton.Enabled = true; + btnSelectAudio.Enabled = true; pauseButton.Enabled = false; - verticalProgressBar1.Value = 0; + recorder.StopRecording(); timeCodeWorker.Stop(); playButton.Enabled = true; stopButton.BackColor = Color.White; recordButton.BackColor = Color.Lime; - copyFileToUncPath(); + //copyFileToUncPath(); } catch (Exception e) { MessageBox.Show(e.Message, StringResources.ERROR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -172,7 +212,7 @@ namespace AudioRecorder { private void copyFileToUncPath() { FileInfo fileInfo = new FileInfo(recorder.getCurentWavFilePath()); String wavFileName = fileInfo.Name; - String wavUncPath = DetermineWorkingDirectory(settings.getUncPath(), fileInfo.Name); + String wavUncPath = DetermineWorkingDirectory(parameters.unc_path, fileInfo.Name); if (!Directory.Exists(wavUncPath)) Directory.CreateDirectory(wavUncPath); wavUncPath = Path.Combine(wavUncPath, fileInfo.Name); @@ -191,32 +231,16 @@ namespace AudioRecorder { return result; } - private void record_Click(object sender, EventArgs e) { - FileNameForm nameForm = new FileNameForm(this, settings); - nameForm.ShowDialog(); - } + private void OnRecordClick(object sender, EventArgs e) { + //FileNameForm nameForm = new FileNameForm(this, parameters); + //nameForm.ShowDialog(); - private void startRecord() { - try { - recording = true; - recorder.StartRecording(currentFilePath); - timeCodeWorker.Start(); - pauseButton.Enabled = true; - recordButton.Enabled = false; - stopButton.Enabled = true; - selectAudioButton.Enabled = false; - playButton.Enabled = false; - stopButton.BackColor = Color.Red; - recordButton.BackColor = Color.White; - } - catch (Exception e) { - MessageBox.Show(e.Message, StringResources.ERROR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); - } + startRecord(); } public void recordFireEvent(String currentFileName, string id) { recordButton.Enabled = false; - String path = String.Format("{0}\\{1}", settings.getWorkingDir(), id); + String path = String.Format("{0}\\{1}", parameters.working_dir, id); if (!Directory.Exists(path)) Directory.CreateDirectory(path); SetCurrentFileNameAndPath(currentFileName, path); @@ -251,49 +275,42 @@ namespace AudioRecorder { private void setToolTipToFileNameLabel(String filePath) { ToolTip toolTip = new ToolTip(); - String uncPath = String.Format("{0}{1}{2}", settings.getUncPath(), Path.DirectorySeparatorChar, currentFileName); + String uncPath = String.Format("{0}{1}{2}", parameters.unc_path, Path.DirectorySeparatorChar, currentFileName); String tip = String.Format("{0}\n{1}", filePath, uncPath); toolTip.SetToolTip(fileNameLabel, tip); } private void selectAudioButton_Click(object sender, EventArgs e) { - showAudioDeviceSelectorForm(); + ShowAudioDeviceSelectorForm(true); } - private void showAudioDeviceSelectorForm() { - selectorForm = new AudioDeviceSelectorForm(this); - if (!selectorForm.isDisposed()) - selectorForm.ShowDialog(); + private void ShowAudioDeviceSelectorForm(bool refreshDevices = false) { + if (refreshDevices) { + devicesDetector = new AudioDevicesDetector(); + devicesDetector.findDevices(); + audioDevicesNames = devicesDetector.getDeviceNames(); + } + AudioDeviceSelectorForm deviceSelectorForm = new AudioDeviceSelectorForm(); + SelectedDeviceIndex = deviceSelectorForm.Open(audioDevicesNames, SelectedDeviceIndex, ref parameters); + if (SelectedDeviceIndex > -1) + parameters.Save(CONFIG_FILE); } private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { - if (recording) { - DialogResult result = MessageBox.Show(StringResources.ARE_YOU_SURE_TO_QUIT_DURING_RECORDING, - StringResources.EXIT_TITLE, MessageBoxButtons.YesNo); - if (result == DialogResult.Yes) { - stopRecording(); - deleteTemporariFiles(); - } else - e.Cancel = true; - } else { - if (String.IsNullOrEmpty(settings.getAudioDeviceName())) - settings.addSelectedAudio(selectedAudioName, CONFIG_FILE); + if (recording) + e.Cancel = true; + else deleteTemporariFiles(); - } } private void deleteTemporariFiles() { - if (recorder != null) { - List createdFiles = recorder.getCreatedFiles(); - fileWorker.deleteFiles(createdFiles); - } + //if (recorder != null) { + // List createdFiles = recorder.getCreatedFiles(); + // fileWorker.deleteFiles(createdFiles); + //} } - public void disableRecordButton() { - recordButton.Enabled = false; - } - - private void playButton_Click(object sender, EventArgs e) { + private void OnPlayClick(object sender, EventArgs e) { Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = new FileInfo(currentFilePath).FullName; @@ -305,10 +322,10 @@ namespace AudioRecorder { TrackBar trackbar = sender as TrackBar; if (trackbar == null) return; - if (currentDevice == null) + if (CurrentDevice == null) return; int value = trackbar.Value; - currentDevice.AudioEndpointVolume.MasterVolumeLevel = value; + CurrentDevice.AudioEndpointVolume.MasterVolumeLevel = value; } private void pauseButton_Click(object sender, EventArgs e) { @@ -321,10 +338,15 @@ namespace AudioRecorder { TrackBar trackbar = sender as TrackBar; if (trackbar == null) return; - if (currentDevice == null) + if (CurrentDevice == null) return; int value = trackbar.Value; - currentDevice.AudioEndpointVolume.MasterVolumeLevel = value; + CurrentDevice.AudioEndpointVolume.MasterVolumeLevel = value; + } + + private void OnVolumeChanged(object sender, EventArgs e) { + CurrentDevice.AudioEndpointVolume.MasterVolumeLevel = tbVolume.Value; + Debug.WriteLine($"Levels {CurrentDevice.AudioEndpointVolume.VolumeRange.MinDecibels} {CurrentDevice.AudioEndpointVolume.VolumeRange.MaxDecibels} V {CurrentDevice.AudioEndpointVolume.MasterVolumeLevel}"); } } } diff --git a/client/AudioRecorder/PeakMeterCtrl.Designer.cs b/client/AudioRecorder/PeakMeterCtrl.Designer.cs new file mode 100644 index 00000000..47d8b597 --- /dev/null +++ b/client/AudioRecorder/PeakMeterCtrl.Designer.cs @@ -0,0 +1,39 @@ +using System; +namespace Ernzo.WinForms.Controls +{ + partial class PeakMeterCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + StopAnimation(); + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + + } +} diff --git a/client/AudioRecorder/PeakMeterCtrl.cs b/client/AudioRecorder/PeakMeterCtrl.cs new file mode 100644 index 00000000..43d0569e --- /dev/null +++ b/client/AudioRecorder/PeakMeterCtrl.cs @@ -0,0 +1,767 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2008 Ernest Laurentin (elaurentin@netzero.net) +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +/////////////////////////////////////////////////////////////////////////////// +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; +using System.Threading; + +namespace Ernzo.WinForms.Controls +{ + public enum PeakMeterStyle + { + PMS_Horizontal = 0, + PMS_Vertical = 1 + } + + internal struct PeakMeterData + { + public int Value; + public int Falloff; + public int Speed; + } + + [ToolboxBitmap(typeof(MyResourceNamespace), "PeakMeterCtrl.pmicon.bmp")] + public partial class PeakMeterCtrl : Control + { + private const byte DarkenByDefault = 40; + private const byte LightenByDefault = 150; + private const int MinRangeDefault = 60; + private const int MedRangeDefault = 80; + private const int MaxRangeDefault = 100; + private const int FalloffFast = 1; + private const int FalloffNormal = 10; + private const int FalloffSlow = 100; + private const int FalloffDefault = 10; + private const int DecrementPercent = 10; + private const int BandsMin = 1; + private const int BandsMax = 1000; + private const int BandsDefault = 8; + private const int LEDMin = 1; + private const int LEDMax = 1000; + private const int LEDDefault = 8; + private const int cxyMargin = 1; + + private int _AnimDelay; + private int _MinRangeValue; + private int _MedRangeValue; + private int _MaxRangeValue; + private PeakMeterData[] _meterData; + private System.Threading.Timer _animationTimer; + public PeakMeterCtrl() + { + InitializeComponent(); + InitDefault(); + this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); + this.SetStyle(ControlStyles.UserPaint, true); + //this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); + } + + private void InitDefault() + { + _AnimDelay = Timeout.Infinite; + _MinRangeValue = MinRangeDefault; // [0,60[ + _MedRangeValue = MedRangeDefault; // [60,80[ + _MaxRangeValue = MaxRangeDefault; // [80,100[ + _meterData = null; + _animationTimer = null; + _ShowGrid = true; + _ColoredGrid = false; + _GridColor = Color.Gainsboro; + _ColorNormal = Color.Green; + _ColorMedium = Color.Yellow; + _ColorHigh = Color.Red; + _ColorNormalBack = LightenColor(_ColorNormal, LightenByDefault); + _ColorMediumBack = LightenColor(_ColorMedium, LightenByDefault); + _ColorHighBack = LightenColor(_ColorHigh, LightenByDefault); + _BandsCount = BandsDefault; + _LEDCount = LEDDefault; + _FalloffSpeed = FalloffNormal; + _FalloffEffect = true; + _FalloffColor = DarkenColor(_GridColor, DarkenByDefault); + ResetControl(); + } + + #region Control properties + private PeakMeterStyle _PmsMeterStyle; + [Category("Appearance"), DefaultValue(PeakMeterStyle.PMS_Horizontal)] + public PeakMeterStyle MeterStyle + { + get { return _PmsMeterStyle; } + set { _PmsMeterStyle = value; Refresh(); } + } + + private bool _ShowGrid; + [Category("Appearance"), DefaultValue(true)] + public bool ShowGrid + { + get { return _ShowGrid; } + set { _ShowGrid = value; Refresh(); } + } + + private bool _ColoredGrid; + [Category("Appearance"), DefaultValue(false)] + public bool ColoredGrid + { + get { return _ColoredGrid; } + set { _ColoredGrid = value; Refresh(); } + } + + private Color _GridColor; + [Category("Appearance")] + public Color GridColor + { + get { return _GridColor; } + set { _GridColor = value; Refresh(); } + } + + private Color _ColorNormal; + [Category("Appearance")] + public Color ColorNormal + { + get { return _ColorNormal; } + set { _ColorNormal = value; Refresh(); } + } + + private Color _ColorMedium; + [Category("Appearance")] + public Color ColorMedium + { + get { return _ColorMedium; } + set { _ColorMedium = value; Refresh(); } + } + + private Color _ColorHigh; + [Category("Appearance")] + public Color ColorHigh + { + get { return _ColorHigh; } + set { _ColorHigh = value; Refresh(); } + } + + private Color _ColorNormalBack; + [Category("Appearance")] + public Color ColorNormalBack + { + get { return _ColorNormalBack; } + set { _ColorNormalBack = value; Refresh(); } + } + + private Color _ColorMediumBack; + [Category("Appearance")] + public Color ColorMediumBack + { + get { return _ColorMediumBack; } + set { _ColorMediumBack = value; Refresh(); } + } + + private Color _ColorHighBack; + [Category("Appearance")] + public Color ColorHighBack + { + get { return _ColorHighBack; } + set { _ColorHighBack = value; Refresh(); } + } + + private int _BandsCount; + [Category("Appearance"), DefaultValue(BandsDefault)] + public int BandsCount + { + get { return _BandsCount; } + set { + if (value >= BandsMin && value <= BandsMax) + { + _BandsCount = value; + ResetControl(); + Refresh(); + } + } + } + + private int _LEDCount; + [Category("Appearance"), DefaultValue(LEDDefault)] + public int LEDCount + { + get { return _LEDCount; } + set { + if (value >= LEDMin && value <= LEDMax) + { + _LEDCount = value; + Refresh(); + } + } + } + + private int _FalloffSpeed; + [Category("Falloff Effect"), DefaultValue(FalloffDefault)] + public int FalloffSpeed + { + get { return _FalloffSpeed; } + set { _FalloffSpeed = value; } + } + + private bool _FalloffEffect; + [Category("Falloff Effect"), DefaultValue(true)] + public bool FalloffEffect + { + get { return _FalloffEffect; } + set { _FalloffEffect = value; } + } + + private Color _FalloffColor; + [Category("Falloff Effect")] + public Color FalloffColor + { + get { return _FalloffColor; } + set { _FalloffColor = value; } + } + + #endregion + + [Browsable(false)] + public bool IsActive + { + get { return (_animationTimer != null); } + } + + #region Control Methods + + // support for thread-safe version + private delegate bool StartDelegate(int delay); + /// + /// Start animation + /// + /// + /// + public bool Start(int delay) + { + if (this.InvokeRequired) + { + StartDelegate startDelegate = new StartDelegate(this.Start); + return (bool)this.Invoke(startDelegate, delay); + } + _AnimDelay = delay; + return StartAnimation(delay); + } + + // support for thread-safe version + private delegate bool StopDelegate(); + /// + /// Stop Animation + /// + /// + public bool Stop() + { + if (this.InvokeRequired) + { + StopDelegate stopDelegate = new StopDelegate(this.Stop); + return (bool)this.Invoke(stopDelegate); + } + _AnimDelay = Timeout.Infinite; + return StopAnimation(); + } + + /// + /// Set number of LED bands + /// + /// Number of bands + /// Number of LED per bands + public void SetMeterBands(int BandsCount, int LEDCount) + { + if (BandsCount < BandsMin || BandsCount > BandsMax) + throw new ArgumentOutOfRangeException("BandsCount"); + if (LEDCount < LEDMin || LEDCount > LEDMax) + throw new ArgumentOutOfRangeException("LEDCount"); + _BandsCount = BandsCount; + _LEDCount = LEDCount; + ResetControl(); + Refresh(); + } + + /// + /// Set range info + /// + /// Min Range + /// Medium Range + /// High Range + public void SetRange(int minRangeVal, int medRangeVal, int maxRangeVal) + { + if (maxRangeVal <= medRangeVal || medRangeVal < minRangeVal ) + throw new ArgumentOutOfRangeException("minRangeVal"); + _MinRangeValue = minRangeVal; + _MedRangeValue = medRangeVal; + _MaxRangeValue = maxRangeVal; + ResetControl(); + Refresh(); + } + + // support for thread-safe version + private delegate bool SetDataDelegate(int[] arrayValue, int offset, int size); + /// + /// Set meter band value + /// + /// Array value for the bands + /// Starting offset position + /// Number of values to set + /// + public bool SetData(int[] arrayValue, int offset, int size) + { + if (arrayValue == null) + throw new ArgumentNullException("arrayValue"); + if (arrayValue.Length < (offset + size)) + throw new ArgumentOutOfRangeException("arrayValue"); + + if (this.InvokeRequired) + { + SetDataDelegate setDelegate = new SetDataDelegate(this.SetData); + return (bool)this.Invoke(setDelegate, arrayValue, offset, size); + } + bool isRunning = this.IsActive; + + Monitor.Enter(this._meterData); + + int maxIndex = offset + size; + for (int i = offset; i < maxIndex; i++) + { + if (i < this._meterData.Length) + { + PeakMeterData pm = this._meterData[i]; + pm.Value = Math.Min(arrayValue[i], this._MaxRangeValue); + pm.Value = Math.Max(pm.Value, 0); + if (pm.Falloff < pm.Value) + { + pm.Falloff = pm.Value; + pm.Speed = this._FalloffSpeed; + } + this._meterData[i] = pm; + } + } + Monitor.Exit(this._meterData); + + // check that timer should be restarted + if (_AnimDelay != Timeout.Infinite) + { + if (_animationTimer == null) + { + StartAnimation(_AnimDelay); + } + } + else + { + Refresh(); + } + + return isRunning; + } + #endregion + + /// + /// Make a color darker + /// + /// Color to darken + /// Value to decrease by + protected virtual Color DarkenColor(Color color, byte darkenBy) + { + byte red = (byte)(color.R > darkenBy ? (color.R - darkenBy) : 0); + byte green = (byte)(color.G > darkenBy ? (color.G - darkenBy) : 0); + byte blue = (byte)(color.B > darkenBy ? (color.B - darkenBy) : 0); + return Color.FromArgb(red, green, blue); + } + /// + /// Make a color lighter + /// + /// + /// + /// + protected virtual Color LightenColor(Color color, byte lightenBy) + { + byte red = (byte)((color.R + lightenBy) <= 255 ? (color.R + lightenBy) : 255); + byte green = (byte)((color.G + lightenBy) <= 255 ? (color.G + lightenBy) : 255); + byte blue = (byte)((color.B + lightenBy) <= 255 ? (color.B + lightenBy) : 255); + return Color.FromArgb(red, green, blue); + } + + protected static bool InRange(int value, int rangeMin, int rangeMax) + { + return (value >= rangeMin && value <= rangeMax); + } + + protected void ResetControl() + { + _meterData = new PeakMeterData[_BandsCount]; + PeakMeterData pm; + pm.Value = _MaxRangeValue; + pm.Falloff = _MaxRangeValue; + pm.Speed = _FalloffSpeed; + for (int i = 0; i < _meterData.Length; i++) + { + _meterData[i] = pm; + } + } + protected bool StartAnimation(int period) + { + if ( !IsActive ) + { + TimerCallback timerDelegate = + new TimerCallback(TimerCallback); + _animationTimer = new System.Threading.Timer(timerDelegate, this, Timeout.Infinite, Timeout.Infinite); + } + return _animationTimer.Change(period, period); + } + protected bool StopAnimation() + { + bool result = false; + if ( IsActive ) + { + try + { + result = _animationTimer.Change(Timeout.Infinite, Timeout.Infinite); + _animationTimer.Dispose(); + _animationTimer = null; + result = true; + } + catch (Exception) + { + } + } + return result; + } + + protected override void OnHandleDestroyed(EventArgs e) + { + Stop(); + base.OnHandleDestroyed(e); + } + protected override void OnBackColorChanged(EventArgs e) + { + Refresh(); + } + protected override void OnPaint(PaintEventArgs e) + { + // Calling the base class OnPaint + base.OnPaint(e); + + Graphics g = e.Graphics; + Rectangle rect = new Rectangle(0, 0, this.Width, this.Height); + Brush backColorBrush = new SolidBrush(this.BackColor); + + g.FillRectangle(backColorBrush, rect); + //rect.Inflate(-this.Margin.Left, -this.Margin.Top); + if (MeterStyle == PeakMeterStyle.PMS_Horizontal) + { + DrawHorzBand(g, rect); + } + else + { + DrawVertBand(g, rect); + } + } + + protected void TimerCallback(Object thisObject) + { + try + { + // refresh now! + Control thisControl = thisObject as Control; + if (thisControl != null && thisControl.IsHandleCreated) + { + thisControl.Invoke(new MethodInvoker(Refresh)); + } + else + { + return; + } + } + catch (Exception) + { + // just ignore + } + + int nDecValue = _MaxRangeValue / _LEDCount; + bool noUpdate = true; + + Monitor.Enter(this._meterData); + for (int i = 0; i < _meterData.Length; i++) + { + PeakMeterData pm = _meterData[i]; + + if (pm.Value > 0) + { + pm.Value -= (_LEDCount > 1 ? nDecValue : (_MaxRangeValue * DecrementPercent) / 100); + if (pm.Value < 0) + pm.Value = 0; + noUpdate = false; + } + + if (pm.Speed > 0) + { + pm.Speed -= 1; + noUpdate = false; + } + + if (pm.Speed == 0 && pm.Falloff > 0) + { + pm.Falloff -= (_LEDCount > 1 ? nDecValue >> 1 : 5); + if (pm.Falloff < 0) + pm.Falloff = 0; + noUpdate = false; + } + + // re-assign PeakMeterData + _meterData[i] = pm; + } + Monitor.Exit(this._meterData); + + if (noUpdate) // Stop timer if no more data but do not reset ID + { + StopAnimation(); + } + } + protected void DrawHorzBand(Graphics g, Rectangle rect) + { + int nMaxRange = (_MedRangeValue == 0) ? Math.Abs(_MaxRangeValue - _MinRangeValue) : _MaxRangeValue; + int nVertBands = (_LEDCount > 1 ? _LEDCount : (nMaxRange * DecrementPercent) / 100); + int nMinVertLimit = _MinRangeValue * nVertBands / nMaxRange; + int nMedVertLimit = _MedRangeValue * nVertBands / nMaxRange; + int nMaxVertLimit = nVertBands; + + if (_MedRangeValue == 0) + { + nMedVertLimit = Math.Abs(_MinRangeValue) * nVertBands / nMaxRange; + nMinVertLimit = 0; + } + Size size = new Size(rect.Width/_BandsCount, rect.Height/nVertBands); + Rectangle rcBand = new Rectangle(rect.Location, size); + + // Draw band from bottom + rcBand.Offset(0, rect.Height-size.Height); + int xDecal = (_BandsCount>1 ? cxyMargin : 0); + //int yDecal = 0; + + Color gridPenColor = (this.ShowGrid ? GridColor : BackColor); + Pen gridPen = new Pen(gridPenColor); + Pen fallPen = new Pen( this.FalloffColor ); + + for(int nHorz=0; nHorz < _BandsCount; nHorz++) + { + int nValue = _meterData[nHorz].Value; + int nVertValue = nValue*nVertBands/nMaxRange; + Rectangle rcPrev = rcBand; + + for(int nVert=0; nVert < nVertBands; nVert++) + { + // Find color based on range value + Color colorBand = gridPenColor; + + // Draw grid line (level) bar + if ( this.ShowGrid && (nVert == nMinVertLimit || nVert == nMedVertLimit || nVert == (nVertBands-1))) + { + Point []points = new Point[2]; + points[0].X = rcBand.Left; + points[0].Y = rcBand.Top + (rcBand.Height>>1); + points[1].X = rcBand.Right; + points[1].Y = points[0].Y; + g.DrawPolygon(gridPen, points); + } + + if ( _MedRangeValue == 0 ) + { + int nVertStart = nMedVertLimit+nVertValue; + if ( InRange(nVert, nVertStart, nMedVertLimit-1) ) + colorBand = this.ColorNormal; + else if ( nVert >= nMedVertLimit && InRange(nVert, nMedVertLimit, nVertStart) ) + colorBand = this.ColorHigh; + else { + colorBand = (nVert < nMedVertLimit) ? this.ColorNormalBack : this.ColorHighBack; + } + } + else if ( nVertValue < nVert ) + { + if ( this.ShowGrid && this.ColoredGrid ) + { + if ( InRange(nVert, 0, nMinVertLimit) ) + colorBand = this.ColorNormalBack; + else if ( InRange(nVert, nMinVertLimit+1, nMedVertLimit) ) + colorBand = this.ColorMediumBack; + else if ( InRange(nVert, nMedVertLimit+1, nMaxVertLimit) ) + colorBand = this.ColorHighBack; + } + } else { + if (nValue == 0) + { + if (this.ShowGrid && this.ColoredGrid) + colorBand = this.ColorNormalBack; + } + else if ( InRange(nVert, 0, nMinVertLimit) ) + colorBand = this.ColorNormal; + else if ( InRange(nVert, nMinVertLimit+1, nMedVertLimit) ) + colorBand = this.ColorMedium; + else if ( InRange(nVert, nMedVertLimit+1, nMaxVertLimit) ) + colorBand = this.ColorHigh; + } + + if (colorBand != this.BackColor) + { + SolidBrush fillBrush = new SolidBrush(colorBand); + if (this._LEDCount > 1) + rcBand.Inflate(-cxyMargin, -cxyMargin); + g.FillRectangle(fillBrush, rcBand.Left, rcBand.Top, rcBand.Width+1, rcBand.Height); + if (this._LEDCount > 1) + rcBand.Inflate(cxyMargin, cxyMargin); + } + rcBand.Offset(0, -size.Height); + } + + // Draw falloff effect + if (this.FalloffEffect && this.IsActive) + { + int nMaxHeight = size.Height*nVertBands; + Point []points = new Point[2]; + points[0].X = rcPrev.Left + xDecal; + points[0].Y = rcPrev.Bottom - (_meterData[nHorz].Falloff * nMaxHeight) / _MaxRangeValue; + points[1].X = rcPrev.Right - xDecal; + points[1].Y = points[0].Y; + g.DrawPolygon(fallPen, points); + } + + // Move to Next Horizontal band + rcBand.Offset(size.Width, size.Height * nVertBands); + } + } + protected void DrawVertBand(Graphics g, Rectangle rect) + { + int nMaxRange = (_MedRangeValue == 0) ? Math.Abs(_MaxRangeValue - _MinRangeValue) : _MaxRangeValue; + int nHorzBands = (_LEDCount > 1 ? _LEDCount : (nMaxRange * DecrementPercent) / 100); + int nMinHorzLimit = _MinRangeValue*nHorzBands/nMaxRange; + int nMedHorzLimit = _MedRangeValue*nHorzBands/nMaxRange; + int nMaxHorzLimit = nHorzBands; + + if ( _MedRangeValue == 0 ) + { + nMedHorzLimit = Math.Abs(_MinRangeValue)*nHorzBands/nMaxRange; + nMinHorzLimit = 0; + } + + Size size = new Size(rect.Width/nHorzBands, rect.Height/_BandsCount); + Rectangle rcBand = new Rectangle(rect.Location, size); + + // Draw band from top + rcBand.Offset(0, rect.Height-size.Height*_BandsCount); + //int xDecal = 0; + int yDecal = (_BandsCount>1 ? cxyMargin : 0); + + Color gridPenColor = (this.ShowGrid ? GridColor : BackColor); + Pen gridPen = new Pen(gridPenColor); + Pen fallPen = new Pen( this.FalloffColor ); + + for(int nVert=0; nVert < _BandsCount; nVert++) + { + int nValue = _meterData[nVert].Value; + int nHorzValue = nValue*nHorzBands/nMaxRange; + Rectangle rcPrev = rcBand; + + for(int nHorz=0; nHorz < nHorzBands; nHorz++) + { + // Find color based on range value + Color colorBand = gridPenColor; + + if ( this.ShowGrid && (nHorz == nMinHorzLimit || nHorz == nMedHorzLimit || nHorz == (nHorzBands-1))) + { + Point []points = new Point[2]; + points[0].X = rcBand.Left + (rcBand.Width>>1); + points[0].Y = rcBand.Top; + points[1].X = points[0].X; + points[1].Y = rcBand.Bottom; + g.DrawPolygon(gridPen, points); + } + + if (_MedRangeValue == 0) + { + int nHorzStart = nMedHorzLimit+nHorzValue; + if ( InRange(nHorz, nHorzStart, nMedHorzLimit-1) ) + colorBand = this.ColorNormal; + else if ( nHorz >= nMedHorzLimit && InRange(nHorz, nMedHorzLimit, nHorzStart) ) + colorBand = this.ColorHigh; + else { + colorBand = (nHorz < nMedHorzLimit) ? this.ColorNormalBack : this.ColorHighBack; + } + } + else if ( nHorzValue < nHorz ) + { + if ( this.ShowGrid && this.ColoredGrid ) + { + if ( InRange(nHorz, 0, nMinHorzLimit) ) + colorBand = this.ColorNormalBack; + else if ( InRange(nHorz, nMinHorzLimit+1, nMedHorzLimit) ) + colorBand = this.ColorMediumBack; + else if ( InRange(nHorz, nMedHorzLimit+1, nMaxHorzLimit) ) + colorBand = this.ColorHighBack; + } + } else { + if (nValue == 0) + { + if (this.ShowGrid && this.ColoredGrid) + colorBand = this.ColorNormalBack; + } + else if (InRange(nHorz, 0, nMinHorzLimit)) + colorBand = this.ColorNormal; + else if ( InRange(nHorz, nMinHorzLimit+1, nMedHorzLimit) ) + colorBand = this.ColorMedium; + else if ( InRange(nHorz, nMedHorzLimit+1, nMaxHorzLimit) ) + colorBand = this.ColorHigh; + } + + if (colorBand != this.BackColor) + { + SolidBrush fillBrush = new SolidBrush(colorBand); + if (this._LEDCount > 1) + rcBand.Inflate(-cxyMargin, -cxyMargin); + g.FillRectangle(fillBrush, rcBand.Left, rcBand.Top, rcBand.Width, rcBand.Height+1); + if (this._LEDCount > 1) + rcBand.Inflate(cxyMargin, cxyMargin); + } + rcBand.Offset(size.Width, 0); + } + + // Draw falloff effect + if (this.FalloffEffect && this.IsActive) + { + int nMaxWidth = size.Width * nHorzBands; + Point[] points = new Point[2]; + points[0].X = rcPrev.Left + (_meterData[nVert].Falloff * nMaxWidth) / _MaxRangeValue; + points[0].Y = rcPrev.Top + yDecal; + points[1].X = points[0].X; + points[1].Y = rcPrev.Bottom - yDecal; + g.DrawPolygon(fallPen, points); + } + + // Move to Next Vertical band + rcBand.Offset(-size.Width*nHorzBands, size.Height); + } + } + } +} + +// use this to find resource namespace +internal class MyResourceNamespace +{ +} diff --git a/client/AudioRecorder/Resources.Designer.cs b/client/AudioRecorder/Resources.Designer.cs index 5fee7dc0..5d9a1445 100644 --- a/client/AudioRecorder/Resources.Designer.cs +++ b/client/AudioRecorder/Resources.Designer.cs @@ -69,6 +69,16 @@ namespace AudioRecorder { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ic_refresh_black_24dp_1x { + get { + object obj = ResourceManager.GetObject("ic_refresh_black_24dp_1x", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized string similar to Leállítás. /// diff --git a/client/AudioRecorder/Resources.resx b/client/AudioRecorder/Resources.resx index 0f2b9ab9..8adc74fd 100644 --- a/client/AudioRecorder/Resources.resx +++ b/client/AudioRecorder/Resources.resx @@ -120,6 +120,10 @@ Felvétel + + + Resources\ic_refresh_black_24dp_1x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Leállítás diff --git a/client/AudioRecorder/Resources/ic_refresh_black_24dp_1x.png b/client/AudioRecorder/Resources/ic_refresh_black_24dp_1x.png new file mode 100644 index 00000000..c82efd5f Binary files /dev/null and b/client/AudioRecorder/Resources/ic_refresh_black_24dp_1x.png differ diff --git a/client/AudioRecorder/VerticalProgressBar.cs b/client/AudioRecorder/VerticalProgressBar.cs index 123e7127..2cc3d0f1 100644 --- a/client/AudioRecorder/VerticalProgressBar.cs +++ b/client/AudioRecorder/VerticalProgressBar.cs @@ -14,7 +14,6 @@ namespace AudioRecorder { public VerticalProgressBar() { Style = ProgressBarStyle.Blocks; - } protected override void CreateHandle() { diff --git a/client/AudioRecorder/WavRecorder.cs b/client/AudioRecorder/WavRecorder.cs index 04cb7c18..ce0ac740 100644 --- a/client/AudioRecorder/WavRecorder.cs +++ b/client/AudioRecorder/WavRecorder.cs @@ -2,11 +2,9 @@ using System.Collections.Generic; using NAudio.Wave; using NAudio.CoreAudioApi; -using System.Diagnostics; -using System.Linq; namespace AudioRecorder { - public class WavRecorder : IRecorder { + public class WavRecorder { private const int MONO_CHANEL = 1; private int inputDeviceIndex; @@ -15,10 +13,10 @@ namespace AudioRecorder { private String filePath; private List createdWavFiles; private MMDevice device; - private IMainForm mainForm; + private MainForm mainForm; private volatile bool pausing; - public WavRecorder(int inputDeviceIndex, MMDevice device, IMainForm mainForm) { + public WavRecorder(int inputDeviceIndex, MMDevice device, MainForm mainForm) { this.inputDeviceIndex = inputDeviceIndex; createdWavFiles = new List(); this.device = device; @@ -58,13 +56,6 @@ namespace AudioRecorder { if (!pausing) { waveWriter.Write(e.Buffer, 0, e.BytesRecorded); waveWriter.Flush(); - try { - int panelHeight = (int)Math.Round(device.AudioMeterInformation.MasterPeakValue * 100); - mainForm.setPanelSizeHeight(panelHeight); - } - catch (Exception ex) { - Console.WriteLine(ex.Message); - } } } diff --git a/client/DxPlay/DxPlay.csproj b/client/DxPlay/DxPlay.csproj index e83e3db1..a7959ef6 100644 --- a/client/DxPlay/DxPlay.csproj +++ b/client/DxPlay/DxPlay.csproj @@ -172,12 +172,6 @@ - - Component - - - ColorSlider.cs - @@ -250,9 +244,6 @@ PreserveNewest - - ColorSlider.cs - PlayerForm.cs diff --git a/client/DxPlay/PlayerForm.Designer.cs b/client/DxPlay/PlayerForm.Designer.cs index 6ae7c08f..92fe9631 100644 --- a/client/DxPlay/PlayerForm.Designer.cs +++ b/client/DxPlay/PlayerForm.Designer.cs @@ -7,13 +7,13 @@ namespace DxPlay { private Panel pVideo; private NoFocusCueButton btnPlay; private NoFocusCueButton btnPause; - private TextBox textCurrentTC; + private TextBox lbCurrentTC; private NoFocusCueButton btnStop; - private TextBox txtStartTC; - private TextBox txtEndTC; + private TextBox lbStartTC; + private TextBox lbEndTC; private Panel panel3; - private Label label2; - private Label label1; + private Label lbDuration; + private Label lbStart; /// /// Clean up any resources being used. @@ -41,20 +41,20 @@ namespace DxPlay { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PlayerForm)); this.pVideo = new System.Windows.Forms.Panel(); - this.textCurrentTC = new System.Windows.Forms.TextBox(); - this.txtStartTC = new System.Windows.Forms.TextBox(); - this.txtEndTC = new System.Windows.Forms.TextBox(); + this.lbCurrentTC = new System.Windows.Forms.TextBox(); + this.lbStartTC = new System.Windows.Forms.TextBox(); + this.lbEndTC = new System.Windows.Forms.TextBox(); this.panel3 = new System.Windows.Forms.Panel(); - this.labelStatus = new System.Windows.Forms.Label(); - this.trackBar1 = new DxPlay.ColorSlider(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); + this.lbStatus = new System.Windows.Forms.Label(); + this.trackBar1 = new ColorSlider(); + this.lbDuration = new System.Windows.Forms.Label(); + this.lbStart = new System.Windows.Forms.Label(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.panelPlayer = new System.Windows.Forms.Panel(); this.pControls = new System.Windows.Forms.FlowLayoutPanel(); - this.btnPlay = new NoFocusCueButton(); - this.btnStop = new NoFocusCueButton(); - this.btnPause = new NoFocusCueButton(); + this.btnPlay = new MaestroShared.Controls.NoFocusCueButton(); + this.btnStop = new MaestroShared.Controls.NoFocusCueButton(); + this.btnPause = new MaestroShared.Controls.NoFocusCueButton(); this.dgSegments = new System.Windows.Forms.DataGridView(); this.bsSegments = new System.Windows.Forms.BindingSource(this.components); this.menuButtonSegmentActions = new DxPlay.MenuButton(); @@ -88,76 +88,76 @@ namespace DxPlay { this.pVideo.SizeChanged += new System.EventHandler(this.panel1_SizeChanged); this.pVideo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // - // textCurrentTC - // - this.textCurrentTC.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.textCurrentTC.BackColor = System.Drawing.Color.White; - this.textCurrentTC.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.textCurrentTC.Font = new System.Drawing.Font("Calibri", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.textCurrentTC.Location = new System.Drawing.Point(284, 12); - this.textCurrentTC.Name = "textCurrentTC"; - this.textCurrentTC.ReadOnly = true; - this.textCurrentTC.Size = new System.Drawing.Size(108, 27); - this.textCurrentTC.TabIndex = 15; - this.textCurrentTC.TabStop = false; - this.textCurrentTC.Text = "00:00:00.00"; - // - // txtStartTC - // - this.txtStartTC.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.txtStartTC.BackColor = System.Drawing.Color.White; - this.txtStartTC.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtStartTC.Font = new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.txtStartTC.ForeColor = System.Drawing.SystemColors.WindowText; - this.txtStartTC.Location = new System.Drawing.Point(6, 21); - this.txtStartTC.Name = "txtStartTC"; - this.txtStartTC.ReadOnly = true; - this.txtStartTC.Size = new System.Drawing.Size(66, 17); - this.txtStartTC.TabIndex = 16; - this.txtStartTC.TabStop = false; - this.txtStartTC.Text = "00:00:00.00"; - // - // txtEndTC - // - this.txtEndTC.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.txtEndTC.BackColor = System.Drawing.Color.White; - this.txtEndTC.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtEndTC.Font = new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.txtEndTC.ForeColor = System.Drawing.SystemColors.WindowText; - this.txtEndTC.Location = new System.Drawing.Point(605, 24); - this.txtEndTC.Name = "txtEndTC"; - this.txtEndTC.ReadOnly = true; - this.txtEndTC.Size = new System.Drawing.Size(65, 17); - this.txtEndTC.TabIndex = 17; - this.txtEndTC.TabStop = false; - this.txtEndTC.Text = "00:00:00.00"; - this.txtEndTC.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // lbCurrentTC + // + this.lbCurrentTC.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.lbCurrentTC.BackColor = System.Drawing.Color.White; + this.lbCurrentTC.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.lbCurrentTC.Font = new System.Drawing.Font("Calibri", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.lbCurrentTC.Location = new System.Drawing.Point(284, 12); + this.lbCurrentTC.Name = "lbCurrentTC"; + this.lbCurrentTC.ReadOnly = true; + this.lbCurrentTC.Size = new System.Drawing.Size(108, 27); + this.lbCurrentTC.TabIndex = 15; + this.lbCurrentTC.TabStop = false; + this.lbCurrentTC.Text = "00:00:00.00"; + // + // lbStartTC + // + this.lbStartTC.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lbStartTC.BackColor = System.Drawing.Color.White; + this.lbStartTC.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.lbStartTC.Font = new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.lbStartTC.ForeColor = System.Drawing.SystemColors.WindowText; + this.lbStartTC.Location = new System.Drawing.Point(6, 21); + this.lbStartTC.Name = "lbStartTC"; + this.lbStartTC.ReadOnly = true; + this.lbStartTC.Size = new System.Drawing.Size(66, 17); + this.lbStartTC.TabIndex = 16; + this.lbStartTC.TabStop = false; + this.lbStartTC.Text = "00:00:00.00"; + // + // lbEndTC + // + this.lbEndTC.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.lbEndTC.BackColor = System.Drawing.Color.White; + this.lbEndTC.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.lbEndTC.Font = new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.lbEndTC.ForeColor = System.Drawing.SystemColors.WindowText; + this.lbEndTC.Location = new System.Drawing.Point(605, 24); + this.lbEndTC.Name = "lbEndTC"; + this.lbEndTC.ReadOnly = true; + this.lbEndTC.Size = new System.Drawing.Size(65, 17); + this.lbEndTC.TabIndex = 17; + this.lbEndTC.TabStop = false; + this.lbEndTC.Text = "00:00:00.00"; + this.lbEndTC.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // panel3 // - this.panel3.Controls.Add(this.labelStatus); + this.panel3.Controls.Add(this.lbStatus); this.panel3.Controls.Add(this.trackBar1); - this.panel3.Controls.Add(this.label2); - this.panel3.Controls.Add(this.label1); - this.panel3.Controls.Add(this.txtStartTC); - this.panel3.Controls.Add(this.txtEndTC); - this.panel3.Controls.Add(this.textCurrentTC); + this.panel3.Controls.Add(this.lbDuration); + this.panel3.Controls.Add(this.lbStart); + this.panel3.Controls.Add(this.lbStartTC); + this.panel3.Controls.Add(this.lbEndTC); + this.panel3.Controls.Add(this.lbCurrentTC); this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel3.Location = new System.Drawing.Point(0, 433); this.panel3.Name = "panel3"; this.panel3.Size = new System.Drawing.Size(675, 51); this.panel3.TabIndex = 19; // - // labelStatus + // lbStatus // - this.labelStatus.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.labelStatus.Font = new System.Drawing.Font("Calibri", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.labelStatus.Location = new System.Drawing.Point(281, 4); - this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(111, 13); - this.labelStatus.TabIndex = 20; - this.labelStatus.Text = "NO INPUT"; - this.labelStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbStatus.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.lbStatus.Font = new System.Drawing.Font("Calibri", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.lbStatus.Location = new System.Drawing.Point(281, 4); + this.lbStatus.Name = "lbStatus"; + this.lbStatus.Size = new System.Drawing.Size(111, 13); + this.lbStatus.TabIndex = 20; + this.lbStatus.Text = "NO INPUT"; + this.lbStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // trackBar1 // @@ -186,27 +186,27 @@ namespace DxPlay { this.trackBar1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.trackBar1_MouseDown); this.trackBar1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.trackBar1_MouseUp); // - // label2 + // lbDuration // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.label2.Font = new System.Drawing.Font("Calibri", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.label2.Location = new System.Drawing.Point(605, 5); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(68, 13); - this.label2.TabIndex = 19; - this.label2.Text = "DURATION"; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.lbDuration.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.lbDuration.Font = new System.Drawing.Font("Calibri", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.lbDuration.Location = new System.Drawing.Point(605, 5); + this.lbDuration.Name = "lbDuration"; + this.lbDuration.Size = new System.Drawing.Size(68, 13); + this.lbDuration.TabIndex = 19; + this.lbDuration.Text = "DURATION"; + this.lbDuration.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // - // label1 + // lbStart // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label1.Font = new System.Drawing.Font("Calibri", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.label1.Location = new System.Drawing.Point(3, 5); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(69, 13); - this.label1.TabIndex = 18; - this.label1.Text = "START"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.lbStart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lbStart.Font = new System.Drawing.Font("Calibri", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.lbStart.Location = new System.Drawing.Point(3, 5); + this.lbStart.Name = "lbStart"; + this.lbStart.Size = new System.Drawing.Size(69, 13); + this.lbStart.TabIndex = 18; + this.lbStart.Text = "START"; + this.lbStart.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // splitContainer1 // @@ -252,7 +252,7 @@ namespace DxPlay { // btnPlay // this.btnPlay.AutoSize = true; - this.btnPlay.BackColor = System.Drawing.Color.White; + this.btnPlay.BackColor = System.Drawing.Color.Transparent; this.btnPlay.FlatAppearance.BorderSize = 0; this.btnPlay.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnPlay.Image = global::DxPlay.Properties.Resources.ic_play_arrow_black_24dp_2x; @@ -268,7 +268,7 @@ namespace DxPlay { // btnStop // this.btnStop.AutoSize = true; - this.btnStop.BackColor = System.Drawing.Color.White; + this.btnStop.BackColor = System.Drawing.Color.Transparent; this.btnStop.FlatAppearance.BorderSize = 0; this.btnStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnStop.Image = global::DxPlay.Properties.Resources.ic_stop_black_24dp_2x; @@ -284,7 +284,7 @@ namespace DxPlay { // btnPause // this.btnPause.AutoSize = true; - this.btnPause.BackColor = System.Drawing.Color.White; + this.btnPause.BackColor = System.Drawing.Color.Transparent; this.btnPause.FlatAppearance.BorderSize = 0; this.btnPause.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnPause.Image = global::DxPlay.Properties.Resources.ic_pause_black_24dp_2x; @@ -425,7 +425,7 @@ namespace DxPlay { #endregion private ColorSlider trackBar1; - private Label labelStatus; + private Label lbStatus; private SplitContainer splitContainer1; private Panel panelPlayer; private MenuButton menuButtonSegmentActions; diff --git a/client/DxPlay/PlayerForm.cs b/client/DxPlay/PlayerForm.cs index 2e85b957..89ea8de4 100644 --- a/client/DxPlay/PlayerForm.cs +++ b/client/DxPlay/PlayerForm.cs @@ -34,6 +34,7 @@ namespace DxPlay { } private void InitializeTexts() { + defineOneSegmentToolStripMenuItem.Text = StringResource.SZEGMENS_DEFINIALASA; splitSegmentAtCurrentPositionToolStripMenuItem.Text = StringResource.SZEGMENS_SZETVAGASA; actualPositionToIntroToolStripMenuItem.Text = StringResource.AKTUALIS_POZICIO_BELEPO; @@ -44,9 +45,9 @@ namespace DxPlay { //btnPause.Text = StringResource.SZUNET; //btnPlay.Text = StringResource.LEJATSZAS; //btnStop.Text = StringResource.LEALLITAS; - labelStatus.Text = StringResource.NINCS_BEMENET; - label1.Text = StringResource.INDULASI_PONT; - label2.Text = StringResource.HOSSZ; + lbStatus.Text = StringResource.NINCS_BEMENET; + lbStart.Text = StringResource.INDULASI_PONT; + lbDuration.Text = StringResource.HOSSZ; } private void cueue() { @@ -64,8 +65,8 @@ namespace DxPlay { m_play.PlayEvent += new DxPlayEvent(playEvent); if (m_mediaDescription != null) { trackBar1.Maximum = m_mediaDescription.Duration.Frames; - txtStartTC.Text = m_mediaDescription.FirstFrame.ToString(); - txtEndTC.Text = m_mediaDescription.Duration.ToString(); + lbStartTC.Text = m_mediaDescription.FirstFrame.ToString(); + lbEndTC.Text = m_mediaDescription.Duration.ToString(); } } catch (Exception ce) { @@ -94,10 +95,10 @@ namespace DxPlay { return; if (!trackBarAtUser) trackBar1.Value = m_play.CurrentTC.ZeroBasedFrames; - textCurrentTC.Text = m_play.CurrentTC.ToString(); - string labelStatusText = labelStatus.Text; + lbCurrentTC.Text = m_play.CurrentTC.ToString(); + string labelStatusText = lbStatus.Text; m_play.stateHunStringValues.TryGetValue(m_play.State, out labelStatusText);//m_play.State.ToString().ToUpper(); - labelStatus.Text = labelStatusText; + lbStatus.Text = labelStatusText; })); } @@ -227,6 +228,15 @@ namespace DxPlay { splitContainer1.Panel2Collapsed = true; splitContainer1.Panel2.Hide(); } + + lbStartTC.BackColor = BackColor; + lbDuration.BackColor = BackColor; + lbEndTC.BackColor = BackColor; + lbCurrentTC.BackColor = BackColor; + lbStart.BackColor = BackColor; + lbStatus.BackColor = BackColor; + dgSegments.BackgroundColor = BackColor; + } private void PlayerForm_KeyDown(object sender, KeyEventArgs e) { @@ -288,6 +298,14 @@ namespace DxPlay { m_play.Play(); result = true; break; + case Keys.I: + if (SegmentEditor) + SetActualPositionAsIn(); + break; + case Keys.O: + if (SegmentEditor) + SetActualPositionAsOut(); + break; } return result; } @@ -353,43 +371,73 @@ namespace DxPlay { segments.Remove(bsSegments.Current as MovieSegment); } - private void OnActualPositionToTCInToolStripMenuItem1Click(object sender, EventArgs e) { + private void SetActualPositionAsIn() { MovieSegment currentSegment = bsSegments.Current as MovieSegment; - if (currentSegment == null) - return; - if (currentSegment.TCOut.Frames <= m_play.CurrentTC.Frames) { - MessageBox.Show("A belépõ nem lehet a kilépõ után."); - return; - } - //if (MessageBox.Show("Biztos felül akarja írni az belépõt?", "Belépõ felülírása", MessageBoxButtons.YesNo) == DialogResult.No) - // return; - MovieSegment collisionSegment = segments.Where(s => s.TCIn.Frames < m_play.CurrentTC.Frames && m_play.CurrentTC.Frames < s.TCOut.Frames).SingleOrDefault(); + if (currentSegment == null || bsSegments.Count == 0) { + MovieSegment newSegment = new MovieSegment() { + TCIn = new Timecode(m_play.CurrentTC.Frames), + TCOut = new Timecode(m_play.MediaDescription.FirstFrame.Frames + m_play.MediaDescription.Duration.Frames) + }; + bsSegments.Position = bsSegments.Add(newSegment); + } else { + if (currentSegment.TCOut.Frames <= m_play.CurrentTC.Frames) { + int pos = bsSegments.IndexOf(currentSegment); + if (pos == bsSegments.Count - 1) { + MovieSegment newSegment = new MovieSegment() { + TCIn = new Timecode(m_play.CurrentTC.Frames), + TCOut = new Timecode(m_play.MediaDescription.FirstFrame.Frames + m_play.MediaDescription.Duration.Frames) + }; + bsSegments.Position = bsSegments.Add(newSegment); + return; + } + MessageBox.Show("A belépõ nem lehet a kilépõ után."); + return; + } + //if (MessageBox.Show("Biztos felül akarja írni az belépõt?", "Belépõ felülírása", MessageBoxButtons.YesNo) == DialogResult.No) + // return; + MovieSegment collisionSegment = segments.Where(s => s.TCIn.Frames < m_play.CurrentTC.Frames && m_play.CurrentTC.Frames < s.TCOut.Frames).SingleOrDefault(); - if (collisionSegment != null && !currentSegment.Equals(collisionSegment)) { - MessageBox.Show("A szegmensek között nem lehet átfedés."); - return; - } + if (collisionSegment != null && !currentSegment.Equals(collisionSegment)) { + MessageBox.Show("A szegmensek között nem lehet átfedés."); + return; + } - currentSegment.TCIn = new Timecode(m_play.CurrentTC.Frames); + currentSegment.TCIn = new Timecode(m_play.CurrentTC.Frames); + } } - private void OnActualPositionToTCOutToolStripMenuItem1Click(object sender, EventArgs e) { + + private void SetActualPositionAsOut() { MovieSegment currentSegment = bsSegments.Current as MovieSegment; - if (currentSegment == null) - return; - if (currentSegment.TCIn.Frames >= m_play.CurrentTC.Frames) - MessageBox.Show("A kilépõ nem lehet a belépõ elõtt."); + if (currentSegment == null || bsSegments.Count == 0) { + MovieSegment newSegment = new MovieSegment() { + TCIn = new Timecode(m_play.MediaDescription.FirstFrame.Frames), + TCOut = new Timecode(m_play.CurrentTC.Frames), + }; + bsSegments.Position = bsSegments.Add(newSegment); + } else { + if (currentSegment.TCIn.Frames >= m_play.CurrentTC.Frames) + MessageBox.Show("A kilépõ nem lehet a belépõ elõtt."); - MovieSegment collisionSegment = segments.Where(s => s.TCIn.Frames < m_play.CurrentTC.Frames && m_play.CurrentTC.Frames < s.TCOut.Frames).SingleOrDefault(); + MovieSegment collisionSegment = segments.Where(s => s.TCIn.Frames < m_play.CurrentTC.Frames && m_play.CurrentTC.Frames < s.TCOut.Frames).SingleOrDefault(); - if (collisionSegment != null && !currentSegment.Equals(collisionSegment)) { - MessageBox.Show("A szegmensek között nem lehet átfedés."); - return; + if (collisionSegment != null && !currentSegment.Equals(collisionSegment)) { + MessageBox.Show("A szegmensek között nem lehet átfedés."); + return; + } + + //if (MessageBox.Show("Biztos felül akarja írni az kilépõt?", "Kilépõ felülírása", MessageBoxButtons.YesNo) == DialogResult.No) + // return; + currentSegment.TCOut = new Timecode(m_play.CurrentTC.Frames); } + } + + private void OnActualPositionToTCInToolStripMenuItem1Click(object sender, EventArgs e) { + SetActualPositionAsIn(); + } - //if (MessageBox.Show("Biztos felül akarja írni az kilépõt?", "Kilépõ felülírása", MessageBoxButtons.YesNo) == DialogResult.No) - // return; - currentSegment.TCOut = new Timecode(m_play.CurrentTC.Frames); + private void OnActualPositionToTCOutToolStripMenuItem1Click(object sender, EventArgs e) { + SetActualPositionAsOut(); } private void OnSplitSegmentAtCurrentPositionClick(object sender, EventArgs e) { @@ -434,10 +482,13 @@ namespace DxPlay { m_play.Pause(); int pos = actualSegment.TCOut.Frames - m_play.MediaDescription.FirstFrame.Frames; //Az utolsó kocka nem jelenik meg egyébként - if (pos == m_play.MediaDescription.Duration.Frames) + if (pos == m_play.MediaDescription.Duration.Frames) { pos--; - m_play.Seek(pos); - m_play.Play(); + m_play.Seek(pos); + m_play.Play(); + } else + m_play.Seek(pos); + } } diff --git a/client/Maestro/Configuration/configuration-nle.json b/client/Maestro/Configuration/configuration-nle.json index 3a7010ad..dcc5e6db 100644 --- a/client/Maestro/Configuration/configuration-nle.json +++ b/client/Maestro/Configuration/configuration-nle.json @@ -3,6 +3,8 @@ "active": true, "startInTray": false, "enableCustomMetadataId": true, + "defaultWindowColor": "#E1BEE7", + "partialWindowColor": "#F3E5F5", "player": { "enabled": true, "autoStart": false, @@ -45,8 +47,8 @@ "timeout": 1000 } }, - "disableProject": false, - "disableSourceOpen": false + "disableOpenProject": false, + "disableOpenSourceFolder": false } }, { diff --git a/client/Maestro/Installer/installforge-installer-project.ifp b/client/Maestro/Installer/installforge-installer-project.ifp index c925d278..c2a05404 100644 Binary files a/client/Maestro/Installer/installforge-installer-project.ifp and b/client/Maestro/Installer/installforge-installer-project.ifp differ diff --git a/client/Maestro/MaestroForm.Metadata.cs b/client/Maestro/MaestroForm.Metadata.cs index 640c3f13..7a022140 100644 --- a/client/Maestro/MaestroForm.Metadata.cs +++ b/client/Maestro/MaestroForm.Metadata.cs @@ -107,6 +107,7 @@ namespace Maestro { } ArchiveMetadataForm form = new ArchiveMetadataForm(ref archiveMetadata); + form.BackColor = partialColor; DialogResult result = form.ShowDialog(); if (result == DialogResult.OK && String.IsNullOrEmpty(textSelectedMetadata.Text)) { @@ -159,6 +160,7 @@ namespace Maestro { if (movieSegments == null) movieSegments = new BindingList(); PlayerForm player = new PlayerForm(ref movieSegments); + player.BackColor = partialColor; player.AutoStart = Configuration.Player.AutoStart; player.SegmentEditor = Configuration.Player.SegmentEditor; player.Open(SelectedSource.FileInfo); @@ -461,5 +463,11 @@ namespace Maestro { Lookup(SelectedMetadata.ID); } + private void ClearSelectedMetadata() { + trafficIDSelector.ClearSelection(); + octopusIDSelector.ClearSelection(); + SelectedMetadata = null; + } + } } diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index e348ff35..64c140ef 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -43,6 +43,12 @@ namespace Maestro { } private void InitializeSource() { + + if (Configuration.DefaultWindowColor != null) + defaultColor = (Color) Configuration.DefaultWindowColor; + if (Configuration.PartialWindowColor != null) + partialColor = (Color) Configuration.PartialWindowColor; + Uri localAddress = Configuration?.Source?.Local?.Address; Uri remoteAddress = Configuration?.Source?.Remote?.Address; if (String.IsNullOrEmpty(remoteAddress?.ToString())) { @@ -188,6 +194,7 @@ namespace Maestro { Cursor = Cursors.WaitCursor; try { PlayerForm player = new PlayerForm(); + player.BackColor = partialColor; player.AutoStart = Configuration.Player.AutoStart; player.Open(fileSourceItem.FileInfo); if (!player.IsDisposed) diff --git a/client/Maestro/MaestroForm.Target.cs b/client/Maestro/MaestroForm.Target.cs index 432ff07e..88cf649f 100644 --- a/client/Maestro/MaestroForm.Target.cs +++ b/client/Maestro/MaestroForm.Target.cs @@ -229,8 +229,8 @@ namespace Maestro { CreateJobsQueueWorker(); ActivateTab(0); SelectedSource = null; + ClearSelectedMetadata(); } - } } diff --git a/client/Maestro/MaestroForm.cs b/client/Maestro/MaestroForm.cs index 40bfd264..15aa8906 100644 --- a/client/Maestro/MaestroForm.cs +++ b/client/Maestro/MaestroForm.cs @@ -33,8 +33,8 @@ namespace Maestro { private ToolTip formTooltip = new ToolTip(); private ConfigurationInfo configuration; - private static readonly Color highlightColor = Color.White; - private static readonly Color defaultColor = SystemColors.Control; + private Color partialColor = Color.White; + private Color defaultColor = SystemColors.Control; public ConfigurationInfo Configuration { @@ -156,7 +156,7 @@ namespace Maestro { private void groupBox_Enter(object sender, EventArgs e) { Control control = sender as Control; control.Font = new Font(control.Font, FontStyle.Bold); - SetColor(control, highlightColor); + SetColor(control, partialColor); } private void SetColor(Control control, Color color) { diff --git a/client/Maestro/Properties/AssemblyInfo.cs b/client/Maestro/Properties/AssemblyInfo.cs index c0bb94b1..6acc4e72 100644 --- a/client/Maestro/Properties/AssemblyInfo.cs +++ b/client/Maestro/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.4.5")] -[assembly: AssemblyFileVersion("2.0.4.5")] +[assembly: AssemblyVersion("2.0.5.0")] +[assembly: AssemblyFileVersion("2.0.5.0")] diff --git a/client/MaestroShared/Configuration/ConfigurationInfo.cs b/client/MaestroShared/Configuration/ConfigurationInfo.cs index ac1a9761..d0567ba3 100644 --- a/client/MaestroShared/Configuration/ConfigurationInfo.cs +++ b/client/MaestroShared/Configuration/ConfigurationInfo.cs @@ -3,6 +3,7 @@ using System; using System.Linq; using System.Collections.Generic; using System.IO; +using System.Drawing; namespace MaestroShared.Configuration { @@ -28,6 +29,10 @@ namespace MaestroShared.Configuration { } public class ConfigurationInfo { + //[JsonConverter(typeof(KeysColorConverter))] + public Color? DefaultWindowColor { get; set; } + //[JsonConverter(typeof(KeysColorConverter))] + public Color? PartialWindowColor { get; set; } public bool StartInTray { get; set; } public bool Active { get; set; } public string Title { get; set; } @@ -86,7 +91,7 @@ namespace MaestroShared.Configuration { //[JsonConverter(typeof(KeysJsonConverter))] public Uri Address { get; set; } public string UserName { get; set; } - [JsonConverter(typeof(KeysJsonConverter))] + [JsonConverter(typeof(KeysPasswordConverter))] public string Password { get; set; } public int Timeout { get; set; } } @@ -112,8 +117,8 @@ namespace MaestroShared.Configuration { public Connection TemplateRoot { get; set; } public Target Target { get; set; } public string TemplateName { get; set; } - public bool DisableProject { get; set; } - public bool DisableSourceOpen { get; set; } + public bool DisableOpenProject { get; set; } + public bool DisableOpenSourceFolder { get; set; } public bool IsValid { get { return Target?.Remote?.Address != null && diff --git a/client/MaestroShared/Configuration/KeysColorConverter.cs b/client/MaestroShared/Configuration/KeysColorConverter.cs new file mode 100644 index 00000000..685fc494 --- /dev/null +++ b/client/MaestroShared/Configuration/KeysColorConverter.cs @@ -0,0 +1,36 @@ +using Newtonsoft.Json; +using System; +using System.Drawing; +using System.Globalization; +using System.Windows.Forms; + +namespace MaestroShared.Configuration { + public class KeysColorConverter : JsonConverter { + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { + string d = serializer.Deserialize(reader, objectType)?.ToString(); + Color color = SystemColors.Control; + try { + color = Color.FromArgb(int.Parse(d.Substring(1, 2), NumberStyles.HexNumber), + int.Parse(d.Substring(3, 2), NumberStyles.HexNumber), + int.Parse(d.Substring(5, 2), NumberStyles.HexNumber)); + } + catch (Exception e) { + MessageBox.Show(e.Message); + } + return color; + } + + public override bool CanConvert(Type objectType) { + return true; + } + + public override bool CanRead { + get { + return true; + } + } + } +} diff --git a/client/MaestroShared/Configuration/KeysJsonConverter.cs b/client/MaestroShared/Configuration/KeysJsonConverter.cs index 9a712f85..210dfc7a 100644 --- a/client/MaestroShared/Configuration/KeysJsonConverter.cs +++ b/client/MaestroShared/Configuration/KeysJsonConverter.cs @@ -3,7 +3,7 @@ using PasswordEncrypter; using System; namespace MaestroShared.Configuration { - public class KeysJsonConverter : JsonConverter { + public class KeysPasswordConverter : JsonConverter { public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { } diff --git a/client/DxPlay/ColorSlider.cs b/client/MaestroShared/Controls/ColorSlider.cs similarity index 97% rename from client/DxPlay/ColorSlider.cs rename to client/MaestroShared/Controls/ColorSlider.cs index be317394..c6f12d6f 100644 --- a/client/DxPlay/ColorSlider.cs +++ b/client/MaestroShared/Controls/ColorSlider.cs @@ -4,7 +4,7 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; -namespace DxPlay +namespace MaestroShared.Controls { /// /// Encapsulates control that visualy displays certain integer value and allows user to change it within desired range. It imitates as far as mouse usage is concerned. diff --git a/client/DxPlay/ColorSlider.designer.cs b/client/MaestroShared/Controls/ColorSlider.designer.cs similarity index 93% rename from client/DxPlay/ColorSlider.designer.cs rename to client/MaestroShared/Controls/ColorSlider.designer.cs index d13c6ea3..3ca25966 100644 --- a/client/DxPlay/ColorSlider.designer.cs +++ b/client/MaestroShared/Controls/ColorSlider.designer.cs @@ -1,4 +1,4 @@ -namespace DxPlay { +namespace MaestroShared.Controls { partial class ColorSlider { /// /// Required designer variable. diff --git a/client/DxPlay/ColorSlider.resx b/client/MaestroShared/Controls/ColorSlider.resx similarity index 100% rename from client/DxPlay/ColorSlider.resx rename to client/MaestroShared/Controls/ColorSlider.resx diff --git a/client/MaestroShared/MaestroShared.csproj b/client/MaestroShared/MaestroShared.csproj index 310b065a..2d5b76ce 100644 --- a/client/MaestroShared/MaestroShared.csproj +++ b/client/MaestroShared/MaestroShared.csproj @@ -86,8 +86,15 @@ + + + Component + + + ColorSlider.cs + Component @@ -118,5 +125,10 @@ PasswordEncrypter + + + ColorSlider.cs + + \ No newline at end of file diff --git a/client/OctopusClient/OctopusClient.csproj b/client/OctopusClient/OctopusClient.csproj index 7a16e275..c5585399 100644 --- a/client/OctopusClient/OctopusClient.csproj +++ b/client/OctopusClient/OctopusClient.csproj @@ -139,5 +139,8 @@ MaestroShared + + + \ No newline at end of file diff --git a/client/OctopusClient/OctopusIDSelector.Designer.cs b/client/OctopusClient/OctopusIDSelector.Designer.cs index d2026605..8d0617be 100644 --- a/client/OctopusClient/OctopusIDSelector.Designer.cs +++ b/client/OctopusClient/OctopusIDSelector.Designer.cs @@ -24,15 +24,16 @@ /// private void InitializeComponent() { this.treeOctopus = new OctopusClient.CheckableTreeView(); - this.pSearch = new System.Windows.Forms.TableLayoutPanel(); + this.pSeparator = new System.Windows.Forms.Panel(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.cbFolders = new System.Windows.Forms.ComboBox(); + this.dtScheduled = new System.Windows.Forms.DateTimePicker(); this.pFolderType = new System.Windows.Forms.FlowLayoutPanel(); this.rbRundown = new System.Windows.Forms.RadioButton(); this.rbStoryFolder = new System.Windows.Forms.RadioButton(); this.txtFilter = new System.Windows.Forms.TextBox(); - this.dtScheduled = new System.Windows.Forms.DateTimePicker(); - this.pSeparator = new System.Windows.Forms.Panel(); - this.pSearch.SuspendLayout(); + this.noFocusCueButton1 = new MaestroShared.Controls.NoFocusCueButton(); + this.tableLayoutPanel1.SuspendLayout(); this.pFolderType.SuspendLayout(); this.SuspendLayout(); // @@ -42,39 +43,44 @@ this.treeOctopus.BorderStyle = System.Windows.Forms.BorderStyle.None; this.treeOctopus.CheckBoxes = true; this.treeOctopus.Dock = System.Windows.Forms.DockStyle.Fill; - this.treeOctopus.Location = new System.Drawing.Point(0, 78); + this.treeOctopus.Location = new System.Drawing.Point(0, 80); this.treeOctopus.Margin = new System.Windows.Forms.Padding(0); this.treeOctopus.Name = "treeOctopus"; - this.treeOctopus.Size = new System.Drawing.Size(300, 322); + this.treeOctopus.Size = new System.Drawing.Size(300, 320); this.treeOctopus.TabIndex = 5; this.treeOctopus.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeOctopus_NodeMouseClick); this.treeOctopus.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeOctopus_NodeMouseDoubleClick); this.treeOctopus.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeContent_KeyDown); // - // pSearch - // - this.pSearch.AutoSize = true; - this.pSearch.ColumnCount = 2; - this.pSearch.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.pSearch.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.pSearch.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.pSearch.Controls.Add(this.cbFolders, 0, 2); - this.pSearch.Controls.Add(this.pFolderType, 0, 1); - this.pSearch.Controls.Add(this.txtFilter, 0, 0); - this.pSearch.Controls.Add(this.dtScheduled, 0, 2); - this.pSearch.Dock = System.Windows.Forms.DockStyle.Top; - this.pSearch.Location = new System.Drawing.Point(0, 0); - this.pSearch.Margin = new System.Windows.Forms.Padding(0); - this.pSearch.Name = "pSearch"; - this.pSearch.Padding = new System.Windows.Forms.Padding(3); - this.pSearch.RowCount = 3; - this.pSearch.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.pSearch.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.pSearch.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.pSearch.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.pSearch.Size = new System.Drawing.Size(300, 72); - this.pSearch.TabIndex = 11; - this.pSearch.Paint += new System.Windows.Forms.PaintEventHandler(this.OnSearchPanelPaint); + // pSeparator + // + this.pSeparator.BackColor = System.Drawing.Color.White; + this.pSeparator.Dock = System.Windows.Forms.DockStyle.Top; + this.pSeparator.Location = new System.Drawing.Point(0, 74); + this.pSeparator.Name = "pSeparator"; + this.pSeparator.Size = new System.Drawing.Size(300, 6); + this.pSeparator.TabIndex = 12; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.Controls.Add(this.cbFolders, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.dtScheduled, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.pFolderType, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.txtFilter, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.noFocusCueButton1, 2, 2); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(300, 74); + this.tableLayoutPanel1.TabIndex = 13; // // cbFolders // @@ -83,24 +89,35 @@ this.cbFolders.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbFolders.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.cbFolders.FormattingEnabled = true; - this.cbFolders.Location = new System.Drawing.Point(86, 47); + this.cbFolders.Location = new System.Drawing.Point(83, 49); this.cbFolders.Margin = new System.Windows.Forms.Padding(1); this.cbFolders.Name = "cbFolders"; - this.cbFolders.Size = new System.Drawing.Size(210, 21); - this.cbFolders.TabIndex = 4; - this.cbFolders.SelectedIndexChanged += new System.EventHandler(this.OnSelectedFolderChanged); + this.cbFolders.Size = new System.Drawing.Size(193, 21); + this.cbFolders.TabIndex = 5; + this.cbFolders.SelectedValueChanged += new System.EventHandler(this.OnSelectedFolderChanged); + // + // dtScheduled + // + this.dtScheduled.CustomFormat = " "; + this.dtScheduled.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dtScheduled.Location = new System.Drawing.Point(1, 49); + this.dtScheduled.Margin = new System.Windows.Forms.Padding(1); + this.dtScheduled.Name = "dtScheduled"; + this.dtScheduled.Size = new System.Drawing.Size(80, 20); + this.dtScheduled.TabIndex = 4; + this.dtScheduled.ValueChanged += new System.EventHandler(this.OnDateChanged); // // pFolderType // - this.pSearch.SetColumnSpan(this.pFolderType, 2); + this.tableLayoutPanel1.SetColumnSpan(this.pFolderType, 3); this.pFolderType.Controls.Add(this.rbRundown); this.pFolderType.Controls.Add(this.rbStoryFolder); this.pFolderType.Dock = System.Windows.Forms.DockStyle.Top; - this.pFolderType.Location = new System.Drawing.Point(3, 25); + this.pFolderType.Location = new System.Drawing.Point(0, 22); this.pFolderType.Margin = new System.Windows.Forms.Padding(0); this.pFolderType.Name = "pFolderType"; - this.pFolderType.Size = new System.Drawing.Size(294, 21); - this.pFolderType.TabIndex = 2; + this.pFolderType.Size = new System.Drawing.Size(300, 26); + this.pFolderType.TabIndex = 3; // // rbRundown // @@ -135,34 +152,27 @@ // // txtFilter // - this.pSearch.SetColumnSpan(this.txtFilter, 2); + this.tableLayoutPanel1.SetColumnSpan(this.txtFilter, 3); this.txtFilter.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtFilter.Location = new System.Drawing.Point(4, 4); + this.txtFilter.Location = new System.Drawing.Point(1, 1); this.txtFilter.Margin = new System.Windows.Forms.Padding(1); this.txtFilter.Name = "txtFilter"; - this.txtFilter.Size = new System.Drawing.Size(292, 20); - this.txtFilter.TabIndex = 0; + this.txtFilter.Size = new System.Drawing.Size(298, 20); + this.txtFilter.TabIndex = 1; this.txtFilter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnFilterKeyDown); // - // dtScheduled + // noFocusCueButton1 // - this.dtScheduled.CustomFormat = " "; - this.dtScheduled.Format = System.Windows.Forms.DateTimePickerFormat.Short; - this.dtScheduled.Location = new System.Drawing.Point(4, 47); - this.dtScheduled.Margin = new System.Windows.Forms.Padding(1); - this.dtScheduled.Name = "dtScheduled"; - this.dtScheduled.Size = new System.Drawing.Size(80, 20); - this.dtScheduled.TabIndex = 3; - this.dtScheduled.ValueChanged += new System.EventHandler(this.OnDateChanged); - // - // pSeparator - // - this.pSeparator.BackColor = System.Drawing.Color.White; - this.pSeparator.Dock = System.Windows.Forms.DockStyle.Top; - this.pSeparator.Location = new System.Drawing.Point(0, 72); - this.pSeparator.Name = "pSeparator"; - this.pSeparator.Size = new System.Drawing.Size(300, 6); - this.pSeparator.TabIndex = 12; + this.noFocusCueButton1.FlatAppearance.BorderSize = 0; + this.noFocusCueButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.noFocusCueButton1.Image = global::OctopusClient.Resources.ic_refresh_black_24dp_1x; + this.noFocusCueButton1.Location = new System.Drawing.Point(278, 49); + this.noFocusCueButton1.Margin = new System.Windows.Forms.Padding(1); + this.noFocusCueButton1.Name = "noFocusCueButton1"; + this.noFocusCueButton1.Size = new System.Drawing.Size(21, 21); + this.noFocusCueButton1.TabIndex = 6; + this.noFocusCueButton1.UseVisualStyleBackColor = true; + this.noFocusCueButton1.Click += new System.EventHandler(this.noFocusCueButton1_Click); // // OctopusIDSelector // @@ -171,27 +181,27 @@ this.BackColor = System.Drawing.Color.Transparent; this.Controls.Add(this.treeOctopus); this.Controls.Add(this.pSeparator); - this.Controls.Add(this.pSearch); + this.Controls.Add(this.tableLayoutPanel1); this.Name = "OctopusIDSelector"; this.Size = new System.Drawing.Size(300, 400); - this.pSearch.ResumeLayout(false); - this.pSearch.PerformLayout(); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); this.pFolderType.ResumeLayout(false); this.pFolderType.PerformLayout(); this.ResumeLayout(false); - this.PerformLayout(); } #endregion private CheckableTreeView treeOctopus; - private System.Windows.Forms.TableLayoutPanel pSearch; + private System.Windows.Forms.Panel pSeparator; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.ComboBox cbFolders; + private System.Windows.Forms.DateTimePicker dtScheduled; private System.Windows.Forms.FlowLayoutPanel pFolderType; private System.Windows.Forms.RadioButton rbRundown; private System.Windows.Forms.RadioButton rbStoryFolder; private System.Windows.Forms.TextBox txtFilter; - private System.Windows.Forms.DateTimePicker dtScheduled; - private System.Windows.Forms.ComboBox cbFolders; - private System.Windows.Forms.Panel pSeparator; + private MaestroShared.Controls.NoFocusCueButton noFocusCueButton1; } } diff --git a/client/OctopusClient/OctopusIDSelector.cs b/client/OctopusClient/OctopusIDSelector.cs index ac48deb8..690a83e4 100644 --- a/client/OctopusClient/OctopusIDSelector.cs +++ b/client/OctopusClient/OctopusIDSelector.cs @@ -64,18 +64,21 @@ namespace OctopusClient { treeOctopus.AfterCheck += OnTreeAfterCheck; treeOctopus.DrawMode = TreeViewDrawMode.OwnerDrawText; treeOctopus.DrawNode += OnDrawNode; - treeOctopus.NodeDoubleClick += treeOctopus_NodeDoubleClick; + treeOctopus.NodeDoubleClick += OnNodeDoubleClick; } void OnDrawNode(object sender, DrawTreeNodeEventArgs e) { Graphics g = e.Graphics; - if ((e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected) { + if ((e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected || (e.State & TreeNodeStates.Focused) == TreeNodeStates.Focused) { using (SolidBrush brush = new SolidBrush(Color.Gainsboro)) { e.Graphics.FillRectangle(brush, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); } - using (Pen pen = new Pen(Color.Black)) { - pen.Width = 1; - e.Graphics.DrawLine(pen, e.Bounds.X, e.Bounds.Y + 2, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 4); + if ((e.Node.Level == 0 && !parameters.Configuration.DisableStoryCheck) || + e.Node.Level == 1 && !parameters.Configuration.DisablePlaceHolderCheck) { + using (Pen pen = new Pen(Color.Black)) { + pen.Width = 1; + e.Graphics.DrawLine(pen, e.Bounds.X, e.Bounds.Y + 2, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 4); + } } } TextRenderer.DrawText(e.Graphics, e.Node.Text, treeOctopus.Font, e.Bounds, treeOctopus.ForeColor, TextFormatFlags.Left | TextFormatFlags.Top); @@ -115,6 +118,10 @@ namespace OctopusClient { //this.OnKeyDown(e); if (e.KeyCode != Keys.F5) return; + Refresh(); + } + + private void Refresh() { if (String.IsNullOrEmpty(txtFilter.Text)) RefreshStories(); else @@ -393,8 +400,8 @@ namespace OctopusClient { private void treeOctopus_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { } - private void treeOctopus_NodeDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { - if (e.X < e.Node.Bounds.X + 5) + private void OnNodeDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { + if (e.X < e.Node.Bounds.X + 5 || e.Node.Level != 0) return; Open(e.Node); } @@ -433,10 +440,17 @@ namespace OctopusClient { return; } - Process.Start(processor.Output); + if (!projectConfiguration.DisableOpenProject) + Process.Start(processor.Output); + if (!projectConfiguration.DisableOpenSourceFolder) { + string path = Path.GetDirectoryName(Path.GetDirectoryName(processor.Output)); + Process.Start(path); + } } - + private void noFocusCueButton1_Click(object sender, EventArgs e) { + Refresh(); + } } public class OctopusAPIMessage : IMessage { diff --git a/client/OctopusClient/Resources.Designer.cs b/client/OctopusClient/Resources.Designer.cs index d1feb6af..c1b45496 100644 --- a/client/OctopusClient/Resources.Designer.cs +++ b/client/OctopusClient/Resources.Designer.cs @@ -87,6 +87,16 @@ namespace OctopusClient { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ic_refresh_black_24dp_1x { + get { + object obj = ResourceManager.GetObject("ic_refresh_black_24dp_1x", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized string similar to ID. /// diff --git a/client/OctopusClient/Resources.resx b/client/OctopusClient/Resources.resx index 3e037957..6b1de8e9 100644 --- a/client/OctopusClient/Resources.resx +++ b/client/OctopusClient/Resources.resx @@ -126,6 +126,10 @@ Global ID + + + Resources\ic_refresh_black_24dp_1x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ID diff --git a/client/OctopusClient/Resources/ic_refresh_black_24dp_1x.png b/client/OctopusClient/Resources/ic_refresh_black_24dp_1x.png new file mode 100644 index 00000000..c82efd5f Binary files /dev/null and b/client/OctopusClient/Resources/ic_refresh_black_24dp_1x.png differ