Exemplo n.º 1
0
        private BaseDockableContent GetDockable(object rootModel, object context, DockArea dockArea, bool isDocument = false)
        {
            var docmanager = GetDockingManager();

            var existingView = docmanager.DockableContents.FirstOrDefault(dc => dc.Title == (rootModel as ViewModelBase).DisplayName) as BaseDockableContent;

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

            var view = ViewLocator.LocateForModel(rootModel, null, context);

            ViewModelBinder.Bind(rootModel, view, context);
            var dockableView = new BaseDockableContent(rootModel, view, dockArea, isDocument);

            //set the display name (tab title)
            var haveDisplayName = rootModel as IHaveDisplayName;

            //if (haveDisplayName != null && !ConventionManager.HasBinding(dockableView, ManagedContent.TitleProperty))
            //    dockableView.SetBinding(ManagedContent.TitleProperty, "DisplayName");
            if (haveDisplayName != null && !ConventionManager.HasBinding(dockableView, ManagedContent.TitleProperty))
            {
                dockableView.Title = (rootModel as IHaveDisplayName).DisplayName;
            }

            new DockableContentConductor(rootModel, dockableView);
            return(dockableView);
        }
Exemplo n.º 2
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "DockableContentConductor" /> class.
        /// </summary>
        /// <param name = "viewModel">The view model.</param>
        /// <param name = "view">The view.</param>
        public DockableContentConductor(object viewModel, BaseDockableContent view)
        {
            m_ViewModel = viewModel;
            m_View      = view;

            view.IsActiveContentChanged += (sender, args) =>
            {
                var baseDockableContent = sender as BaseDockableContent;
                if (baseDockableContent != null && baseDockableContent.IsActiveContent)
                {
                    var activatable = baseDockableContent.ViewModel as IActivate;
                    if (activatable != null && !activatable.IsActive)
                    {
                        CursorHelper.ExecuteWithWaitCursor(activatable.Activate);
                    }
                }
            };

            var deactivatable = viewModel as IDeactivate;

            if (deactivatable != null)
            {
                view.Closed += OnClosed;
                deactivatable.Deactivated += OnDeactivated;
            }

            var guard = viewModel as IGuardClose;

            if (guard != null)
            {
                view.Closing += OnClosing;
            }
        }
Exemplo n.º 3
0
        private void ShowWindowInLocation(DockArea dockArea, DockingManager dockingManager, BaseDockableContent dockableContent)
        {
            if (dockableContent == null)
            {
                return;
            }

            //CheckAreas(dockingManager);

            if (_documentArea == DockArea.Master)
            {
                _documentArea = dockArea;
            }

            if (_documentArea == dockArea)
            {
                dockableContent.ShowAsDocument(dockingManager);
            }
            else
            {
                dockableContent.Show(dockingManager, AnchorStyle.Bottom);
            }

            if (!_openMenuItems.Contains(dockArea))
            {
                _openMenuItems.Add(dockArea);
            }

            // TODO
            //var eventAggregator = IoC.Get<IEventAggregator>();
            //eventAggregator.PublishOnUIThread(new OpenMenuItemsChangedEvent(_openMenuItems));
        }