Modify Tooltip

Modify Tooltip

mehdi-guida
Advocate Advocate
478 Views
1 Reply
Message 1 of 2

Modify Tooltip

mehdi-guida
Advocate
Advocate

Hi,

How can i modify tootips to show custom informations (by .Net)?

0 Likes
479 Views
1 Reply
Reply (1)
Message 2 of 2

Jeff_M
Consultant
Consultant

You can create your own tooltips:

https://forums.autodesk.com/t5/net/rollover-tooltip-code/td-p/8385407

 

Or, you can recreate the actual rollover tool tip which, I believe, is a little more difficult. Here is a small example where I added the LayerState saved to a viewport. The toolTipOID is saved to a global variable when the object being rolled over is a VIEWPORT.

Modified VP Tooltip.pngNormal VP Tooltip.png

 

        private static void ComponentManager_ToolTipOpened(object sender, EventArgs e)
        {
            var ttString = "<No LayerState set>";
            if (toolTipOID != ObjectId.Null && Application.GetSystemVariable("RollOverTips").ToString() == "1" && Application.GetSystemVariable("USEQUUXVPTOOLTIP").ToString() == "1")
            {
                var toolTip = sender as ToolTip;
                if (toolTip != null)
                {
                    var lsm = new LayerStateManager(HostApplicationServices.WorkingDatabase);
                    foreach (string ls in lsm.GetLayerStateNames(false, false))
                    {
                        if (lsm.CompareLayerStateToDb(ls, toolTipOID))
                        {
                            ttString = ls;
                            break;
                        }
                    }
                    var vp = (Viewport)toolTipOID.Open(OpenMode.ForRead);
                    var newToolTip = new WPFControls.ToolTipCustomContent
                    {
                        MaxWidth = 600,
                        ClassName = { Text = toolTipOID.ObjectClass.DxfName }
                    };
                    newToolTip.LayerName.Text = vp.Layer;
                    newToolTip.LayerState.Text = ttString;
                    var stdScale = vp.StandardScale.ToString().Replace("Scale", "").Replace("To", "\" = ") + "'";
                    if (Application.GetSystemVariable("MEASUREMENT").ToString() == "1")
                    {
                        stdScale = vp.StandardScale.ToString().Replace("Scale", "").Replace("To", " : ");
                    }
                    newToolTip.StandardScale.Text = stdScale;
                    newToolTip.CustomScale.Text = vp.CustomScale.ToString("F4");
                    var colorname = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(vp.Color.ColorNameForDisplay);
                    newToolTip.Color.Text = colorname == "BYLAYER" ? "ByLayer" : colorname;
                    newToolTip.ColorButton.Background = vp.ColorBrush();
                    newToolTip.LayerOverride.Text = vp.HasLayerOverrides()== false ? "No" : "Yes";
                    toolTip.Content = newToolTip;
                    vp.Close();
                    vp.Dispose();
                }
            }
        }

 

Jeff_M, also a frequent Swamper
EESignature
0 Likes