@@ -17,6 +17,8 @@ public partial class Dialog : MasterForm {
1717 private int saveCount = 0 ;
1818
1919 private SharpClipboard _clipMonitor ;
20+ private bool disableUiEvents = false ;
21+
2022 public SharpClipboard clipMonitor {
2123 get {
2224 if ( _clipMonitor == null ) _clipMonitor = new SharpClipboard ( ) ;
@@ -97,10 +99,9 @@ public Dialog(string location = null, string filename = null, bool? showDialogOv
9799
98100 if ( saveIntoSubdir ) location += @"\" + formatFilenameTemplate ( Settings . Default . subdirTemplate ) ;
99101 txtCurrentLocation . Text = location ;
100- chkClrClipboard . Checked = clearClipboardOverwrite ?? Settings . Default . clrClipboard ;
101- chkContinuousMode . Checked = Settings . Default . continuousMode ;
102- updateSavebutton ( ) ;
103- chkAutoSave . Checked = Settings . Default . autoSave ;
102+ updateUiFromSettings ( ) ;
103+ chkClrClipboard . Checked = clearClipboardOverwrite ?? chkClrClipboard . Checked ;
104+ Settings . Default . PropertyChanged += ( sender , args ) => updateUiFromSettings ( ) ;
104105
105106
106107 txtFilename . Select ( ) ;
@@ -156,6 +157,15 @@ public Dialog(string location = null, string filename = null, bool? showDialogOv
156157
157158 }
158159
160+ private void updateUiFromSettings ( ) {
161+ disableUiEvents = true ;
162+ chkClrClipboard . Checked = Settings . Default . clrClipboard ;
163+ chkContinuousMode . Checked = Settings . Default . continuousMode ;
164+ chkAutoSave . Checked = Settings . Default . autoSave ;
165+ updateSavebutton ( ) ;
166+ disableUiEvents = false ;
167+ }
168+
159169 public static string formatFilenameTemplate ( string template , DateTime timestamp , int count ) {
160170 return String . Format ( template , timestamp , count ) ;
161171 }
@@ -223,7 +233,7 @@ private void ClipboardChanged(Object sender, SharpClipboard.ClipboardChangedEven
223233 readClipboard ( ) ;
224234
225235 // continuous batch mode
226- if ( Settings . Default . continuousMode ) {
236+ if ( chkContinuousMode . Checked ) {
227237 var ignore = false ;
228238 // ignore duplicate updates within 100ms
229239 ignore |= ( clipData . Timestamp - previousClipboardTimestamp ) . TotalMilliseconds <= 500 ;
@@ -314,8 +324,8 @@ private void updateContentPreview() {
314324
315325
316326 private void updateSavebutton ( ) {
317- btnSave . Enabled = txtFilename . Enabled = ! Settings . Default . continuousMode ;
318- btnSave . Text = Settings . Default . continuousMode ? string . Format ( Resources . str_n_saved , saveCount ) : Resources . str_save ;
327+ btnSave . Enabled = txtFilename . Enabled = ! chkContinuousMode . Checked ;
328+ btnSave . Text = chkContinuousMode . Checked ? string . Format ( Resources . str_n_saved , saveCount ) : Resources . str_save ;
319329 }
320330
321331 private void btnSave_Click ( object sender , EventArgs e ) {
@@ -416,11 +426,13 @@ private void Main_KeyPress(object sender, KeyPressEventArgs e) {
416426 }
417427
418428 private void ChkClrClipboard_CheckedChanged ( object sender , EventArgs e ) {
429+ if ( disableUiEvents ) return ;
419430 Settings . Default . clrClipboard = chkClrClipboard . Checked ;
420431 Settings . Default . Save ( ) ;
421432 }
422433
423434 private void chkContinuousMode_CheckedChanged ( object sender , EventArgs e ) {
435+ if ( disableUiEvents ) return ;
424436 if ( chkContinuousMode . Checked ) {
425437 var saveNow = MessageBox . Show ( Resources . str_continuous_mode_enabled_ask_savenow , Resources . str_continuous_mode , MessageBoxButtons . YesNoCancel , MessageBoxIcon . Question ) ;
426438 if ( saveNow == DialogResult . Yes ) // save current clipboard now
@@ -438,6 +450,7 @@ private void chkContinuousMode_CheckedChanged(object sender, EventArgs e) {
438450 }
439451
440452 private void ChkAutoSave_CheckedChanged ( object sender , EventArgs e ) {
453+ if ( disableUiEvents ) return ;
441454 if ( chkAutoSave . Checked && ! Settings . Default . autoSave ) {
442455 MessageBox . Show ( Resources . str_autosave_infotext , Resources . str_autosave_checkbox , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
443456 }
0 commit comments