System.Windows.Forms.ToolTip.ToolTipWindow.Present C# (CSharp) Method

Present() public method

public Present ( Control control, string text ) : void
control Control
text string
return void
			public void Present (Control control, string text)
			{
				if (IsDisposed)
					return;

				Size display_size;

				//XplatUI.GetDisplaySize (out display_size);
        display_size = new System.Drawing.Size(200,40);

				associated_control = control;

				Text = text;

				PopupEventArgs pea = new PopupEventArgs (control, control, false, Size.Empty);
				OnPopup (pea);
				
				if (pea.Cancel)
					return;
					
				Size size = pea.ToolTipSize;

				Width = size.Width;
				Height = size.Height;

				int cursor_w, cursor_h, hot_x, hot_y;
				//XplatUI.GetCursorInfo (control.Cursor.Handle, out cursor_w, out cursor_h, out hot_x, out hot_y);
				Point loc = Control.MousePosition;
				//loc.Y += (cursor_h - hot_y);

				if ((loc.X + Width) > display_size.Width)
					loc.X = display_size.Width - Width;

				//if ((loc.Y + Height) > display_size.Height)
				//	loc.Y = Control.MousePosition.Y - Height - hot_y;
				
				Location = loc;
				Visible = true;
			}

Usage Example

Example #1
0
        // Called from timer (with only_refresh = false)
        // Called from ToolTipStart if tooltip is already shown (with only_refresh = true)
        public void ToolTipShow(bool only_refresh)
        {
            if (!form.Visible)
            {
                return;
            }

            string text = Locale.GetText(tooltip_hovered_button.Caption.ToString());

            tooltip_timer.Interval = tooltip_hide_interval;
            tooltip_timer.Enabled  = true;

            if (only_refresh && (tooltip == null || !tooltip.Visible))
            {
                return;
            }

            if (tooltip == null)
            {
                tooltip = new ToolTip.ToolTipWindow();
            }
            else if (tooltip.Text == text && tooltip.Visible)
            {
                return;
            }
            else if (tooltip.Visible)
            {
                tooltip.Visible = false;
            }

            if (form.WindowState == FormWindowState.Maximized && form.MdiParent != null)
            {
                tooltip.Present(form.MdiParent, text);
            }
            else
            {
                tooltip.Present(form, text);
            }
        }