예제 #1
0
        protected SpacePart InitSpace(SpaceName name)
        {
            //only call from ctor?
            SpacePart dockspace = new SpacePart(this, 10, 10, name);

            return(dockspace);
        }
예제 #2
0
        static int FindMaxWidthBar(SpacePart b1,
                                   SpacePart b2, SpacePart b3)
        {
            int maxWidth = 0;
            int w        = 0;

            if (b1 != null)
            {
                w = FindMaxWidthBar(b1);
                if (w > maxWidth)
                {
                    maxWidth = w;
                }
            }
            if (b2 != null)
            {
                w = FindMaxWidthBar(b2);
                if (w > maxWidth)
                {
                    maxWidth = w;
                }
            }
            if (b3 != null)
            {
                w = FindMaxWidthBar(b3);
                if (w > maxWidth)
                {
                    maxWidth = w;
                }
            }
            return(maxWidth);
        }
예제 #3
0
        static int FindMaxHeightBar(SpacePart b1,
                                    SpacePart b2, SpacePart b3)
        {
            //find bar with max height
            int maxHeight = 0;
            int h         = 0;

            if (b1 != null)
            {
                h = FindMaxHeightBar(b1);
                if (h > maxHeight)
                {
                    maxHeight = h;
                }
            }
            if (b2 != null)
            {
                h = FindMaxHeightBar(b2);
                if (h > maxHeight)
                {
                    maxHeight = h;
                }
            }
            if (b3 != null)
            {
                h = FindMaxHeightBar(b3);
                if (h > maxHeight)
                {
                    maxHeight = h;
                }
            }

            return(maxHeight);
        }
예제 #4
0
        //public override string ToString()
        //{
        //    //if (dockSpaceConcept == SpaceConcept.NineSpaceFree)
        //    //{
        //    //    return "FREE_NINE_LAY (L" + dbug_layer_id + this.dbugLayerState + "):" + this.PostCalculateContentSize.ToString() + " of " + ownerVisualElement.ToString();
        //    //}
        //    //else
        //    //{
        //    //    return "dock layer (L" + dbug_layer_id + this.dbugLayerState + "):" + this.PostCalculateContentSize.ToString() + " of " + ownerVisualElement.ToString();
        //    //}
        //}
#endif

        protected static void SetDockBound(SpacePart dock, int x, int y, int newWidth, int newHeight)
        {
            if (dock == null)
            {
                return;
            }
            dock.SetBound(x, y, newWidth, newHeight);
        }
예제 #5
0
 public IEnumerable <UIElement> GetVisualElementIter()
 {
     for (int i = spaces.Length - 1; i >= 0; --i)
     {
         SpacePart sp = spaces[i];
         if (sp != null)
         {
             yield return(sp.Content);
         }
     }
 }
예제 #6
0
        static int CalculateTotalFreeSpacesDesiredHeight(SpacePart bx1, SpacePart bx2, SpacePart bx3)
        {
            int totalHeight = 0;

            if (bx1 != null)
            {
                switch (bx1.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Middle:
                {
                    totalHeight += (bx1.DesiredHeight / 2);
                }
                break;

                case NamedSpaceContainerOverlapMode.Outer:
                {
                    totalHeight += bx1.DesiredHeight;
                }
                break;
                }
            }
            if (bx2 != null)
            {
                //center not care overlapping
                totalHeight += bx2.DesiredHeight;
            }
            if (bx3 != null)
            {
                switch (bx3.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Middle:
                {
                    totalHeight += (bx3.DesiredHeight / 2);
                }
                break;

                case NamedSpaceContainerOverlapMode.Outer:
                {
                    totalHeight += bx3.DesiredHeight;
                }
                break;
                }
            }
            return(totalHeight);
        }
예제 #7
0
        static int CalculateTotalDockSpaceDesiredHeight(SpacePart bx1, SpacePart bx2, SpacePart bx3)
        {
            int total = 0;

            if (bx1 != null)
            {
                total += bx1.DesiredHeight;
            }
            if (bx2 != null)
            {
                total += bx2.DesiredHeight;
            }
            if (bx3 != null)
            {
                total += bx3.DesiredHeight;
            }
            return(total);
        }
