public CellConditionControl()
        {
            InitializeComponent();

            lblCondition.Text = Localization.ValueCondition_Label;
            AppearanceItem.Header = Localization.CellConditionControl_AppearanceItem;
            CellAppearanceItem.Header = Localization.CellConditionControl_CellAppearanceItem;
            ProgressBarItem.Header = Localization.CellConditionControl_ProgressBarItem;
            ImageItem.Header = Localization.CellConditionControl_ImageItem;
            lblShowValue.Text = Localization.ShowValue_Check;
            lblShowImage.Text = Localization.ShowImage_Check;
            lblShowProgressBar.Text = Localization.ShowProgressBar_Check;
            lblUseBackColor.Text = Localization.UseBackColor_Check;
            lblUseForeColor.Text = Localization.UseForeColor_Check;
            lblUseBorderColor.Text = Localization.UseBorderColor_Check;
            lblUseAllOptions.Text = Localization.UseAllOptions_Check;
            lblIgnoreAllOptions.Text = Localization.IgnoreAllOptions_Check;
            lblBackColor.Text = Localization.BackColor_Label;
            lblForeColor.Text = Localization.ForeColor_Label;
            lblBorderColor.Text = Localization.BorderColor_Label;
            lblMinValue.Text = Localization.MinValue_Label;
            lblMaxValue.Text = Localization.MaxValue_Label;
            lblStartColor.Text = Localization.StartColor_Label;
            lblEndColor.Text = Localization.EndColor_Label;
            lblImage.Text = Localization.Image_Label;
            btnChangeCustomImage.Content = Localization.ChangeCustomImage_Caption;

            // Стилизуем скроллеры
            StyleContainer styleContainer = new StyleContainer();
            if (styleContainer.Resources != null &&
                styleContainer.Resources.Contains("ScrollViewerGlowStyle"))
            {
                Scroller.Style = styleContainer.Resources["ScrollViewerGlowStyle"] as Style;
            }

            Ranet.AgOlap.Features.ScrollViewerMouseWheelSupport.AddMouseWheelSupport(Scroller);
        }
        public PivotGridControl()
        {
            IsTabStop = true;

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

            StyleContainer styleContainer = new StyleContainer();

            m_HorizontalScroll = new ScrollBar();
            m_HorizontalScroll.Orientation = Orientation.Horizontal;
            LayoutRoot.Children.Add(m_HorizontalScroll);
            Grid.SetColumn(m_HorizontalScroll, 0);
            Grid.SetRow(m_HorizontalScroll, 1);
            m_HorizontalScroll.SmallChange = 1;
            m_HorizontalScroll.LargeChange = 1;
            m_HorizontalScroll.Minimum = 0;
            m_HorizontalScroll.Maximum = 0;
            m_HorizontalScroll.Scroll += new ScrollEventHandler(m_HorizontalScroll_Scroll);
            m_HorizontalScroll.ValueChanged += new RoutedPropertyChangedEventHandler<double>(m_HorizontalScroll_ValueChanged);
            m_HorizontalScroll.Visibility = Visibility.Collapsed;

            m_VerticalScroll = new ScrollBar();
            m_VerticalScroll.Orientation = Orientation.Vertical;
            LayoutRoot.Children.Add(m_VerticalScroll);
            Grid.SetColumn(m_VerticalScroll, 1);
            Grid.SetRow(m_VerticalScroll, 0);
            m_VerticalScroll.SmallChange = 1;
            m_VerticalScroll.LargeChange = 1;
            m_VerticalScroll.Minimum = 0;
            m_VerticalScroll.Maximum = 0;
            m_VerticalScroll.Scroll += new ScrollEventHandler(m_VerticalScroll_Scroll);
            m_VerticalScroll.ValueChanged += new RoutedPropertyChangedEventHandler<double>(m_VerticalScroll_ValueChanged);
            m_VerticalScroll.Visibility = Visibility.Collapsed;

            if (styleContainer.Resources != null &&
                styleContainer.Resources.Contains("ScrollBarGlowStyle"))
            {
                m_HorizontalScroll.Style = styleContainer.Resources["ScrollBarGlowStyle"] as Style;
                m_VerticalScroll.Style = styleContainer.Resources["ScrollBarGlowStyle"] as Style;
            }

            ItemsLayoutRoot = new Grid();
            // Чтобы работало колесо мыши льём цветом
            ItemsLayoutRoot.Background = new SolidColorBrush(Colors.White);
            LayoutRoot.Children.Add(ItemsLayoutRoot);
            this.Content = LayoutRoot;

            m_VericalScroll_Timer = new Storyboard();
            m_VericalScroll_Timer.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 250));
            m_VericalScroll_Timer.Completed += new EventHandler(m_VericalScroll_Timer_Completed);
            LayoutRoot.Resources.Add("m_VericalScroll_Timer", m_VericalScroll_Timer);

            m_HorizontalScroll_Timer = new Storyboard();
            m_HorizontalScroll_Timer.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 250));
            m_HorizontalScroll_Timer.Completed += new EventHandler(m_HorizontalScroll_Timer_Completed);
            LayoutRoot.Resources.Add("m_HorizontalScroll_Timer", m_HorizontalScroll_Timer);

            GradientStopCollection stops = new GradientStopCollection();
            GradientStop stop0 = new GradientStop();
            stop0.Color = Colors.White;
            GradientStop stop1 = new GradientStop();
            stop1.Color = Colors.LightGray;
            stop1.Offset = 1;
            stops.Add(stop0);
            stops.Add(stop1);
            m_MembersBackground = new LinearGradientBrush(stops, 90);

            m_CellsBackground = new SolidColorBrush(Colors.White);
            m_CellsBorder = new SolidColorBrush(Colors.DarkGray);

            m_MembersBorder = new SolidColorBrush(Colors.DarkGray);

            //ItemsLayoutRoot.AttachContextMenu(p => GetCurrentContextMenu(p));
            UseContextMenu = true;

            this.KeyDown += new KeyEventHandler(SpanCellsAreaControl_KeyDown);
            ItemsLayoutRoot.KeyDown += new KeyEventHandler(SpanCellsAreaControl_KeyDown);
            this.GotFocus += new RoutedEventHandler(PivotGridControl_GotFocus);

            ItemsLayoutRoot.MouseEnter += new MouseEventHandler(CellsAreaControl_MouseEnter);
            ItemsLayoutRoot.MouseLeave += new MouseEventHandler(CellsAreaControl_MouseLeave);
            SelectionManager.SelectionChanged += new EventHandler(SelectionManager_SelectionChanged);

            m_Refresh_Timer = new Storyboard();
            m_Refresh_Timer.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 50));
            m_Refresh_Timer.Completed += new EventHandler(m_Refresh_Timer_Completed);
            LayoutRoot.Resources.Add("m_Refresh_Timer", m_Refresh_Timer);

            this.SizeChanged += new SizeChangedEventHandler(PivotGridControl_SizeChanged);

            m_VericalMouseWhellSupport = new ScrollBarMouseWheelSupport();
            m_VericalMouseWhellSupport.AddMouseWheelSupport(m_VerticalScroll);

            m_HorizontalMouseWhellSupport = new ScrollBarMouseWheelSupport() { IsHorizontal = true };
            m_HorizontalMouseWhellSupport.AddMouseWheelSupport(m_HorizontalScroll);

            TooltipManager = new TooltipController(this);
            TooltipManager.BeforeOpen += new EventHandler<CustomEventArgs<Point>>(TooltipManager_BeforeOpen);
            TooltipManager.ToolTipContent = new ToolTipControl();
        }