<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Rollover tooltip - code. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8385529#M24349</link>
    <description>&lt;P&gt;I don't know if this is exactly what you're looking for, but this snippet from @Anonymous shows how to add somethin in the AutoCAD tooltip.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/// PointMonitorClient.cs    Copyright(c) 2009   Tony Tanzillo
/// CaddZone AutoCAD Programming Samples - PointMonitorClient.cs
/// 
/// This sample code shows how to use the Editor's PointMonitor
/// event to display information about the entity currently under 
/// the pickbox in AutoCAD's tooltip.
/// 
/// In this example, we display the length of the Curve object
/// which the pickbox is hovering over, but in practicle use you
/// may display anything at all about any type of object(s).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;

using Acad = Autodesk.AutoCAD.ApplicationServices.Application;

[assembly: ExtensionApplication(typeof(PointMonitorToolTipExample.PointMonitorClient))]

namespace PointMonitorToolTipExample
{

    // IExtensionApplication
    public class MyApplication : IExtensionApplication
    {
        public void Initialize()
        {
            PointMonitorClient.Initialize();
        }

        public void Terminate()
        {
        }
    }

    internal class PointMonitorClient
    {

        // This is a dummy method that invokes the static constructor 
        // below. We place code that should never run more than once in
        // the static constructor, because .NET guarantees us that a 
        // static c'tor will never run multiple times.

        public static void Initialize()
        {
        }

        // Handle the PointMonitor event of all currently open documents,
        // and add event handlers to manage the point monitor events of
        // all subsequently opened and closed documents:

        // Static constructor
        static PointMonitorClient()
        {
            Acad.DocumentManager.DocumentCreated += documentCreated;
            Acad.DocumentManager.DocumentToBeDestroyed += documentToBeDestroyed;
            foreach (Document doc in Acad.DocumentManager)
                doc.Editor.PointMonitor += pointMonitor;
        }

        // The DocumentCreated event handler adds the PointMonitor event handler 
        // to each subsequently-opened document:
        static void documentCreated(object sender, DocumentCollectionEventArgs e)
        {
            if (e.Document != null)
                e.Document.Editor.PointMonitor += pointMonitor;
        }

        // The DocumentToBeDestroyed event handler removes the PointMonitor 
        // event handler from each document when it is closing:
        static void documentToBeDestroyed(object sender, DocumentCollectionEventArgs e)
        {
            if (e.Document != null)
                e.Document.Editor.PointMonitor -= pointMonitor;
        }

        // The PointMonitor Event Handler
        static void pointMonitor(object sender, PointMonitorEventArgs e)
        {
            // For this purpose we ignore events triggered by keyboard input:
            if ((e.Context.History &amp;amp; PointHistoryBits.FromKeyboard) == PointHistoryBits.FromKeyboard)
                return;

            // Get all entities in the aperture target:
            FullSubentityPath[] paths = e.Context.GetPickedEntities();

            // If none were found, bail out
            if (paths == null || paths.Length == 0)
                return;

            // There will be one FullSubentityPath in the array for each
            // top-level entity in the aperture target, so when there's
            // multiple entities in aperture target, we must select the
            // correct one. 
            //
            // The first ObjectId in the first FullSubEntityPath (if there's
            // more than one) is the entity that should be highlighted by
            // rollover highlighting, so we use that same object here. Note
            // that this example does not support nested objects even though
            // that's possible given the data returned by GetPickedEntities().

            ObjectId[] ids = paths[0].GetObjectIds();

            if (ids == null || ids.Length == 0)
                return;

            ObjectId id = ids[0];  // The first ObjectId is the top-level entity

            // Use the RXClass returned by the ObjectId's ObjectClass property 
            // to determine if the object is a Curve. Note that this is a more 
            // efficient way to query the type of an object, verses opening it 
            // and examining its managed wrapper type:

            if (id.IsValid &amp;amp;&amp;amp; id.ObjectClass.IsDerivedFrom(curveClass))
            {

                // Start a transaction:
                using (Transaction tr = id.Database.TransactionManager.StartTransaction())
                {
                    // Open the object and cast it to a Curve:
                    Curve curve = tr.GetObject(id, OpenMode.ForRead) as Curve;

                    // Try to get the curve's length:
                    double length = curve.TryGetLength(-1.0);

                    // If a valid length was returned, then 
                    // convert it to current distance units 
                    // format and add that to the tooltip text:

                    if (length &amp;gt; 0.0)
                    {
                        e.AppendToolTipText(
                            string.Format(
                                "Curve length: {0}",
                                Converter.DistanceToString(length)));
                    }

                    tr.Commit();
                }
            }
        }

