Build 130105

This commit is contained in:
Tiberiu Chibici 2013-11-18 20:06:17 +02:00
parent 4e0e7d4a83
commit 8954fd2635
82 changed files with 2620 additions and 586 deletions

View File

@ -43,4 +43,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
EndGlobal

BIN
DrumKit.suo Normal file

Binary file not shown.

Binary file not shown.

View File

@ -64,7 +64,7 @@ namespace DrumKit
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
if (!rootFrame.Navigate(typeof(LoadingPage), args.Arguments))
{
throw new Exception("Failed to create initial page");
}
@ -80,10 +80,22 @@ namespace DrumKit
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
private async void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
try {
await DataManager.Close();
}
catch (Exception ex) {
Log.Error("Exception in OnSuspending method!");
Log.Except(ex);
}
Log.Write("Application suspended.");
//TODO:::...
deferral.Complete();
}
}

View File

@ -0,0 +1,328 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Windows.Storage;
namespace DrumKit.Archiving
{
public class TarballReader
{
#region Data types etc
/// <summary>
/// Tarball header structure
/// </summary>
private struct TarballHeader
{
public string FileName;
public uint FileMode;
public uint OwnerId, GroupId;
public int Size;
public DateTime LastModified;
public uint Checksum;
public byte LinkIndicator;
public string LinkedFile;
}
#endregion
#region Private attributes
private Stream stream;
private TarballHeader header;
#endregion
#region Constructor
/// <summary>
/// Creates a new instance of a tarball archive reader.
/// </summary>
public TarballReader()
{
stream = null;
header = new TarballHeader();
}
#endregion
#region Public functions (unpack)
/// <summary>
/// Unpacks a tarball in a temporary folder.
/// </summary>
/// <param name="file">An URI to the tarball file.</param>
/// <returns>Storage folder pointing to where the files were unpacked.</returns>
public async Task<StorageFolder> Unpack (Uri file)
{
var stfile = await StorageFile.GetFileFromApplicationUriAsync(file);
return await this.Unpack(stfile);
}
/// <summary>
/// Unpacks a tarball in a specified folder.
/// </summary>
/// <param name="file">An URI to the tarball file.</param>
/// <param name="destination">A folder where files will be unpacked.</param>
/// <returns>Storage folder pointing to where the files were unpacked.</returns>
public async Task<StorageFolder> Unpack(Uri file, StorageFolder destination)
{
var stfile = await StorageFile.GetFileFromApplicationUriAsync(file);
return await this.Unpack(stfile, destination);
}
/// <summary>
/// Unpacks a tarball in a temporary folder.
/// </summary>
/// <param name="file">A path to the tarball file.</param>
/// <returns>Storage folder pointing to where the files were unpacked.</returns>
public async Task<StorageFolder> Unpack(string file)
{
var stfile = await StorageFile.GetFileFromPathAsync(file);
return await this.Unpack(stfile);
}
/// <summary>
/// Unpacks a tarball in a specified folder.
/// </summary>
/// <param name="file">A path to the tarball file.</param>
/// <param name="destination">A folder where files will be unpacked.</param>
/// <returns>Storage folder pointing to where the files were unpacked.</returns>
public async Task<StorageFolder> Unpack(string file, StorageFolder destination)
{
var stfile = await StorageFile.GetFileFromPathAsync(file);
return await this.Unpack(stfile, destination);
}
/// <summary>
/// Unpacks a tarball in a temporary folder.
/// </summary>
/// <param name="file">The tarball file.</param>
/// <returns>Storage folder pointing to where the files were unpacked.</returns>
public async Task<StorageFolder> Unpack(StorageFile file)
{
// Prepare temp folder
var dest = await this.CreateTempFolder();
// Unpack
await this.Initialize(file);
await this.UnpackFiles(dest);
this.Dispose();
// Results
return dest;
}
/// <summary>
/// Unpacks a tarball in a specified folder.
/// </summary>
/// <param name="file">The tarball file.</param>
/// <param name="destination">A folder where files will be unpacked.</param>
/// <returns>Storage folder pointing to where the files were unpacked.</returns>
public async Task<StorageFolder> Unpack(StorageFile file, StorageFolder destination)
{
// Unpack
await this.Initialize(file);
await this.UnpackFiles(destination);
this.Dispose();
// Results
return destination;
}
#endregion
#region Initialize, dispose
/// <summary>
/// Performs initialization actions before unpacking (such as opening the stream).
/// </summary>
private async Task Initialize(StorageFile file)
{
var str = await file.OpenReadAsync();
this.stream = str.AsStream();
}
/// <summary>
/// Performs cleanups after unpacking finished.
/// </summary>
private void Dispose()
{
// Clean up
this.stream.Dispose();
this.stream = null;
this.header = new TarballHeader();
}
#endregion
#region Headers
/// <summary>
/// Calculates the checksum from a header.
/// </summary>
/// <param name="buffer">The header bytes</param>
private uint CalculateChecksum(byte[] buffer)
{
uint result = 0;
// Calculate sum of all bytes, with the exception of bytes 148-155
// (checksum field). These are all assumed to be 0x20.
for (int i = 0; i < buffer.Length; i++)
if (i >= 148 && i < 156)
result += 0x20;
else result += Convert.ToUInt32(buffer[i]);
// Done
return result;
}
/// <summary>
/// Converts binary data to a TarballHeader.
/// </summary>
private TarballHeader ParseHeaderFields(byte[] buffer)
{
TarballHeader header = new TarballHeader();
string temp;
// File name
temp = SharpDX.Text.ASCIIEncoding.ASCII.GetString(buffer, 0, 100).Trim('\0', ' ');
header.FileName = temp;
// File mode
temp = SharpDX.Text.ASCIIEncoding.ASCII.GetString(buffer, 100, 8).Trim('\0', ' ');
header.FileMode = (string.IsNullOrEmpty(temp)) ? 0 : Convert.ToUInt32(temp, 8);
// Owner id
temp = SharpDX.Text.ASCIIEncoding.ASCII.GetString(buffer, 108, 8).Trim('\0', ' ');
header.OwnerId = (string.IsNullOrEmpty(temp)) ? 0 : Convert.ToUInt32(temp, 8);
// Group id
temp = SharpDX.Text.ASCIIEncoding.ASCII.GetString(buffer, 116, 8).Trim('\0', ' ');
header.GroupId = (string.IsNullOrEmpty(temp)) ? 0 : Convert.ToUInt32(temp, 8);
// Size
temp = SharpDX.Text.ASCIIEncoding.ASCII.GetString(buffer, 124, 12).Trim('\0', ' ');
header.Size = (string.IsNullOrEmpty(temp)) ? 0 : Convert.ToInt32(temp, 8);
// Last modified date
temp = SharpDX.Text.ASCIIEncoding.ASCII.GetString(buffer, 136, 12).Trim('\0', ' ');
int seconds = (string.IsNullOrEmpty(temp)) ? 0 : Convert.ToInt32(temp, 8);
header.LastModified = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(seconds).ToLocalTime();
// Checksum
temp = SharpDX.Text.ASCIIEncoding.ASCII.GetString(buffer, 148, 8).Trim('\0', ' ');
header.Checksum = (string.IsNullOrEmpty(temp)) ? 0 : Convert.ToUInt32(temp, 8);
// Link indicator
header.LinkIndicator = buffer[156];
// Linked file
temp = SharpDX.Text.ASCIIEncoding.ASCII.GetString(buffer, 157, 100).Trim('\0', ' ');
header.LinkedFile = temp;
// Done
return header;
}
/// <summary>
/// Reads a file header.
/// </summary>
/// <returns>True if another header was read, false otherwise.</returns>
private async Task<bool> ReadNextFileHeader()
{
byte[] buffer = new byte[512];
// Check current position
if (stream.Position >= stream.Length)
return false;
// Read header
await stream.ReadAsync(buffer, 0, 512);
// Parse header fields
this.header = this.ParseHeaderFields(buffer);
// Verify checksum
uint checksum = this.CalculateChecksum(buffer);
if (checksum == 256) // If 256 (only the checksum bytes different than 0), then
return false; // we most likely hit an invalid entry, probably marking the
// end of the file
if (checksum != header.Checksum)
throw new IOException("Invalid checksum!");
// Done
return true;
}
#endregion
#region File system helpers
/// <summary>
/// Creates a temporary folder.
/// </summary>
private async Task<StorageFolder> CreateTempFolder()
{
// Generate file name
string name = "tar" + DateTime.Now.Ticks.ToString();
// Create file
var temp = ApplicationData.Current.TemporaryFolder;
return await temp.CreateFolderAsync(name, CreationCollisionOption.GenerateUniqueName);
}
#endregion
#region Unpack
/// <summary>
/// Unpacks a file using the information from the header.
/// The function assumes the header was previously read.
/// </summary>
/// <param name="destination">The destination file.</param>
private async Task UnpackNextFile(StorageFile destination)
{
// Open destination file
var str = await destination.OpenAsync(FileAccessMode.ReadWrite);
var iostr = str.AsStream();
// Write data
var buffer = new byte[512];
int read = 0, total = 0;
while (total < this.header.Size)
{
read = await this.stream.ReadAsync(buffer, 0, 512);
await iostr.WriteAsync(buffer, 0, Math.Min(read, this.header.Size - total));
total += read;
}
// Cleanup
await iostr.FlushAsync();
iostr.Dispose();
}
/// <summary>
/// Unpacks the files from the loaded tarball.
/// </summary>
/// <param name="destination">Destination folder.</param>
private async Task UnpackFiles(StorageFolder destination)
{
if (this.stream == null)
throw new ArgumentNullException("No file opened!");
while (await this.ReadNextFileHeader())
{
// Directory?
if (this.header.FileName.EndsWith("/"))
await IOHelper.CreateFolderRelativeAsync(destination, this.header.FileName);
// Create file
else
{
var file = await IOHelper.CreateFileRelativeAsync(destination, this.header.FileName);
await this.UnpackNextFile(file);
}
}
}
#endregion
}
}

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 515 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 801 B

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -1,40 +0,0 @@
[Kick]
position=.41,.2
size=.3
image=ms-appx:///Assets/Drums/big_drum_of.png
sound,0=ms-appx:///Assets/Sounds/Kick07.wav
[Snare]
position=.16,.34
size=.25
image=ms-appx:///Assets/Drums/drum_of.png
sound,0=ms-appx:///Assets/Sounds/Snare08.wav
[High Tom]
position=.33,.05
size=.22
image=ms-appx:///Assets/Drums/drum_of.png
sound,0=ms-appx:///Assets/Sounds/TomHigh04.wav
[Low Tom]
position=.55,.05
size=.22
image=ms-appx:///Assets/Drums/drum_of.png
sound,0=ms-appx:///Assets/Sounds/TomLow04.wav
[Floor Tom]
position=.66,.44
size=.29
image=ms-appx:///Assets/Drums/drum_of.png
sound,0=ms-appx:///Assets/Sounds/Floor04.wav
[HiHat]
position=.03,.55
size=.21
image=ms-appx:///Assets/Drums/plate_off.png
sound,0=ms-appx:///Assets/Sounds/HiHatOpen04.wav
[Crash]
position=.1,.02
size=.25
image=ms-appx:///Assets/Drums/plate_off.png
sound,0=ms-appx:///Assets/Sounds/Crash05.wav
[Ride]
position=.72,.04
size=.25
image=ms-appx:///Assets/Drums/plate_off.png
sound,0=ms-appx:///Assets/Sounds/Ride04.wav

BIN
DrumKit/Build/7z.exe Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 KiB

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<drumkitConfig>
<drums>
<drumConfig targetId="defaultkick">
<volume>1.0</volume>
<vkey>A</vkey>
</drumConfig>
<drumConfig targetId="defaultsnare">
<volume>1.0</volume>
<vkey>B</vkey>
</drumConfig>
<drumConfig targetId="defaulthitom">
<volume>1.0</volume>
<vkey>C</vkey>
</drumConfig>
<drumConfig targetId="defaultlotom">
<volume>1.0</volume>
<vkey>D</vkey>
</drumConfig>
<drumConfig targetId="defaultfltom">
<volume>1.0</volume>
<vkey>E</vkey>
</drumConfig>
<drumConfig targetId="defaulthihatcl">
<volume>1.0</volume>
<vkey>F</vkey>
</drumConfig>
<drumConfig targetId="defaulthihatop">
<volume>1.0</volume>
<vkey>G</vkey>
</drumConfig>
<drumConfig targetId="defaultcrash">
<volume>1.0</volume>
<vkey>H</vkey>
</drumConfig>
<drumConfig targetId="defaultride">
<volume>1.0</volume>
<vkey>I</vkey>
</drumConfig>
</drums>
</drumkitConfig>

