Ejemplo n.º 1
0
        /// <summary>
        /// Get the available space for a row or column based upon padding, margin, the number of elements and their current size.
        /// </summary>
        /// <param name="index">The index of the row or column.</param>
        /// <param name="structure">Whether it is a row or column we are checking.</param>
        /// <param name="sizeStyle">Whether we want to distribute the available size evenly or to the cell first in line.</param>
        /// <returns>The amount of 'free' space available for the given row or column.</returns>
        private float GetAvailableSpace(int index, LayoutStructure structure, LayoutSizeStyle sizeStyle)
        {
            //Whether to check a row or column.
            switch (structure)
            {
                case (LayoutStructure.Row):
                    {
                        //The space available.
                        float available = AvailableWidth - ((RowCount(index) - 1) * _Margin);

                        //Subtract the width of all cells.
                        if (sizeStyle == LayoutSizeStyle.FirstInLine)
                        {
                            for (int x = 0; x < _Grid.GetLength(0); x++) { if (_Grid[x, index] != null) { available -= _Grid[x, index].GoalWidth; } }
                        }

                        //Return the available space.
                        return available;
                    }
                case (LayoutStructure.Column):
                    {
                        //The space available.
                        float available = AvailableHeight - ((ColumnCount(index) - 1) * _Margin);

                        //Subtract the height of all cells.
                        if (sizeStyle == LayoutSizeStyle.FirstInLine)
                        {
                            for (int y = 0; y < _Grid.GetLength(1); y++) { if (_Grid[index, y] != null) { available -= _Grid[index, y].GoalHeight; } }
                        }

                        //Return the available space.
                        return available;
                    }
                default: { return 0; }
            }
        }
Ejemplo n.º 2
0
        public string GetCurrentLayout(string name)
        {
            LayoutStructure layoutStructure = LayoutAnalayzer.GetLayoutStructure(name);

            return(SerializeStructure(layoutStructure));
        }
        public static bool RestoreLayout(TabablzControl rootTabControl, LayoutStructure layoutStructure,
                                         string language, string primary = null, string accent = null, bool?darkMode = null)
        {
            try
            {
                if (!ApplicationService.IsStarting)
                {
                    LanguageHelper.ChangeLanguage(language);
                    DepopulateTabControl(ref rootTabControl);
                }

                SetColors(primary, accent, darkMode);

                VerifyWindowPositions(layoutStructure);

                foreach (var layoutStructureWindow in layoutStructure.Windows)
                {
                    TabablzControl tabControl;
                    Window         currentWindow = null;
                    if (layoutStructure.Windows.First() == layoutStructureWindow)
                    {
                        tabControl = rootTabControl;
                        var window = Window.GetWindow(rootTabControl);
                        window.Left        = layoutStructureWindow.Left;
                        window.Top         = layoutStructureWindow.Top;
                        window.Width       = layoutStructureWindow.Width;
                        window.Height      = layoutStructureWindow.Height;
                        window.Topmost     = layoutStructureWindow.Topmost;
                        window.WindowState = layoutStructureWindow.WindowState;
                    }
                    else
                    {
                        var newTabHost = IoC.Get <IInterTabClient>().GetNewHost(rootTabControl.InterTabController.InterTabClient, null, rootTabControl);
                        tabControl                = newTabHost.TabablzControl;
                        currentWindow             = newTabHost.Container;
                        currentWindow.Left        = layoutStructureWindow.Left;
                        currentWindow.Top         = layoutStructureWindow.Top;
                        currentWindow.Width       = layoutStructureWindow.Width;
                        currentWindow.Height      = layoutStructureWindow.Height;
                        currentWindow.Topmost     = layoutStructureWindow.Topmost;
                        currentWindow.WindowState = layoutStructureWindow.WindowState;
                        currentWindow.Show();
                    }

                    var layoutStructureTabSets = layoutStructureWindow.TabSets.ToDictionary(tabSet => tabSet.Id);

                    if (layoutStructureWindow.Branches.Any())
                    {
                        var branchIndex = layoutStructureWindow.Branches.ToDictionary(b => b.Id);
                        var rootBranch  = GetRoot(branchIndex);

                        //do the nasty recursion to build the layout, populate the tabs after, keep it simple...
                        foreach (var tuple in BuildLayout(tabControl, rootBranch, branchIndex))
                        {
                            PopulateTabControl(tuple.Item2, layoutStructureTabSets[tuple.Item1]);
                        }
                    }
                    else
                    {
                        var layoutStructureTabSet = layoutStructureTabSets.Values.FirstOrDefault();
                        if (layoutStructureTabSet != null)
                        {
                            PopulateTabControl(tabControl, layoutStructureTabSet);
                        }
                    }
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
 public static LayoutStructure AddWindow(this LayoutStructure layoutStructure)
 {
     return(AddWindow(layoutStructure, 0, 0, 0, 0));
 }
Ejemplo n.º 5
0
 public static LayoutStructure AddWindow(this LayoutStructure layoutStructure, double width, double height)
 {
     return(AddWindow(layoutStructure, width, height, 0, 0));
 }
 public abstract void Preview(LayoutStructure layout, Parameters parameters);