Пример #1
0
        /// <summary>
        /// Gets the state of a branch
        /// </summary>
        /// <typeparam name="TTabModel">The type of tab model</typeparam>
        /// <typeparam name="TTabViewModel">The type of tab view model, currently displayed in the app.</typeparam>
        /// <param name="branchVisitor">The branch to be inspected</param>
        /// <param name="tabContentModelConverter">The converter that transforms tab view models to models</param>
        /// <returns>The read state of the branch</returns>
        private static BranchState <TTabModel> GetBranchState <TTabModel, TTabViewModel>(BranchAccessor branchVisitor, Func <TTabViewModel, TTabModel> tabContentModelConverter)
        {
            BranchItemState <TTabModel> firstState  = null;
            BranchItemState <TTabModel> secondState = null;

            if (branchVisitor.FirstItemBranchAccessor != null)
            {
                firstState = new BranchItemState <TTabModel>(GetBranchState(branchVisitor.FirstItemBranchAccessor, tabContentModelConverter), null);
            }
            else
            {
                firstState = new BranchItemState <TTabModel>(null, GetTabSetState(branchVisitor.FirstItemTabablzControl, tabContentModelConverter));
            }

            if (branchVisitor.SecondItemBranchAccessor != null)
            {
                secondState = new BranchItemState <TTabModel>(GetBranchState(branchVisitor.SecondItemBranchAccessor, tabContentModelConverter), null);
            }
            else
            {
                secondState = new BranchItemState <TTabModel>(null, GetTabSetState(branchVisitor.SecondItemTabablzControl, tabContentModelConverter));
            }

            return(new BranchState <TTabModel>(
                       firstState,
                       secondState,
                       branchVisitor.Branch.Orientation,
                       branchVisitor.Branch.GetFirstProportion()));
        }
Пример #2
0
 /// <summary> The constructor </summary>
 /// <param name="firstChild">  The first child </param>
 /// <param name="secondChild"> The second child </param>
 /// <param name="orientation"> The split orientation </param>
 /// <param name="ratio">       The split ratio </param>
 public BranchState(BranchItemState <TTabModel> firstChild, BranchItemState <TTabModel> secondChild,
                    Orientation orientation, double ratio)
 {
     this.FirstChild  = firstChild;
     this.SecondChild = secondChild;
     this.Orientation = orientation;
     this.Ratio       = ratio;
 }
Пример #3
0
        /// <summary>
        /// Gets the state of a single window
        /// </summary>
        /// <typeparam name="TTabModel">The type of tab model</typeparam>
        /// <typeparam name="TTabViewModel">The type of tab view model, currently displayed in the app.</typeparam>
        /// <param name="layout">The layout to be inspected</param>
        /// <param name="tabContentModelConverter">The converter that transforms tab view models to models</param>
        /// <returns>The state of the specified window</returns>
        private static LayoutWindowState <TTabModel> GetLayoutState <TTabModel, TTabViewModel>(Layout layout, Func <TTabViewModel, TTabModel> tabContentModelConverter)
        {
            var window = Window.GetWindow(layout);

            if (window == null)
            {
                throw new InvalidOperationException("The layout is not bound to any window");
            }

            var layoutAccessor = layout.Query();

            BranchItemState <TTabModel> root = null;

            layoutAccessor.Visit(
                branchVisitor => root  = new BranchItemState <TTabModel>(GetBranchState(branchVisitor, tabContentModelConverter), null),
                tabablzControl => root = new BranchItemState <TTabModel>(null, GetTabSetState(tabablzControl, tabContentModelConverter))
                );

            return(new LayoutWindowState <TTabModel>(window.Left, window.Top, window.Width, window.Height, window.WindowState, root));
        }
Пример #4
0
 /// <summary>
 /// The constructor
 /// </summary>
 /// <param name="x">The X position of the window</param>
 /// <param name="y">The Y position of the window</param>
 /// <param name="width">The window width</param>
 /// <param name="height">The window height</param>
 /// <param name="windowState">The window state</param>
 /// <param name="child">The root of this layout</param>
 public LayoutWindowState(double x, double y, double width, double height, WindowState windowState, BranchItemState <TTabModel> child)
 {
     this.X           = x;
     this.Y           = y;
     this.Width       = width;
     this.Height      = height;
     this.WindowState = windowState;
     this.Child       = child;
 }
Пример #5
0
 /// <summary>
 /// Restores the state of a branch item
 /// </summary>
 /// <typeparam name="TTabModel">The type of tab model</typeparam>
 /// <typeparam name="TTabViewModel">The type of tab view model to be displayed in the app.</typeparam>
 /// <param name="tabablzControl">The control in which to restore the items</param>
 /// <param name="branchItemState">The state of the branch item to be restored</param>
 /// <param name="viewModelFactory">The function that creates the view model based on a model</param>
 private static void RestoreBranchItemState <TTabModel, TTabViewModel>(TabablzControl tabablzControl, BranchItemState <TTabModel> branchItemState, Func <TTabModel, TTabViewModel> viewModelFactory)
 {
     if (branchItemState.ItemAsTabSet != null)
     {
         RestoreTabSetState(tabablzControl, branchItemState.ItemAsTabSet, viewModelFactory);
     }
     else if (branchItemState.ItemAsBranch != null)
     {
         RestoreBranchState(tabablzControl, branchItemState.ItemAsBranch, viewModelFactory);
     }
 }