Example #1
0
            public static TabGroupPane FindTabGroupPane(XamDockManager dockManager)
            {
                TabGroupPane tabs;

                dockManager.TryFindChild(out tabs);

                return(tabs);
            }
        protected override void OnAttach()
        {
            _parentDockManager = XamDockManager.GetDockManager(_hostControl);
            if (_parentDockManager != null)
            {
                _parentDockManager.ActivePaneChanged += DockManager_ActivePaneChanged;
            }

            Region.ActiveViews.CollectionChanged += ActiveViews_CollectionChanged;
        }
Example #3
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);
            if (!string.IsNullOrEmpty(Settings.Default.Layout))
            {
                this.SetPlacement(Settings.Default.Layout);
            }

            if (!string.IsNullOrEmpty(Settings.Default.Docking))
            {
                XamDockManager.LoadLayout(Settings.Default.Docking);
            }
        }
Example #4
0
            static SplitPane FindSplitPaneWithLocationOrCreate(XamDockManager dockManager, PaneLocation location)
            {
                SplitPane pane = FindSplitPaneWithLocation(dockManager, location);

                if (pane != null)
                {
                    return(pane);
                }

                pane = new SplitPane();
                XamDockManager.SetInitialLocation(pane, location.ToInitialPaneLocation());

                return(pane);
            }
        ContentPane GetContentPaneFromFromViewModel(object viewModel)
        {
            var panes = XamDockManager.GetDockManager(_hostControl).GetPanes(PaneNavigationOrder.VisibleOrder);

            foreach (ContentPane contentPane in panes)
            {
                if (contentPane.DataContext == viewModel)
                {
                    return(contentPane);
                }
            }

            return(null);
        }
Example #6
0
        public void ShowFloatingWindow(object viewModel, object context = null, bool selectWhenShown = true)
        {
            ContentPane dockableWindow = CreateDockable(viewModel, context);
            SplitPane   pane           = new SplitPane();

            XamDockManager.SetInitialLocation(pane, InitialPaneLocation.DockableFloating);

            pane.Panes.Add(dockableWindow);
            DockManager.Panes.Add(pane);

            if (selectWhenShown)
            {
                dockableWindow.Activate();
            }
        }
Example #7
0
        private ContentPane GetSiblingDocument()
        {
            DocumentContentHost dch = _target as DocumentContentHost;

            if (dch == null)
            {
                return(null);
            }

            if (null != dch.ActiveDocument)
            {
                return(dch.ActiveDocument);
            }

            XamDockManager dm = XamDockManager.GetDockManager(dch);

            if (dm == null)
            {
                return(null);
            }

            ContentPane firstDocument = null;

            foreach (ContentPane cp in dm.GetPanes(PaneNavigationOrder.VisibleOrder))
            {
                if (cp.PaneLocation != PaneLocation.Document)
                {
                    continue;
                }

                if (firstDocument == null)
                {
                    firstDocument = cp;
                }

                if (cp.Visibility != Visibility.Visible)
                {
                    continue;
                }

                return(cp);
            }

            return(firstDocument);
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="xamDockManager">A <see cref="XamDockManager"/> instance.</param>
        public XamDockManagerProxy(ContentControl xamDockManager)
        {
            // The 'xamDockManager' argument is of type ContentControl because the
            // main NCAL assembly cannot reference the Infragistics assemblies.

            _xamDockManager = xamDockManager as XamDockManager;

            if (_xamDockManager == null)
                throw new ArgumentException(Strings.Docking_Exception_XamDockManagerProxyArgument);

            _splitPaneProxies = new List<SplitPaneProxy>();

            // Create proxies for any pre-existing splitpanes.
            foreach (SplitPane existingPane in _xamDockManager.Panes)
                _splitPaneProxies.Add(new SplitPaneProxy(existingPane));

            this.HookEvents(true);
        }
Example #9
0
        private void OnViewsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, IRegion region, TabGroupPane regionTarget)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                //we want to add them behind any previous views that may have been manually declare in XAML or injected
                int startIndex = e.NewStartingIndex;
                foreach (object newItem in e.NewItems)
                {
                    ContentPane contentPane = PrepareContainerForItem(newItem, region);

                    if (regionTarget.Items.Count != startIndex)
                    {
                        startIndex = 0;
                    }

                    //we must make sure we bring the TabGroupPane into view.  If we don't a System.StackOverflowException will occur in
                    //UIAutomationProvider.dll if trying to add a ContentPane to a TabGroupPane that is not in view.
                    //This is most common when using nested TabGroupPane regions. If you don't this, you can comment it out.
                    regionTarget.BringIntoView();

                    regionTarget.Items.Insert(startIndex, contentPane);
                    regionTarget.Items.MoveCurrentTo(contentPane);
                    regionTarget.SelectedIndex = startIndex;
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                if (regionTarget.Items.Count == 0)
                {
                    return;
                }

                IEnumerable <ContentPane> contentPanes = XamDockManager.GetDockManager(regionTarget).GetPanes(PaneNavigationOrder.VisibleOrder);
                foreach (ContentPane contentPane in contentPanes)
                {
                    if (e.OldItems.Contains(contentPane) || e.OldItems.Contains(contentPane.Content))
                    {
                        contentPane.ExecuteCommand(ContentPaneCommands.Close);
                    }
                }
            }
        }
