ActivatableTabItem CreateTabItem(IViewCreationCommand viewCreator, IServiceProvider serviceProvider)
        {
            View view = viewCreator.CreateView(serviceProvider);

            view.Title = viewCreator.DisplayName;
            var item = new ActivatableTabItem()
            {
                ViewCreator = viewCreator,
                View        = view
            };

            ActivatableTabItem.SetTabItem(view, item);
            view.Site = item;
            item.SetBinding(ActivatableTabItem.ContentProperty, new Binding {
                Source = view, Path = new PropertyPath("ViewContent")
            });
            item.SetBinding(ActivatableTabItem.HeaderProperty, new Binding {
                Source = view, Path = new PropertyPath("Title")
            });
            AutomationProperties.SetAutomationId(item, viewCreator.RegisteredName);

            view.Closed += OnViewClosed;

            return(item);
        }
 public ViewSource(LayoutDefinition parent, int id, string slotName, IViewCreationCommand creator)
 {
     this.Parent      = parent;
     this.Id          = id;
     this.SlotName    = slotName;
     this.ViewCreator = creator;
     this.Title       = this.ViewCreator.DisplayName;
 }
 public ViewSource(LayoutDefinition parent, int id, string slotName, IViewCreationCommand creator)
 {
     this.Parent = parent;
     this.Id = id;
     this.SlotName = slotName;
     this.ViewCreator = creator;
     this.Title = this.ViewCreator.DisplayName;
 }
        public ActivatableTabItem CreateView(IViewCreationCommand viewCreator, IServiceProvider serviceProvider, TabNode destinationNode = null)
        {
            ActivatableTabItem item = CreateTabItem(viewCreator, serviceProvider);

            if (destinationNode == null)
            {
                destinationNode = this.activeTabNode;
            }

            AddItemToControl(item, destinationNode.TabControl, true);
            return(item);
        }
        public ViewSource AddViewSource(IViewCreationCommand creator, Slot targetSlot, Dock?dock)
        {
            ViewSource source;

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

            if (this.ViewSources.Count == 0)
            {
                source = new ViewSource(this, this.nextViewId++, this.SlotDefinition.Name, creator);
                this.ViewSources.Add(source);

                var handler = this.PlaceholderModified;

                // Note that this is the only place where this event could fire (going from 0 to 1 sources)
                if (this.IsNewPlaceholder && handler != null)
                {
                    handler(this, EventArgs.Empty);
                }

                return(source);
            }

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

            Slot newSlot = targetSlot;

            if (dock.HasValue)
            {
                newSlot = SplitSlot(targetSlot, dock.Value);
            }

            source = new ViewSource(this, this.nextViewId++, newSlot.Name, creator);
            this.ViewSources.Add(source);

            RecomputeViewShortcutKeys();
            return(source);
        }
Beispiel #6
0
        bool IsViewAffinitized(IViewCreationCommand viewCommand, DocumentCategory category)
        {
            if (viewCommand.IsInternalOnly && !this.ShowInternalViews)
            {
                // No internal views...
                return(false);
            }

            if (viewCommand.DocumentFactoryAffinities.Count() == 0)
            {
                // This view has no declared affinity, so it can go anywhere
                return(true);
            }

            if ((category == null) || (category.DocumentFactoryName == null))
            {
                // This view has declared affinity(ies), so it can't go in the 'Any' layouts
                return(false);
            }

            // This view is affinitized if it has declared affinity with the active document factory
            return(viewCommand.DocumentFactoryAffinities.Contains(category.DocumentFactoryName));
        }
 public ActivatableTabItem FindView(IViewCreationCommand creator)
 {
     return(FindViewInTabNode(this.rootTabNode, i => i.ViewCreator == creator));
 }
        public ViewSource AddViewSource(IViewCreationCommand creator, Slot targetSlot, Dock? dock)
        {
            ViewSource source;

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

            if (this.ViewSources.Count == 0)
            {
                source = new ViewSource(this, this.nextViewId++, this.SlotDefinition.Name, creator);
                this.ViewSources.Add(source);

                var handler = this.PlaceholderModified;

                // Note that this is the only place where this event could fire (going from 0 to 1 sources)
                if (this.IsNewPlaceholder && handler != null)
                {
                    handler(this, EventArgs.Empty);
                }

                return source;
            }

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

            Slot newSlot = targetSlot;

            if (dock.HasValue)
            {
                newSlot = SplitSlot(targetSlot, dock.Value);
            }

            source = new ViewSource(this, this.nextViewId++, newSlot.Name, creator);
            this.ViewSources.Add(source);

            RecomputeViewShortcutKeys();
            return source;
        }
        bool IsViewAffinitized(IViewCreationCommand viewCommand, DocumentCategory category)
        {
            if (viewCommand.IsInternalOnly && !this.ShowInternalViews)
            {
                // No internal views...
                return false;
            }

            if (viewCommand.DocumentFactoryAffinities.Count() == 0)
            {
                // This view has no declared affinity, so it can go anywhere
                return true;
            }

            if ((category == null) || (category.DocumentFactoryName == null))
            {
                // This view has declared affinity(ies), so it can't go in the 'Any' layouts
                return false;
            }

            // This view is affinitized if it has declared affinity with the active document factory
            return viewCommand.DocumentFactoryAffinities.Contains(category.DocumentFactoryName);
        }
 public ActivatableTabItem FindView(IViewCreationCommand creator)
 {
     return FindViewInTabNode(this.rootTabNode, i => i.ViewCreator == creator);
 }
        public ActivatableTabItem CreateView(IViewCreationCommand viewCreator, IServiceProvider serviceProvider, TabNode destinationNode = null)
        {
            ActivatableTabItem item = CreateTabItem(viewCreator, serviceProvider);

            if (destinationNode == null)
            {
                destinationNode = this.activeTabNode;
            }

            AddItemToControl(item, destinationNode.TabControl, true);
            return item;
        }
        ActivatableTabItem CreateTabItem(IViewCreationCommand viewCreator, IServiceProvider serviceProvider)
        {
            View view = viewCreator.CreateView(serviceProvider);

            view.Title = viewCreator.DisplayName;
            var item = new ActivatableTabItem()
            {
                ViewCreator = viewCreator,
                View = view
            };

            ActivatableTabItem.SetTabItem(view, item);
            view.Site = item;
            item.SetBinding(ActivatableTabItem.ContentProperty, new Binding { Source = view, Path = new PropertyPath("ViewContent") });
            item.SetBinding(ActivatableTabItem.HeaderProperty, new Binding { Source = view, Path = new PropertyPath("Title") });
            AutomationProperties.SetAutomationId(item, viewCreator.RegisteredName);

            view.Closed += OnViewClosed;

            return item;
        }