@@ -182,33 +182,79 @@ void NestedConstraintLayoutTest(ConstraintLayout page)
182182 {
183183 ( Button FirstButton , Button SecondButton , ContentView ThirdCanvas , Label FouthTextBlock , Entry FifthTextBox , Editor SixthRichTextBlock ) = CreateControls ( ) ;
184184
185- var layout = new ConstraintLayout ( )
185+ var leftLayout = new ConstraintLayout ( )
186+ {
187+ ConstrainPaddingTop = 10 ,
188+ ConstrainPaddingBottom = 10 ,
189+ ConstrainPaddingLeft = 10 ,
190+ ConstrainPaddingRight = 10 ,
191+ DebugName = "left" ,
192+ Background = new SolidColorBrush ( Colors . Red )
193+ } ;
194+
195+ var rightLayout = new ConstraintLayout ( )
186196 {
187- Background = new SolidColorBrush ( Colors . Black )
197+ ConstrainPaddingTop = 10 ,
198+ ConstrainPaddingBottom = 10 ,
199+ ConstrainPaddingLeft = 10 ,
200+ ConstrainPaddingRight = 10 ,
201+ DebugName = "right" ,
202+ Background = new SolidColorBrush ( Colors . Green )
188203 } ;
189204
190205 using ( var pageSet = new FluentConstraintSet ( ) )
191206 {
192- page . AddElement ( layout ) ;
207+ page . AddElement ( leftLayout , rightLayout ) ;
193208 pageSet . Clone ( page ) ;
194- pageSet . Select ( layout )
195- . CenterTo ( )
196- . Width ( ConstraintSet . WrapContent )
197- . Height ( ConstraintSet . WrapContent ) ;
209+ pageSet . Select ( leftLayout )
210+ . EdgesYTo ( null , 10 ) . LeftToLeft ( null , 10 ) . RightToLeft ( rightLayout , 5 )
211+ . Width ( SizeBehavier . MatchConstraint )
212+ . Height ( SizeBehavier . MatchParent )
213+ . Select ( rightLayout ) . EdgesYTo ( null , 10 ) . LeftToRight ( leftLayout , 5 ) . RightToRight ( null , 10 )
214+ . Width ( SizeBehavier . MatchConstraint )
215+ . Height ( SizeBehavier . MatchConstraint )
216+ ;
217+
198218 pageSet . ApplyTo ( page ) ;
199- layout . AddElement ( ThirdCanvas ) ;
200- layout . AddElement ( FirstButton ) ;
219+ var leftChildView = new ConstraintLayout ( )
220+ {
221+ DebugName = "Second" ,
222+ Background = new SolidColorBrush ( Colors . Yellow )
223+ } ;
224+ leftLayout . AddElement ( leftChildView ) ;
225+ using ( var layoutSet = new FluentConstraintSet ( ) )
226+ {
227+ layoutSet . Clone ( leftLayout ) ;
228+ layoutSet
229+ . Select ( leftChildView ) . EdgesTo ( null , 20 , 20 )
230+ . Width ( SizeBehavier . MatchConstraint )
231+ . Height ( SizeBehavier . MatchConstraint ) ;
232+ layoutSet . ApplyTo ( leftLayout ) ;
233+ }
234+
235+ var rightChildView = new ConstraintLayout ( )
236+ {
237+ DebugName = "Second" ,
238+ Background = new SolidColorBrush ( Colors . Yellow ) ,
239+ ConstrainWidth = ConstraintSet . WrapContent ,
240+ } ;
241+ rightLayout . AddElement ( rightChildView ) ;
242+ rightChildView . Add ( FirstButton ) ;
201243 using ( var layoutSet = new FluentConstraintSet ( ) )
202244 {
203- layoutSet . Clone ( layout ) ;
245+ layoutSet . Clone ( rightLayout ) ;
204246 layoutSet
205- . Select ( FirstButton ) . CenterXTo ( ) . CenterYTo ( )
206- . Width ( FluentConstraintSet . SizeBehavier . WrapContent )
207- . Height ( FluentConstraintSet . SizeBehavier . WrapContent )
208- . Select ( ThirdCanvas ) . EdgesTo ( null , 20 , 20 )
209- . Width ( FluentConstraintSet . SizeBehavier . MatchParent )
210- . Height ( FluentConstraintSet . SizeBehavier . MatchParent ) ;
211- layoutSet . ApplyTo ( layout ) ;
247+ . Select ( rightChildView ) . EdgesTo ( null , 20 , 20 )
248+ . Width ( SizeBehavier . WrapContent )
249+ . Height ( SizeBehavier . MatchConstraint ) ;
250+ layoutSet . ApplyTo ( rightLayout ) ;
251+
252+ using ( var set = new FluentConstraintSet ( ) )
253+ {
254+ set . Clone ( rightChildView ) ;
255+ set . Select ( FirstButton ) . CenterTo ( ) ;
256+ set . ApplyTo ( rightChildView ) ;
257+ }
212258 }
213259 }
214260 }
@@ -535,40 +581,44 @@ private void ConstraintLayoutInListViewTest(ListView listView)
535581 var layout = new ConstraintLayout ( ) { ConstrainWidth = ConstraintSet . MatchParent , ConstrainHeight = ConstraintSet . WrapContent , BackgroundColor = Color . FromRgb ( 66 , 66 , 66 ) } ;
536582 var title = new Label ( ) { TextColor = Colors . White , FontSize = 30 , FontAttributes = FontAttributes . Bold } ;
537583 title . SetBinding ( Label . TextProperty , nameof ( Models . MicrosoftNews . Title ) ) ;
538- var image = new Image ( ) ;
539- image . SetBinding ( Image . SourceProperty , nameof ( Models . MicrosoftNews . ImageUrl ) ) ;
584+ // var image = new Image();
585+ // image.SetBinding(Image.SourceProperty, nameof(Models.MicrosoftNews.ImageUrl));
540586 var sourceFrom = new Label ( ) { TextColor = Color . FromRgb ( 175 , 165 , 136 ) , FontSize = 12 , FontAttributes = FontAttributes . Bold } ;
541587 sourceFrom . SetBinding ( Label . TextProperty , nameof ( Models . MicrosoftNews . SourceForm ) ) ;
542- var sourceFromeImage = new Image ( ) ;
543- sourceFromeImage . SetBinding ( Image . SourceProperty , nameof ( Models . MicrosoftNews . SourceForm ) ) ;
544- layout . AddElement ( image , title , sourceFromeImage , sourceFrom ) ;
588+ //var sourceFromeImage = new Image();
589+ //sourceFromeImage.SetBinding(Image.SourceProperty, nameof(Models.MicrosoftNews.SourceForm));
590+ layout . AddElement (
591+ //image,
592+ title ,
593+ //sourceFromeImage,
594+ sourceFrom ) ;
545595
546596 var guideLine = new Guideline ( ) { } ;
547597 layout . AddElement ( guideLine ) ;
548598
549599 var littleWindow = new FluentConstraintSet ( ) ;
550600 littleWindow . Clone ( layout ) ;
551601 littleWindow
552- . Select ( guideLine , image , sourceFromeImage , sourceFrom , title ) . Clear ( ) //需要移除之前的约束
602+ . Select ( guideLine ,
603+ //image, sourceFromeImage,
604+ sourceFrom , title ) . Clear ( ) //需要移除之前的约束
553605 . Select ( guideLine ) . GuidelineOrientation ( Orientation . X ) . GuidelinePercent ( 0.6f )
554- . Select ( image ) . EdgesXTo ( ) . BottomToTop ( guideLine )
555- . Width ( SizeBehavier . MatchParent ) . Height ( SizeBehavier . WrapContent )
556- . Select ( sourceFromeImage ) . LeftToLeft ( null , 20 ) . BottomToTop ( title , 20 )
557- . Width ( SizeBehavier . WrapContent ) . Height ( SizeBehavier . WrapContent )
558- . Select ( sourceFrom ) . LeftToRight ( sourceFromeImage , 20 ) . CenterYTo ( sourceFromeImage )
606+ //.Select(image).EdgesXTo().BottomToTop(guideLine).Width(SizeBehavier.MatchParent).Height(SizeBehavier.WrapContent)
607+ //.Select(sourceFromeImage).LeftToLeft(null, 20).BottomToTop(title, 20).Width(SizeBehavier.WrapContent).Height(SizeBehavier.WrapContent)
608+ . Select ( sourceFrom ) //.LeftToRight(sourceFromeImage, 20).CenterYTo(sourceFromeImage)
559609 . Select ( title ) . LeftToLeft ( null , 20 ) . RightToRight ( null , 20 ) . BottomToBottom ( null , 20 ) . Width ( SizeBehavier . MatchConstraint ) ;
560610
561611 var bigWindow = new FluentConstraintSet ( ) ;
562612 bigWindow . Clone ( layout ) ;
563613 bigWindow
564- . Select ( guideLine , image , sourceFromeImage , sourceFrom , title ) . Clear ( ) //需要移除之前的约束
565- . Select ( image ) . RightToRight ( null , 20 ) . TopToTop ( null , 20 )
566- . Width ( 140 ) . Height ( 140 )
567- . Select ( sourceFromeImage ) . LeftToLeft ( null , 20 ) . TopToTop ( image )
568- . Width ( SizeBehavier . WrapContent ) . Height ( SizeBehavier . WrapContent )
569- . Select ( sourceFrom ) . LeftToRight ( sourceFromeImage , 20 ) . CenterYTo ( sourceFromeImage )
570- . Select ( title ) . LeftToLeft ( null , 20 ) . RightToLeft ( image , 20 ) . TopToBottom ( sourceFromeImage , 20 ) . Width ( SizeBehavier . MatchConstraint ) ;
571-
614+ . Select ( guideLine ,
615+ // image, sourceFromeImage,
616+ sourceFrom , title ) . Clear ( ) //需要移除之前的约束
617+ // .Select(image).RightToRight (null, 20).TopToTop(null, 20).Width(140).Height(140 )
618+ //.Select(sourceFromeImage).LeftToLeft(null, 20).TopToTop(image) .Width(SizeBehavier.WrapContent).Height(SizeBehavier.WrapContent)
619+ . Select ( sourceFrom ) // .LeftToRight(sourceFromeImage, 20).CenterYTo(sourceFromeImage)
620+ . Select ( title ) . LeftToLeft ( null , 20 ) // .RightToLeft(image, 20).TopToBottom(sourceFromeImage, 20).Width(SizeBehavier.MatchConstraint);
621+ ;
572622 double oldValue = - 1 ;
573623 layout . SizeChanged += ( sender , e ) =>
574624 {
0 commit comments