View File

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8" ?>
<drumkit>
<!-- General info -->
<name>Default</name>
<description>Default drums</description>
<!-- Files -->
<configfile>config.xml</configfile>
<layoutfile>layout.xml</layoutfile>
<!-- Drums -->
<drums>
<drum id="defaultkick">
<name>Kick</name>
<image>Images/kick.png</image>
<imagePressed>Images/kickPressed.png</imagePressed>
<sounds>
<sound intensity="0">Sounds/Kick07.wav</sound>
</sounds>
</drum>
<drum id="defaultsnare">
<name>Snare</name>
<image>Images/drum.png</image>
<imagePressed>Images/drumPressed.png</imagePressed>
<sounds>
<sound intensity="0">Sounds/Snare08.wav</sound>
</sounds>
</drum>
<drum id="defaulthitom">
<name>High Tom</name>
<image>Images/drum.png</image>
<imagePressed>Images/drumPressed.png</imagePressed>
<sounds>
<sound intensity="0">Sounds/TomHigh04.wav</sound>
</sounds>
</drum>
<drum id="defaultlotom">
<name>Low Tom</name>
<image>Images/drum.png</image>
<imagePressed>Images/drumPressed.png</imagePressed>
<sounds>
<sound intensity="0">Sounds/TomLow04.wav</sound>
</sounds>
</drum>
<drum id="defaultfltom">
<name>Floor Tom</name>
<image>Images/drum.png</image>
<imagePressed>Images/drumPressed.png</imagePressed>
<sounds>
<sound intensity="0">Sounds/Floor04.wav</sound>
</sounds>
</drum>
<drum id="defaulthihatcl">
<name>Hi-Hat Closed (pedal)</name>
<image>Images/pedal.png</image>
<imagePressed>Images/pedalPressed.png</imagePressed>
<sounds>
<sound intensity="0">Sounds/HiHatClosed04.wav</sound>
</sounds>
</drum>
<drum id="defaulthihatop">
<name>Hi-Hat Opened</name>
<image>Images/plate.png</image>
<imagePressed>Images/platePressed.png</imagePressed>
<sounds>
<sound intensity="0">Sounds/HiHatOpen04.wav</sound>
</sounds>
</drum>
<drum id="defaultcrash">
<name>Crash</name>
<image>Images/plate.png</image>
<imagePressed>Images/platePressed.png</imagePressed>
<sounds>
<sound intensity="0">Sounds/Crash05.wav</sound>
</sounds>
</drum>
<drum id="defaultride">
<name>Ride</name>
<image>Images/plate.png</image>
<imagePressed>Images/platePressed.png</imagePressed>
<sounds>
<sound intensity="0">Sounds/Ride04.wav</sound>
</sounds>
</drum>
</drums>
<!--
[Kick]
position=.41,.2
size=.3
image=ms-appx:///Assets/Drums/big_drum_of.png
sound,0=ms-appx:///Assets/Sounds/Kick07.wav
[Snare]
position=.16,.34
size=.25
image=ms-appx:///Assets/Drums/drum_of.png
sound,0=ms-appx:///Assets/Sounds/Snare08.wav
[High Tom]
position=.33,.05
size=.22
image=ms-appx:///Assets/Drums/drum_of.png
sound,0=ms-appx:///Assets/Sounds/TomHigh04.wav
[Low Tom]
position=.55,.05
size=.22
image=ms-appx:///Assets/Drums/drum_of.png
sound,0=ms-appx:///Assets/Sounds/TomLow04.wav
[Floor Tom]
position=.66,.44
size=.29
image=ms-appx:///Assets/Drums/drum_of.png
sound,0=ms-appx:///Assets/Sounds/Floor04.wav
[Hi-Hat Closed]
position=.10,.87
size=.05
image=ms-appx:///Assets/Drums/HiHat_off.png
sound,0=ms-appx:///Assets/Sounds/HiHatClosed04.wav
[Hi-Hat Opened]
position=.03,.55
size=.21
image=ms-appx:///Assets/Drums/plate_off.png
sound,0=ms-appx:///Assets/Sounds/HiHatOpen04.wav
[Crash]
position=.1,.02
size=.25
image=ms-appx:///Assets/Drums/plate_off.png
sound,0=ms-appx:///Assets/Sounds/Crash05.wav
[Ride]
position=.72,.04
size=.25
image=ms-appx:///Assets/Drums/plate_off.png
sound,0=ms-appx:///Assets/Sounds/Ride04.wav-->
</drumkit>

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8" ?>
<drumkitLayoutCollection>
<items>
<!-- Standard layout - all views -->
<drumkitLayout>
<name>Standard layout</name>
<targetView>Snapped|Landscape|Filled|Portrait</targetView>
<isDefault>true</isDefault>
<drums>
<drumLayout targetId="defaultkick">
<size>.3</size>
<x>.41</x>
<y>.2</y>
<zindex>0</zindex>
</drumLayout>
<drumLayout targetId="defaultsnare">
<size>.25</size>
<x>.16</x>
<y>.34</y>
<zindex>2</zindex>
<angle>61</angle>
</drumLayout>
<drumLayout targetId="defaulthitom">
<size>.22</size>
<x>.33</x>
<y>.05</y>
<zindex>1</zindex>
<angle>150</angle>
</drumLayout>
<drumLayout targetId="defaultlotom">
<size>.22</size>
<x>.55</x>
<y>.05</y>
<zindex>1</zindex>
<angle>150</angle>
</drumLayout>
<drumLayout targetId="defaultfltom">
<size>.29</size>
<x>.66</x>
<y>.44</y>
<zindex>1</zindex>
<angle>-30</angle>
</drumLayout>
<drumLayout targetId="defaulthihatcl">
<size>.055</size>
<x>.11</x>
<y>.89</y>
<zindex>3</zindex>
</drumLayout>
<drumLayout targetId="defaulthihatop">
<size>.21</size>
<x>.03</x>
<y>.55</y>
<zindex>4</zindex>
<angle>80</angle>
</drumLayout>
<drumLayout targetId="defaultcrash">
<size>.26</size>
<x>.1</x>
<y>.02</y>
<zindex>4</zindex>
<angle>80</angle>
</drumLayout>
<drumLayout targetId="defaultride">
<size>.25</size>
<x>.72</x>
<y>.04</y>
<zindex>4</zindex>
</drumLayout>
</drums>
</drumkitLayout>
</items>
</drumkitLayoutCollection>

View File

@ -424,7 +424,13 @@
<Setter Property="Content" Value="&#xE103;"/>
</Style>
<!--
<Style x:Key="VideoAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="VideoAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Video"/>
<Setter Property="Content" Value="&#xE116;"/>
</Style>
<!--
<Style x:Key="SkipBackAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="SkipBackAppBarButton"/>
@ -525,10 +531,7 @@
-->
<!--
<Style x:Key="VideoAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="VideoAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Video"/>
<Setter Property="Content" Value="&#xE116;"/>
</Style>
<Style x:Key="RefreshAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="RefreshAppBarButton"/>

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DrumKit
{
[XmlType("drumkitSettings")]
public class AppSettings
{
[XmlElement("currentKit")]
public string CurrentKit { get; set; }
[XmlElement("showKeys")]
public bool ShowKeyBindings { get; set; }
[XmlElement("animations")]
public bool Animations { get; set; }
public AppSettings()
{
this.CurrentKit = "Default";
this.ShowKeyBindings = false;
this.Animations = true;
}
}
}

53
DrumKit/Domain/Drum.cs Normal file
View File

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DrumKit
{
[XmlType("drum")]
public class Drum
{
#region Public properties
[XmlAttribute("id")]
public string Id { get; set; }
/// <summary>
/// Gets or sets the name of the drum.
/// </summary>
[XmlElement("name")]
public string Name { get; set; }
/// <summary>
/// Gets or sets the image uri.
/// </summary>
[XmlElement("image")]
public string ImageSource { get; set; }
/// <summary>
/// Gets or sets the image uri.
/// </summary>
[XmlElement("imagePressed")]
public string ImagePressedSource { get; set; }
/// <summary>
/// Gets or sets the list of sound sources.
/// </summary>
[XmlArray("sounds")]
public List<SoundSource> Sounds { get; set; }
#endregion
#region Constructor
public Drum()
{
this.Name = null;
this.ImageSource = null;
this.ImagePressedSource = null;
this.Sounds = new List<SoundSource>();
}
#endregion
}
}

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DrumKit
{
[XmlType("drumConfig")]
public class DrumConfig
{
[XmlAttribute("targetId")]
public string TargetId { get; set; }
[XmlElement("enabled")]
public bool IsEnabled { get; set; }
[XmlElement("volume")]
public double Volume {
get {
if (this.VolumeL != this.VolumeR)
return double.NaN;
return this.VolumeL;
}
set {
if (!double.IsNaN(value))
this.VolumeL = this.VolumeR = value;
}
}
[XmlElement("volumeL")]
public double VolumeL { get; set; }
[XmlElement("volumeR")]
public double VolumeR { get; set; }
[XmlElement("vkey")]
public Windows.System.VirtualKey Key { get; set; }
public DrumConfig()
{
this.TargetId = null;
this.Volume = 1.0;
this.IsEnabled = true;
this.Key = Windows.System.VirtualKey.None;
}
}
}

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DrumKit
{
[XmlType("drumLayout")]
public class DrumLayout
{
[XmlAttribute("targetId")]
public string TargetId { get; set; }
[XmlElement("size")]
public double Size { get; set; }
[XmlElement("x")]
public double X { get; set; }
[XmlElement("y")]
public double Y { get; set; }
[XmlElement("zindex")]
public int ZIndex { get; set; }
[XmlElement("angle")]
public double Angle { get; set; }
public DrumLayout()
{
this.TargetId = null;
this.Size = .1;
this.X = 0;
this.Y = 0;
this.ZIndex = 0;
this.Angle = 0;
}
}
}

