Issue #7: Use different sound when tests failed
Issue #5: Custom sounds
This commit is contained in:
parent
9de93268f2
commit
df15518a52
13 changed files with 488 additions and 106 deletions
128
VsDingExtensionProject/SingleSoundSelectControl.cs
Normal file
128
VsDingExtensionProject/SingleSoundSelectControl.cs
Normal file
|
@ -0,0 +1,128 @@
|
|||
namespace VitaliiGanzha.VsDingExtension
|
||||
{
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public partial class SingleSoundSelectControl : UserControl
|
||||
{
|
||||
private EventType eventType = EventType.None;
|
||||
|
||||
public SoundsSelectOptionsPage OptionsPage = null;
|
||||
|
||||
[Category("Data")]
|
||||
[Description("Gets or sets the event type of the sound to override sound for")]
|
||||
public EventType EventType
|
||||
{
|
||||
get { return this.eventType; }
|
||||
set { this.eventType = value; }
|
||||
}
|
||||
|
||||
[Category("Data")]
|
||||
[Description("Gets or sets the title of the group box")]
|
||||
public string BoxTitle
|
||||
{
|
||||
get { return this.groupBox.Text; }
|
||||
set { this.groupBox.Text = value; }
|
||||
}
|
||||
|
||||
public SingleSoundSelectControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
ReadOptions();
|
||||
}
|
||||
|
||||
private void chkUseDifferentSound_CheckedChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
ValidateProperties();
|
||||
this.StoreOptions();
|
||||
}
|
||||
|
||||
private void btnBrowse_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.ValidateProperties();
|
||||
var dialogResult = this.openFileDialog.ShowDialog();
|
||||
if (dialogResult != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var file = openFileDialog.FileName;
|
||||
if (File.Exists(file))
|
||||
{
|
||||
this.selectedFileEdit.Text = file;
|
||||
this.StoreOptions();
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateProperties()
|
||||
{
|
||||
if (this.EventType == EventType.None)
|
||||
{
|
||||
throw new Exception("Event type not initialized");
|
||||
}
|
||||
|
||||
if (this.OptionsPage == null)
|
||||
{
|
||||
throw new Exception("Options Page not initialized");
|
||||
}
|
||||
}
|
||||
|
||||
private void StoreOptions()
|
||||
{
|
||||
var useDifferentSound = this.chkUseDifferentSound.Checked;
|
||||
var pathToFile = this.selectedFileEdit.Text;
|
||||
switch (eventType)
|
||||
{
|
||||
case EventType.BreakpointHit:
|
||||
this.OptionsPage.OverrideOnBreakpointHitSound = useDifferentSound;
|
||||
this.OptionsPage.CustomOnBreakpointHitSoundLocation = pathToFile;
|
||||
break;
|
||||
case EventType.BuildCompleted:
|
||||
this.OptionsPage.OverrideOnBuildSound = useDifferentSound;
|
||||
this.OptionsPage.CustomOnBuildSoundLocation = pathToFile;
|
||||
break;
|
||||
case EventType.TestsCompletedFailure:
|
||||
this.OptionsPage.OverrideOnTestCompleteFailureSound = useDifferentSound;
|
||||
this.OptionsPage.CustomOnTestCompleteFailureSoundLocation = pathToFile;
|
||||
break;
|
||||
case EventType.TestsCompletedSuccess:
|
||||
this.OptionsPage.OverrideOnTestCompleteSuccesSound = useDifferentSound;
|
||||
this.OptionsPage.CustomOnTestCompleteSuccesSoundLocation = pathToFile;
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Invalid Event Type");
|
||||
}
|
||||
}
|
||||
|
||||
public void ReadOptions()
|
||||
{
|
||||
string pathToFile = null;
|
||||
bool useDifferentSound = false;
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
case EventType.BreakpointHit:
|
||||
useDifferentSound = this.OptionsPage.OverrideOnBreakpointHitSound;
|
||||
pathToFile = this.OptionsPage.CustomOnBreakpointHitSoundLocation;
|
||||
break;
|
||||
case EventType.BuildCompleted:
|
||||
useDifferentSound = this.OptionsPage.OverrideOnBuildSound;
|
||||
pathToFile = this.OptionsPage.CustomOnBuildSoundLocation;
|
||||
break;
|
||||
case EventType.TestsCompletedFailure:
|
||||
useDifferentSound = this.OptionsPage.OverrideOnTestCompleteFailureSound;
|
||||
pathToFile = this.OptionsPage.CustomOnTestCompleteFailureSoundLocation;
|
||||
break;
|
||||
case EventType.TestsCompletedSuccess:
|
||||
useDifferentSound = this.OptionsPage.OverrideOnTestCompleteSuccesSound;
|
||||
pathToFile = this.OptionsPage.CustomOnTestCompleteSuccesSoundLocation;
|
||||
break;
|
||||
}
|
||||
|
||||
this.selectedFileEdit.Text = pathToFile;
|
||||
this.chkUseDifferentSound.Checked = useDifferentSound;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue