<?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: How to replace AutoCAD rollover tooltips for a custom WPF user control? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927229#M37829</link>
    <description>&lt;P&gt;sorry about this mis interpretation.&lt;/P&gt;&lt;P&gt;For tooltips on objects i'll (mis) use hyperlinks for that purpose, like in this pseudo code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (HyperLinkCollection hyperlinks = TheEntity.Hyperlinks)&lt;BR /&gt;{&lt;BR /&gt;using (HyperLink newHyperLink = new HyperLink())&lt;BR /&gt;{&lt;BR /&gt;newHyperLink.Description = "Some Description";&lt;BR /&gt;newHyperLink.Name = "Some Name";&lt;BR /&gt;newHyperLink.SubLocation = "Some Description";&lt;BR /&gt;hyperlinks.Add(newHyperLink);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Nov 2015 15:31:46 GMT</pubDate>
    <dc:creator>SENL1362</dc:creator>
    <dc:date>2015-11-27T15:31:46Z</dc:date>
    <item>
      <title>How to replace AutoCAD rollover tooltips for a custom WPF user control?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927055#M37826</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I go about replacing the stock rollover tooltip for my own WPF user control whenever a certain type of object is hovered over?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it even possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2015 12:42:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927055#M37826</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-11-27T12:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace AutoCAD rollover tooltips for a custom WPF user control?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927142#M37827</link>
      <description>&lt;A href="http://adndevblog.typepad.com/autocad/2012/05/change-tooltip-of-ribbon-button-using-runtime-ribbon-api-not-cui-api.html" target="_blank"&gt;http://adndevblog.typepad.com/autocad/2012/05/change-tooltip-of-ribbon-button-using-runtime-ribbon-api-not-cui-api.html&lt;/A&gt;&lt;BR /&gt;RibbonToolTip toolTip = myRibbonButton.ToolTip as RibbonToolTip;&lt;BR /&gt;if (toolTip == null)&lt;BR /&gt;return;&lt;BR /&gt;toolTip.Title = "New Title";&lt;BR /&gt;toolTip.Content = "New Content";</description>
      <pubDate>Fri, 27 Nov 2015 14:28:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927142#M37827</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-11-27T14:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace AutoCAD rollover tooltips for a custom WPF user control?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927154#M37828</link>
      <description>That works on ribbon tooltips only, right?&lt;BR /&gt;I meant the rollover tooltips when I hover a certain object in the drawing, for example an Xref block, a line or anyother object...</description>
      <pubDate>Fri, 27 Nov 2015 14:35:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927154#M37828</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-11-27T14:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace AutoCAD rollover tooltips for a custom WPF user control?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927229#M37829</link>
      <description>&lt;P&gt;sorry about this mis interpretation.&lt;/P&gt;&lt;P&gt;For tooltips on objects i'll (mis) use hyperlinks for that purpose, like in this pseudo code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (HyperLinkCollection hyperlinks = TheEntity.Hyperlinks)&lt;BR /&gt;{&lt;BR /&gt;using (HyperLink newHyperLink = new HyperLink())&lt;BR /&gt;{&lt;BR /&gt;newHyperLink.Description = "Some Description";&lt;BR /&gt;newHyperLink.Name = "Some Name";&lt;BR /&gt;newHyperLink.SubLocation = "Some Description";&lt;BR /&gt;hyperlinks.Add(newHyperLink);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2015 15:31:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927229#M37829</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-11-27T15:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace AutoCAD rollover tooltips for a custom WPF user control?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927268#M37830</link>
      <description>&lt;P&gt;Yes, you can.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First you need to add two event handlers to your code. &amp;nbsp;These should be added to every open document and to each newly opened/created document.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;            ComponentManager.ToolTipOpened += ComponentManager_ToolTipOpened;
            document.Editor.PointMonitor += Editor_PointMonitor;&lt;/PRE&gt;