        static RXClass curveClass = RXObject.GetClass(typeof(Curve));

        static RXClass blockRefClass = RXClass.GetClass(typeof(BlockReference));
    }

    public static class ExtensionMethods
    {
        // This extension method returns the length of any curve
        // which has a valid length (Rays and XLines do not have
        // a length, or more precisely, are of infinite length, so 
        // we must deal with those as well as various other cases).

        // When a curve doesn't have a valid length or is of infinite
        // length, an exception is thrown by one of the members used
        // here, so we just catch the exception and return the default
        // parameter.

        // Note that some curves (namely arcs and elliptical arcs) 
        // do not necessarily have a start parameter of 0.0, which 
        // means their length is the distance from the start param
        // to the end param, so we must subtract the distance to the
        // point at the start param from the distance to the point
        // at the end param to ensure we get the actual length:

        public static double TryGetLength(this Curve curve, double defaultValue)
        {
            try
            {
                return Math.Abs(curve.GetDistanceAtParameter(curve.EndParam) - curve.GetDistanceAtParameter(curve.StartParam));
            }
            catch
            {
                return defaultValue;
            }
        }

        public static int CountInsertsInSpace(this BlockTableRecord btr, ObjectId spaceId)
        {
            int cnt = 0;
            foreach (ObjectId brId in btr.GetBlockReferenceIds(true, false))
            {
                BlockReference br = (BlockReference)brId.GetObject(OpenMode.ForRead);
                if (br.OwnerId == spaceId) cnt++;
            }
            return cnt;
        }
    }
}&lt;/PRE&gt;</description>
    <pubDate>Wed, 07 Nov 2018 11:14:53 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2018-11-07T11:14:53Z</dc:date>
    <item>
      <title>Rollover tooltip - code.</title>
      <link>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8385407#M24348</link>
      <description>&lt;P&gt;Hello everyone!&lt;/P&gt;&lt;P&gt;I'm curious if there is an option to get the code for the rollover tooltip. I wan to see how it is made.&lt;/P&gt;&lt;P&gt;Probably it's a UserControl that replaces the standard .NET Tooltip, am I right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody help me with this issue?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 10:18:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8385407#M24348</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-07T10:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Rollover tooltip - code.</title>
      <link>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8385529#M24349</link>
      <description>&lt;P&gt;I don't know if this is exactly what you're looking for, but this snippet from @Anonymous shows how to add somethin in the AutoCAD tooltip.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/// PointMonitorClient.cs    Copyright(c) 2009   Tony Tanzillo
/// CaddZone AutoCAD Programming Samples - PointMonitorClient.cs
/// 
/// This sample code shows how to use the Editor's PointMonitor
/// event to display information about the entity currently under 
/// the pickbox in AutoCAD's tooltip.
/// 
/// In this example, we display the length of the Curve object
/// which the pickbox is hovering over, but in practicle use you
/// may display anything at all about any type of object(s).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;

using Acad = Autodesk.AutoCAD.ApplicationServices.Application;

[assembly: ExtensionApplication(typeof(PointMonitorToolTipExample.PointMonitorClient))]

namespace PointMonitorToolTipExample
{

