public MemberPropertiesControl()
        {
            TabCtrl = new RanetTabControl();

            PropertiesCtrl = new PropertiesListControl();

            TabItem PropertiesTab = new TabItem();
            PropertiesTab.Header = Localization.Properties;
            PropertiesTab.Style = TabCtrl.Resources["TabControlOutputItem"] as Style;
            PropertiesTab.Content = PropertiesCtrl;
            TabCtrl.TabCtrl.Items.Add(PropertiesTab);

            PropertiesTab.Header = Localization.Properties;

            TabToolBar toolBar = TabCtrl.ToolBar;
            if (toolBar != null)
            {
                RanetToolBarButton copyBtn = new RanetToolBarButton();
                ToolTipService.SetToolTip(copyBtn, Localization.CopyToClipboard_ToolTip);
                copyBtn.Content = UiHelper.CreateIcon(UriResources.Images.Copy16);
                toolBar.Stack.Children.Add(copyBtn);
                copyBtn.Click += new RoutedEventHandler(CopyButton_Click);
            }

            this.Content = TabCtrl;
        }
        public CalculationsEditor()
        {
            InitializeComponent();

            m_AddCalcMemberButton = new RanetToolBarButton();
            m_AddCalcMemberButton.Content = UiHelper.CreateIcon(UriResources.Images.AddMeasure16);
            m_AddCalcMemberButton.Click += new RoutedEventHandler(m_AddCalcMemberButton_Click);
            ToolTipService.SetToolTip(m_AddCalcMemberButton, Localization.CalcMemberEditor_AddMember);
            ToolBar.AddItem(m_AddCalcMemberButton);

            m_AddNamedSetButton = new RanetToolBarButton();
            m_AddNamedSetButton.Content = UiHelper.CreateIcon(UriResources.Images.AddNamedSet16);
            m_AddNamedSetButton.Click += new RoutedEventHandler(m_AddNamedSetButton_Click);
            ToolTipService.SetToolTip(m_AddNamedSetButton, Localization.CalcMemberEditor_AddNamedSet);
            ToolBar.AddItem(m_AddNamedSetButton);

            m_DeleteCalcMemberButton = new RanetToolBarButton();
            m_DeleteCalcMemberButton.Content = UiHelper.CreateIcon(UriResources.Images.RemoveCross16);
            m_DeleteCalcMemberButton.Click += new RoutedEventHandler(m_DeleteCalcMemberButton_Click);
            m_DeleteCalcMemberButton.IsEnabled = false;
            ToolTipService.SetToolTip(m_DeleteCalcMemberButton, Localization.CalcMemberEditor_DeleteMember);
            ToolBar.AddItem(m_DeleteCalcMemberButton);

            m_ClearButton = new RanetToolBarButton();
            m_ClearButton.Content = UiHelper.CreateIcon(UriResources.Images.RemoveAllCross16);
            m_ClearButton.Click += new RoutedEventHandler(m_ClearButton_Click);
            m_ClearButton.IsEnabled = (Members.Count + Sets.Count) > 0;
            ToolTipService.SetToolTip(m_ClearButton, Localization.CalcMemberEditor_Clear);
            ToolBar.AddItem(m_ClearButton);

            MembersList.SelectionChanged += new EventHandler<SelectionChangedEventArgs<CalculationInfoBase>>(MembersList_SelectionChanged);

            MemberCtrl.InnerEditStart += new EventHandler(MemberCtrl_InnerEditStart);
            MemberCtrl.InnerEditEnd += new EventHandler(MemberCtrl_InnerEditEnd);
            MemberCtrl.EditEnd += new EventHandler(MemberCtrl_EditEnd);

            SetCtrl.EditEnd += new EventHandler(MemberCtrl_EditEnd);

            FormatStrings.Add("#");
            FormatStrings.Add("#,#");
            FormatStrings.Add("#,#.00");
            FormatStrings.Add("$#,#;-$#,#;");
            FormatStrings.Add("$#,#.00;-$#,#.00;");
            FormatStrings.Add("Standard");
            FormatStrings.Add("Short Date");
            FormatStrings.Add("Short Time");
            FormatStrings.Add("Percent");

            CubeBrowser.DragNodes = true;
            CubeBrowser.DragStarted += new EventHandler<DragNodeArgs<DragStartedEventArgs>>(CubeBrowser_DragStarted);
            CubeBrowser.DragDelta += new EventHandler<DragNodeArgs<DragDeltaEventArgs>>(CubeBrowser_DragDelta);
            CubeBrowser.DragCompleted += new EventHandler<DragNodeArgs<DragCompletedEventArgs>>(CubeBrowser_DragCompleted);
        }
        public CustomCellConditionsEditor()
        {
            InitializeComponent();

            lblStyleDetails.Text = Localization.StyleDetails_Label;
            lblStyles.Text = Localization.Styles_Label;

            DescriptorsList.SelectionChanged += new EventHandler<SelectionChangedEventArgs<CellConditionsDescriptor>>(DescriptorsList_SelectionChanged);
            DescriptorDetails.EditEnd += new EventHandler(DescriptorDetails_EditEnd);

            AddButton = new RanetToolBarButton();
            AddButton.Content = UiHelper.CreateIcon(UriResources.Images.New16);
            AddButton.Click += new RoutedEventHandler(m_AddButton_Click);
            ToolTipService.SetToolTip(AddButton, Localization.Toolbar_NewButton_ToolTip);
            ToolBar.AddItem(AddButton);

            DeleteButton = new RanetToolBarButton();
            DeleteButton.Content = UiHelper.CreateIcon(UriResources.Images.RemoveCross16);
            DeleteButton.Click += new RoutedEventHandler(m_DeleteButton_Click);
            DeleteButton.IsEnabled = false;
            ToolTipService.SetToolTip(DeleteButton, Localization.Toolbar_DeleteButton_ToolTip);
            ToolBar.AddItem(DeleteButton);

            DeleteAllButton = new RanetToolBarButton();
            DeleteAllButton.Content = UiHelper.CreateIcon(UriResources.Images.RemoveAllCross16);
            DeleteAllButton.Click += new RoutedEventHandler(m_DeleteAllButton_Click);
            DeleteAllButton.IsEnabled = false;
            ToolTipService.SetToolTip(DeleteAllButton, Localization.Toolbar_DeleteAllButton_ToolTip);
            ToolBar.AddItem(DeleteAllButton);

            m_ImportButton = new RanetToolBarButton();
            m_ImportButton.Content = UiHelper.CreateIcon(UriResources.Images.FileImport16);
            m_ImportButton.Click += new RoutedEventHandler(m_ImportButton_Click);
            ToolTipService.SetToolTip(m_ImportButton, Localization.LoadSettings_ToolTip);
            ToolBar.AddItem(m_ImportButton);

            m_ExportButton = new RanetToolBarButton();
            m_ExportButton.Content = UiHelper.CreateIcon(UriResources.Images.FileExport16);
            m_ExportButton.Click += new RoutedEventHandler(m_ExportButton_Click);
            ToolTipService.SetToolTip(m_ExportButton, Localization.SaveSettings_ToolTip);
            ToolBar.AddItem(m_ExportButton);

            DescriptorsList.DeleteAllButton_IsEnabledChanged += new DependencyPropertyChangedEventHandler(DescriptorsList_DeleteAllButton_IsEnabledChanged);
            DescriptorsList.DeleteButton_IsEnabledChanged += new DependencyPropertyChangedEventHandler(DescriptorsList_DeleteButton_IsEnabledChanged);
        }
        public CellPropertiesControl()
        {
            InitializeComponent();

            PropertiesCtrl = new PropertiesListControl();
            TupleCtrl = new CellTupleControl();

            TabItem PropertiesTab = new TabItem();
            PropertiesTab.Header = Localization.Properties;
            PropertiesTab.Style = TabCtrl.Resources["TabControlOutputItem"] as Style;
            PropertiesTab.Content = PropertiesCtrl;

            TabItem TupleTab = new TabItem();
            TupleTab.Header = Localization.Tuple;
            TupleTab.Style = TabCtrl.Resources["TabControlOutputItem"] as Style;
            TupleTab.Content = TupleCtrl;

            TabCtrl.TabCtrl.Items.Add(PropertiesTab);
            TabCtrl.TabCtrl.Items.Add(TupleTab);

            TupleCtrl.HierarchyColumn.Width = PropertiesCtrl.PropertyColumnWidth;
            TupleCtrl.MemberColumn.Width = PropertiesCtrl.ValueColumnWidth;

            PropertiesTab.Header = Localization.Properties;
            TupleTab.Header = Localization.Tuple;

            TabToolBar toolBar = TabCtrl.ToolBar;
            if (toolBar != null)
            {
                RanetToolBarButton copyBtn = new RanetToolBarButton();
                ToolTipService.SetToolTip(copyBtn, Localization.CopyToClipboard_ToolTip);
                copyBtn.Content = UiHelper.CreateIcon(UriResources.Images.Copy16);
                toolBar.Stack.Children.Add(copyBtn);
                copyBtn.Click += new RoutedEventHandler(CopyButton_Click);
            }
        }
        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 UpdateablePivotGridControl()
		{
			RowDefinition row0 = new RowDefinition();
			row0.Height = GridLength.Auto;
			RowDefinition row1 = new RowDefinition();

			LayoutRoot.RowDefinitions.Add(row0);
			LayoutRoot.RowDefinitions.Add(row1);

			RefreshButton = new RanetToolBarButton();
			RefreshButton.Click += new RoutedEventHandler(RefreshButton_Click);
			RefreshButton.Content = UiHelper.CreateIcon(UriResources.Images.Refresh16);
			ToolTipService.SetToolTip(RefreshButton, Localization.PivotGrid_RefreshButton_ToolTip);

			ToBeginButton = new RanetToolBarButton();
			ToBeginButton.Click += new RoutedEventHandler(ToBeginButton_Click);
			ToBeginButton.Content = UiHelper.CreateIcon(UriResources.Images.ToBegin16);
			ToolTipService.SetToolTip(ToBeginButton, Localization.PivotGrid_ToBeginButton_ToolTip);

			BackButton = new RanetToolBarButton();
			BackButton.Click += new RoutedEventHandler(BackButton_Click);
			BackButton.Content = UiHelper.CreateIcon(UriResources.Images.Back16);
			ToolTipService.SetToolTip(BackButton, Localization.PivotGrid_BackButton_ToolTip);

			ForwardButton = new RanetToolBarButton();
			ForwardButton.Click += new RoutedEventHandler(ForwardButton_Click);
			ForwardButton.Content = UiHelper.CreateIcon(UriResources.Images.Forward16);
			ToolTipService.SetToolTip(ForwardButton, Localization.PivotGrid_ForwardButton_ToolTip);

			ToEndButton = new RanetToolBarButton();
			ToEndButton.Click += new RoutedEventHandler(ToEndButton_Click);
			ToEndButton.Content = UiHelper.CreateIcon(UriResources.Images.ToEnd16);
			ToolTipService.SetToolTip(ToEndButton, Localization.PivotGrid_ToEndButton_ToolTip);

			EditButton = new RanetToggleButton();
			ToolTipService.SetToolTip(EditButton, Localization.PivotGrid_EditButton_ToolTip);
			EditButton.Checked += new RoutedEventHandler(EditButton_Click);
			EditButton.Unchecked += new RoutedEventHandler(EditButton_Click);
			EditButton.Content = UiHelper.CreateIcon(UriResources.Images.EditCells16);

			UseChangesCasheButton = new RanetToggleButton();
			ToolTipService.SetToolTip(UseChangesCasheButton, Localization.PivotGrid_UseChangesCasheButton_ToolTip);
			UseChangesCasheButton.Checked += new RoutedEventHandler(UseChangesCasheButton_Checked);
			UseChangesCasheButton.Unchecked += new RoutedEventHandler(UseChangesCasheButton_Checked);
			UseChangesCasheButton.Content = UiHelper.CreateIcon(UriResources.Images.UseChangesCache16);

			CopyToClipboardButton = new RanetToolBarButton();
			ToolTipService.SetToolTip(CopyToClipboardButton, Localization.PivotGrid_CopyToClipboardButton_ToolTip);
			CopyToClipboardButton.Click += new RoutedEventHandler(CopyToClipboardoButton_Click);
			CopyToClipboardButton.Content = UiHelper.CreateIcon(UriResources.Images.Copy16);

			PasteFromClipboardButton = new RanetToolBarButton();
			ToolTipService.SetToolTip(PasteFromClipboardButton, Localization.PivotGrid_PasteFromClipboardButton_ToolTip);
			PasteFromClipboardButton.Click += new RoutedEventHandler(PasteFromClipboardoButton_Click);
			PasteFromClipboardButton.Content = UiHelper.CreateIcon(UriResources.Images.Paste16);

			ConfirmEditButton = new RanetToolBarButton(UriResources.Images.ConfirmEdit16, Localization.PivotGrid_ConfirmEditButton_Caption);
			ToolTipService.SetToolTip(ConfirmEditButton, Localization.PivotGrid_ConfirmEditButton_ToolTip);
			ConfirmEditButton.Click += new RoutedEventHandler(ConfirmEditButton_Click);

			CancelEditButton = new RanetToolBarButton();
			ToolTipService.SetToolTip(CancelEditButton, Localization.PivotGrid_CancelEditButton_ToolTip);
			CancelEditButton.Click += new RoutedEventHandler(CancelEditButton_Click);
			CancelEditButton.Content = UiHelper.CreateIcon(UriResources.Images.CancelEdit16);

			RestoreDefaultSizeButton = new RanetToolBarButton();
			ToolTipService.SetToolTip(RestoreDefaultSizeButton, Localization.PivotGrid_RestoreDefaultSize_ToolTip);
			RestoreDefaultSizeButton.Click += new RoutedEventHandler(RestoreDefaultSizeButton_Click);
			RestoreDefaultSizeButton.Content = UiHelper.CreateIcon(UriResources.Images.RestoreSize16);

			HideEmptyRowsButton = new RanetToggleButton();
			HideEmptyRowsButton.Click += new RoutedEventHandler(HideEmptyRowsButton_Click);
			HideEmptyRowsButton.Content = UiHelper.CreateIcon(UriResources.Images.HideEmptyRows16);
			ToolTipService.SetToolTip(HideEmptyRowsButton, Localization.PivotGrid_HideEmptyRowsButton_ToolTip);

			HideEmptyColumnsButton = new RanetToggleButton();
			HideEmptyColumnsButton.ClickMode = ClickMode.Press;
			HideEmptyColumnsButton.Click += new RoutedEventHandler(HideEmptyColumnsButton_Click);
			HideEmptyColumnsButton.Content = UiHelper.CreateIcon(UriResources.Images.HideEmptyColumns16);
			ToolTipService.SetToolTip(HideEmptyColumnsButton, Localization.PivotGrid_HideEmptyColumnsButton_ToolTip);

			GoToFocusedCellButton = new RanetToolBarButton();
			GoToFocusedCellButton.Click += new RoutedEventHandler(GoToFocusedCellButton_Click);
			GoToFocusedCellButton.Content = UiHelper.CreateIcon(UriResources.Images.ToFocused16);
			ToolTipService.SetToolTip(GoToFocusedCellButton, Localization.PivotGrid_GoToFocusedCellButton_ToolTip);

			ExportToExcelButton = new RanetToolBarButton();
			ToolTipService.SetToolTip(ExportToExcelButton, Localization.PivotGrid_ExportToExcelButton_ToolTip);
			ExportToExcelButton.Click += new RoutedEventHandler(ExportToExcelButton_Click);
			ExportToExcelButton.Content = UiHelper.CreateIcon(UriResources.Images.ExportToExcel16);

			RotateAxesButton = new RanetToggleButton();
			RotateAxesButton.ClickMode = ClickMode.Press;
			RotateAxesButton.Click += new RoutedEventHandler(RotateAxesButton_Click);
			RotateAxesButton.Content = UiHelper.CreateIcon(UriResources.Images.RotateAxes16);
			ToolTipService.SetToolTip(RotateAxesButton, Localization.PivotGrid_RotateAxesButton_ToolTip);

			HideHintsButton = new RanetToggleButton();
			HideHintsButton.ClickMode = ClickMode.Press;
			HideHintsButton.Click += new RoutedEventHandler(HideHintsButton_Click);
			HideHintsButton.Content = UiHelper.CreateIcon(UriResources.Images.HideHint16);
			ToolTipService.SetToolTip(HideHintsButton, Localization.PivotGrid_HideHintsButton_ToolTip);

			ConditionsDesignerButton = new RanetToggleButton();
			ConditionsDesignerButton.ClickMode = ClickMode.Press;
			ConditionsDesignerButton.Click += new RoutedEventHandler(ConditionsDesignerButton_Click);
			ConditionsDesignerButton.Content = UiHelper.CreateIcon(UriResources.Images.CellConditionsDesigner16);
			ConditionsDesignerButton.Visibility = Visibility.Collapsed;
			ToolTipService.SetToolTip(ConditionsDesignerButton, Localization.PivotGrid_CellsConditionsDesignerButton_ToolTip);

			ZoomControl = new ZoomingToolBarControl();
			ToolTipService.SetToolTip(ZoomControl, Localization.PivotGrid_ZoomingControl_ToolTip);
			ZoomControl.ValueChanged += new EventHandler(ZoomControl_ValueChanged);

			ToolBar.AddItem(RefreshButton);
			ToolBar.AddItem(m_NavigationButtons_Splitter);
			ToolBar.AddItem(ToBeginButton);
			ToolBar.AddItem(BackButton);
			ToolBar.AddItem(ForwardButton);
			ToolBar.AddItem(ToEndButton);
			NavigationToolBarSplitter = new RanetToolBarSplitter();
			ToolBar.AddItem(NavigationToolBarSplitter);
			ToolBar.AddItem(EditButton);
			ToolBar.AddItem(CopyToClipboardButton);
			ToolBar.AddItem(PasteFromClipboardButton);
			ToolBar.AddItem(UseChangesCasheButton);
			ToolBar.AddItem(ConfirmEditButton);
			ToolBar.AddItem(CancelEditButton);
			ToolBar.AddItem(new RanetToolBarSplitter());
			ToolBar.AddItem(RestoreDefaultSizeButton);
			ToolBar.AddItem(HideEmptyRowsButton);
			ToolBar.AddItem(HideEmptyColumnsButton);
			ToolBar.AddItem(GoToFocusedCellButton);
			ToolBar.AddItem(RotateAxesButton);
			ToolBar.AddItem(HideHintsButton);
			ToolBar.AddItem(ConditionsDesignerButton);
			ToolBar.AddItem(new RanetToolBarSplitter());
			ToolBar.AddItem(ExportToExcelButton);
			ToolBar.AddItem(ZoomControl);

			LayoutRoot.Children.Add(ToolBar);
			ToolBar.Margin = new Thickness(0, 0, 0, 3);

			// Сводная таблица
			//m_PivotGridPanel = new PivotGridPanel();
			//LayoutRoot.Children.Add(m_PivotGridPanel);
			//Grid.SetRow(m_PivotGridPanel, 1);

			m_PivotGrid = GetPivotGridControl();
			LayoutRoot.Children.Add(m_PivotGrid);
			Grid.SetRow(m_PivotGrid, 1);

			PivotGrid.ExecuteMemberAction += new MemberActionEventHandler(PivotGrid_ExecuteMemberAction);
			PivotGrid.CellValueChanged += new CellValueChangedEventHandler(CellsControl_CellValueChanged);
			PivotGrid.UndoCellChanges += new EventHandler(CellsControl_UndoCellChanges);
			PivotGrid.Cells_ContextMenuCreated += new EventHandler(CellsControl_ContextMenuCreated);
			PivotGrid.Columns_ContextMenuCreated += new EventHandler(ColumnsControl_ContextMenuCreated);
			PivotGrid.Rows_ContextMenuCreated += new EventHandler(RowsControl_ContextMenuCreated);
			PivotGrid.InitializeContextMenu += new EventHandler<CustomContextMenuEventArgs>(PivotGrid_InitializeContextMenu);

			UpdateToolbarButtons(null);
			UpdateEditToolBarButtons();

			grdIsWaiting = new Grid() { Background = new SolidColorBrush(Color.FromArgb(125, 0xFF, 0xFF, 0xFF)) };
			grdIsWaiting.Visibility = Visibility.Collapsed;
			BusyControl m_Waiting = new BusyControl();
			m_Waiting.Text = Localization.Loading;
			grdIsWaiting.Children.Add(m_Waiting);

			LayoutRoot.Children.Add(grdIsWaiting);
			Grid.SetColumnSpan(grdIsWaiting, LayoutRoot.ColumnDefinitions.Count > 0 ? LayoutRoot.ColumnDefinitions.Count : 1);
			Grid.SetRowSpan(grdIsWaiting, LayoutRoot.RowDefinitions.Count > 0 ? LayoutRoot.RowDefinitions.Count : 1);
			this.Content = LayoutRoot;

			PivotGrid.Cells_PerformControlAction += new EventHandler<ControlActionEventArgs<CellInfo>>(CellsControl_PerformControlAction);
			PivotGrid.Members_PerformControlAction += new EventHandler<ControlActionEventArgs<MemberControl>>(MembersArea_PerformControlAction);

			m_OlapDataLoader = GetOlapDataLoader();
			m_OlapDataLoader.DataLoaded += new EventHandler<DataLoaderEventArgs>(OlapDataLoader_DataLoaded);

			m_StorageManager = GetStorageManager();
			m_StorageManager.InvokeCompleted += new EventHandler<DataLoaderEventArgs>(StorageManager_ActionCompleted);

			// Метод Initialize необходимо вызывать для RotVisual элемента
			// всего приложения. Перенес его в ClientApp.
			//ScrollViewerMouseWheelSupport.Initialize(this);
			//m_ScrollableDataControl.ScrollView.AddMouseWheelSupport();

			this.KeyDown += new KeyEventHandler(UpdateablePivotGridControl_KeyDown);

			OlapTransactionManager.AfterCommandComplete += new EventHandler<TransactionCommandResultEventArgs>(AnalysisTransactionManager_AfterCommandComplete);
		}
        public ValueCopyDesignerControl()
        {
            Grid LayoutRoot = new Grid();
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            LayoutRoot.RowDefinitions.Add(new RowDefinition());

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

            // Контрол копирования данных
            m_CopyControl = new ValueCopyControl();
            m_CopyControl.IsAdminMode = true;
            LayoutRoot.Children.Add(m_CopyControl);
            Grid.SetRow(m_CopyControl, 1);

            RanetToolBarButton 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.ValueCopyControl_ImportSettings_ToolTip);
            m_ToolBar.AddItem(m_ImportLayout);

            RanetToolBarButton 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.ValueCopyControl_ExportSettings_ToolTip);
            m_ToolBar.AddItem(m_ExportLayout);

            m_ToolBar.AddItem(new RanetToolBarSplitter());

            RanetToolBarButton m_PreviewButton = new RanetToolBarButton();
            m_PreviewButton.Content = UiHelper.CreateIcon(UriResources.Images.Run16);
            m_PreviewButton.Click += new RoutedEventHandler(m_PreviewButton_Click);
            ToolTipService.SetToolTip(m_PreviewButton, Localization.ValueCopyControl_RunCopyForm_Tooltip);
            m_ToolBar.AddItem(m_PreviewButton);

            m_OlapDataLoader = GetOlapDataLoader();
            m_StorageManager = GetStorageManager();

            m_StorageManager.InvokeCompleted += new EventHandler<DataLoaderEventArgs>(StorageManager_ActionCompleted);
            m_OlapDataLoader.DataLoaded += new EventHandler<DataLoaderEventArgs>(OlapDataLoader_DataLoaded);

            grdIsWaiting = new Grid() { Background = new SolidColorBrush(Color.FromArgb(125, 0xFF, 0xFF, 0xFF)) };
            grdIsWaiting.Visibility = Visibility.Collapsed;
            BusyControl m_Waiting = new BusyControl();
            m_Waiting.Text = Localization.Loading;
            grdIsWaiting.Children.Add(m_Waiting);

            LayoutRoot.Children.Add(grdIsWaiting);
            Grid.SetColumnSpan(grdIsWaiting, LayoutRoot.ColumnDefinitions.Count > 0 ? LayoutRoot.ColumnDefinitions.Count : 1);
            Grid.SetRowSpan(grdIsWaiting, LayoutRoot.RowDefinitions.Count > 0 ? LayoutRoot.RowDefinitions.Count : 1);

            this.Content = LayoutRoot;
        }
        public MemberChoiceControl()
        {
            try
            {
                m_Initializing = true;
                Grid LayoutRoot = new Grid();
                LayoutRoot.RowDefinitions.Add(new RowDefinition());
                // Строка для кнопок
                //OK LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star), MinWidth = 50 });
                // Колонка для свойств
                LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { MinWidth = 50 });

                tabControl = new RanetTabControl();
                tabControl.TabCtrl.SelectionChanged += new SelectionChangedEventHandler(TabControl_SelectionChanged);

                membersTab = new TabItem();
                membersTab.Header = Localization.Members;
                membersTab.Style = tabControl.Resources["TabControlOutputItem"] as Style;

                findTab = new TabItem();
                findTab.Header = Localization.Find;
                findTab.Style = tabControl.Resources["TabControlOutputItem"] as Style;

                mdxSetTab = new TabItem();
                mdxSetTab.Header = Localization.MemberChoice_Selected;
                mdxSetTab.Style = tabControl.Resources["TabControlOutputItem"] as Style;

                tabControl.TabCtrl.Items.Add(membersTab);
                tabControl.TabCtrl.Items.Add(findTab);
                tabControl.TabCtrl.Items.Add(mdxSetTab);

                LayoutRoot.Children.Add(tabControl);

                //OK StackPanel buttonsPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
                //LayoutRoot.Children.Add(buttonsPanel);
                //Grid.SetRow(buttonsPanel, 1);

                //Border border = new Border() { BorderBrush = new SolidColorBrush(Colors.DarkGray), BorderThickness = new Thickness(1), Padding = new Thickness(5), Background = new SolidColorBrush(Colors.White) };
                //border.Child = LayoutRoot;

                // Растягиваем дерево
                Grid.SetColumnSpan(tabControl, 2);

                // Закладка MEMBERS
                Grid membersTab_LayoutRoot = new Grid();
                membersTab.Content = membersTab_LayoutRoot;
                membersTab_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                membersTab_LayoutRoot.RowDefinitions.Add(new RowDefinition());

                membersTree = new CustomTree() { BorderBrush = new SolidColorBrush(Colors.DarkGray) };
                membersTree.Margin = new Thickness(0, 3, 0, 0);
                membersTree.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(membersTree_SelectedItemChanged);
                membersTab_LayoutRoot.Children.Add(membersTree);
                Grid.SetRow(membersTree, 1);

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

                // Свойства элемента
                m_CurrentMemberControl = new PropertiesControl();
                m_CurrentMemberControl.Background = new SolidColorBrush(Color.FromArgb(0x7F, 128, 128, 128));
                m_CurrentMemberControl.PropertiesList.PropertyColumnWidth = new DataGridLength(100);
                m_PropertiesLayoutBorder = new Border() { BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x80, 0x80, 0x80)), BorderThickness = new Thickness(1) };
                m_PropertiesLayoutBorder.Child = m_CurrentMemberControl;
                LayoutRoot.Children.Add(m_PropertiesLayoutBorder);
                Grid.SetRow(m_PropertiesLayoutBorder, 0);
                Grid.SetColumn(m_PropertiesLayoutBorder, 1);

                // Прячем свойства
                m_PropertiesLayoutBorder.Visibility = Visibility.Collapsed;

                StackPanel members_toolBar = new StackPanel();
                members_toolBar.Orientation = Orientation.Horizontal;

                membersTab_LayoutRoot.Children.Add(members_toolBar);
                Grid.SetRow(members_toolBar, 0);
                Grid.SetColumnSpan(members_toolBar, 2);

                RanetToolBarButton Refresh_Button = new RanetToolBarButton();
                Refresh_Button.Margin = new Thickness(0, 0, 0, 0);
                Refresh_Button.Click += new RoutedEventHandler(RefreshButton_Click);
                Refresh_Button.Content = UiHelper.CreateIcon(UriResources.Images.Refresh16);
                ToolTipService.SetToolTip(Refresh_Button, Localization.MemberChoice_Refresh_ToolTip);
                members_toolBar.Children.Add(Refresh_Button);

                Clear_Choice_Button = new RanetToolBarButton();
                Clear_Choice_Button.Click += new RoutedEventHandler(Clear_Choice_Button_Click);
                Clear_Choice_Button.Content = UiHelper.CreateIcon(UriResources.Images.ClearChoice16);
                ToolTipService.SetToolTip(Clear_Choice_Button, Localization.MemberChoice_ClearSelection_ToolTip);
                members_toolBar.Children.Add(Clear_Choice_Button);

                Levels_ComboBox = new ComboBoxEx();
                Levels_ComboBox.Margin = new Thickness(2, 0, 0, 0);
                Levels_ComboBox.Width = 150;
                members_toolBar.Children.Add(Levels_ComboBox);

                //OK buttonsPanel.Margin = new Thickness(0, 5, 0, 0);
                //Grid.SetColumnSpan(buttonsPanel, 2);
                //OkButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 10, 0) };
                //OkButton.Content = Localization.DialogButton_Ok;
                //OkButton.Height = 22;
                //OkButton.Click += new RoutedEventHandler(OkButton_Click);
                //buttonsPanel.Children.Add(OkButton);
                //CancelButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 0, 0) };
                //CancelButton.Content = Localization.DialogButton_Cancel;
                //CancelButton.Height = 22;
                //CancelButton.Click += new RoutedEventHandler(CancelButton_Click);
                //buttonsPanel.Children.Add(CancelButton);

                membersTree.Special_MouseDoubleClick += new EventHandler<CustomEventArgs<CustomTreeNode>>(node_SpecialNodeExpanded);

                // Закладка ПОИСК
                Grid findTab_LayoutRoot = new Grid();
                findTab.Content = findTab_LayoutRoot;

                findTab_LayoutRoot.RowDefinitions.Add(new RowDefinition());
                findTab_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                findTab_LayoutRoot.RowDefinitions.Add(new RowDefinition());
                findTab_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(22) });

                filterBuilder = new FilterBuilderControl();
                filterBuilder.ApplyFilter += new EventHandler(filterBuilder_ApplyFilter);
                findTab_LayoutRoot.Children.Add(filterBuilder);

                RanetButton RunSearch_Button = new RanetButton();
                RunSearch_Button.Height = 22;
                RunSearch_Button.Width = 75;
                RunSearch_Button.Margin = new Thickness(2, 5, 0, 0);
                RunSearch_Button.Content = Localization.Find;
                RunSearch_Button.HorizontalAlignment = HorizontalAlignment.Right;
                RunSearch_Button.Click += new RoutedEventHandler(RunSearch_Button_Click);

                findTab_LayoutRoot.Children.Add(RunSearch_Button);
                Grid.SetRow(RunSearch_Button, 1);

                // Дерево с результатом поиска
                findResultTree = new CustomTree() { BorderBrush = new SolidColorBrush(Colors.DarkGray) };
                findResultTree.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(tree_SelectedItemChanged);
                findResultTree.Margin = new Thickness(0, 5, 0, 0);
                findTab_LayoutRoot.Children.Add(findResultTree);
                Grid.SetRow(findResultTree, 2);

                // Количество найденных элементов
                Grid find_buttons_panel = new Grid();
                find_buttons_panel.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                find_buttons_panel.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

                TextBlock m_Find_Results = new TextBlock() { Text = Localization.MemberChoice_MembersFound };
                m_Find_Results.VerticalAlignment = VerticalAlignment.Center;
                find_buttons_panel.Children.Add(m_Find_Results);

                m_Find_Count = new TextBlock() { Text = "0" };
                m_Find_Count.VerticalAlignment = VerticalAlignment.Center;
                find_buttons_panel.Children.Add(m_Find_Count);
                Grid.SetColumn(m_Find_Count, 1);

                findTab_LayoutRoot.Children.Add(find_buttons_panel);
                Grid.SetRow(find_buttons_panel, 3);

                // Закладка ВЫБРАННЫЕ
                Grid mdxSetTab_LayoutRoot = new Grid();
                mdxSetTab.Content = mdxSetTab_LayoutRoot;
                mdxSetTab_LayoutRoot.RowDefinitions.Add(new RowDefinition());
                mdxSetTab_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(22) });
                mdxSetTab_LayoutRoot.RowDefinitions.Add(new RowDefinition());

                selectedList = new CustomTree() { BorderBrush = new SolidColorBrush(Colors.DarkGray) };
                selectedList.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(tree_SelectedItemChanged);
                mdxSetTab_LayoutRoot.Children.Add(selectedList);

                // Количество выбранных элементов
                Grid selected_buttons_panel = new Grid();
                selected_buttons_panel.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                selected_buttons_panel.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

                TextBlock m_Selected_Results = new TextBlock() { Text = Localization.MemberChoice_MembersSelected };
                m_Selected_Results.Margin = new Thickness(0, 5, 0, 5);
                m_Selected_Results.VerticalAlignment = VerticalAlignment.Center;
                selected_buttons_panel.Children.Add(m_Selected_Results);

                m_Selected_Count = new TextBlock() { Text = "0" };
                m_Selected_Count.VerticalAlignment = VerticalAlignment.Center;
                m_Selected_Count.Margin = new Thickness(0, 5, 0, 5);
                selected_buttons_panel.Children.Add(m_Selected_Count);
                Grid.SetColumn(m_Selected_Count, 1);

                mdxSetTab_LayoutRoot.Children.Add(selected_buttons_panel);
                Grid.SetRow(selected_buttons_panel, 1);

                mdxSetTextBox = new SimpleTextBox() { AcceptsReturn = true, TextWrapping = TextWrapping.Wrap, IsReadOnly = true };
                mdxSetTextBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                mdxSetTextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                mdxSetTextBox.Margin = new Thickness(0, 0, 0, 0);
                mdxSetTextBox.BorderBrush = new SolidColorBrush(Colors.Black);
                mdxSetTab_LayoutRoot.Children.Add(mdxSetTextBox);
                Grid.SetRow(mdxSetTextBox, 2);

                SelectedItemChanged_Story = new Storyboard();
                SelectedItemChanged_Story.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
                SelectedItemChanged_Story.Completed += new EventHandler(SelectedItemChanged_Story_Completed);
                membersTab_LayoutRoot.Resources.Add("SelectedItemChanged_Story", SelectedItemChanged_Story);

                // Кнопка для отображения свойств элемента
                m_ShowMemberPropertiesButton = new RanetToggleButton();

                TabToolBar toolbar = tabControl.ToolBar;
                if (toolbar != null)
                {
                    ToolTipService.SetToolTip(m_ShowMemberPropertiesButton, Localization.MemberChoice_ShowMemberProperties_ToolTip);
                    m_ShowMemberPropertiesButton.Click += new RoutedEventHandler(SowMemberPropertiesButton_Click);
                    m_ShowMemberPropertiesButton.Content = UiHelper.CreateIcon(UriResources.Images.MemberProperty16);
                    toolbar.Stack.Children.Add(m_ShowMemberPropertiesButton);
                }

                this.Content = LayoutRoot;
            }
            finally {
                m_Initializing = false;
            }
        }
        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;
        }
        public DataSourceInfoControl()
        {
            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());
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            // Строка соединения
            TextBlock connectionString_Label = new TextBlock() { Text = Localization.Connection + ":" };
            LayoutRoot.Children.Add(connectionString_Label);

            connectionString = new RichTextBox() {IsReadOnly = true };
            connectionString.Height = 22;
            connectionString.Margin = new Thickness(0, 5, 0, 0);
            LayoutRoot.Children.Add(connectionString);
            Grid.SetRow(connectionString, 1);
            //connectionString.Background = new SolidColorBrush(Colors.Transparent);

            // Запрос
            queryInfoTabControl = new RanetTabControl();
            queryInfoTabControl.Margin = new Thickness(0, 5, 0, 0);
            LayoutRoot.Children.Add(queryInfoTabControl);
            Grid.SetRow(queryInfoTabControl, 2);

            // Закладка "MDX Query"
            TabItem queryTab = new TabItem();
            queryTab.Header = Localization.MDXQuery;
            queryTab.Style = queryInfoTabControl.Resources["TabControlOutputItem"] as Style;
            queryInfoTabControl.TabCtrl.Items.Add(queryTab);

            Grid queryTabLayoutRoot = new Grid() { Margin = new Thickness(0, 0, 0, 0) };
            queryTabLayoutRoot.RowDefinitions.Add(new RowDefinition());
            queryTabLayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            mdxQuery = new RichTextBox() { AcceptsReturn = true, TextWrapping = TextWrapping.Wrap, IsReadOnly = true };
            mdxQuery.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            mdxQuery.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            queryTabLayoutRoot.Children.Add(mdxQuery);
            Grid.SetRow(mdxQuery, 0);

            parseMdx = new CheckBox() { Margin = new Thickness(0, 5, 0, 0) };
            parseMdx.Content = Localization.DataSourceInfo_ShowParsedQuery;
            queryTabLayoutRoot.Children.Add(parseMdx);
            Grid.SetRow(parseMdx, 1);
            parseMdx.Checked += new RoutedEventHandler(parseMdx_CheckedChanged);
            parseMdx.Unchecked += new RoutedEventHandler(parseMdx_CheckedChanged);

            queryTab.Content = queryTabLayoutRoot;

            // Закладка "Moved Axes"
            TabItem movedAxesTab = new TabItem();
            movedAxesTab.Header = Localization.DataSourceInfo_MovedAxes;
            movedAxesTab.Style = queryInfoTabControl.Resources["TabControlOutputItem"] as Style;
            queryInfoTabControl.TabCtrl.Items.Add(movedAxesTab);

            Grid movedAxesTabLayoutRoot = new Grid() { Margin = new Thickness(0, 0, 0, 0) };
            movedAxesTabLayoutRoot.RowDefinitions.Add(new RowDefinition());
            movedAxesTabLayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            movedAxes_MdxQuery = new RichTextBox() { AcceptsReturn = true, TextWrapping = TextWrapping.Wrap, IsReadOnly = true };
            movedAxes_MdxQuery.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            movedAxes_MdxQuery.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            movedAxesTabLayoutRoot.Children.Add(movedAxes_MdxQuery);
            Grid.SetRow(movedAxes_MdxQuery, 0);

            parseMovedAxesMdx = new CheckBox() { Margin = new Thickness(0, 5, 0, 0) };
            parseMovedAxesMdx.Content = Localization.DataSourceInfo_ShowParsedQuery;
            movedAxesTabLayoutRoot.Children.Add(parseMovedAxesMdx);
            Grid.SetRow(parseMovedAxesMdx, 1);
            parseMovedAxesMdx.Checked += new RoutedEventHandler(parseMovedAxesMdx_CheckedChanged);
            parseMovedAxesMdx.Unchecked += new RoutedEventHandler(parseMovedAxesMdx_CheckedChanged);

            movedAxesTab.Content = movedAxesTabLayoutRoot;

            // Закладка "Update Script"
            scriptTab = new TabItem();
            scriptTab.Header = Localization.UpdateScript;
            scriptTab.Style = queryInfoTabControl.Resources["TabControlOutputItem"] as Style;
            queryInfoTabControl.TabCtrl.Items.Add(scriptTab);

            Grid scriptTabLayoutRoot = new Grid() { Margin = new Thickness(0, 0, 0, 0) };
            scriptTabLayoutRoot.RowDefinitions.Add(new RowDefinition());
            scriptTabLayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            updateScript = new RichTextBox() { AcceptsReturn = true, TextWrapping = TextWrapping.Wrap, IsReadOnly = true };
            updateScript.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            updateScript.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scriptTabLayoutRoot.Children.Add(updateScript);
            Grid.SetRow(updateScript, 0);

            parseUpdateScript = new CheckBox() { Margin = new Thickness(0, 5, 0, 0) };
            parseUpdateScript.Content = Localization.DataSourceInfo_ShowParsedScript;
            scriptTabLayoutRoot.Children.Add(parseUpdateScript);
            Grid.SetRow(parseUpdateScript, 1);
            parseUpdateScript.Checked += new RoutedEventHandler(parseUpdateScript_CheckedChanged);
            parseUpdateScript.Unchecked += new RoutedEventHandler(parseUpdateScript_CheckedChanged);

            scriptTab.Content = scriptTabLayoutRoot;
          
            this.Content = LayoutRoot;

            TabToolBar toolBar = queryInfoTabControl.ToolBar;
            if (toolBar != null)
            {
                RanetToolBarButton copyBtn = new RanetToolBarButton();
                ToolTipService.SetToolTip(copyBtn, Localization.CopyToClipboard_ToolTip);
                copyBtn.Content = UiHelper.CreateIcon(UriResources.Images.Copy16);
                toolBar.Stack.Children.Add(copyBtn);
                copyBtn.Click += new RoutedEventHandler(CopyButton_Click);
            }
        }
        public ValueCopyControl()
        {
            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());

            Grid Row0_LayoutRoot = new Grid();
            Row0_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            Row0_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            Row0_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            Row0_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            Row0_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            Row0_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            //Row0_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

            // Тип копирования
            TextBlock Label_CopyType = new TextBlock() { Text = Localization.ValueCopyControl_TypeOfCopying, Margin = new Thickness(0) };
            Row0_LayoutRoot.Children.Add(Label_CopyType);
            Grid.SetRow(Label_CopyType, 0);
            Grid.SetColumnSpan(Label_CopyType, 2);
            m_CopyType = new ComboBoxEx();
            m_CopyType.Margin = new Thickness(0, 5, 0, 0);
            
            ItemControlBase ctrl;
            ctrl = new ItemControlBase(false);
            ctrl.Text = Localization.ValueCopyControl_CopyValueFromSource;
            ctrl.Tag = ValueCopyTypes.CopyValueFromSource;
            m_CopyType.Combo.Items.Add(ctrl);
            ctrl = new ItemControlBase(false);
            ctrl.Text = Localization.ValueCopyControl_DeliveryValuePropotrionalSource;
            ctrl.Tag = ValueCopyTypes.DeliveryValuePropotrionalSource;
            m_CopyType.Combo.Items.Add(ctrl);
            Row0_LayoutRoot.Children.Add(m_CopyType);
            Grid.SetRow(m_CopyType, 1);
            Grid.SetColumnSpan(m_CopyType, 2);

            // Коэффициент
            TextBlock Label_Coefficient = new TextBlock() { Text = Localization.ValueCopyControl_Сoefficient, Margin = new Thickness(0, 5, 0, 0) };
            Row0_LayoutRoot.Children.Add(Label_Coefficient);
            Grid.SetRow(Label_Coefficient, 2);
            m_Coefficient = new RichTextBox() { Text = "1", Margin = new Thickness(0, 5, 0, 0) };
            Row0_LayoutRoot.Children.Add(m_Coefficient);
            Grid.SetRow(m_Coefficient, 3);

            // Значение
            TextBlock Label_Value = new TextBlock() { Text = Localization.ValueCopyControl_Value, Margin = new Thickness(5, 5, 0, 0) };
            Row0_LayoutRoot.Children.Add(Label_Value);
            Grid.SetRow(Label_Value, 2);
            Grid.SetColumn(Label_Value, 1);
            m_Value = new RichTextBox() { Text = "0", Margin = new Thickness(5, 5, 0, 0) };
            Row0_LayoutRoot.Children.Add(m_Value);
            Grid.SetRow(m_Value, 3);
            Grid.SetColumn(m_Value, 1);

            m_CopyType.SelectionChanged += new SelectionChangedEventHandler(m_CopyType_SelectionChanged);
            m_CopyType.Combo.SelectedIndex = 0;
            LayoutRoot.Children.Add(Row0_LayoutRoot);
            Grid.SetRow(Row0_LayoutRoot, 1);

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

            // Координаты
            TextBlock Label_Coordinates = new TextBlock() { Text = Localization.ValueCopyControl_Coordinates, Margin = new Thickness(0, 5, 0, 0) };
            Row1_LayoutRoot.Children.Add(Label_Coordinates);
            Grid.SetRow(Label_Coordinates, 0);
            m_Coordinates = new CoordinatesControl();
            m_Coordinates.GetOlapDataLoader += new EventHandler<GetIDataLoaderArgs>(m_Coordinates_GetOlapDataLoader);
            m_Coordinates.Margin = new Thickness(5);

            Border coordinates_Border = new Border() { Margin = new Thickness(0,5,0,0), BorderBrush = new SolidColorBrush(Colors.DarkGray), BorderThickness = new Thickness(1) };
            coordinates_Border.Child = m_Coordinates;
            Row1_LayoutRoot.Children.Add(coordinates_Border);
            Grid.SetRow(coordinates_Border, 1);

            LayoutRoot.Children.Add(Row1_LayoutRoot);
            Grid.SetRow(Row1_LayoutRoot, 2);

            // Ожидание загрузки
            m_Waiting = new BusyControl();
            m_Waiting.Text = Localization.Loading;
            Row1_LayoutRoot.Children.Add(m_Waiting);
            Grid.SetRow(m_Waiting, 2);

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

            RanetToolBarButton 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.ValueCopyControl_ImportSettings_ToolTip);
            m_ToolBar.AddItem(m_ImportLayout);

            RanetToolBarButton 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.ValueCopyControl_ExportSettings_ToolTip);
            m_ToolBar.AddItem(m_ExportLayout);

            IsBusy = false;
            this.Content = LayoutRoot;
        }