Comments (1)
LayoutPanelControl.cs
func:
protected override void OnFixChildrenDockLengths()
{
if (ActualWidth == 0.0 || ActualHeight == 0.0) return;
#region Setup DockWidth/Height for children
if (_model.Orientation == Orientation.Horizontal)
{
if (_model.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>())
{
for (var i = 0; i < _model.Children.Count; i++)
{
if (_model.Children[i] as ILayoutContainer != null &&
((_model.Children[i] as ILayoutContainer).IsOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ||
(_model.Children[i] as ILayoutContainer).ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>()))
{
// Keep set values (from XML for instance)
if (!(_model.Children[i] as ILayoutPositionableElement).DockWidth.IsStar) (_model.Children[i] as ILayoutPositionableElement).DockWidth = new GridLength(1.0, GridUnitType.Star);
}
else if (_model.Children[i] as ILayoutPositionableElement != null && (_model.Children[i] as ILayoutPositionableElement).DockWidth.IsStar)
{
var childPositionableModelWidthActualSize = _model.Children[i] as ILayoutPositionableElement as ILayoutPositionableElementWithActualSize;
var childDockMinWidth = (_model.Children[i] as ILayoutPositionableElement).CalculatedDockMinWidth();
if (childPositionableModelWidthActualSize.ActualWidth == 0)
{
if (childPositionableModelWidthActualSize.DockWidth.IsStar)
{
childPositionableModelWidthActualSize.ActualWidth = (ActualWidth - _model.Children.Cast<ILayoutPositionableElement>()
.Where(j => j.DockWidth.IsAbsolute)
.Select(j => j.DockWidth.Value)
.Sum()) * childPositionableModelWidthActualSize.DockWidth.Value / _model.Children.Cast<ILayoutPositionableElement>()
.Where(j => j.DockWidth.IsStar)
.Select(j => j.DockWidth.Value)
.Sum();
}
else if (childPositionableModelWidthActualSize.DockWidth.IsAbsolute)
{
childPositionableModelWidthActualSize.ActualWidth = childPositionableModelWidthActualSize.DockWidth.Value;
}
}
var widthToSet = Math.Max(childPositionableModelWidthActualSize.ActualWidth, childDockMinWidth);
widthToSet = Math.Min(widthToSet, ActualWidth / 2.0);
widthToSet = Math.Max(widthToSet, childDockMinWidth);
(_model.Children[i] as ILayoutPositionableElement).DockWidth = new GridLength(widthToSet, GridUnitType.Pixel);
}
}
}
else
{
for (var i = 0; i < _model.Children.Count; i++)
{
var childPositionableModel = _model.Children[i] as ILayoutPositionableElement;
if (!childPositionableModel.DockWidth.IsStar)
{
// Keep set values (from XML for instance)
if (!childPositionableModel.DockWidth.IsStar) childPositionableModel.DockWidth = new GridLength(1.0, GridUnitType.Star);
}
}
}
}
else // Vertical
{
if (_model.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>())
{
for (var i = 0; i < _model.Children.Count; i++)
{
if (_model.Children[i] is ILayoutContainer childContainerModel &&
(childContainerModel.IsOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ||
childContainerModel.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>()))
{
// Keep set values (from XML for instance)
if (!(_model.Children[i] as ILayoutPositionableElement).DockHeight.IsStar) (_model.Children[i] as ILayoutPositionableElement).DockHeight = new GridLength(1.0, GridUnitType.Star);
}
else if (_model.Children[i] as ILayoutPositionableElement != null && (_model.Children[i] as ILayoutPositionableElement).DockHeight.IsStar)
{
var childPositionableModelWidthActualSize = _model.Children[i] as ILayoutPositionableElement as ILayoutPositionableElementWithActualSize;
var childDockMinHeight = (_model.Children[i] as ILayoutPositionableElement).CalculatedDockMinHeight();
if (childPositionableModelWidthActualSize.ActualHeight == 0)
{
if (childPositionableModelWidthActualSize.DockHeight.IsStar)
{
childPositionableModelWidthActualSize.ActualHeight = ((ActualHeight - _model.Children.Cast<ILayoutPositionableElement>()
.Where(j => j.DockHeight.IsAbsolute)
.Select(j => j.DockHeight.Value)
.Sum())) * childPositionableModelWidthActualSize.DockHeight.Value / _model.Children.Cast<ILayoutPositionableElement>()
.Where(j => j.DockHeight.IsStar)
.Select(j => j.DockHeight.Value)
.Sum();
}
else if (childPositionableModelWidthActualSize.DockHeight.IsAbsolute)
{
childPositionableModelWidthActualSize.ActualHeight = childPositionableModelWidthActualSize.DockHeight.Value;
}
}
var heightToSet = Math.Max(childPositionableModelWidthActualSize.ActualHeight, childDockMinHeight);
heightToSet = Math.Min(heightToSet, ActualHeight / 2.0);
heightToSet = Math.Max(heightToSet, childDockMinHeight);
(_model.Children[i] as ILayoutPositionableElement).DockHeight = new GridLength(heightToSet, GridUnitType.Pixel);
}
}
}
else
{
for (var i = 0; i < _model.Children.Count; i++)
{
var childPositionableModel = _model.Children[i] as ILayoutPositionableElement;
if (!childPositionableModel.DockHeight.IsStar)
{
// Keep set values (from XML for instance)
if (!childPositionableModel.DockHeight.IsStar) childPositionableModel.DockHeight = new GridLength(1.0, GridUnitType.Star);
}
}
}
}
#endregion Setup DockWidth/Height for children
}
from avalondock.
Related Issues (20)
- Floating Windows are added twice to _fwList when layout is loaded.
- CaptureMouse in LayoutFloatingWindowControl causes mouse drag to fail when using Expression theme
- Closing document keytip hint HOT 1
- How do I modify the color of AnchorablePaneTabPanel
- When selecting layout anchorable from contextmenu in layout document pane control it doesn´t come into view
- How to change AccentColors Vs2013DarkTheme ? HOT 1
- How do I change this element style? HOT 1
- .NET 8 Update HOT 1
- WPF UI Theming
- Weird 'IsFloating' error at AnchorablePane creation HOT 1
- The widget dragged out, can it be a separate window like in Visual Studio, independent of the parent window? HOT 1
- Community Toolkit Sample HOT 1
- How to keep order of LayoutAnchorable after setting IsVisible HOT 1
- PropertyChanged event is not fired for IsFloating when dragging LayoutAnchorable to float or dock HOT 2
- 动态切换语言
- LayoutDocument可以不显示那个三角符号吗
- Net8 avalondock does not appear in the form editor
- IconSource property does not work when binding defined in Style HOT 1
- NavigatorWindow crashes application when double clicking on file option
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avalondock.