Divelements Community
Customer discussion of all Divelements products

Enumerate through the open Dockable Windows

Latest post 09-16-2008 12:34 by Mayank Gaur. 1 replies.
  • 09-15-2008 15:14

    Enumerate through the open Dockable Windows

    How can I enumerate through all the open dockable windows in a docksite or dockcontainer?  I have a situation where if a user performs a certain action, I need to enumerate through the windows, find ones that meet a certain criteria, and close those windows.

  • 09-16-2008 12:34 In reply to

    Re: Enumerate through the open Dockable Windows

    Following is a code-snippet I use to find the SplitContainer & Window Group of a given DockableWindow. You can easily moidify it not to return but to complete the traversal for finding windows. Also, you would require to iterate over the WindowGroup items to get all the unpinned windows as well.

    private WindowPropertyContainer GetWindowProperties(DockableWindow _window)
        {
          Debug.Assert(null != _window, "null == _window.");
          if (_window.DockSite != null && _window.DockSite.SplitContainers != null)
          {
            for (int i = 0; i < _window.DockSite.SplitContainers.Count; ++i)
            {
              SplitContainer splitContainer = _window.DockSite.SplitContainers;
              if (splitContainer != null)
              {
                WindowPropertyContainer container = this.GetWindowProperties(splitContainer, _window);
                if (!container.IsEmpty)
                {
                  return container;
                }
              }
            }
          }
          return WindowPropertyContainer.Empty;
        }

        private WindowPropertyContainer GetWindowProperties(SplitContainer splitContainer_, DockableWindow _window)
        {
          if (splitContainer_ != null)
          {
            for (int i = 0; i < splitContainer_.Children.Count; ++i)
            {
              FrameworkElement element = splitContainer_.Children;
              if (element != null)
              {
                if (element is WindowGroup)
                {
                  WindowGroup windowGroup = element as WindowGroup;
                  if (windowGroup != null)
                  {
                    if (windowGroup.SelectedWindow == _window || windowGroup.Items.Contains(_window))
                    {
                      return new WindowPropertyContainer(splitContainer_, windowGroup);
                    }
                  }
                }
                else if (element is SplitContainer)
                {
                  SplitContainer splitContainer = element as SplitContainer;
                  WindowPropertyContainer container = this.GetWindowProperties(splitContainer);
                  if (!container.IsEmpty)
                  {
                    return container;
                  }
                }
                else
                {
                  Debug.Fail("Unexpected type: " + element.GetType().FullName);
                }
              }
            }
          }
          return WindowPropertyContainer.Empty;
        }

     

Page 1 of 1 (2 items) | RSS
Copyright © 2008 Divelements Limited
Powered by Community Server (Commercial Edition), by Telligent Systems