Exemple #1
0
        /// <summary>
        /// perform layout after splitter was moved
        /// </summary>
        /// <param name="splitter"></param>
        /// <param name="e"></param>
        internal void onSplitterMoved(Splitter splitter, SplitterEventArgs e)
        {
            MgSplitContainer mgSplitContainer = (MgSplitContainer)splitter.Parent;

            mgSplitContainer.IgnoreLayout = false;
            mgSplitContainer.PerformLayout();
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="MgSplitContainer"></param>
        /// <param name="e"></param>
        /// <param name="selectedSplitterBounds"></param>
        /// <param name="beforeControlBounds"></param>
        /// <param name="beforeControlMinimumSize"></param>
        /// <param name="afterControlBounds"></param>
        /// <param name="afterControlMinimumSize"></param>
        /// <returns></returns>
        private int getShift(MgSplitContainer mgSplitContainer, SplitterEventArgs e, Rectangle selectedSplitterBounds, Rectangle beforeControlBounds, int beforeControlMinimumSize, Rectangle afterControlBounds, int afterControlMinimumSize)
        {
            int shift = 0;

            if (mgSplitContainer.getOrientation() == MgSplitContainer.SPLITTER_STYLE_HORIZONTAL)
            {
                shift = e.SplitX - selectedSplitterBounds.X;
                if (shift < 0)
                // we need to check the allow of the before control
                {
                    if (beforeControlBounds.Width > beforeControlMinimumSize)
                    {
                        if (beforeControlBounds.Width + shift < beforeControlMinimumSize)
                        {
                            shift    = beforeControlMinimumSize - beforeControlBounds.Width;
                            e.SplitX = selectedSplitterBounds.X + shift;
                        }
                    }
                    else
                    {
                        shift    = 0;
                        e.SplitX = selectedSplitterBounds.X;
                    }
                }
                // if (shift > 0)//we need to check the allow of the after control
                else
                {
                    if (afterControlBounds.Width > afterControlMinimumSize)
                    {
                        if (afterControlBounds.Width + (-shift) < afterControlMinimumSize)
                        {
                            shift    = afterControlBounds.Width - afterControlMinimumSize;
                            e.SplitX = selectedSplitterBounds.X - (shift);
                        }
                    }
                    else
                    {
                        shift    = 0;
                        e.SplitX = selectedSplitterBounds.X;
                    }
                }
            }
            // if (getOrientation() == SWT.VERTICAL)
            else
            {
                shift = e.SplitY - selectedSplitterBounds.Y;
                if (shift < 0)
                //// we need to check the allow of the before control
                {
                    if (beforeControlBounds.Height > beforeControlMinimumSize)
                    {
                        if (beforeControlBounds.Height + shift < beforeControlMinimumSize)
                        {
                            shift    = beforeControlMinimumSize - beforeControlBounds.Height;
                            e.SplitY = selectedSplitterBounds.Y + shift;
                        }
                    }
                    else
                    {
                        shift    = 0;
                        e.SplitY = selectedSplitterBounds.Y;
                    }
                }
                // if (shift > 0)//we need to check the allow of the after control
                else
                {
                    if (afterControlBounds.Height > afterControlMinimumSize)
                    {
                        if (afterControlBounds.Height + (-shift) < afterControlMinimumSize)
                        {
                            shift    = afterControlBounds.Height - afterControlMinimumSize;
                            e.SplitY = selectedSplitterBounds.Y - (shift);
                        }
                    }
                    else
                    {
                        shift    = 0;
                        e.SplitY = selectedSplitterBounds.Y;
                    }
                }
            }
            System.Console.WriteLine("shift : " + shift);
            return(shift);
        }
Exemple #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);
                }
            }
        }
Exemple #4
0
 internal void SplitterMovingHandler(object sender, SplitterEventArgs e)
 {
     handleEvent(EventType.SPLITTER_MOVING, sender, e);
 }