internal MenuItemButton(MenuItemStyle style) { Widget = new Grid((GridStyle)null); _imageProportion = new Grid.Proportion(); Widget.ColumnsProportions.Add(_imageProportion); var textProportion = new Grid.Proportion(); Widget.ColumnsProportions.Add(textProportion); _shortcutProportion = new Grid.Proportion(); Widget.ColumnsProportions.Add(_shortcutProportion); _image = new Image(); Widget.Widgets.Add(_image); _textBlock = new TextBlock { GridPositionX = 1, IsMenuText = true }; Widget.Widgets.Add(_textBlock); PaddingLeft = 5; PaddingRight = 5; PaddingBottom = 2; if (style != null) { ApplyMenuItemStyle(style); } }
internal MenuItemButton(Menu menu, MenuItemStyle style) { Menu = menu; InternalChild = new Grid(); _imageProportion = new Grid.Proportion(); InternalChild.ColumnsProportions.Add(_imageProportion); var textProportion = new Grid.Proportion(); InternalChild.ColumnsProportions.Add(textProportion); _shortcutProportion = new Grid.Proportion(); InternalChild.ColumnsProportions.Add(_shortcutProportion); _image = new Image(); InternalChild.Widgets.Add(_image); _textBlock = new TextBlock { GridColumn = 1, }; InternalChild.Widgets.Add(_textBlock); if (style != null) { ApplyMenuItemStyle(style); } }
private void GetProportions(int leftWidgetIndex, out Grid.Proportion leftProportion, out Grid.Proportion rightProportion) { var baseIndex = leftWidgetIndex * 2; leftProportion = Orientation == Orientation.Horizontal ? Widget.ColumnsProportions[baseIndex] : Widget.RowsProportions[baseIndex]; rightProportion = Orientation == Orientation.Horizontal ? Widget.ColumnsProportions[baseIndex + 2] : Widget.RowsProportions[baseIndex + 2]; }
public void Reset() { // Clear Widget.Widgets.Clear(); _handles.Clear(); _handlesSize = 0; Widget.ColumnsProportions.Clear(); Widget.RowsProportions.Clear(); var i = 0; var handleSize = Orientation == Orientation.Horizontal ? HandleStyle.Background.Size.X : HandleStyle.Background.Size.Y; 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(); }
public void Reset() { // Clear InternalChild.Widgets.Clear(); _handles.Clear(); _handlesSize = 0; InternalChild.ColumnsProportions.Clear(); InternalChild.RowsProportions.Clear(); var i = 0; var handleSize = Orientation == Orientation.Horizontal ? HandleStyle.Background.Size.X : HandleStyle.Background.Size.Y; 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, ReleaseOnMouseLeft = false }; handle.PressedChanged += HandleOnPressedChanged; proportion = new Grid.Proportion(Grid.ProportionType.Auto); if (Orientation == Orientation.Horizontal) { _handlesSize += handleSize; handle.GridColumn = i * 2 - 1; InternalChild.ColumnsProportions.Add(proportion); } else { _handlesSize += handleSize; handle.GridRow = i * 2 - 1; InternalChild.RowsProportions.Add(proportion); } InternalChild.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.GridColumn = i * 2; InternalChild.ColumnsProportions.Add(proportion); } else { w.GridRow = i * 2; InternalChild.RowsProportions.Add(proportion); } InternalChild.Widgets.Add(w); ++i; } foreach (var h in _handles) { if (Orientation == Orientation.Horizontal) { h.Width = handleSize; h.Height = null; } else { h.Width = null; h.Height = handleSize; } } FireProportionsChanged(); }