Skip to content

Commit

Permalink
Merge pull request #316 from IvanJosipovic/fix-close
Browse files Browse the repository at this point in the history
fix: prevent closing dockables which should not be closable
  • Loading branch information
wieslawsoltes authored Mar 11, 2024
2 parents b77793f + aeed334 commit c51a07b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Dock.Model/FactoryBase.Dockable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public virtual void SwapDockable(IDock sourceDock, IDock targetDock, IDockable s
var originalTargetDockable = targetDock.VisibleDockables[targetIndex];
sourceDock.VisibleDockables[sourceIndex] = originalTargetDockable;
targetDock.VisibleDockables[targetIndex] = originalSourceDockable;

InitDockable(originalSourceDockable, targetDock);
InitDockable(originalTargetDockable, sourceDock);

Expand Down Expand Up @@ -309,7 +309,7 @@ public virtual void PinDockable(IDockable dockable)
{
return;
}

var isVisible = false;

if (toolDock.VisibleDockables is not null)
Expand Down Expand Up @@ -349,7 +349,7 @@ public virtual void PinDockable(IDockable dockable)
break;
}
}

if (toolDock.VisibleDockables is not null)
{
RemoveVisibleDockable(toolDock, dockable);
Expand Down Expand Up @@ -458,7 +458,7 @@ public virtual void PinDockable(IDockable dockable)

AddVisibleDockable(toolDock, dockable);
OnDockableAdded(dockable);

// TODO: Handle ActiveDockable state.
// TODO: Handle IsExpanded property of IToolDock.
// TODO: Handle AutoHide property of IToolDock.
Expand Down Expand Up @@ -519,7 +519,7 @@ public virtual void FloatDockable(IDockable dockable)
/// <inheritdoc/>
public virtual void CloseDockable(IDockable dockable)
{
if (dockable.OnClose())
if (dockable.CanClose && dockable.OnClose())
{
RemoveDockable(dockable, true);
OnDockableClosed(dockable);
Expand Down Expand Up @@ -577,7 +577,7 @@ public virtual void CloseLeftDockables(IDockable dockable)
{
return;
}

CloseDockablesRange(dock, 0, indexOf - 1);
}

Expand All @@ -594,7 +594,7 @@ public virtual void CloseRightDockables(IDockable dockable)
{
return;
}

CloseDockablesRange(dock, indexOf + 1, dock.VisibleDockables.Count - 1);
}

Expand Down

0 comments on commit c51a07b

Please sign in to comment.