Skip to content

Commit abbd73a

Browse files
Support for warning for infinite loop, localized errors for new generic HTTP code based errors 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 and methods are made IntelliSense compatible.
2 parents 9b978b5 + 59fbcaa commit abbd73a

3 files changed

Lines changed: 165 additions & 1 deletion

File tree

BeepStopper/MainWindow.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ private void ThemeManager_ThemeChanged(object? sender, EventArgs e)
4444

4545
int themeIndex = 0;
4646

47+
/// <summary>
48+
/// Applies the current application theme based on the selected theme index and system settings.
49+
/// </summary>
50+
/// <remarks>If the theme index is set to automatic, the method selects a light or dark theme
51+
/// according to the system's current theme preference. Otherwise, it applies the explicitly selected light or
52+
/// dark theme. This method updates the internal theme state to match the applied theme.</remarks>
4753
private void SetTheme()
4854
{
4955
switch (Program.themeIndex)

BeepStopper/Program.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,28 @@ static void Main()
7171
ThemeManager.Cleanup();
7272
Debug.WriteLine("Beep stopper application has exited.");
7373
}
74+
75+
/// <summary>
76+
/// Loads application settings from the synchronized settings source and applies the theme and language
77+
/// preferences.
78+
/// </summary>
79+
/// <remarks>This method updates the application's theme and language based on the current
80+
/// synchronized settings. It should be called during application startup or when settings need to be
81+
/// refreshed.</remarks>
7482
private static void LoadSettings()
7583
{
7684
var SynchronizedSettings = NeoBleeper.SynchronizedSettings.Load(false);
7785
themeIndex = SynchronizedSettings.Theme;
7886
UIHelper.SetLanguageByName(SynchronizedSettings.Language);
7987
Debug.WriteLine($"Beep stopper is starting with language: {SynchronizedSettings.Language}");
8088
}
89+
90+
/// <summary>
91+
/// Checks if InpOutx64.dll is present and valid; if not, places the DLL file from embedded resources.
92+
/// </summary>
93+
/// <remarks> This method ensures that the InpOutx64.dll file is available in the application's base directory.
94+
/// If the file is missing or corrupted, it writes the DLL from the embedded resources to the file system.
95+
/// </remarks>
8196
private static void CheckAndPlaceInpOutX64()
8297
{
8398
var inpOutX64File = NeoBleeper.Properties.Resources.inpoutx64; // InpOutx64.dll binary resource
@@ -101,6 +116,15 @@ private static void CheckAndPlaceInpOutX64()
101116
Debug.WriteLine("InpOutx64.dll already exists and valid. No action needed.");
102117
}
103118
}
119+
120+
/// <summary>
121+
/// Determines whether the InpOutx64.dll file is present in the application's base directory and matches the
122+
/// expected SHA256 hash.
123+
/// </summary>
124+
/// <remarks>This method verifies both the presence and integrity of InpOutx64.dll by comparing
125+
/// its SHA256 hash to a known good value. Use this check before attempting to interact with the DLL to ensure
126+
/// compatibility and prevent potential errors due to tampering or corruption.</remarks>
127+
/// <returns>true if InpOutx64.dll exists and its SHA256 hash matches the embedded reference; otherwise, false.</returns>
104128
private static bool IsInpOutX64PresentAndValid() // Check if InpOutx64.dll is present and valid by comparing SHA256 hash
105129
{
106130
var inpOutX64Path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "InpOutx64.dll");

NeoBleeper/SettingsWindow.cs

Lines changed: 135 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,12 @@ private void PlayMinuetInG()
782782
NotePlayer.PlayOnlySystemSpeakerBeep(note[0], note[1]);
783783
}
784784
}
785+
786+
/// <summary>
787+
/// Plays the melody of "Greensleeves" using system speaker beeps.
788+
/// </summary>
789+
/// <remarks>This method plays a fixed sequence of notes corresponding to the melody. The playback
790+
/// uses the system speaker and may not be supported on all platforms or hardware configurations.</remarks>
785791
private void PlayGreensleeves()
786792
{
787793
int[][] melody = new int[][]
@@ -800,6 +806,12 @@ private void PlayGreensleeves()
800806
NotePlayer.PlayOnlySystemSpeakerBeep(note[0], note[1]);
801807
}
802808
}
809+
810+
/// <summary>
811+
/// Plays the melody of "Row, Row, Row Your Boat" using system speaker beeps.
812+
/// </summary>
813+
/// <remarks>This method plays a fixed sequence of notes corresponding to the melody. The playback
814+
/// uses the system speaker and may not be supported on all platforms or hardware configurations.</remarks>
803815
private void PlayRowRowRowYourBoat()
804816
{
805817
int[][] melody = new int[][]
@@ -819,7 +831,12 @@ private void PlayRowRowRowYourBoat()
819831
}
820832
}
821833

