Skip to content

Commit 36d2392

Browse files
Support for warning for infinite loop, localized errors for new generic HTTP code based errors, bug fix in main window and IntelliSense compatibility
"Create Music with AI" is made StreamContent instead of GenerateContent to apply infinite loop warning, localized errors are extended for new generic HTTP code based errors, the bug in "Use keyboard as piano" that still causes to play notes even when "Use keyboard as piano" is disabled is fixed and methods are made IntelliSense compatible.
2 parents 39a2443 + 4f222a1 commit 36d2392

1 file changed

Lines changed: 40 additions & 12 deletions

File tree

NeoBleeper/MainWindow.cs

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4764,7 +4764,7 @@ private void rewindToSavedVersionToolStripMenuItem_Click(object sender, EventArg
47644764
{
47654765
StopPlaying();
47664766
}
4767-
int selectedLine = listViewNotes.SelectedItems.Count > 0 ? listViewNotes.SelectedIndices[0] : -1;
4767+
int visibleLine = GetVisibleIndex();
47684768
if (initialMemento == null)
47694769
{
47704770
MessageForm.Show(Resources.MessageNoSavedVersion, Resources.TextError, MessageBoxButtons.OK, MessageBoxIcon.Error);
@@ -4785,17 +4785,17 @@ private void rewindToSavedVersionToolStripMenuItem_Click(object sender, EventArg
47854785
SetThemeOfListViewItems(); // Set theme of list view items after rewinding if theme when rewinding is different
47864786
if (listViewNotes.Items.Count > 0)
47874787
{
4788-
if (selectedLine != -1 && selectedLine < listViewNotes.Items.Count)
4788+
if (visibleLine != -1 && visibleLine < listViewNotes.Items.Count)
47894789
{
4790-
listViewNotes.EnsureVisible(selectedLine);
4790+
listViewNotes.EnsureVisible(visibleLine);
47914791
}
47924792
else
47934793
{
47944794
listViewNotes.EnsureVisible(listViewNotes.Items.Count - 1);
47954795
}
47964796
}
47974797
// Log states of variables
4798-
Logger.Log($"Rewind to saved version - BPM: {Variables.bpm}, Alt Notes: {Variables.alternatingNoteLength}", Logger.LogTypes.Info);
4798+
Logger.Log($"Rewind to saved version - BPM: {Variables.bpm}, Alt Notes: {Variables.alternatingNoteLength}, Note Silence Ratio: {Variables.noteSilenceRatio}, Time Signature: {Variables.timeSignature}, Octave: {Variables.octave}", Logger.LogTypes.Info);
47994799
}
48004800
catch (Exception ex)
48014801
{
@@ -5331,20 +5331,45 @@ private string LocalizeLengthModsAndArticulations(string standardizedClipboardTe
53315331
.Replace("Fer", Resources.FermataArticulation);
53325332
return localizedText;
53335333
}
5334+
private int GetVisibleIndex()
5335+
{
5336+
if (listViewNotes.Items.Count == 0)
5337+
{
5338+
return -1;
5339+
}
5340+
5341+
// Check if there is a top visible item
5342+
if (listViewNotes.TopItem != null)
5343+
{
5344+
// Get the index of the top visible item
5345+
int topIndex = listViewNotes.TopItem.Index;
5346+
int headerHeight = listViewNotes.Height - listViewNotes.ClientSize.Height;
5347+
5348+
// Calculate the number of fully visible items
5349+
int visibleItemsCount = listViewNotes.ClientSize.Height / listViewNotes.TopItem.Bounds.Height;
5350+
5351+
// Calculate the index of the last visible item
5352+
int lastVisibleIndex = Math.Min((topIndex + visibleItemsCount - 1) - 1, listViewNotes.Items.Count - 1);
5353+
5354+
return lastVisibleIndex;
5355+
}
5356+
5357+
return -1; // Return -1 if no item is visible
5358+
}
53345359
private void undoToolStripMenuItem_Click(object sender, EventArgs e)
53355360
{
53365361
if (isMusicPlaying == true)
53375362
{
53385363
StopPlaying();
53395364
}
5340-
int selectedLine = listViewNotes.SelectedItems.Count > 0 ? listViewNotes.SelectedIndices[0] : -1;
5365+
int visibleLine = GetVisibleIndex();
53415366
commandManager.Undo();
53425367
SetThemeOfListViewItems(); // Set theme of list view items after undoing if theme when undoing is different
53435368
if (listViewNotes.Items.Count > 0)
53445369
{
5345-
if (selectedLine != -1 && selectedLine < listViewNotes.Items.Count)
5370+
if (visibleLine != -1 && visibleLine < listViewNotes.Items.Count)
53465371
{
5347-
listViewNotes.EnsureVisible(selectedLine);
5372+
listViewNotes.EnsureVisible(visibleLine);
53485373
}
53495374
else
53505375
{
@@ -5365,14 +5390,14 @@ private void redoToolStripMenuItem_Click(object sender, EventArgs e)
53655390
{
53665391
StopPlaying();
53675392
}
5368-
int selectedLine = listViewNotes.SelectedItems.Count > 0 ? listViewNotes.SelectedIndices[0] : -1;
5393+
int visibleIndex = GetVisibleIndex();
53695394
commandManager.Redo();
53705395
SetThemeOfListViewItems(); // Set theme of list view items after redoing if theme when redoing is different
53715396
if (listViewNotes.Items.Count > 0)
53725397
{
5373-
if (selectedLine != -1 && selectedLine < listViewNotes.Items.Count)
5398+
if (visibleIndex != -1 && visibleIndex < listViewNotes.Items.Count)
53745399
{
5375-
listViewNotes.EnsureVisible(selectedLine);
5400+
listViewNotes.EnsureVisible(visibleIndex);
53765401
}
53775402
else
53785403
{
@@ -5910,7 +5935,7 @@ public void RestoreVariableValues(int bpmValue, int alternatingNoteLength,
59105935
lbl_note_silence_ratio.Text = Resources.TextPercent.Replace("{number}",
59115936
((int)(noteSilenceRatio * 100)).ToString());
59125937

5913-
Logger.Log($"Values restored: BPM={bpmValue}, Alt Notes={alternatingNoteLength}", Logger.LogTypes.Info);
5938+
Logger.Log($"Values restored: BPM={bpmValue}, Alt Notes={alternatingNoteLength}, Time Sig={timeSignature}, Silence Ratio={noteSilenceRatio}", Logger.LogTypes.Info);
59145939
}
59155940
catch (Exception ex)
59165941
{
@@ -6352,7 +6377,10 @@ private void main_window_KeyDown(object sender, KeyEventArgs e)
63526377
currentlyPressedKeys.Add((int)e.KeyCode);
63536378
if (!isAlternatingPlaying)
63546379
{
6355-
RestartBeepIfMutedEarly(GetFrequencyFromKeyCode((int)e.KeyCode));
6380+
if (checkBox_use_keyboard_as_piano.Checked)
6381+
{
6382+
RestartBeepIfMutedEarly(GetFrequencyFromKeyCode((int)e.KeyCode));
6383+
}
63566384
if (currentlyPressedKeys == pressedKeys)
63576385
{
63586386
// If the key is already pressed, do nothing

0 commit comments

Comments
 (0)