예제 #8
0
        static int FindMaxWidthBar(SpacePart bx)
        {
            switch (bx.OverlapMode)
            {
            case NamedSpaceContainerOverlapMode.Middle:
            {
                return(bx.Width / 2);
            }

            case NamedSpaceContainerOverlapMode.Outer:
            {
                return(bx.Width);
            }

            default:
            {
                return(0);
            }
            }
        }
예제 #9
0
        public override void ArrangeAllSpaces()
        {
#if DEBUG
            //vinv.dbug_SetInitObject(this);
            //vinv.dbug_StartLayoutTrace(dbugVisualElementLayoutMsg.DockSpaceLayer_ArrAllDockSpaces);
#endif
            for (int i = spaces.Length - 1; i >= 0; --i)
            {
                spaces[i].CalculateContentSize();
            }
#if DEBUG
            //vinv.dbug_EnterLayerReArrangeContent(this);
#endif


            //-------------------------------------------------
            // this.BeginLayerGraphicUpdate(vinv);
            //-------------------------------------------------
            int w = this.sizeW;
            int h = this.sizeH;
            if (dockSpaceConcept == SpaceConcept.FourSpace)
            {
                //-------------------------------------------------
                if (!this.HasSpecificBottomSpaceHeight)
                {
                }
                if (!this.HasSpecificTopSpaceHeight)
                {
                }
                if (!this.HasSpecificRightSpaceWidth)
                {
                }
                if (!this.HasSpecificLeftSpaceWidth)
                {
                }
                //-------------------------------------------------
                SetDockBound(spaces[FOURSPACE_LT],
                             0,
                             0,
                             leftSpaceWidth,
                             topSpaceHeight);
                //-------------------------------------------------------
                SetDockBound(spaces[FOURSPACE_LB],
                             0,
                             topSpaceHeight,
                             leftSpaceWidth,
                             OwnerVisualElement.Height - (topSpaceHeight));
                //------------------------------------------------------
                SetDockBound(spaces[FOURSPACE_RT],
                             leftSpaceWidth,
                             0,
                             w - leftSpaceWidth,
                             topSpaceHeight);
                //------------------------------------------------------
                SetDockBound(spaces[FOURSPACE_RB],
                             leftSpaceWidth,
                             topSpaceHeight,
                             w - (leftSpaceWidth),
                             h - (topSpaceHeight));
                //------------------------------------------------------
            }
            else
            {
                //start with ninespace , the extend to proper form

                //-------------------------------------------------
                var b_space = spaces[B];
                var t_space = spaces[T];
                var l_space = spaces[L];
                var r_space = spaces[R];
                if (!this.HasSpecificBottomSpaceHeight && b_space != null)
                {
                    b_space.CalculateContentSize();
                    //if (b_space.NeedReCalculateContentSize)
                    //{
                    //    b_space.TopDownReCalculateContentSize(vinv);
                    //}
                    this.bottomSpaceHeight = b_space.DesiredHeight;
                }

                if (!this.HasSpecificTopSpaceHeight && t_space != null)
                {
                    t_space.CalculateContentSize();
                    //if (t_space.NeedReCalculateContentSize)
                    //{
                    //    t_space.TopDownReCalculateContentSize(vinv);
                    //}
                    this.topSpaceHeight = t_space.DesiredHeight;
                }
                if (!this.HasSpecificRightSpaceWidth && r_space != null)
                {
                    r_space.CalculateContentSize();
                    //if (r_space.NeedReCalculateContentSize)
                    //{
                    //    r_space.TopDownReCalculateContentSize(vinv);
                    //}
                    this.rightSpaceWidth = r_space.DesiredWidth;
                }
                if (!this.HasSpecificLeftSpaceWidth && l_space != null)
                {
                    l_space.CalculateContentSize();
                    //if (l_space.NeedReCalculateContentSize)
                    //{
                    //    l_space.TopDownReCalculateContentSize(vinv);
                    //}
                    this.leftSpaceWidth = l_space.DesiredWidth;
                }
                //-------------------------------------------------

                if (l_space != null)
                {
                    int left_y = topSpaceHeight;
                    int left_h = h - topSpaceHeight - bottomSpaceHeight;
                    if ((leftBoxVerticalExpansionFlags & VerticalBoxExpansion.Top) == VerticalBoxExpansion.Top)
                    {
                        left_y  = 0;
                        left_h += topSpaceHeight;
                    }
                    if ((leftBoxVerticalExpansionFlags & VerticalBoxExpansion.Bottom) == VerticalBoxExpansion.Bottom)
                    {
                        left_h += bottomSpaceHeight;
                    }
                    SetDockBound(spaces[L],
                                 0,//x
                                 left_y,
                                 leftSpaceWidth,
                                 left_h);
                }
                //-------------------------------------------------
                if (r_space != null)
                {
                    int right_y = topSpaceHeight;
                    int right_h = h - topSpaceHeight - bottomSpaceHeight;
                    if (HasSpecificCenterSpaceWidth)
                    {
                        rightSpaceWidth = OwnerVisualElement.Width - (leftSpaceWidth + centerSpaceWidth);
                    }

                    if ((rightBoxVerticalExpansionFlags & VerticalBoxExpansion.Top) == VerticalBoxExpansion.Top)
                    {
                        right_y  = 0;
                        right_h += topSpaceHeight;
                    }
                    if ((rightBoxVerticalExpansionFlags & VerticalBoxExpansion.Bottom) == VerticalBoxExpansion.Bottom)
                    {
                        right_h += bottomSpaceHeight;
                    }
                    SetDockBound(spaces[R],
                                 w - rightSpaceWidth,
                                 right_y,
                                 rightSpaceWidth,
                                 right_h);
                    //spaces[R].InvalidateArrangeStatus();
                }
                //-------------------------------------------------
                if (t_space != null)
                {
                    //top
                    int top_x = 0;
                    int top_w = w;
                    if (this.dockSpaceConcept == SpaceConcept.NineSpace)
                    {
                        top_x = leftSpaceWidth;
                        top_w = w - (leftSpaceWidth + rightSpaceWidth);
                    }
                    //-------------------------------------------------------

                    if ((leftBoxVerticalExpansionFlags & VerticalBoxExpansion.Top) == VerticalBoxExpansion.Top)
                    {
                        top_x = leftSpaceWidth;
                        //top_w -= leftSpaceWidth;
                    }
                    if ((rightBoxVerticalExpansionFlags & VerticalBoxExpansion.Top) == VerticalBoxExpansion.Top)
                    {
                        //top_w -= rightSpaceWidth;
                    }
                    SetDockBound(spaces[T],
                                 top_x,
                                 0,
                                 top_w,
                                 topSpaceHeight);
                }
                //-------------------------------------------------
                if (b_space != null)
                {
                    int bottom_x = 0;
                    int bottom_w = w;
                    if (this.dockSpaceConcept == SpaceConcept.NineSpace)
                    {
                        bottom_x = leftSpaceWidth;
                        bottom_w = w - (leftSpaceWidth + rightSpaceWidth);
                    }
                    //-----------------------------------------------------

                    if ((leftBoxVerticalExpansionFlags & VerticalBoxExpansion.Bottom) == VerticalBoxExpansion.Bottom)
                    {
                        bottom_x = leftSpaceWidth;
                        //bottom_w -= leftSpaceWidth;
                    }
                    if ((rightBoxVerticalExpansionFlags & VerticalBoxExpansion.Bottom) == VerticalBoxExpansion.Bottom)
                    {
                        //bottom_w -= rightSpaceWidth;
                    }


                    bottom_x += leftSplitterWidth;
                    //-----------------------------------------------------
                    SetDockBound(spaces[B],
                                 bottom_x,
                                 h - bottomSpaceHeight,
                                 bottom_w,
                                 bottomSpaceHeight);
                }


                //---------------------------------------------------------------------------------
                if (spaces[C] != null)
                {
                    w = OwnerVisualElement.Width - (rightSpaceWidth + leftSpaceWidth) - (leftSplitterWidth + rightSplitterWidth);
                    h = OwnerVisualElement.Height - (topSpaceHeight + bottomSpaceHeight);
                    if (w < 1)
                    {
                        w = 1;
                    }
                    if (h < 1)
                    {
                        h = 1;
                    }

                    int x = leftSpaceWidth + leftSplitterWidth;
                    SetDockBound(spaces[C],
                                 x,
                                 topSpaceHeight,
                                 w,
                                 h);
                }
                if (dockSpaceConcept == SpaceConcept.NineSpace)
                {
                    h = OwnerVisualElement.Height;
                    w = OwnerVisualElement.Width;
                    SetDockBound(spaces[LT], 0, 0, leftSpaceWidth, topSpaceHeight);
                    SetDockBound(spaces[LB], 0, h - bottomSpaceHeight, leftSpaceWidth, bottomSpaceHeight);
                    SetDockBound(spaces[RT], w - rightSpaceWidth, 0, rightSpaceWidth, topSpaceHeight);
                    SetDockBound(spaces[RB], w - rightSpaceWidth, h - bottomSpaceHeight, rightSpaceWidth, bottomSpaceHeight);
                }
                //-----------------------------
            }
            for (int i = spaces.Length - 1; i >= 0; i--)
            {
                SpacePart dockSpace = spaces[i];
                if (dockSpace.SpaceName == SpaceName.Left ||
                    dockSpace.SpaceName == SpaceName.Right)
                {
                }
                if (dockSpace != null)
                {
                    dockSpace.ArrangeContent();
                }
            }

            //-------------------------------------------------

            if (this.FinishNineSpaceArrangement != null)
            {
                FinishNineSpaceArrangement(this, EventArgs.Empty);
            }

#if DEBUG
            //vinv.dbug_EndLayoutTrace();
#endif
        }