&lt;P&gt;In the point monitor event handler you should monitor the object being hovered over and determine if it is the object that you wish to display the tooltip for. &amp;nbsp;In the code below I am looking at AutoCAD MEP objects to determine if they need to display a custom tooltip.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        private static ObjectId toolTipObjectId = ObjectId.Null;

        public static void PointMonitor(object sender, PointMonitorEventArgs e)
        {
            toolTipObjectId = ObjectId.Null;

            if (Application.GetSystemVariable("RollOverTips").ToString() != "1" || !SuperToolTipSettings.EnableSuperToolTips)
                return;

            if ((e.Context.History &amp;amp; PointHistoryBits.FromKeyboard) == PointHistoryBits.FromKeyboard)
                return;

            FullSubentityPath[] paths = e.Context.GetPickedEntities();

            if (paths == null || paths.Length == 0)
                return;

            ObjectId[] ids = paths[0].GetObjectIds();

            if (ids == null || ids.Length == 0)
                return;

            var i = 0;

            if (!ids[i].IsValid)
                return;
            GetClass(ids, i)
            ;

        }

        private static void GetClass(ObjectId[] ids, int i)
        {
            if ((ids[i].ObjectClass.Name == "AecbDbDuct") ||
                        (ids[i].ObjectClass.Name == "AecbDbDuctFitting") ||
                        (ids[i].ObjectClass.Name == "AecbDbDuctCustomFitting") ||
                        (ids[i].ObjectClass.Name == "AecbDbDuctFlex") ||
                        (ids[i].ObjectClass.Name == "AecbDbPipe") ||
                        (ids[i].ObjectClass.Name == "AecbDbPipeFitting") &amp;amp;&amp;amp; SuperToolTipSettings.DisplayPipeFittings) ||
                        (ids[i].ObjectClass.Name == "AecbDbPipeCustomFitting") ||
                        (ids[i].ObjectClass.Name == "AecbDbPipeFlex") &amp;amp;&amp;amp; SuperToolTipSettings.DisplayFlexPipe) ||
                        (ids[i].ObjectClass.Name == "AecbDbCableTray" &amp;amp;&amp;amp; SuperToolTipSettings.DisplayCableTray) ||
                        (ids[i].ObjectClass.Name == "AecbDbCableTrayFitting") ||
                        (ids[i].ObjectClass.Name == "AecbDbConduit") ||
                        (ids[i].ObjectClass.Name == "AecbDbConduitFitting" &amp;amp;&amp;amp; SuperToolTipSettings.DisplayConduitFittings) ||
                        (ids[i].ObjectClass.Name == "AecbDbSchematicPipe") ||
                        (ids[i].ObjectClass.Name == "AecbDbSchematicPipeFitting") ||
                        (ids[i].ObjectClass.Name == "AecbDbSchematic") ||
                        (ids[i].ObjectClass.Name == "AecbDbSchematicSymbol") ||
                        (ids[i].ObjectClass.Name == "AecbDbDevice") ||
                        (ids[i].ObjectClass.Name == "AecbDbPanel") ||
                        (ids[i].ObjectClass.Name == "AecbDbWire") ||
                        (ids[i].ObjectClass.Name == "AecbDbMvPart"))
            {
                toolTipObjectId = ids[i];
            }

            if (ids[i].ObjectClass.Name == "AcDbBlockReference")
            {
                GetClass(ids, i + 1);
            }
        }&lt;/PRE&gt;
