コード例 #1
0
ファイル: CommonHelper.cs プロジェクト: Cocotteseb/Krypton
        /// <summary>
        /// Return the provided rectangle with 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(Orientation orientation,
                                             Rectangle rect, 
                                             Padding padding)
        {
            // Ignore an empty padding value
            if (!padding.Equals(CommonHelper.InheritPadding))
            {
                // The orientation determines how the border padding is
                // applied to the preferred size of the children
                switch (orientation)
                {
                    case Orientation.Horizontal:
                        rect.X += padding.Left;
                        rect.Width -= padding.Horizontal;
                        rect.Y += padding.Top;
                        rect.Height -= padding.Vertical;
                        break;
                    case Orientation.Vertical:
                        rect.X += padding.Top;
                        rect.Width -= padding.Vertical;
                        rect.Y += padding.Right;
                        rect.Height -= padding.Horizontal;
                        break;
                    default:
                        // Should never happen!
                        Debug.Assert(false);
                        break;
                }
            }

            return rect;
        }
コード例 #2
0
ファイル: CommonHelper.cs プロジェクト: Cocotteseb/Krypton
        /// <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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
ファイル: CommonHelper.cs プロジェクト: Cocotteseb/Krypton
        /// <summary>
        /// Return the provided size with visual orientation specific padding applied.
        /// </summary>
        /// <param name="orientation">Orientation to apply padding with.</param>
        /// <param name="size">Starting size.</param>
        /// <param name="padding">Padding to be applied.</param>
        /// <returns>Updated size.</returns>
        public static Size ApplyPadding(VisualOrientation orientation,
                                        Size size, 
                                        Padding padding)
        {
            // Ignore an empty padding value
            if (!padding.Equals(CommonHelper.InheritPadding))
            {
                // The orientation determines how the border padding is
                // applied to the preferred size of the children
                switch (orientation)
                {
                    case VisualOrientation.Top:
                    case VisualOrientation.Bottom:
                        size.Width += padding.Horizontal;
                        size.Height += padding.Vertical;
                        break;
                    case VisualOrientation.Left:
                    case VisualOrientation.Right:
                        size.Width += padding.Vertical;
                        size.Height += padding.Horizontal;
                        break;
                    default:
                        // Should never happen!
                        Debug.Assert(false);
                        break;
                }
            }

            return size;
        }
コード例 #5
0
        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;
        }
コード例 #6
0
        public static Rectangle ApplyPadding(Orientation orientation, Rectangle rect, Padding padding)
        {
            if (!padding.Equals(InheritPadding))
            {
                switch (orientation)
                {
                    case Orientation.Horizontal:
                        rect.X += padding.Left;
                        rect.Width -= padding.Horizontal;
                        rect.Y += padding.Top;
                        rect.Height -= padding.Vertical;
                        return rect;

                    case Orientation.Vertical:
                        rect.X += padding.Top;
                        rect.Width -= padding.Vertical;
                        rect.Y += padding.Right;
                        rect.Height -= padding.Horizontal;
                        return rect;
                }
            }
            return rect;
        }
コード例 #7
0
        public static Size ApplyPadding(VisualOrientation orientation, Size size, Padding padding)
        {
            if (!padding.Equals(InheritPadding))
            {
                switch (orientation)
                {
                    case VisualOrientation.Top:
                    case VisualOrientation.Bottom:
                        size.Width += padding.Horizontal;
                        size.Height += padding.Vertical;
                        return size;

                    case VisualOrientation.Left:
                    case VisualOrientation.Right:
                        size.Width += padding.Vertical;
                        size.Height += padding.Horizontal;
                        return size;
                }
            }
            return size;
        }
コード例 #8
0
        public static Rectangle ApplyPadding(VisualOrientation orientation, Rectangle rect, Padding padding)
        {
            if (!padding.Equals(InheritPadding))
            {
                switch (orientation)
                {
                    case VisualOrientation.Top:
                        rect = new Rectangle(rect.X + padding.Left, rect.Y + padding.Top, rect.Width - padding.Horizontal, rect.Height - padding.Vertical);
                        return rect;

                    case VisualOrientation.Bottom:
                        rect = new Rectangle(rect.X + padding.Right, rect.Y + padding.Bottom, rect.Width - padding.Horizontal, rect.Height - padding.Vertical);
                        return rect;

                    case VisualOrientation.Left:
                        rect = new Rectangle(rect.X + padding.Top, rect.Y + padding.Right, rect.Width - padding.Vertical, rect.Height - padding.Horizontal);
                        return rect;

                    case VisualOrientation.Right:
                        rect = new Rectangle(rect.X + padding.Bottom, rect.Y + padding.Left, rect.Width - padding.Vertical, rect.Height - padding.Horizontal);
                        return rect;
                }
            }
            return rect;
        }
コード例 #9
0
 private bool ShouldSerializePadding()
 {
     System.Windows.Forms.Padding padding = (System.Windows.Forms.Padding)base.ShadowProperties["Padding"];
     return(!padding.Equals(_defaultPadding));
 }