예제 #10
0
        void SetBoundOfFreeSpace(SpacePart space,
                                 SpacePart centerspace,
                                 bool suddenArr)
        {
            if (space == null)
            {
                return;
            }

            suddenArr = false;
            var centerspacex = centerspace.Content;
            int x_pos        = centerspace.X;
            int y_pos        = centerspace.Y;

            int dw = OwnerVisualElement.Width;
            int dh = OwnerVisualElement.Height;


            if (space.DesiredWidth < dw)
            {
                dw = space.DesiredWidth;
            }
            if (space.DesiredHeight < dh)
            {
                dh = space.DesiredHeight;
            }


            SetDockBound(space,
                         0,
                         0,
                         dw,
                         dh);


            switch (space.SpaceName)
            {
            case SpaceName.Left:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    x_pos -= space.Width;
                } break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    x_pos -= space.Width / 2;
                } break;
                }
                space.SetLocation(x_pos, y_pos);
            } break;

            case SpaceName.Right:
            {
                x_pos = centerspace.Right;
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Inner:
                {
                    x_pos -= space.Width;
                } break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    x_pos -= space.Width / 2;
                } break;
                }
            } break;

            case SpaceName.Top:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    y_pos -= space.Height;
                } break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    y_pos -= space.Height / 2;
                } break;
                }
            } break;

            case SpaceName.Bottom:
            {
                y_pos = centerspace.Bottom;

                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Inner:
                {
                    y_pos -= space.Height;
                } break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    y_pos -= space.Height / 2;
                } break;
                }
            } break;

            case SpaceName.LeftTop:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    x_pos -= space.Width;
                    y_pos -= space.Height;
                } break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    x_pos -= space.Width / 2;
                    y_pos -= space.Height / 2;
                } break;
                }
            } break;

            case SpaceName.LeftBottom:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    x_pos -= space.Width;
                    y_pos  = centerspace.Bottom;
                } break;

                case NamedSpaceContainerOverlapMode.Inner:
                {
                    y_pos = centerspace.Bottom - space.Height;
                } break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    x_pos -= space.Width / 2;
                    y_pos  = centerspace.Bottom - space.Height / 2;
                } break;
                }
            } break;

            case SpaceName.RightTop:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    x_pos  = centerspace.Right;
                    y_pos -= space.Height;
                } break;

                case NamedSpaceContainerOverlapMode.Inner:
                {
                    x_pos = centerspace.Right - space.Width;
                } break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    //outter - half of grip
                    x_pos  = centerspace.Right - (space.Width / 2);
                    y_pos -= space.Height - (space.Height / 2);
                } break;
                }
            } break;

            case SpaceName.RightBottom:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    x_pos = centerspace.Right;
                    y_pos = centerspace.Bottom;
                } break;

                case NamedSpaceContainerOverlapMode.Inner:
                {
                    x_pos = centerspace.Right - space.Width;
                    y_pos = centerspace.Bottom - space.Height;
                } break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    //outer - half of grid box
                    x_pos = centerspace.Right - (space.Width / 2);
                    y_pos = centerspace.Bottom - (space.Height / 2);
                } break;
                }
            } break;
            }

            //VisualInvalidateCanvasArgs vinv = contentArrVisitor.GetVisualInvalidateCanvasArgs();
            space.SetLocation(x_pos, y_pos);
        }
