本文整理汇总了C#中System.Windows.Forms.Form.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# Form.ThrowIfNull方法的具体用法?C# Form.ThrowIfNull怎么用?C# Form.ThrowIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Form
的用法示例。
在下文中一共展示了Form.ThrowIfNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowTip
/// <summary>
/// Show a "tip of the day"-like message on the top right corner of the given window.
/// </summary>
/// <param name="form">The owner window.</param>
/// <param name="key">The key used to store informations about messages the user already saw. Every messages is only displayed once.</param>
/// <param name="title">The title of the tip window.</param>
/// <param name="tiptext">The text of the tip window.</param>
/// <param name="checkBoxVisible">if set to <c>true</c> the checkbox is visible.</param>
/// <exception cref="System.ArgumentNullException">form</exception>
public static void ShowTip(Form form, string key, string title, string tiptext, bool checkBoxVisible = true)
{
form.ThrowIfNull(nameof(form));
if (Settings.UI.ConfirmedTips.Contains(key))
return;
// Quit if it's already shown
if (form.Controls.OfType<TipWindow>().Any())
return;
// Gets disposed when clicking the OK button
TipWindow tipWindow = new TipWindow(form, title, tiptext, key, checkBoxVisible);
tipWindow.Show();
}
示例2: SetToolTipLocation
/// <summary>
/// Sets the tool tip location.
/// </summary>
/// <param name="tooltipForm">The tooltip form.</param>
/// <exception cref="System.ArgumentNullException">tooltipForm</exception>
public static void SetToolTipLocation(Form tooltipForm)
{
tooltipForm.ThrowIfNull(nameof(tooltipForm));
Point mp = Control.MousePosition;
NativeMethods.AppBarData appBarData = NativeMethods.AppBarData.Create();
NativeMethods.SHAppBarMessage(NativeMethods.ABM_GETTASKBARPOS, ref appBarData);
NativeMethods.RECT taskBarLocation = appBarData.Rect;
Screen curScreen = Screen.FromPoint(mp);
Point winPoint;
bool slideLeftRight;
switch (appBarData.UEdge)
{
default:
winPoint = mp;
slideLeftRight = true;
break;
case NativeMethods.ABE_BOTTOM:
winPoint = new Point(mp.X, taskBarLocation.Top - tooltipForm.Height);
slideLeftRight = true;
break;
case NativeMethods.ABE_TOP:
winPoint = new Point(mp.X, taskBarLocation.Bottom);
slideLeftRight = true;
break;
case NativeMethods.ABE_LEFT:
winPoint = new Point(taskBarLocation.Right, mp.Y);
slideLeftRight = false;
break;
case NativeMethods.ABE_RIGHT:
winPoint = new Point(taskBarLocation.Left - tooltipForm.Width, mp.Y);
slideLeftRight = false;
break;
}
if (slideLeftRight)
{
if (winPoint.X + tooltipForm.Width > curScreen.Bounds.Right)
winPoint = new Point(curScreen.Bounds.Right - tooltipForm.Width - 1, winPoint.Y);
if (winPoint.X < curScreen.Bounds.Left)
winPoint = new Point(curScreen.Bounds.Left + 2, winPoint.Y);
}
else
{
if (winPoint.Y + tooltipForm.Height > curScreen.Bounds.Bottom)
winPoint = new Point(winPoint.X, curScreen.Bounds.Bottom - tooltipForm.Height - 1);
if (winPoint.Y < curScreen.Bounds.Top)
winPoint = new Point(winPoint.X, curScreen.Bounds.Top + 2);
}
tooltipForm.Location = winPoint;
}