void initPivotGridButton_Click(object sender, RoutedEventArgs e)
		{
			// pivotGridControl.URL = WSDataUrl;
			pivotGridControl.Connection = ConnectionStringId;
			pivotGridControl.Query = tbMdxQuery.Text;
			pivotGridControl.UpdateScript = tbUpdateScript.Text;
			pivotGridControl.MembersViewMode = (Ranet.AgOlap.Controls.ViewModeTypes)cbMembersViewMode.SelectedIndex;
			pivotGridControl.MemberVisualizationType = (Ranet.Olap.Core.Data.MemberVisualizationTypes)cbMemberVisualizationType.SelectedIndex;
			pivotGridControl.DataReorganizationType = (Ranet.Olap.Core.Providers.DataReorganizationTypes)cbDataReorganizationType.SelectedIndex;
			pivotGridControl.DefaultMemberAction = (Ranet.AgOlap.Controls.MemberClickBehaviorTypes)cbDefaultMemberAction.SelectedIndex;
			pivotGridControl.ColumnTitleClickBehavior = (Ranet.AgOlap.Controls.ColumnTitleClickBehavior)cbColumnTitleClickBehavior.SelectedIndex;
			pivotGridControl.DrillDownMode = (Ranet.AgOlap.Controls.DrillDownMode)cbDrillDownMode.SelectedIndex;
			pivotGridControl.IsUpdateable = ckbIsUpdateable.IsChecked.Value;
			pivotGridControl.AutoWidthColumns = ckbAutoWidthColumns.IsChecked.Value;
			pivotGridControl.ColumnsIsInteractive = ckbColumnsIsInteractive.IsChecked.Value;
			pivotGridControl.RowsIsInteractive = ckbRowsIsInteractive.IsChecked.Value;
			pivotGridControl.UseColumnsAreaHint = ckbUseColumnsAreaHint.IsChecked.Value;
			pivotGridControl.UseRowsAreaHint = ckbUseRowsAreaHint.IsChecked.Value;
			pivotGridControl.UseCellsAreaHint = ckbUseCellsAreaHint.IsChecked.Value;
			pivotGridControl.UseCellConditionsDesigner = ckbUseCellConditionsDesigner.IsChecked.Value;
			if (!pivotGridControl.UseCellConditionsDesigner)
			{
				var conds = new CellConditionsDescriptor("[Measures].[Internet Sales Amount]");
				var cellApp = new CellAppearanceObject(Colors.Cyan, Colors.Black, Colors.Black);
				cellApp.Options.UseBackColor = true;
				// cellApp.Options.UseBorderColor=true;
				var cond = new CellCondition(CellConditionType.GreaterOrEqual, 1000000.0, 1000000.0, cellApp);
				conds.Conditions.Add(cond);
				pivotGridControl.CustomCellsConditions = new List<CellConditionsDescriptor>();
				pivotGridControl.CustomCellsConditions.Add(conds);
			}
			pivotGridControl.Initialize();
		}
        void CalculateCustomCellCondidtions()
        {
            m_CustomCellCondidtions = null;
            m_CustomCellAppearance = null;

            if (Cell != null)
            {
                if (Owner != null && Owner.CustomCellsConditions != null && Owner.CustomCellsConditions.Count > 0)
                {
                    // Поиск условий, которые могут быть наложены на данную ячейку. 
                    // Перебираем всех предков по области столбцов и по их уникальному имени ищем
                    IList<MemberInfo> column_ascendants = this.Cell.ColumnMember.GetAncestors();
                    // column_ascendants - коллекция предков снизу вверх
                    foreach (MemberInfo member in column_ascendants)
                    {
                        // Ищем объект, содержащий условия для данного элемента по уникальному имени элемента
                        CellConditionsDescriptor conditions_descr = null;
                        foreach (CellConditionsDescriptor descr in Owner.CustomCellsConditions)
                        {
                            if (descr.MemberUniqueName == member.UniqueName)
                            {
                                conditions_descr = descr;
                                break;
                            }
                        }

                        List<CellCondition> usedConditions = null;
                        // Отбор условий, которым удовлетворяет значение ячейки
                        if (conditions_descr != null)
                        {
                            if (Cell.CellDescr != null &&
                                Cell.CellDescr.Value != null)
                            {
                                    try
                                    {
                                        double value = Cell.CellDescr.Value.Value != null ? Convert.ToDouble(Cell.CellDescr.Value.Value) : double.NaN;
                                        usedConditions = CellConditionsDescriptor.TestToConditions(value, conditions_descr);
                                    }
                                    catch (System.InvalidCastException)
                                    {
                                    }
                            }
                        }

                        if (usedConditions != null)
                        {
                            //Условий может быть несколько и они могут накладываться, например:
                            //1) > 0 и цвет фона - красный. 
                            //2) > 0 и шрифт жирный
                            //Поэтому для храненния накопленных условий использую m_CustomCellAppearance и потом буду использовать эту информацию при рисовании ячейки

                            //Проходим по списку условий и применяем настройки для ячейки
                            foreach (CellCondition cond in usedConditions)
                            {
                                if (m_CustomCellAppearance == null)
                                    m_CustomCellAppearance = new CellAppearanceObject();

                                if (cond.Appearance.Options.IgnoreAllOptions)
                                    continue;

                                if (cond.Appearance.Options.UseAllOptions ||
                                    cond.Appearance.Options.UseBackColor)
                                {
                                    m_CustomCellAppearance.Options.UseBackColor = true;
                                    m_CustomCellAppearance.BackColor = cond.Appearance.BackColor;
                                    //painter.CellArgs.StyleAppearance.BackColor2 =
                                    //    cond.Appearance.BackColor2;
                                    //painter.CellArgs.StyleAppearance.GradientMode =
                                    //    cond.Appearance.GradientMode;
                                }
                                if (cond.Appearance.Options.UseAllOptions ||
                                    cond.Appearance.Options.UseBorderColor)
                                {
                                    m_CustomCellAppearance.Options.UseBorderColor = true;
                                    m_CustomCellAppearance.BorderColor = cond.Appearance.BorderColor;
                                }
                                //if (cond.Appearance.Options.UseAllOptions ||
                                //    cond.Appearance.Options.UseFont)
                                //{
                                //    if (cond.Appearance.Font != null)
                                //    {
                                //        painter.CellArgs.StyleAppearance.Options.UseFont
                                //            = true;
                                //        painter.CellArgs.StyleAppearance.Font =
                                //            cond.Appearance.Font;
                                //    }
                                //}
                                if (cond.Appearance.Options.UseAllOptions ||
                                    cond.Appearance.Options.UseForeColor)
                                {
                                    m_CustomCellAppearance.Options.UseForeColor = true;
                                    m_CustomCellAppearance.ForeColor = cond.Appearance.ForeColor;
                                }

                                if (cond.Appearance.Options.IgnoreAllOptions ||
                                    !cond.Appearance.Options.ShowValue)
                                {
                                    m_CustomCellAppearance.Options.ShowValue = false;
                                }

                                //if (cond.Appearance.Options.UseAllOptions ||
                                //    cond.Appearance.Options.UseTextOptions)
                                //{
                                //    painter.CellArgs.StyleAppearance.Options.
                                //        UseTextOptions = true;

                                //    painter.CellArgs.StyleAppearance.TextOptions.
                                //        HAlignment =
                                //        cond.Appearance.TextOptions.HAlignment;
                                //    painter.CellArgs.StyleAppearance.TextOptions.
                                //        VAlignment =
                                //        cond.Appearance.TextOptions.VAlignment;
                                //    painter.CellArgs.StyleAppearance.TextOptions.
                                //        WordWrap = cond.Appearance.TextOptions.WordWrap;
                                //    painter.CellArgs.StyleAppearance.TextOptions.
                                //        Trimming = cond.Appearance.TextOptions.Trimming;
                                //}

                                if (cond.Appearance.Options.UseAllOptions ||
                                    cond.Appearance.Options.UseImage)
                                {
                                    m_CustomCellAppearance.Options.UseImage = true;
                                    m_CustomCellAppearance.CustomImage = cond.Appearance.CustomImage;
                                    m_CustomCellAppearance.CustomImageUri = cond.Appearance.CustomImageUri;
                                }

                                if (cond.Appearance.Options.UseAllOptions ||
                                    cond.Appearance.Options.UseProgressBar)
                                {
                                    m_CustomCellAppearance.Options.UseProgressBar = true;
                                    m_CustomCellAppearance.ProgressBarOptions = cond.Appearance.ProgressBarOptions;
                                }
                            }
                        }
                    }
                }
            }
        }
 public CellCondition(CellConditionType type, double val1, double val2, CellAppearanceObject appearance)
     : this(type, val1, val2)
 {
     m_Appearance = appearance;
 }
        public CellCondition(CellConditionType type, double val1, double val2, CellAppearanceObject appearance)
            : this(type, val1, val2)
        {

            m_Appearance = appearance;
        }