added test button for custom sounds
This commit is contained in:
parent
879f937517
commit
f60d7f3a1d
|
@ -33,25 +33,27 @@ namespace VitaliiGanzha.VsDingExtension
|
||||||
this.selectedFileEdit = new System.Windows.Forms.TextBox();
|
this.selectedFileEdit = new System.Windows.Forms.TextBox();
|
||||||
this.chkUseDifferentSound = new System.Windows.Forms.CheckBox();
|
this.chkUseDifferentSound = new System.Windows.Forms.CheckBox();
|
||||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||||
|
this.btnTest = new System.Windows.Forms.Button();
|
||||||
this.groupBox.SuspendLayout();
|
this.groupBox.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBox
|
// groupBox
|
||||||
//
|
//
|
||||||
|
this.groupBox.Controls.Add(this.btnTest);
|
||||||
this.groupBox.Controls.Add(this.btnBrowse);
|
this.groupBox.Controls.Add(this.btnBrowse);
|
||||||
this.groupBox.Controls.Add(this.selectedFileEdit);
|
this.groupBox.Controls.Add(this.selectedFileEdit);
|
||||||
this.groupBox.Controls.Add(this.chkUseDifferentSound);
|
this.groupBox.Controls.Add(this.chkUseDifferentSound);
|
||||||
this.groupBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.groupBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.groupBox.Location = new System.Drawing.Point(0, 0);
|
this.groupBox.Location = new System.Drawing.Point(0, 0);
|
||||||
this.groupBox.Name = "groupBox";
|
this.groupBox.Name = "groupBox";
|
||||||
this.groupBox.Size = new System.Drawing.Size(323, 78);
|
this.groupBox.Size = new System.Drawing.Size(323, 66);
|
||||||
this.groupBox.TabIndex = 0;
|
this.groupBox.TabIndex = 0;
|
||||||
this.groupBox.TabStop = false;
|
this.groupBox.TabStop = false;
|
||||||
this.groupBox.Text = "Title";
|
this.groupBox.Text = "Title";
|
||||||
//
|
//
|
||||||
// btnBrowse
|
// btnBrowse
|
||||||
//
|
//
|
||||||
this.btnBrowse.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
this.btnBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.btnBrowse.Location = new System.Drawing.Point(242, 40);
|
this.btnBrowse.Location = new System.Drawing.Point(242, 40);
|
||||||
this.btnBrowse.Name = "btnBrowse";
|
this.btnBrowse.Name = "btnBrowse";
|
||||||
this.btnBrowse.Size = new System.Drawing.Size(75, 23);
|
this.btnBrowse.Size = new System.Drawing.Size(75, 23);
|
||||||
|
@ -64,10 +66,10 @@ namespace VitaliiGanzha.VsDingExtension
|
||||||
//
|
//
|
||||||
this.selectedFileEdit.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
this.selectedFileEdit.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.selectedFileEdit.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.selectedFileEdit.Font = new System.Drawing.Font("Calibri", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.selectedFileEdit.Location = new System.Drawing.Point(6, 40);
|
this.selectedFileEdit.Location = new System.Drawing.Point(6, 40);
|
||||||
this.selectedFileEdit.Name = "selectedFileEdit";
|
this.selectedFileEdit.Name = "selectedFileEdit";
|
||||||
this.selectedFileEdit.Size = new System.Drawing.Size(230, 22);
|
this.selectedFileEdit.Size = new System.Drawing.Size(183, 22);
|
||||||
this.selectedFileEdit.TabIndex = 1;
|
this.selectedFileEdit.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// chkUseDifferentSound
|
// chkUseDifferentSound
|
||||||
|
@ -86,13 +88,24 @@ namespace VitaliiGanzha.VsDingExtension
|
||||||
this.openFileDialog.Filter = "Wav files|*.wav";
|
this.openFileDialog.Filter = "Wav files|*.wav";
|
||||||
this.openFileDialog.Title = "Select custom sound";
|
this.openFileDialog.Title = "Select custom sound";
|
||||||
//
|
//
|
||||||
|
// btnTest
|
||||||
|
//
|
||||||
|
this.btnTest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.btnTest.Location = new System.Drawing.Point(195, 40);
|
||||||
|
this.btnTest.Name = "btnTest";
|
||||||
|
this.btnTest.Size = new System.Drawing.Size(41, 23);
|
||||||
|
this.btnTest.TabIndex = 3;
|
||||||
|
this.btnTest.Text = "Test";
|
||||||
|
this.btnTest.UseVisualStyleBackColor = true;
|
||||||
|
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
|
||||||
|
//
|
||||||
// SingleSoundSelectControl
|
// SingleSoundSelectControl
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.Controls.Add(this.groupBox);
|
this.Controls.Add(this.groupBox);
|
||||||
this.Name = "SingleSoundSelectControl";
|
this.Name = "SingleSoundSelectControl";
|
||||||
this.Size = new System.Drawing.Size(323, 78);
|
this.Size = new System.Drawing.Size(323, 66);
|
||||||
this.groupBox.ResumeLayout(false);
|
this.groupBox.ResumeLayout(false);
|
||||||
this.groupBox.PerformLayout();
|
this.groupBox.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
@ -106,5 +119,6 @@ namespace VitaliiGanzha.VsDingExtension
|
||||||
private System.Windows.Forms.Button btnBrowse;
|
private System.Windows.Forms.Button btnBrowse;
|
||||||
private System.Windows.Forms.TextBox selectedFileEdit;
|
private System.Windows.Forms.TextBox selectedFileEdit;
|
||||||
private System.Windows.Forms.OpenFileDialog openFileDialog;
|
private System.Windows.Forms.OpenFileDialog openFileDialog;
|
||||||
|
private System.Windows.Forms.Button btnTest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ namespace VitaliiGanzha.VsDingExtension
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Media;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
public partial class SingleSoundSelectControl : UserControl
|
public partial class SingleSoundSelectControl : UserControl
|
||||||
|
@ -133,5 +134,33 @@ namespace VitaliiGanzha.VsDingExtension
|
||||||
this.selectedFileEdit.Text = pathToFile;
|
this.selectedFileEdit.Text = pathToFile;
|
||||||
this.chkUseDifferentSound.Checked = useDifferentSound;
|
this.chkUseDifferentSound.Checked = useDifferentSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnTest_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
const string title = "Can't play sound";
|
||||||
|
if (string.IsNullOrWhiteSpace(this.selectedFileEdit.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("No file selected", title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!File.Exists(this.selectedFileEdit.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("File does not exists", title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var player = new SoundPlayer(this.selectedFileEdit.Text))
|
||||||
|
{
|
||||||
|
player.Play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(System.Environment.NewLine + "Error: " + ex.Message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue