-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The window cannot be automatically filled after being unpined #276
Labels
bug
Something isn't working
Comments
@wieslawsoltes In ProportionalStackPanel.cs,i have changed the AssignProportions method,this is my code Dictionary<Control, double> lastProportion = new Dictionary<Control, double>();
private void AssignProportions(IList<Control?> children)
{
var assignedProportion = 0.0;
var unassignedProportions = 0;
#region My change
double unassign = 0.0;
foreach (var control in children)
{
if (control.DataContext is IProportionalDock pdock && pdock.VisibleDockables != null)
{
// if all tooldocks has no ActiveDockable,then set the proportion of the parent ProportionalStackPanel to 0;
var toolDocks = pdock.VisibleDockables.OfType<IToolDock>();
if (toolDocks.All(x => x.ActiveDockable == null))
{
var proportion = ProportionalStackPanelSplitter.GetProportion(control);
ProportionalStackPanelSplitter.SetProportion(control, 0);
unassign += proportion;
//record the last proportion
lastProportion[control] = proportion;
}
else
{
if (lastProportion.TryGetValue(control, out var value))
{
ProportionalStackPanelSplitter.SetProportion(control, value);
}
}
}
}
if (unassign > 0)
{
//if has the document dock,add the remaining proportion to the document dock
var documentDock = children.OfType<DocumentDockControl>().FirstOrDefault();
if (documentDock != null)
{
var p = ProportionalStackPanelSplitter.GetProportion(documentDock);
p += unassign;
ProportionalStackPanelSplitter.SetProportion(documentDock, p);
}
}
#endregion
foreach (var control in children)
{
if (control is { } and not ProportionalStackPanelSplitter)
{
var proportion = ProportionalStackPanelSplitter.GetProportion(control);
if (double.IsNaN(proportion))
{
unassignedProportions++;
}
else
{
assignedProportion += proportion;
}
}
}
if (unassignedProportions > 0)
{
var toAssign = assignedProportion;
foreach (var control in children.Where(c => c is { } && double.IsNaN(ProportionalStackPanelSplitter.GetProportion(c))))
{
if (control is { } and not ProportionalStackPanelSplitter)
{
var proportion = (1.0 - toAssign) / unassignedProportions;
ProportionalStackPanelSplitter.SetProportion(control, proportion);
assignedProportion += (1.0 - toAssign) / unassignedProportions;
}
}
}
if (assignedProportion < 1)
{
var numChildren = (double)children.Count(c => c is not ProportionalStackPanelSplitter);
var toAdd = (1.0 - assignedProportion) / numChildren;
foreach (var child in children.Where(c => c is not ProportionalStackPanelSplitter))
{
if (child is { })
{
var proportion = ProportionalStackPanelSplitter.GetProportion(child) + toAdd;
ProportionalStackPanelSplitter.SetProportion(child, proportion);
}
}
}
else if (assignedProportion > 1)
{
var numChildren = (double)children.Count(c => c is not ProportionalStackPanelSplitter);
var toRemove = (assignedProportion - 1.0) / numChildren;
foreach (var child in children.Where(c => c is not ProportionalStackPanelSplitter))
{
if (child is { })
{
var proportion = ProportionalStackPanelSplitter.GetProportion(child) - toRemove;
ProportionalStackPanelSplitter.SetProportion(child, proportion);
}
}
}
} i only add some code in region |
It's known issue, didn't yet found a working solution. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: