当前位置: 首页>>代码示例>>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;未经允许,请勿转载。