    // IExtensionApplication
    public class MyApplication : IExtensionApplication
    {
        public void Initialize()
        {
            PointMonitorClient.Initialize();
        }

        public void Terminate()
        {
        }
    }

    internal class PointMonitorClient
    {

        // This is a dummy method that invokes the static constructor 
        // below. We place code that should never run more than once in
        // the static constructor, because .NET guarantees us that a 
        // static c'tor will never run multiple times.

        public static void Initialize()
        {
        }

        // Handle the PointMonitor event of all currently open documents,
        // and add event handlers to manage the point monitor events of
        // all subsequently opened and closed documents:

        // Static constructor
        static PointMonitorClient()
        {
            Acad.DocumentManager.DocumentCreated += documentCreated;
            Acad.DocumentManager.DocumentToBeDestroyed += documentToBeDestroyed;
            foreach (Document doc in Acad.DocumentManager)
                doc.Editor.PointMonitor += pointMonitor;
        }

        // The DocumentCreated event handler adds the PointMonitor event handler 
        // to each subsequently-opened document:
        static void documentCreated(object sender, DocumentCollectionEventArgs e)
        {
            if (e.Document != null)
                e.Document.Editor.PointMonitor += pointMonitor;
        }

        // The DocumentToBeDestroyed event handler removes the PointMonitor 
        // event handler from each document when it is closing:
        static void documentToBeDestroyed(object sender, DocumentCollectionEventArgs e)
        {
            if (e.Document != null)
                e.Document.Editor.PointMonitor -= pointMonitor;
        }

        // The PointMonitor Event Handler
        static void pointMonitor(object sender, PointMonitorEventArgs e)
        {
            // For this purpose we ignore events triggered by keyboard input:
            if ((e.Context.History &amp;amp; PointHistoryBits.FromKeyboard) == PointHistoryBits.FromKeyboard)
                return;

            // Get all entities in the aperture target:
            FullSubentityPath[] paths = e.Context.GetPickedEntities();

            // If none were found, bail out
            if (paths == null || paths.Length == 0)
                return;

            // There will be one FullSubentityPath in the array for each
            // top-level entity in the aperture target, so when there's
            // multiple entities in aperture target, we must select the
            // correct one. 
            //
            // The first ObjectId in the first FullSubEntityPath (if there's
            // more than one) is the entity that should be highlighted by
            // rollover highlighting, so we use that same object here. Note
            // that this example does not support nested objects even though
            // that's possible given the data returned by GetPickedEntities().

            ObjectId[] ids = paths[0].GetObjectIds();

            if (ids == null || ids.Length == 0)
                return;

            ObjectId id = ids[0];  // The first ObjectId is the top-level entity

            // Use the RXClass returned by the ObjectId's ObjectClass property 
            // to determine if the object is a Curve. Note that this is a more 
            // efficient way to query the type of an object, verses opening it 
            // and examining its managed wrapper type:

            if (id.IsValid &amp;amp;&amp;amp; id.ObjectClass.IsDerivedFrom(curveClass))
            {

                // Start a transaction:
                using (Transaction tr = id.Database.TransactionManager.StartTransaction())
                {
                    // Open the object and cast it to a Curve:
                    Curve curve = tr.GetObject(id, OpenMode.ForRead) as Curve;

                    // Try to get the curve's length:
                    double length = curve.TryGetLength(-1.0);

                    // If a valid length was returned, then 
                    // convert it to current distance units 
                    // format and add that to the tooltip text:

                    if (length &amp;gt; 0.0)
                    {
                        e.AppendToolTipText(
                            string.Format(
                                "Curve length: {0}",
                                Converter.DistanceToString(length)));
                    }

                    tr.Commit();
                }
            }
        }

        static RXClass curveClass = RXObject.GetClass(typeof(Curve));

        static RXClass blockRefClass = RXClass.GetClass(typeof(BlockReference));
    }

    public static class ExtensionMethods
    {
        // This extension method returns the length of any curve
        // which has a valid length (Rays and XLines do not have
        // a length, or more precisely, are of infinite length, so 
        // we must deal with those as well as various other cases).

