Added 'show key bindings' feature.

This commit is contained in:
Tiberiu Chibici 2014-05-05 11:23:28 +03:00
parent e5c16873d2
commit 4a66734720
14 changed files with 3741 additions and 3616 deletions

View File

@ -1,6 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrumKit", "DrumKit\DrumKit.csproj", "{9A5D3F55-DFD5-45DB-99FF-C82EFCC3294D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tarball", "Tarball\Tarball.csproj", "{5CB567D7-572E-4BAE-802F-7E3F62CDDF64}"

Binary file not shown.

View File

@ -769,13 +769,15 @@
<Setter Property="AutomationProperties.AutomationId" Value="GoAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Go"/>
<Setter Property="Content" Value="&#xE143;"/>
</Style>
</Style> -->
<Style x:Key="KeyboardAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="KeyboardAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Keyboard"/>
<Setter Property="Content" Value="&#xE144;"/>
</Style>
<Style x:Key="DockLeftAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
<!-- <Style x:Key="DockLeftAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="DockLeftAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Dock Left"/>
<Setter Property="Content" Value="&#xE145;"/>

View File

@ -201,6 +201,7 @@
<None Include="Build\ApplicationData\Drumkits\Default\Sounds\TomLow04.wav" />
<None Include="DrumKit_StoreKey.pfx" />
<None Include="DrumKit_TemporaryKey.pfx" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\bg.png" />
@ -281,22 +282,23 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<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, 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>
<ProjectReference Include="..\Tarball\Tarball.csproj">
<Project>{5cb567d7-572e-4bae-802f-7e3f62cddf64}</Project>
<Name>Tarball</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<Reference Include="SharpDX">
<HintPath>..\packages\SharpDX.2.5.0\lib\win8\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.XAudio2">
<HintPath>..\packages\SharpDX.XAudio2.2.5.0\lib\win8\SharpDX.XAudio2.dll</HintPath>
</Reference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>
</PropertyGroup>

View File

@ -9,8 +9,7 @@
d:DesignHeight="300"
d:DesignWidth="400">
<Grid Name="grid" Background="Transparent"
PointerPressed="Grid_PointerPressed">
<Grid Background="Transparent">
<VisualStateManager.VisualStateGroups>
@ -52,6 +51,10 @@
</VisualStateManager.VisualStateGroups>
<Grid Name="grid" Background="Transparent"
PointerPressed="Grid_PointerPressed">
<Image Name="image" IsHitTestVisible="False"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
@ -60,6 +63,26 @@
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Opacity="0" />
</Grid>
<TextBlock Name="textKeyShadow"
Text="{Binding ElementName=textKey, Path=Text}"
Style="{StaticResource TitleTextStyle}"
Foreground="Black"
IsHitTestVisible="False"
VerticalAlignment="Bottom"
HorizontalAlignment="Center"
Margin="2,0,0,13"
Opacity="0.6" />
<TextBlock Name="textKey"
IsHitTestVisible="False"
Style="{StaticResource TitleTextStyle}"
VerticalAlignment="Bottom"
HorizontalAlignment="Center"
Margin="0,0,0,14"
Opacity="0.8" />
</Grid>
</UserControl>

View File

@ -62,11 +62,50 @@ namespace DrumKit
/// <summary>
/// Enables or disables the hit animation.
/// </summary>
private bool IsAnimationEnabled {
get {
private bool IsAnimationEnabled
{
get
{
return DataController.Settings.Animations;
}
}
/// <summary>
/// Sets the key string for display
/// </summary>
public string KeyString
{
set
{
if (!String.IsNullOrEmpty(value))
this.textKey.Text = String.Format("{0} [{1}]", DrumName, value);
else this.textKey.Text = DrumName;
}
}
/// <summary>
/// Gets or sets a value indicating if the key is visible
/// </summary>
public bool IsKeyVisible
{
get
{
return this.textKey.Visibility == Windows.UI.Xaml.Visibility.Visible;
}
set
{
this.textKey.Visibility = (value) ? Visibility.Visible : Visibility.Collapsed;
this.textKeyShadow.Visibility = (value) ? Visibility.Visible : Visibility.Collapsed;
}
}
/// <summary>
/// Gets or sets the drum name
/// </summary>
private string DrumName { get; set; }
#endregion
#region Constructor
@ -82,7 +121,8 @@ namespace DrumKit
// Set drum properties
this.DrumID = drum.Id;
// TODO: key
this.DrumName = drum.Name;
this.KeyString = null;
this.image.Source = drum.LoadedImageSource;
this.imagePressed.Source = drum.LoadedImagePressedSource;
}

View File

@ -82,6 +82,13 @@
Click="ButtonEditMode_Click"
Style="{StaticResource EditAppBarButtonStyle}" />
<ToggleButton
Name="buttonKeys"
Click="buttonKeys_Click"
AutomationProperties.Name="Show keys"
IsChecked="True"
Style="{StaticResource KeyboardAppBarButtonStyle}" />
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" >

View File

@ -79,12 +79,21 @@ namespace DrumKit
{
// Clear previous stuff if any
this.DrumUIs.Clear();
this.Keymap.Clear();
// Load drums
foreach (var i in DataController.CurrentDrumkit.DrumsList)
InitializeDrum(i);
UpdateDrumConfig();
}
/// <summary>
/// Sets up the drum configurations
/// </summary>
private void UpdateDrumConfig()
{
this.Keymap.Clear();
// Load drum configurations
foreach (var i in DataController.CurrentConfig.DrumsList)
{
@ -95,11 +104,18 @@ namespace DrumKit
this.DrumUIs.Remove(i.TargetId);
}
else
{
// Set drum key
this.DrumUIs[i.TargetId].KeyString = UIHelper.GetPrettifiedVKeyName(i.Key);
this.DrumUIs[i.TargetId].IsKeyVisible = DataController.Settings.ShowKeyBindings;
// Keyboard mapping
if (!Keymap.ContainsKey(i.Key))
Keymap.Add(i.Key, i.TargetId);
}
}
}
#endregion
@ -283,6 +299,7 @@ namespace DrumKit
// Set toggles
buttonAnimations.IsChecked = DataController.Settings.Animations;
buttonKeys.IsChecked = DataController.Settings.ShowKeyBindings;
}
/// <summary>
@ -336,6 +353,29 @@ namespace DrumKit
DataController.SaveSettings();
}
/// <summary>
/// Handles the 'show keys' toggle button
/// </summary>
private void buttonKeys_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 setting
DataController.Settings.ShowKeyBindings = isChecked;
// Update UI
UpdateDrumConfig();
// Save modified setting
DataController.SaveSettings();
}
/// <summary>
/// Goes to application settings.
/// </summary>
@ -345,6 +385,5 @@ namespace DrumKit
}
#endregion
}
}

