diff --git a/Telepathy/Properties/Resources.Designer.cs b/Telepathy/Properties/Resources.Designer.cs index bd32069..8140c5c 100644 --- a/Telepathy/Properties/Resources.Designer.cs +++ b/Telepathy/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Telepathy.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/Telepathy/RemoteParamAttributes.cs b/Telepathy/RemoteParamAttributes.cs index 6f56920..eaf46b0 100644 --- a/Telepathy/RemoteParamAttributes.cs +++ b/Telepathy/RemoteParamAttributes.cs @@ -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); @@ -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); } diff --git a/Telepathy/Telepathy.csproj b/Telepathy/Telepathy.csproj index 434fb11..586449e 100644 --- a/Telepathy/Telepathy.csproj +++ b/Telepathy/Telepathy.csproj @@ -1,5 +1,5 @@  - + Debug64 AnyCPU @@ -10,7 +10,7 @@ Properties Telepathy Telepathy - v4.5 + v4.7 512 false @@ -103,4 +103,8 @@ Program false + + Copy "$(TargetPath)" "$(TargetDir)$(ProjectName).gha" +Erase "$(TargetPath)" + \ No newline at end of file diff --git a/Telepathy/TelepathyUtils.cs b/Telepathy/TelepathyUtils.cs index e9920ef..7631ac7 100644 --- a/Telepathy/TelepathyUtils.cs +++ b/Telepathy/TelepathyUtils.cs @@ -5,7 +5,7 @@ using System.Text; using System.Windows.Forms; using Microsoft.VisualBasic.CompilerServices; - +using Microsoft.Win32; namespace Telepathy { public static class TelepathyUtils @@ -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)