├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── Resources ├── NewApi.png ├── sharex-20220319134253.png ├── sharex-20220319134414.png ├── sharex-20220319134520.png ├── sharex-20220319134617.png └── 报告20220330-1905.diagsession ├── SharpConstraintLayout.Core.Benchmark ├── App.xaml ├── App.xaml.cs ├── CSharpAbsoluteLayoutControlTest.cs ├── CSharpConstraintLayoutControlTest.cs ├── CSharpConstraintLayoutTest.cs ├── CSharpRelativeLayoutControlTest.cs ├── FlexLayoutControlTest.cs ├── FlowTest.cs ├── JavaConstraintLayoutControlTest.Android.cs ├── JavaConstraintLayoutTest.Android.cs ├── JavaFlowTest.Android.cs ├── JavaRelativeLayoutControlTest.Android.cs ├── MauiProgram.cs ├── Platforms │ ├── Android │ │ ├── AndroidManifest.xml │ │ ├── MainActivity.cs │ │ ├── MainApplication.cs │ │ └── Resources │ │ │ └── values │ │ │ └── colors.xml │ ├── MacCatalyst │ │ ├── AppDelegate.cs │ │ ├── Info.plist │ │ └── Program.cs │ ├── Windows │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── Package.appxmanifest │ │ └── app.manifest │ └── iOS │ │ ├── AppDelegate.cs │ │ ├── Info.plist │ │ └── Program.cs ├── Properties │ └── launchSettings.json ├── Resources │ ├── Fonts │ │ └── OpenSans-Regular.ttf │ ├── Images │ │ └── dotnet_bot.svg │ ├── Raw │ │ ├── AboutAssets.txt │ │ └── favorite_black_24dp.svg │ ├── appicon.svg │ └── appiconfg.svg ├── SharpConstraintLayout.Core.Benchmark.csproj └── SimpleClock.cs ├── SharpConstraintLayout.Core.Console ├── FlowTest.cs ├── Program.cs ├── SharpConstraintLayout.Core.Console.csproj └── SimpleTest.cs ├── SharpConstraintLayout.Core ├── ArrayHelperClass.cs ├── DateTimeHelperClass.cs ├── DecimalFormat.cs ├── ExceptionHelperClass.cs ├── GlobalUsing.cs ├── HashMapHelperClass.cs ├── LinkedHashMap.cs ├── ListHelperClass.cs ├── MathHelperClass.cs ├── NumberHelperClass.cs ├── RectangularArrays.cs ├── SharpConstraintLayout.Core.csproj ├── StringHelperClass.cs └── androidx │ └── constraintlayout │ └── core │ ├── ArrayLinkedVariables.cs │ ├── ArrayRow.cs │ ├── Cache.cs │ ├── GoalRow.cs │ ├── LinearSystem.cs │ ├── Metrics.cs │ ├── Pools.cs │ ├── PriorityGoalRow.cs │ ├── SolverVariable.cs │ ├── SolverVariableValues.cs │ ├── motion │ ├── CustomAttribute.cs │ ├── CustomVariable.cs │ ├── Motion.cs │ ├── MotionConstrainedPoint.cs │ ├── MotionPaths.cs │ ├── MotionWidget.cs │ ├── key │ │ ├── MotionConstraintSet.cs │ │ ├── MotionKey.cs │ │ ├── MotionKeyAttributes.cs │ │ ├── MotionKeyCycle.cs │ │ ├── MotionKeyPosition.cs │ │ ├── MotionKeyTimeCycle.cs │ │ └── MotionKeyTrigger.cs │ ├── parse │ │ └── KeyParser.cs │ └── utils │ │ ├── ArcCurveFit.cs │ │ ├── CurveFit.cs │ │ ├── DifferentialInterpolator.cs │ │ ├── Easing.cs │ │ ├── FloatRect.cs │ │ ├── HyperSpline.cs │ │ ├── KeyCache.cs │ │ ├── KeyCycleOscillator.cs │ │ ├── KeyFrameArray.cs │ │ ├── LinearCurveFit.cs │ │ ├── MonotonicCurveFit.cs │ │ ├── Oscillator.cs │ │ ├── Rect.cs │ │ ├── Schlick.cs │ │ ├── SplineSet.cs │ │ ├── SpringStopEngine.cs │ │ ├── StepCurve.cs │ │ ├── StopEngine.cs │ │ ├── StopLogicEngine.cs │ │ ├── TimeCycleSplineSet.cs │ │ ├── TypedBundle.cs │ │ ├── TypedValues.cs │ │ ├── Utils.cs │ │ ├── VelocityMatrix.cs │ │ └── ViewState.cs │ ├── parser │ ├── CLArray.cs │ ├── CLContainer.cs │ ├── CLElement.cs │ ├── CLKey.cs │ ├── CLNumber.cs │ ├── CLObject.cs │ ├── CLParser.cs │ ├── CLParsingException.cs │ ├── CLString.cs │ └── CLToken.cs │ ├── state │ ├── ConstraintReference.cs │ ├── Dimension.cs │ ├── HelperReference.cs │ ├── Interpolator.cs │ ├── Reference.cs │ ├── Registry.cs │ ├── RegistryCallback.cs │ ├── State.cs │ ├── Transition.cs │ ├── WidgetFrame.cs │ └── helpers │ │ ├── AlignHorizontallyReference.cs │ │ ├── AlignVerticallyReference.cs │ │ ├── BarrierReference.cs │ │ ├── ChainReference.cs │ │ ├── Facade.cs │ │ ├── GuidelineReference.cs │ │ ├── HorizontalChainReference.cs │ │ └── VerticalChainReference.cs │ └── widgets │ ├── Barrier.cs │ ├── Chain.cs │ ├── ChainHead.cs │ ├── ConstraintAnchor.cs │ ├── ConstraintWidget.cs │ ├── ConstraintWidgetContainer.cs │ ├── Flow.cs │ ├── Guideline.cs │ ├── Helper.cs │ ├── HelperWidget.cs │ ├── Optimizer.cs │ ├── Placeholder.cs │ ├── Rectangle.cs │ ├── VirtualLayout.cs │ ├── WidgetContainer.cs │ └── analyzer │ ├── BaselineDimensionDependency.cs │ ├── BasicMeasure.cs │ ├── ChainRun.cs │ ├── Dependency.cs │ ├── DependencyGraph.cs │ ├── DependencyNode.cs │ ├── DimensionDependency.cs │ ├── Direct.cs │ ├── Grouping.cs │ ├── GuidelineReference.cs │ ├── HelperReferences.cs │ ├── HorizontalWidgetRun.cs │ ├── RunGroup.cs │ ├── VerticalWidgetRun.cs │ ├── WidgetGroup.cs │ └── WidgetRun.cs ├── SharpConstraintLayout.Maui.Example ├── App.xaml ├── App.xaml.cs ├── AppShell.xaml ├── AppShell.xaml.cs ├── MauiProgram.cs ├── Models │ └── MicrosoftNews.cs ├── Pages │ ├── HStack.cs │ ├── LayoutPerformanceTestPage.xaml │ ├── LayoutPerformanceTestPage.xaml.cs │ ├── MainPage.cs │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── ShowAnimationView.xaml │ ├── ShowAnimationView.xaml.cs │ ├── ShowZIndexView.xaml │ ├── ShowZIndexView.xaml.cs │ ├── TestContentView.xaml │ ├── TestContentView.xaml.cs │ ├── XamlSupport.xaml │ └── XamlSupport.xaml.cs ├── Platforms │ ├── Android │ │ ├── AndroidManifest.xml │ │ ├── MainActivity.cs │ │ ├── MainApplication.cs │ │ └── Resources │ │ │ └── values │ │ │ └── colors.xml │ ├── MacCatalyst │ │ ├── AppDelegate.cs │ │ ├── Info.plist │ │ └── Program.cs │ ├── Tizen │ │ ├── Main.cs │ │ └── tizen-manifest.xml │ ├── Windows │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── Package.appxmanifest │ │ └── app.manifest │ └── iOS │ │ ├── AppDelegate.cs │ │ ├── Info.plist │ │ └── Program.cs ├── Properties │ └── launchSettings.json ├── Resources │ ├── Fonts │ │ ├── OpenSans-Regular.ttf │ │ └── OpenSans-Semibold.ttf │ ├── Images │ │ └── dotnet_bot.svg │ ├── Raw │ │ └── AboutAssets.txt │ ├── Styles.xaml │ ├── appicon.svg │ └── appiconfg.svg ├── SharpConstraintLayout.Maui.Example.csproj ├── SharpConstraintLayout.Maui.Example.sln ├── Tool │ ├── FrameRateCalculator.Android.cs │ ├── FrameRateCalculator.Windows.cs │ ├── FrameRateCalculator.iOS.cs │ ├── Log.cs │ ├── SimpleTest.cs │ ├── UIThread.cs │ └── ViewExtension.Maui.cs └── ViewModels │ └── ListViewViewModel.cs ├── SharpConstraintLayout.Maui.Native.Benchmark ├── CSharpConstraintLayoutControlTest.Native.Android.cs ├── MauiProgram.cs ├── Platforms │ ├── Android │ │ ├── AndroidManifest.xml │ │ ├── MainActivity.cs │ │ ├── MainApplication.cs │ │ └── Resources │ │ │ └── values │ │ │ └── colors.xml │ ├── MacCatalyst │ │ ├── AppDelegate.cs │ │ ├── Info.plist │ │ └── Program.cs │ ├── Windows │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── Package.appxmanifest │ │ └── app.manifest │ └── iOS │ │ ├── AppDelegate.cs │ │ ├── Info.plist │ │ └── Program.cs ├── Properties │ └── launchSettings.json ├── Resources │ ├── Fonts │ │ └── OpenSans-Regular.ttf │ ├── Images │ │ └── dotnet_bot.svg │ ├── Raw │ │ ├── AboutAssets.txt │ │ └── favorite_black_24dp.svg │ ├── appicon.svg │ └── appiconfg.svg └── SharpConstraintLayout.Maui.Native.Benchmark.csproj ├── SharpConstraintLayout.Maui.Native.Example ├── MainController.Android.cs ├── MainController.MaciOS.cs ├── MainController.Windows.cs ├── MainPage.Android.cs ├── MainPage.MaciOS.cs ├── MainPage.Windows.cs ├── MainPage.cs ├── Platforms │ ├── Android │ │ ├── AndroidManifest.xml │ │ ├── MainApplication.cs │ │ └── Resources │ │ │ └── values │ │ │ └── colors.xml │ ├── MacCatalyst │ │ ├── AppDelegate.cs │ │ ├── Info.plist │ │ └── Program.cs │ ├── Windows │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── MainWindow.xaml │ │ ├── MainWindow.xaml.cs │ │ ├── Package.appxmanifest │ │ └── app.manifest │ └── iOS │ │ ├── AppDelegate.cs │ │ ├── Info.plist │ │ └── Program.cs ├── Properties │ └── launchSettings.json ├── Resources │ ├── Fonts │ │ └── OpenSans-Regular.ttf │ ├── Images │ │ └── dotnet_bot.svg │ ├── Raw │ │ ├── AboutAssets.txt │ │ └── favorite_black_24dp.svg │ ├── appicon.svg │ └── appiconfg.svg ├── SharpConstraintLayout.Maui.Native.Example.csproj └── Tool │ ├── SimpleTest.cs │ ├── UIThread.cs │ ├── ViewExtension.Android.cs │ ├── ViewExtension.Windows.cs │ └── ViewExtension.iOS.cs ├── SharpConstraintLayout.Maui.Native ├── DebugTool │ ├── MessageClient.cs │ └── SimpleDebug.cs ├── GloableUsing.cs ├── SharpConstraintLayout.Maui.Native.csproj └── Widget │ ├── ConstraintHelper.Android.cs │ ├── ConstraintHelper.Windows.cs │ ├── ConstraintHelper.iOS.cs │ ├── ConstraintLayout.Android.cs │ ├── ConstraintLayout.Windows.cs │ └── ConstraintLayout.iOS.cs ├── SharpConstraintLayout.Maui.sln ├── SharpConstraintLayout.Maui ├── GloableUsing.cs ├── Helper │ └── Widget │ │ ├── Flow.cs │ │ ├── Interface │ │ ├── IFlow.cs │ │ └── ILayer.cs │ │ └── Layer.cs ├── SharpConstraintLayout.Maui.csproj ├── SizeI.cs └── Widget │ ├── Barrier.cs │ ├── ConstraintHelper.Maui.cs │ ├── ConstraintHelper.cs │ ├── ConstraintLayout.Maui.cs │ ├── ConstraintLayout.cs │ ├── ConstraintLayoutAnimationExtension.Maui.cs │ ├── ConstraintSet.Constraint.cs │ ├── ConstraintSet.Core.cs │ ├── ConstraintSet.Data.cs │ ├── ConstraintSet.Layout.cs │ ├── ConstraintSet.PropertySet.cs │ ├── ConstraintSet.Transform.cs │ ├── Enums.cs │ ├── FluentConstraintSet.cs │ ├── Group..cs │ ├── Guideline.cs │ ├── IBaseline.cs │ ├── Interface │ ├── IBarrier.cs │ ├── IConstraintHelper.cs │ ├── IConstraintLayout.cs │ ├── IConstraintSet.cs │ ├── IElement.cs │ ├── IGroup.cs │ ├── IGuideline.cs │ ├── IPlaceholder.cs │ └── IVirtualLayout.cs │ ├── MeasureSpec.cs │ ├── Placeholder.cs │ ├── UIElementExtension.cs │ ├── UIThread.cs │ ├── ViewInfo.cs │ └── VirtualLayout.cs ├── SharpConstraintLayout.Native.sln └── SharpConstraintLayoutTests ├── AdvancedChainTest.cs ├── Amount.cs ├── AmountTest.cs ├── ArrayBackedVariables.cs ├── ArrayLinkedVariablesTest.cs ├── BarrierTest.cs ├── BasicTests.cs ├── CenterWrapTest.cs ├── ChainTest.cs ├── ChainWrapContentTest.cs ├── CircleTest.cs ├── ComposeLayoutsTest.cs ├── EquationVariable.cs ├── EquationVariableTest.cs ├── FlowTest.cs ├── GlobalUsing.cs ├── GuidelineTest.cs ├── HistogramCounter.cs ├── LayoutTest.cs ├── LinearEquation.cs ├── LinearEquationTest.cs ├── LinearSystemTest.cs ├── MatchConstraintTest.cs ├── NestedLayout.cs ├── ObjectExtension.cs ├── OptimizationsTest.cs ├── PerformanceTest.cs ├── PriorityTest.cs ├── RandomLayoutTest.cs ├── RatioTest.cs ├── SharpConstraintLayoutTests.csproj ├── SolverVariableValuesTest.cs ├── VisibilityTest.cs ├── WidgetsPositioningTest.cs ├── WrapTest.cs ├── my ├── MyBaselineTest.cs └── MyWarpTest.cs ├── parser ├── CLParserBenchmarkTest.cs └── CLParserTest.cs ├── scout ├── Direction.cs ├── Scout.cs ├── ScoutProbabilities.cs ├── ScoutWidget.cs └── Utils.cs └── widgets ├── BasicSolverVariableValues.cs └── ChainHeadTest.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /Resources/NewApi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtuzy/SharpConstraintLayout/83057e11cc524be7c74d04bbe75c85bef787b684/Resources/NewApi.png -------------------------------------------------------------------------------- /Resources/sharex-20220319134253.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtuzy/SharpConstraintLayout/83057e11cc524be7c74d04bbe75c85bef787b684/Resources/sharex-20220319134253.png -------------------------------------------------------------------------------- /Resources/sharex-20220319134414.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtuzy/SharpConstraintLayout/83057e11cc524be7c74d04bbe75c85bef787b684/Resources/sharex-20220319134414.png -------------------------------------------------------------------------------- /Resources/sharex-20220319134520.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtuzy/SharpConstraintLayout/83057e11cc524be7c74d04bbe75c85bef787b684/Resources/sharex-20220319134520.png -------------------------------------------------------------------------------- /Resources/sharex-20220319134617.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtuzy/SharpConstraintLayout/83057e11cc524be7c74d04bbe75c85bef787b684/Resources/sharex-20220319134617.png -------------------------------------------------------------------------------- /Resources/报告20220330-1905.diagsession: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtuzy/SharpConstraintLayout/83057e11cc524be7c74d04bbe75c85bef787b684/Resources/报告20220330-1905.diagsession -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | 10 | #512bdf 11 | White 12 | 13 | 17 | 18 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Maui.Controls; 2 | 3 | namespace SharpConstraintLayout.Core.Benchmark 4 | { 5 | public partial class App : Application 6 | { 7 | public App() 8 | { 9 | InitializeComponent(); 10 | 11 | MainPage = new MainPage(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/CSharpAbsoluteLayoutControlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Maui.Controls; 2 | using Microsoft.Maui.Graphics; 3 | using Microsoft.Maui.Layouts; 4 | using System.Collections.Generic; 5 | using Xunit; 6 | using Xunit.Abstractions; 7 | namespace SharpConstraintLayout.Core.Benchmark 8 | { 9 | public class CSharpAbsoluteLayoutControlTest 10 | { 11 | readonly ITestOutputHelper _output; 12 | 13 | public CSharpAbsoluteLayoutControlTest(ITestOutputHelper output) 14 | { 15 | _output = output; 16 | } 17 | 18 | [Theory] 19 | [InlineData(5)] 20 | [InlineData(25)] 21 | [InlineData(50)] 22 | [InlineData(75)] 23 | [InlineData(100)] 24 | [InlineData(500)] 25 | [InlineData(1000)] 26 | public void PerformanceTest(int childCount) 27 | { 28 | //don't measure time of create control. 29 | var absoluteLayout = new AbsoluteLayout() 30 | { 31 | WidthRequest = 1000, 32 | HeightRequest = 1000, 33 | }; 34 | View preview = new ContentView(); 35 | var views = new List(); 36 | for (var i = 1; i <= childCount - 1; i++) 37 | { 38 | var view = new ContentView() { }; 39 | views.Add(view); 40 | } 41 | 42 | absoluteLayout.Add(preview); 43 | foreach (var view in views) 44 | { 45 | absoluteLayout.Add(view); 46 | } 47 | int space = 2; 48 | var time = SimpleClock.BenchmarkTime(() => 49 | { 50 | var pre = preview; 51 | AbsoluteLayout.SetLayoutBounds(pre, new Rect(0, 0, 100, 100)); 52 | //AbsoluteLayout.SetLayoutFlags(pre, AbsoluteLayoutFlags.PositionProportional); 53 | 54 | for (var index = 0; index < views.Count; index++) 55 | { 56 | var view = views[index]; 57 | AbsoluteLayout.SetLayoutBounds(view, new Rect((index+1)*space, (index + 1) * space, 100, 100)); 58 | //AbsoluteLayout.SetLayoutFlags(view, AbsoluteLayoutFlags.PositionProportional); 59 | pre = view; 60 | } 61 | 62 | var manager = new AbsoluteLayoutManager(absoluteLayout); 63 | var measure = manager.Measure(absoluteLayout.WidthRequest, absoluteLayout.HeightRequest); 64 | var arrange = manager.ArrangeChildren(new Rect(Point.Zero, measure)); 65 | }, 10); 66 | _output.WriteLine(time); 67 | 68 | var children = absoluteLayout.Children; 69 | for (var index = 0; index < children.Count; index++) 70 | { 71 | var child = children[index]; 72 | Assert.Equal(0 + (index * space), child.Frame.Left); 73 | Assert.Equal(0 + (index * space), child.Frame.Top); 74 | Assert.Equal(100, child.Frame.Width); 75 | Assert.Equal(100, child.Frame.Height); 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/MauiProgram.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Maui.Controls.Compatibility.Hosting; 2 | using Microsoft.Maui.Controls.Hosting; 3 | using Microsoft.Maui.Hosting; 4 | using Xunit.Runners.Maui; 5 | 6 | namespace SharpConstraintLayout.Core.Benchmark 7 | { 8 | public static class MauiProgram 9 | { 10 | public static MauiApp CreateMauiApp() 11 | { 12 | var builder = MauiApp.CreateBuilder(); 13 | builder 14 | //.UseMauiApp() 15 | .ConfigureFonts(fonts => 16 | { 17 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); 18 | }); 19 | builder.ConfigureTests(new TestOptions 20 | { 21 | Assemblies = 22 | { 23 | typeof(MauiProgram).Assembly 24 | } 25 | }) 26 | .UseVisualRunner(); 27 | builder.UseMauiCompatibility(); 28 | return builder.Build(); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content.PM; 3 | using Android.OS; 4 | using Microsoft.Maui; 5 | 6 | namespace SharpConstraintLayout.Core.Benchmark 7 | { 8 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)] 9 | public class MainActivity : MauiAppCompatActivity 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/Android/MainApplication.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Runtime; 3 | using Microsoft.Maui; 4 | using Microsoft.Maui.Hosting; 5 | using System; 6 | 7 | namespace SharpConstraintLayout.Core.Benchmark 8 | { 9 | [Application] 10 | public class MainApplication : MauiApplication 11 | { 12 | protected MainApplication(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) 13 | { 14 | } 15 | 16 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 17 | } 18 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #512BD4 4 | #2B0B98 5 | #2B0B98 6 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/MacCatalyst/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | using Microsoft.Maui; 3 | using Microsoft.Maui.Hosting; 4 | using UIKit; 5 | 6 | namespace SharpConstraintLayout.Core.Benchmark 7 | { 8 | [Register("AppDelegate")] 9 | public class AppDelegate : MauiUIApplicationDelegate 10 | { 11 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 12 | } 13 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/MacCatalyst/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIDeviceFamily 6 | 7 | 1 8 | 2 9 | 10 | UIRequiredDeviceCapabilities 11 | 12 | arm64 13 | 14 | UISupportedInterfaceOrientations 15 | 16 | UIInterfaceOrientationPortrait 17 | UIInterfaceOrientationLandscapeLeft 18 | UIInterfaceOrientationLandscapeRight 19 | 20 | UISupportedInterfaceOrientations~ipad 21 | 22 | UIInterfaceOrientationPortrait 23 | UIInterfaceOrientationPortraitUpsideDown 24 | UIInterfaceOrientationLandscapeLeft 25 | UIInterfaceOrientationLandscapeRight 26 | 27 | XSAppIconAssets 28 | Assets.xcassets/appicon.appiconset 29 | 30 | 31 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/MacCatalyst/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace SharpConstraintLayout.Core.Benchmark 5 | { 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/Windows/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/Windows/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Maui; 2 | using Microsoft.Maui.Hosting; 3 | using Microsoft.UI.Xaml; 4 | 5 | // To learn more about WinUI, the WinUI project structure, 6 | // and more about our project templates, see: http://aka.ms/winui-project-info. 7 | 8 | namespace SharpConstraintLayout.Core.Benchmark.WinUI 9 | { 10 | /// 11 | /// Provides application-specific behavior to supplement the default Application class. 12 | /// 13 | /// 14 | /// Provides application-specific behavior to supplement the default Application class. 15 | /// 16 | public partial class App : MauiWinUIApplication 17 | { 18 | /// 19 | /// Initializes the singleton application object. This is the first line of authored code 20 | /// executed, and as such is the logical equivalent of main() or WinMain(). 21 | /// 22 | public App() 23 | { 24 | this.InitializeComponent(); 25 | } 26 | 27 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 28 | } 29 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/Windows/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  SharpConstraintLayoutBenchmark Microsoft appiconStoreLogo.png 2 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/Windows/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | using Microsoft.Maui; 3 | using Microsoft.Maui.Hosting; 4 | using UIKit; 5 | 6 | namespace SharpConstraintLayout.Core.Benchmark 7 | { 8 | [Register("AppDelegate")] 9 | public class AppDelegate : MauiUIApplicationDelegate 10 | { 11 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 12 | } 13 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LSRequiresIPhoneOS 6 | 7 | UIDeviceFamily 8 | 9 | 1 10 | 2 11 | 12 | UIRequiredDeviceCapabilities 13 | 14 | arm64 15 | 16 | UISupportedInterfaceOrientations 17 | 18 | UIInterfaceOrientationPortrait 19 | UIInterfaceOrientationLandscapeLeft 20 | UIInterfaceOrientationLandscapeRight 21 | 22 | UISupportedInterfaceOrientations~ipad 23 | 24 | UIInterfaceOrientationPortrait 25 | UIInterfaceOrientationPortraitUpsideDown 26 | UIInterfaceOrientationLandscapeLeft 27 | UIInterfaceOrientationLandscapeRight 28 | 29 | XSAppIconAssets 30 | Assets.xcassets/appicon.appiconset 31 | 32 | 33 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Platforms/iOS/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace SharpConstraintLayout.Core.Benchmark 5 | { 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Windows Machine": { 4 | "commandName": "MsixPackage", 5 | "nativeDebugging": false 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Resources/Fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtuzy/SharpConstraintLayout/83057e11cc524be7c74d04bbe75c85bef787b684/SharpConstraintLayout.Core.Benchmark/Resources/Fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Resources/Raw/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories) and given a Build Action of "MauiAsset": 3 | 4 | 5 | 6 | These files will be deployed with you package and will be accessible using Essentials: 7 | 8 | async Task LoadMauiAsset() 9 | { 10 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); 11 | using var reader = new StreamReader(stream); 12 | 13 | var contents = reader.ReadToEnd(); 14 | } 15 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Resources/Raw/favorite_black_24dp.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Resources/appicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Benchmark/Resources/appiconfg.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Console/Program.cs: -------------------------------------------------------------------------------- 1 | // See https://aka.ms/new-console-template for more information 2 | using BenchmarkDotNet.Running; 3 | using SharpConstraintLayout.Core.Benchmark; 4 | 5 | /*Console.WriteLine("Hello, World!"); 6 | var test = new FlowTest(); 7 | for (int i = 0; i < 100; i++) 8 | { 9 | var data = Console.ReadLine(); 10 | var strs = data.Split(','); 11 | test.measureFlowWrapNoneMemoryAnalysis(int.Parse(strs[0]), int.Parse(strs[1])); 12 | }*/ 13 | 14 | //var summary = BenchmarkRunner.Run(); 15 | Console.ReadLine(); 16 | //new FlowTest().measureFlowWrapNoneMemoryAnalysis1000Widget(1000, 1000); 17 | new FlowTest().measureFlowWrapChainMemoryAnalysis(1,100); 18 | //new FlowTest().Measure_Views_Benchmark(); 19 | Console.ReadLine(); 20 | GC.Collect(); 21 | Console.ReadLine(); -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Console/SharpConstraintLayout.Core.Console.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core.Console/SimpleTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace SharpConstraintLayout.Core.Benchmark 10 | { 11 | internal class SimpleTest 12 | { 13 | internal static void AreEqual(double hope, double real, string method, string messages = "") 14 | { 15 | Console.WriteLine($"{method} {((int)hope == (int)real ? "Passed" : "Failed")}: {messages}, result: hope { hope} real { real} "); 16 | } 17 | 18 | internal static void AreEqual(double hope, double real, int detal, string method, string messages = "") 19 | { 20 | Console.WriteLine($"{method} {((Math.Abs((int)hope - (int)real)) <= detal ? "Passed" : "Failed")}: {messages}, result: hope { hope} real { real} "); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/ArrayHelperClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | 6 | public static class ArrayHelperClass 7 | { 8 | public static T[] Copy(this T[] oldArray, int copyLength) 9 | { 10 | var newArray = new T[copyLength]; 11 | Array.Copy(oldArray, newArray, Math.Min(oldArray.Length, copyLength)); 12 | return newArray; 13 | } 14 | 15 | public static void Fill(this T[] oldArray, T value) where T : class 16 | { 17 | for (int i = 0; i < oldArray.Length; i++) 18 | oldArray[i] = value; 19 | } 20 | 21 | public static void Fill(this double[] oldArray, double value) 22 | { 23 | for (int i = 0; i < oldArray.Length; i++) 24 | oldArray[i] = value; 25 | } 26 | 27 | public static void Fill(this float[] oldArray, float value) 28 | { 29 | for (int i = 0; i < oldArray.Length; i++) 30 | oldArray[i] = value; 31 | } 32 | 33 | public static void Fill(this int[] oldArray, int value) 34 | { 35 | for (int i = 0; i < oldArray.Length; i++) 36 | oldArray[i] = value; 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/DateTimeHelperClass.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------------------------------- 2 | // Copyright © - 2017 Tangible Software Solutions Inc. 3 | // This class can be used by anyone provided that the copyright notice remains intact. 4 | // 5 | // This class is used to replace calls to Java's System.currentTimeMillis with the C# equivalent. 6 | // Unix time is defined as the number of seconds that have elapsed since midnight UTC, 1 January 1970. 7 | //--------------------------------------------------------------------------------------------------------- 8 | using System; 9 | using System.Diagnostics; 10 | 11 | public static class DateTimeHelperClass 12 | { 13 | private static readonly System.DateTime Jan1st1970 = new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); 14 | public static long CurrentUnixTimeMillis() 15 | { 16 | return (long)(System.DateTime.UtcNow - Jan1st1970).TotalMilliseconds; 17 | } 18 | 19 | /// 20 | /// https://stackoverflow.com/a/44136515/13254773 21 | /// 22 | /// 23 | public static long nanoTime() 24 | { 25 | /*long nano = 10000L * Stopwatch.GetTimestamp(); 26 | nano /= TimeSpan.TicksPerMillisecond; 27 | nano *= 100L; 28 | return nano;*/ 29 | return (long)(System.DateTime.UtcNow.Ticks - Jan1st1970.Ticks) * 100L; 30 | } 31 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/DecimalFormat.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | 6 | public class DecimalFormat 7 | { 8 | private string v; 9 | 10 | public DecimalFormat(string v) 11 | { 12 | this.v = v; 13 | } 14 | 15 | public string format(double mValue) 16 | { 17 | throw new NotImplementedException(); 18 | } 19 | 20 | public string format(float[] vs) 21 | { 22 | throw new NotImplementedException(); 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/ExceptionHelperClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | 6 | public class AssertionError : Exception 7 | { 8 | public AssertionError() : base() 9 | { 10 | } 11 | 12 | public AssertionError(string message) : base(message) 13 | { 14 | } 15 | 16 | public AssertionError(string message, Exception innerException) : base(message, innerException) 17 | { 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/GlobalUsing.cs: -------------------------------------------------------------------------------- 1 | global using Console = System.Diagnostics.Debug; 2 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/HashMapHelperClass.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------------------------------- 2 | // Copyright © - 2017 Tangible Software Solutions Inc. 3 | // This class can be used by anyone provided that the copyright notice remains intact. 4 | // 5 | // This class is used to replace calls to some Java HashMap or Hashtable methods. 6 | //--------------------------------------------------------------------------------------------------------- 7 | using System.Collections.Generic; 8 | internal static class HashMapHelperClass 9 | { 10 | internal static HashSet> SetOfKeyValuePairs(this IDictionary dictionary) 11 | { 12 | HashSet> entries = new HashSet>(); 13 | foreach (KeyValuePair keyValuePair in dictionary) 14 | { 15 | entries.Add(keyValuePair); 16 | } 17 | return entries; 18 | } 19 | 20 | internal static TValue GetValueOrNull(this IDictionary dictionary, TKey key) 21 | { 22 | TValue ret; 23 | dictionary.TryGetValue(key, out ret); 24 | return ret; 25 | } 26 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/LinkedHashMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.CompilerServices; 4 | using System.Text; 5 | 6 | /// 7 | /// 参考: 8 | /// 1. https://stackoverflow.com/questions/29205934/c-sharp-equivalent-of-linkedhashmap 9 | /// 2. https://stackoverflow.com/questions/754233/is-it-there-any-lru-implementation-of-idictionary/3719378#3719378 10 | /// 11 | /// 12 | /// 13 | internal class LinkedHashMap 14 | { 15 | private Dictionary>> D = new Dictionary>>(); 16 | private LinkedList> LL = new LinkedList>(); 17 | 18 | public LinkedHashMap() 19 | { 20 | } 21 | 22 | [MethodImpl(MethodImplOptions.Synchronized)] 23 | public V get(K key) 24 | { 25 | return D[key].Value.Item2; 26 | } 27 | 28 | [MethodImpl(MethodImplOptions.Synchronized)] 29 | public void put(K key, V val) 30 | { 31 | if (D.TryGetValue(key, out var existingNode)) 32 | { 33 | LL.Remove(existingNode); 34 | } 35 | 36 | Tuple cacheItem = new Tuple(key, val); 37 | LinkedListNode> node = new LinkedListNode>(cacheItem); 38 | LL.AddLast(node); 39 | D[key] = node; 40 | } 41 | 42 | private void RemoveFirst() 43 | { 44 | // Remove from LRUPriority 45 | LinkedListNode> node = LL.First; 46 | LL.RemoveFirst(); 47 | 48 | // Remove from cache 49 | D.Remove(node.Value.Item1); 50 | } 51 | 52 | public int Count 53 | { 54 | get 55 | { 56 | return D.Count; 57 | } 58 | } 59 | 60 | public bool containsKey(K key) 61 | { 62 | return D.ContainsKey(key); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/ListHelperClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | 6 | internal static class ListHelperClass 7 | { 8 | public static void addAll(this List list, IEnumerable value) 9 | { 10 | foreach (var item in value) 11 | list.Add(item); 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/MathHelperClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | /// 6 | /// 一般参考Math.java 7 | /// 8 | public static class MathExtension 9 | { 10 | /** 11 | * Constant by which to multiply an angular value in degrees to obtain an 12 | * angular value in radians. 13 | */ 14 | private const double DEGREES_TO_RADIANS = 0.017453292519943295; 15 | 16 | /** 17 | * Converts an angle measured in degrees to an approximately 18 | * equivalent angle measured in radians. The conversion from 19 | * degrees to radians is generally inexact. 20 | * 21 | * @param angdeg an angle, in degrees 22 | * @return the measurement of the angle {@code angdeg} 23 | * in radians. 24 | * @since 1.2 25 | */ 26 | public static double toRadians(double angdeg) 27 | { 28 | return angdeg * DEGREES_TO_RADIANS; 29 | } 30 | 31 | /// 32 | /// https://www.dreamincode.net/forums/topic/273525-java-mathhypotab-equivalent-in-c%23/ 33 | /// 34 | /// 35 | /// 36 | /// 37 | public static double hypot(double x, double y) 38 | { 39 | return System.Math.Sqrt(x * x + y * y); 40 | } 41 | 42 | 43 | /** 44 | * Constant by which to multiply an angular value in radians to obtain an 45 | * angular value in degrees. 46 | */ 47 | private const double RADIANS_TO_DEGREES = 57.29577951308232; 48 | 49 | /** 50 | * Converts an angle measured in radians to an approximately 51 | * equivalent angle measured in degrees. The conversion from 52 | * radians to degrees is generally inexact; users should 53 | * not expect {@code cos(toRadians(90.0))} to exactly 54 | * equal {@code 0.0}. 55 | * 56 | * @param angrad an angle, in radians 57 | * @return the measurement of the angle {@code angrad} 58 | * in degrees. 59 | * @since 1.2 60 | */ 61 | public static double toDegrees(double angrad) 62 | { 63 | return angrad * RADIANS_TO_DEGREES; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/NumberHelperClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | 6 | public static class NumberHelperClass 7 | { 8 | /// 9 | /// https://stackoverflow.com/a/26394670/13254773 10 | /// 11 | /// 12 | /// 13 | public static int floatToIntBits(this float value) 14 | { 15 | return BitConverter.ToInt32(BitConverter.GetBytes(value), 0); 16 | } 17 | 18 | public static float intBitsToFloat(this int value) 19 | { 20 | return (float)BitConverter.ToDouble(BitConverter.GetBytes(value),0);//TODO:验证正确性 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/RectangularArrays.cs: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------------------------- 2 | // Copyright © - 2017 Tangible Software Solutions Inc. 3 | // This class can be used by anyone provided that the copyright notice remains intact. 4 | // 5 | // This class includes methods to convert Java rectangular arrays (jagged arrays 6 | // with inner arrays of the same length). 7 | //---------------------------------------------------------------------------------------- 8 | public static class RectangularArrays 9 | { 10 | internal static double[][] ReturnRectangularDoubleArray(int size1, int size2) 11 | { 12 | double[][] newArray = new double[size1][]; 13 | for (int array1 = 0; array1 < size1; array1++) 14 | { 15 | newArray[array1] = new double[size2]; 16 | } 17 | 18 | return newArray; 19 | } 20 | 21 | public static float[][] ReturnRectangularFloatArray(int size1, int size2) 22 | { 23 | float[][] newArray = new float[size1][]; 24 | for (int array1 = 0; array1 < size1; array1++) 25 | { 26 | newArray[array1] = new float[size2]; 27 | } 28 | 29 | return newArray; 30 | } 31 | 32 | internal static object[][] ReturnRectangularObjectArray(int size1, int size2) 33 | { 34 | object[][] newArray = new object[size1][]; 35 | for (int array1 = 0; array1 < size1; array1++) 36 | { 37 | newArray[array1] = new object[size2]; 38 | } 39 | 40 | return newArray; 41 | } 42 | 43 | public static float[][][][] ReturnRectangularFloatArray(int size1, int size2, int size3, int size4) 44 | { 45 | float[][][][] newArray = new float[size1][][][]; 46 | for (int array1 = 0; array1 < size1; array1++) 47 | { 48 | newArray[array1] = new float[size2][][]; 49 | if (size3 > -1) 50 | { 51 | for (int array2 = 0; array2 < size2; array2++) 52 | { 53 | newArray[array1][array2] = new float[size3][]; 54 | if (size4 > -1) 55 | { 56 | for (int array3 = 0; array3 < size3; array3++) 57 | { 58 | newArray[array1][array2][array3] = new float[size4]; 59 | } 60 | } 61 | } 62 | } 63 | } 64 | 65 | return newArray; 66 | } 67 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/SharpConstraintLayout.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0; 5 | preview 6 | C# port of ConstraintLayout 7 | https://github.com/xtuzy/SharpConstraintLayout 8 | https://github.com/xtuzy/SharpConstraintLayout 9 | wpf;constraintlayout 10 | True 11 | True 12 | 1.1.1 13 | use span test performance 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/Cache.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace androidx.constraintlayout.core 17 | { 18 | /// 19 | /// Cache for common objects 20 | /// 21 | public class Cache 22 | { 23 | internal Pools.Pool optimizedArrayRowPool = new Pools.SimplePool(256); 24 | internal Pools.Pool arrayRowPool = new Pools.SimplePool(256); 25 | internal Pools.Pool solverVariablePool = new Pools.SimplePool(256); 26 | internal SolverVariable[] mIndexedVariables = new SolverVariable[32]; 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/GoalRow.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core 18 | { 19 | public class GoalRow : ArrayRow 20 | { 21 | 22 | public GoalRow(Cache cache) : base(cache) 23 | { 24 | } 25 | 26 | public override void addError(SolverVariable error) 27 | { 28 | base.addError(error); 29 | // error variables in the goal shouldn't be tracked (we only care if they are 30 | // in the system rows) 31 | error.usageInRowCount--; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/motion/key/MotionConstraintSet.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace androidx.constraintlayout.core.motion.key 17 | { 18 | public class MotionConstraintSet 19 | { 20 | private const string ERROR_MESSAGE = "XML parser error must be within a Constraint "; 21 | 22 | private const int INTERNAL_MATCH_PARENT = -1; 23 | private const int INTERNAL_WRAP_CONTENT = -2; 24 | private const int INTERNAL_MATCH_CONSTRAINT = -3; 25 | private const int INTERNAL_WRAP_CONTENT_CONSTRAINED = -4; 26 | 27 | private bool mValidate; 28 | public string mIdString; 29 | public const int ROTATE_NONE = 0; 30 | public const int ROTATE_PORTRATE_OF_RIGHT = 1; 31 | public const int ROTATE_PORTRATE_OF_LEFT = 2; 32 | public const int ROTATE_RIGHT_OF_PORTRATE = 3; 33 | public const int ROTATE_LEFT_OF_PORTRATE = 4; 34 | public int mRotate = 0; 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/motion/utils/DifferentialInterpolator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace androidx.constraintlayout.core.motion.utils 17 | { 18 | public interface DifferentialInterpolator 19 | { 20 | float getInterpolation(float v); 21 | float Velocity {get;} 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/motion/utils/FloatRect.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace androidx.constraintlayout.core.motion.utils 17 | { 18 | public class FloatRect 19 | { 20 | public float bottom; 21 | public float left; 22 | public float right; 23 | public float top; 24 | public float centerX() 25 | { 26 | return (left + right) * 0.5f; 27 | } 28 | public float centerY() 29 | { 30 | return (top + bottom) * 0.5f; 31 | } 32 | 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/motion/utils/KeyCache.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | /* 4 | * Copyright (C) 2020 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace androidx.constraintlayout.core.motion.utils 20 | { 21 | 22 | /// 23 | /// Used by KeyTimeCycles (and any future time dependent behaviour) to cache its current parameters 24 | /// to maintain consistency across requestLayout type rebuilds. 25 | /// 26 | public class KeyCache 27 | { 28 | 29 | internal Dictionary> map = new Dictionary>(); 30 | 31 | public virtual void setFloatValue(object view, string type, int element, float value) 32 | { 33 | if (!map.ContainsKey(view)) 34 | { 35 | Dictionary array = new Dictionary(); 36 | float[] vArray = new float[element + 1]; 37 | vArray[element] = value; 38 | array[type] = vArray; 39 | map[view] = array; 40 | } 41 | else 42 | { 43 | Dictionary array = map[view]; 44 | if (array == null) 45 | { 46 | array = new Dictionary(); 47 | } 48 | 49 | if (!array.ContainsKey(type)) 50 | { 51 | float[] vArray = new float[element + 1]; 52 | vArray[element] = value; 53 | array[type] = vArray; 54 | map[view] = array; 55 | } 56 | else 57 | { 58 | float[] vArray = array[type]; 59 | if (vArray == null) 60 | { 61 | vArray = new float[0]; 62 | } 63 | if (vArray.Length <= element) 64 | { 65 | //vArray = Arrays.copyOf(vArray, element + 1); 66 | vArray = vArray.Copy(element + 1); 67 | } 68 | vArray[element] = value; 69 | array[type] = vArray; 70 | } 71 | } 72 | } 73 | 74 | public virtual float getFloatValue(object view, string type, int element) 75 | { 76 | if (!map.ContainsKey(view)) 77 | { 78 | return float.NaN; 79 | } 80 | else 81 | { 82 | Dictionary array = map[view]; 83 | if (array == null || !array.ContainsKey(type)) 84 | { 85 | return float.NaN; 86 | } 87 | float[] vArray = array[type]; 88 | if (vArray == null) 89 | { 90 | return float.NaN; 91 | } 92 | if (vArray.Length > element) 93 | { 94 | return vArray[element]; 95 | } 96 | return float.NaN; 97 | } 98 | } 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/motion/utils/Rect.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace androidx.constraintlayout.core.motion.utils 17 | { 18 | public class Rect 19 | { 20 | public int bottom; 21 | public int left; 22 | public int right; 23 | public int top; 24 | 25 | public virtual int width() 26 | { 27 | return right - left; 28 | } 29 | 30 | public virtual int height() 31 | { 32 | return bottom - top; 33 | } 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/motion/utils/Schlick.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.motion.utils 18 | { 19 | /// 20 | /// Schlick’s bias and gain functions 21 | /// curve for use in an easing function including quantize functions 22 | /// 23 | /// 24 | public class Schlick : Easing 25 | { 26 | private const bool DEBUG = false; 27 | internal double mS, mT; 28 | internal double eps; 29 | 30 | internal Schlick(string configString) 31 | { 32 | // done this way for efficiency 33 | 34 | str = configString; 35 | int start = configString.IndexOf('('); 36 | int off1 = configString.IndexOf(',', start); 37 | mS = double.Parse(configString.Substring(start + 1, off1 - (start + 1)).Trim()); 38 | int off2 = configString.IndexOf(',', off1 + 1); 39 | mT = double.Parse(configString.Substring(off1 + 1, off2 - (off1 + 1)).Trim()); 40 | } 41 | 42 | private double func(double x) 43 | { 44 | if (x < mT) 45 | { 46 | return mT * x / (x + mS * (mT - x)); 47 | } 48 | return ((1 - mT) * (x - 1)) / (1 - x - mS * (mT - x)); 49 | } 50 | 51 | private double dfunc(double x) 52 | { 53 | if (x < mT) 54 | { 55 | return (mS * mT * mT) / ((mS * (mT - x) + x) * (mS * (mT - x) + x)); 56 | } 57 | return (mS * (mT - 1) * (mT - 1)) / ((-mS * (mT - x) - x + 1) * (-mS * (mT - x) - x + 1)); 58 | } 59 | 60 | public override double getDiff(double x) 61 | { 62 | return dfunc(x); 63 | } 64 | 65 | public override double get(double x) 66 | { 67 | return func(x); 68 | } 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/motion/utils/StopEngine.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.motion.utils 18 | { 19 | public interface StopEngine 20 | { 21 | string debug(string desc, float time); 22 | 23 | float getVelocity(float x); 24 | 25 | float getInterpolation(float v); 26 | 27 | float Velocity {get;} 28 | 29 | bool Stopped {get;} 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/motion/utils/ViewState.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace androidx.constraintlayout.core.motion.utils 17 | { 18 | 19 | public class ViewState 20 | { 21 | public float rotation; 22 | public int left, top, right, bottom; 23 | 24 | public virtual void getState(MotionWidget v) 25 | { 26 | left = (int) v.Left; 27 | top = (int) v.Top; 28 | right = (int) v.Right; 29 | bottom = (int) v.Bottom; 30 | rotation = (int) v.RotationZ; 31 | } 32 | 33 | public virtual int width() 34 | { 35 | return right - left; 36 | } 37 | 38 | public virtual int height() 39 | { 40 | return bottom - top; 41 | } 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/parser/CLArray.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | /* 4 | * Copyright (C) 2021 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | namespace androidx.constraintlayout.core.parser 19 | { 20 | public class CLArray : CLContainer 21 | { 22 | public CLArray(char[] content) : base(content) 23 | { 24 | } 25 | 26 | public static CLElement allocate(char[] content) 27 | { 28 | return new CLArray(content); 29 | } 30 | 31 | public override string toJSON() 32 | { 33 | StringBuilder content = new StringBuilder(DebugName + "["); 34 | bool first = true; 35 | for (int i = 0; i < mElements.Count; i++) 36 | { 37 | if (!first) 38 | { 39 | content.Append(", "); 40 | } 41 | else 42 | { 43 | first = false; 44 | } 45 | content.Append(mElements[i].toJSON()); 46 | } 47 | return content + "]"; 48 | } 49 | 50 | protected internal override string toFormattedJSON(int indent, int forceIndent) 51 | { 52 | StringBuilder json = new StringBuilder(); 53 | string val = toJSON(); 54 | if (forceIndent <= 0 && val.Length + indent < MAX_LINE) 55 | { 56 | json.Append(val); 57 | } 58 | else 59 | { 60 | json.Append("[\n"); 61 | bool first = true; 62 | foreach (CLElement element in mElements) 63 | { 64 | if (!first) 65 | { 66 | json.Append(",\n"); 67 | } 68 | else 69 | { 70 | first = false; 71 | } 72 | addIndent(json, indent + BASE_INDENT); 73 | json.Append(element.toFormattedJSON(indent + BASE_INDENT, forceIndent - 1)); 74 | } 75 | json.Append("\n"); 76 | addIndent(json, indent); 77 | json.Append("]"); 78 | } 79 | return json.ToString(); 80 | } 81 | } 82 | 83 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/parser/CLNumber.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | /* 4 | * Copyright (C) 2021 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | namespace androidx.constraintlayout.core.parser 19 | { 20 | public class CLNumber : CLElement 21 | { 22 | 23 | internal float value = float.NaN; 24 | public CLNumber(char[] content) : base(content) 25 | { 26 | } 27 | 28 | public CLNumber(float value) : base(null) 29 | { 30 | this.value = value; 31 | } 32 | 33 | public static CLElement allocate(char[] content) 34 | { 35 | return new CLNumber(content); 36 | } 37 | 38 | public override string toJSON() 39 | { 40 | float value = Float; 41 | int intValue = (int) value; 42 | if ((float) intValue == value) 43 | { 44 | return "" + intValue; 45 | } 46 | return "" + value; 47 | } 48 | 49 | protected internal override string toFormattedJSON(int indent, int forceIndent) 50 | { 51 | StringBuilder json = new StringBuilder(); 52 | addIndent(json, indent); 53 | float value = Float; 54 | int intValue = (int) value; 55 | if ((float) intValue == value) 56 | { 57 | json.Append(intValue); 58 | } 59 | else 60 | { 61 | json.Append(value); 62 | } 63 | return json.ToString(); 64 | } 65 | 66 | public virtual bool isInt 67 | { 68 | get 69 | { 70 | float value = Float; 71 | int intValue = (int) value; 72 | return ((float) intValue == value); 73 | } 74 | } 75 | 76 | public override int Int 77 | { 78 | get 79 | { 80 | if (float.IsNaN(value)) 81 | { 82 | value = int.Parse(content()); 83 | } 84 | return (int) value; 85 | } 86 | } 87 | 88 | public override float Float 89 | { 90 | get 91 | { 92 | if (float.IsNaN(value)) 93 | { 94 | value = float.Parse(content()); 95 | } 96 | return value; 97 | } 98 | } 99 | 100 | public virtual void putValue(float value) 101 | { 102 | this.value = value; 103 | } 104 | 105 | } 106 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/parser/CLParsingException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /* 4 | * Copyright (C) 2021 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | namespace androidx.constraintlayout.core.parser 19 | { 20 | public class CLParsingException : Exception 21 | { 22 | private readonly string mReason; 23 | private readonly int mLineNumber; 24 | private readonly string mElementClass; 25 | 26 | public CLParsingException(string reason, CLElement element) 27 | { 28 | mReason = reason; 29 | if (element != null) 30 | { 31 | mElementClass = element.StrClass; 32 | mLineNumber = element.Line; 33 | } 34 | else 35 | { 36 | mElementClass = "unknown"; 37 | mLineNumber = 0; 38 | } 39 | } 40 | 41 | public virtual string reason() 42 | { 43 | return mReason + " (" + mElementClass + " at line " + mLineNumber + ")"; 44 | } 45 | 46 | public override string ToString() 47 | { 48 | return "CLParsingException (" + this.GetHashCode() + ") : " + reason(); 49 | } 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/parser/CLString.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | /* 4 | * Copyright (C) 2021 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | namespace androidx.constraintlayout.core.parser 19 | { 20 | public class CLString : CLElement 21 | { 22 | 23 | public CLString(char[] content) : base(content) 24 | { 25 | } 26 | public static CLElement allocate(char[] content) 27 | { 28 | return new CLString(content); 29 | } 30 | public override string toJSON() 31 | { 32 | return "'" + content() + "'"; 33 | } 34 | protected internal override string toFormattedJSON(int indent, int forceIndent) 35 | { 36 | StringBuilder json = new StringBuilder(); 37 | addIndent(json, indent); 38 | json.Append("'"); 39 | json.Append(content()); 40 | json.Append("'"); 41 | return json.ToString(); 42 | } 43 | } 44 | 45 | 46 | 47 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/state/HelperReference.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | /* 4 | * Copyright (C) 2019 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace androidx.constraintlayout.core.state 20 | { 21 | using Facade = androidx.constraintlayout.core.state.helpers.Facade; 22 | using ConstraintWidget = androidx.constraintlayout.core.widgets.ConstraintWidget; 23 | using HelperWidget = androidx.constraintlayout.core.widgets.HelperWidget; 24 | 25 | 26 | public class HelperReference : ConstraintReference, Facade 27 | { 28 | protected internal readonly new State mState; 29 | internal readonly State.Helper mType; 30 | protected internal List mReferences = new List(); 31 | private HelperWidget mHelperWidget; 32 | 33 | public HelperReference(State state, State.Helper type) : base(state) 34 | { 35 | mState = state; 36 | mType = type; 37 | } 38 | 39 | public virtual State.Helper Type 40 | { 41 | get 42 | { 43 | return mType; 44 | } 45 | } 46 | 47 | public virtual HelperReference add(params object[] objects) 48 | { 49 | //Collections.addAll(mReferences, objects); 50 | mReferences.addAll(objects); 51 | return this; 52 | } 53 | 54 | public virtual HelperWidget HelperWidget 55 | { 56 | set 57 | { 58 | mHelperWidget = value; 59 | } 60 | get 61 | { 62 | return mHelperWidget; 63 | } 64 | } 65 | 66 | 67 | public override ConstraintWidget ConstraintWidget 68 | { 69 | get 70 | { 71 | return HelperWidget; 72 | } 73 | } 74 | 75 | public override void apply() 76 | { 77 | // nothing 78 | } 79 | } 80 | 81 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/state/Interpolator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.state 18 | { 19 | public delegate float Interpolator(float input); 20 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/state/Reference.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.state 18 | { 19 | using Facade = androidx.constraintlayout.core.state.helpers.Facade; 20 | using ConstraintWidget = androidx.constraintlayout.core.widgets.ConstraintWidget; 21 | 22 | public interface Reference 23 | { 24 | ConstraintWidget ConstraintWidget {get;set;} 25 | object Key {set;get;} 26 | void apply(); 27 | Facade Facade {get;} 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/state/RegistryCallback.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace androidx.constraintlayout.core.state 17 | { 18 | public interface RegistryCallback 19 | { 20 | void onNewMotionScene(string content); 21 | void onProgress(float progress); 22 | void onDimensions(int width, int height); 23 | string currentMotionScene(); 24 | int DrawDebug {set;} 25 | string currentLayoutInformation(); 26 | int LayoutInformationMode {set;} 27 | long LastModified {get;} 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/state/helpers/AlignHorizontallyReference.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.state.helpers 18 | { 19 | 20 | public class AlignHorizontallyReference : HelperReference 21 | { 22 | 23 | private float mBias = 0.5f; 24 | 25 | public AlignHorizontallyReference(State state) : base(state, State.Helper.ALIGN_VERTICALLY) 26 | { 27 | } 28 | 29 | public override void apply() 30 | { 31 | foreach (object key in mReferences) 32 | { 33 | ConstraintReference reference = mState.constraints(key); 34 | reference.clearHorizontal(); 35 | if (mStartToStart != null) 36 | { 37 | reference.startToStart(mStartToStart); 38 | } 39 | else if (mStartToEnd != null) 40 | { 41 | reference.startToEnd(mStartToEnd); 42 | } 43 | else 44 | { 45 | reference.startToStart(State.PARENT); 46 | } 47 | if (mEndToStart != null) 48 | { 49 | reference.endToStart(mEndToStart); 50 | } 51 | else if (mEndToEnd != null) 52 | { 53 | reference.endToEnd(mEndToEnd); 54 | } 55 | else 56 | { 57 | reference.endToEnd(State.PARENT); 58 | } 59 | if (mBias != 0.5f) 60 | { 61 | reference.horizontalBias(mBias); 62 | } 63 | } 64 | } 65 | 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/state/helpers/AlignVerticallyReference.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.state.helpers 18 | { 19 | 20 | public class AlignVerticallyReference : HelperReference 21 | { 22 | 23 | private float mBias = 0.5f; 24 | 25 | public AlignVerticallyReference(State state) : base(state, State.Helper.ALIGN_VERTICALLY) 26 | { 27 | } 28 | 29 | public override void apply() 30 | { 31 | foreach (object key in mReferences) 32 | { 33 | ConstraintReference reference = mState.constraints(key); 34 | reference.clearVertical(); 35 | if (mTopToTop != null) 36 | { 37 | reference.topToTop(mTopToTop); 38 | } 39 | else if (mTopToBottom != null) 40 | { 41 | reference.topToBottom(mTopToBottom); 42 | } 43 | else 44 | { 45 | reference.topToTop(State.PARENT); 46 | } 47 | if (mBottomToTop != null) 48 | { 49 | reference.bottomToTop(mBottomToTop); 50 | } 51 | else if (mBottomToBottom != null) 52 | { 53 | reference.bottomToBottom(mBottomToBottom); 54 | } 55 | else 56 | { 57 | reference.bottomToBottom(State.PARENT); 58 | } 59 | if (mBias != 0.5f) 60 | { 61 | reference.verticalBias(mBias); 62 | } 63 | } 64 | } 65 | 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/state/helpers/BarrierReference.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.state.helpers 18 | { 19 | using Barrier = androidx.constraintlayout.core.widgets.Barrier; 20 | using HelperWidget = androidx.constraintlayout.core.widgets.HelperWidget; 21 | 22 | public class BarrierReference : HelperReference 23 | { 24 | 25 | private State.Direction mDirection; 26 | private int mMargin; 27 | private Barrier mBarrierWidget; 28 | 29 | public BarrierReference(State state) : base(state, State.Helper.BARRIER) 30 | { 31 | } 32 | 33 | public virtual State.Direction BarrierDirection 34 | { 35 | set 36 | { 37 | mDirection = value; 38 | } 39 | } 40 | 41 | public override ConstraintReference margin(object value) 42 | { 43 | margin(mState.convertDimension(value)); 44 | return this; 45 | } 46 | 47 | public override ConstraintReference margin(int value) 48 | { 49 | mMargin = value; 50 | return this; 51 | } 52 | 53 | /// 54 | /// getHelperWidget(); 55 | /// 56 | public override HelperWidget HelperWidget 57 | { 58 | get 59 | { 60 | if (mBarrierWidget == null) 61 | { 62 | mBarrierWidget = new Barrier(); 63 | } 64 | return mBarrierWidget; 65 | } 66 | } 67 | 68 | public override void apply() 69 | { 70 | var temp = HelperWidget; 71 | int direction = Barrier.LEFT; 72 | switch (mDirection) 73 | { 74 | case State.Direction.LEFT: 75 | case State.Direction.START: 76 | { 77 | // TODO: handle RTL 78 | } 79 | break; 80 | case State.Direction.RIGHT: 81 | case State.Direction.END: 82 | { 83 | // TODO: handle RTL 84 | direction = Barrier.RIGHT; 85 | } 86 | break; 87 | case State.Direction.TOP: 88 | { 89 | direction = Barrier.TOP; 90 | } 91 | break; 92 | case State.Direction.BOTTOM: 93 | { 94 | direction = Barrier.BOTTOM; 95 | } 96 | break; 97 | } 98 | mBarrierWidget.BarrierType = direction; 99 | mBarrierWidget.Margin = mMargin; 100 | } 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/state/helpers/ChainReference.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.state.helpers 18 | { 19 | 20 | public class ChainReference : HelperReference 21 | { 22 | 23 | protected internal float mBias = 0.5f; 24 | protected internal State.Chain mStyle = State.Chain.SPREAD; 25 | 26 | public ChainReference(State state, State.Helper type) : base(state, type) 27 | { 28 | } 29 | 30 | public virtual State.Chain Style 31 | { 32 | get 33 | { 34 | return State.Chain.SPREAD; 35 | } 36 | } 37 | public virtual ChainReference style(State.Chain style) 38 | { 39 | mStyle = style; 40 | return this; 41 | } 42 | public virtual float Bias 43 | { 44 | get 45 | { 46 | return mBias; 47 | } 48 | } 49 | //public override ChainReference bias(float bias) 50 | public override ConstraintReference bias(float bias) 51 | { 52 | mBias = bias; 53 | return this; 54 | } 55 | 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/state/helpers/Facade.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.state.helpers 18 | { 19 | using ConstraintWidget = androidx.constraintlayout.core.widgets.ConstraintWidget; 20 | 21 | public interface Facade 22 | { 23 | ConstraintWidget ConstraintWidget {get;} 24 | void apply(); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/state/helpers/HorizontalChainReference.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.state.helpers 18 | { 19 | using ConstraintWidget = androidx.constraintlayout.core.widgets.ConstraintWidget; 20 | 21 | public class HorizontalChainReference : ChainReference 22 | { 23 | 24 | public HorizontalChainReference(State state) : base(state, State.Helper.HORIZONTAL_CHAIN) 25 | { 26 | } 27 | 28 | public override void apply() 29 | { 30 | ConstraintReference first = null; 31 | ConstraintReference previous = null; 32 | foreach (object key in mReferences) 33 | { 34 | ConstraintReference reference = mState.constraints(key); 35 | reference.clearHorizontal(); 36 | } 37 | 38 | foreach (object key in mReferences) 39 | { 40 | ConstraintReference reference = mState.constraints(key); 41 | if (first == null) 42 | { 43 | first = reference; 44 | if (mStartToStart != null) 45 | { 46 | first.startToStart(mStartToStart).margin(mMarginStart); 47 | } 48 | else if (mStartToEnd != null) 49 | { 50 | first.startToEnd(mStartToEnd).margin(mMarginStart); 51 | } 52 | else 53 | { 54 | first.startToStart(State.PARENT); 55 | } 56 | } 57 | if (previous != null) 58 | { 59 | previous.endToStart(reference.Key); 60 | reference.startToEnd(previous.Key); 61 | } 62 | previous = reference; 63 | } 64 | 65 | if (previous != null) 66 | { 67 | if (mEndToStart != null) 68 | { 69 | previous.endToStart(mEndToStart).margin(mMarginEnd); 70 | } 71 | else if (mEndToEnd != null) 72 | { 73 | previous.endToEnd(mEndToEnd).margin(mMarginEnd); 74 | } 75 | else 76 | { 77 | previous.endToEnd(State.PARENT); 78 | } 79 | } 80 | 81 | if (first == null) 82 | { 83 | return; 84 | } 85 | 86 | if (mBias != 0.5f) 87 | { 88 | first.horizontalBias(mBias); 89 | } 90 | 91 | switch (mStyle) 92 | { 93 | case State.Chain.SPREAD: 94 | { 95 | first.HorizontalChainStyle = ConstraintWidget.CHAIN_SPREAD; 96 | } 97 | break; 98 | case State.Chain.SPREAD_INSIDE: 99 | { 100 | first.HorizontalChainStyle = ConstraintWidget.CHAIN_SPREAD_INSIDE; 101 | } 102 | break; 103 | case State.Chain.PACKED: 104 | { 105 | first.HorizontalChainStyle = ConstraintWidget.CHAIN_PACKED; 106 | } 107 | break; 108 | } 109 | } 110 | 111 | } 112 | 113 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/state/helpers/VerticalChainReference.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.state.helpers 18 | { 19 | using ConstraintWidget = androidx.constraintlayout.core.widgets.ConstraintWidget; 20 | 21 | public class VerticalChainReference : ChainReference 22 | { 23 | 24 | public VerticalChainReference(State state) : base(state, State.Helper.VERTICAL_CHAIN) 25 | { 26 | } 27 | 28 | public override void apply() 29 | { 30 | ConstraintReference first = null; 31 | ConstraintReference previous = null; 32 | foreach (object key in mReferences) 33 | { 34 | ConstraintReference reference = mState.constraints(key); 35 | reference.clearVertical(); 36 | } 37 | 38 | foreach (object key in mReferences) 39 | { 40 | ConstraintReference reference = mState.constraints(key); 41 | if (first == null) 42 | { 43 | first = reference; 44 | if (mTopToTop != null) 45 | { 46 | first.topToTop(mTopToTop); 47 | } 48 | else if (mTopToBottom != null) 49 | { 50 | first.topToBottom(mTopToBottom); 51 | } 52 | else 53 | { 54 | first.topToTop(State.PARENT); 55 | } 56 | } 57 | if (previous != null) 58 | { 59 | previous.bottomToTop(reference.Key); 60 | reference.topToBottom(previous.Key); 61 | } 62 | previous = reference; 63 | } 64 | 65 | if (previous != null) 66 | { 67 | if (mBottomToTop != null) 68 | { 69 | previous.bottomToTop(mBottomToTop); 70 | } 71 | else if (mBottomToBottom != null) 72 | { 73 | previous.bottomToBottom(mBottomToBottom); 74 | } 75 | else 76 | { 77 | previous.bottomToBottom(State.PARENT); 78 | } 79 | } 80 | 81 | if (first == null) 82 | { 83 | return; 84 | } 85 | 86 | if (mBias != 0.5f) 87 | { 88 | first.verticalBias(mBias); 89 | } 90 | 91 | switch (mStyle) 92 | { 93 | case State.Chain.SPREAD: 94 | { 95 | first.VerticalChainStyle = ConstraintWidget.CHAIN_SPREAD; 96 | } 97 | break; 98 | case State.Chain.SPREAD_INSIDE: 99 | { 100 | first.VerticalChainStyle = ConstraintWidget.CHAIN_SPREAD_INSIDE; 101 | } 102 | break; 103 | case State.Chain.PACKED: 104 | { 105 | first.VerticalChainStyle = ConstraintWidget.CHAIN_PACKED; 106 | } 107 | break; 108 | } 109 | } 110 | 111 | } 112 | 113 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/widgets/Helper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace androidx.constraintlayout.core.widgets 17 | { 18 | /// 19 | /// interface to virtual objects 20 | /// 21 | 22 | public interface Helper 23 | { 24 | void updateConstraints(ConstraintWidgetContainer container); 25 | void add(ConstraintWidget widget); 26 | void removeAllIds(); 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/widgets/Rectangle.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace androidx.constraintlayout.core.widgets 17 | { 18 | /// 19 | /// Simple rect class 20 | /// 21 | public class Rectangle 22 | { 23 | public int x; 24 | public int y; 25 | public int width; 26 | public int height; 27 | 28 | public virtual void setBounds(int x, int y, int width, int height) 29 | { 30 | this.x = x; 31 | this.y = y; 32 | this.width = width; 33 | this.height = height; 34 | } 35 | internal virtual void grow(int w, int h) 36 | { 37 | x -= w; 38 | y -= h; 39 | width += 2 * w; 40 | height += 2 * h; 41 | } 42 | 43 | internal virtual bool intersects(Rectangle bounds) 44 | { 45 | return x >= bounds.x && x < bounds.x + bounds.width && y >= bounds.y && y < bounds.y + bounds.height; 46 | } 47 | 48 | public virtual bool contains(int x, int y) 49 | { 50 | return x >= this.x && x < this.x + this.width && y >= this.y && y < this.y + this.height; 51 | } 52 | 53 | public virtual int CenterX 54 | { 55 | get 56 | { 57 | return (x + width) / 2; 58 | } 59 | } 60 | public virtual int CenterY 61 | { 62 | get 63 | { 64 | return (y + height) / 2; 65 | } 66 | } 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/widgets/analyzer/BaselineDimensionDependency.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.widgets.analyzer 18 | { 19 | internal class BaselineDimensionDependency : DimensionDependency 20 | { 21 | 22 | public BaselineDimensionDependency(WidgetRun run) : base(run) 23 | { 24 | } 25 | 26 | public virtual void update(DependencyNode node) 27 | { 28 | VerticalWidgetRun verticalRun = (VerticalWidgetRun) run; 29 | verticalRun.baseline.margin = run.widget.BaselineDistance; 30 | resolved = true; 31 | } 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/widgets/analyzer/Dependency.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace androidx.constraintlayout.core.widgets.analyzer 18 | { 19 | public interface Dependency 20 | { 21 | void update(Dependency node); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Core/androidx/constraintlayout/core/widgets/analyzer/DimensionDependency.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /* 4 | * Copyright (C) 2019 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace androidx.constraintlayout.core.widgets.analyzer 20 | { 21 | internal class DimensionDependency : DependencyNode 22 | { 23 | 24 | public int wrapValue; 25 | 26 | public DimensionDependency(WidgetRun run) : base(run) 27 | { 28 | if (run is HorizontalWidgetRun) 29 | { 30 | type = Type.HORIZONTAL_DIMENSION; 31 | } 32 | else 33 | { 34 | type = Type.VERTICAL_DIMENSION; 35 | } 36 | } 37 | 38 | public override void resolve(int value) 39 | { 40 | if (resolved) 41 | { 42 | return; 43 | } 44 | this.resolved = true; 45 | this.value = value; 46 | foreach (Dependency node in dependencies) 47 | { 48 | node.update(node); 49 | } 50 | } 51 | 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /SharpConstraintLayout.Maui.Example/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Maui.Example/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using ReloadPreview; 2 | 3 | namespace SharpConstraintLayout.Maui.Example; 4 | 5 | public partial class App : Application 6 | { 7 | public static int WindowWidth; 8 | public static int WindowHeight; 9 | public App() 10 | { 11 | InitializeComponent(); 12 | 13 | Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow), (handler, view) => 14 | { 15 | #if WINDOWS 16 | var mauiWindow = handler.VirtualView; 17 | var nativeWindow = handler.PlatformView; 18 | 19 | nativeWindow.Activate(); 20 | IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(nativeWindow); 21 | 22 | var windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle); 23 | var appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId); 24 | 25 | appWindow.Resize(new Windows.Graphics.SizeInt32(500, 700)); 26 | WindowWidth = appWindow.Size.Width; 27 | WindowHeight = appWindow.Size.Height; 28 | #endif 29 | }); 30 | 31 | MainPage = new AppShell(); 32 | 33 | #if DEBUG 34 | HotReload.Instance.Reload += () => 35 | { 36 | try 37 | { 38 | this.Dispatcher.Dispatch(() => 39 | { 40 | var view = HotReload.Instance.ReloadClass() as Page; 41 | MainPage = view; 42 | System.Diagnostics.Trace.WriteLine($"HotReload:{view} " + view.GetHashCode()); 43 | }); 44 | 45 | } 46 | catch (Exception ex) 47 | { 48 | System.Diagnostics.Trace.WriteLine(ex.ToString()); 49 | } 50 | 51 | }; 52 | HotReload.Instance.Init("192.168.0.144"); 53 | #endif 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Maui.Example/AppShell.xaml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Maui.Example/AppShell.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SharpConstraintLayout.Maui.Example; 2 | 3 | public partial class AppShell : Shell 4 | { 5 | public AppShell() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Maui.Example/MauiProgram.cs: -------------------------------------------------------------------------------- 1 | using MauiGestures; 2 | using SharpConstraintLayout.Maui.Widget; 3 | 4 | namespace SharpConstraintLayout.Maui.Example; 5 | 6 | public static class MauiProgram 7 | { 8 | public static MauiApp CreateMauiApp() 9 | { 10 | var builder = MauiApp.CreateBuilder(); 11 | builder 12 | .UseMauiApp() 13 | .ConfigureFonts(fonts => 14 | { 15 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); 16 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); 17 | }) 18 | .ConfigureMauiHandlers(handler => 19 | { 20 | //handler.AddHandler(typeof(ConstraintLayout), typeof(Microsoft.Maui.Handlers.LayoutHandler)); 21 | }) 22 | .AddAdvancedGestures(); 23 | 24 | return builder.Build(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Maui.Example/Models/MicrosoftNews.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SharpConstraintLayout.Maui.Example.Models 8 | { 9 | internal class MicrosoftNews 10 | { 11 | public string Title { get; set; } 12 | public string SourceForm { get; set; } 13 | public string SourceFormImageUrl { get; set; } 14 | //public string Details { get; set; } 15 | public string ImageUrl { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SharpConstraintLayout.Maui.Example/Pages/LayoutPerformanceTestPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |