RobinPerris/DarkUI

Initial size of DarkToolWindow

Opened this issue · 2 comments

This is more a question than a issue, but here i go.

When i add a content using DarkToolWindow, and set the DefaultDockArea to left, i can change the start width of this? If i can, how do i do that?

Docked content doesn't have a set size. It inherits the size of the area instead. The area sizes are not directly accessible from outside of the DarkUI project as they are set to private.

The library was designed around workspaces which could be saved and loaded, rather than programatically setting these values directly. Personally I had a pre-defined workspace configuration which I shipped with the application as the default, then allowed users to save their own custom configurations alongside that. Within that, I set the default area sizes to what I found to be suitable.

There's a working method of doing this in the example project:

#region Serialization Region
private void SerializeDockPanel(string path)
{
var state = DockPanel.GetDockPanelState();
SerializerHelper.Serialize(state, path);
}
private void DeserializeDockPanel(string path)
{
var state = SerializerHelper.Deserialize<DockPanelState>(path);
DockPanel.RestoreDockPanelState(state, GetContentBySerializationKey);
}
private DarkDockContent GetContentBySerializationKey(string key)
{
foreach (var window in _toolWindows)
{
if (window.SerializationKey == key)
return window;
}
return null;
}
#endregion

However, if you do want to directly set the size of an area programatically, you can add the following method to DarkDockPanel.cs and it should allow you to do this.

public void SetAreaSize(DarkDockArea area, Size size)
{
  switch (area)
  {
      case DarkDockArea.Left:
          _regions[DarkDockArea.Left].Size = size;
          break;
      case DarkDockArea.Right:
          _regions[DarkDockArea.Right].Size = size;
          break;
      case DarkDockArea.Bottom:
          _regions[DarkDockArea.Bottom].Size = size;
          break;
  }
}

Closing due to inactivity