private static void PopulateTabControl(TabablzControl tabablzControl, LayoutStructureTabSet layoutStructureTabSet)
        {
            bool wasAnyTabSelected = false;

            foreach (var tabItem in layoutStructureTabSet.TabItems)
            {
                var view = ViewLocator.LocateForModelType(tabItem.ViewModelType, null, null);
                var vm   = typeof(IoC).GetMethod("Get").MakeGenericMethod(tabItem.ViewModelType).Invoke(tabablzControl, new Object[] { null });

                ViewModelBinder.Bind(vm, view, null);
                (tabablzControl.DataContext as ShellViewModel).ActivateItem(vm as IScreen);

                tabablzControl.AddToSource(view);

                if (tabItem.Id == layoutStructureTabSet.SelectedTabItemId)
                {
                    tabablzControl.Dispatcher.BeginInvoke(new System.Action(() =>
                    {
                        tabablzControl.SetCurrentValue(Selector.SelectedItemProperty, view);
                    }), DispatcherPriority.Loaded);
                    wasAnyTabSelected = true;
                }
            }

            if (!wasAnyTabSelected && tabablzControl.Items.Count != 0)
            {
                tabablzControl.Dispatcher.BeginInvoke(new System.Action(() =>
                {
                    tabablzControl.SetCurrentValue(Selector.SelectedItemProperty, tabablzControl.Items.OfType <System.Windows.Controls.UserControl>().First());
                }), DispatcherPriority.Loaded);
                wasAnyTabSelected = true;
            }
        }
Ejemplo n.º 2
0
        public TabablzControl GetNew(TabablzControl source)
        {
            var tabablzControl = new TabablzControl {
                DataContext = source.DataContext
            };

            Clone(source, tabablzControl);

            var newInterTabController = new InterTabController
            {
                Partition = source.InterTabController.Partition
            };

            Clone(source.InterTabController, newInterTabController);
            tabablzControl.SetCurrentValue(TabablzControl.InterTabControllerProperty, newInterTabController);
            return(tabablzControl);
        }
        private static IEnumerable <Tuple <Guid, TabablzControl> > BuildLayout(
            TabablzControl intoTabablzControl,
            LayoutStructureBranch layoutStructureBranch,
            IDictionary <Guid, LayoutStructureBranch> layoutStructureBranchIndex)
        {
            var newSiblingTabablzControl = new TabablzControl();
            var branchResult             = Layout.Branch(intoTabablzControl, newSiblingTabablzControl, layoutStructureBranch.Orientation, false, layoutStructureBranch.Ratio);

            var newInterTabController = new InterTabController
            {
                Partition      = intoTabablzControl.InterTabController.Partition,
                InterTabClient = intoTabablzControl.InterTabController.InterTabClient
            };

            CaliburnInterLayoutClient.Clone(intoTabablzControl.InterTabController, newInterTabController);
            newSiblingTabablzControl.SetCurrentValue(TabablzControl.InterTabControllerProperty, newInterTabController);

            if (layoutStructureBranch.ChildFirstBranchId.HasValue)
            {
                var firstChildBranch = layoutStructureBranchIndex[layoutStructureBranch.ChildFirstBranchId.Value];
                foreach (var tuple in BuildLayout(intoTabablzControl, firstChildBranch, layoutStructureBranchIndex))
                {
                    yield return(tuple);
                }
            }
            else if (layoutStructureBranch.ChildFirstTabSetId.HasValue)
            {
                SetTabSetId(intoTabablzControl, layoutStructureBranch.ChildFirstTabSetId.Value);
                yield return(new Tuple <Guid, TabablzControl>(layoutStructureBranch.ChildFirstTabSetId.Value, intoTabablzControl));
            }

            if (layoutStructureBranch.ChildSecondBranchId.HasValue)
            {
                var secondChildBranch = layoutStructureBranchIndex[layoutStructureBranch.ChildSecondBranchId.Value];
                foreach (var tuple in BuildLayout(branchResult.TabablzControl, secondChildBranch, layoutStructureBranchIndex))
                {
                    yield return(tuple);
                }
            }
            else if (layoutStructureBranch.ChildSecondTabSetId.HasValue)
            {
                SetTabSetId(newSiblingTabablzControl, layoutStructureBranch.ChildSecondTabSetId.Value);
                yield return(new Tuple <Guid, TabablzControl>(layoutStructureBranch.ChildSecondTabSetId.Value, newSiblingTabablzControl));
            }
        }
