public void Reset() { // Clear Widget.Widgets.Clear(); _handles.Clear(); _handlesSize = 0; Widget.ColumnsProportions.Clear(); Widget.RowsProportions.Clear(); var i = 0; int handleSize = (int)(Orientation == Orientation.Horizontal ? HandleStyle.Background.Size.Width : HandleStyle.Background.Size.Height); foreach (var w in _widgets) { Grid.Proportion proportion; if (i > 0) { // Add splitter var handle = new ImageButton(HandleStyle) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, CanFocus = false }; handle.Down += HandleOnDown; handle.Up += HandleOnUp; proportion = new Grid.Proportion(Grid.ProportionType.Auto); if (Orientation == Orientation.Horizontal) { _handlesSize += handleSize; handle.GridPositionX = i * 2 - 1; Widget.ColumnsProportions.Add(proportion); } else { _handlesSize += handleSize; handle.GridPositionY = i * 2 - 1; Widget.RowsProportions.Add(proportion); } Widget.Widgets.Add(handle); _handles.Add(handle); } proportion = i < _widgets.Count - 1 ? new Grid.Proportion(Grid.ProportionType.Part, 1.0f) : new Grid.Proportion(Grid.ProportionType.Fill, 1.0f); // Set grid coord and add widget itself if (Orientation == Orientation.Horizontal) { w.GridPositionX = i * 2; Widget.ColumnsProportions.Add(proportion); } else { w.GridPositionY = i * 2; Widget.RowsProportions.Add(proportion); } Widget.Widgets.Add(w); ++i; } foreach (var h in _handles) { if (Orientation == Orientation.Horizontal) { h.WidthHint = handleSize; h.HeightHint = null; } else { h.WidthHint = null; h.HeightHint = handleSize; } } FireProportionsChanged(); }
private void HandleOnUp(object sender, EventArgs args) { _handleDown = null; _mouseCoord = null; }