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)*/ }
        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;            
        }