private void LoadHierarchies(OlapControl grid, List <Measure> assignedMeasures)
        {
            if (Hierarchies == null)
            {
                return;
            }

            foreach (var H in Hierarchies)
            {
                var h = grid.Dimensions.FindHierarchy(H.UniqueName);
                if (h != null)
                {
                    H.Restore(h);
                }
            }

            foreach (var s in AxesLayout.RowHierarchies)
            {
                var h = grid.Dimensions.FindHierarchy(s);
                if (h != null)
                {
                    grid.PivotingLast(h, LayoutArea.laRow);
                }
            }

            foreach (var s in AxesLayout.ColumnHierarchies)
            {
                var H = grid.Dimensions.FindHierarchy(s);
                if (H != null)
                {
                    grid.PivotingLast(H, LayoutArea.laColumn);
                }
            }
            //if (olap.OlapDocumentMode == OlapDocumentMode.MDI && (olap.AllowShareFilter == false))
            {
                foreach (var s in AxesLayout.PageHierarchies)
                {
                    var H = grid.Dimensions.FindHierarchy(s);
                    if (H != null)
                    {
                        grid.PivotingLast(H, LayoutArea.laPage);
                    }
                }
            }

            if (AxesLayout.DetailsHierarchies != null)
            {
                foreach (var s in AxesLayout.DetailsHierarchies)
                {
                    var h = grid.Dimensions.FindHierarchy(s);
                    if (h != null)
                    {
                        grid.PivotingLast(h, LayoutArea.laDetails);
                    }
                }
            }

            if (!string.IsNullOrEmpty(AxesLayout.ColorAxis)) // && grid.CellsetMode == CellsetMode.cmChart)
            {
                var m = grid.Measures.Find(AxesLayout.ColorAxis);
                if (m != null)
                {
                    grid.Pivoting(m, LayoutArea.laColor, null, LayoutArea.laNone);
                    assignedMeasures.Remove(m);
                }
                else
                {
                    var h = grid.Dimensions.FindHierarchy(AxesLayout.ColorAxis);
                    if (h != null)
                    {
                        grid.PivotingFirst(h, LayoutArea.laColor);
                    }
                }
            }

            if (!string.IsNullOrEmpty(AxesLayout.ColorForeAxis) && grid.CellsetMode == CellsetMode.cmGrid)
            {
                var m = grid.Measures.Find(AxesLayout.ColorForeAxis);
                if (m != null)
                {
                    grid.Pivoting(m, LayoutArea.laColorFore, null, LayoutArea.laNone);
                    assignedMeasures.Remove(m);
                }
                else
                {
                    var h = grid.Dimensions.FindHierarchy(AxesLayout.ColorForeAxis);
                    if (h != null)
                    {
                        grid.PivotingFirst(h, LayoutArea.laColorFore);
                    }
                }
            }

            if (!string.IsNullOrEmpty(AxesLayout.SizeAxis))
            {
                var m = grid.Measures.Find(AxesLayout.SizeAxis);
                if (m != null)
                {
                    grid.Pivoting(m, LayoutArea.laSize, null, LayoutArea.laNone);
                    assignedMeasures.Remove(m);
                }
                else
                {
                    var h = grid.Dimensions.FindHierarchy(AxesLayout.SizeAxis);
                    if (h != null)
                    {
                        grid.PivotingFirst(h, LayoutArea.laSize);
                    }
                }
            }
            if (!string.IsNullOrEmpty(AxesLayout.ShapeAxis))
            {
                var h = grid.Dimensions.FindHierarchy(AxesLayout.ShapeAxis);
                if (h != null)
                {
                    grid.PivotingFirst(h, LayoutArea.laShape);
                }
            }

            if (!string.IsNullOrEmpty(AxesLayout.XMeasure))
            {
                var m = grid.Measures.Find(AxesLayout.XMeasure);
                if (m != null)
                {
                    grid.Pivoting(m, LayoutArea.laColumn, null, LayoutArea.laNone);
                }
            }

            if (AxesLayout.YMeasures != null)
            {
                grid.AxesLayout.fYAxisMeasures.Clear();

                foreach (var gm in AxesLayout.YMeasures)
                {
                    gm.Restore(grid, assignedMeasures);
                }
            }

#pragma warning disable 612,618
            if (AxesLayout.OpenendNodes != null)
            {
                var on = new Dictionary <string, PossibleDrillActions>(AxesLayout.OpenendNodes.Length);
                for (var i = 0; i < AxesLayout.OpenendNodes.Length; i++)
                {
                    on.Add(AxesLayout.OpenendNodes[i], AxesLayout.OpenendActions[i]);
                }
#pragma warning restore 612,618
                grid.FCellSet.ApplyOpenedNodes(on);
            }
            if (AxesLayout.Drills != null)
            {
                foreach (var s in AxesLayout.Drills)
                {
                    var da = DrillAction.FromString(grid, s);
                    if (da != null)
                    {
                        grid.CellSet.FDrillActions.Add(da);
                    }
                }
            }
        }