예제 #11
0
        //public override string ToString()
        //{
        //    //if (dockSpaceConcept == SpaceConcept.NineSpaceFree)
        //    //{
        //    //    return "FREE_NINE_LAY (L" + dbug_layer_id + this.dbugLayerState + "):" + this.PostCalculateContentSize.ToString() + " of " + ownerVisualElement.ToString();
        //    //}
        //    //else
        //    //{
        //    //    return "dock layer (L" + dbug_layer_id + this.dbugLayerState + "):" + this.PostCalculateContentSize.ToString() + " of " + ownerVisualElement.ToString();
        //    //}
        //}
#endif

        protected static void SetDockBound(SpacePart dock, int x, int y, int newWidth, int newHeight)
        {
            if (dock == null)
            {
                return;
            }
            dock.SetBound(x, y, newWidth, newHeight);
        }
예제 #12
0
 static int CalculateTotalFreeSpacesDesiredHeight(SpacePart bx1, SpacePart bx2, SpacePart bx3)
 {
     int totalHeight = 0;
     if (bx1 != null)
     {
         switch (bx1.OverlapMode)
         {
             case NamedSpaceContainerOverlapMode.Middle:
                 {
                     totalHeight += (bx1.DesiredHeight / 2);
                 }
                 break;
             case NamedSpaceContainerOverlapMode.Outer:
                 {
                     totalHeight += bx1.DesiredHeight;
                 }
                 break;
         }
     }
     if (bx2 != null)
     {
         //center not care overlapping
         totalHeight += bx2.DesiredHeight;
     }
     if (bx3 != null)
     {
         switch (bx3.OverlapMode)
         {
             case NamedSpaceContainerOverlapMode.Middle:
                 {
                     totalHeight += (bx3.DesiredHeight / 2);
                 }
                 break;
             case NamedSpaceContainerOverlapMode.Outer:
                 {
                     totalHeight += bx3.DesiredHeight;
                 }
                 break;
         }
     }
     return totalHeight;
 }
예제 #13
0
 static int CalculateTotalDockSpaceDesiredHeight(SpacePart bx1, SpacePart bx2, SpacePart bx3)
 {
     int total = 0;
     if (bx1 != null)
     {
         total += bx1.DesiredHeight;
     }
     if (bx2 != null)
     {
         total += bx2.DesiredHeight;
     }
     if (bx3 != null)
     {
         total += bx3.DesiredHeight;
     }
     return total;
 }
예제 #14
0
 protected SpacePart InitSpace(SpaceName name)
 {
     //only call from ctor?
     SpacePart dockspace = new SpacePart(this, 10, 10, name);
     return dockspace;
 }