@@ -268,6 +268,8 @@ public bool IsGroupAction
268
268
}
269
269
270
270
public UndoRedoState State { get ; set ; }
271
+ public bool FillColorChanged { get ; set ; }
272
+
271
273
272
274
protected override void OnPropertyChanged ( string name )
273
275
{
@@ -297,7 +299,23 @@ protected override void OnPropertyChanged(string name)
297
299
this . HistoryManager . LogData ( this , data ) ;
298
300
}
299
301
302
+
303
+ if ( node . FillColor != ( SolidColorBrush ) new BrushConverter ( ) . ConvertFromString ( "White" ) )
304
+ {
305
+ FillColorChanged = true ;
306
+ }
300
307
node . FillColor = selectedFillBrush ;
308
+ if ( FillColorChanged )
309
+ {
310
+ HistoryEntry historyEntry = new HistoryEntry ( ) ;
311
+ historyEntry . Mode = EntryMode . External ;
312
+ historyEntry . Action = HistoryAction . CustomAction ;
313
+ historyEntry . GroupId = Guid . NewGuid ( ) ;
314
+ historyEntry . UndoElements . Add ( selectedFillBrush ) ;
315
+ HistoryManager . UndoStack . Push ( historyEntry ) ;
316
+ OnHistoryChanged ( obj ) ;
317
+ FillColorChanged = false ;
318
+ }
301
319
}
302
320
303
321
if ( canLogData && ! isGroupAction )
@@ -362,13 +380,52 @@ private void UpdateFormatingProperties(bool updateFontFamily = false, bool updat
362
380
}
363
381
364
382
if ( updateFontFamily )
365
- annotation . FontFamily = selectedFontFamily ;
383
+ {
384
+ if ( annotation . FontFamily == null || ! annotation . FontFamily . Equals ( selectedFontFamily ) )
385
+ {
386
+ annotation . FontFamily = selectedFontFamily ;
387
+ HistoryEntry historyEntry = new HistoryEntry ( ) ;
388
+ historyEntry . Mode = EntryMode . External ;
389
+ historyEntry . Action = HistoryAction . CustomAction ;
390
+ historyEntry . GroupId = Guid . NewGuid ( ) ;
391
+ historyEntry . UndoElements . Add ( annotation . FontFamily ) ;
392
+ HistoryManager . UndoStack . Push ( historyEntry ) ;
393
+ OnHistoryChanged ( obj ) ;
394
+ }
395
+
396
+ }
366
397
367
398
if ( updateFontSize )
368
- annotation . FontSize = selectedFontSize ;
399
+ {
400
+ if ( ! annotation . FontSize . Equals ( selectedFontSize ) )
401
+ {
402
+ annotation . FontSize = selectedFontSize ;
403
+ HistoryEntry historyEntry = new HistoryEntry ( ) ;
404
+ historyEntry . Mode = EntryMode . External ;
405
+ historyEntry . Action = HistoryAction . CustomAction ;
406
+ historyEntry . GroupId = Guid . NewGuid ( ) ;
407
+ historyEntry . UndoElements . Add ( annotation . FontSize ) ;
408
+ HistoryManager . UndoStack . Push ( historyEntry ) ;
409
+ OnHistoryChanged ( obj ) ;
410
+ }
411
+ }
369
412
370
413
if ( updateFontColor )
371
- annotation . Foreground = selectedFontBrush ;
414
+ {
415
+
416
+ if ( annotation . Foreground == null || ! annotation . Foreground . Equals ( selectedFontBrush ) )
417
+ {
418
+ annotation . Foreground = selectedFontBrush ;
419
+ HistoryEntry historyEntry = new HistoryEntry ( ) ;
420
+ historyEntry . Mode = EntryMode . External ;
421
+ historyEntry . Action = HistoryAction . CustomAction ;
422
+ historyEntry . GroupId = Guid . NewGuid ( ) ;
423
+ historyEntry . UndoElements . Add ( annotation . Foreground ) ;
424
+ HistoryManager . UndoStack . Push ( historyEntry ) ;
425
+ OnHistoryChanged ( obj ) ;
426
+ ;
427
+ }
428
+ }
372
429
}
373
430
}
374
431
}
@@ -386,13 +443,52 @@ private void UpdateFormatingProperties(bool updateFontFamily = false, bool updat
386
443
}
387
444
388
445
if ( updateFontFamily )
389
- annotation . FontFamily = selectedFontFamily ;
446
+ {
447
+ if ( annotation . FontFamily == null || ! annotation . FontFamily . Equals ( selectedFontFamily ) )
448
+ {
449
+ annotation . FontFamily = selectedFontFamily ;
450
+ HistoryEntry historyEntry = new HistoryEntry ( ) ;
451
+ historyEntry . Mode = EntryMode . External ;
452
+ historyEntry . Action = HistoryAction . CustomAction ;
453
+ historyEntry . GroupId = Guid . NewGuid ( ) ;
454
+ historyEntry . UndoElements . Add ( annotation . FontFamily ) ;
455
+ HistoryManager . UndoStack . Push ( historyEntry ) ;
456
+ OnHistoryChanged ( obj ) ;
457
+ }
458
+ }
390
459
391
460
if ( updateFontSize )
392
- annotation . FontSize = selectedFontSize ;
461
+ {
462
+ if ( ! annotation . FontSize . Equals ( selectedFontSize ) )
463
+ {
464
+ annotation . FontSize = selectedFontSize ;
465
+
466
+ HistoryEntry historyEntry = new HistoryEntry ( ) ;
467
+ historyEntry . GroupId = Guid . NewGuid ( ) ;
468
+ historyEntry . Mode = EntryMode . External ;
469
+ historyEntry . Action = HistoryAction . CustomAction ;
470
+ historyEntry . UndoElements . Add ( annotation . FontSize ) ;
471
+ HistoryManager . UndoStack . Push ( historyEntry ) ;
472
+ OnHistoryChanged ( obj ) ;
473
+ }
474
+
475
+
476
+ }
393
477
394
478
if ( updateFontColor )
395
- annotation . Foreground = selectedFontBrush ;
479
+ {
480
+ if ( annotation . Foreground == null || ! annotation . Foreground . Equals ( selectedFontBrush ) )
481
+ {
482
+ annotation . Foreground = selectedFontBrush ;
483
+ HistoryEntry historyEntry = new HistoryEntry ( ) ;
484
+ historyEntry . Mode = EntryMode . External ;
485
+ historyEntry . Action = HistoryAction . CustomAction ;
486
+ historyEntry . GroupId = Guid . NewGuid ( ) ;
487
+ historyEntry . UndoElements . Add ( annotation . Foreground ) ;
488
+ HistoryManager . UndoStack . Push ( historyEntry ) ;
489
+ OnHistoryChanged ( obj ) ;
490
+ }
491
+ }
396
492
}
397
493
}
398
494
}
@@ -402,6 +498,7 @@ private void UpdateFormatingProperties(bool updateFontFamily = false, bool updat
402
498
}
403
499
404
500
private bool canLogData = true ;
501
+ private object obj ;
405
502
private void OnItemSelected ( object obj )
406
503
{
407
504
canLogData = false ;
0 commit comments