@@ -33,7 +33,6 @@ internal partial class EntityTypeShape
3333 private static Image _complexPropertyBitmap ;
3434 private static Image _navigationPropertyBitmap ;
3535 private bool _isAdjustedForFillColor ;
36- private EntityChevronButtonField _expandCollapseField ;
3736
3837 internal class EntityChevronButtonField : ChevronButtonField
3938 {
@@ -104,6 +103,9 @@ public override void OnInitialize()
104103 bounds . Location = randomized ;
105104 AbsoluteBounds = bounds ;
106105 EntityDesignerViewModel . EntityShapeLocationSeed ++ ;
106+
107+ // Provide keyboard shortcuts for collapse and expand of this EntityType shape
108+ this . KeyUp += EntityTypeShape_KeyUp ;
107109 }
108110
109111 /// <summary>
@@ -446,16 +448,11 @@ protected override void InitializeShapeFields(IList<ShapeField> shapeFields)
446448 // replace default glyphs in header with ones that respond to filler color and scale with the UX
447449 ReplaceField (
448450 shapeFields , "ExpandCollapse" ,
449- fieldName =>
450- {
451- _expandCollapseField =
452- new EntityChevronButtonField ( fieldName )
453- {
454- DefaultSelectable = false ,
455- DefaultFocusable = false
456- } ;
457- return _expandCollapseField ;
458- } ) ;
451+ fieldName => new EntityChevronButtonField ( fieldName )
452+ {
453+ DefaultSelectable = false ,
454+ DefaultFocusable = false
455+ } ) ;
459456 ReplaceField (
460457 shapeFields , "IconDecorator" ,
461458 fieldName => new EntityImageField ( fieldName , appearance => appearance . EntityGlyph ) ) ;
@@ -487,11 +484,11 @@ public override void EnsureCompartments()
487484 SetAccessibilityOnCompartment ( NavigationCompartment , false ) ;
488485
489486 // need to add our own handler for KeyUp event in order to disable Insert key for Navigation Compartment
490- // and provide keyboard shorcuts for expand and collapse.
487+ // and provide keyboard shortcuts for expand and collapse.
491488 NavigationCompartment . KeyUp += NavigationCompartmentKeyUpHandler ;
492489
493490 // since Properties compartment contains now two DomainClasses (Scalar and Complex) we need to handle Insert key on our own
494- // and provide keyboard shorcuts for expand and collapse.
491+ // and provide keyboard shortcuts for expand and collapse.
495492 PropertiesCompartment . KeyUp += PropertiesCompartmentKeyUpHandler ;
496493 }
497494
@@ -518,13 +515,13 @@ private void PropertiesCompartmentKeyUpHandler(object sender, DiagramKeyEventArg
518515 // Provide keyboard shortcuts for expand and collapse.
519516 if ( e . Control && e . KeyCode == Keys . Up )
520517 {
521- PropertiesCompartment . CollapseInTransaction ( ) ;
518+ PropertiesCompartment . EnsureExpandedState ( false ) ;
522519 e . Handled = true ;
523520 }
524521
525522 if ( e . Control && e . KeyCode == Keys . Down )
526523 {
527- PropertiesCompartment . ExpandInTransaction ( ) ;
524+ PropertiesCompartment . EnsureExpandedState ( true ) ;
528525 e . Handled = true ;
529526 }
530527 }
@@ -545,13 +542,13 @@ private void NavigationCompartmentKeyUpHandler(object sender, DiagramKeyEventArg
545542
546543 if ( e . Control && e . KeyCode == Keys . Up )
547544 {
548- NavigationCompartment . CollapseInTransaction ( ) ;
545+ NavigationCompartment . EnsureExpandedState ( false ) ;
549546 e . Handled = true ;
550547 }
551548
552549 if ( e . Control && e . KeyCode == Keys . Down )
553550 {
554- NavigationCompartment . ExpandInTransaction ( ) ;
551+ NavigationCompartment . EnsureExpandedState ( true ) ;
555552 e . Handled = true ;
556553 }
557554 }
@@ -690,28 +687,19 @@ public override string AccessibleHelp
690687 }
691688 }
692689
693- public override void OnKeyUp ( DiagramKeyEventArgs e )
690+ private void EntityTypeShape_KeyUp ( object sender , DiagramKeyEventArgs e )
694691 {
695692 if ( e . Control && e . KeyCode == Keys . Up )
696693 {
697- var isExpanded = _expandCollapseField . IsExpanded ( this ) ;
698- if ( isExpanded . HasValue && isExpanded . Value )
699- {
700- _expandCollapseField . ChangeState ( this ) ;
701- e . Handled = true ;
702- }
694+ this . EnsureExpandedState ( false ) ;
695+ e . Handled = true ;
703696 }
697+
704698 if ( e . Control && e . KeyCode == Keys . Down )
705699 {
706- var isExpanded = _expandCollapseField . IsExpanded ( this ) ;
707- if ( isExpanded . HasValue && ! isExpanded . Value )
708- {
709- _expandCollapseField . ChangeState ( this ) ;
710- e . Handled = true ;
711- }
700+ this . EnsureExpandedState ( true ) ;
701+ e . Handled = true ;
712702 }
713-
714- base . OnKeyUp ( e ) ;
715703 }
716704
717705 /// <summary>
0 commit comments