/// <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); } } }
/// <summary> </summary> /// <param name="control"> </param> /// <returns> </returns> private Point getMinimunSize(Control control) { MinSizeInfo msInfo = GuiUtils.getMinSizeInfo(control); return(msInfo.getMinSize(false)); }