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


C# Padding.Equals方法代碼示例

本文整理匯總了C#中System.Windows.Forms.Padding.Equals方法的典型用法代碼示例。如果您正苦於以下問題:C# Padding.Equals方法的具體用法?C# Padding.Equals怎麽用?C# Padding.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.Padding的用法示例。


在下文中一共展示了Padding.Equals方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ApplyPadding

        /// <summary>
        /// Return the provided rectangle with visual orientation specific padding applied.
        /// </summary>
        /// <param name="orientation">Orientation to apply padding with.</param>
        /// <param name="rect">Starting rectangle.</param>
        /// <param name="padding">Padding to be applied.</param>
        /// <returns>Updated rectangle.</returns>
        public static Rectangle ApplyPadding(VisualOrientation orientation,
                                             Rectangle rect, 
                                             Padding padding)
        {
            // Ignore an empty padding value
            if (!padding.Equals(CommonHelper.InheritPadding))
            {
                // The orientation determines how the border padding is
                // used to reduce the space available for children
                switch (orientation)
                {
                    case VisualOrientation.Top:
                        rect = new Rectangle(rect.X + padding.Left, rect.Y + padding.Top,
                                             rect.Width - padding.Horizontal, rect.Height - padding.Vertical);
                        break;
                    case VisualOrientation.Bottom:
                        rect = new Rectangle(rect.X + padding.Right, rect.Y + padding.Bottom,
                                             rect.Width - padding.Horizontal, rect.Height - padding.Vertical);
                        break;
                    case VisualOrientation.Left:
                        rect = new Rectangle(rect.X + padding.Top, rect.Y + padding.Right,
                                             rect.Width - padding.Vertical, rect.Height - padding.Horizontal);
                        break;
                    case VisualOrientation.Right:
                        rect = new Rectangle(rect.X + padding.Bottom, rect.Y + padding.Left,
                                             rect.Width - padding.Vertical, rect.Height - padding.Horizontal);
                        break;
                    default:
                        // Should never happen!
                        Debug.Assert(false);
                        break;
                }
            }

            return rect;
        }
開發者ID:Cocotteseb,項目名稱:Krypton,代碼行數:43,代碼來源:CommonHelper.cs

示例2: ApplyPadding

        private Rectangle ApplyPadding(Rectangle rect, Padding padding)
        {
            // Ignore an empty padding value
            if (!padding.Equals(CommonHelper.InheritPadding))
            {
                // Get the orientation to use for applying the padding
                VisualOrientation orientation = Orientation;

                // Do we need to apply right to left?
                if (_rightToLeftLayout && (_rightToLeft == RightToLeft.Yes))
                {
                    // Reverse the left and right only
                    switch (orientation)
                    {
                        case VisualOrientation.Left:
                            orientation = VisualOrientation.Right;
                            break;
                        case VisualOrientation.Right:
                            orientation = VisualOrientation.Left;
                            break;
                    }
                }

                // The orientation determines how the border padding is
                // used to reduce the space available for children
                switch (orientation)
                {
                    case VisualOrientation.Top:
                        rect = new Rectangle(rect.X + padding.Left, rect.Y + padding.Top,
                                             rect.Width - padding.Horizontal, rect.Height - padding.Vertical);
                        break;
                    case VisualOrientation.Bottom:
                        rect = new Rectangle(rect.X + padding.Left, rect.Y + padding.Bottom,
                                             rect.Width - padding.Horizontal, rect.Height - padding.Vertical);
                        break;
                    case VisualOrientation.Left:
                        rect = new Rectangle(rect.X + padding.Top, rect.Y + padding.Left,
                                             rect.Width - padding.Vertical, rect.Height - padding.Horizontal);
                        break;
                    case VisualOrientation.Right:
                        rect = new Rectangle(rect.X + padding.Bottom, rect.Y + padding.Left,
                                             rect.Width - padding.Vertical, rect.Height - padding.Horizontal);
                        break;
                    default:
                        // Should never happen!
                        Debug.Assert(false);
                        break;
                }
            }

            return rect;
        }
開發者ID:Cocotteseb,項目名稱:Krypton,代碼行數:52,代碼來源:ViewLayoutViewport.cs

示例3: ApplyPadding

        public static Size ApplyPadding(Orientation orientation, Size size, Padding padding)
        {
            if (!padding.Equals(InheritPadding))
            {
                switch (orientation)
                {
                    case Orientation.Horizontal:
                        size.Width += padding.Horizontal;
                        size.Height += padding.Vertical;
                        return size;

                    case Orientation.Vertical:
                        size.Width += padding.Vertical;
                        size.Height += padding.Horizontal;
                        return size;
                }
            }
            return size;
        }
開發者ID:routd1,項目名稱:ProjectHurricane,代碼行數:19,代碼來源:CommonHelper.cs


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