Example #10
0
        /// <summary>
        /// Gets the dock site associated to the window.
        /// </summary>
        /// <param name="window">The window.</param>
        /// <returns>The retrieved dock site.</returns>
        /// <exception cref="InvalidOperationException">No dock site could be retrieved.</exception>
        private XamDockManager GetDockingManager(Window window = null)
        {
            XamDockManager dockSite = _dockManager;

            if (dockSite == null)
            {
                Window parentWindow = GetParentWindow(window);

                if (parentWindow != null)
                {
                    dockSite = parentWindow.FindChild <XamDockManager>();
                }
            }

            if (dockSite == null)
            {
                throw new InvalidOperationException("Unable to retrieve a docking manager");
            }

            return(dockSite);
        }
Example #11
0
        private void MainWindow_OnClosing(object sender, CancelEventArgs e)
        {
            if (!(DataContext is MainWindowViewModel model))
            {
                return;
            }

            e.Cancel = !model.PromptModified();
            if (e.Cancel)
            {
                return;
            }

            Settings.Default.Layout = this.GetPlacement();

            model.SaveSettings();
            MemoryStream ms = new MemoryStream();

            XamDockManager.SaveLayout(ms);
            Settings.Default.Docking = Encoding.UTF8.GetString(ms.GetBuffer(), 0, (int)ms.Position);
            ms.Dispose();

            Settings.Default.Save();
        }
        public XamDockManagerActiveAwareBehavior(XamDockManager xamDockManager, IRegion region)
        {
            _regionWeakReference = new WeakReference(region);

                _xamDockManagerWeakReference = new WeakReference(xamDockManager);
        }
Example #13
0
 public XamDockManagerDockAwareWindowManager(Window window = null, XamDockManager dockManager = null)
 {
     _window      = window;
     _dockManager = dockManager;
 }
 static SplitPane FindSplitPaneWithLocation(XamDockManager dockManager, PaneLocation location)
 {
     return dockManager.Panes.FirstOrDefault(p => GetSplitPaneLocation(p) == location);
 }
 public static SplitPane FindSplitPaneWithLocationOrCreate(XamDockManager dockManager, InitialPaneLocation location)
 {
     return FindSplitPaneWithLocationOrCreate(dockManager, location.ToPaneLocation());
 }
Example #16
0
 public static SplitPane FindSplitPaneWithLocationOrCreate(XamDockManager dockManager, InitialPaneLocation location)
 {
     return(FindSplitPaneWithLocationOrCreate(dockManager, location.ToPaneLocation()));
 }
Example #17
0
 static SplitPane FindSplitPaneWithLocation(XamDockManager dockManager, PaneLocation location)
 {
     return(dockManager.Panes.FirstOrDefault(p => GetSplitPaneLocation(p) == location));
 }
Example #18
0
 static PaneLocation GetSplitPaneLocation(SplitPane pane)
 {
     return(XamDockManager.GetPaneLocation(pane));
 }
Example #19
0
        ContentPane GetContentPaneFromFromViewModel(object viewModel)
        {
            var panes = XamDockManager.GetDockManager(_hostControl).GetPanes(PaneNavigationOrder.VisibleOrder);

            return(panes.FirstOrDefault(contentPane => contentPane.DataContext == viewModel));
        }
            static SplitPane FindSplitPaneWithLocationOrCreate(XamDockManager dockManager, PaneLocation location)
            {
                SplitPane pane = FindSplitPaneWithLocation(dockManager, location);

                if(pane != null)
                    return pane;

                pane = new SplitPane();
                XamDockManager.SetInitialLocation(pane, location.ToInitialPaneLocation());

                return pane;
            }
 public XamDockManagerDockAwareWindowManager(Window window = null, XamDockManager dockManager = null)
 {
     _window = window;
     _dockManager = dockManager;
 }
            public static TabGroupPane FindTabGroupPane(XamDockManager dockManager)
            {
                TabGroupPane tabs;

                dockManager.TryFindChild(out tabs);

                return tabs;
            }