Skip to content

Commit 16da3cf

Browse files
committed
Fixing some initialization issues, making color easier to persistently customize
1 parent 96aa87e commit 16da3cf

File tree

7 files changed

+47
-33
lines changed

7 files changed

+47
-33
lines changed

TASagentStreamBot.KezBoard/KezboardView.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public KezBoardView(
4040
this.communication = communication;
4141

4242
midiDevices = midiDeviceManager.GetMidiDevices();
43+
44+
PrintInstructions();
45+
}
46+
public override void NotifyStartup()
47+
{
48+
base.NotifyStartup();
49+
4350
bool setDevice = false;
4451

4552
if (!string.IsNullOrEmpty(midiBindingConfig.MidiDevice) && midiDevices.Contains(midiBindingConfig.MidiDevice))
@@ -49,7 +56,7 @@ public KezBoardView(
4956

5057
if (setDevice)
5158
{
52-
communication.SendDebugMessage($"Midi Device connected from settings: {midiBindingConfig.MidiDevice}");
59+
communication.SendDebugMessage($"Midi Device connected from settings: {midiBindingConfig.MidiDevice}\n");
5360
}
5461
}
5562

@@ -60,16 +67,14 @@ public KezBoardView(
6067

6168
if (setDevice)
6269
{
63-
communication.SendDebugMessage($"Midi Device set to first device detected: {midiDevices[0]}");
70+
communication.SendDebugMessage($"Midi Device set to first device detected: {midiDevices[0]}\n");
6471
}
6572
}
6673

6774
if (!setDevice)
6875
{
69-
communication.SendDebugMessage($"No Midi Device detected");
76+
communication.SendDebugMessage($"No Midi Device detected\n");
7077
}
71-
72-
PrintInstructions();
7378
}
7479

7580
private void PrintInstructions()
@@ -81,52 +86,52 @@ private void PrintInstructions()
8186
"\n********* EDIT ***********\n" +
8287
"Press ESCAPE to end binding editing and enable playing.\n" +
8388
"Press A to Add/Edit a binding.\n" +
84-
"Press S to Remove a binding.");
89+
"Press S to Remove a binding.\n");
8590

8691
if (midiBindingConfig.KeyMapping.Count > 0)
8792
{
88-
communication.SendDebugMessage($"Current Bindings:\n{string.Join("\n", midiBindingConfig.KeyMapping.Select(x => $" Key {x.Key} -> {x.Value.ToString()[4..]}"))}");
93+
communication.SendDebugMessage($"Current Bindings:\n{string.Join("\n", midiBindingConfig.KeyMapping.Select(x => $" Key {x.Key} -> {x.Value.ToString()[4..]}"))}\n");
8994
}
9095
else
9196
{
92-
communication.SendDebugMessage($"Current Bindings: NONE");
97+
communication.SendDebugMessage($"Current Bindings: NONE\n");
9398
}
9499
break;
95100

96101
case State.EditingAddBinding:
97102
communication.SendDebugMessage(
98103
"\n********* ADD ***********\n" +
99-
"Press the Midi key to bind, then the keyboard key to bind it to.");
104+
"Press the Midi key to bind, then the keyboard key to bind it to.\n");
100105
break;
101106

102107
case State.EditingRemoveBinding:
103108
communication.SendDebugMessage(
104109
"\n********* REMOVE ***********\n" +
105-
"Press the Midi key to unbind.");
110+
"Press the Midi key to unbind.\n");
106111
break;
107112

108113
case State.Playing:
109114
communication.SendDebugMessage(
110115
"\n********* PLAY ***********\n" +
111116
"Press CTRL-Q to save and quit\n" +
112117
"Press A to Change the current Midi Device.\n" +
113-
"Press S to Edit current bindings.");
118+
"Press S to Edit current bindings.\n");
114119
break;
115120

116121
case State.SettingDevice:
117122
communication.SendDebugMessage(
118123
"\n********* SET DEVICE ***********\n" +
119124
"Press ESCAPE to Abort device selection.\n" +
120-
"Press the NUMBER corresponding to a midi device below to select that device.");
125+
"Press the NUMBER corresponding to a midi device below to select that device.\n");
121126