&lt;P&gt;The code above is recursive and will delve into block references and xrefs to find the object and store the objectID of the object being hovered over.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have the objectId of a object you wish to display a new tooltip for you will need to display the tooltip. &amp;nbsp;The code in the tooltipopened event handler takes care of this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        public static void ComponentManager_ToolTipOpened(object sender, EventArgs e)
        {
            if (toolTipObjectId != ObjectId.Null &amp;amp;&amp;amp; Application.GetSystemVariable("RollOverTips").ToString() == "1")
            {
                var toolTip = sender as ToolTip;

                // This check is needed to distinguish between the ribbon tooltips and the entity tooltips
                if (toolTip != null)
                {
                    Member member = null;
                    using (Transaction transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartOpenCloseTransaction())
                    {
                        member = transaction.GetObject(toolTipObjectId, 0) as Member;
                        transaction.Commit();
                    }
                    if (member != null)
                    {
                    var memberToolTip = new SuperToolTipDisplay
                    {
                        MaxWidth = 600,
                        ClassName = {Text = "Object Type"}
                    };


                        // Repeat this section for each property of the object to add to the tooltip&lt;BR /&gt;                        // I added generic text for this sample but you would instead get properties from the object&lt;BR /&gt;                        // and display them here.  The blockName would be the name of the property and the blockValue&lt;BR /&gt;                        // would be the value of the property.
                        {
                            var blockName = new TextBlock();
                            var blockValue = new TextBlock();

                            blockName.Text = "Property Name";
                            blockName.Margin = new Thickness(0.0, 5.0, 0.0, 0.0);
                            blockName.HorizontalAlignment = HorizontalAlignment.Left;
                            blockName.VerticalAlignment = VerticalAlignment.Center;

                            blockValue.Text = "Property Value";

                            blockValue.Margin = new Thickness(10.0, 5.0, 10.0, 0.0);
                            blockValue.TextWrapping = TextWrapping.Wrap;
                            blockValue.HorizontalAlignment = HorizontalAlignment.Left;
                            blockValue.VerticalAlignment = VerticalAlignment.Center;

                            memberToolTip.StackPanelName.Children.Add(blockName);
                            memberToolTip.StackPanelValue.Children.Add(blockValue);

                            // Because BlockValue textblock can have wrapped text we need to set the height
                            // of the BlockName textblock to equal that of the BlockValue textblock.
                            // We need to give the wpf layout engine time to calculate the actual height
                            // so that we can set the values.
                            memberToolTip.StackPanelValue.Dispatcher.BeginInvoke(
                                DispatcherPriority.Background,
                                new DispatcherOperationCallback(delegate
                                {
                                    blockName.Height = blockValue.ActualHeight;
                                    return null;
                                }), null);
                        }



                        // Swap out the AutoCAD ToolTip with our own ToolTip
                        toolTip.Content = memberToolTip;
                        member.Dispose();
                    }
                }

                // Reset the object for the next tooltip
                toolTipObjectId = ObjectId.Null;
            }&lt;/PRE&gt;
&lt;P&gt;The xaml for the wpf user control to replace the tooltip.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;UserControl x:Class="SuperToolTipDisplay"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"&amp;gt;

    &amp;lt;Grid x:Name="RootGrid" HorizontalAlignment="Left" VerticalAlignment="Top"&amp;gt;
        &amp;lt;TextBlock x:Name="ClassName" TextWrapping="Wrap" Text="TextBlock" Margin ="10,10,10,10" FontWeight="Bold" HorizontalAlignment="Left" VerticalAlignment="Top"/&amp;gt;
        &amp;lt;DockPanel x:Name="LineContainer" HorizontalAlignment="Left" Margin="10,30,10,10" VerticalAlignment="Top"&amp;gt;
            &amp;lt;StackPanel x:Name="StackPanelName" Orientation="Vertical" VerticalAlignment="Top" MaxWidth="290"/&amp;gt;
            &amp;lt;WrapPanel x:Name="StackPanelValue" Orientation="Vertical" VerticalAlignment="Top" /&amp;gt;
        &amp;lt;/DockPanel&amp;gt;

    &amp;lt;/Grid&amp;gt;
&amp;lt;/UserControl&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That should be enough to get you going. &amp;nbsp;I grabbed the code out of an active project and think that I got everything. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In summary, you check the object being hovered over to get its objectId and check that objectid againt a list of objects you are monitoring. &amp;nbsp;Then once the tooltip for that object is opened check to see if it is a object that we want and then replace the tooltip panel with one of our own creation. &amp;nbsp;I have been unsuccessful in adding an image to the tooltip but I believe it is possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See this link. &amp;nbsp;&lt;A href="http://stackoverflow.com/questions/10873263/autocad-infobox-functionality" target="_self"&gt;http://stackoverflow.com/questions/10873263/autocad-infobox-functionality&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2015 16:10:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927268#M37830</guid>
      <dc:creator>Keith.Brown</dc:creator>
      <dc:date>2015-11-27T16:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace AutoCAD rollover tooltips for a custom WPF user control?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927283#M37831</link>
      <description>&lt;P&gt;I have been using this code for a couple years to display custom tooltips and it works extremely well and extremely fast. &amp;nbsp; I need to spend some time and come back to this code and "adjust" it to be able to display an image in the tooltip. &amp;nbsp;Let me know if you have any issues with it and I will create a sample project that will show the complete code.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2015 16:17:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927283#M37831</guid>
      <dc:creator>Keith.Brown</dc:creator>
      <dc:date>2015-11-27T16:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace AutoCAD rollover tooltips for a custom WPF user control?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927287#M37832</link>
      <description>Thanks Keith.Brown! This is exactly what i've been looking for. This will certainly get me started! I reckon I should have no problem implementing bindings to display the entity's properties (using the MVVM pattern), am I right?&lt;BR /&gt;Again, thanks a lot!</description>
      <pubDate>Fri, 27 Nov 2015 16:24:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/5927287#M37832</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-11-27T16:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace AutoCAD rollover tooltips for a custom WPF user control?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/6761295#M37833</link>
      <description>&lt;P&gt;Keith,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Inspired by the discussion here and your code, I post an article &lt;A href="http://drive-cad-with-code.blogspot.ca/2016/12/custom-autocad-entity-tool-tip.html" target="_self"&gt;here&lt;/A&gt;. Do you still have issue of displaying image in tool tip? It seems I do not have problem showing image here. The picture used in my code is PNG with size of over 1MB, which could be considered "fairly big" for tool tip.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 18:43:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/6761295#M37833</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2016-12-20T18:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace AutoCAD rollover tooltips for a custom WPF user control?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/6761522#M37834</link>
      <description>&lt;P&gt;Hi Norman,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nice write up and thanks for the shout out!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was able to finally get an image to display. &amp;nbsp;At the time it was my lack of understanding of WPF that caused the issue but eventually &amp;nbsp;I did something very similar to your code where you are converting the image to get it to work.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 19:50:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-replace-autocad-rollover-tooltips-for-a-custom-wpf-user/m-p/6761522#M37834</guid>
      <dc:creator>Keith.Brown</dc:creator>
      <dc:date>2016-12-20T19:50:42Z</dc:date>
    </item>
  </channel>
</rss>

