Replies: 2 comments
-
Same here. It seems that Close action removes it from list instead of hiding them or something like that. |
Beta Was this translation helpful? Give feedback.
-
Please disregard the information below the Legacy tag, but I'm keeping it here for future reference. I think elements of this solution are good, but it ultimately doesn't work consistently enough to be a working solution. We really need some documentation on dynamically adding and removing dockables. We sort of have some examples with documents, but my project does not make use of documents. All of my dockables are tools (perhaps that is a flaw in my own design from a misunderstanding of how best to use Dock) and so an example of adding and removing tools at runtime would be great. I can sometimes successfully add a tool; however, if I remove all the tools from the original dock, it collapses and then (sometimes) does not reopen when a new dockable is added. I also have many issues with dockables seemingly rendering on top of each other in weird ways, or else being added, but not showing up until you delete every other dockable. My guess is I'm either adding things incorrectly or otherwise trying to use this tool in ways it wasn't designed for. Not sure. Either way, the documentation only shows creating initial layouts or saving/loading layouts, but not actually how to modify them at runtime. Deleting, creating, and restoring dockables are missing. An example of what I'm looking for is, let's say you have a dockable called "Inspector" that you initially dock on the right of your main window. Then, you remove it. I'd like an example that shows you going to the top bar, selecting "Window > Inspector", and having that tool reappear. Even better would be for it to appear in its last docked or floating position if possible. As I've mentioned, I've gotten this partially working, but with many unwanted side effects and inconsistencies. -- Legacy --I know this question is a bit old, but I encountered a similar issue and wanted to share my solution. (It hardly works...but it's a start) I'm not sure what the best way to do this is, either. As @MihaMarkic said, it seems that when the tools are closed, they are completely removed from the public void RestoreTool(IDockable tool)
{
if (_toolDock is { } && tool is ICloseable { IsClosed: true } closeable)
{
closeable.IsClosed = false;
var newTool = new ToolDock
{
ActiveDockable = tool,
VisibleDockables = CreateList
(
tool
),
Alignment = Alignment.Right,
GripMode = GripMode.Visible
};
AddDockable(_toolDock, newTool);
}
} Then, for each Tool, I add an interface called public override void OnDockableClosed(IDockable? dockable)
{
base.OnDockableClosed(dockable);
if (dockable is ICloseable closeable)
{
closeable.IsClosed = true;
}
} This allows you to track any Then, from the relevant ViewModel that has access to this factory, I call the I modified the Notepad sample to create a new Find tool if it had previously been closed. To do this I modified the public void EditFind()
{
if (_factory?.GetDockable<ITool>("Find") is { } tool && Layout is { })
{
((NotepadFactory)_factory).RestoreTool(tool); // Probably would want to create an INotepad interface wrapper, but this works for now.
_factory.SetActiveDockable(tool);
_factory.SetFocusedDockable(Layout, tool);
}
} Again, is this the correct or best way to do this? No idea. But it worked for me! I couldn't find anywhere in either the documentation or the samples to restore tools to be open again. There is a method in the factory called Edit: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I need some help or hint how to restore/reopen a Tool I closed. Tried to get hints in Core2D (it seems to be a TODO here) or sample but could not find any.
Thanks
Daniel
Beta Was this translation helpful? Give feedback.
All reactions