@@ -55,19 +55,13 @@ private void ThemeManager_ThemeChanged(object? sender, EventArgs e)
5555 }
5656 }
5757
58- protected override void WndProc ( ref Message m )
59- {
60- const int WM_SETTINGCHANGE = 0x001A ;
61- base . WndProc ( ref m ) ;
62-
63- if ( m . Msg == WM_SETTINGCHANGE )
64- {
65- if ( Settings1 . Default . theme == 0 && ( darkTheme != SystemThemeUtility . IsDarkTheme ( ) ) )
66- {
67- SetTheme ( ) ;
68- }
69- }
70- }
58+ /// <summary>
59+ /// Applies the current application theme to the form based on user or system preferences.
60+ /// </summary>
61+ /// <remarks>This method selects and applies a light or dark theme according to the application's
62+ /// theme settings. If the theme is set to follow the system, the method detects the system's current theme and
63+ /// applies the corresponding style. The method also ensures that UI updates are performed efficiently and that
64+ /// the form is refreshed to reflect the new theme.</remarks>
7165 private void SetTheme ( )
7266 {
7367 this . SuspendLayout ( ) ; // Suspend layout to batch updates
@@ -131,8 +125,21 @@ private void buttonCopyBeepCommandToClipboard_Click(object sender, EventArgs e)
131125 Toast . ShowToast ( this , Resources . MessageConvertedBeepCommandCopied , 2000 ) ;
132126 }
133127
128+
134129 StringBuilder beepCommandBuilder = new StringBuilder ( ) ;
135130 int elapsedElementTime = 0 ; // Equivalent of Stopwatch.ElapsedMilliseconds for text based timing
131+
132+ /// <summary>
133+ /// Parses a music project string and generates a formatted beep command sequence representing the extracted
134+ /// notes.
135+ /// </summary>
136+ /// <remarks>The returned beep command sequence encodes the timing and pitch information for each
137+ /// note as specified in the input music project. The method applies default values for certain settings if they
138+ /// are missing from the input. The output can be used as input to a beep-compatible audio tool or command-line
139+ /// utility.</remarks>
140+ /// <param name="musicString">A string containing the serialized music project data to parse for note extraction. Cannot be null.</param>
141+ /// <returns>A string containing the formatted beep command sequence for the extracted notes. Returns an empty string if
142+ /// no notes are found or if the input is invalid.</returns>
136143 private String ExtractNotes ( string musicString )
137144 {
138145 List < NoteInfo > notes = new List < NoteInfo > ( ) ;
@@ -202,16 +209,36 @@ private String ExtractNotes(string musicString)
202209 if ( silence > 0 )
203210 {
204211 // Pass endOfLine so that last element doesn't get a trailing -n
205- beepCommandBuilder . Append ( createDelay ( silence , endOfLine ) . duration ) ;
212+ beepCommandBuilder . Append ( CreateDelay ( silence , endOfLine ) . duration ) ;
206213 }
207214
208215 }
209216 string rawOutput = beepCommandBuilder . ToString ( ) ;
210217 string trimmedOutput = rawOutput . TrimEnd ( ) ;
211218 return trimmedOutput ;
212219 }
220+
221+ /// <summary>
222+ /// Inserts one or more musical notes into the beep command sequence, specifying which notes to play, their
223+ /// order, and duration.
224+ /// </summary>
225+ /// <remarks>The order and alternation of notes depend on the current playback mode. Only notes
226+ /// marked to be played and with non-empty names are included. If no notes are selected, a delay of the
227+ /// specified length is inserted instead.</remarks>
228+ /// <param name="note1">The name of the first note to include in the sequence. Can be null or empty if not used.</param>
229+ /// <param name="note2">The name of the second note to include in the sequence. Can be null or empty if not used.</param>
230+ /// <param name="note3">The name of the third note to include in the sequence. Can be null or empty if not used.</param>
231+ /// <param name="note4">The name of the fourth note to include in the sequence. Can be null or empty if not used.</param>
232+ /// <param name="playNote1">true to play the note specified by note1; otherwise, false.</param>
233+ /// <param name="playNote2">true to play the note specified by note2; otherwise, false.</param>
234+ /// <param name="playNote3">true to play the note specified by note3; otherwise, false.</param>
235+ /// <param name="playNote4">true to play the note specified by note4; otherwise, false.</param>
236+ /// <param name="length">The total duration, in milliseconds, for which the notes should be played. Must be a positive integer.</param>
237+ /// <param name="endOfLine">true to indicate that this is the last note or group of notes in the line; otherwise, false. The default is
238+ /// false.</param>
239+ /// <returns>The total elapsed time, in milliseconds, for the inserted notes or delay.</returns>
213240 private int insert_note_to_beep_command ( String note1 , String note2 , String note3 , String note4 ,
214- bool playNote1 , bool playNote2 , bool playNote3 , bool playNote4 , int length , bool endOfLine = false ) // Play note in a line
241+ bool playNote1 , bool playNote2 , bool playNote3 , bool playNote4 , int length , bool endOfLine = false ) // Play note in a line
215242 {
216243 int elapsedTime = 0 ;
217244 double note1Frequency = 0 , note2Frequency = 0 , note3Frequency = 0 , note4Frequency = 0 ;
@@ -355,7 +382,7 @@ private int insert_note_to_beep_command(String note1, String note2, String note3
355382 }
356383 else
357384 {
358- generatedBeepCommand = createDelay ( remainingLength , endOfLine ) . duration ;
385+ generatedBeepCommand = CreateDelay ( remainingLength , endOfLine ) . duration ;
359386 beepCommandBuilder . Append ( generatedBeepCommand + Environment . NewLine ) ;
360387 remainingLength = 0 ;
361388 break ;
@@ -370,11 +397,26 @@ private int insert_note_to_beep_command(String note1, String note2, String note3
370397 }
371398 else
372399 {
373- beepCommandBuilder . Append ( createDelay ( length , endOfLine ) . duration ) ;
400+ beepCommandBuilder . Append ( CreateDelay ( length , endOfLine ) . duration ) ;
374401 return length ;
375402 }
376403 return elapsedTime ;
377404 }
405+
406+ /// <summary>
407+ /// Creates a command-line argument string representing a beep with the specified frequency and duration, and
408+ /// calculates the total duration including any required delays.
409+ /// </summary>
410+ /// <remarks>If the specified frequency matches a known resonant frequency, it is incremented by 1
411+ /// Hz to prevent potential playback issues. When nonStopping is false, an extra delay is added to ensure the
412+ /// beep plays correctly.</remarks>
413+ /// <param name="frequency">The frequency of the beep, in hertz. If the value matches a known resonant frequency, it is automatically
414+ /// adjusted to avoid issues.</param>
415+ /// <param name="duration">The duration of the beep, in milliseconds. Must be a non-negative integer.</param>
416+ /// <param name="endOfLine">true if the beep is at the end of a line and should not be followed by a new beep; otherwise, false.</param>
417+ /// <param name="nonStopping">true to omit the additional delay and stop sequence after the beep; otherwise, false. The default is false.</param>
418+ /// <returns>A tuple containing the constructed command-line argument string for the beep and the total duration in
419+ /// milliseconds, including any additional delay if applicable.</returns>
378420 private ( string frequencyAndLength , int totalDuration ) CreateFrequencyAndDurationDuo ( int frequency , int duration , bool endOfLine , bool nonStopping = false )
379421 {
380422 if ( probableResonantFrequencies . Contains ( frequency ) )
@@ -393,7 +435,14 @@ private int insert_note_to_beep_command(String note1, String note2, String note3
393435 }
394436 return ( result , nonStopping ? duration : duration + 5 ) ;
395437 }
396- private ( string duration , int totalDuration ) createDelay ( int duration , bool endOfLine )
438+
439+ /// <summary>
440+ /// Creates a delay command string and returns the corresponding duration information.
441+ /// </summary>
442+ /// <param name="duration">The length of the delay, in milliseconds. Must be a non-negative integer.</param>
443+ /// <param name="endOfLine">true to indicate the delay is at the end of a line; otherwise, false to start a new beep after the delay.</param>
444+ /// <returns>A tuple containing the delay command string and the total duration in milliseconds.</returns>
445+ private ( string duration , int totalDuration ) CreateDelay ( int duration , bool endOfLine )
397446 {
398447 string result = $ " -f 0 -l 0 -D { duration } "; // Add delay
399448 if ( ! endOfLine )
@@ -402,6 +451,14 @@ private int insert_note_to_beep_command(String note1, String note2, String note3
402451 }
403452 return ( result , duration ) ;
404453 }
454+
455+ /// <summary>
456+ /// Deserializes an XML representation of a NeoBleeper project file from the specified string reader.
457+ /// </summary>
458+ /// <param name="stringReader">A StringReader containing the XML data to deserialize. Must not be null and must contain a valid XML
459+ /// representation of a NeoBleeper project file.</param>
460+ /// <returns>A NeoBleeperProjectFile object deserialized from the XML data, or null if the XML does not represent a valid
461+ /// NeoBleeper project file.</returns>
405462 private NBPMLFile . NeoBleeperProjectFile ? DeserializeXMLFromString ( StringReader stringReader )
406463 {
407464 System . Xml . Serialization . XmlSerializer serializer = new System . Xml . Serialization . XmlSerializer ( typeof ( NBPMLFile . NeoBleeperProjectFile ) ) ;
0 commit comments