        // When a curve doesn't have a valid length or is of infinite
        // length, an exception is thrown by one of the members used
        // here, so we just catch the exception and return the default
        // parameter.

        // Note that some curves (namely arcs and elliptical arcs) 
        // do not necessarily have a start parameter of 0.0, which 
        // means their length is the distance from the start param
        // to the end param, so we must subtract the distance to the
        // point at the start param from the distance to the point
        // at the end param to ensure we get the actual length:

        public static double TryGetLength(this Curve curve, double defaultValue)
        {
            try
            {
                return Math.Abs(curve.GetDistanceAtParameter(curve.EndParam) - curve.GetDistanceAtParameter(curve.StartParam));
            }
            catch
            {
                return defaultValue;
            }
        }

        public static int CountInsertsInSpace(this BlockTableRecord btr, ObjectId spaceId)
        {
            int cnt = 0;
            foreach (ObjectId brId in btr.GetBlockReferenceIds(true, false))
            {
                BlockReference br = (BlockReference)brId.GetObject(OpenMode.ForRead);
                if (br.OwnerId == spaceId) cnt++;
            }
            return cnt;
        }
    }
}&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Nov 2018 11:14:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8385529#M24349</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-11-07T11:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rollover tooltip - code.</title>
      <link>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8385963#M24350</link>
      <description>&lt;P&gt;Besides the code posted by &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;, If you want to make the rollover tooltip more presentable, you may want to read this article of mine posted about 2 years ago:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive-cad-with-code.blogspot.com/2016/12/custom-autocad-entity-tool-tip.html" target="_blank"&gt;https://drive-cad-with-code.blogspot.com/2016/12/custom-autocad-entity-tool-tip.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;assuming you know AutoCAD .NET API programming well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 14:10:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8385963#M24350</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2018-11-07T14:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Rollover tooltip - code.</title>
      <link>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8388635#M24351</link>
      <description>&lt;P&gt;Thank you for your response, &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;. That's not exactly what I want to have - I don't want to change/edit/modify the existing Rollover tooltip but get to the code of the existing one that is build-in the AutoCAD API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to achieve the same effect of ToolTip in another application and I don't want to use any AutoCAD references.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;, thank you for the link - this tutorial gets me a little bit closer to the final result that I'm looking for. But still - the result is not the same as AutoCAD Rollover ToolTip. Do you know how to improve the code from your tutorial? I'm not a best WPF developer in the world &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 13:04:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8388635#M24351</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-08T13:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Rollover tooltip - code.</title>
      <link>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8388850#M24352</link>
      <description>&lt;P&gt;Now, after second reading of your original post and your reply, it seems you are not interested in doing your own rollowner tip in AutoCAD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I am not sure what you want and what does "&lt;EM&gt;...&amp;nbsp;&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;get the code for the rollover tooltip...&lt;/EM&gt;" mean, especially, what does "&lt;STRONG&gt;code&lt;/STRONG&gt;" mean here? Also. if you want to do something similar to AutoCAD's rollover tip in different application other than AutoCAD, I am afraid nothing discussed in this forum would help you, because all things discussed USE APIs provided by AutoCAD and HAVE TO BE running in AutoCAD.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 14:12:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8388850#M24352</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2018-11-08T14:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Rollover tooltip - code.</title>
      <link>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8391499#M24353</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;You're right, in this specific case I'm talking about another application.&lt;/P&gt;&lt;P&gt;In my job, I work with AutoCAD and TeklaSoftware&amp;nbsp;(plugins, extensions etc.). Sometimes I mix the best features from both of them. This time, I want to create this tooltip in my Tekla plugin. This feature of AutoCAD is one of the best I've ever seen.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 13:24:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/rollover-tooltip-code/m-p/8391499#M24353</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-09T13:24:46Z</dc:date>
    </item>
  </channel>
</rss>

