コード例 #1
0
ファイル: CornerAnchor.cs プロジェクト: simo-andreev/Emotion
        private void TopLeftAnchor(AnchorPen pen, AnchorLayoutControl control)
        {
            // Check if reached limit.
            if (pen.Left + control.Control.Width >= pen.WidthLimit)
            {
                pen.Left = Padding.X;
                pen.Top  = pen.NeededTop;
            }

            // Apply left margin.
            pen.Left += control.Margin.X;
            // Apply top margin.
            float topPenCopy = pen.Top + control.Margin.Y;

            // Position at top left.
            control.Control.X = pen.Left;
            control.Control.Y = topPenCopy;

            // Apply right margin for the next control.
            pen.Left += control.Control.Width + control.Margin.Width;

            // Set the max position of the top pen.
            float neededPenTop = control.Control.Height + topPenCopy + control.Margin.Height;

            if (neededPenTop > pen.NeededTop)
            {
                pen.NeededTop = neededPenTop;
            }
        }
コード例 #2
0
ファイル: CornerAnchor.cs プロジェクト: simo-andreev/Emotion
        private void BottomRightAnchor(AnchorPen pen, AnchorLayoutControl control)
        {
            // Check if reached limit.
            if (pen.Left - control.Control.Width - control.Margin.Width < pen.WidthLimit)
            {
                pen.Left = pen.Holder;
                pen.Top  = pen.NeededTop;
            }

            // Apply right margin and size.
            pen.Left -= control.Margin.Width + control.Control.Width;

            // Apply bottom margin and height.
            float topPenCopy = pen.Top - control.Margin.Height - control.Control.Height;

            // Position at top left.
            control.Control.X = pen.Left;
            control.Control.Y = topPenCopy;

            // Apply left margin for the next control.
            pen.Left -= control.Margin.X;

            // Set the max position of the top pen.
            float neededPenTop = topPenCopy - control.Margin.Y;

            if (neededPenTop < pen.NeededTop)
            {
                pen.NeededTop = neededPenTop;
            }
        }
コード例 #3
0
ファイル: CornerAnchor.cs プロジェクト: simo-andreev/Emotion
        private void ApplyLogic()
        {
            float limitPercentage = ColumnLimit / 100;
            float widthLimit      = Width * limitPercentage;

            AnchorPen topLeftPen = new AnchorPen
            {
                Top        = Padding.X,
                Left       = Padding.Y,
                WidthLimit = widthLimit,
                NeededTop  = 0
            };

            AnchorPen bottomLeftPen = new AnchorPen
            {
                Top        = Height - Padding.Height,
                Left       = Padding.Y,
                WidthLimit = widthLimit,
                NeededTop  = Height
            };

            AnchorPen topRightPen = new AnchorPen
            {
                Top        = Padding.X,
                Left       = Width - Padding.Width,
                WidthLimit = widthLimit,
                NeededTop  = 0,
                Holder     = Width - Padding.Width
            };

            AnchorPen bottomRightPen = new AnchorPen
            {
                Top        = Height - Padding.Height,
                Left       = Width - Padding.Width,
                WidthLimit = widthLimit,
                NeededTop  = Height,
                Holder     = Width - Padding.Width
            };

            lock (_controls)
            {
                foreach (AnchorLayoutControl control in _controls)
                {
                    switch (control.Anchor)
                    {
                    case AnchorLocation.TopLeft:
                        TopLeftAnchor(topLeftPen, control);
                        break;

                    case AnchorLocation.BottomLeft:
                        BottomLeftAnchor(bottomLeftPen, control);
                        break;

                    case AnchorLocation.TopRight:
                        TopRightAnchor(topRightPen, control);
                        break;

                    case AnchorLocation.BottomRight:
                        BottomRightAnchor(bottomRightPen, control);
                        break;
                    }
                }
            }
        }