122127
midiDevices = midiDeviceManager.GetMidiDevices();
123128
if (midiDevices.Count > 0)
124129
{
125-
communication.SendDebugMessage($"Midi Devices:\n{string.Join("\n", midiDevices.Select((x,i) => $" {i+1}) {x}"))}");
130+
communication.SendDebugMessage($"Midi Devices:\n{string.Join("\n", midiDevices.Select((x,i) => $" {i+1}) {x}"))}\n");
126131
}
127132
else
128133
{
129-
communication.SendDebugMessage("Midi Devices: None Detected");
134+
communication.SendDebugMessage("Midi Devices: None Detected\n");
130135
}
131136
break;
132137

@@ -488,6 +493,8 @@ public void HandleKeyDown(int key)
488493
communication.SendDebugMessage($"Key {key} unbound.");
489494
state = State.EditingModeSelection;
490495
PrintInstructions();
496+
497+
midiBindingConfig.Serialize();
491498
}
492499
break;
493500
}

TASagentStreamBot.KezBoard/Program.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898
app.UseAuthorization();
9999
app.UseDefaultFiles();
100100

101+
//Use custom files
102+
app.UseDocumentsOverrideContent();
103+
101104
//Custom Web Assets
102105
app.UseStaticFiles();
103106

@@ -156,12 +159,6 @@
156159

157160
midiKeyboardHandler.BindToCustomBinding(midiBinding);
158161

159-
List<string> midiDevices = midiDeviceManager.GetMidiDevices();
160-
if (midiDevices.Count > 0)
161-
{
162-
midiDeviceManager.UpdateMidiDevice(0, midiDevices[0]);
163-
}
164-
165162
//
166163
// Wait for signal to end application
167164
//
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.Key {
2+
border-color: rgb(0, 0, 0);
3+
border-width: 4px;
4+
}
5+
6+
.WhiteKey {
7+
background-color: rgb(255, 255, 255);
8+
}
9+
10+
.BlackKey {
11+
background-color: rgb(0, 0, 0);
12+
}
13+
14+
.WhiteKey.On {
15+
background-color: rgb(100, 100, 255);
16+
}
17+
18+
.BlackKey.On {
19+
background-color: rgb(50, 50, 155);
20+
}

TASagentStreamBot.KezBoard/wwwroot/Assets/css/pianoDisplay.css

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,22 @@
1818
}
1919

2020
.Key {
21-
border-color: rgb(0, 0, 0);
2221
top: 0px;
2322
display: inline-block;
2423
margin: 0px;
2524
padding: 0px;
2625
border-style: solid;
27-
border-width: 4px;
2826
vertical-align: top;
2927
}
3028

3129
.WhiteKey {
32-
background-color: rgb(255, 255, 255);
3330
width: 38px;
3431
height: 150px;
3532
margin-right: -8px;
3633
margin-left: 0px;
3734
}
3835

3936
.BlackKey {
40-
background-color: rgb(0, 0, 0);
4137
position: relative;
4238
margin-left: 0px;
4339
margin-right: 10px;
@@ -64,12 +60,4 @@
6460

6561
.BlackKeyRight {
6662
left: 2px;
67-
}
68-
69-
.WhiteKey.On {
70-
background-color: rgb(100, 100, 255);
71-
}
72-
73-
.BlackKey.On {
74-
background-color: rgb(50, 50, 155);
7563
}

TASagentStreamBot.KezBoard/wwwroot/BrowserSource/FullPianoDisplay.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<script src="/Assets/libs/jquery/3.6.0/jquery.min.js"></script>
1010
<script src="/Assets/libs/signalr/6.0.0/signalr.min.js"></script>
1111
<link rel="stylesheet" type="text/css" href="/Assets/css/pianoDisplay.css" />
12+
<link rel="stylesheet" type="text/css" href="/Assets/css/pianoColor.css" />
1213
</head>
1314
<body>
1415
<div class="Keyboard">

TASagentStreamBot.KezBoard/wwwroot/BrowserSource/PianoDisplay.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<script src="/Assets/libs/jquery/3.6.0/jquery.min.js"></script>
1010
<script src="/Assets/libs/signalr/6.0.0/signalr.min.js"></script>
1111
<link rel="stylesheet" type="text/css" href="/Assets/css/pianoDisplay.css" />
12+
<link rel="stylesheet" type="text/css" href="/Assets/css/pianoColor.css" />
1213
</head>
1314
<body>
1415
<div class="Keyboard">

TASagentTwitchBotCore

0 commit comments

Comments
 (0)