public override void OnMouseMoved() { base.OnMouseMoved(); if (_mouseCoord == null) { return; } var bounds = Bounds; if (bounds.Width == 0) { return; } var handleIndex = InternalChild.Widgets.IndexOf(_handleDown); Grid.Proportion firstProportion, secondProportion; float fp; var position = Desktop.MousePosition; if (Orientation == Orientation.Horizontal) { var firstWidth = position.X - bounds.X - _mouseCoord.Value; for (var i = 0; i < handleIndex - 1; ++i) { firstWidth -= InternalChild.GetColumnWidth(i); } fp = (float)Widgets.Count * firstWidth / (bounds.Width - _handlesSize); firstProportion = InternalChild.ColumnsProportions[handleIndex - 1]; secondProportion = InternalChild.ColumnsProportions[handleIndex + 1]; } else { var firstHeight = position.Y - bounds.Y - _mouseCoord.Value; for (var i = 0; i < handleIndex - 1; ++i) { firstHeight -= InternalChild.GetRowHeight(i); } fp = (float)Widgets.Count * firstHeight / (bounds.Height - _handlesSize); firstProportion = InternalChild.RowsProportions[handleIndex - 1]; secondProportion = InternalChild.RowsProportions[handleIndex + 1]; } if (fp >= 0 && fp <= 2.0f) { var fp2 = firstProportion.Value + secondProportion.Value - fp; firstProportion.Value = fp; secondProportion.Value = fp2; FireProportionsChanged(); } }
private Rectangle GetItemBounds(int index) { var bounds = InternalChild.Bounds; if (Orientation == Orientation.Horizontal) { return(new Rectangle(bounds.X + InternalChild.GetCellLocationX(index), bounds.Y, InternalChild.GetColumnWidth(index), bounds.Height)); } return(new Rectangle(bounds.X, bounds.Y + InternalChild.GetCellLocationY(index), bounds.Width, InternalChild.GetRowHeight(index))); }