GetToolTip() приватный Метод

private GetToolTip ( Control control ) : string
control Control
Результат string
Пример #1
0
        void _flex_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (_colResize > -1)
            {
                // user canceled resizing
                if (_flex.Cursor == Cursors.Default)
                {
                    _colResize = -1;
                    _tip.SetToolTip(_flex, null);
                    return;
                }

                // update tooltip
                int width = _flex.Cols[_colResize].WidthDisplay;
                width += Control.MousePosition.X - _startX;
                if (width < 0)
                {
                    width = 0;
                }
                string tip = string.Format("{0} pixels", width);
                if (tip != _tip.GetToolTip(_flex))
                {
                    _tip.SetToolTip(_flex, tip);
                }
            }
        }
Пример #2
0
 private void toolTip_Popup(object sender, PopupEventArgs e)
 {
     using (Font f = new Font("Segoe", 10f, FontStyle.Bold))
     {
         e.ToolTipSize = TextRenderer.MeasureText(
             ToolTip1.GetToolTip(e.AssociatedControl), f) + new Size(0, 8);
     }
 }
Пример #3
0
		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");
		}
Пример #4
0
		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");
		}
Пример #5
0
 // Determines the correct size for the button2 ToolTip.
 private void toolTip_Popup(object sender, PopupEventArgs e)
 {
     if (e.AssociatedControl == fpPictureBox2)
     {
         using (Font f = new Font("Tahoma", 9))
         {
             e.ToolTipSize = TextRenderer.MeasureText(_toolTip.GetToolTip(e.AssociatedControl), f);
         }
     }
 }
        /// <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);
            }
        }
Пример #7
0
        private void listViewFaces_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ListViewItem item = listViewFaces.GetItemAt(e.X, e.Y);

            if (item != null)
            {
                string tooltipText = String.Format("タイトル: {0}\n製作者: {1}\nバージョン: {2}",
                                                   item.Text, item.SubItems[2].Text, item.SubItems[3].Text);

                if (toolTipPreviewDetail.GetToolTip(listViewFaces) != tooltipText)
                {
                    toolTipPreviewDetail.SetToolTip(listViewFaces, tooltipText);
                }
            }
            else
            {
                // 消す。
                toolTipPreviewDetail.SetToolTip(listViewFaces, "");
            }
        }
            protected override void OnMouseMove(MouseEventArgs e)
            {
                base.OnMouseMove(e);

                if (base.m_ItemUnderMouse != null)
                {
                    string tooltip = string.Format("'{0}' appears in {1} task(s)",
                                                   base.m_ItemUnderMouse.Word.Text,
                                                   base.m_ItemUnderMouse.Word.Occurrences);

                    if (m_ToolTip.GetToolTip(this) != tooltip)
                    {
                        m_ToolTip.SetToolTip(this, tooltip);
                    }
                }
                else
                {
                    m_ToolTip.SetToolTip(this, "");
                }
            }
Пример #9
0
 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
         }
     }
 }
Пример #10
0
		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");
		}
Пример #11
0
		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");
		}
 // <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;
     }
 }
        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);
            }
        }
        public static void Translate( ICatalog catalog, object myObject, ToolTip tooltip, object[] extra )
        {
            #region Translating myObject
            if ( myObject != null )
            {
                string objtype = myObject.GetType().ToString();
                if ( objtype.IndexOf( "Forms.ToolStripContainer", StringComparison.InvariantCultureIgnoreCase ) >= 0 )
                {
                    //continue;
                }
                //System.Windows.Forms.ColorDialog
                //System.Windows.Forms.FileDialog
                //System.Windows.Forms.FolderBrowserDialog
                //System.Windows.Forms.FontDialog
                //System.Windows.Forms.PageSetupDialog
                //System.Windows.Forms.PrintDialog
                else if (
                    ( objtype.IndexOf( "Forms.OpenFileDialog", StringComparison.InvariantCultureIgnoreCase ) >= 0 ) ||
                    ( objtype.IndexOf( "Forms.SaveFileDialog", StringComparison.InvariantCultureIgnoreCase ) >= 0 )
                        )
                {
                    FileDialog dlg = myObject as FileDialog;
                    dlg.Title = _( catalog, dlg.Title );
                    dlg.Filter = _( catalog, dlg.Filter );
                }
                else if (
                    ( objtype.IndexOf( "Forms.ToolStripMenuItem", StringComparison.InvariantCultureIgnoreCase ) >= 0 ) ||
                    ( objtype.IndexOf( "Forms.ToolStripDropDownItem", StringComparison.InvariantCultureIgnoreCase ) >= 0 )
                        )
                {
                    ToolStripMenuItem menuitems = myObject as ToolStripMenuItem;
                    foreach ( ToolStripMenuItem Item in menuitems.DropDownItems )
                    {
                        Item.Text = _( catalog, Item.Text );
                        if ( Item.DropDownItems.Count > 0 )
                        {
                            Translate( catalog, Item, tooltip );
                        }
                    }
                }
                else if (
                    ( objtype.IndexOf( "Forms.ToolStripDropDownButton", StringComparison.InvariantCultureIgnoreCase ) >= 0 )
                        )
                {
                    ToolStripDropDownButton menuitems = myObject as ToolStripDropDownButton;
                    foreach ( ToolStripMenuItem Item in menuitems.DropDownItems )
                    {
                        Item.Text = _( catalog, Item.Text );
                        if ( Item.DropDownItems.Count > 0 )
                        {
                            Translate( catalog, Item, tooltip );
                        }
                    }
                }
                else if (
                    ( objtype.IndexOf( "Forms.ToolStripSplitButton", StringComparison.InvariantCultureIgnoreCase ) >= 0 )
                        )
                {
                    ToolStripSplitButton menuitems = myObject as ToolStripSplitButton;
                    foreach ( ToolStripMenuItem Item in menuitems.DropDownItems )
                    {
                        Item.Text = _( catalog, Item.Text );
                        if ( Item.DropDownItems.Count > 0 )
                        {
                            Translate( catalog, Item, tooltip );
                        }
                    }
                }
                else if (
                    ( objtype.IndexOf( "Forms.MenuStrip", StringComparison.InvariantCultureIgnoreCase ) >= 0 ) ||
                    ( objtype.IndexOf( "Forms.ToolStripDropDownMenu", StringComparison.InvariantCultureIgnoreCase ) >= 0 ) ||
                    ( objtype.IndexOf( "Forms.ContextMenuStrip", StringComparison.InvariantCultureIgnoreCase ) >= 0 )
                        )
                {
                    MenuStrip menuitems = myObject as MenuStrip;
                    foreach ( ToolStripMenuItem Item in menuitems.Items )
                    {
                        Item.Text = _( catalog, Item.Text );
                        if ( Item.DropDownItems.Count > 0 )
                        {
                            Translate( catalog, Item, tooltip );
                        }
                    }
                }
                else if (
                    ( objtype.IndexOf( "Forms.StatusStrip", StringComparison.InvariantCultureIgnoreCase ) >= 0 ) ||
                    ( objtype.IndexOf( "Forms.ToolStrip", StringComparison.InvariantCultureIgnoreCase ) >= 0 )
                        )
                {
                    ToolStrip tools = myObject as ToolStrip;
                    foreach ( ToolStripItem Item in tools.Items )
                    {
                        Item.Text = _( catalog, Item.Text );
                        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
        }