@@ -21,15 +21,10 @@ internal sealed class RealTimeLayoutService : IRealTimeLayoutService
2121 /// </summary>
2222 private readonly List < ( WeakReference < object > Reference , Action Callback ) > _callbacks = [ ] ;
2323
24- /// <summary>
25- /// Gets the current flow direction based on the current UI culture (RightToLeft or LeftToRight).
26- /// </summary>
24+ /// <inheritdoc/>
2725 public FlowDirection FlowDirection => CultureInfo . CurrentUICulture . TextInfo . IsRightToLeft ? FlowDirection . RightToLeft : FlowDirection . LeftToRight ;
2826
29- /// <summary>
30- /// Updates the culture for the layout service and invokes the necessary callbacks if the flow direction changes.
31- /// </summary>
32- /// <param name="culture">The new culture information to apply.</param>
27+ /// /// <inheritdoc/>
3328 public void UpdateCulture ( CultureInfo culture )
3429 {
3530 FlowDirection tmp = FlowDirection ;
@@ -41,28 +36,23 @@ public void UpdateCulture(CultureInfo culture)
4136 InvokeCallbacks ( ) ;
4237 }
4338
44- /// <summary>
45- /// Registers a callback to be invoked when the layout needs to be updated for the specified target.
46- /// </summary>
47- /// <param name="target">The target object to associate with the callback.</param>
48- /// <param name="callback">The callback to invoke when the layout is updated.</param>
49- public void AddCallback ( object target , Action callback )
39+ /// <inheritdoc/>
40+ public void AddCallback ( Window target , Action callback )
5041 {
5142 var weakReference = new WeakReference < object > ( target ) ;
5243 _callbacks . Add ( ( weakReference , callback ) ) ;
44+ target . Closed += ( sender , args ) => RemoveCallback ( target ) ;
45+ }
5346
54- if ( target is Window window )
55- window . Closed += ( sender , args ) => RemoveCallback ( target ) ;
56-
57- if ( target is FrameworkElement element )
58- element . Unloaded += ( sender , args ) => RemoveCallback ( target ) ;
47+ /// <inheritdoc/>
48+ public void AddCallback ( FrameworkElement target , Action callback )
49+ {
50+ var weakReference = new WeakReference < object > ( target ) ;
51+ _callbacks . Add ( ( weakReference , callback ) ) ;
52+ target . Unloaded += ( sender , args ) => RemoveCallback ( target ) ;
5953 }
6054
61- /// <summary>
62- /// Updates the title bar layout of the specified window based on the current flow direction.
63- /// </summary>
64- /// <param name="window">The window whose title bar layout needs updating.</param>
65- /// <returns>True if the title bar layout was successfully updated; otherwise, false.</returns>
55+ /// <inheritdoc/>
6656 public bool UpdateTitleBar ( Window window )
6757 {
6858 try
@@ -85,20 +75,14 @@ public bool UpdateTitleBar(Window window)
8575 return true ;
8676 }
8777
88- /// <summary>
89- /// Updates the content layout of the specified window to match the current flow direction.
90- /// </summary>
91- /// <param name="window">The window whose content layout needs updating.</param>
78+ /// <inheritdoc/>
9279 public void UpdateContent ( Window window )
9380 {
9481 if ( window . Content is FrameworkElement frameworkElement )
9582 frameworkElement . FlowDirection = FlowDirection ;
9683 }
9784
98- /// <summary>
99- /// Updates the content layout of the specified framework element to match the current flow direction.
100- /// </summary>
101- /// <param name="frameworkElement">The framework element whose content layout needs updating.</param>
85+ /// <inheritdoc/>
10286 public void UpdateContent ( FrameworkElement frameworkElement )
10387 {
10488 frameworkElement . FlowDirection = FlowDirection ;
0 commit comments