This commit is contained in:
Trevi Awater
2024-03-02 21:46:37 +01:00
parent cd30e482dd
commit b009222333
10 changed files with 27 additions and 30 deletions

View File

@@ -125,7 +125,7 @@ namespace Xamarin.Neo4j.iOS.CustomRenderers
// Apply text color formatting for text inside double quotes.
ApplyQuoteTextColorFormatting(text, attributedText, "\"(.*?)\"", Color.FromHex("#ae8b2d").ToUIColor());
attributedText.AddAttribute(UIStringAttributeKey.Font, UIFont.SystemFontOfSize((nfloat) Element.FontSize), new NSRange(0, attributedText.Length));
attributedText.AddAttribute(UIStringAttributeKey.Font, UIFont.FromName("Roboto Mono", (nfloat) Element.FontSize), new NSRange(0, attributedText.Length));
Control.AttributedText = attributedText;
}

View File

@@ -41,6 +41,8 @@
<string>iconize-fontawesome-regular.ttf</string>
<string>iconize-fontawesome-solid.ttf</string>
<string>iconize-fontawesome-brands.ttf</string>
<string>iconize-fontawesome-brands.ttf</string>
<string>roboto-mono-regular.ttf</string>
</array>
</dict>
</plist>

View File

@@ -28,5 +28,3 @@ using Xamarin.Forms;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ExportFont("RobotoMono-Regular.ttf", Alias = "RobotoMonoRegular")]

View File

@@ -151,5 +151,8 @@
<BundleResource Include="Resources\logo.png" />
<BundleResource Include="Resources\resoftware.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\roboto-mono-regular.ttf" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>

View File

@@ -18,11 +18,6 @@ namespace Xamarin.Neo4j.Controls
public event EventHandler ExecuteClicked;
public QueryEditor()
{
FontFamily = "RobotoMonoRegular";
}
protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
{
var sizeRequest = base.OnMeasure(widthConstraint, heightConstraint);

View File

@@ -43,7 +43,7 @@
<pancakeView:Border Thickness="2" Color="#d8e5f1" />
</pancakeView:PancakeView.Border>
<controls:QueryEditor Text="{Binding Query}" ExecuteClicked="ExecuteQuery" MaxHeight="200" HorizontalOptions="FillAndExpand" AutoSize="TextChanges" />
<controls:QueryEditor Text="{Binding Query}" ExecuteClicked="ExecuteQuery" FontSize="14" MaxHeight="200" HorizontalOptions="FillAndExpand" AutoSize="TextChanges" />
</pancakeView:PancakeView>
</pancakeView:PancakeView>

View File

@@ -153,7 +153,7 @@ namespace Xamarin.Neo4j.Services
Success = true,
CanDisplayGraph = canDisplayGraph,
Query = query,
DisplayQuery = QueryHelper.TransformQuery(query),
DisplayQuery = QueryHelper.ToDisplayQuery(query),
ConnectionString = connectionString,
Results = results
};

View File

@@ -15,18 +15,16 @@ namespace Xamarin.Neo4j.Utilities
{
public static class QueryHelper
{
public static string TransformQuery(string query)
public static string ToDisplayQuery(string query)
{
// Check if there is a return statement, if not return the original query
if (query.IndexOf("RETURN ", StringComparison.OrdinalIgnoreCase) <= 0)
return query;
// This pattern is designed to match relationships with and without labels.
// It captures the relationship direction and type, but not the existing label (if any).
const string pattern = @"-\[:?(\w+)?\]->";
// Adjusted pattern to match relationships with and without labels/types.
const string pattern = @"-\[(\w*:?(\w+)?)\]->";
var matches = Regex.Matches(query, pattern);
// Keep track of unique relationships to ensure they are returned
var relationships = new List<string>();
var relationshipCounter = 1;
@@ -36,9 +34,12 @@ namespace Xamarin.Neo4j.Utilities
{
var newLabel = $"display_variable_{relationshipCounter++}"; // Generate a unique label for the relationship
// Replace the first occurrence of this match in the query with the new labeled version
// Determine the correct new pattern based on whether the original had a type/label
var oldPattern = match.Value;
var newPattern = oldPattern.Replace("[:", $"[{newLabel}:").Replace("]->", "]->");
var newPattern = !string.IsNullOrEmpty(match.Groups[1].Value) ?
oldPattern.Replace("[:", $"[{newLabel}:").Replace("]->", "]->") : // For labeled/types
oldPattern.Replace("[]", $"[{newLabel}]"); // For unlabeled
var idx = transformedQuery.IndexOf(oldPattern);
if (idx != -1)
@@ -52,7 +53,6 @@ namespace Xamarin.Neo4j.Utilities
// Construct the new RETURN clause with the added relationships.
if (relationships.Count > 0)
{
// Assuming there's always a RETURN statement to append to.
var returnIndex = transformedQuery.LastIndexOf("RETURN ", StringComparison.OrdinalIgnoreCase);
var returnClause = transformedQuery.Substring(returnIndex + "RETURN ".Length);
var newReturnClause = string.Join(", ", relationships) + ", " + returnClause;

View File

@@ -24,6 +24,5 @@
<None Remove="Resources\licenses.json" />
<EmbeddedResource Include="Resources\licenses.json" />
<None Remove="Assets\Fonts\RobotoMono-Regular.ttf" />
<EmbeddedResource Include="Assets\Fonts\RobotoMono-Regular.ttf" />
</ItemGroup>
</Project>