822-
834+
/// <summary>
835+
/// Plays the melody of the song "Jingle Bells" using system speaker beeps.
836+
/// </summary>
837+
/// <remarks>This method plays a sequence of tones corresponding to the main theme of "Jingle
838+
/// Bells" through the system speaker. The method is intended for simple audio feedback and does not support
839+
/// advanced playback features or audio output devices beyond the system speaker.</remarks>
823840
private void PlayJingleBells()
824841
{
825842
int[][] melody = new int[][]
@@ -842,6 +859,13 @@ private void PlayJingleBells()
842859
NotePlayer.PlayOnlySystemSpeakerBeep(note[0], note[1]);
843860
}
844861
}
862+
863+
/// <summary>
864+
/// Plays the melody of "Mary Had a Little Lamb" using system speaker beeps.
865+
/// </summary>
866+
/// <remarks>This method plays a sequence of tones corresponding to the notes of the song "Mary
867+
/// Had a Little Lamb". Each note is played using the system speaker and may not be audible on all hardware or
868+
/// operating systems. The method does not block or return any value.</remarks>
845869
private void PlayMaryHadALittleLamb()
846870
{
847871
int[][] melody = new int[][]
@@ -866,6 +890,13 @@ private void PlayMaryHadALittleLamb()
866890
NotePlayer.PlayOnlySystemSpeakerBeep(note[0], note[1]);
867891
}
868892
}
893+
894+
/// <summary>
895+
/// Plays the melody of "Ode to Joy" using the system speaker.
896+
/// </summary>
897+
/// <remarks>This method plays a sequence of notes corresponding to the main theme of Beethoven's
898+
/// "Ode to Joy". The playback uses the system speaker and may not be available or audible on all
899+
/// systems.</remarks>
869900
private void PlayOdeToJoy()
870901
{
871902
int[][] melody = new int[][]
@@ -892,6 +923,13 @@ private void PlayOdeToJoy()
892923
NotePlayer.PlayOnlySystemSpeakerBeep(note[0], note[1]);
893924
}
894925
}
926+
927+
/// <summary>
928+
/// Plays the melody of "Yankee Doodle" using the system speaker.
929+
/// </summary>
930+
/// <remarks>This method plays a sequence of notes corresponding to the main theme of "Yankee
931+
/// Doodle" by invoking the system speaker for each note. The method is intended for use in environments where
932+
/// system speaker output is supported.</remarks>
895933
private void PlayYankeeDoodle()
896934
{
897935
int[][] melody = new int[][]
@@ -917,6 +955,12 @@ private void PlayYankeeDoodle()
917955
NotePlayer.PlayOnlySystemSpeakerBeep(note[0], note[1]);
918956
}
919957
}
958+
959+
/// <summary>
960+
/// Plays the melody of "Frère Jacques" using system speaker beeps.
961+
/// </summary>
962+
/// <remarks>Each note of the melody is played sequentially through the system speaker. This
963+
/// method does not provide audio output on systems where the system beep is unavailable or disabled.</remarks>
920964
private void PlayFrereJacques()
921965
{
922966
int[][] melody = new int[][]
@@ -954,6 +998,13 @@ private void PlayFrereJacques()
954998
NotePlayer.PlayOnlySystemSpeakerBeep(note[0], note[1]);
955999
}
9561000
}
1001+
1002+
/// <summary>
1003+
/// Plays a C minor chord using the system speaker.
1004+
/// </summary>
1005+
/// <remarks>This method plays the notes C4, D#4, and G4 sequentially, each for 500 milliseconds,
1006+
/// through the system speaker. The method is intended for simple audio feedback and does not support polyphonic
1007+
/// playback.</remarks>
9571008
private void PlayMinorChord()
9581009
{
9591010
int[] frequencies = { 261, 311, 392 }; // C4, D#4, G4
@@ -962,6 +1013,12 @@ private void PlayMinorChord()
9621013
NotePlayer.PlayOnlySystemSpeakerBeep(freq, 500); // 500 ms for each note
9631014
}
9641015
}
1016+
1017+
/// <summary>
1018+
/// Plays the notes of a C major chord sequentially using the system speaker.
1019+
/// </summary>
1020+
/// <remarks>Each note of the chord (C4, E4, G4) is played for 500 milliseconds in sequence. This
1021+
/// method uses the system speaker and may not produce sound on all hardware configurations.</remarks>
9651022
private void PlayMajorChord()
9661023
{
9671024
int[] frequencies = { 261, 329, 392 }; // C4, E4, G4
@@ -970,20 +1027,40 @@ private void PlayMajorChord()
9701027
NotePlayer.PlayOnlySystemSpeakerBeep(freq, 500); // 500 ms for each note
9711028
}
9721029
}
1030+
1031+
/// <summary>
1032+
/// Plays a sequence of beeps with descending frequencies using the system speaker.
1033+
/// </summary>
1034+
/// <remarks>Each beep decreases in pitch, starting from a higher frequency and ending at a lower
1035+
/// frequency. This method is typically used to provide audible feedback or alerts to the user.</remarks>
9731036
private void PlayDescendingBeeps()
9741037
{
9751038
for (int freq = 2000; freq >= 200; freq -= 200)
9761039
{
9771040
NotePlayer.PlayOnlySystemSpeakerBeep(freq, 500); // 500 ms for each frequency
9781041
}
9791042
}
1043+
1044+
/// <summary>
1045+
/// Plays a sequence of beeps with ascending frequencies using the system speaker.
1046+
/// </summary>
1047+
/// <remarks>Each beep increases in frequency from 200 Hz to 2000 Hz in 200 Hz increments, with
1048+
/// each tone lasting 500 milliseconds. This method can be used to provide audible feedback or notifications
1049+
/// that indicate progression or escalation.</remarks>
9801050
private void PlayAscendingBeeps()
9811051
{
9821052
for (int freq = 200; freq <= 2000; freq += 200)
9831053
{
9841054
NotePlayer.PlayOnlySystemSpeakerBeep(freq, 500); // 500 ms for each frequency
9851055
}
9861056
}
1057+
1058+
/// <summary>
1059+
/// Plays a sequence of beeps with random frequencies and durations using the system speaker.
1060+
/// </summary>
1061+
/// <remarks>This method plays ten beeps, each with a randomly selected frequency between 200 Hz
1062+
/// and 2000 Hz and a duration between 100 ms and 1000 ms. The beeps are played in succession and may block the
1063+
/// calling thread until all beeps have finished playing.</remarks>
9871064
private void PlayRandomBeeps()
9881065
{
9891066
Random rnd = new Random();
@@ -994,6 +1071,14 @@ private void PlayRandomBeeps()
9941071
NotePlayer.PlayOnlySystemSpeakerBeep(frequency, duration);
9951072
}
9961073
}
1074+
1075+
/// <summary>
1076+
/// Plays the "Happy Birthday" melody using the system speaker.
1077+
/// </summary>
1078+
/// <remarks>This method plays a simple version of the "Happy Birthday" tune by emitting a
1079+
/// sequence of beeps through the system speaker. The method is intended for environments where audio output is
1080+
/// available via the system beep functionality. No sound will be produced if the system speaker is unavailable
1081+
/// or disabled.</remarks>
9971082
private void PlayHappyBirthday()
9981083
{
9991084
int[][] melody = new int[][]
@@ -1017,6 +1102,13 @@ private void PlayHappyBirthday()
10171102
NotePlayer.PlayOnlySystemSpeakerBeep(note[0], note[1]);
10181103
}
10191104
}
1105+
1106+
/// <summary>
1107+
/// Plays the opening motif of Beethoven's Fifth Symphony using system speaker beeps.
1108+
/// </summary>
1109+
/// <remarks>This method plays a fixed sequence of notes corresponding to the recognizable
1110+
/// "short-short-short-long" motif. The method uses the system speaker and may not produce sound on all hardware
1111+
/// or operating systems.</remarks>
10201112
private void PlayBeethovenFifth()
10211113
{
10221114
int[][] melody = new int[][]
@@ -1036,6 +1128,13 @@ private void PlayBeethovenFifth()
10361128
NotePlayer.PlayOnlySystemSpeakerBeep(note[0], note[1]);
10371129
}
10381130
}
1131+
1132+
/// <summary>
1133+
/// Plays the melody of "Twinkle, Twinkle, Little Star" using system speaker beeps.
1134+
/// </summary>
1135+
/// <remarks>This method plays a fixed sequence of notes corresponding to the main theme of the
1136+
/// song. The method does not return until the entire melody has finished playing. The output is limited to the
1137+
/// capabilities of the system speaker and may not be available on all platforms.</remarks>
10391138
private void PlayTwinkleTwinkle()
10401139
{
10411140
int[][] melody = new int[][]
@@ -1061,12 +1160,26 @@ private void PlayTwinkleTwinkle()
10611160
NotePlayer.PlayOnlySystemSpeakerBeep(note[0], note[1]);
10621161
}
10631162
}
1163+
1164+
/// <summary>
1165+
/// Plays a simple sequence of three beeps with increasing frequencies using the system speaker.
1166+
/// </summary>
1167+
/// <remarks>This method plays three distinct beeps at frequencies of 1000 Hz, 1500 Hz, and 2000 Hz,
1168+
/// each lasting for 500 milliseconds. The beeps are played sequentially through the system speaker and may not
1169+
/// be audible on all hardware configurations.</remarks>
10641170
private void PlaySimpleBeepSequence()
10651171
{
10661172
NotePlayer.PlayOnlySystemSpeakerBeep(1000, 500); // Frequency: 1000 Hz, Duration: 500 ms
10671173
NotePlayer.PlayOnlySystemSpeakerBeep(1500, 500); // Frequency: 1500 Hz, Duration: 500 ms
10681174
NotePlayer.PlayOnlySystemSpeakerBeep(2000, 500); // Frequency: 2000 Hz, Duration: 500 ms
10691175
}
1176+
1177+
/// <summary>
1178+
/// Plays a C major scale using the system speaker.
1179+
/// </summary>
1180+
/// <remarks>This method plays the notes of the C major scale (C4 to C5) sequentially,
1181+
/// each for 500 milliseconds. The playback is done through the system speaker and may not be
1182+
/// supported on all platforms or hardware configurations.</remarks>
10701183
private void PlayScale()
10711184
{
10721185
int[] frequencies = { 261, 293, 329, 349, 392, 440, 493, 523 }; // C4 to C5
@@ -1251,6 +1364,13 @@ private void note_indicator_color_change_Click(object sender, EventArgs e)
12511364
Logger.Log("Colors reset to default.", Logger.LogTypes.Info);
12521365
}
12531366

