/* * Calculates transform matrix from layout coordinate system to view coordinate system. */ private static Matrix2d LayoutTransform(RectangleF bounds, LinearLayoutDirection layoutDirection, LinearLayoutDirection flowDirection) { switch (layoutDirection) { case LinearLayoutDirection.LeftRight: switch (flowDirection) { case LinearLayoutDirection.TopBottom: return(new Matrix2d()); case LinearLayoutDirection.BottomTop: return(Matrix2d.Translation(0, bounds.Height) * Matrix2d.Stretch(1, -1)); } break; case LinearLayoutDirection.RightLeft: switch (flowDirection) { case LinearLayoutDirection.TopBottom: return(Matrix2d.Translation(bounds.Width, 0) * Matrix2d.Stretch(-1, 1)); case LinearLayoutDirection.BottomTop: return(Matrix2d.Translation(bounds.Width, bounds.Height) * Matrix2d.Stretch(-1, -1)); } break; case LinearLayoutDirection.TopBottom: switch (flowDirection) { case LinearLayoutDirection.LeftRight: return(Matrix2d.Rotation(90) * Matrix2d.Stretch(1, -1)); case LinearLayoutDirection.RightLeft: return(Matrix2d.Translation(bounds.Width, 0) * Matrix2d.Rotation(90)); } break; case LinearLayoutDirection.BottomTop: switch (flowDirection) { case LinearLayoutDirection.LeftRight: return(Matrix2d.Translation(0, bounds.Height) * Matrix2d.Rotation(-90)); case LinearLayoutDirection.RightLeft: return(Matrix2d.Translation(bounds.Width, bounds.Height) * Matrix2d.Stretch(-1, 1) * Matrix2d.Rotation(-90)); } break; } var message = $"Layout direction {layoutDirection} is not compatible with flow direction {flowDirection}"; throw new ArgumentException(message); }