Exemple #1
0
        public override void OnMouseMoved(Point position)
        {
            base.OnMouseMoved(position);

            if (_mouseCoord == null)
            {
                return;
            }

            var bounds = Bounds;

            if (bounds.Width == 0)
            {
                return;
            }

            var handleIndex = Widget.Widgets.IndexOf(_handleDown);

            Grid.Proportion firstProportion, secondProportion;
            float           fp;

            if (Orientation == Orientation.Horizontal)
            {
                var firstWidth = position.X - bounds.X - _mouseCoord.Value;

                for (var i = 0; i < handleIndex - 1; ++i)
                {
                    firstWidth -= Widget.GetColumnWidth(i);
                }

                fp = (float)Widgets.Count * firstWidth / (bounds.Width - _handlesSize);

                firstProportion  = Widget.ColumnsProportions[handleIndex - 1];
                secondProportion = Widget.ColumnsProportions[handleIndex + 1];
            }
            else
            {
                var firstHeight = position.Y - bounds.Y - _mouseCoord.Value;

                for (var i = 0; i < handleIndex - 1; ++i)
                {
                    firstHeight -= Widget.GetRowHeight(i);
                }

                fp = (float)Widgets.Count * firstHeight / (bounds.Height - _handlesSize);

                firstProportion  = Widget.RowsProportions[handleIndex - 1];
                secondProportion = Widget.RowsProportions[handleIndex + 1];
            }

            if (fp >= 0 && fp <= 2.0f)
            {
                var fp2 = firstProportion.Value + secondProportion.Value - fp;
                firstProportion.Value  = fp;
                secondProportion.Value = fp2;
                FireProportionsChanged();
            }
        }