Skip to content

Commit

Permalink
Add LayoutOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pepsi1x1 committed Sep 27, 2020
1 parent 8a7d93d commit 30cebdc
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,4 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
/XamarinForms.VisualDebug.App/dist
/XamarinForms.VisualDebug/XamarinForms.VisualDebug/IPConstant.cs
6 changes: 5 additions & 1 deletion VisualDebug.Models/RenderRepresentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ public class RenderRepresentation

public RenderThickness Padding { get; set; }

public string HorizontalOptions { get; set; }

public string VerticalOptions { get; set; }

[Newtonsoft.Json.JsonProperty(DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, PropertyName = "children", Required = Newtonsoft.Json.Required.AllowNull)]
[System.Runtime.Serialization.DataMember(EmitDefaultValue = false, IsRequired = false, Name = "children")]
public List<RenderRepresentation> Children { get; set; }

public byte[] ViewPng { get; set; }
public byte[] ViewPng { get; set; }

public override string ToString()
{
Expand Down
2 changes: 1 addition & 1 deletion XamarinForms.VisualDebug.App/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion XamarinForms.VisualDebug.App/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xamarin-forms.visual-debug.app",
"version": "0.0.0",
"version": "0.0.3",
"description": "XamarinForms.VisualDebug.App",
"main": "app.js",
"author": {
Expand Down
32 changes: 31 additions & 1 deletion XamarinForms.VisualDebug.App/renderer/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var orgChart = (function () {
/* Configuration */
_duration = 750, /* Duration of the animations */
_rectW = 180, /* Width of the rectangle */
_rectH = 150, /* Height of the rectangle */
_rectH = 180, /* Height of the rectangle */
_rectSpacing = 120, /* Spacing between the rectangles */
_fixedDepth = 200, /* Height of the line for child nodes */
_mode = "line", /* Choose the values "line" or "diagonal" */
Expand Down Expand Up @@ -214,6 +214,36 @@ var orgChart = (function () {
return "Padding:" + d.Padding.Left + "," + d.Padding.Top + "," + d.Padding.Right + "," + d.Padding.Bottom;
});

currentYOffset += _labelSize + _labelMargin;
nodeEnter.append("text")
.attr("x", 5)
.attr("y", currentYOffset)
.attr("dy", _labelSize + "px")
.attr("text-anchor", "left")
.style("cursor", function (d) { return (d.children || d._children || d.hasChild) ? "pointer" : "default"; })
.text(function (d) {
if (d.HorizontalOptions === null || d.HorizontalOptions === undefined) {
return "HorizontalOptions: N/A";
}

return "HorizontalOptions:" + d.HorizontalOptions;
});

currentYOffset += _labelSize + _labelMargin;
nodeEnter.append("text")
.attr("x", 5)
.attr("y", currentYOffset)
.attr("dy", _labelSize + "px")
.attr("text-anchor", "left")
.style("cursor", function (d) { return (d.children || d._children || d.hasChild) ? "pointer" : "default"; })
.text(function (d) {
if (d.VerticalOptions === null || d.VerticalOptions === undefined) {
return "VerticalOptions: N/A";
}

return "VerticalOptions:" + d.VerticalOptions;
});

nodeEnter.append("image")
.attr("x", _rectW)
.attr("y", 0)
Expand Down
22 changes: 16 additions & 6 deletions XamarinForms.VisualDebug.Core/TreeRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,20 @@ private static RenderRepresentation ToRenderRepresentation(VisualElement element
}
};

if (element is View repv)


if (element is View view)
{
rep.HorizontalOptions = LayoutOptionsToString(view.HorizontalOptions);

rep.VerticalOptions = LayoutOptionsToString(view.VerticalOptions);

rep.Margin = new RenderThickness
{
Left = repv.Margin.Left,
Top = repv.Margin.Top,
Right = repv.Margin.Right,
Bottom = repv.Margin.Bottom
Left = view.Margin.Left,
Top = view.Margin.Top,
Right = view.Margin.Right,
Bottom = view.Margin.Bottom
};
}

Expand All @@ -123,6 +129,10 @@ private static RenderRepresentation ToRenderRepresentation(VisualElement element
return rep;
}


private static string LayoutOptionsToString(LayoutOptions options)
{
return options.Alignment + (options.Expands ? "AndExpand" : "");
}

}
}
2 changes: 1 addition & 1 deletion XamarinForms.VisualDebug.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>XamarinForms.VisualDebug</id>
<title>XamarinForms.VisualDebug</title>
<version>0.0.2</version>
<version>0.0.3</version>
<authors>David Thompson</authors>
<owners>David Thompson</owners>
<projectUrl>https://github.com/Pepsi1x1/XamarinForms.VisualDebug</projectUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>

<ItemGroup>
<Compile Update="IPConstant.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>IPConstant.tt</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="RenderSamples.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
Expand Down

0 comments on commit 30cebdc

Please sign in to comment.