當前位置: 首頁>>代碼示例>>C#>>正文


C# Form.ThrowIfNull方法代碼示例

本文整理匯總了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();
        }
開發者ID:,項目名稱:,代碼行數:24,代碼來源:

示例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;
        }
開發者ID:,項目名稱:,代碼行數:60,代碼來源:


注:本文中的System.Windows.Forms.Form.ThrowIfNull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。