예제 #1
0
        /// <summary> calculate the minimum width.</summary>
        /// <originalMinSize:>  if to return the original min size(without the decrease the Spliter width) </originalMinSize:>
        /// <returns>
        /// </returns>
        private int calcMinimumWidth(bool originalMinSize)
        {
            int         retMinWidth    = 0;
            IEnumerator valuesIterator = _childrenMinSizeInfo.Values.GetEnumerator();

            while (valuesIterator.MoveNext())
            {
                MinSizeInfo minSizeInfo = (MinSizeInfo)valuesIterator.Current;
                if (getOrientation() == MgSplitContainer.SPLITTER_STYLE_HORIZONTAL)
                {
                    retMinWidth += minSizeInfo.calcMinimumWidth(originalMinSize);
                }
                else
                {
                    retMinWidth = Math.Max(minSizeInfo.calcMinimumWidth(originalMinSize), retMinWidth);
                }
            }

            int size = MinWidth;

            if (originalMinSize && MinWidth > 0)
            {
                Point pt = new Point(MinWidth, GuiConstants.DEFAULT_VALUE_INT);
                GuiUtils.updateFrameSize(ref pt, false);
                size = pt.X;
            }

            retMinWidth = Math.Max(retMinWidth, size);

            return(retMinWidth);
        }
예제 #2
0
 /// <summary> add minimum size info for a child.
 ///
 /// </summary>
 /// <param name="control">
 /// </param>
 /// <param name="minSizeInfoChild">
 /// </param>
 internal void addChildMinSizeInfo(Control control, MinSizeInfo minSizeInfoChild)
 {
     if (_childrenMinSizeInfo[control] == null)
     {
         _childrenMinSizeInfo[control] = minSizeInfoChild;
     }
 }
예제 #3
0
        /// <summary> handle the drag of the splitter
        /// and update the org size
        /// </summary>
        /// <param name="event">
        /// </param>
        internal void onSplitterMoving(Splitter splitter, SplitterEventArgs e)
        {
            MgSplitContainer mgSplitContainer = (MgSplitContainer)splitter.Parent;

            mgSplitContainer.IgnoreLayout = true;

            int shift = 0;
            int beforeControlminimumSize = 0;
            int afterControlminimumSize  = 0;

            // Rectangle splitterBounds - get the bound of the selected splitter- the new bound after the resize
            Rectangle boundsSelectedSplitter = splitter.Bounds;
            // check only when there is movement in the Splitter place
            bool isHorizontal = mgSplitContainer.getOrientation() == MgSplitContainer.SPLITTER_STYLE_HORIZONTAL;

            if ((isHorizontal && e.SplitX == boundsSelectedSplitter.X) || (!isHorizontal && e.SplitY == boundsSelectedSplitter.Y))
            {
                mgSplitContainer.IgnoreLayout = false;
                return;
            }

            int SplitterIndex = -1;

            // found the Splitter that was selected in the array Splitter
            for (int i = 0; i < mgSplitContainer.Splitters.Count; i++)
            {
                if (mgSplitContainer.Splitters[i] == splitter)
                {
                    SplitterIndex = i;
                    break;
                }
            }
            // if not found return
            if (SplitterIndex == -1)
            {
                mgSplitContainer.IgnoreLayout = false;
                return;
            }
            Control[] controls = mgSplitContainer.getControls(true);

            // fixed bug#:769214
            if (controls.Length <= SplitterIndex + 1)
            {
                mgSplitContainer.IgnoreLayout = false;
                return;
            }

            // get the control BEFORE the selected Splitter from the control array
            Control controlBefore = controls[SplitterIndex];
            // get the control AFTER the selected Splitter from the control array
            Control controlAfter = controls[SplitterIndex + 1];

            // get the minimum size of the before\After control
            MinSizeInfo beforeControlMinSizeInfo = GuiUtils.getMinSizeInfo(controlBefore);
            MinSizeInfo afterControlMinSizeInfo  = GuiUtils.getMinSizeInfo(controlAfter);
            Point       minSize;

            if (beforeControlMinSizeInfo != null)
            {
                minSize = beforeControlMinSizeInfo.getMinSize(false);
                beforeControlminimumSize = isHorizontal ? minSize.X : minSize.Y;
            }
            if (afterControlMinSizeInfo != null)
            {
                minSize = afterControlMinSizeInfo.getMinSize(false);
                afterControlminimumSize = isHorizontal ? minSize.X : minSize.Y;
            }

            // get the bounds of the two controls
            Rectangle beforeControlBounds = new Rectangle(controlBefore.Bounds.Location.X,
                                                          controlBefore.Bounds.Location.Y,
                                                          controlBefore.Bounds.Size.Width,
                                                          controlBefore.Bounds.Size.Height);
            Rectangle afterControlBounds = new Rectangle(controlAfter.Bounds.Location.X,
                                                         controlAfter.Bounds.Location.Y,
                                                         controlAfter.Bounds.Size.Width,
                                                         controlAfter.Bounds.Size.Height);

            ////do the movement
            if (isHorizontal)
            {
                // found the allow shift until the minimum size
                shift = getShift(mgSplitContainer, e, boundsSelectedSplitter, beforeControlBounds, beforeControlminimumSize, afterControlBounds, afterControlminimumSize);
                if (shift == 0)
                {
                    return;
                }
                else
                {
                    // update the bounds of the Splitter control by the shift value
                    beforeControlBounds.Width += shift;
                    afterControlBounds.X      += shift;
                    afterControlBounds.Width  -= shift;

                    e.SplitX = beforeControlBounds.Width;

                    setOrgSize(mgSplitContainer, controlBefore, beforeControlBounds, controlAfter, afterControlBounds);
                }
            }
            else
            {
                // found the allow shift until the minimum size
                shift = getShift(mgSplitContainer, e, boundsSelectedSplitter, beforeControlBounds, beforeControlminimumSize, afterControlBounds, afterControlminimumSize);
                if (shift == 0)
                {
                    return;
                }
                else
                {
                    // update the bounds of the Splitter control by the shift value
                    beforeControlBounds.Height += shift;
                    afterControlBounds.Y       += shift;
                    afterControlBounds.Height  -= shift;

                    setOrgSize(mgSplitContainer, controlBefore, beforeControlBounds, controlAfter, afterControlBounds);
                }
            }
        }
예제 #4
0
        /// <summary> </summary>
        /// <param name="control"> </param>
        /// <returns> </returns>
        private Point getMinimunSize(Control control)
        {
            MinSizeInfo msInfo = GuiUtils.getMinSizeInfo(control);

            return(msInfo.getMinSize(false));
        }