public ServerExplorerCtrl()
        {
            m_CubeBrowser = new CubeBrowserCtrl();

            Grid LayoutRoot = new Grid();
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            LayoutRoot.RowDefinitions.Add(new RowDefinition());

            var cubesComboHeader = new HeaderControl(UriResources.Images.Cube16, Localization.MdxDesigner_Cube) { Margin = new Thickness(0, 0, 0, 3) };

            Cubes_ComboBox = new ComboBoxEx();
            Cubes_ComboBox.SelectionChanged += new SelectionChangedEventHandler(Cubes_ComboBox_SelectionChanged);
            Cubes_ComboBox.Height = 22;
            Cubes_ComboBox.Margin = new Thickness(0, 0, 0, 5);

            LayoutRoot.Children.Add(cubesComboHeader);
            LayoutRoot.Children.Add(Cubes_ComboBox);
            Grid.SetRow(Cubes_ComboBox, 1);
            LayoutRoot.Children.Add(m_CubeBrowser);
            Grid.SetRow(m_CubeBrowser, 2);

            base.Content = LayoutRoot;

            m_OlapDataLoader = GetOlapDataLoader();

            m_CubeBrowser.OlapDataLoader = GetOlapDataLoader();
            
            m_CubeBrowser.SelectedItemChanged += new EventHandler<ItemEventArgs>(m_CubeBrowser_SelectedItemChanged);

            Cubes_ComboBox.IsEnabled = false;
            m_CubeBrowser.IsEnabled = false;
        }
        public KpiViewer()
        {            
            ScrollViewer Scroll = new ScrollViewer();
            Scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            Scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            m_DataGrid = new DragDropDataGrid();
            m_DataGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            m_DataGrid.VerticalAlignment = VerticalAlignment.Top;
            LayoutRoot = new Grid();
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            LayoutRoot.RowDefinitions.Add(new RowDefinition());
            m_InputColumn = new ColumnDefinition() { Width = new GridLength(m_InputColumnWidth) };
            LayoutRoot.ColumnDefinitions.Add(m_InputColumn);
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { /*Width = new GridLength(2, GridUnitType.Star)*/ });

            // ТУЛБАР 
            m_ToolBar = new RanetToolBar();
            m_ToolBar.Margin = new Thickness(0, 0, 0, 4);
            LayoutRoot.Children.Add(m_ToolBar);
            Grid.SetColumnSpan(m_ToolBar, 2);

            m_ShowMetadataArea = new RanetToggleButton();
            m_ShowMetadataArea.ClickMode = ClickMode.Press;            
            m_ShowMetadataArea.IsChecked = true;
            m_ShowMetadataArea.Checked += new RoutedEventHandler(m_ShowMetadataArea_Checked);
            m_ShowMetadataArea.Unchecked += new RoutedEventHandler(m_ShowMetadataArea_Unchecked);
            m_ShowMetadataArea.Content = UiHelper.CreateIcon(UriResources.Images.Menu16);
            ToolTipService.SetToolTip(m_ShowMetadataArea, Localization.MdxDesigner_ShowQueryDesigner_ToolTip);
            m_ToolBar.AddItem(m_ShowMetadataArea);

            RanetToggleButton showAllButton = new RanetToggleButton();
            showAllButton.ClickMode = ClickMode.Press;
            showAllButton.Content = UiHelper.CreateIcon(UriResources.GetImage("/Ranet.AgOlap;component/Controls/Images/OLAP/KPI/ShowAll.png"));
            showAllButton.Checked += new RoutedEventHandler(showAllButton_Checked);
            showAllButton.Unchecked += new RoutedEventHandler(showAllButton_Unchecked);
            ToolTipService.SetToolTip(showAllButton,Localization.ShowAll_Check);
            showAllButton.Visibility = System.Windows.Visibility.Collapsed;
            m_ToolBar.AddItem(showAllButton);

            RanetToolBarButton m_ApplyChanges = new RanetToolBarButton();
            m_ApplyChanges.ClickMode = ClickMode.Press;
            m_ApplyChanges.Click += new RoutedEventHandler(m_ApplyChanges_Click);
            m_ApplyChanges.Content = UiHelper.CreateIcon(UriResources.Images.Run16);
            ToolTipService.SetToolTip(m_ApplyChanges, Localization.Apply);
            m_ToolBar.AddItem(m_ApplyChanges);

            //showColumnChoice = new RanetToggleButton();
            //showColumnChoice.ClickMode = ClickMode.Press;
            //showColumnChoice.IsChecked = true;
            //showColumnChoice.Checked += new RoutedEventHandler(showColumnChoice_Checked);
            //showColumnChoice.Unchecked += new RoutedEventHandler(showColumnChoice_Unchecked);
            //showColumnChoice.Content = UiHelper.CreateIcon(UriResources.Images.ColumnsArea16);
            //ToolTipService.SetToolTip(showColumnChoice, Localization.MdxDesigner_RunQueryAutomatic);
            //this.m_ToolBar.AddItem(showColumnChoice);  
                     
            Grid Input_LayoutRoot = new Grid();
            Input_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(2, GridUnitType.Star) });
            Input_LayoutRoot.Margin = new Thickness(0, 0, 0, 0);
            Input_LayoutRoot.RowDefinitions.Add(new RowDefinition());

            
            Input_Border = new Border() { Padding = new Thickness(3), BorderBrush = new SolidColorBrush(Colors.DarkGray), BorderThickness = new Thickness(1) };
            Input_Border.Margin = new Thickness(0, 0, 5, 0);
            Input_Border.Child = Input_LayoutRoot;

            Grid Ouput_LayoutRoot = new Grid();
            Ouput_LayoutRoot.Margin = new Thickness(0, 0, 0, 0);
            // По умолчанию высота 0
            var m_MDX_Row = new RowDefinition() { Height = new GridLength(0.0) };
            Ouput_LayoutRoot.RowDefinitions.Add(m_MDX_Row);
            Ouput_LayoutRoot.RowDefinitions.Add(new RowDefinition() /*{ Height = new GridLength(2, GridUnitType.Star) }*/);

            LayoutRoot.Children.Add(Input_Border);
            Grid.SetRow(Input_Border, 1);
            LayoutRoot.Children.Add(Ouput_LayoutRoot);
            Grid.SetRow(Ouput_LayoutRoot, 1);
            Grid.SetColumn(Ouput_LayoutRoot, 1);

            LayoutRoot_VertSplitter = new RanetGridSplitter();
            LayoutRoot_VertSplitter.VerticalAlignment = VerticalAlignment.Stretch;
            LayoutRoot_VertSplitter.HorizontalAlignment = HorizontalAlignment.Right;
            LayoutRoot_VertSplitter.IsTabStop = false;
            LayoutRoot_VertSplitter.Background = new SolidColorBrush(Colors.Transparent);
            LayoutRoot.Children.Add(LayoutRoot_VertSplitter);
            Grid.SetRow(LayoutRoot_VertSplitter, 1);
            Grid.SetColumn(LayoutRoot_VertSplitter, 0);

            // Информация о кубе
            // Просмотрщик куба
            m_ServerExplorer = new ServerExplorerCtrl();
            m_ServerExplorer.Margin = new Thickness(0, 0, 0, 5);   // Для RanetGridSplitter
            m_ServerExplorer.CubeBrowser.DragNodes = true;
            m_ServerExplorer.CubeBrowser.DragStarted += new EventHandler<DragNodeArgs<System.Windows.Controls.Primitives.DragStartedEventArgs>>(CubeBrowser_DragStarted);
            m_ServerExplorer.CubeBrowser.DragDelta += new EventHandler<DragNodeArgs<System.Windows.Controls.Primitives.DragDeltaEventArgs>>(CubeBrowser_DragDelta);
            m_ServerExplorer.CubeBrowser.DragCompleted += new EventHandler<DragNodeArgs<System.Windows.Controls.Primitives.DragCompletedEventArgs>>(CubeBrowser_DragCompleted);
            m_ServerExplorer.CubeSelected += new EventHandler<CustomEventArgs<string>>(m_ServerExplorer_CubeSelected);

            StackPanel rowsPanel = new StackPanel() {Orientation = Orientation.Vertical};
            var cubesComboHeader = new HeaderControl(UriResources.Images.HideEmptyRows16, Localization.ColumnsHeader) { Margin = new Thickness(0, 0, 0, 3) };     
            m_columnsList = new RanetCheckedListBox();
            m_ColumnNames = new Dictionary<string,bool>();
            //m_ColumnNames.Add("Display Folder",false);
            m_ColumnNames.Add("Kpi Name",true);
            m_columnsList.AddItem(new RanetCheckedItem() { Text = "Kpi Name" , IsChecked = true});
            m_ColumnNames.Add("Kpi Value",true);
            m_columnsList.AddItem(new RanetCheckedItem() { Text = "Kpi Value", IsChecked = true });
            m_ColumnNames.Add("Kpi Goal", true);
            m_columnsList.AddItem(new RanetCheckedItem() { Text = "Kpi Goal", IsChecked = true });
            m_ColumnNames.Add("Kpi Variance", true);
            m_columnsList.AddItem(new RanetCheckedItem() { Text = "Kpi Variance", IsChecked = true });
            m_ColumnNames.Add("Trend", true);
            m_columnsList.AddItem(new RanetCheckedItem() { Text = "Trend", IsChecked = true });
            m_ColumnNames.Add("Status", true);
            m_columnsList.AddItem(new RanetCheckedItem() { Text = "Status", IsChecked = true });
            m_ColumnNames.Add("Kpi Weight", false);
            m_columnsList.AddItem(new RanetCheckedItem() { Text = "Kpi Weight", IsChecked = false });
            m_columnsList.ListBox.SelectionChanged += new SelectionChangedEventHandler(m_columnsList_SelectionChanged);
            
            Input_LayoutRoot.Children.Add(m_ServerExplorer);
            Grid.SetRow(m_ServerExplorer, 0);

            rowsPanel.Children.Add(cubesComboHeader);
            rowsPanel.Children.Add(m_columnsList);
            Input_LayoutRoot.Children.Add(rowsPanel);
            Grid.SetRow(rowsPanel, 1);

            // Заголовок
            Table_LayoutRoot = new Grid();
            Table_LayoutRoot.Margin = new Thickness(0, 3, 0, 0);
            Table_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            Table_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            Table_LayoutRoot.RowDefinitions.Add(new RowDefinition() {Height = GridLength.Auto});
            HeaderControl pivot_Header = new HeaderControl(UriResources.Images.PivotGrid16, Localization.MdxDesigner_QueryResult) { Margin = new Thickness(0, 0, 0, 3) };
            Table_LayoutRoot.Children.Add(pivot_Header);
            Grid.SetRow(Table_LayoutRoot,0);
            m_Waiting = new BusyControl();
            m_Waiting.Text = Localization.Loading;
            Table_LayoutRoot.Children.Add(m_Waiting);
            Grid.SetRow(m_Waiting, 1);

            IsBusy = false;
            //m_OlapDataLoader = GetDataLoader();

            Table_LayoutRoot.Children.Add(m_DataGrid);
            Grid.SetRow(m_DataGrid, 2);
            // Сводная таблица            

            Pivot_Border = new Border() { Padding = new Thickness(3), BorderBrush = new SolidColorBrush(Colors.DarkGray), BorderThickness = new Thickness(1) };
            Pivot_Border.Margin = new Thickness(0, 1, 0, 0);
            Pivot_Border.Child = Table_LayoutRoot;

            Ouput_LayoutRoot.Children.Add(Pivot_Border);
            Grid.SetRow(Pivot_Border, 1);

            //var Output_HorzSplitter = new RanetGridSplitter();
            //Output_HorzSplitter.VerticalAlignment = VerticalAlignment.Bottom;
            //Output_HorzSplitter.HorizontalAlignment = HorizontalAlignment.Stretch;
            //Output_HorzSplitter.IsTabStop = false;
            //Output_HorzSplitter.Background = new SolidColorBrush(Colors.Transparent);
            //Ouput_LayoutRoot.Children.Add(Output_HorzSplitter);
            //Grid.SetRow(Output_HorzSplitter, 0);
            //Grid.SetColumn(Output_HorzSplitter, 0);            
            //

            this.Content = LayoutRoot;            
        }
        public AreaItemControl()
        {
            LayoutRoot = new Grid();
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

            Border border = new Border();
            border.BorderBrush = new SolidColorBrush(Colors.DarkGray);
            border.BorderThickness = new Thickness(1);
            border.Padding = new Thickness(2);
            border.Child = LayoutRoot;

            m_ItemCtrl = new HeaderControl();
            LayoutRoot.Children.Add(m_ItemCtrl);

            m_MoveUpButton = new RanetHotButton();
            m_MoveUpButton.Click += new RoutedEventHandler(m_MoveUpButton_Click);
            m_MoveUpButton.Width = 18;
            m_MoveUpButton.Height = 18;
            m_MoveUpButton.Content = UiHelper.CreateIcon(UriResources.Images.Up16);
            LayoutRoot.Children.Add(m_MoveUpButton);
            Grid.SetColumn(m_MoveUpButton, 2); 

            m_MoveDownButton = new RanetHotButton();
            m_MoveDownButton.Click += new RoutedEventHandler(m_MoveDownButton_Click);
            m_MoveDownButton.Width = 18;
            m_MoveDownButton.Height = 18;
            m_MoveDownButton.Content = UiHelper.CreateIcon(UriResources.Images.Down16);
            LayoutRoot.Children.Add(m_MoveDownButton);
            Grid.SetColumn(m_MoveDownButton, 3); 

            m_RemoveButton = new RanetHotButton();
            m_RemoveButton.Click += new RoutedEventHandler(m_RemoveButton_Click);
            m_RemoveButton.Width = 18;
            m_RemoveButton.Height = 18;
            m_RemoveButton.Content = UiHelper.CreateIcon(UriResources.Images.RemoveHot16);
            LayoutRoot.Children.Add(m_RemoveButton);
            Grid.SetColumn(m_RemoveButton, 4); 

            this.Content = border;

            LayoutRoot.AttachContextMenu(p => GetCurrentContextMenu(p));

            TooltipManager = new TooltipController(this);
            TooltipManager.BeforeOpen += new EventHandler<CustomEventArgs<Point>>(TooltipManager_BeforeOpen);
            TooltipManager.ToolTipContent = ToolTip;
        }
        public PivotMdxDesignerControl()
        {
            ScrollViewer Scroll = new ScrollViewer();
            Scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            Scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;

            LayoutRoot = new Grid();
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            LayoutRoot.RowDefinitions.Add(new RowDefinition());
            m_Input_Column = new ColumnDefinition() { Width = new GridLength(m_InputColumnWidth) };
            LayoutRoot.ColumnDefinitions.Add(m_Input_Column);
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { /*Width = new GridLength(2, GridUnitType.Star)*/ });

            // ТУЛБАР 
            m_ToolBar = new RanetToolBar();
            m_ToolBar.Margin = new Thickness(0, 0, 0, 4);
            LayoutRoot.Children.Add(m_ToolBar);
            Grid.SetColumnSpan(m_ToolBar, 2);

            m_ShowMetadataArea = new RanetToggleButton();
            m_ShowMetadataArea.ClickMode = ClickMode.Press;
            m_ShowMetadataArea.Click += new RoutedEventHandler(m_ShowMetadataArea_Click);
            m_ShowMetadataArea.IsChecked = new bool?(true);
            m_ShowMetadataArea.Content = UiHelper.CreateIcon(UriResources.Images.Menu16);
            ToolTipService.SetToolTip(m_ShowMetadataArea, Localization.MdxDesigner_ShowQueryDesigner_ToolTip);
            m_ToolBar.AddItem(m_ShowMetadataArea);

            m_ShowMDXQuery = new RanetToggleButton();
            m_ShowMDXQuery.ClickMode = ClickMode.Press;
            m_ShowMDXQuery.Click += new RoutedEventHandler(m_ShowMDXQuery_Click);
            m_ShowMDXQuery.IsChecked = new bool?(false);
            m_ShowMDXQuery.Content = UiHelper.CreateIcon(UriResources.Images.Mdx16);
            ToolTipService.SetToolTip(m_ShowMDXQuery, Localization.MdxDesigner_ShowQuery_ToolTip);
            m_ToolBar.AddItem(m_ShowMDXQuery);

            m_EditMDXQuery = new RanetToggleButton();
            m_EditMDXQuery.ClickMode = ClickMode.Press;
            m_EditMDXQuery.Click += new RoutedEventHandler(m_EditMDXQuery_Click);
            m_EditMDXQuery.IsChecked = new bool?(false);
            m_EditMDXQuery.Content = UiHelper.CreateIcon(UriResources.Images.Edit16);
            ToolTipService.SetToolTip(m_EditMDXQuery, Localization.MdxDesigner_EditQuery_ToolTip);
            m_ToolBar.AddItem(m_EditMDXQuery);

            m_RunAreaSplitter = new RanetToolBarSplitter();
            m_ToolBar.AddItem(m_RunAreaSplitter);

            m_CalculatedMemberEditor = new RanetToolBarButton();
            m_CalculatedMemberEditor.Content = UiHelper.CreateIcon(UriResources.Images.CustomCalculations16);
            m_CalculatedMemberEditor.Click += new RoutedEventHandler(m_CalculatedMemberEditor_Click);
            ToolTipService.SetToolTip(m_CalculatedMemberEditor, Localization.MdxDesigner_CalculatedMemberEditor);
            m_ToolBar.AddItem(m_CalculatedMemberEditor);

            m_RunQueryAutomatic = new RanetToggleButton();
            m_RunQueryAutomatic.ClickMode = ClickMode.Press;
            m_RunQueryAutomatic.IsChecked = new bool?(true);
            m_RunQueryAutomatic.Content = UiHelper.CreateIcon(UriResources.Images.AutoRun16);
            ToolTipService.SetToolTip(m_RunQueryAutomatic, Localization.MdxDesigner_RunQueryAutomatic);
            m_ToolBar.AddItem(m_RunQueryAutomatic);

            m_ExecuteQuery = new RanetToolBarButton();
            m_ExecuteQuery.Content = UiHelper.CreateIcon(UriResources.Images.Run16);
            m_ExecuteQuery.Click += new RoutedEventHandler(m_ExecuteQuery_Click);
            ToolTipService.SetToolTip(m_ExecuteQuery, Localization.MdxDesigner_ExecuteQuery);
            m_ToolBar.AddItem(m_ExecuteQuery);

            m_StorageAreaSplitter = new RanetToolBarSplitter();
            m_ToolBar.AddItem(m_StorageAreaSplitter);

            m_ImportLayout = new RanetToolBarButton();
            m_ImportLayout.Content = UiHelper.CreateIcon(UriResources.Images.FileImport16);
            m_ImportLayout.Click += new RoutedEventHandler(m_ImportLayout_Click);
            ToolTipService.SetToolTip(m_ImportLayout, Localization.MdxDesigner_ImportLayout_ToolTip);
            m_ToolBar.AddItem(m_ImportLayout);

            m_ExportLayout = new RanetToolBarButton();
            m_ExportLayout.Content = UiHelper.CreateIcon(UriResources.Images.FileExport16);
            m_ExportLayout.Click += new RoutedEventHandler(m_ExportLayout_Click);
            ToolTipService.SetToolTip(m_ExportLayout, Localization.MdxDesigner_ExportLayout_ToolTip);
            m_ToolBar.AddItem(m_ExportLayout);

            Grid Input_LayoutRoot = new Grid();
            Input_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(2, GridUnitType.Star) });
            Input_LayoutRoot.Margin = new Thickness(0, 0, 0, 0);
            Input_LayoutRoot.RowDefinitions.Add(new RowDefinition());

            Input_Border = new Border() { Padding = new Thickness(3), BorderBrush = new SolidColorBrush(Colors.DarkGray), BorderThickness = new Thickness(1) };
            Input_Border.Margin = new Thickness(0, 0, 3, 0);
            Input_Border.Child = Input_LayoutRoot;

            Grid Ouput_LayoutRoot = new Grid();
            Ouput_LayoutRoot.Margin = new Thickness(0, 0, 0, 0);
            // По умолчанию высота 0
            m_MDX_Row = new RowDefinition(){ Height = new GridLength(0.0)};
            Ouput_LayoutRoot.RowDefinitions.Add(m_MDX_Row);
            Ouput_LayoutRoot.RowDefinitions.Add(new RowDefinition() /*{ Height = new GridLength(2, GridUnitType.Star) }*/);

            LayoutRoot.Children.Add(Input_Border);
            Grid.SetRow(Input_Border, 1);
            LayoutRoot.Children.Add(Ouput_LayoutRoot);
            Grid.SetRow(Ouput_LayoutRoot, 1);
            Grid.SetColumn(Ouput_LayoutRoot, 1);

            LayoutRoot_VertSplitter = new GridSplitter();
            LayoutRoot_VertSplitter.VerticalAlignment = VerticalAlignment.Stretch;
            LayoutRoot_VertSplitter.HorizontalAlignment = HorizontalAlignment.Right;
            LayoutRoot_VertSplitter.Width = 3;
            LayoutRoot_VertSplitter.IsTabStop = false;
            LayoutRoot_VertSplitter.Background = new SolidColorBrush(Colors.Transparent);
            LayoutRoot.Children.Add(LayoutRoot_VertSplitter);
            Grid.SetRow(LayoutRoot_VertSplitter, 1);
            Grid.SetColumn(LayoutRoot_VertSplitter, 0);

            // Информация о кубе
            Grid Cube_LayotRoot = new Grid();
            Cube_LayotRoot.Margin = new Thickness(0, 3, 0, 0);
            Cube_LayotRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            Cube_LayotRoot.RowDefinitions.Add(new RowDefinition());
            
            // Заголовок
            //HeaderControl cube_Header = new HeaderControl(UriResources.Images.Cube16, Localization.MdxDesigner_CubeMetadata) { Margin = new Thickness(0, 0, 0, 3) };
            //Cube_LayotRoot.Children.Add(cube_Header);

            // Просмотрщик куба
            m_ServerExplorer = new ServerExplorerCtrl();
            m_ServerExplorer.CubeBrowser.DragNodes = true;
            m_ServerExplorer.CubeBrowser.DragStarted += new EventHandler<DragNodeArgs<DragStartedEventArgs>>(m_CubeBrowser_DragStarted);
            m_ServerExplorer.CubeBrowser.DragDelta += new EventHandler<DragNodeArgs<DragDeltaEventArgs>>(m_CubeBrowser_DragDelta);
            m_ServerExplorer.CubeBrowser.DragCompleted += new EventHandler<DragNodeArgs<DragCompletedEventArgs>>(m_CubeBrowser_DragCompleted);
            m_ServerExplorer.CubeSelected += new EventHandler<CustomEventArgs<string>>(m_ServerExplorer_CubeSelected);
            Cube_LayotRoot.Children.Add(m_ServerExplorer);
            Grid.SetRow(m_ServerExplorer, 1);

            Input_LayoutRoot.Children.Add(Cube_LayotRoot);
            Grid.SetRow(Cube_LayotRoot, 0);

            Areas_LayoutRoot = new Grid();
            Areas_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            Areas_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            Areas_LayoutRoot.RowDefinitions.Add(new RowDefinition());
            Areas_LayoutRoot.RowDefinitions.Add(new RowDefinition());

            m_FilterAreaContainer = new PivotAreaContainer();
            m_FilterAreaContainer.ItemRemoved += new EventHandler<AreaItemArgs>(AreaContainer_ItemRemoved);
            m_FilterAreaContainer.Margin = new Thickness(0, 5, 0, 0);
            m_FilterAreaContainer.Icon = UriResources.Images.FiltersArea16;
            m_FilterAreaContainer.Caption = Localization.MdxDesigner_FilterArea_Caption;
            m_FilterAreaContainer.BeforeShowContextMenu += new EventHandler<AreaItemArgs>(m_FilterAreaContainer_BeforeShowContextMenu);
            m_FilterAreaContainer.ItemsListChanged += new EventHandler(AreaContainer_ItemsListChanged);
            Areas_LayoutRoot.Children.Add(m_FilterAreaContainer);
            Grid.SetRow(m_FilterAreaContainer, 0);
            Grid.SetColumn(m_FilterAreaContainer, 0);

            m_RowsAreaContainer = new PivotAreaContainer();
            m_RowsAreaContainer.ItemRemoved += new EventHandler<AreaItemArgs>(AreaContainer_ItemRemoved);
            m_RowsAreaContainer.Margin = new Thickness(0, 5, 0, 0);
            m_RowsAreaContainer.Icon = UriResources.Images.RowsArea16;
            m_RowsAreaContainer.Caption = Localization.MdxDesigner_RowsArea_Caption;
            m_RowsAreaContainer.BeforeShowContextMenu += new EventHandler<AreaItemArgs>(m_RowsAreaContainer_BeforeShowContextMenu);
            m_RowsAreaContainer.ItemsListChanged += new EventHandler(AreaContainer_ItemsListChanged);
            Areas_LayoutRoot.Children.Add(m_RowsAreaContainer);
            Grid.SetRow(m_RowsAreaContainer, 1);
            Grid.SetColumn(m_RowsAreaContainer, 0);

            m_ColumnsAreaContainer = new PivotAreaContainer();
            m_ColumnsAreaContainer.ItemRemoved += new EventHandler<AreaItemArgs>(AreaContainer_ItemRemoved);
            m_ColumnsAreaContainer.Margin = new Thickness(5, 5, 0, 0);
            m_ColumnsAreaContainer.Icon = UriResources.Images.ColumnsArea16;
            m_ColumnsAreaContainer.Caption = Localization.MdxDesigner_ColumnsArea_Caption;
            m_ColumnsAreaContainer.BeforeShowContextMenu += new EventHandler<AreaItemArgs>(m_ColumnsAreaContainer_BeforeShowContextMenu);
            m_ColumnsAreaContainer.ItemsListChanged += new EventHandler(AreaContainer_ItemsListChanged);
            Areas_LayoutRoot.Children.Add(m_ColumnsAreaContainer);
            Grid.SetRow(m_ColumnsAreaContainer, 0);
            Grid.SetColumn(m_ColumnsAreaContainer, 1);

            m_DataAreaContainer = new PivotAreaContainer();
            m_DataAreaContainer.ItemRemoved += new EventHandler<AreaItemArgs>(AreaContainer_ItemRemoved);
            m_DataAreaContainer.Margin = new Thickness(5, 5, 0, 0);
            m_DataAreaContainer.Icon = UriResources.Images.DataArea16;
            m_DataAreaContainer.Caption = Localization.MdxDesigner_DataArea_Caption;
            m_DataAreaContainer.ItemsListChanged += new EventHandler(AreaContainer_ItemsListChanged);
            Areas_LayoutRoot.Children.Add(m_DataAreaContainer);
            Grid.SetRow(m_DataAreaContainer, 1);
            Grid.SetColumn(m_DataAreaContainer, 1);

            Input_LayoutRoot.Children.Add(Areas_LayoutRoot);
            Grid.SetRow(Areas_LayoutRoot, 1);

            GridSplitter Input_HorzSplitter = new GridSplitter();
            Input_HorzSplitter.VerticalAlignment = VerticalAlignment.Bottom;
            Input_HorzSplitter.HorizontalAlignment = HorizontalAlignment.Stretch;
            Input_HorzSplitter.Height = 3;
            Input_HorzSplitter.IsTabStop = false;
            Input_HorzSplitter.Background = new SolidColorBrush(Colors.Transparent);
            Input_LayoutRoot.Children.Add(Input_HorzSplitter);
            Grid.SetRow(Input_HorzSplitter, 0);
            Grid.SetColumn(Input_HorzSplitter, 0);

            // Результат выполнения запроса
            Grid Pivot_LayotRoot = new Grid();
            Pivot_LayotRoot.Margin = new Thickness(0, 3, 0, 0);
            Pivot_LayotRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            Pivot_LayotRoot.RowDefinitions.Add(new RowDefinition());

            // Заголовок
            HeaderControl pivot_Header = new HeaderControl(UriResources.Images.PivotGrid16, Localization.MdxDesigner_QueryResult) { Margin = new Thickness(0, 0, 0, 3) };
            Pivot_LayotRoot.Children.Add(pivot_Header);

            // Сводная таблица
            m_PivotGrid = new UpdateablePivotGridControl();
            m_PivotGrid.Margin = new Thickness(0, 0, 0, 0);
            m_PivotGrid.IsUpdateable = true;
            m_PivotGrid.ColumnsIsInteractive = true;
            m_PivotGrid.RowsIsInteractive = true;
            m_PivotGrid.ShowToolBar = true;
            Pivot_LayotRoot.Children.Add(m_PivotGrid);
            Grid.SetRow(m_PivotGrid, 1);

            Border Pivot_Border = new Border() { Padding = new Thickness(3), BorderBrush = new SolidColorBrush(Colors.DarkGray), BorderThickness = new Thickness(1) };
            Pivot_Border.Margin = new Thickness(0, 0, 0, 0);
            Pivot_Border.Child = Pivot_LayotRoot;

            Ouput_LayoutRoot.Children.Add(Pivot_Border);
            Grid.SetRow(Pivot_Border, 1);

            Output_HorzSplitter = new GridSplitter();
            Output_HorzSplitter.VerticalAlignment = VerticalAlignment.Bottom;
            Output_HorzSplitter.HorizontalAlignment = HorizontalAlignment.Stretch;
            Output_HorzSplitter.Height = 3;
            Output_HorzSplitter.IsTabStop = false;
            Output_HorzSplitter.Background = new SolidColorBrush(Colors.Transparent);
            Ouput_LayoutRoot.Children.Add(Output_HorzSplitter);
            Grid.SetRow(Output_HorzSplitter, 0);
            Grid.SetColumn(Output_HorzSplitter, 0);

            // Информация о MDX запросе
            Grid Mdx_LayotRoot = new Grid();
            Mdx_LayotRoot.Margin = new Thickness(0, 3, 0, 0);
            Mdx_LayotRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            Mdx_LayotRoot.RowDefinitions.Add(new RowDefinition());

            // Заголовок
            HeaderControl mdx_Header = new HeaderControl(UriResources.Images.Mdx16, Localization.MdxDesigner_MdxQuery) { Margin = new Thickness(0, 0, 0, 3) };
            Mdx_LayotRoot.Children.Add(mdx_Header);
            
            // Текст запроса
            m_MdxQuery = new RichTextBox();
            m_MdxQuery.AcceptsReturn = true;
            m_MdxQuery.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            m_MdxQuery.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            m_MdxQuery.IsReadOnly = true;
            Mdx_LayotRoot.Children.Add(m_MdxQuery);
            Grid.SetRow(m_MdxQuery, 1);

            Mdx_Border = new Border() { Padding = new Thickness(3), BorderBrush = new SolidColorBrush(Colors.DarkGray), BorderThickness = new Thickness(1) };
            Mdx_Border.Margin = new Thickness(0, 0, 0, 4);
            Mdx_Border.Child = Mdx_LayotRoot;

            Ouput_LayoutRoot.Children.Add(Mdx_Border);
            Grid.SetRow(Mdx_Border, 0);

            AllowDragDrop(m_FilterAreaContainer);
            AllowDragDrop(m_ColumnsAreaContainer);
            AllowDragDrop(m_RowsAreaContainer);
            AllowDragDrop(m_DataAreaContainer);

            //Scroll.Content = LayoutRoot;

            m_ServerExplorer.OlapDataLoader = GetOlapDataLoader();
            m_PivotGrid.OlapDataLoader = GetOlapDataLoader();
            m_StorageManager = GetStorageManager();
            m_StorageManager.InvokeCompleted += new EventHandler<DataLoaderEventArgs>(StorageManager_ActionCompleted);

            this.Content = LayoutRoot;
        }