Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Telepathy/Properties/Resources.Designer.cs

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

5 changes: 3 additions & 2 deletions Telepathy/RemoteParamAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public override void SetupTooltip(PointF point, GH_TooltipDisplayEventArgs e)
protected override void Layout()
{
//establish the size based on the text content
float textWidth = (float)System.Math.Max(GH_FontServer.MeasureString(this.Owner.NickName, GH_FontServer.StandardBold).Width + 10, 50);
float baseTextWidth = GH_FontServer.MeasureString(this.Owner.NickName, GH_FontServer.StandardBold).Width / TelepathyUtils.resolutionScale;
float textWidth = (float)System.Math.Max(baseTextWidth + 10, 50);
System.Drawing.RectangleF bounds = new System.Drawing.RectangleF(this.Pivot.X - 0.5f * textWidth, this.Pivot.Y - 10f, textWidth, 20f);
this.Bounds = bounds;
this.Bounds = GH_Convert.ToRectangle(this.Bounds);
Expand Down Expand Up @@ -155,7 +156,7 @@ private static void renderArrow(GH_Canvas canvas, Graphics graphics, PointF loc)
// Font font = new Font("Wingdings 3", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(2)));
//render the text at specified location
//Version for everyone:
GH_GraphicsUtil.RenderCenteredText(graphics, "\u2192", new Font("Arial", 10F), Color.Black, new PointF(loc.X, loc.Y - 1.5f));
GH_GraphicsUtil.RenderCenteredText(graphics, "\u2192", new Font("Arial", 10f/TelepathyUtils.resolutionScale), Color.Black, new PointF(loc.X, loc.Y - 1.5f));
//Version for Marc:
// GH_GraphicsUtil.RenderCenteredText(graphics, "*", new Font("Arial", 10F), Color.Black, loc);
}
Expand Down
8 changes: 6 additions & 2 deletions Telepathy/Telepathy.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug64</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Telepathy</RootNamespace>
<AssemblyName>Telepathy</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
Expand Down Expand Up @@ -103,4 +103,8 @@
<StartAction>Program</StartAction>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>Copy "$(TargetPath)" "$(TargetDir)$(ProjectName).gha"
Erase "$(TargetPath)"</PostBuildEvent>
</PropertyGroup>
</Project>
25 changes: 24 additions & 1 deletion Telepathy/TelepathyUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic.CompilerServices;

using Microsoft.Win32;
namespace Telepathy
{
public static class TelepathyUtils
Expand All @@ -18,6 +18,29 @@ public static void connectMatchingParams(GH_Document doc,bool scheduleNew)
if(scheduleNew) Grasshopper.Instances.ActiveCanvas.Document.ScheduleSolution(10);
}


//Method for establishing windows resolution scaling. From debugging this is called when the
//property is first required, e.g. when telepathy object is dropped onto canvas after GH is
//first opended
private static float getResolutionScale()
{
try
{
var canvasDPI = Grasshopper.Instances.ActiveCanvas.DeviceDpi;
return canvasDPI / 96.0f;
}
catch
{
return 1.0f;
}
}

//Field for storing the scale, at the moment this is fixed for the lifetime of the GH
//Weirdly it still seems to work if you change the scale mid Rhino session, it looks like
//windows just applies a scale on all the pixels in Rhino if you do this - the UI looks
//scaled to me.
public static readonly float resolutionScale = getResolutionScale();

//the main method that does the work - checks all receivers and senders for matches,
//and rewires accordingly.
public static void connectMatchingParams(GH_Document doc)
Expand Down