Skip to content

Commit

Permalink
progress on issues #5 and #7
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoderok committed Jan 6, 2016
1 parent df15518 commit c4d7c3c
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 49 deletions.
36 changes: 36 additions & 0 deletions SampleTestProject/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SampleTestProject")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SampleTestProject")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f0230a17-5be1-4adb-b2b9-39fed6d8b4c8")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
83 changes: 83 additions & 0 deletions SampleTestProject/SampleTestProject.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3A315AD2-E21E-4FC6-A601-795989A45514}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SampleTestProject</RootNamespace>
<AssemblyName>SampleTestProject</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="UnitTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
21 changes: 21 additions & 0 deletions SampleTestProject/UnitTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SampleTestProject
{
[TestClass]
public class UnitTests
{
[TestMethod]
public void TestMethodSuccess()
{
Assert.IsTrue(true);
}

[TestMethod]
public void TestMethodFailure()
{
Assert.IsTrue(false);
}
}
}
6 changes: 6 additions & 0 deletions VsDingExtension.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VsDingExtensionProject", "V
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VsDingExtensionFor2012", "VsDingExtensionFor2012\VsDingExtensionFor2012.csproj", "{F37A5870-9786-4196-A3BE-51FEC6155623}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleTestProject", "SampleTestProject\SampleTestProject.csproj", "{3A315AD2-E21E-4FC6-A601-795989A45514}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -28,6 +30,10 @@ Global
{F37A5870-9786-4196-A3BE-51FEC6155623}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F37A5870-9786-4196-A3BE-51FEC6155623}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F37A5870-9786-4196-A3BE-51FEC6155623}.Release|Any CPU.Build.0 = Release|Any CPU
{3A315AD2-E21E-4FC6-A601-795989A45514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A315AD2-E21E-4FC6-A601-795989A45514}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A315AD2-E21E-4FC6-A601-795989A45514}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A315AD2-E21E-4FC6-A601-795989A45514}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
69 changes: 53 additions & 16 deletions VsDingExtensionProject/Players.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,61 @@
using Microsoft.VisualStudio.Shell;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;

