@@ -163,36 +163,40 @@ private void WidgetsOnCollectionChanged(object sender, NotifyCollectionChangedEv
163163
164164 private void GetProportions ( int leftWidgetIndex ,
165165 out Proportion leftProportion ,
166- out Proportion rightProportion )
166+ out Proportion rightProportion ,
167+ out float total )
167168 {
169+ var allProps = Orientation == Orientation . Horizontal
170+ ? _layout . ColumnsProportions : _layout . RowsProportions ;
171+
172+ total = 0 ;
173+ for ( var i = 0 ; i < allProps . Count ; i += 2 )
174+ {
175+ total += allProps [ i ] . Value ;
176+ }
177+
168178 var baseIndex = leftWidgetIndex * 2 ;
169- leftProportion = Orientation == Orientation . Horizontal
170- ? _layout . ColumnsProportions [ baseIndex ]
171- : _layout . RowsProportions [ baseIndex ] ;
172- rightProportion = Orientation == Orientation . Horizontal
173- ? _layout . ColumnsProportions [ baseIndex + 2 ]
174- : _layout . RowsProportions [ baseIndex + 2 ] ;
179+ leftProportion = allProps [ baseIndex ] ;
180+ rightProportion = allProps [ baseIndex + 2 ] ;
175181 }
176182
177183 public float GetSplitterPosition ( int leftWidgetIndex )
178184 {
185+ float total ;
179186 Proportion leftProportion , rightProportion ;
180- GetProportions ( leftWidgetIndex , out leftProportion , out rightProportion ) ;
181-
182- var total = leftProportion . Value + rightProportion . Value ;
187+ GetProportions ( leftWidgetIndex , out leftProportion , out rightProportion , out total ) ;
183188
184189 return leftProportion . Value / total ;
185190 }
186191
187192 public void SetSplitterPosition ( int leftWidgetIndex , float proportion )
188193 {
194+ float total ;
189195 Proportion leftProportion , rightProportion ;
190- GetProportions ( leftWidgetIndex , out leftProportion , out rightProportion ) ;
191-
192- var total = leftProportion . Value + rightProportion . Value ;
196+ GetProportions ( leftWidgetIndex , out leftProportion , out rightProportion , out total ) ;
193197
194198 var fp = proportion * total ;
195- var fp2 = total - fp ;
199+ var fp2 = leftProportion . Value + rightProportion . Value - fp ;
196200 leftProportion . Value = fp ;
197201 rightProportion . Value = fp2 ;
198202 }
0 commit comments