Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 92240eb
Showing
396 changed files
with
56,208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Application | ||
x:Class="Stensel.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Stensel"> | ||
|
||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.ApplicationModel; | ||
using Windows.ApplicationModel.Activation; | ||
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; | ||
|
||
namespace Stensel | ||
{ | ||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
sealed partial class App : Application | ||
{ | ||
/// <summary> | ||
/// Initializes the singleton application object. This is the first line of authored code | ||
/// executed, and as such is the logical equivalent of main() or WinMain(). | ||
/// </summary> | ||
public App() | ||
{ | ||
this.InitializeComponent(); | ||
this.Suspending += OnSuspending; | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when the application is launched normally by the end user. Other entry points | ||
/// will be used such as when the application is launched to open a specific file. | ||
/// </summary> | ||
/// <param name="e">Details about the launch request and process.</param> | ||
protected override void OnLaunched(LaunchActivatedEventArgs e) | ||
{ | ||
Frame rootFrame = Window.Current.Content as Frame; | ||
|
||
// Do not repeat app initialization when the Window already has content, | ||
// just ensure that the window is active | ||
if (rootFrame == null) | ||
{ | ||
// Create a Frame to act as the navigation context and navigate to the first page | ||
rootFrame = new Frame(); | ||
|
||
rootFrame.NavigationFailed += OnNavigationFailed; | ||
|
||
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) | ||
{ | ||
//TODO: Load state from previously suspended application | ||
} | ||
|
||
// Place the frame in the current Window | ||
Window.Current.Content = rootFrame; | ||
} | ||
|
||
if (e.PrelaunchActivated == false) | ||
{ | ||
if (rootFrame.Content == null) | ||
{ | ||
// When the navigation stack isn't restored navigate to the first page, | ||
// configuring the new page by passing required information as a navigation | ||
// parameter | ||
rootFrame.Navigate(typeof(MainPage), e.Arguments); | ||
} | ||
// Ensure the current window is active | ||
Window.Current.Activate(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when Navigation to a certain page fails | ||
/// </summary> | ||
/// <param name="sender">The Frame which failed navigation</param> | ||
/// <param name="e">Details about the navigation failure</param> | ||
void OnNavigationFailed(object sender, NavigationFailedEventArgs e) | ||
{ | ||
throw new Exception("Failed to load Page " + e.SourcePageType.FullName); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when application execution is being suspended. Application state is saved | ||
/// without knowing whether the application will be terminated or resumed with the contents | ||
/// of memory still intact. | ||
/// </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) | ||
{ | ||
var deferral = e.SuspendingOperation.GetDeferral(); | ||
//TODO: Save application state and stop any background activity | ||
deferral.Complete(); | ||
} | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
'Key definitions (Key_Name;Key_X;Key_Y) | ||
#;2;1 | ||
S;2;2 | ||
T;3;1 | ||
K;3;2 | ||
P;4;1 | ||
W;4;2 | ||
H;5;1 | ||
R;5;2 | ||
*;6;1 | ||
-F;7;1 | ||
-R;7;2 | ||
-P;8;1 | ||
-B;8;2 | ||
-L;9;1 | ||
-G;9;2 | ||
-T;10;1 | ||
-S;10;2 | ||
-D;11;1 | ||
-Z;11;2 | ||
A;4;3 | ||
O;5;3 | ||
E;7;3 | ||
U;8;3 | ||
|
||
--- | ||
'Key binds (NOTE;KEY_1,KEY_2,...) | ||
37;# | ||
39;#,S | ||
40;S | ||
41;T | ||
42;T,K | ||
43;K | ||
44;P | ||
45;P,W | ||
46;W | ||
47;H | ||
48;H,R | ||
49;R | ||
50;H,* | ||
51;R,* | ||
52;* | ||
53;A | ||
54;A,O | ||
55;O | ||
|
||
59;E | ||
60;E,U | ||
61;U | ||
62;*,-F | ||
63;-F | ||
64;*,-R | ||
65;-F,-R | ||
66;-R | ||
67;-P | ||
68;-P,-B | ||
69;-B | ||
70;-L | ||
71;-L,-G | ||
72;-G | ||
73;-T | ||
74;-T,-S | ||
75;-S | ||
76;-T,-D | ||
77;-D | ||
78;-S,-Z | ||
79;-D,-Z | ||
80;-Z | ||
82;H,R,* | ||
83;*,-F,-R | ||
84;-T,-S,-D,-Z | ||
|
||
|
||
--- | ||
'Control change bindings ( !NOTE | ||
' UPTO;NOTE_1,NOTE_2,... | ||
' ? ) | ||
--- |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.Storage; | ||
|
||
namespace Stensel | ||
{ | ||
class Layout | ||
{ | ||
public struct LayoutKey | ||
{ | ||
public LayoutKey(int xPos, int yPos, string name) | ||
{ | ||
this.xPos = xPos; | ||
this.yPos = yPos; | ||
this.name = name; | ||
} | ||
|
||
public int xPos; | ||
public int yPos; | ||
public string name; | ||
|
||
public string GetDisplayName() | ||
{ | ||
return name.Replace("-", ""); | ||
} | ||
} | ||
|
||
private Dictionary<byte, string[][]> controlSurfaces = new Dictionary<byte, string[][]>(); | ||
private Dictionary<byte, string[]> noteSurfaces = new Dictionary<byte, string[]>(); | ||
private Dictionary<string, byte> namesToNotes = new Dictionary<string, byte>(); | ||
|
||
public async Task<LayoutKey[]> LoadLayout() | ||
{ | ||
StorageFolder sfold = ApplicationData.Current.LocalFolder; | ||
StorageFile sf = (StorageFile) await sfold.TryGetItemAsync("Stenotype.txt"); | ||
|
||
if (sf == null) | ||
{ | ||
// Copy the file from the install folder to the local folder | ||
var folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets"); | ||
|
||
var file = await folder.GetFileAsync("Stenotype.txt"); | ||
if (file != null) | ||
{ | ||
await file.CopyAsync(sfold, "Stenotype.txt", NameCollisionOption.FailIfExists); | ||
} | ||
|
||
sf = await sfold.GetFileAsync("Stenotype.txt"); | ||
} | ||
|
||
|
||
var fs = File.Open(sf.Path, FileMode.Open); | ||
TextReader tr = new StreamReader(fs); | ||
|
||
List<LayoutKey> ret = new List<LayoutKey>(); | ||
|
||
string line; | ||
|
||
while ((line = tr.ReadLine()) != null) | ||
{ | ||
if (line.Contains("---")) | ||
break; | ||
|
||
if (line.Length > 4 && line[0] != '\'') | ||
{ | ||
string[] parts = line.Split(';'); | ||
|
||
if (parts.Length > 2) | ||
ret.Add(new LayoutKey(int.Parse(parts[1]), int.Parse(parts[2]), parts[0])); | ||
} | ||
} | ||
|
||
// While the list to be returned is already completed, we'll take this moment to read the rest of the data as well | ||
while ((line = tr.ReadLine()) != null) | ||
{ | ||
if (line.Contains("---")) | ||
break; | ||
|
||
if (line.Length > 2 && line[0] != '\'') | ||
{ | ||
string[] parts = line.Split(';'); | ||
|
||
if (parts.Length > 1) | ||
{ | ||
string[] keys = parts[1].Split(','); | ||
noteSurfaces.Add(byte.Parse(parts[0]), keys); | ||
|
||
if(parts.Length == 2) | ||
{ | ||
if(!namesToNotes.ContainsKey(parts[1])) | ||
{ | ||
namesToNotes.Add(parts[1], byte.Parse(parts[0])); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
while ((line = tr.ReadLine()) != null) | ||
{ | ||
if (line.Contains("---")) | ||
break; | ||
|
||
if (line.Length > 0 && line[0] == '!') | ||
{ | ||
string key = line.Substring(1); | ||
if(key.Length > 0) | ||
{ | ||
byte note = byte.Parse(key); | ||
|
||
string[][] noteNames = new string[128][]; | ||
string subline; | ||
int index = 0; | ||
|
||
while ((subline = tr.ReadLine()) != null) | ||
{ | ||
|
||
if(subline.Length > 0) | ||
{ | ||
if (subline[0] == '?') | ||
break; | ||
|
||
string[] parts = subline.Split(';'); | ||
|
||
if (parts.Length > 1) | ||
{ | ||
string[] keys = parts[1].Split(','); | ||
|
||
int upto = int.Parse(parts[0]); | ||
|
||
while (index <= upto) | ||
noteNames[index++] = keys; | ||
} | ||
} | ||
} | ||
|
||
controlSurfaces.Add(note, noteNames); | ||
} | ||
} | ||
} | ||
|
||
return ret.ToArray(); | ||
} | ||
|
||
public string[] GetActiveNoteNames(ChannelRecord[] records) | ||
{ | ||
List<string> ret = new List<string>(); | ||
|
||
foreach(var rec in records) | ||
{ | ||
if (noteSurfaces.ContainsKey(rec.GetNote())) | ||
{ | ||
foreach(string note in noteSurfaces[rec.GetNote()]) | ||
{ | ||
if(!ret.Contains(note)) | ||
{ | ||
ret.Add(note); | ||
} | ||
} | ||
} | ||
else if(controlSurfaces.ContainsKey(rec.GetNote()) && rec.GetLast() > -1) | ||
{ | ||
foreach (string note in controlSurfaces[rec.GetNote()][rec.GetLast()]) | ||
{ | ||
if (!ret.Contains(note)) | ||
{ | ||
ret.Add(note); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return ret.ToArray(); | ||
} | ||
|
||
public byte[] GetActiveNotes(ChannelRecord[] records) | ||
{ | ||
string[] noteNames = GetActiveNoteNames(records); | ||
List<byte> ret = new List<byte>(); | ||
|
||
foreach(string noteName in noteNames) | ||
{ | ||
if (namesToNotes.ContainsKey(noteName) && !ret.Contains(namesToNotes[noteName])) | ||
ret.Add(namesToNotes[noteName]); | ||
} | ||
|
||
return ret.ToArray(); | ||
} | ||
} | ||
} |
Oops, something went wrong.