Skip to content

Commit

Permalink
Merge pull request #415 from Noisrev/fix-pr410
Browse files Browse the repository at this point in the history
Improved and fix floating window activation and activation pane
  • Loading branch information
Dirkster99 committed Dec 26, 2022
2 parents ba90c40 + cbf6f92 commit bca85e3
Showing 1 changed file with 68 additions and 49 deletions.
Expand Up @@ -118,15 +118,33 @@ private void ActiveOfSinglePane(bool isActive)
var layoutDocumentPane = _model.Descendents().OfType<LayoutDocumentPane>()
.FirstOrDefault(p => p.ChildrenCount > 0 && p.SelectedContent != null);

layoutDocumentPane.SelectedContent.IsActive = isActive;
if (layoutDocumentPane != null)
{
layoutDocumentPane.SelectedContent.IsActive = isActive;
}
// When the floating tool window is mixed with the floating document window
// and the document pane in the floating document window is dragged out.

// Only the Tool panes is left in the floating document window.
// The Children Count is greater than 0 and the Selected Content is null.

// Then we only need to activate the last active content.
else
{
ActiveLastActivationOfItems(isActive);
}
}

private static LayoutDocumentPaneControl FindDocumentPaneControlByPoint(IEnumerable<LayoutDocumentPaneControl> areaHosts, Point point)
private LayoutDocumentPaneControl FindDocumentPaneControlByMousePoint()
{
var mousePosition = Win32Helper.GetMousePosition();
var rootVisual = ((FloatingWindowContentHost)Content).RootVisual;
var areaHosts = rootVisual.FindVisualChildren<LayoutDocumentPaneControl>();

foreach (var areaHost in areaHosts)
{
var area = areaHost.GetScreenArea();
var pos = areaHost.TransformFromDeviceDPI(point);
var pos = areaHost.TransformFromDeviceDPI(mousePosition);
var b = area.Contains(pos);

if (b)
Expand All @@ -138,73 +156,74 @@ private static LayoutDocumentPaneControl FindDocumentPaneControlByPoint(IEnumera
return null;
}

private void ActiveOfMultiPane(bool isActive)
private void ActiveLastActivationOfPane(LayoutDocumentPane model)
{
var mousePosition = Win32Helper.GetMousePosition();
var rootVisual = ((FloatingWindowContentHost)Content).RootVisual;
var areaHosts = rootVisual.FindVisualChildren<LayoutDocumentPaneControl>();

if (isActive)
if (model.Children.Count > 0)
{
var documentPane = FindDocumentPaneControlByPoint(areaHosts, mousePosition);
if (documentPane != null)
var index = 0;
if (model.Children.Count > 1)
{
var model = (LayoutDocumentPane)documentPane.Model;
if (model.SelectedContent != null)
var tmTimeStamp = model.Children[0].LastActivationTimeStamp;
for (var i = 1; i < model.Children.Count; i++)
{
model.SelectedContent.IsActive = true;
return;
}
// AnchorablePane
else
{
var index = 0;
for (var i = 0; i < model.Children.Count; i++)
var item = model.Children[i];
if (item.LastActivationTimeStamp > tmTimeStamp)
{
var item = model.Children[i];
if (item.IsLastFocusedDocument)
{
index = i;
}
tmTimeStamp = item.LastActivationTimeStamp;
index = i;
}

model.SelectedContentIndex = index;
return;
}
}
else

model.SelectedContentIndex = index;
}
}

private void ActiveLastActivationOfItems(bool isActive)
{
var items = _model.Descendents().OfType<LayoutContent>().ToList();
if (items.Count > 0)
{
var index = 0;
if (items.Count > 1)
{
// Active the Last Focus
foreach (var areaHost in areaHosts)
var tmpTimeStamp2 = items[0].LastActivationTimeStamp;
for (var i = 1; i < items.Count; i++)
{
var model = (LayoutDocumentPane)areaHost.Model;
for (var i = 0; i < model.Children.Count; i++)
var item = items[i];
if (item.LastActivationTimeStamp > tmpTimeStamp2)
{
var item = model.Children[i];
if (item.IsLastFocusedDocument)
{
item.IsActive = true;
return;
}
tmpTimeStamp2 = item.LastActivationTimeStamp;
index = i;
}
}
}

items[index].IsActive = isActive;
}
else
}

private void ActiveOfMultiPane(bool isActive)
{
if (isActive)
{
foreach (var areaHost in areaHosts)
var documentPane = FindDocumentPaneControlByMousePoint();
if (documentPane != null)
{
var model = (LayoutDocumentPane)areaHost.Model;
for (var i = 0; i < model.Children.Count; i++)
var model = (LayoutDocumentPane)documentPane.Model;
if (model.SelectedContent != null)
{
var item = model.Children[i];
if (item.IsActive)
{
item.IsActive = false;
}
model.SelectedContent.IsActive = true;
return;
}
else
{
ActiveLastActivationOfPane(model);
return;
}
}
}
ActiveLastActivationOfItems(isActive);
}

/// <inheritdoc />
Expand Down

0 comments on commit bca85e3

Please sign in to comment.