Skip to content

Commit

Permalink
Add a MouseCallback sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesterKing committed Apr 25, 2019
1 parent 17dd8db commit fe1cc3a
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 0 deletions.
Binary file not shown.
59 changes: 59 additions & 0 deletions rhinocommon/cs/SampleCsMouseCallback/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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")]
85 changes: 85 additions & 0 deletions rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallback.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CF2A3245-3EB5-4247-8532-A09139EEC262}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SampleCsMouseCallback</RootNamespace>
<AssemblyName>SampleCsMouseCallback</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="RhinoCommon">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files\Rhino 6\System\rhinocommon.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Eto">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files\Rhino 6\System\Eto.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Rhino.UI">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files\Rhino 6\System\Rhino.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="SampleCsMouseCallbackCommand.cs" />
<Compile Include="SampleCsMouseCallbackPlugIn.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SampleMouseCallback.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="EmbeddedResources\plugin-utility.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>Copy "$(TargetPath)" "$(TargetDir)$(ProjectName).rhp"
Erase "$(TargetPath)"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<FallbackCulture>en-US</FallbackCulture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartProgram>C:\Program Files\Rhino 6\System\Rhino.exe</StartProgram>
<StartArguments>
</StartArguments>
<StartAction>Program</StartAction>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -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;
}

///<summary>The only instance of this command.</summary>
public static SampleCsMouseCallbackCommand Instance
{
get; private set;
}

///<returns>The command name as it appears on the Rhino command line.</returns>
public override string EnglishName
{
get { return "SampleCsMouseCallbackCommand"; }
}

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
smcb.Enabled = !smcb.Enabled;
return Result.Success;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace SampleCsMouseCallback
{
///<summary>
/// <para>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.</para>
/// <para>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).</para>
///</summary>
public class SampleCsMouseCallbackPlugIn : Rhino.PlugIns.PlugIn

{
public SampleCsMouseCallbackPlugIn()
{
Instance = this;
}

///<summary>Gets the only instance of the SampleCsMouseCallbackPlugIn plug-in.</summary>
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.
}
}
31 changes: 31 additions & 0 deletions rhinocommon/cs/SampleCsMouseCallback/SampleMouseCallback.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
6 changes: 6 additions & 0 deletions rhinocommon/cs/SamplesCs.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fe1cc3a

Please sign in to comment.