View File

@ -68,7 +68,7 @@
<ToggleButton
Name="toggleEnabled" Grid.Column="0"
Margin="0,-4,20,0" Padding="5,1"
Content="Enabled"
Content="Visible"
Click="ToggleEnabled_Click" />
<TextBlock

View File

@ -106,22 +106,7 @@ namespace DrumKit
if (key != null)
{
if (Enum.IsDefined(typeof(VirtualKey), config.Key))
{
// Get name
string text = Enum.GetName(typeof(VirtualKey), config.Key);
// Prettify the name
if (text.StartsWith("Number"))
text = text.Substring("Number".Length);
text = System.Text.RegularExpressions.Regex.Replace(text, "([a-z])([A-Z])", "${1} ${2}");
// Set the text
key.Text = text;
}
else key.Text = string.Format("Unnamed ({0})", (int)config.Key);
key.Text = UIHelper.GetPrettifiedVKeyName(config.Key);
}
}
}

View File

@ -133,12 +133,12 @@
Grid.Row="10" Grid.Column="1"/>
<!-- Interface section: Key bindings -->
<!--<TextBlock Style="{StaticResource ItemTextStyle}"
<TextBlock Style="{StaticResource ItemTextStyle}"
Grid.Row="11" Margin="2,12,2,2">
Display key bindings</TextBlock>
<ToggleSwitch Name="keyBindingsToggle"
Grid.Row="11" Grid.Column="1"/>-->
Grid.Row="11" Grid.Column="1"/>
<!-- Miscellaneous section -->
<TextBlock Style="{StaticResource MyTitleTextStyle}"

View File

@ -36,14 +36,14 @@ namespace DrumKit
this.masterVolumeSlider.Value = DataController.MasterVolume * 100;
this.polyphonySlider.Value = DataController.Settings.Polyphony;
this.animationsToggle.IsOn = DataController.Settings.Animations;
//this.keyBindingsToggle.IsOn = DataController.Settings.ShowKeyBindings;
this.keyBindingsToggle.IsOn = DataController.Settings.ShowKeyBindings;
this.debuggingModeToggle.IsOn = DataController.Settings.DebugMode;
// Set up events
masterVolumeSlider.ValueChanged += masterVolumeSlider_ValueChanged;
polyphonySlider.ValueChanged += polyphonySlider_ValueChanged;
animationsToggle.Toggled += animationsToggle_Toggled;
//keyBindingsToggle.Toggled += keyBindingsToggle_Toggled;
keyBindingsToggle.Toggled += keyBindingsToggle_Toggled;
buttonWebsite.Click += buttonWebsite_Click;
buttonSupport.Click += buttonSupport_Click;
buttonReset.Click += buttonReset_Click;
@ -68,11 +68,11 @@ namespace DrumKit
DataController.SaveSettings();
}
//private void keyBindingsToggle_Toggled(object sender, RoutedEventArgs e)
//{
// DataController.Settings.ShowKeyBindings = this.keyBindingsToggle.IsOn;
// DataController.SaveSettings();
//}
private void keyBindingsToggle_Toggled(object sender, RoutedEventArgs e)
{
DataController.Settings.ShowKeyBindings = this.keyBindingsToggle.IsOn;
DataController.SaveSettings();
}
private async void buttonWebsite_Click(object sender, RoutedEventArgs e)
{

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.System;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;
@ -51,5 +52,24 @@ namespace DrumKit
return null;
}
public static string GetPrettifiedVKeyName(VirtualKey vkey)
{
if (Enum.IsDefined(typeof(VirtualKey), vkey))
{
// Get name
string text = Enum.GetName(typeof(VirtualKey), vkey);
// Prettify the name
if (text.StartsWith("Number"))
text = text.Substring("Number".Length);
text = System.Text.RegularExpressions.Regex.Replace(text, "([a-z])([A-Z])", "${1} ${2}");
// Set the text
return text;
}
else return string.Format("Unnamed ({0})", (int)vkey);
}
}
}

5
DrumKit/packages.config Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SharpDX" version="2.5.0" targetFramework="win" />
<package id="SharpDX.XAudio2" version="2.5.0" targetFramework="win" />
</packages>