namespace VitaliiGanzha.VsDingExtension
{
public class Players : IDisposable
using System;
using System.Collections.Generic;
using System.IO;
using System.Media;
using Microsoft.VisualStudio.Shell;

public sealed class Players : IDisposable
{
private readonly Dictionary<EventType, IList<SoundPlayer>> eventTypeToSoundPlayerMapping;
private readonly SoundsSelectOptionsPage overridesSettings;
private Dictionary<EventType, IList<SoundPlayer>> eventTypeToSoundPlayerMapping;

public Players(SoundsSelectOptionsPage overridesSettings)
{
this.overridesSettings = overridesSettings;
this.SetupSounds();
}

private void SetupSounds()
{
// Add regular sounds
var tempMapping = new Dictionary<EventType, IList<SoundPlayer>>();
tempMapping[EventType.BuildCompleted] = new List<SoundPlayer>() { new SoundPlayer(Resources.build) };
tempMapping[EventType.BreakpointHit] = new List<SoundPlayer>() { new SoundPlayer(Resources.debug) };
tempMapping[EventType.TestsCompletedSuccess] = new List<SoundPlayer>()
{
new SoundPlayer(Resources.ding)
};
tempMapping[EventType.TestsCompletedFailure] = new List<SoundPlayer>()
{
new SoundPlayer(Resources.test_failed)
};

// Add custom sounds
this.AddSoundOverrideIf(tempMapping, this.overridesSettings.OverrideOnBuildSound, this.overridesSettings.CustomOnBuildSoundLocation, EventType.BuildCompleted);
this.AddSoundOverrideIf(tempMapping, this.overridesSettings.OverrideOnBreakpointHitSound, this.overridesSettings.CustomOnBreakpointHitSoundLocation, EventType.BreakpointHit);
this.AddSoundOverrideIf(tempMapping, this.overridesSettings.OverrideOnTestCompleteFailureSound, this.overridesSettings.CustomOnTestCompleteFailureSoundLocation, EventType.TestsCompletedFailure);
this.AddSoundOverrideIf(tempMapping, this.overridesSettings.OverrideOnTestCompleteSuccesSound, this.overridesSettings.CustomOnTestCompleteSuccesSoundLocation, EventType.TestsCompletedSuccess);

this.eventTypeToSoundPlayerMapping = tempMapping;
}

private void AddSoundOverrideIf(Dictionary<EventType, IList<SoundPlayer>> tempMapping, bool shouldAdd, string fileLocation, EventType eventType)
{
if (shouldAdd)
{
if (!string.IsNullOrWhiteSpace(fileLocation) &&
File.Exists(fileLocation))
{
tempMapping[eventType].Insert(0, new SoundPlayer(fileLocation));
}
}
}

public Players()
public void SoundSettingsChanged()
{
eventTypeToSoundPlayerMapping = new Dictionary<EventType, IList<SoundPlayer>>();
eventTypeToSoundPlayerMapping[EventType.BuildCompleted] = new List<SoundPlayer>() { new SoundPlayer(Resources.build) };
eventTypeToSoundPlayerMapping[EventType.BreakpointHit] = new List<SoundPlayer>() { new SoundPlayer(Resources.debug) };
eventTypeToSoundPlayerMapping[EventType.TestsCompletedSuccess] = new List<SoundPlayer>() { new SoundPlayer(Resources.ding) };
eventTypeToSoundPlayerMapping[EventType.TestsCompletedFailure] = new List<SoundPlayer>() { new SoundPlayer(Resources.test_failed) };
this.SetupSounds();
}

public void PlaySoundSafe(EventType eventType)
Expand Down
17 changes: 13 additions & 4 deletions VsDingExtensionProject/SingleSoundSelectControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ public partial class SingleSoundSelectControl : UserControl
{
private EventType eventType = EventType.None;

public SoundsSelectOptionsPage OptionsPage = null;
public SoundsSelectOptionsPage optionsPage = null;

public SoundsSelectOptionsPage OptionsPage
{
get { return this.optionsPage; }
set
{
this.optionsPage = value;
this.ReadOptions();
this.optionsPage.StoreOptionsNotifier += this.StoreOptions;
this.optionsPage.OnActivateHandler += this.ReadOptions;
}
}

[Category("Data")]
[Description("Gets or sets the event type of the sound to override sound for")]
Expand All @@ -30,13 +42,11 @@ public string BoxTitle
public SingleSoundSelectControl()
{
InitializeComponent();
ReadOptions();
}

private void chkUseDifferentSound_CheckedChanged(object sender, System.EventArgs e)
{
ValidateProperties();
this.StoreOptions();
}

private void btnBrowse_Click(object sender, EventArgs e)
Expand All @@ -52,7 +62,6 @@ private void btnBrowse_Click(object sender, EventArgs e)
if (File.Exists(file))
{
this.selectedFileEdit.Text = file;
this.StoreOptions();
}
}

Expand Down
27 changes: 27 additions & 0 deletions VsDingExtensionProject/SoundsSelectOptionsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public class SoundsSelectOptionsPage : DialogPage

#region Properties

public Action OnApplyHandler { get; set; }

public Action StoreOptionsNotifier { get; set; }

public Action OnActivateHandler { get; set; }

/// <summary>
/// Gets the window an instance of DialogPage that it uses as its user interface.
/// </summary>
Expand Down Expand Up @@ -46,6 +52,27 @@ protected override IWin32Window Window
}
}

protected override void OnApply(DialogPage.PageApplyEventArgs e)
{
if (this.StoreOptionsNotifier != null)
{
this.StoreOptionsNotifier();
}

if (this.OnApplyHandler != null)
{
this.OnApplyHandler();
}
}

protected override void OnActivate(CancelEventArgs cancelEventArgs)
{
if (this.OnActivateHandler != null)
{
this.OnActivateHandler();
}
}

[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public bool OverrideOnBuildSound { get; set; }

Expand Down
Loading

0 comments on commit c4d7c3c

Please sign in to comment.