diff --git a/rhinocommon/cs/SampleCsMouseCallback/EmbeddedResources/plugin-utility.ico b/rhinocommon/cs/SampleCsMouseCallback/EmbeddedResources/plugin-utility.ico new file mode 100644 index 00000000..022d1f78 Binary files /dev/null and b/rhinocommon/cs/SampleCsMouseCallback/EmbeddedResources/plugin-utility.ico differ diff --git a/rhinocommon/cs/SampleCsMouseCallback/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsMouseCallback/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..e4df3ac2 --- /dev/null +++ b/rhinocommon/cs/SampleCsMouseCallback/Properties/AssemblyInfo.cs @@ -0,0 +1,59 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Rhino.PlugIns; + +// Plug-in Description Attributes - all of these are optional. +// These will show in Rhino's option dialog, in the tab Plug-ins. +[assembly: PlugInDescription(DescriptionType.Address, "-")] +[assembly: PlugInDescription(DescriptionType.Country, "-")] +[assembly: PlugInDescription(DescriptionType.Email, "-")] +[assembly: PlugInDescription(DescriptionType.Phone, "-")] +[assembly: PlugInDescription(DescriptionType.Fax, "-")] +[assembly: PlugInDescription(DescriptionType.Organization, "-")] +[assembly: PlugInDescription(DescriptionType.UpdateUrl, "-")] +[assembly: PlugInDescription(DescriptionType.WebSite, "-")] + +// Icons should be Windows .ico files and contain 32-bit images in the following sizes: 16, 24, 32, 48, and 256. +// This is a Rhino 6-only description. +[assembly: PlugInDescription(DescriptionType.Icon, "SampleCsMouseCallback.EmbeddedResources.plugin-utility.ico")] + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SampleCsMouseCallback")] + +// This will be used also for the plug-in description. +[assembly: AssemblyDescription("SampleCsMouseCallback utility plug-in")] + +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SampleCsMouseCallback")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("cf2a3245-3eb5-4247-8532-a09139eec262")] // This will also be the Guid of the Rhino plug-in + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +// Make compatible with Rhino Installer Engine +[assembly: AssemblyInformationalVersion("2")] diff --git a/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallback.csproj b/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallback.csproj new file mode 100644 index 00000000..33348445 --- /dev/null +++ b/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallback.csproj @@ -0,0 +1,85 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {CF2A3245-3EB5-4247-8532-A09139EEC262} + Library + Properties + SampleCsMouseCallback + SampleCsMouseCallback + v4.5 + 512 + false + + + true + full + false + ..\bin\ + DEBUG;TRACE + prompt + false + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + False + C:\Program Files\Rhino 6\System\rhinocommon.dll + False + + + False + C:\Program Files\Rhino 6\System\Eto.dll + False + + + False + C:\Program Files\Rhino 6\System\Rhino.UI.dll + False + + + + + + + + + + + + + + + Copy "$(TargetPath)" "$(TargetDir)$(ProjectName).rhp" +Erase "$(TargetPath)" + + + en-US + + + C:\Program Files\Rhino 6\System\Rhino.exe + + + Program + + \ No newline at end of file diff --git a/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackCommand.cs b/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackCommand.cs new file mode 100644 index 00000000..6c364fb8 --- /dev/null +++ b/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackCommand.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using Rhino; +using Rhino.Commands; +using Rhino.Geometry; +using Rhino.Input; +using Rhino.Input.Custom; + +namespace SampleCsMouseCallback +{ + public class SampleCsMouseCallbackCommand : Command + { + readonly SampleMouseCallback smcb = new SampleMouseCallback(); + public SampleCsMouseCallbackCommand() + { + // Rhino only creates one instance of each command class defined in a + // plug-in, so it is safe to store a refence in a static property. + Instance = this; + } + + ///The only instance of this command. + public static SampleCsMouseCallbackCommand Instance + { + get; private set; + } + + ///The command name as it appears on the Rhino command line. + public override string EnglishName + { + get { return "SampleCsMouseCallbackCommand"; } + } + + protected override Result RunCommand(RhinoDoc doc, RunMode mode) + { + smcb.Enabled = !smcb.Enabled; + return Result.Success; + } + } +} diff --git a/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackPlugIn.cs b/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackPlugIn.cs new file mode 100644 index 00000000..e6dcc2fb --- /dev/null +++ b/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackPlugIn.cs @@ -0,0 +1,29 @@ +namespace SampleCsMouseCallback +{ + /// + /// Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived + /// class. DO NOT create instances of this class yourself. It is the + /// responsibility of Rhino to create an instance of this class. + /// To complete plug-in information, please also see all PlugInDescription + /// attributes in AssemblyInfo.cs (you might need to click "Project" -> + /// "Show All Files" to see it in the "Solution Explorer" window). + /// + public class SampleCsMouseCallbackPlugIn : Rhino.PlugIns.PlugIn + + { + public SampleCsMouseCallbackPlugIn() + { + Instance = this; + } + + ///Gets the only instance of the SampleCsMouseCallbackPlugIn plug-in. + public static SampleCsMouseCallbackPlugIn Instance + { + get; private set; + } + + // You can override methods here to change the plug-in behavior on + // loading and shut down, add options pages to the Rhino _Option command + // and maintain plug-in wide options in a document. + } +} \ No newline at end of file diff --git a/rhinocommon/cs/SampleCsMouseCallback/SampleMouseCallback.cs b/rhinocommon/cs/SampleCsMouseCallback/SampleMouseCallback.cs new file mode 100644 index 00000000..8af4d15a --- /dev/null +++ b/rhinocommon/cs/SampleCsMouseCallback/SampleMouseCallback.cs @@ -0,0 +1,31 @@ +using Rhino; +using Rhino.UI; + +namespace SampleCsMouseCallback +{ + public class SampleMouseCallback : MouseCallback + { + protected override void OnMouseEnter(MouseCallbackEventArgs e) + { + RhinoApp.WriteLine($"Entering view {e.View?.ActiveViewport?.Name}"); + } + + protected override void OnMouseHover(MouseCallbackEventArgs e) + { + RhinoApp.WriteLine($"Hovering on view {e.View?.ActiveViewport?.Name}"); + base.OnMouseHover(e); + } + + protected override void OnMouseLeave(MouseCallbackEventArgs e) + { + RhinoApp.WriteLine($"Leaving view {e.View?.ActiveViewport?.Name}"); + base.OnMouseLeave(e); + } + + protected override void OnMouseMove(MouseCallbackEventArgs e) + { + RhinoApp.WriteLine($"Moving over view {e.View?.ActiveViewport?.Name}"); + base.OnMouseMove(e); + } + } +} diff --git a/rhinocommon/cs/SamplesCs.sln b/rhinocommon/cs/SamplesCs.sln index 9e487e3b..64ef1fb3 100644 --- a/rhinocommon/cs/SamplesCs.sln +++ b/rhinocommon/cs/SamplesCs.sln @@ -69,6 +69,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleCsDeserializeEmbedded EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleCsDragDrop", "SampleCsDragDrop\SampleCsDragDrop.csproj", "{D94B1200-37DC-4DE7-856A-97ADDF3F965F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleCsMouseCallback", "SampleCsMouseCallback\SampleCsMouseCallback.csproj", "{CF2A3245-3EB5-4247-8532-A09139EEC262}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -195,6 +197,10 @@ Global {D94B1200-37DC-4DE7-856A-97ADDF3F965F}.Debug|Any CPU.Build.0 = Debug|Any CPU {D94B1200-37DC-4DE7-856A-97ADDF3F965F}.Release|Any CPU.ActiveCfg = Release|Any CPU {D94B1200-37DC-4DE7-856A-97ADDF3F965F}.Release|Any CPU.Build.0 = Release|Any CPU + {CF2A3245-3EB5-4247-8532-A09139EEC262}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF2A3245-3EB5-4247-8532-A09139EEC262}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF2A3245-3EB5-4247-8532-A09139EEC262}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF2A3245-3EB5-4247-8532-A09139EEC262}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE