From dbf3b11946855b360ade4ce05297b10a78361685 Mon Sep 17 00:00:00 2001 From: mattpodwysocki Date: Wed, 28 Sep 2016 03:12:47 -0700 Subject: [PATCH] Add C# example for css-layout CSSNode Summary: This PR adds the C# version of the `CSSNode` API calls where it currently has only Java and C versions. Closes https://github.com/facebook/css-layout/pull/225 Reviewed By: lucasr Differential Revision: D3936431 Pulled By: emilsjolander fbshipit-source-id: 689cb359c204c6c52e04e031c66615fb04c001af --- README.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 66c820f4..854b513f 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,8 @@ root.setStyleWidth(100); root.setStyleHeight(100); for (int i = 0; i < 10; i++) { - CSSNodeRef child = CSSNodeNew(); + CSSNode child = new CSSNode(); + child.init(); child.setStyleHeight(10); root.addChildAt(child, 0); } @@ -91,8 +92,32 @@ root.getLayoutWidth(); root.getLayoutHeight(); ``` +### .NET +The full API can be found in `csharp/Facebook.CSSLayout/CSSNode.cs`. + +```csharp +var root = new CSSNode(); +root.Initialize(); +root.StyleWidth = 100; +root.StyleHeight = 100; + +for (var i = 0; i < 10; i++) +{ + var child = new CSSNode(); + child.Initialize(); + child.StyleHeight = 10; + root.Insert(0, child); +} + +// Get for resulting layout +root.LayoutX; +root.LayoutY; +root.LayoutWidth; +root.LayoutHeight; +``` + ## Contributing -To contribute to CSSLayout you need to first install [buck](https://buckbuild.com) which is the build system used by CSSLayout. CSSLayout is implemented in C with language bindings for Java. When making changes to `CSSLayout/CSSLayout.h` please ensure to update `java/jni/CSSJNI.h` and `java/com/facebook/csslayout/CSSNode.java` to reflect the API change. Before submitting any code please run `format.sh` to ensure the code matches the project's code style. +To contribute to CSSLayout you need to first install [buck](https://buckbuild.com) which is the build system used by CSSLayout. CSSLayout is implemented in C with language bindings for Java and .NET. When making changes to `CSSLayout/CSSLayout.h` please ensure to update `java/jni/CSSJNI.h`, `java/com/facebook/csslayout/CSSNode.java` and `csharp/Facebook.CSSLayout/CSSNode.cs` to reflect the API change. Before submitting any code please run `format.sh` to ensure the code matches the project's code style. Before making any larger changes to CSSLayout please open an issue with a RFC so the changes can be discussed first. Generally we are very open to changes and improvements that will benefit the community.