@@ -1030,8 +1030,6 @@ public virtual void OnParentResized(ref Vector2 oldSize)
10301030
10311031            var  bounds  =  Bounds ; 
10321032
1033-             // TODO: finish all anchor styles logic 
1034- 
10351033            switch  ( _anchorStyle ) 
10361034            { 
10371035            case  AnchorStyle . UpperCenter : 
@@ -1041,14 +1039,12 @@ public virtual void OnParentResized(ref Vector2 oldSize)
10411039            } 
10421040            case  AnchorStyle . UpperRight : 
10431041            { 
1044-                 float  distance  =  oldSize . X  -  bounds . Left ; 
1045-                 bounds . X  =  _parent . Width  -  distance ; 
1042+                 bounds . X  =  _parent . Width  -  ( oldSize . X  -  bounds . Left ) ; 
10461043                break ; 
10471044            } 
10481045            case  AnchorStyle . Upper : 
10491046            { 
1050-                 float  distance  =  oldSize . X  -  bounds . Right ; 
1051-                 bounds . Width  =  _parent . Width  -  bounds . X  -  distance ; 
1047+                 bounds . Width  =  _parent . Width  -  bounds . X  -  ( oldSize . X  -  bounds . Right ) ; 
10521048                break ; 
10531049            } 
10541050
@@ -1064,29 +1060,49 @@ public virtual void OnParentResized(ref Vector2 oldSize)
10641060            } 
10651061            case  AnchorStyle . CenterRight : 
10661062            { 
1067-                 float  distance  =  oldSize . X  -  bounds . Left ; 
1068-                 bounds . X  =  _parent . Width  -  distance ; 
1063+                 bounds . X  =  _parent . Width  -  ( oldSize . X  -  bounds . Left ) ; 
10691064                bounds . Y  =  ( _parent . Height  -  bounds . Height )  *  0.5f ; 
10701065                break ; 
10711066            } 
10721067
10731068            case  AnchorStyle . BottomLeft : 
10741069            { 
1075-                 float  distance  =  oldSize . Y  -  bounds . Y ; 
1076-                 bounds . Y  =  _parent . Height  -  distance ; 
1070+                 bounds . Y  =  _parent . Height  -  ( oldSize . Y  -  bounds . Y ) ; 
1071+                 break ; 
1072+             } 
1073+             case  AnchorStyle . BottomCenter : 
1074+             { 
1075+                 bounds . X  =  ( _parent . Width  -  bounds . Width )  *  0.5f ; 
1076+                 bounds . Y  =  _parent . Height  -  ( oldSize . Y  -  bounds . Y ) ; 
1077+                 break ; 
1078+             } 
1079+             case  AnchorStyle . BottomRight : 
1080+             { 
1081+                 bounds . X  =  _parent . Width  -  ( oldSize . X  -  bounds . Left ) ; 
1082+                 bounds . Y  =  _parent . Height  -  ( oldSize . Y  -  bounds . Y ) ; 
1083+                 break ; 
1084+             } 
1085+             case  AnchorStyle . Bottom : 
1086+             { 
1087+                 bounds . Width  =  _parent . Width  -  bounds . X  -  ( oldSize . X  -  bounds . Right ) ; 
1088+                 bounds . Y  =  _parent . Height  -  ( oldSize . Y  -  bounds . Y ) ; 
10771089                break ; 
10781090            } 
1079-             //case AnchorStyle.BottomCenter: break; 
1080-             //case AnchorStyle.BottomRight: break; 
1081-             //case AnchorStyle.Bottom: break; 
1082- 
1083-             //case AnchorStyle.Left: break; 
1084-             //case AnchorStyle.Right: break; 
10851091
1086-             default : 
1087-                 throw  new  NotImplementedException ( "finish anchor styles" ) ; 
1092+             case  AnchorStyle . Left : 
1093+             { 
1094+                 bounds . Height  =  _parent . Height  -  bounds . Y  -  ( oldSize . Y  -  bounds . Bottom ) ; 
10881095                break ; 
10891096            } 
1097+             case  AnchorStyle . Right : 
1098+             { 
1099+                 bounds . Height  =  _parent . Height  -  bounds . Y  -  ( oldSize . Y  -  bounds . Bottom ) ; 
1100+                 bounds . X  =  _parent . Width  -  ( oldSize . X  -  bounds . Left ) ; 
1101+                 break ; 
1102+             } 
1103+ 
1104+             default :  throw  new  ArgumentOutOfRangeException ( ) ; 
1105+             } 
10901106
10911107            Bounds  =  bounds ; 
10921108        } 
0 commit comments