コード例 #1
0
        public TreeViewNodeControl(
			ContainerControl hMembersControl,
			ContainerControl vMembersControl)
            : base()
        {
            HMembers = hMembersControl;
            VMembers = vMembersControl;

            this.CollapseButton = new PictureChangeBox(
                PictureLibrary.Instance.Minus,
                PictureLibrary.Instance.Plus);
            this.CollapseButton.Visible = false;
            this.CollapseButton.Box.Margins.SetAll(3);
            this.CollapseButton.Box.MouseSensitivityArea.SetAll(8);
            this.Add(CollapseButton);

            this.Add(HMembers);
            this.Add(VMembers);

            TreeLineStyle = DefaultLineStyle;

            this.Focusable = true;
            this.Collapsable = true;

            this.CollapseChanged += TreeViewNodeControl_CollapseChanged;
        }
コード例 #2
0
ファイル: Layouter.cs プロジェクト: Ju2ender/csharp-e
        public static int MaxChildWidth(ContainerControl parent)
        {
            int max = 0;

            foreach (Control child in parent.Children)
            {
                if (child.Visible && child.Bounds.Size.X > max)
                {
                    max = child.Bounds.Size.X;
                }
            }

            return max;
        }
コード例 #3
0
ファイル: RootControl.cs プロジェクト: Ju2ender/csharp-e
 public IEnumerable<Control> AllControls(ContainerControl parent)
 {
     foreach (Control c in parent.Children)
     {
         yield return c;
         ContainerControl embedded = c as ContainerControl;
         if (embedded != null)
         {
             foreach (Control c2 in AllControls(embedded))
             {
                 yield return c2;
             }
         }
     }
 }
コード例 #4
0
ファイル: LinearLayout.cs プロジェクト: Ju2ender/csharp-e
        protected virtual void VerticalLayoutDock(ContainerControl control)
        {
            if (WrapMaxSize <= 0)
            {
                Point minSize = control.BiggestMinimumChildSize();
                int proposedSize = control.Bounds.Size.X - control.Box.Padding.LeftAndRight - control.Box.Borders.LeftAndRight;
                if (proposedSize < minSize.X) proposedSize = minSize.X;

                foreach (Control child in control.Children)
                {
                    child.SetBoundsToMinimumSize();
                    if (child.ShouldStretchHorizontally)
                    {
                        //child.Bounds.Location.X = control.Bounds.Location.X + XMargin;
                        child.Bounds.Size.X = proposedSize - child.Box.Margins.LeftAndRight;
                    }
                    child.LayoutDock();
                }
            }
        }
コード例 #5
0
ファイル: LinearLayout.cs プロジェクト: Ju2ender/csharp-e
        /// <summary>
        /// Internal helper to align vertically
        /// </summary>
        /// <param name="control">control whose child controls are to be aligned</param>
        protected virtual void VerticalLayout(ContainerControl control)
        {
            bool someChildAlreadyProcessed = false;

            int ox = control.Bounds.Location.X;
            int oy = control.Bounds.Location.Y;

            int x = ox + control.Box.Borders.Left + control.Box.Padding.Left;
            int y = oy + control.Box.Borders.Top + control.Box.Padding.Top;

            Point maxSize = control.BiggestMinimumChildSize();
            Point childSize = new Point();

            foreach (Control child in control.Children)
            {
                if (child.Visible)
                {
                    if (!someChildAlreadyProcessed)
                    {
                        someChildAlreadyProcessed = true;
                    }
                    else
                    {
                        y += YSpacing;
                    }

                    int moveToX = x;

                    child.CalcSizeWithMargins(child.MinimumRequiredSize, childSize);

                    switch (this.Alignment)
                    {
                        case AlignmentType.Center:
                            moveToX = x + (maxSize.X - childSize.X) / 2;
                            break;
                        case AlignmentType.RightOrBottomEdge:
                            moveToX = x + (maxSize.X - childSize.X);
                            break;
                        case AlignmentType.Justify:
                        //child.Bounds.Size.X = maxSize;
                        //moveToX = x;
                        //break;
                        case AlignmentType.LeftOrTopEdge:
                        default:
                            break;
                    }

                    child.MoveTo(moveToX + child.Box.Margins.Left, y + child.Box.Margins.Top);

                    y += childSize.Y;
                }
            }

            x += maxSize.X + control.Box.Borders.Right + control.Box.Padding.Right;
            y += control.Box.Borders.Bottom + control.Box.Padding.Bottom;

            control.Bounds.Size.Set(x - ox, y - oy);
        }
コード例 #6
0
ファイル: LinearLayout.cs プロジェクト: Ju2ender/csharp-e
        protected virtual void HorizontalLayoutDock(ContainerControl control)
        {
            if (WrapMaxSize <= 0)
            {
                Point minSize = control.BiggestMinimumChildSize();
                int proposedSize = control.Bounds.Size.Y - control.Box.Padding.TopAndBottom - control.Box.Borders.TopAndBottom;
                if (proposedSize < minSize.Y) proposedSize = minSize.Y;

                foreach (Control child in control.Children)
                {
                    child.SetBoundsToMinimumSize();
                    if (child.ShouldStretchHorizontally && child == control.Children.Tail)
                    {
                        //child.Bounds.Location.X = control.Bounds.Location.X + XMargin;
                        child.Bounds.Size.X = control.Bounds.Right - child.Bounds.Location.X;
                    }
                    if (child.ShouldStretchVertically)
                    {
                        child.Bounds.Size.Y = proposedSize;
                    }
                    if (child.Stretch != StretchMode.None)
                    {
                        child.LayoutDock();
                    }
                }
            }
        }
