本文整理汇总了C#中System.Windows.Forms.ToolTip.GetToolTip方法的典型用法代码示例。如果您正苦于以下问题:C# ToolTip.GetToolTip方法的具体用法?C# ToolTip.GetToolTip怎么用?C# ToolTip.GetToolTip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ToolTip
的用法示例。
在下文中一共展示了ToolTip.GetToolTip方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveToolTipTest
public void RemoveToolTipTest ()
{
ToolTip myToolTip = new ToolTip ();
Button myButton = new Button ();
myToolTip.ShowAlways = true;
myToolTip.SetToolTip (myButton, "My Button");
myToolTip.RemoveAll ();
Assert.AreEqual ("", myToolTip.GetToolTip (myButton), "#Mtd2");
}
示例2: GetAndSetToolTipTest
public void GetAndSetToolTipTest ()
{
ToolTip myToolTip = new ToolTip ();
Button myButton = new Button ();
myToolTip.ShowAlways = true;
myToolTip.SetToolTip (myButton, "My Button");
string myString = myToolTip.GetToolTip (myButton);
Assert.AreEqual ("My Button", myString, "#Mtd1");
}
示例3: SetContainerTooltips
/// <summary>Sets the tooltip for controls found in composite containers to match their parents tooltip</summary>
/// <param name="aParent">The container parent control</param>
/// <param name="aTip">The tooltip control to update</param>
/// <remarks>
/// By default, the .NET ToolTip class will not display a tooltip when the mouse is over a child control in a
/// composite control, such as a UserControl derived class. Use this method to apply the composite controls
/// tooltip to child controls.
/// </remarks>
public static void SetContainerTooltips(this Control aParent, ToolTip aTip, string tip = null)
{
if (aParent == null || aParent.Controls == null || aParent.Controls.Count <= 0)
return;
foreach (Control lCtrl in aParent.Controls) {
if (lCtrl.Controls == null || aParent.Controls.Count <= 0)
continue;
string lTip = tip == null ? aTip.GetToolTip(lCtrl) : tip;
foreach (Control lChildCtrl in lCtrl.Controls)
aTip.SetToolTip(lChildCtrl, lTip);
}
}
示例4: LocaliseControl
private static void LocaliseControl(Control.ControlCollection ctl, ToolTip toolTip)
{
foreach (Control childCtl in ctl) // look for all child controls
{
//if (childCtl.GetType() != typeof(Button))
//{
// float fontSize = 1;
// SizeF stringSize;
// do
// {
// fontSize += (float)0.25;
// stringSize = sourceForm.CreateGraphics().MeasureString(childCtl.Text,
// new Font(childCtl.Font.Name, fontSize + (float)0.25));
// } while (stringSize.Width < childCtl.Width);
// childCtl.Font = ChangeFontSize(childCtl.Font, fontSize);
//}
toolTip.SetToolTip(childCtl, Localise.GetPhrase(toolTip.GetToolTip(childCtl)));
if (((childCtl.GetType() == typeof(Label))) || ((childCtl.GetType() == typeof(GroupBox))) || ((childCtl.GetType() == typeof(CheckBox))) || ((childCtl.GetType() == typeof(Button))))
{
childCtl.Text = Localise.GetPhrase(childCtl.Text);
LocaliseControl(childCtl.Controls, toolTip); // Localize recursively for nested controls
}
}
}
示例5: MsdnHelpTextPropertyTest
public override void MsdnHelpTextPropertyTest ()
{
ListBox listbox = GetControl () as ListBox;
ToolTip tooltip = new ToolTip ();
tooltip.SetToolTip (listbox, "I'm HelpTextProperty in listbox");
AutomationElement child = GetAutomationElementFromControl (listbox);
Assert.AreEqual (tooltip.GetToolTip (listbox),
child.GetCurrentPropertyValue (AutomationElementIdentifiers.HelpTextProperty, true),
"HelpTextProperty");
}
示例6: MsdnHelpTextPropertyTest
public override void MsdnHelpTextPropertyTest ()
{
LinkLabel linkLabel = GetControl () as LinkLabel;
ToolTip tooltip = new ToolTip ();
tooltip.SetToolTip (linkLabel, "I'm HelpTextProperty in button");
AutomationElement child = GetAutomationElementFromControl (linkLabel);
Assert.AreEqual (tooltip.GetToolTip (linkLabel),
child.GetCurrentPropertyValue (AutomationElementIdentifiers.HelpTextProperty, true),
"HelpTextProperty");
}
示例7: ToolTipOnDisabledControl_OnMouseMove
// <summary>
// Helper method to display a tooltip over a disabled control
// </summary>
internal static void ToolTipOnDisabledControl_OnMouseMove(
Object sender, MouseEventArgs e, Control disabledControl, ToolTip toolTip, ref Control controlWithToolTipShown)
{
var parent = sender as Control;
if (parent == null)
{
return;
}
var ctrl = parent.GetChildAtPoint(e.Location);
if (ctrl == disabledControl)
{
// if the user hover on control where tooltip is shown, just return.
if (ctrl == controlWithToolTipShown)
{
return;
}
var tipString = toolTip.GetToolTip(ctrl);
// calculate the screen coordinate of the mouse
toolTip.Show(tipString, ctrl, 2, ctrl.Height + 2);
controlWithToolTipShown = ctrl;
}
else if (controlWithToolTipShown != null)
{
toolTip.Hide(controlWithToolTipShown);
controlWithToolTipShown = null;
}
}
示例8: WriteControlEntry
private static void WriteControlEntry(ref StringBuilder stringBuilder, Control tmpControl, ToolTip tt, int depth, bool withIndent, bool asXml, bool hasChilds)
{
string ttText = string.Empty;
if (tt != null)
ttText = tt.GetToolTip(tmpControl);
bool hasToolTip = !string.IsNullOrEmpty(ttText);
NodeType nt = (!asXml) ? NodeType.SimpleSettings : (hasToolTip || hasChilds) ? NodeType.OpenControl : NodeType.ClosedControl;
WriteEntry(ref stringBuilder, tmpControl.Name, tmpControl.Text, depth, withIndent, nt);
if (hasToolTip)
{
WriteEntry(ref stringBuilder, tmpControl.Name + TOOLTIP, ttText, depth + 1, withIndent, (!asXml) ? NodeType.SimpleSettings : NodeType.ChildControl);
if (asXml && !hasChilds)
stringBuilder.AppendLine(new string(INDENT, depth) + CLOSE_CONTROL_XML_NODE);
}
}
示例9: Translate
//.........这里部分代码省略.........
Item.ToolTipText = _( catalog, Item.ToolTipText );
string itemType = Item.GetType().ToString();
if (
( itemType.IndexOf( "Forms.ToolStripMenuItem", StringComparison.InvariantCultureIgnoreCase ) >= 0 ) ||
( itemType.IndexOf( "Forms.ToolStripDropDownButton", StringComparison.InvariantCultureIgnoreCase ) >= 0 ) ||
( itemType.IndexOf( "Forms.ToolStripSplitButton", StringComparison.InvariantCultureIgnoreCase ) >= 0 )
)
{
Translate( catalog, Item, tooltip );
}
}
}
else if (
( objtype.IndexOf( "Forms.ComboBox", StringComparison.InvariantCultureIgnoreCase ) >= 0 )
)
{
ComboBox comboBox = myObject as ComboBox;
ComboBox.ObjectCollection oldItems = comboBox.Items as ComboBox.ObjectCollection;
List<string> newItems = new List<string>();
if ( oldItems != null )
{
try
{
foreach ( string Item in oldItems )
{
newItems.Add( _( catalog, Item ) );
}
comboBox.Items.Clear();
comboBox.Items.AddRange( newItems.ToArray() );
}
catch { }
}
}
else if ( myObject != null )
{
//Control obj = myObject as Control;
//var obj = myObject as Control;
//var obj = myObject;
//if ( myObject.GetType() == System.ComponentModel.Component )
// obj = myObject as System.ComponentModel.Component;
//else
// obj = myObject as Control;
var obj = myObject as Control;
if ( obj != null )
{
try
{
if ( !string.IsNullOrEmpty( obj.Text ) )
{
obj.Text = _( catalog, obj.Text );
}
if ( tooltip != null )
{
if( !string.IsNullOrEmpty(tooltip.ToolTipTitle ))
{
tooltip.ToolTipTitle = _( tooltip.ToolTipTitle );
}
//if ( !string.IsNullOrEmpty( obj.Text ) )
//{
// tooltip.ToolTipTitle = obj.Text;
//}
tooltip.SetToolTip( obj, _( catalog, tooltip.GetToolTip( obj ) ).Replace( "\\n", "\n" ) );
}
//try
//{
// if ( !obj.ToolTipText )
// {
// obj.ToolTipText = _( catalog, obj.ToolTipText );
// }
//}
//catch ( Exception ett )
//{
//}
}
catch ( Exception ee )
{
}
foreach ( Control child in obj.Controls )
{
Translate( catalog, child, tooltip );
}
}
}
}
#endregion
#region Translating extra
if ( extra != null )
{
foreach ( object control in extra )
{
Translate( catalog, control, tooltip );
}
}
#endregion
}