Ejemplo n.º 4
0
        private void PopulateTabControl(TabablzControl tabablzControl, LayoutStructureTabSet layoutStructureTabSet)
        {
            foreach (var tabItem in layoutStructureTabSet.TabItems)
            {
                var featureFactory         = _featureRegistry[tabItem.FeatureId];
                var tabContentLifetimeHost = featureFactory.RestoreTabContent(tabItem);
                var tabContentContainer    = new TabItemContainer(tabItem.Id, featureFactory.FeatureId, tabContentLifetimeHost, featureFactory);
                tabablzControl.AddToSource(tabContentContainer);

                if (tabContentContainer.TabId == layoutStructureTabSet.SelectedTabItemId)
                {
                    tabablzControl.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        tabablzControl.SetCurrentValue(Selector.SelectedItemProperty, tabContentContainer);
                    }), DispatcherPriority.Loaded);
                }
            }
        }
        public INewTabHost <UIElement> GetNewHost(object partition, TabablzControl source)
        {
            TabablzControl tabablzControl1 = new TabablzControl();
            object         dataContext     = source.DataContext;

            tabablzControl1.DataContext = dataContext;
            TabablzControl tabablzControl2 = tabablzControl1;

            DefaultInterLayoutClientEx.Clone((DependencyObject)source, (DependencyObject)tabablzControl2);
            InterTabController interTabController = new InterTabController()
            {
                Partition = source.InterTabController.Partition
            };

            DefaultInterLayoutClientEx.Clone((DependencyObject)source.InterTabController, (DependencyObject)interTabController);
            tabablzControl2.SetCurrentValue(TabablzControl.InterTabControllerProperty, (object)interTabController);
            return((INewTabHost <UIElement>) new NewTabHost <UIElement>((UIElement)tabablzControl2, tabablzControl2));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a split in a layout, at the location of a specified <see cref="TabablzControl"/>.
        /// </summary>
        /// <para></para>
        /// <param name="tabablzControl">Tab control to be split.</param>
        /// <param name="newSiblingTabablzControl">New sibling tab control (otherwise <see cref="Layout.BranchTemplate"/> will be used).</param>
        /// <param name="orientation">Direction of split.</param>
        /// <param name="makeCurrentSecond">Set to <c>true</c> to make the current tab control push into the right hand or bottom of the split.</param>
        /// <param name="firstItemProportion">Sets the proportion of the first tab control, with 0.5 being 50% of available space.</param>
        /// <remarks>The tab control to be split must be hosted in a layout control. </remarks>
        public static BranchResult Branch(TabablzControl tabablzControl, TabablzControl?newSiblingTabablzControl, Orientation orientation, bool makeCurrentSecond,
                                          double firstItemProportion)
        {
            if (firstItemProportion < 0.0 || firstItemProportion > 1.0)
            {
                throw new ArgumentOutOfRangeException("firstItemProportion", "Must be >= 0.0 and <= 1.0");
            }

            var locationReport = Find(tabablzControl);

            Action <Branch> applier;
            object          existingContent;

            if (!locationReport.IsLeaf)
            {
                existingContent = locationReport.RootLayout.Content;
                applier         = branch => locationReport.RootLayout.Content = branch;
            }
            else if (!locationReport.IsSecondLeaf)
            {
                existingContent = locationReport.ParentBranch.FirstItem;
                applier         = branch => locationReport.ParentBranch.FirstItem = branch;
            }
            else
            {
                existingContent = locationReport.ParentBranch.SecondItem;
                applier         = branch => locationReport.ParentBranch.SecondItem = branch;
            }

            var selectedItem = tabablzControl.SelectedItem;
            var branchResult = Branch(orientation, firstItemProportion, makeCurrentSecond, locationReport.RootLayout.BranchTemplate, newSiblingTabablzControl, existingContent, applier);

            tabablzControl.SelectedItem = selectedItem;
            tabablzControl.Dispatcher.BeginInvoke(new Action(() =>
            {
                tabablzControl.SetCurrentValue(Selector.SelectedItemProperty, selectedItem);
                MarkTopLeftItem(locationReport.RootLayout);
            }),
                                                  DispatcherPriority.Loaded);

            return(branchResult);
        }
        public INewTabHost <UIElement> GetNewHost(object partition, TabablzControl source)
        {
            var tabablzControl = new TabablzControl {
                DataContext = source.DataContext
            };

            Clone(source, tabablzControl);

            if (source.InterTabController == null)
            {
                throw new InvalidOperationException("Source tab does not have an InterTabCOntroller set.  Ensure this is set on initial, and subsequently generated tab controls.");
            }

            var newInterTabController = new InterTabController
            {
                Partition = source.InterTabController.Partition
            };

            Clone(source.InterTabController, newInterTabController);
            tabablzControl.SetCurrentValue(TabablzControl.InterTabControllerProperty, newInterTabController);

            return(new NewTabHost <UIElement>(tabablzControl, tabablzControl));
        }
Ejemplo n.º 8
0
        public INewTabHost <UIElement> GetNewHost(object partition, TabablzControl source)
        {
            TabControlVM   vm = new TabControlVM();
            InterTabWindow mw = (InterTabWindow)Window.GetWindow(source);

            mw.TabWindowVM.TabControlVMs.Add(vm);
            var tabablzControl = new TabablzControl {
                DataContext = vm
            };

            tabablzControl.ItemsSource = vm.TabPanelVMs;

            Clone(source, tabablzControl);

            var newInterTabController = new InterTabController
            {
                Partition = source.InterTabController.Partition
            };

            Clone(source.InterTabController, newInterTabController);
            tabablzControl.SetCurrentValue(TabablzControl.InterTabControllerProperty, newInterTabController);

            return(new NewTabHost <UIElement>(tabablzControl, tabablzControl));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a split in a layout, at the location of a specified <see cref="TabablzControl"/>.
        /// </summary>
        /// <para></para>
        /// <param name="tabablzControl">Tab control to be split.</param>
        /// <param name="orientation">Direction of split.</param>
        /// <param name="makeSecond">Set to <c>true</c> to make the current tab control push into the right hand or bottom of the split.</param>
        /// <param name="firstItemProportion">Sets the proportion of the first tab control, with 0.5 being 50% of available space.</param>
        /// <remarks>The tab control to be split must be hosted in a layout control.</remarks>
        public static BranchResult Branch(TabablzControl tabablzControl, Orientation orientation, bool makeSecond, double firstItemProportion)
        {
            if (firstItemProportion < 0.0 || firstItemProportion > 1.0) throw new ArgumentOutOfRangeException("firstItemProportion", "Must be >= 0.0 and <= 1.0");

            var locationReport = Find(tabablzControl);
            
            Action<Branch> applier;
            object existingContent;
            if (!locationReport.IsLeaf)
            {
                existingContent = locationReport.RootLayout.Content;
                applier = branch => locationReport.RootLayout.Content = branch;
            }
            else if (!locationReport.IsSecondLeaf)
            {
                existingContent = locationReport.ParentBranch.FirstItem;
                applier = branch => locationReport.ParentBranch.FirstItem = branch;
            }
            else
            {
                existingContent = locationReport.ParentBranch.SecondItem;
                applier = branch => locationReport.ParentBranch.SecondItem = branch;
            }            

            var selectedItem = tabablzControl.SelectedItem;
            var branchResult = Branch(orientation, firstItemProportion, makeSecond, locationReport.RootLayout.BranchTemplate, existingContent, applier);
            tabablzControl.SelectedItem = selectedItem;
            tabablzControl.Dispatcher.BeginInvoke(new Action(() =>
                tabablzControl.SetCurrentValue(Selector.SelectedItemProperty, selectedItem)),
                DispatcherPriority.Loaded);

            return branchResult;
        }