コード例 #7
0
ファイル: LinearLayout.cs プロジェクト: Ju2ender/csharp-e
        /// <summary>
        /// Internal helper to align horizontally
        /// </summary>
        /// <param name="control">control whose children are to be aligned</param>
        protected virtual void HorizontalLayoutComplex(ContainerControl control)
        {
            int ox = control.Bounds.Location.X;
            int oy = control.Bounds.Location.Y;

            int XMargin = control.Box.Padding.Left;
            int YMargin = control.Box.Padding.Top;

            List<Point> LayerSizes = new List<Point>();
            LayerSizes.Add(new Point());

            bool someChildAlreadyProcessed = false;
            bool startingLayer = true;

            int x = ox + XMargin;
            int y = oy + YMargin;
            int maxX = 0;

            int j = 0;

            foreach (Control child in control.Children)
            {
                if (child.Visible)
                {
                    if (!someChildAlreadyProcessed)
                    {
                        someChildAlreadyProcessed = true;
                    }
                    else
                    {
                        x += XSpacing;
                        LayerSizes[j].X += XSpacing;
                    }

                    if (WrapMaxSize > 0 && x + child.MinimumRequiredSize.X + XMargin > ox + WrapMaxSize)
                    {
                        if (!startingLayer)
                        {
                            x = ox + control.Box.Padding.Left;
                            LayerSizes.Add(new Point());
                            j++;
                            startingLayer = true;
                        }
                    }

                    if (child.Bounds.Size.Y > LayerSizes[j].Y)
                    {
                        LayerSizes[j].Y = child.MinimumRequiredSize.Y;
                    }

                    LayerSizes[j].X += child.MinimumRequiredSize.X;

                    x += child.MinimumRequiredSize.X;
                    if (x > maxX)
                    {
                        maxX = x;
                    }
                    startingLayer = false;
                }
            }

            someChildAlreadyProcessed = false;
            startingLayer = true;

            switch (LayerAlignment)
            {
                case AlignmentType.LeftOrTopEdge:
                    x = ox + XMargin;
                    break;
                case AlignmentType.Center:
                    x = ox + XMargin + (maxX - ox - XMargin - LayerSizes[0].X) / 2;
                    break;
                case AlignmentType.RightOrBottomEdge:
                    x = maxX - LayerSizes[0].X;
                    break;
                case AlignmentType.Justify:
                default:
                    x = ox + control.Box.Padding.Left;
                    break;
            }

            y = oy + control.Box.Padding.Top;

            j = 0;

            foreach (Control child in control.Children)
            {
                if (child.Visible)
                {
                    if (!someChildAlreadyProcessed)
                    {
                        someChildAlreadyProcessed = true;
                    }
                    else
                    {
                        x += XSpacing;
                    }

                    if (WrapMaxSize > 0
                        && x + child.MinimumRequiredSize.X + XMargin > ox + WrapMaxSize)
                    {
                        if (!startingLayer)
                        {
                            switch (LayerAlignment)
                            {
                                case AlignmentType.LeftOrTopEdge:
                                    x = ox + XMargin;
                                    break;
                                case AlignmentType.Center:
                                    x = ox + XMargin + (maxX - ox - XMargin - LayerSizes[j].X) / 2;
                                    break;
                                case AlignmentType.RightOrBottomEdge:
                                    x = maxX - LayerSizes[j].X;
                                    break;
                                case AlignmentType.Justify:
                                default:
                                    x = ox + XMargin;
                                    break;
                            }

                            y += LayerSizes[j].Y + YSpacing;
                            j++;
                            startingLayer = true;
                        }
                    }

                    int moveToY = y;

                    switch (this.Alignment)
                    {
                        case AlignmentType.Center:
                            moveToY = y + (LayerSizes[j].Y - child.MinimumRequiredSize.Y) / 2;
                            break;
                        case AlignmentType.RightOrBottomEdge:
                            moveToY = y + LayerSizes[j].Y - child.MinimumRequiredSize.Y;
                            break;
                        case AlignmentType.Justify:
                            child.Bounds.Size.Y = LayerSizes[j].Y;
                            break;
                        case AlignmentType.LeftOrTopEdge:
                        default:
                            break;
                    }

                    child.MoveTo(x, moveToY);

                    x += child.MinimumRequiredSize.X;
                    startingLayer = false;
                }
            }

            x = maxX + XMargin;
            y += LayerSizes[j].Y + YMargin;

            control.Bounds.Size.Set(x - ox, y - oy);
        }
コード例 #8
0
ファイル: LinearLayout.cs プロジェクト: Ju2ender/csharp-e
 public void LayoutDock(ContainerControl control)
 {
     if (Orientation == OrientationType.Vertical)
     {
         VerticalLayoutDock(control);
     }
     else
     {
         HorizontalLayoutDock(control);
     }
 }