1367+
/// <summary>
1368+
/// Refreshes the list of available MIDI input devices and updates the related user interface controls to
1369+
/// reflect the current device state.
1370+
/// </summary>
1371+
/// <remarks>This method should be called whenever the set of connected MIDI input devices may
1372+
/// have changed, such as after connecting or disconnecting a device. The enabled state of related controls is
1373+
/// updated based on device availability.</remarks>
12541374
private void RefreshMidiInputDevices()
12551375
{
12561376
comboBox_midi_input_devices.Items.Clear();
@@ -1276,6 +1396,12 @@ private void RefreshMidiInputDevices()
12761396
Logger.Log("MIDI input devices refreshed.", Logger.LogTypes.Info);
12771397
}
12781398

1399+
/// <summary>
1400+
/// Refreshes the list of available MIDI output devices and updates the related user interface controls to
1401+
/// </summary>
1402+
/// <remarks>This method should be called whenever the set of connected MIDI output devices may
1403+
/// have changed, such as after connecting or disconnecting a device. The enabled state of related controls is
1404+
/// updated based on device availability.</remarks>
12791405
private void RefreshMidiOutputDevices()
12801406
{
12811407
comboBox_midi_output_devices.Items.Clear();
@@ -1577,6 +1703,14 @@ private void checkBoxClassicBleeperMode_CheckedChanged(object sender, EventArgs
15771703
openForm.ResumeLayout();
15781704
}
15791705
}
1706+
1707+
/// <summary>
1708+
/// Refreshes the specified control and its child controls to apply visual style changes.
1709+
/// </summary>
1710+
/// <remarks>This method recursively traverses the control hierarchy, refreshing each control.
1711+
/// For NumericUpDown and TextBox controls, it invokes the non-public RecreateHandle method to ensure
1712+
/// that visual style changes are applied correctly.</remarks>
1713+
/// <param name="ctrl"></param>
15801714
private void RefreshControls(Control ctrl)
15811715
{
15821716
if (ctrl.HasChildren)

0 commit comments

Comments
 (0)