37
DrumKit/Domain/Drumkit.cs Normal file
View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DrumKit
{
[XmlType("drumkit")]
public class Drumkit
{
[XmlElement("name")]
public string Name { get; set; }
[XmlElement("description")]
public string Description { get; set; }
[XmlElement("configfile")]
public string ConfigFilePath { get; set; }
[XmlElement("layoutfile")]
public string LayoutFilePath { get; set; }
[XmlArray("drums")]
public List<Drum> Drums { get; set; }
public Drumkit()
{
this.Name = null;
this.Description = null;
this.ConfigFilePath = null;
this.LayoutFilePath = null;
this.Drums = new List<Drum>();
}
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DrumKit
{
[XmlType("drumkitConfig")]
public class DrumkitConfig
{
[XmlArray("drums")]
public List<DrumConfig> Drums { get; set; }
}
}

View File

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DrumKit
{
[XmlType("drumkitLayout")]
public class DrumkitLayout
{
[XmlElement("name")]
public string Name { get; set; }
[XmlIgnore()]
public DrumkitLayoutTargetView TargetView { get; set; }
[XmlElement("targetView")]
private string TargetViewSerialize
{
get
{
if (this.TargetView == DrumkitLayoutTargetView.All)
return "All";
if (this.TargetView == DrumkitLayoutTargetView.None)
return "None";
else
{
string str = "";
if ((this.TargetView & DrumkitLayoutTargetView.Filled) != 0)
str += "Filled|";
if ((this.TargetView & DrumkitLayoutTargetView.Landscape) != 0)
str += "Landscape|";
if ((this.TargetView & DrumkitLayoutTargetView.Portrait) != 0)
str += "Portrait|";
if ((this.TargetView & DrumkitLayoutTargetView.Snapped) != 0)
str += "Snapped|";
return str.TrimEnd('|');
}
}
set
{
this.TargetView = DrumkitLayoutTargetView.None;
foreach (var i in value.Split('|'))
switch (i)
{
case "Filled": this.TargetView |= DrumkitLayoutTargetView.Filled; break;
case "Landscape": this.TargetView |= DrumkitLayoutTargetView.Landscape; break;
case "Portrait": this.TargetView |= DrumkitLayoutTargetView.Portrait; break;
case "Snapped": this.TargetView |= DrumkitLayoutTargetView.Snapped; break;
case "All": this.TargetView |= DrumkitLayoutTargetView.All; break;
}
}
}
[XmlElement("isDefault")]
public bool IsDefault { get; set; }
[XmlArray("drums")]
public List<DrumLayout> Drums { get; set; }
public DrumkitLayout()
{
this.Name = null;
this.IsDefault = false;
this.Drums = new List<DrumLayout>();
this.TargetView = DrumkitLayoutTargetView.All;
}
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DrumKit
{
[XmlType("drumkitLayoutCollection")]
public class DrumkitLayoutCollection
{
[XmlArray("items")]
public List<DrumkitLayout> Items { get; set; }
public DrumkitLayoutCollection()
{
this.Items = new List<DrumkitLayout>();
}
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DrumKit
{
[Flags]
public enum DrumkitLayoutTargetView
{
None = 0,
Snapped = 1,
Filled = 2,
Landscape = 4,
Portrait = 8,
All = Snapped | Filled | Landscape | Portrait
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DrumKit
{
[XmlType("sound")]
public class SoundSource
{
[XmlAttribute("intensity")]
public int Intensity { get; set; }
[XmlText()]
public string Source { get; set; }
}
}

View File

@ -1,107 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;
namespace DrumKit
{
class Drum
{
#region Attributes
private Uri imageSource;
private Point position;
private double size;
#endregion
#region Public properties
/// <summary>
/// Gets or sets the name of the drum.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or sets the image uri. If enabled, the image is loaded.
/// </summary>
public Uri ImageSource {
get { return this.imageSource; }
set { this.SetImageSource(value); }
}
/// <summary>
/// Gets or sets the position of the element on the screen.
/// </summary>
public Point Position {
get { return this.position; }
set { this.SetPosition(value); }
}
/// <summary>
/// Gets the size of the image displayed on the screen.
/// </summary>
public double Size {
get { return this.size; }
set { this.size = value; }
}
/// <summary>
/// Sound sources
/// </summary>
public Dictionary<int, Uri> SoundSources
{
get;
private set;
}
#endregion
#region Constructor
public Drum()
{
// Initialize sources
this.SoundSources = new Dictionary<int, Uri>();
this.imageSource = null;
// Set up other vars
this.position = new Point(0, 0);
this.size = 0;
this.Name = "<unnamed>";
}
#endregion
#region Setters
public void SetImageSource(Uri imagesrc)
{
// Set property
this.imageSource = imagesrc;
}
public void SetPosition(Point location)
{
// Set property
this.position = location;
}
public void SetSoundSource(int intensity, Uri source)
{
// Set up sound source
if (this.SoundSources.ContainsKey(intensity))
this.SoundSources[intensity] = source;
else this.SoundSources.Add(intensity, source);
}
#endregion
}
}

View File

@ -12,7 +12,10 @@
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PackageCertificateKeyFile>DrumKit_TemporaryKey.pfx</PackageCertificateKeyFile>
<PackageCertificateKeyFile>DrumKit_StoreKey.pfx</PackageCertificateKeyFile>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<PackageCertificateThumbprint>4FCCD6DD6F5D1EEA43AC26BB8D451F1B54209922</PackageCertificateThumbprint>
<AppxSymbolPackageEnabled>True</AppxSymbolPackageEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -103,46 +106,75 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Drum.cs" />
<Compile Include="MainPage.xaml.cs">
<Compile Include="Archiving\TarballReader.cs" />
<Compile Include="Domain\AppSettings.cs" />
<Compile Include="IOHelper.cs" />
<Compile Include="Log.cs" />
<Compile Include="Managers\DataManager.cs" />
<Compile Include="Domain\Drum.cs" />
<Compile Include="Domain\DrumConfig.cs" />
<Compile Include="Domain\Drumkit.cs" />
<Compile Include="Domain\DrumkitConfig.cs" />
<Compile Include="Domain\DrumkitLayout.cs" />
<Compile Include="Domain\DrumkitLayoutCollection.cs" />
<Compile Include="Domain\DrumkitLayoutTargetView.cs" />
<Compile Include="Domain\DrumLayout.cs" />
<Compile Include="Managers\DrumsManager.cs" />
<Compile Include="Managers\UIManager.cs" />
<Compile Include="UI\DrumUI.cs" />
<Compile Include="UI\LoadingPage.xaml.cs">
<DependentUpon>LoadingPage.xaml</DependentUpon>
</Compile>
<Compile Include="UI\MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Recorder.cs" />
<Compile Include="Repository\DrumRepository.cs" />
<Compile Include="SoundPlayer.cs" />
<Compile Include="Managers\SoundManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SoundPool.cs" />
<Compile Include="Domain\SoundSource.cs" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets\ApplicationData.tar" />
<None Include="Build\7z.exe" />
<None Include="Build\ApplicationData\Drumkits\Default\config.xml" />
<None Include="Build\ApplicationData\Drumkits\Default\drumkit.xml" />
<None Include="Build\ApplicationData\Drumkits\Default\Images\drum.png" />
<None Include="Build\ApplicationData\Drumkits\Default\Images\drumPressed.png" />
<None Include="Build\ApplicationData\Drumkits\Default\Images\kick.png" />
<None Include="Build\ApplicationData\Drumkits\Default\Images\kickPressed.png" />
<None Include="Build\ApplicationData\Drumkits\Default\Images\pedal.png" />
<None Include="Build\ApplicationData\Drumkits\Default\Images\pedalPressed.png" />
<None Include="Build\ApplicationData\Drumkits\Default\Images\plate.png" />
<None Include="Build\ApplicationData\Drumkits\Default\Images\platePressed.png" />
<None Include="Build\ApplicationData\Drumkits\Default\layout.xml" />
<None Include="Build\ApplicationData\Drumkits\Default\Sounds\Crash05.wav" />
<None Include="Build\ApplicationData\Drumkits\Default\Sounds\Floor04.wav" />
<None Include="Build\ApplicationData\Drumkits\Default\Sounds\Hat04.WAV" />
<None Include="Build\ApplicationData\Drumkits\Default\Sounds\HiHatClosed04.wav" />
<None Include="Build\ApplicationData\Drumkits\Default\Sounds\HiHatOpen04.wav" />
<None Include="Build\ApplicationData\Drumkits\Default\Sounds\Kick07.wav" />
<None Include="Build\ApplicationData\Drumkits\Default\Sounds\Ride04.wav" />
<None Include="Build\ApplicationData\Drumkits\Default\Sounds\Snare08.wav" />
<None Include="Build\ApplicationData\Drumkits\Default\Sounds\TomHigh04.wav" />
<None Include="Build\ApplicationData\Drumkits\Default\Sounds\TomLow04.wav" />
<None Include="DrumKit_StoreKey.pfx" />
<None Include="DrumKit_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\bg.png" />
<Content Include="Assets\Drums\big_drum_of.png" />
<Content Include="Assets\Drums\big_drum_on.png" />
<Content Include="Assets\Drums\drum_of.png" />
<Content Include="Assets\Drums\drum_on.png" />
<Content Include="Assets\Sounds\Crash05.wav" />
<Content Include="Assets\Sounds\Hat04.WAV" />
<Content Include="Assets\Sounds\HiHatOpen04.wav" />
<Content Include="Assets\Sounds\Kick07.wav" />
<Content Include="Assets\default">
<SubType>Designer</SubType>
</Content>
<Content Include="Assets\Logos\BadgeIcon.png" />
<Content Include="Assets\Logos\SplashScreen.scale-140.png" />
<Content Include="Assets\Logos\SplashScreen.scale-180.png" />
<Content Include="Assets\Logos\WideLogo.png" />
<Content Include="Assets\Logos\Logo.png" />
<Content Include="Assets\Logos\SmallLogo.png" />
<Content Include="Assets\Logos\SplashScreen.png" />
<Content Include="Assets\Logos\SplashScreen.scale-100.png" />
<Content Include="Assets\Logos\StoreLogo.png" />
<Content Include="Assets\Drums\plate_off.png" />
<Content Include="Assets\Drums\plate_on.png" />
<Content Include="Assets\Sounds\Ride04.wav" />
<Content Include="Assets\Sounds\Snare08.wav" />
<Content Include="Assets\Sounds\TomHigh04.wav" />
<Content Include="Assets\Sounds\Floor04.wav" />
<Content Include="Assets\Sounds\TomLow04.wav" />
<None Include="Package.StoreAssociation.xml" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
@ -153,17 +185,23 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MainPage.xaml">
<Page Include="UI\LoadingPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\MainPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Reference Include="SharpDX">
<HintPath>C:\Users\Tiberiu\Downloads\SharpDX\Bin\Standard-winrt\SharpDX.dll</HintPath>
<Reference Include="SharpDX, Version=2.4.2.0, Culture=neutral, PublicKeyToken=627a3d6d1956f55a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\WebDownloads\SharpDX242\Bin\Signed-winrt\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.XAudio2">
<HintPath>C:\Users\Tiberiu\Downloads\SharpDX\Bin\Standard-winrt\SharpDX.XAudio2.dll</HintPath>
<Reference Include="SharpDX.XAudio2, Version=2.4.2.0, Culture=neutral, PublicKeyToken=627a3d6d1956f55a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\WebDownloads\SharpDX242\Bin\Signed-winrt\SharpDX.XAudio2.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup />
@ -171,6 +209,9 @@
<VisualStudioVersion>11.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>"$(ProjectDir)\Build\7z.exe" a -ttar -y "$(ProjectDir)\Assets\ApplicationData.tar" "$(ProjectDir)\Build\ApplicationData\*"</PreBuildEvent>
</PropertyGroup>
<!-- 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">

View File

@ -3,4 +3,9 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<UseSimulator>False</UseSimulator>
</PropertyGroup>
<PropertyGroup>
<AppxPackageIsForStore>True</AppxPackageIsForStore>
<AppxShowAllApps>True</AppxShowAllApps>
<AppxBuildConfigurationSelection>neutral</AppxBuildConfigurationSelection>
</PropertyGroup>
</Project>

Binary file not shown.

86
DrumKit/IOHelper.cs Normal file
View File

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
namespace DrumKit
{
static class IOHelper
{
/// <summary>
/// Gets a folder using relative path.
/// </summary>
public static async Task<StorageFolder> GetFolderRelativeAsync(StorageFolder root, string path)
{
// Split the path
var splitpath = path.Split(new char[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries);
var currentdir = root;
// Browse to the last folder in the path
for (int i = 0; i < splitpath.Length; i++)
currentdir = await currentdir.GetFolderAsync(splitpath[i]);
// Return file
return currentdir;
}
/// <summary>
/// Gets a file using relative path
/// </summary>
public static async Task<StorageFile> GetFileRelativeAsync(StorageFolder root, string path)
{
// Split the path
var dir = await GetFolderRelativeAsync(root, System.IO.Path.GetDirectoryName(path));
// Return file
return await dir.GetFileAsync(System.IO.Path.GetFileName(path));
}
/// <summary>
/// Creates a folder using relative path.
/// </summary>
public static async Task<StorageFolder> CreateFolderRelativeAsync(StorageFolder root, string path)
{
// Split the path
var splitpath = path.Split(new char[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries);
var currentdir = root;
// Browse to the last folder in the path
for (int i = 0; i < splitpath.Length - 1; i++)
currentdir = await currentdir.GetFolderAsync(splitpath[i]);
// Create folder
return await currentdir.CreateFolderAsync(splitpath.Last(), CreationCollisionOption.ReplaceExisting);
}
/// <summary>
/// Creates a file using a relative path.
/// </summary>
public static async Task<StorageFile> CreateFileRelativeAsync(StorageFolder root, string path)
{
var currentdir = await GetFolderRelativeAsync(root, System.IO.Path.GetDirectoryName(path));
// Create file
return await currentdir.CreateFileAsync(System.IO.Path.GetFileName(path), CreationCollisionOption.ReplaceExisting);
}
/// <summary>
/// Loads an image, and returns an ImageSource (using relative path)
/// </summary>
public static async Task<Windows.UI.Xaml.Media.ImageSource> GetImageAsync(StorageFolder root, string path)
{
// Open file
var file = await GetFileRelativeAsync(root, path);
var stream = await file.OpenReadAsync();
// Get image
var image = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
await image.SetSourceAsync(stream);
// Return result
return image;
}
}
}

63
DrumKit/Log.cs Normal file
View File

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
namespace DrumKit
{
static class Log
{
private static StreamWriter output = null;
public static async Task Initialize()
{
// Create "Logs" folder if not created
var folder = await ApplicationData.Current.RoamingFolder.CreateFolderAsync("AppLogs", CreationCollisionOption.OpenIfExists);
// Create a log file
var file = await folder.CreateFileAsync(DateTime.Now.Ticks.ToString() + ".csv", CreationCollisionOption.GenerateUniqueName);
// Open stream
var stream = await file.OpenAsync(FileAccessMode.ReadWrite);
var iostream = stream.AsStream();
output = new StreamWriter(iostream);
output.AutoFlush = true;
// Write an initial message
Write("Session started");
}
public static void Write(string format, params object[] args)
{
if (output == null) return;
string res = string.Format(format, args);
// Write data
output.WriteLine("{0},Information,{1}", DateTime.Now, res);
}
public static void Error(string format, params object[] args)
{
if (output == null) return;
string res = string.Format(format, args);
// Write data
output.WriteLine("{0},Error,{1}", DateTime.Now, res);
}
public static void Except(Exception ex)
{
if (output == null) return;
// Prepare
string stack = ex.StackTrace.Replace("\n", ",,,,");
// Write data
output.WriteLine("{0},Exception,{1},{2},{3}", DateTime.Now, ex.Message, ex.Source, stack);
}
}
}

View File

@ -1,201 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace DrumKit
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
DrumRepository drumRepo;
SoundPlayer player = new SoundPlayer();
List<Image> uiImages;
List<Button> uiButtons;
List<Thumb> uiThumbs;
public MainPage()
{
this.InitializeComponent();
drumRepo = new DrumRepository();
uiImages = new List<Image>();
uiButtons = new List<Button>();
uiThumbs = new List<Thumb>();
this.InitializeResources();
this.KeyDown += MainPage_KeyDown;
}
void MainPage_KeyDown(object sender, KeyRoutedEventArgs e)
{
string key = Enum.GetName(typeof(Windows.System.VirtualKey), e.Key);
if (key != null && key.Length == 1)
{
int index = Convert.ToInt32(key.ToLower()[0] - 'a');
if (this.uiButtons.Count > index)
this.DrumClicked(this.uiButtons[index], new RoutedEventArgs());
}
}
Image CreateImage(int index, Drum drum)
{
var img = new Image();
var bitmap = new Windows.UI.Xaml.Media.Imaging.BitmapImage(drum.ImageSource);
img.Tag = index.ToString();
img.Source = bitmap;
img.Width = drum.Size * this.ActualWidth;
img.Height = drum.Size * this.ActualWidth;
return img;
}
Button CreateButton(int index, Drum drum)
{
var button = new Button();
button.Tag = index.ToString();
button.Click += DrumClicked;
button.Width = drum.Size * this.ActualWidth;
button.Height = drum.Size * this.ActualWidth;
button.Background = new SolidColorBrush(Windows.UI.Colors.Orange);
button.Opacity = 0;
return button;
}
Thumb CreateThumb(int index, Drum drum)
{
var thumb = new Thumb();
thumb.Tag = index.ToString();
thumb.DragDelta += DrumMoved;
thumb.Width = drum.Size * this.ActualWidth;
thumb.Height = drum.Size * this.ActualWidth;
thumb.Opacity = .3;
thumb.Background = new SolidColorBrush(Windows.UI.Colors.Green);
thumb.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
return thumb;
}
async void InitializeResources()
{
await drumRepo.LoadFile(new Uri("ms-appx:///Assets/default"));
for (int i = 0; i < drumRepo.Drums.Count; i++)
{
var drum = drumRepo.Drums[i];
// Get ui objects
var img = CreateImage(i, drum);
var button = CreateButton(i, drum);
var thumb = CreateThumb(i, drum);
// Set up layout
this.myCanvas.Children.Add(img);
this.myCanvas.Children.Add(button);
this.myCanvas.Children.Add(thumb);
Canvas.SetLeft(img, drum.Position.X * this.ActualWidth);
Canvas.SetLeft(button, drum.Position.X * this.ActualWidth);
Canvas.SetLeft(thumb, drum.Position.X * this.ActualWidth);
Canvas.SetTop(img, drum.Position.Y * this.ActualHeight);
Canvas.SetTop(button, drum.Position.Y * this.ActualHeight);
Canvas.SetTop(thumb, drum.Position.Y * this.ActualHeight);
Canvas.SetZIndex(img, 0);
Canvas.SetZIndex(button, 1);
Canvas.SetZIndex(thumb, 2);
// Add to our list
this.uiImages.Add(img);
this.uiButtons.Add(button);
this.uiThumbs.Add(thumb);
}
// Add drums
this.player.AddDrums(this.drumRepo.Drums);
}
void DrumClicked(object sender, RoutedEventArgs e)
{
var button = sender as Button;
if (button == null) return;
var tag = button.Tag as string;
if (tag == null) return;
int index = int.Parse(tag);
this.player.Play(this.drumRepo.Drums[index].Name + "0");
}
void DrumMoved(object sender, DragDeltaEventArgs e)
{
var thumb = sender as Thumb;
if (thumb == null) return;
var tag = thumb.Tag as string;
if (tag == null) return;
int index = int.Parse(tag);
Canvas.SetLeft(uiImages[index], Canvas.GetLeft(uiImages[index]) + e.HorizontalChange);
Canvas.SetLeft(uiButtons[index], Canvas.GetLeft(uiButtons[index]) + e.HorizontalChange);
Canvas.SetLeft(uiThumbs[index], Canvas.GetLeft(uiThumbs[index]) + e.HorizontalChange);
Canvas.SetTop(uiImages[index], Canvas.GetTop(uiImages[index]) + e.VerticalChange);
Canvas.SetTop(uiButtons[index], Canvas.GetTop(uiButtons[index]) + e.VerticalChange);
Canvas.SetTop(uiThumbs[index], Canvas.GetTop(uiThumbs[index]) + e.VerticalChange);
drumRepo.Drums[index].Position = new Point(drumRepo.Drums[index].Position.X + e.HorizontalChange, drumRepo.Drums[index].Position.Y + e.VerticalChange);
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private async void mybutton_Click_1(object sender, RoutedEventArgs e)
{
var picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.MusicLibrary;
picker.FileTypeFilter.Add("*");
var file = await picker.PickSingleFileAsync();
//blabla.Source = new Uri(file.Path);
//blabla.Play();
}
private void buttonEditMode_Click_1(object sender, RoutedEventArgs e)
{
var button = sender as ToggleButton;
if (button == null) return;
// Fix togglebuton style bug
VisualStateManager.GoToState(button, button.IsChecked.Value ? "Checked" : "Unchecked", false);
// Change visibility of thumbs
bool visible = (buttonEditMode.IsChecked.HasValue && buttonEditMode.IsChecked.Value);
foreach (var i in this.uiThumbs)
if (visible) i.Visibility = Windows.UI.Xaml.Visibility.Visible;
else i.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
}
}
}

View File

@ -0,0 +1,179 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using System.IO;
using Windows.Storage;
namespace DrumKit
{
static class DataManager
{
public static AppSettings Settings { get; private set; }
/// <summary>
/// Checks if this is the first time application was launched.
/// </summary>
public static async Task<bool> IsFirstLaunch()
{
// See if 'installed.xml' exists
var folder = ApplicationData.Current.RoamingFolder;
var files = await folder.GetFilesAsync();
return files.Count(x => x.Name == "installed.xml") == 0;
}
/// <summary>
/// Copies the content of the source folder into the destination folder recursively.
/// </summary>
//private static async Task CopyFolder(StorageFolder source, StorageFolder dest)
//{
// // Copy folders recursively
// var folders = await source.GetFoldersAsync();
// foreach (var i in folders)
// {
// var newfolder = await dest.CreateFolderAsync(i.Name, CreationCollisionOption.OpenIfExists);
// await CopyFolder(i, newfolder);
// }
// // Copy files
// var files = await source.GetFilesAsync();
// foreach (var i in files)
// await i.CopyAsync(dest);
//}
/// <summary>
/// Installs the assets at first launch.
/// </summary>
/// <returns></returns>
private static async Task InstallAssets()
{
// Read content of 'ApplicationData'
var reader = new DrumKit.Archiving.TarballReader();
await reader.Unpack(new Uri("ms-appx:///Assets/ApplicationData.tar"), ApplicationData.Current.RoamingFolder);
}
/// <summary>
/// Creates the 'installed.xml' file.
/// </summary>
/// <returns></returns>
private static async Task MarkInstalled()
{
// Open stream
StorageFile file = await ApplicationData.Current.RoamingFolder.CreateFileAsync("installed.xml");
var stream = await file.OpenAsync(FileAccessMode.ReadWrite);
var iostream = stream.AsStream();
// Generate xml
var writer = System.Xml.XmlWriter.Create(iostream, new System.Xml.XmlWriterSettings() { Async = true, CloseOutput = true });
writer.WriteStartDocument();
writer.WriteStartElement("drumkit");
writer.WriteString(DateTime.UtcNow.ToString());
writer.WriteEndElement();
writer.WriteEndDocument();
// Cleanup
await writer.FlushAsync();
writer.Dispose();
iostream.Dispose();
}
/// <summary>
/// Resets everything to factory settings.
/// The application must be reinitialized after (or closed).
/// </summary>
public static async Task FactoryReset()
{
await ApplicationData.Current.ClearAsync();
}
/// <summary>
/// Loads the settings file.
/// </summary>
public static async Task LoadSettings()
{
// If all else fails, default settings
Settings = new AppSettings();
// Get settings file
var files = await ApplicationData.Current.RoamingFolder.GetFilesAsync();
var sf = files.FirstOrDefault(x => x.Name == "settings.xml");
// File found
if (sf != null)
{
// Open file
var fstream = await sf.OpenReadAsync();
var fstream_net = fstream.AsStream();
// Deserialize
XmlSerializer s = new XmlSerializer(Settings.GetType());
var settings = s.Deserialize(fstream_net) as AppSettings;
// All good
if (settings != null)
Settings = settings;
}
}
/// <summary>
/// Loads the settings file.
/// </summary>
public static async Task SaveSettings()
{
// Get settings file
var file = await ApplicationData.Current.RoamingFolder.CreateFileAsync("settings.xml", CreationCollisionOption.ReplaceExisting);
// Open file
var fstream = await file.OpenAsync(FileAccessMode.ReadWrite);
var fstream_net = fstream.AsStream();
// Serialize
XmlSerializer s = new XmlSerializer(Settings.GetType());
s.Serialize(fstream_net, Settings);
// Cleanup
await fstream_net.FlushAsync();
fstream_net.Dispose();
}
/// <summary>
/// Initializes the application (prepares the application at first launch, loads settings and drums).
/// </summary>
public static async Task Initialize()
{
// Is this the first time the user launches the application?
if (await IsFirstLaunch())
{
// Clean up any junk
await FactoryReset();
// Copy local assets to app data
await InstallAssets();
// Generate 'installed.xml' file
await MarkInstalled();
}
// Load settings
await LoadSettings();
// Load drum packages
}
public static async Task Close()
{
// Save settings
await SaveSettings();
// Save modified layout & stuff
}
}
}

View File

@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using System.IO;
using Windows.Storage;
namespace DrumKit
{
static class DrumsManager
{
private static StorageFolder currentDrumkitKey = null;
private static int currentDrumkitLayoutIndex = -1;
public static Dictionary<StorageFolder, Drumkit> AvailableDrumkits { get; private set; }
public static DrumkitLayoutCollection CurrentDrumkitLayouts { get; private set; }
public static DrumkitConfig CurrentDrumkitConfig { get; private set; }
public static Drumkit CurrentDrumkit
{
get {
return (currentDrumkitKey == null) ? null : AvailableDrumkits[currentDrumkitKey];
}
}
public static StorageFolder CurrentDrumkitLocation
{
get {
return currentDrumkitKey;
}
}
public static DrumkitLayout CurrentDrumkitLayout
{
get {
return (currentDrumkitLayoutIndex == -1) ? null : CurrentDrumkitLayouts.Items[currentDrumkitLayoutIndex];
}
}
private static async Task<object> DeserializeFile(StorageFile file, Type type)
{
// Open manifest file
var stream = await file.OpenReadAsync();
var iostream = stream.AsStream();
// Deserialize
XmlSerializer serializer = new XmlSerializer(type);
return serializer.Deserialize(iostream);
}
private static async Task<Drumkit> LoadDrumkit(StorageFolder f)
{
// Open manifest file
var manifest = await f.GetFileAsync("drumkit.xml");
object dk = await DeserializeFile(manifest, typeof(Drumkit));
return dk as Drumkit;
}
private static async Task FindDrumkits()
{
// Reset list
AvailableDrumkits = new Dictionary<StorageFolder, Drumkit>();
// Get 'drumkits' folder content
var folder = await ApplicationData.Current.RoamingFolder.GetFolderAsync("Drumkits");
var kits = await folder.GetFoldersAsync();
// Load each drumkit
foreach (var i in kits)
{
Drumkit kit = await LoadDrumkit(i);
if (kit != null)
AvailableDrumkits.Add(i, kit);
}
}
private static async Task LoadCurrentDrumkit(string name)
{
// Get it from the list
var current = AvailableDrumkits.FirstOrDefault(x => x.Value.Name == name);
// Doesn't exist? The default should at least exist.
if (current.Equals(default(KeyValuePair<StorageFolder, Drumkit>)))
current = AvailableDrumkits.FirstOrDefault(x => x.Value.Name == "Default");
// Not even default? Get any kit
if (current.Equals(default(KeyValuePair<StorageFolder, Drumkit>)))
current = AvailableDrumkits.FirstOrDefault();
// No drumkit? This is a serious problem
if (current.Equals(default(KeyValuePair<StorageFolder, Drumkit>)))
throw new Exception("No drumkits available.");
currentDrumkitKey = current.Key;
// Load layout and configuration
StorageFile layout = await current.Key.GetFileAsync(current.Value.LayoutFilePath);
CurrentDrumkitLayouts = await DeserializeFile(layout, typeof(DrumkitLayoutCollection)) as DrumkitLayoutCollection;
StorageFile config = await current.Key.GetFileAsync(current.Value.ConfigFilePath);
CurrentDrumkitConfig = await DeserializeFile(config, typeof(DrumkitConfig)) as DrumkitConfig;
}
public static async Task Initialize(AppSettings settings)
{
// Load drumkits
await FindDrumkits();
// Load current drumkit
await LoadCurrentDrumkit(settings.CurrentKit);
}
public static void SetLayout()
{
currentDrumkitLayoutIndex = 0;
}
}
}

View File

@ -0,0 +1,147 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SharpDX;
using SharpDX.XAudio2;
using SharpDX.Multimedia;
using System.IO;
using Windows.Storage;
namespace DrumKit
{
static class SoundManager
{
#region Data types
private class MyWave
{
public AudioBuffer Buffer { get; set; }
public uint[] DecodedPacketsInfo { get; set; }
public WaveFormat WaveFormat { get; set; }
}
#endregion
#region Private attributes
private static XAudio2 xaudio = null;
private static MasteringVoice mvoice = null;
private static Dictionary<string, MyWave> sounds = null;
private static SoundPool soundPool = null;
#endregion
#region Initialization
/// <summary>
/// Initializes the sound manager
/// </summary>
public static void Initialize()
{
xaudio = new XAudio2();
xaudio.StartEngine();
mvoice = new MasteringVoice(xaudio);
sounds = new Dictionary<string, MyWave>();
}
#endregion
#region Unload
/// <summary>
/// Unloads all the sounds
/// </summary>
public static void UnloadAll()
{
if (sounds == null)
return;
sounds.Clear();
}
/// <summary>
/// Unloads the sounds related to a drum.
/// </summary>
/// <param name="drum">The drum which will be unloaded.</param>
public static void UnloadDrum(Drum drum)
{
foreach (var i in drum.Sounds)
sounds.Remove(drum.Id + i.Intensity.ToString());
}
#endregion
#region Load
/// <summary>
/// Adds a sound to the dictionary
/// </summary>
/// <param name="key">A key associated with the sound</param>
/// <param name="file">The file which will be loaded</param>
private static async Task AddSound(string key, StorageFile file)
{
MyWave wave = new MyWave();
// Load file
var stream = await file.OpenReadAsync();
var iostream = stream.AsStream();
var soundStream = new SoundStream(iostream);
var buffer = new AudioBuffer() {
Stream = soundStream,
AudioBytes = (int)soundStream.Length,
Flags = BufferFlags.EndOfStream
};
iostream.Dispose();
// Set up information
wave.Buffer = buffer;
wave.DecodedPacketsInfo = soundStream.DecodedPacketsInfo;
wave.WaveFormat = soundStream.Format;
// Now we can initialize the soundpool
if (soundPool == null)
soundPool = new SoundPool(xaudio, wave.WaveFormat);
// Add to sound list
sounds.Add(key, wave);
}
/// <summary>
/// Loads the sounds associated with a drum
/// </summary>
public static async Task LoadDrum(Drum drum, StorageFolder root)
{
// Load each sound
foreach (var i in drum.Sounds)
{
var file = await IOHelper.GetFileRelativeAsync(root, i.Source);
await AddSound(drum.Id + i.Intensity.ToString(), file);
}
}
/// <summary>
/// Loads every drum in a drumkit.
/// </summary>
public static async Task LoadDrumkit(Drumkit kit, StorageFolder root)
{
// Load each sound
foreach (var i in kit.Drums)
await LoadDrum(i, root);
}
#endregion
#region Play
/// <summary>
/// Plays a sound
/// </summary>
/// <param name="drum_id">The id of the drum</param>
/// <param name="intensity">The intensity</param>
public static void Play(string drum_id, int intensity)
{
// Get wave info
MyWave info = null;
if (!sounds.TryGetValue(drum_id + intensity.ToString(), out info))
return;
// Play
soundPool.PlayBuffer(info.Buffer, info.DecodedPacketsInfo);
}
#endregion
}
}

View File

@ -0,0 +1,183 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
namespace DrumKit
{
static class UIManager
{
private static Dictionary<string, DrumUI> drums;
private static Dictionary<VirtualKey, string> keymap;
public static Canvas TheCanvas { get; private set; }
#region Initialization
/// <summary>
/// Initializes the ui manager
/// </summary>
public static void Initialize()
{
drums = new Dictionary<string, DrumUI>();
keymap = new Dictionary<VirtualKey, string>();
TheCanvas = new Canvas();
}
/// <summary>
/// Loads the ui stuff for drumkit
/// </summary>
public static async Task ReloadDrumkit()
{
// Delete previous
drums.Clear();
keymap.Clear();
// Load drums
foreach (var i in DrumsManager.CurrentDrumkit.Drums)
{
DrumUI drumui = new DrumUI();
await drumui.InitializeDrum(i, DrumsManager.CurrentDrumkitLocation);
drumui.PointerPressed += HandlerDrumPointerPressed;
drumui.DragDelta += HandlerDrumMoved;
TheCanvas.Children.Add(drumui.Element);
drums.Add(i.Id, drumui);
}
}
/// <summary>
/// Updates the layout.
/// </summary>
public static void ReloadLayout()
{
DrumUI drum;
foreach (var i in DrumsManager.CurrentDrumkitLayout.Drums)
if (drums.TryGetValue(i.TargetId, out drum))
drum.UpdateLayout(i, TheCanvas.ActualWidth, TheCanvas.ActualHeight);
}
/// <summary>
/// Updates the configuration.
/// </summary>
public static async Task ReloadConfig()
{
foreach (var i in DrumsManager.CurrentDrumkitConfig.Drums)
{
// Enabled and not loaded
if (i.IsEnabled && !drums.ContainsKey(i.TargetId))
{
Drum drum = DrumsManager.CurrentDrumkit.Drums.FirstOrDefault(x => x.Id == i.TargetId);
if (drum != null)
{
DrumUI drumui = new DrumUI();
await drumui.InitializeDrum(drum, DrumsManager.CurrentDrumkitLocation);
drumui.PointerPressed += HandlerDrumPointerPressed;
drumui.DragDelta += HandlerDrumMoved;
drums.Add(i.TargetId, drumui);
}
}
// Disabled and loaded
else if (!i.IsEnabled && drums.ContainsKey(i.TargetId))
{
TheCanvas.Children.Remove(drums[i.TargetId].Element);
drums.Remove(i.TargetId);
}
// Keyboard mapping
if (!keymap.ContainsKey(i.Key))
keymap.Add(i.Key, i.TargetId);
}
}
#endregion
#region Event handlers
/// <summary>
/// Handles drum hit using mouse/touchpad
/// </summary>
private static void HandlerDrumPointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
var button = sender as FrameworkElement;
var tag = button.Tag as string;
if (tag != null)
HandlerDrumClickedCommon(tag);
}
/// <summary>
/// Handles drum hit using keyboard
/// </summary>
public static void HandlerKeyDown(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.KeyEventArgs args)
{
string drum;
// Key repeat or something
if (args.KeyStatus.WasKeyDown)
return;
// If key in key map, perform "click"
if (keymap.TryGetValue(args.VirtualKey, out drum))
HandlerDrumClickedCommon(drum);
}
/// <summary>
/// Handles drum hit.
/// </summary>
private static void HandlerDrumClickedCommon(string drum_id)
{
SoundManager.Play(drum_id, 0);
if (DataManager.Settings.Animations)
drums[drum_id].Hit();
}
/// <summary>
/// Handles drum movement.
/// </summary>
private static void HandlerDrumMoved(object sender, Windows.UI.Xaml.Controls.Primitives.DragDeltaEventArgs e)
{
var thumb = sender as Thumb;
var tag = thumb.Tag as string;
int drum_index = -1;
if (tag != null)
drum_index = DrumsManager.CurrentDrumkitLayout.Drums.FindIndex(x => x.TargetId == tag);
if (drum_index >= 0)
{
double delta_x = e.HorizontalChange / TheCanvas.ActualWidth;
double delta_y = e.VerticalChange / TheCanvas.ActualHeight;
if (double.IsInfinity(delta_x) || double.IsInfinity(delta_y) || double.IsNaN(delta_x) || double.IsNaN(delta_y))
return;
DrumsManager.CurrentDrumkitLayout.Drums[drum_index].X += delta_x;
DrumsManager.CurrentDrumkitLayout.Drums[drum_index].Y += delta_y;
drums[tag].UpdateLayout(DrumsManager.CurrentDrumkitLayout.Drums[drum_index], TheCanvas.ActualWidth, TheCanvas.ActualHeight);
}
}
#endregion
public static void EnterEdit()
{
foreach (var i in drums)
i.Value.EnableEdit();
}
public static void ExitEdit()
{
foreach (var i in drums)
i.Value.DisableEdit();
}
}
}

View File

@ -0,0 +1,352 @@
<?xml version="1.0" encoding="utf-8"?>
<StoreAssociation xmlns="http://schemas.microsoft.com/appx/2010/storeassociation">
<Publisher>CN=B6F45FE5-D749-4D29-874C-8323B266F3C8</Publisher>
<NamespacePrefix>35555TiberiuChibici</NamespacePrefix>
<PublisherDisplayName>Tiberiu Chibici</PublisherDisplayName>
<GeneratePackageHash>http://www.w3.org/2001/04/xmlenc#sha256</GeneratePackageHash>
<SupportedLocales>
<Language Code="af" InMinimumRequirementSet="false" />
<Language Code="af-za" InMinimumRequirementSet="false" />
<Language Code="am" InMinimumRequirementSet="false" />
<Language Code="am-et" InMinimumRequirementSet="false" />
<Language Code="ar" InMinimumRequirementSet="true" />
<Language Code="ar-ae" InMinimumRequirementSet="true" />
<Language Code="ar-bh" InMinimumRequirementSet="true" />
<Language Code="ar-dz" InMinimumRequirementSet="true" />
<Language Code="ar-eg" InMinimumRequirementSet="true" />
<Language Code="ar-iq" InMinimumRequirementSet="true" />
<Language Code="ar-jo" InMinimumRequirementSet="true" />
<Language Code="ar-kw" InMinimumRequirementSet="true" />
<Language Code="ar-lb" InMinimumRequirementSet="true" />
<Language Code="ar-ly" InMinimumRequirementSet="true" />
<Language Code="ar-ma" InMinimumRequirementSet="true" />
<Language Code="ar-om" InMinimumRequirementSet="true" />
<Language Code="ar-qa" InMinimumRequirementSet="true" />
<Language Code="ar-sa" InMinimumRequirementSet="true" />
<Language Code="ar-sy" InMinimumRequirementSet="true" />
<Language Code="ar-tn" InMinimumRequirementSet="true" />
<Language Code="ar-ye" InMinimumRequirementSet="true" />
<Language Code="as" InMinimumRequirementSet="false" />
<Language Code="as-in" InMinimumRequirementSet="false" />
<Language Code="az-arab" InMinimumRequirementSet="false" />
<Language Code="az-arab-az" InMinimumRequirementSet="false" />
<Language Code="az-cyrl" InMinimumRequirementSet="false" />
<Language Code="az-cyrl-az" InMinimumRequirementSet="false" />
<Language Code="az-latn" InMinimumRequirementSet="false" />
<Language Code="az-latn-az" InMinimumRequirementSet="false" />
<Language Code="be" InMinimumRequirementSet="false" />
<Language Code="be-by" InMinimumRequirementSet="false" />
<Language Code="bg" InMinimumRequirementSet="true" />
<Language Code="bg-bg" InMinimumRequirementSet="true" />
<Language Code="bn" InMinimumRequirementSet="false" />
<Language Code="bn-bd" InMinimumRequirementSet="false" />
<Language Code="bn-in" InMinimumRequirementSet="false" />
<Language Code="bs" InMinimumRequirementSet="false" />
<Language Code="bs-cyrl" InMinimumRequirementSet="false" />
<Language Code="bs-cyrl-ba" InMinimumRequirementSet="false" />
<Language Code="bs-latn" InMinimumRequirementSet="false" />
<Language Code="bs-latn-ba" InMinimumRequirementSet="false" />
<Language Code="ca" InMinimumRequirementSet="false" />
<Language Code="ca-es" InMinimumRequirementSet="false" />
<Language Code="ca-es-valencia" InMinimumRequirementSet="false" />
<Language Code="chr-cher" InMinimumRequirementSet="false" />
<Language Code="chr-cher-us" InMinimumRequirementSet="false" />
<Language Code="chr-latn" InMinimumRequirementSet="false" />
<Language Code="cs" InMinimumRequirementSet="true" />
<Language Code="cs-cz" InMinimumRequirementSet="true" />
<Language Code="cy" InMinimumRequirementSet="false" />
<Language Code="cy-gb" InMinimumRequirementSet="false" />
<Language Code="da" InMinimumRequirementSet="true" />
<Language Code="da-dk" InMinimumRequirementSet="true" />
<Language Code="de" InMinimumRequirementSet="true" />
<Language Code="de-at" InMinimumRequirementSet="true" />
<Language Code="de-ch" InMinimumRequirementSet="true" />
<Language Code="de-de" InMinimumRequirementSet="true" />
<Language Code="de-li" InMinimumRequirementSet="true" />
<Language Code="de-lu" InMinimumRequirementSet="true" />
<Language Code="el" InMinimumRequirementSet="true" />
<Language Code="el-gr" InMinimumRequirementSet="true" />
<Language Code="en" InMinimumRequirementSet="true" />
<Language Code="en-au" InMinimumRequirementSet="true" />
<Language Code="en-bz" InMinimumRequirementSet="true" />
<Language Code="en-ca" InMinimumRequirementSet="true" />
<Language Code="en-gb" InMinimumRequirementSet="true" />
<Language Code="en-hk" InMinimumRequirementSet="true" />
<Language Code="en-id" InMinimumRequirementSet="true" />
<Language Code="en-ie" InMinimumRequirementSet="true" />
<Language Code="en-in" InMinimumRequirementSet="true" />
<Language Code="en-jm" InMinimumRequirementSet="true" />
<Language Code="en-kz" InMinimumRequirementSet="true" />
<Language Code="en-mt" InMinimumRequirementSet="true" />
<Language Code="en-my" InMinimumRequirementSet="true" />
<Language Code="en-nz" InMinimumRequirementSet="true" />
<Language Code="en-ph" InMinimumRequirementSet="true" />
<Language Code="en-pk" InMinimumRequirementSet="true" />
<Language Code="en-sg" InMinimumRequirementSet="true" />
<Language Code="en-tt" InMinimumRequirementSet="true" />
<Language Code="en-us" InMinimumRequirementSet="true" />
<Language Code="en-vn" InMinimumRequirementSet="true" />
<Language Code="en-za" InMinimumRequirementSet="true" />
<Language Code="es" InMinimumRequirementSet="true" />
<Language Code="es-ar" InMinimumRequirementSet="true" />
<Language Code="es-bo" InMinimumRequirementSet="true" />
<Language Code="es-cl" InMinimumRequirementSet="true" />
<Language Code="es-co" InMinimumRequirementSet="true" />
<Language Code="es-cr" InMinimumRequirementSet="true" />
<Language Code="es-do" InMinimumRequirementSet="true" />
<Language Code="es-ec" InMinimumRequirementSet="true" />
<Language Code="es-es" InMinimumRequirementSet="true" />
<Language Code="es-gt" InMinimumRequirementSet="true" />
<Language Code="es-hn" InMinimumRequirementSet="true" />
<Language Code="es-mx" InMinimumRequirementSet="true" />
<Language Code="es-ni" InMinimumRequirementSet="true" />
<Language Code="es-pa" InMinimumRequirementSet="true" />
<Language Code="es-pe" InMinimumRequirementSet="true" />
<Language Code="es-pr" InMinimumRequirementSet="true" />
<Language Code="es-py" InMinimumRequirementSet="true" />
<Language Code="es-sv" InMinimumRequirementSet="true" />
<Language Code="es-us" InMinimumRequirementSet="true" />
<Language Code="es-uy" InMinimumRequirementSet="true" />
<Language Code="es-ve" InMinimumRequirementSet="true" />
<Language Code="et" InMinimumRequirementSet="true" />
<Language Code="et-ee" InMinimumRequirementSet="true" />
<Language Code="eu" InMinimumRequirementSet="false" />
<Language Code="eu-es" InMinimumRequirementSet="false" />
<Language Code="fa" InMinimumRequirementSet="false" />
<Language Code="fa-ir" InMinimumRequirementSet="false" />
<Language Code="fi" InMinimumRequirementSet="true" />
<Language Code="fi-fi" InMinimumRequirementSet="true" />
<Language Code="fil" InMinimumRequirementSet="false" />
<Language Code="fil-latn" InMinimumRequirementSet="false" />
<Language Code="fil-ph" InMinimumRequirementSet="false" />
<Language Code="fr" InMinimumRequirementSet="true" />
<Language Code="fr-015" InMinimumRequirementSet="true" />
<Language Code="fr-be" InMinimumRequirementSet="true" />
<Language Code="fr-ca" InMinimumRequirementSet="true" />
<Language Code="fr-cd" InMinimumRequirementSet="true" />
<Language Code="fr-ch" InMinimumRequirementSet="true" />
<Language Code="fr-ci" InMinimumRequirementSet="true" />
<Language Code="fr-cm" InMinimumRequirementSet="true" />
<Language Code="fr-fr" InMinimumRequirementSet="true" />
<Language Code="fr-ht" InMinimumRequirementSet="true" />
<Language Code="fr-lu" InMinimumRequirementSet="true" />
<Language Code="fr-ma" InMinimumRequirementSet="true" />
<Language Code="fr-mc" InMinimumRequirementSet="true" />
<Language Code="fr-ml" InMinimumRequirementSet="true" />
<Language Code="fr-re" InMinimumRequirementSet="true" />
<Language Code="frc-latn" InMinimumRequirementSet="true" />
<Language Code="frp-latn" InMinimumRequirementSet="true" />
<Language Code="ga" InMinimumRequirementSet="false" />
<Language Code="ga-ie" InMinimumRequirementSet="false" />
<Language Code="gd-gb" InMinimumRequirementSet="false" />
<Language Code="gd-latn" InMinimumRequirementSet="false" />
<Language Code="gl" InMinimumRequirementSet="false" />
<Language Code="gl-es" InMinimumRequirementSet="false" />
<Language Code="gu" InMinimumRequirementSet="false" />
<Language Code="gu-in" InMinimumRequirementSet="false" />
<Language Code="ha-latn" InMinimumRequirementSet="false" />
<Language Code="ha-latn-ng" InMinimumRequirementSet="false" />
<Language Code="he" InMinimumRequirementSet="true" />
<Language Code="he-il" InMinimumRequirementSet="true" />
<Language Code="hi" InMinimumRequirementSet="true" />
<Language Code="hi-in" InMinimumRequirementSet="true" />
<Language Code="hr" InMinimumRequirementSet="true" />
<Language Code="hr-ba" InMinimumRequirementSet="true" />
<Language Code="hr-hr" InMinimumRequirementSet="true" />
<Language Code="hu" InMinimumRequirementSet="true" />
<Language Code="hu-hu" InMinimumRequirementSet="true" />
<Language Code="hy" InMinimumRequirementSet="false" />
<Language Code="hy-am" InMinimumRequirementSet="false" />
<Language Code="id" InMinimumRequirementSet="true" />
<Language Code="id-id" InMinimumRequirementSet="true" />
<Language Code="ig-latn" InMinimumRequirementSet="false" />
<Language Code="ig-ng" InMinimumRequirementSet="false" />
<Language Code="is" InMinimumRequirementSet="false" />
<Language Code="is-is" InMinimumRequirementSet="false" />
<Language Code="it" InMinimumRequirementSet="true" />
<Language Code="it-ch" InMinimumRequirementSet="true" />
<Language Code="it-it" InMinimumRequirementSet="true" />
<Language Code="iu-cans" InMinimumRequirementSet="false" />
<Language Code="iu-latn" InMinimumRequirementSet="false" />
<Language Code="iu-latn-ca" InMinimumRequirementSet="false" />
<Language Code="ja" InMinimumRequirementSet="true" />
<Language Code="ja-jp" InMinimumRequirementSet="true" />
<Language Code="ka" InMinimumRequirementSet="false" />
<Language Code="ka-ge" InMinimumRequirementSet="false" />
<Language Code="kk" InMinimumRequirementSet="false" />
<Language Code="kk-kz" InMinimumRequirementSet="false" />
<Language Code="km" InMinimumRequirementSet="false" />
<Language Code="km-kh" InMinimumRequirementSet="false" />
<Language Code="kn" InMinimumRequirementSet="false" />
<Language Code="kn-in" InMinimumRequirementSet="false" />
<Language Code="ko" InMinimumRequirementSet="true" />
<Language Code="ko-kr" InMinimumRequirementSet="true" />
<Language Code="kok" InMinimumRequirementSet="false" />
<Language Code="kok-in" InMinimumRequirementSet="false" />
<Language Code="ku-arab" InMinimumRequirementSet="false" />
<Language Code="ku-arab-iq" InMinimumRequirementSet="false" />
<Language Code="ky-cyrl" InMinimumRequirementSet="false" />
<Language Code="ky-kg" InMinimumRequirementSet="false" />
<Language Code="lb" InMinimumRequirementSet="false" />
<Language Code="lb-lu" InMinimumRequirementSet="false" />
<Language Code="lt" InMinimumRequirementSet="true" />
<Language Code="lt-lt" InMinimumRequirementSet="true" />
<Language Code="lv" InMinimumRequirementSet="true" />
<Language Code="lv-lv" InMinimumRequirementSet="true" />
<Language Code="mi" InMinimumRequirementSet="false" />
<Language Code="mi-latn" InMinimumRequirementSet="false" />
<Language Code="mi-nz" InMinimumRequirementSet="false" />
<Language Code="mk" InMinimumRequirementSet="false" />
<Language Code="mk-mk" InMinimumRequirementSet="false" />
<Language Code="ml" InMinimumRequirementSet="false" />
<Language Code="ml-in" InMinimumRequirementSet="false" />
<Language Code="mn-cyrl" InMinimumRequirementSet="false" />
<Language Code="mn-mn" InMinimumRequirementSet="false" />
<Language Code="mn-mong" InMinimumRequirementSet="false" />
<Language Code="mn-phag" InMinimumRequirementSet="false" />
<Language Code="mr" InMinimumRequirementSet="false" />
<Language Code="mr-in" InMinimumRequirementSet="false" />
<Language Code="ms" InMinimumRequirementSet="false" />
<Language Code="ms-bn" InMinimumRequirementSet="false" />
<Language Code="ms-my" InMinimumRequirementSet="false" />
<Language Code="mt" InMinimumRequirementSet="false" />
<Language Code="mt-mt" InMinimumRequirementSet="false" />
<Language Code="nb" InMinimumRequirementSet="true" />
<Language Code="nb-no" InMinimumRequirementSet="true" />
<Language Code="ne" InMinimumRequirementSet="false" />
<Language Code="ne-np" InMinimumRequirementSet="false" />
<Language Code="nl" InMinimumRequirementSet="true" />
<Language Code="nl-be" InMinimumRequirementSet="true" />
<Language Code="nl-nl" InMinimumRequirementSet="true" />
<Language Code="nn" InMinimumRequirementSet="false" />
<Language Code="nn-no" InMinimumRequirementSet="false" />
<Language Code="no" InMinimumRequirementSet="true" />
<Language Code="no-no" InMinimumRequirementSet="true" />
<Language Code="nso" InMinimumRequirementSet="false" />
<Language Code="nso-za" InMinimumRequirementSet="false" />
<Language Code="or" InMinimumRequirementSet="false" />
<Language Code="or-in" InMinimumRequirementSet="false" />
<Language Code="pa" InMinimumRequirementSet="false" />
<Language Code="pa-arab" InMinimumRequirementSet="false" />
<Language Code="pa-arab-pk" InMinimumRequirementSet="false" />
<Language Code="pa-deva" InMinimumRequirementSet="false" />
<Language Code="pa-in" InMinimumRequirementSet="false" />
<Language Code="pl" InMinimumRequirementSet="true" />
<Language Code="pl-pl" InMinimumRequirementSet="true" />
<Language Code="prs" InMinimumRequirementSet="false" />
<Language Code="prs-af" InMinimumRequirementSet="false" />
<Language Code="prs-arab" InMinimumRequirementSet="false" />
<Language Code="pt" InMinimumRequirementSet="true" />
<Language Code="pt-br" InMinimumRequirementSet="true" />
<Language Code="pt-pt" InMinimumRequirementSet="true" />
<Language Code="quc-latn" InMinimumRequirementSet="false" />
<Language Code="qut" InMinimumRequirementSet="false" />
<Language Code="qut-gt" InMinimumRequirementSet="false" />
<Language Code="qut-latn" InMinimumRequirementSet="false" />
<Language Code="quz" InMinimumRequirementSet="false" />
<Language Code="quz-bo" InMinimumRequirementSet="false" />
<Language Code="quz-ec" InMinimumRequirementSet="false" />
<Language Code="quz-pe" InMinimumRequirementSet="false" />
<Language Code="ro" InMinimumRequirementSet="true" />
<Language Code="ro-ro" InMinimumRequirementSet="true" />
<Language Code="ru" InMinimumRequirementSet="true" />
<Language Code="ru-ru" InMinimumRequirementSet="true" />
<Language Code="rw" InMinimumRequirementSet="false" />
<Language Code="rw-rw" InMinimumRequirementSet="false" />
<Language Code="sd-arab" InMinimumRequirementSet="false" />
<Language Code="sd-arab-pk" InMinimumRequirementSet="false" />
<Language Code="sd-deva" InMinimumRequirementSet="false" />
<Language Code="si" InMinimumRequirementSet="false" />
<Language Code="si-lk" InMinimumRequirementSet="false" />
<Language Code="sk" InMinimumRequirementSet="true" />
<Language Code="sk-sk" InMinimumRequirementSet="true" />
<Language Code="sl" InMinimumRequirementSet="true" />
<Language Code="sl-si" InMinimumRequirementSet="true" />
<Language Code="sq" InMinimumRequirementSet="false" />
<Language Code="sq-al" InMinimumRequirementSet="false" />
<Language Code="sr-cyrl" InMinimumRequirementSet="false" />
<Language Code="sr-cyrl-ba" InMinimumRequirementSet="false" />
<Language Code="sr-cyrl-cs" InMinimumRequirementSet="false" />
<Language Code="sr-cyrl-me" InMinimumRequirementSet="false" />
<Language Code="sr-cyrl-rs" InMinimumRequirementSet="false" />
<Language Code="sr-latn" InMinimumRequirementSet="true" />
<Language Code="sr-latn-ba" InMinimumRequirementSet="true" />
<Language Code="sr-latn-cs" InMinimumRequirementSet="true" />
<Language Code="sr-latn-me" InMinimumRequirementSet="true" />
<Language Code="sr-latn-rs" InMinimumRequirementSet="true" />
<Language Code="sv" InMinimumRequirementSet="true" />
<Language Code="sv-fi" InMinimumRequirementSet="true" />
<Language Code="sv-se" InMinimumRequirementSet="true" />
<Language Code="sw" InMinimumRequirementSet="false" />
<Language Code="sw-ke" InMinimumRequirementSet="false" />
<Language Code="ta" InMinimumRequirementSet="false" />
<Language Code="ta-in" InMinimumRequirementSet="false" />
<Language Code="te" InMinimumRequirementSet="false" />
<Language Code="te-in" InMinimumRequirementSet="false" />
<Language Code="tg-arab" InMinimumRequirementSet="false" />
<Language Code="tg-cyrl" InMinimumRequirementSet="false" />
<Language Code="tg-cyrl-tj" InMinimumRequirementSet="false" />
<Language Code="tg-latn" InMinimumRequirementSet="false" />
<Language Code="th" InMinimumRequirementSet="true" />
<Language Code="th-th" InMinimumRequirementSet="true" />
<Language Code="ti" InMinimumRequirementSet="false" />
<Language Code="ti-et" InMinimumRequirementSet="false" />
<Language Code="tk-cyrl" InMinimumRequirementSet="false" />
<Language Code="tk-latn" InMinimumRequirementSet="false" />
<Language Code="tk-tm" InMinimumRequirementSet="false" />
<Language Code="tk-tr" InMinimumRequirementSet="false" />
<Language Code="tn" InMinimumRequirementSet="false" />
<Language Code="tn-bw" InMinimumRequirementSet="false" />
<Language Code="tn-za" InMinimumRequirementSet="false" />
<Language Code="tr" InMinimumRequirementSet="true" />
<Language Code="tr-tr" InMinimumRequirementSet="true" />
<Language Code="tt-arab" InMinimumRequirementSet="false" />
<Language Code="tt-cyrl" InMinimumRequirementSet="false" />
<Language Code="tt-latn" InMinimumRequirementSet="false" />
<Language Code="tt-ru" InMinimumRequirementSet="false" />
<Language Code="ug-arab" InMinimumRequirementSet="false" />
<Language Code="ug-cn" InMinimumRequirementSet="false" />
<Language Code="ug-cyrl" InMinimumRequirementSet="false" />
<Language Code="ug-latn" InMinimumRequirementSet="false" />
<Language Code="uk" InMinimumRequirementSet="true" />
<Language Code="uk-ua" InMinimumRequirementSet="true" />
<Language Code="ur" InMinimumRequirementSet="false" />
<Language Code="ur-pk" InMinimumRequirementSet="false" />
<Language Code="uz-cyrl" InMinimumRequirementSet="false" />
<Language Code="uz-latn" InMinimumRequirementSet="false" />
<Language Code="uz-latn-uz" InMinimumRequirementSet="false" />
<Language Code="vi" InMinimumRequirementSet="false" />
<Language Code="vi-vn" InMinimumRequirementSet="false" />
<Language Code="wo" InMinimumRequirementSet="false" />
<Language Code="wo-sn" InMinimumRequirementSet="false" />
<Language Code="xh" InMinimumRequirementSet="false" />
<Language Code="xh-za" InMinimumRequirementSet="false" />
<Language Code="yo-latn" InMinimumRequirementSet="false" />
<Language Code="yo-ng" InMinimumRequirementSet="false" />
<Language Code="zh-cn" InMinimumRequirementSet="true" />
<Language Code="zh-hans" InMinimumRequirementSet="true" />
<Language Code="zh-hans-cn" InMinimumRequirementSet="true" />
<Language Code="zh-hans-sg" InMinimumRequirementSet="true" />
<Language Code="zh-hant" InMinimumRequirementSet="true" />
<Language Code="zh-hant-hk" InMinimumRequirementSet="true" />
<Language Code="zh-hant-mo" InMinimumRequirementSet="true" />
<Language Code="zh-hant-tw" InMinimumRequirementSet="true" />
<Language Code="zh-hk" InMinimumRequirementSet="true" />
<Language Code="zh-tw" InMinimumRequirementSet="true" />
<Language Code="zu" InMinimumRequirementSet="false" />
<Language Code="zu-za" InMinimumRequirementSet="false" />
</SupportedLocales>
<ProductReservedInfo>
<MainPackageIdentityName>35555TiberiuChibici.DrumKit</MainPackageIdentityName>
<ReservedNames>
<ReservedName>DrumKit</ReservedName>
</ReservedNames>
</ProductReservedInfo>
<AccountPackageIdentityNames />
<PackageInfoList LandingUrl="https://appdev.microsoft.com:443/StorePortals/Developer/Catalog/ReleaseAnchor/a07735fd-3955-4470-aa48-5356c8ae5c91">
<PackageInfo>
<PackageArchitecture>neutral</PackageArchitecture>
<PackageMaxArchitectureVersion>1.0.0.6</PackageMaxArchitectureVersion>
</PackageInfo>
</PackageInfoList>
</StoreAssociation>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
<Identity Name="9e797bd6-ff19-4416-8ec8-f371d6d86244" Publisher="CN=Tiberiu" Version="1.0.0.0" />
<Identity Name="35555TiberiuChibici.DrumKit" Publisher="CN=B6F45FE5-D749-4D29-874C-8323B266F3C8" Version="1.1.0.14" />
<Properties>
<DisplayName>DrumKit</DisplayName>
<PublisherDisplayName>Tiberiu</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
<PublisherDisplayName>Tiberiu Chibici</PublisherDisplayName>
<Logo>Assets\Logos\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.2.1</OSMinVersion>
@ -15,21 +15,14 @@
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="DrumKit.App">
<VisualElements DisplayName="DrumKit" Logo="Assets\Logos\Logo.png" SmallLogo="Assets\Logos\SmallLogo.png" Description="DrumKit" ForegroundText="light" BackgroundColor="#464646">
<DefaultTile ShowName="allLogos" />
<VisualElements DisplayName="DrumKit" Logo="Assets\Logos\Logo.png" SmallLogo="Assets\Logos\SmallLogo.png" Description="DrumKit" ForegroundText="light" BackgroundColor="#164646" ToastCapable="false">
<DefaultTile ShowName="allLogos" WideLogo="Assets\Logos\WideLogo.png" />
<SplashScreen Image="Assets\Logos\SplashScreen.png" />
<InitialRotationPreference>
<Rotation Preference="landscape" />
<Rotation Preference="landscapeFlipped" />
</InitialRotationPreference>
</VisualElements>
<Extensions>
<Extension Category="windows.backgroundTasks" EntryPoint="DrumKit">
<BackgroundTasks>
<Task Type="audio" />
</BackgroundTasks>
</Extension>
</Extensions>
</Application>
</Applications>
</Package>

View File

@ -6,50 +6,50 @@ using System.Threading.Tasks;
namespace DrumKit
{
class Recorder
{
private SortedDictionary<double, Uri> hits;
private DateTime begin;
//class Recorder
//{
// private SortedDictionary<double, Uri> hits;
// private DateTime begin;
public bool IsRecording { get; private set; }
// public bool IsRecording { get; private set; }
public Recorder()
{
this.IsRecording = false;
this.begin = new DateTime();
this.hits = new SortedDictionary<double, Uri>();
}
// public Recorder()
// {
// this.IsRecording = false;
// this.begin = new DateTime();
// this.hits = new SortedDictionary<double, Uri>();
// }
public void Start()
{
this.IsRecording = true;
begin = DateTime.Now;
}
// public void Start()
// {
// this.IsRecording = true;
// begin = DateTime.Now;
// }
public void Add(Uri uri)
{
if (!IsRecording)
return;
// public void Add(Uri uri)
// {
// if (!IsRecording)
// return;
var time = DateTime.Now - this.begin;
this.hits.Add(time.TotalMilliseconds, uri);
}
// var time = DateTime.Now - this.begin;
// this.hits.Add(time.TotalMilliseconds, uri);
// }
public void Stop()
{
this.IsRecording = false;
}
// public void Stop()
// {
// this.IsRecording = false;
// }
public void Play()
{
SoundPlayer player = new SoundPlayer();
// public void Play()
// {
// SoundPlayer player = new SoundPlayer();
var sounduris = this.hits.Values.Distinct();
foreach (var i in sounduris)
player.AddWave(i.AbsolutePath, i.AbsolutePath);
// var sounduris = this.hits.Values.Distinct();
// foreach (var i in sounduris)
// player.AddWave(i.AbsolutePath, i.AbsolutePath);
}
}
// }
//}
}

View File

@ -1,76 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
namespace DrumKit
{
class DrumRepository
{
public List<Drum> Drums { get; private set; }
public DrumRepository()
{
this.Drums = new List<Drum>();
}
public async Task LoadFile(Uri path)
{
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(path);
IList<string> lines = await FileIO.ReadLinesAsync(file);
Drum drum = null;
double x, y;
foreach (var i in lines)
{
var clean = i.Trim(' ', '\t', '\r', '\n');
// New drum
if (clean[0] == '[')
{
if (drum != null)
this.Drums.Add(drum);
drum = new Drum();
drum.Name = clean.Substring(1, clean.Length - 2);
}
// Attribute
else if (drum != null)
{
var split = clean.Split(new char[] { '=', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
switch (split[0])
{
case "position":
x = double.Parse(split[1]);
y = double.Parse(split[2]);
drum.Position = new Windows.Foundation.Point(x, y);
break;
case "size":
x = double.Parse(split[1]);
drum.Size = x;
break;
case "image":
drum.ImageSource = new Uri(split[1]);
break;
case "sound":
if (split.Length == 2)
drum.SetSoundSource(0, new Uri(split[1]));
else drum.SetSoundSource(int.Parse(split[1]), new Uri(split[2]));
break;
}
}
}
if (drum != null)
this.Drums.Add(drum);
}
}
}

View File

@ -1,72 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SharpDX;
using SharpDX.XAudio2;
using SharpDX.IO;
using SharpDX.Multimedia;
namespace DrumKit
{
class SoundPlayer
{
private XAudio2 xaudio;
private MasteringVoice mvoice;
Dictionary<string, MyWave> sounds;
SoundPool pool;
public SoundPlayer()
{
xaudio = new XAudio2();
xaudio.StartEngine();
mvoice = new MasteringVoice(xaudio);
sounds = new Dictionary<string, MyWave>();
}
public void AddWave(string key, string filepath)
{
MyWave wave = new MyWave();
var nativeFileStream = new NativeFileStream(filepath, NativeFileMode.Open, NativeFileAccess.Read, NativeFileShare.Read);
var soundStream = new SoundStream(nativeFileStream);
var buffer = new AudioBuffer() { Stream = soundStream, AudioBytes = (int)soundStream.Length, Flags = BufferFlags.EndOfStream };
wave.Buffer = buffer;
wave.DecodedPacketsInfo = soundStream.DecodedPacketsInfo;
wave.WaveFormat = soundStream.Format;
this.sounds.Add(key, wave);
}
public void AddDrums(IEnumerable<Drum> drums)
{
foreach (var d in drums)
foreach (var s in d.SoundSources)
{
string key = d.Name + s.Key.ToString();
string path = s.Value.AbsolutePath.TrimStart('\\', '/');
this.AddWave(key, path);
}
}
public void Play(string key)
{
if (!this.sounds.ContainsKey(key)) return;
MyWave w = this.sounds[key];
if (pool == null)
pool = new SoundPool(xaudio, w.WaveFormat);
pool.PlayBuffer(w.Buffer, w.DecodedPacketsInfo);
}
}
class MyWave
{
public AudioBuffer Buffer { get; set; }
public uint[] DecodedPacketsInfo { get; set; }
public WaveFormat WaveFormat { get; set; }
}
}

178
DrumKit/UI/DrumUI.cs Normal file
View File

@ -0,0 +1,178 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Media.Imaging;
namespace DrumKit
{
class DrumUI
{
#region Private attributes
private Thumb thumb;
private Image image, imagePressed;
private Grid grid;
private Storyboard hitAnimation;
#endregion
#region Public properties
/// <summary>
/// Gets the ui element which will be put in a canvas.
/// </summary>
public FrameworkElement Element { get { return grid; } }
/// <summary>
/// Gets the drum id.
/// </summary>
public string DrumID { get; private set; }
public event Windows.UI.Xaml.Input.PointerEventHandler PointerPressed
{
add {
grid.PointerPressed += value;
}
remove {
grid.PointerPressed -= value;
}
}
public event DragDeltaEventHandler DragDelta
{
add {
thumb.DragDelta += value;
}
remove {
thumb.DragDelta -= value;
}
}
#endregion
#region Initialization
private void GridAddChild(FrameworkElement element)
{
grid.Children.Add(element);
element.HorizontalAlignment = HorizontalAlignment.Stretch;
element.VerticalAlignment = VerticalAlignment.Stretch;
}
private void InitializeCreateObjects()
{
// Create thumb
this.thumb = new Thumb()
{
Background = new SolidColorBrush(Colors.Green),
Opacity = .3,
Visibility = Visibility.Collapsed
};
// Create image
this.image = new Image();
// Create pressed image
this.imagePressed = new Image()
{
Opacity = 0
};
// Create grid
this.grid = new Grid();
// Create animation
DoubleAnimation fade = new DoubleAnimation();
fade.Duration = TimeSpan.FromSeconds(.6);
fade.From = 1;
fade.To = 0;
Storyboard.SetTarget(fade, this.imagePressed);
Storyboard.SetTargetProperty(fade, "Opacity");
this.hitAnimation = new Storyboard();
this.hitAnimation.Children.Add(fade);
// grid.Resources.Add("hitanimation", this.hitAnimation);
}
private void InitializeParenting()
{
this.GridAddChild(this.image);
this.GridAddChild(this.imagePressed);
this.GridAddChild(this.thumb);
}
public async Task InitializeDrum(Drum drum, StorageFolder root)
{
// Set path
Uri rootpath = new Uri(root.Path);
// Set drum id
this.DrumID = drum.Id;
// Set images
this.image.Source = await IOHelper.GetImageAsync(root, drum.ImageSource);
this.imagePressed.Source = await IOHelper.GetImageAsync(root, drum.ImagePressedSource);
// Set tags
this.thumb.Tag = drum.Id;
this.grid.Tag = drum.Id;
}
#endregion
public DrumUI()
{
// Create objects
this.InitializeCreateObjects();
this.InitializeParenting();
}
public void UpdateLayout(DrumLayout layout, double canvasWidth, double canvasHeight)
{
// Set up size
this.grid.Width = layout.Size * canvasWidth;
this.grid.Height = layout.Size * canvasWidth;
// Set up position
Canvas.SetLeft(this.grid, layout.X * canvasWidth);
Canvas.SetTop(this.grid, layout.Y * canvasHeight);
Canvas.SetZIndex(this.grid, layout.ZIndex);
// Rotation
RotateTransform transform = new RotateTransform();
transform.Angle = layout.Angle;
transform.CenterX = this.grid.Width / 2;
transform.CenterY = this.grid.Height / 2;
this.image.RenderTransform = transform;
this.imagePressed.RenderTransform = transform;
}
public void Hit()
{
// Perform a drum hit
this.hitAnimation.Begin();
}
public void EnableEdit()
{
// Thumb becomes visible
this.thumb.Visibility = Visibility.Visible;
}
public void DisableEdit()
{
// Thumb becomes invisible
this.thumb.Visibility = Visibility.Collapsed;
}
}
}

View File

@ -0,0 +1,30 @@
<Page
x:Class="DrumKit.LoadingPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DrumKit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="#164646">
<Grid HorizontalAlignment="Center"
VerticalAlignment="Center">
<Image Source="ms-appx:///Assets/Logos/SplashScreen.png"
Stretch="None"/>
</Grid>
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Orientation="Horizontal"
Margin="20">
<ProgressRing Width="40" Height="40" IsActive="True" Foreground="White" />
<TextBlock
Name="TextLoading"
Style="{StaticResource SubheaderTextStyle}" Margin="10,0,0,0">
Loading resources...</TextBlock>
</StackPanel>
</Grid>
</Page>

View File

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace DrumKit
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class LoadingPage : Page
{
public LoadingPage()
{
this.InitializeComponent();
this.Loaded += LoadingPage_Loaded;
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private async void LoadingPage_Loaded(object sender, RoutedEventArgs e)
{
// Perform initializations
try
{
TextLoading.Text = "Loading data...";
await DataManager.Initialize();
await Log.Initialize();
await DrumsManager.Initialize(DataManager.Settings);
TextLoading.Text = "Loading sounds...";
SoundManager.Initialize();
await SoundManager.LoadDrumkit(DrumsManager.CurrentDrumkit, DrumsManager.CurrentDrumkitLocation);
TextLoading.Text = "Loading interface...";
UIManager.Initialize();
await UIManager.ReloadDrumkit();
await UIManager.ReloadConfig();
Frame.Navigate(typeof(MainPage));
}
// Error handling
catch (Exception ex)
{
TextLoading.Text = "Failure: " + ex.Message;
Log.Error("Failure during loading!");
Log.Except(ex);
}
}
}
}

View File

@ -6,6 +6,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Transitions>
<TransitionCollection>
<EntranceThemeTransition />
</TransitionCollection>
</Page.Transitions>
<Grid
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
@ -13,12 +18,9 @@
<Image Source="ms-appx:///Assets/bg.png"
Stretch="UniformToFill"/>
<Canvas
Name="myCanvas" >
<Grid Name="canvasContainer" />
</Canvas>
<Grid>
<Grid Visibility="Collapsed">
<Border Margin="7"
CornerRadius="10"
BorderBrush="Red"
@ -63,10 +65,19 @@
<Page.BottomAppBar>
<AppBar>
<StackPanel Orientation="Horizontal">
<ToggleButton
Name="buttonAnimations"
Click="buttonAnimations_Click"
AutomationProperties.Name="Animations"
IsChecked="True"
Style="{StaticResource VideoAppBarButtonStyle}" />
<ToggleButton
Name="buttonEditMode"
Click="buttonEditMode_Click_1"
Click="buttonEditMode_Click"
Style="{StaticResource EditAppBarButtonStyle}" />
</StackPanel>
</AppBar>
</Page.BottomAppBar>

View File

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.ApplicationSettings;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace DrumKit
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.SizeChanged += MainPage_SizeChanged;
this.Loaded += MainPage_Loaded;
this.canvasContainer.Children.Add(UIManager.TheCanvas);
}
void MainPage_SizeChanged(object sender, SizeChangedEventArgs e)
{
// TODO: Find best layout, and change it
DrumsManager.SetLayout();
UIManager.ReloadLayout();
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
// Set layout
DrumsManager.SetLayout();
UIManager.ReloadLayout();
// Set toggles
buttonAnimations.IsChecked = DataManager.Settings.Animations;
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Window.Current.CoreWindow.KeyDown += UIManager.HandlerKeyDown;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
Window.Current.CoreWindow.KeyDown -= UIManager.HandlerKeyDown;
}
private void buttonEditMode_Click(object sender, RoutedEventArgs e)
{
var button = sender as ToggleButton;
if (button == null) return;
bool isChecked = (button.IsChecked.HasValue && button.IsChecked.Value);
// Fix togglebuton style bug
VisualStateManager.GoToState(button, isChecked ? "Checked" : "Unchecked", false);
// Change visibility of thumbs
if (isChecked) UIManager.EnterEdit();
else UIManager.ExitEdit();
}
private void buttonAnimations_Click(object sender, RoutedEventArgs e)
{
var button = sender as ToggleButton;
if (button == null) return;
bool isChecked = (button.IsChecked.HasValue && button.IsChecked.Value);
// Fix togglebuton style bug
VisualStateManager.GoToState(button, isChecked ? "Checked" : "Unchecked", false);
// Change animation setting
DataManager.Settings.Animations = isChecked;
}
}
}

BIN
DrumKit130103.vspx Normal file

Binary file not shown.

BIN
DrumKitApplication.suo Normal file

Binary file not shown.

BIN
promo-414x180.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
promo-414x468.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
promo-558x756.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
promo-846x468.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB