Exemple #1
0
        internal void FromConditionalFormat(ConditionalFormat cf)
        {
            SetAllNull();

            if (cf.Scope != null)
            {
                Scope = cf.Scope.Value;
            }
            if (cf.Type != null)
            {
                Type = cf.Type.Value;
            }
            if (cf.Priority != null)
            {
                Priority = cf.Priority.Value;
            }

            SLPivotArea pa;

            using (var oxr = OpenXmlReader.Create(cf))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(PivotArea))
                    {
                        pa = new SLPivotArea();
                        pa.FromPivotArea((PivotArea)oxr.LoadCurrentElement());
                        PivotAreas.Add(pa);
                    }
                }
            }
        }
        private void ButtonOk_Click(object sender, EventArgs e)
        {
            ActiveSheet.ClearConditionalFormats(ActiveSheet.ActiveRowIndex, ActiveSheet.ActiveColumnIndex);

            ConditionalFormat format = Formats[0];

            format.ComparisonOperator = expressionControl1.ComparisonOperator;

            if (format.ComparisonOperator != ComparisonOperator.IsTrue &&
                format.ComparisonOperator != ComparisonOperator.IsFalse &&
                format.ComparisonOperator != ComparisonOperator.IsEmpty)
            {
                if (format.ComparisonOperator == ComparisonOperator.Between ||
                    format.ComparisonOperator == ComparisonOperator.NotBetween)
                {
                    format.FirstCondition = expressionControl1.StartValue;
                    format.LastCondition  = expressionControl1.EndValue;
                    if (!string.IsNullOrEmpty(format.FirstCondition) && !string.IsNullOrEmpty(format.LastCondition))
                    {
                        ActiveSheet.SetConditionalFormat(ActiveSheet.ActiveRowIndex, ActiveSheet.ActiveColumnIndex, 1, 1, format.Style, format.ComparisonOperator, format.FirstCondition, format.LastCondition);
                    }
                }
                else
                {
                    format.FirstCondition = expressionControl1.StartValue;
                    if (!string.IsNullOrEmpty(format.FirstCondition))
                    {
                        ActiveSheet.SetConditionalFormat(ActiveSheet.ActiveRowIndex, ActiveSheet.ActiveColumnIndex, 1, 1, format.Style, format.ComparisonOperator, format.FirstCondition);
                    }
                }
            }

            Close();
        }
        internal ConditionalFormat ToConditionalFormat()
        {
            ConditionalFormat cf = new ConditionalFormat();

            cf.PivotAreas = new PivotAreas()
            {
                Count = (uint)this.PivotAreas.Count
            };
            foreach (SLPivotArea pa in this.PivotAreas)
            {
                cf.PivotAreas.Append(pa.ToPivotArea());
            }

            if (this.Scope != ScopeValues.Selection)
            {
                cf.Scope = this.Scope;
            }
            if (this.Type != RuleValues.None)
            {
                cf.Type = this.Type;
            }
            cf.Priority = this.Priority;

            return(cf);
        }
Exemple #4
0
        /**
         * Gets the conditional formats
         *
         * @return the conditional formats
         */
        public ConditionalFormat[] getConditionalFormats()
        {
            ConditionalFormat[] formats = new ConditionalFormat[conditionalFormats.Count];
            int pos = 0;

            foreach (ConditionalFormat record in conditionalFormats)
            {
                formats[pos++] = record;
            }
            return(formats);
        }
        private void ConditionFormatDialog_Load(object sender, EventArgs e)
        {
            cBox_Value.Items.Add("单元格数值");

            cBox_Value.SelectedIndex = 0;

            //初始化活动单元格的条件格式化信息
            Formats = ActiveSheet.GetConditionalFormats(ActiveSheet.ActiveRowIndex, ActiveSheet.ActiveColumnIndex);
            if (Formats == null || Formats.Length == 0)
            {
                ConditionalFormat cf = new ConditionalFormat();
                cf.ComparisonOperator = ComparisonOperator.Between;
                cf.Style           = new NamedStyle();
                cf.Style.Font      = ActiveSheet.ActiveCell.Font;
                cf.Style.BackColor = Color.White;
                cf.Style.ForeColor = Color.Black;

                Formats = new ConditionalFormat[1] {
                    cf
                };
            }

            ConditionalFormat format = Formats[0];

            if (format.ComparisonOperator != ComparisonOperator.IsTrue &&
                format.ComparisonOperator != ComparisonOperator.IsFalse &&
                format.ComparisonOperator != ComparisonOperator.IsEmpty)
            {
                cBox_Value.SelectedIndex = 0;
            }

            if (cBox_Value.SelectedIndex == 0)
            {
                expressionControl1.BringToFront();

                expressionControl1.ComparisonOperator = format.ComparisonOperator;
                if (format.ComparisonOperator == ComparisonOperator.Between ||
                    format.ComparisonOperator == ComparisonOperator.NotBetween)
                {
                    expressionControl1.StartValue = format.FirstCondition;
                    expressionControl1.EndValue   = format.LastCondition;
                }
                else
                {
                    expressionControl1.StartValue = format.FirstCondition;
                }
            }

            UpdateExample(format.Style);
        }
Exemple #6
0
        private void StyleDialog_Load(object sender, EventArgs e)
        {
            ConditionalFormat format = Formats[0];

            Font_Regular.Checked   = (format.Style.Font.Style == FontStyle.Regular);
            Font_Bold.Checked      = (format.Style.Font.Style == FontStyle.Bold);
            Font_Italic.Checked    = (format.Style.Font.Style == FontStyle.Italic);
            Font_Strikeout.Checked = (format.Style.Font.Style == FontStyle.Strikeout);
            Font_Underline.Checked = (format.Style.Font.Style == FontStyle.Underline);

            label1.Font = format.Style.Font;

            ForeColorPicker.Value = format.Style.ForeColor;
            BackColorPicker.Value = format.Style.BackColor;
        }
        internal void FromConditionalFormat(ConditionalFormat cf)
        {
            this.SetAllNull();

            if (cf.Scope != null) this.Scope = cf.Scope.Value;
            if (cf.Type != null) this.Type = cf.Type.Value;
            if (cf.Priority != null) this.Priority = cf.Priority.Value;

            SLPivotArea pa;
            using (OpenXmlReader oxr = OpenXmlReader.Create(cf))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(PivotArea))
                    {
                        pa = new SLPivotArea();
                        pa.FromPivotArea((PivotArea)oxr.LoadCurrentElement());
                        this.PivotAreas.Add(pa);
                    }
                }
            }
        }
Exemple #8
0
        protected override object DoVisit(ConditionalFormat conditionalFormat)
        {
            // to catch errors, ignore result
            Visit(conditionalFormat.Argument);

            foreach (Case @case in conditionalFormat.Cases)
            {
                object conditionResult = Visit(@case.Condition);

                if (conditionResult == Error)
                {
                    // visit to catch errors, but ignore result
                    Visit(@case.FormatString);
                    continue;
                }

                if ((bool)conditionResult)
                {
                    return(Visit(@case.FormatString));
                }
            }

            return(string.Empty);
        }
        private void ButtonFormatDialog_Click(object sender, EventArgs e)
        {
            StyleDialog Dialog = new StyleDialog(Formats);

            if (DialogResult.OK == Dialog.ShowDialog())
            {
                ConditionalFormat format = Formats[0];

                FontStyle Style = FontStyle.Regular;
                if (Dialog.Font_Regular.Checked)
                {
                    Style = Style | FontStyle.Regular;
                }
                if (Dialog.Font_Bold.Checked)
                {
                    Style = Style | FontStyle.Bold;
                }
                if (Dialog.Font_Italic.Checked)
                {
                    Style = Style | FontStyle.Italic;
                }
                if (Dialog.Font_Strikeout.Checked)
                {
                    Style = Style | FontStyle.Strikeout;
                }
                if (Dialog.Font_Underline.Checked)
                {
                    Style = Style | FontStyle.Underline;
                }
                format.Style.Font      = new Font(format.Style.Font.FontFamily, format.Style.Font.Size, Style, format.Style.Font.Unit, format.Style.Font.GdiCharSet);
                format.Style.ForeColor = Dialog.ForeColorPicker.Value;
                format.Style.BackColor = Dialog.BackColorPicker.Value;

                UpdateExample(format.Style);
            }
        }
Exemple #10
0
        internal ConditionalFormat ToConditionalFormat()
        {
            var cf = new ConditionalFormat();

            cf.PivotAreas = new PivotAreas {
                Count = (uint)PivotAreas.Count
            };
            foreach (var pa in PivotAreas)
            {
                cf.PivotAreas.Append(pa.ToPivotArea());
            }

            if (Scope != ScopeValues.Selection)
            {
                cf.Scope = Scope;
            }
            if (Type != RuleValues.None)
            {
                cf.Type = Type;
            }
            cf.Priority = Priority;

            return(cf);
        }
        internal ConditionalFormat ToConditionalFormat()
        {
            ConditionalFormat cf = new ConditionalFormat();
            cf.PivotAreas = new PivotAreas() { Count = (uint)this.PivotAreas.Count };
            foreach (SLPivotArea pa in this.PivotAreas)
            {
                cf.PivotAreas.Append(pa.ToPivotArea());
            }

            if (this.Scope != ScopeValues.Selection) cf.Scope = this.Scope;
            if (this.Type != RuleValues.None) cf.Type = this.Type;
            cf.Priority = this.Priority;

            return cf;
        }
Exemple #12
0
 protected virtual object DoVisit(ConditionalFormat conditionalFormat)
 {
     return(Default(conditionalFormat));
 }
Exemple #13
0
        private void genarateData()
        {
            if (cmbJenisPel.Text.Equals("Rawat Jalan"))
            {
                this.pivotGridControl1.ItemSource = getDataRawatJalan();
            }
            else
            {
                this.pivotGridControl1.ItemSource = getDataRawatInap();
            }

            if (chkBoxSort.Checked)
            {
                this.pivotGridControl1.RowPivotsOnly = true;
            }
            else
            {
                this.pivotGridControl1.RowPivotsOnly = false;
                this.pivotGridControl1.PivotRows.Add(new PivotItem {
                    FieldMappingName = "diagnosa_grouper", FieldHeader = "Diagnosa", AllowSort = true
                });
            }

            this.pivotGridControl1.GridVisualStyles = GridVisualStyles.Metro;
            this.pivotGridControl1.PivotRows.Add(new PivotItem {
                FieldMappingName = "deskripsi", FieldHeader = "Deskripsi", AllowSort = true
            });
            this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo {
                FieldName = "no_sep", FieldHeader = "Total Kasus(SEP)", AllowSort = true
            });

            this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo {
                FieldName = "biaya_rs", FieldHeader = "Biaya RS", SummaryType = SummaryType.Sum, Format = "#,##0", AllowSort = true
            });

            this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo {
                FieldName = "iurPasien", FieldHeader = "Iuran Pasien", SummaryType = SummaryType.Sum, Format = "#,##0", AllowSort = true
            });

            this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo {
                FieldName = "potongan", FieldHeader = "Potongan", SummaryType = SummaryType.Sum, Format = "#,##0", AllowSort = true
            });

            this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo {
                FieldName = "COB", FieldHeader = "COB", SummaryType = SummaryType.Sum, Format = "#,##0", AllowSort = true
            });



            this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo {
                FieldName = "piutangRS", FieldHeader = "Piutang RS", SummaryType = SummaryType.Sum, Format = "#,##0", AllowSort = true, FieldCaption = "Piutang RS"
            });
            this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo {
                FieldName = "umbal", FieldHeader = "Umbal BPJS", SummaryType = SummaryType.Sum, Format = "#,##0", AllowSort = true
            });
            this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo {
                FieldName = "selisihUmbal", FieldHeader = "Selisih Dgn Umbal", SummaryType = SummaryType.Sum, Format = "#,##0", AllowSort = true, FieldCaption = "Selisih Umbal"
            });

            this.pivotGridControl1.ShowSubTotals         = false;
            this.pivotGridControl1.ShowPivotValueChooser = true;
            this.pivotGridControl1.TableControl.AllowRowPivotFiltering               = true;
            this.pivotGridControl1.TableControl.AllowRowResizeUsingCellBoundaries    = true;
            this.pivotGridControl1.TableControl.AllowColumnResizeUsingCellBoundaries = true;

            // this.pivotGridControl1.RowPivotsOnly = true;
            this.pivotGridControl1.AllowSorting          = true;
            pivotGridControl1.TableControl.FreezeHeaders = true;
            NewRuleConditionalFormat newRule1 = new NewRuleConditionalFormat();

            newRule1.RuleType       = RuleType.FormatOnlyCellsThatContain;
            newRule1.SummaryElement = "Selisih";

            ConditionalFormat condition1 = new ConditionalFormat();

            condition1.ConditionType = PivotGridDataConditionType.LessThan;
            condition1.StartValue    = 0;
            newRule1.Conditions.Add(condition1);

            PivotGridNewRuleConditionalFormat newRuleFormat1 = new PivotGridNewRuleConditionalFormat();

            newRuleFormat1.NewRuleCollections.Add(newRule1);
            newRuleFormat1.PivotCellStyle.BackColor = Color.Pink;
            newRuleFormat1.PivotCellStyle.TextColor = Color.White;
            this.pivotGridControl1.TableControl.NewRuleConditionalFormat.Add(newRuleFormat1);
            this.pivotGridControl1.Refresh();
            this.pivotGridControl1.ShowPivotTableFieldList = true;


            this.pivotGridControl1.ShowGroupBar = true;
            this.pivotGridControl1.PivotSchemaDesigner.RefreshGridSchemaLayout();
            pivotGridControl1.TableModel.Model.ColWidths[1] = 100;
            pivotGridControl1.TableModel.Model.ColWidths[2] = 400;
        }
Exemple #14
0
        /// <summary>
        /// Set the values for all the cell
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            bool isNeedColor = false;
            NewRuleConditionalFormat newRule1 = new NewRuleConditionalFormat();
            string RuleType = this.grdRuleType.Text;

            newRule1.RuleType = SetRuleType(RuleType);
            double number = 0;

            switch (RuleType)
            {
            case "Format Only Cells That Contain":
                ConditionalFormat form = new ConditionalFormat();
                form.ConditionType = SetConditionalType(cboRule2ConditionType.SelectedItem.ToString());
                form.PredicateType = SetPredicateType(cboRule2ConditionType.SelectedItem.ToString());
                if (!string.IsNullOrEmpty(txtRule2StartValue.Text) &&
                    double.TryParse(txtRule2StartValue.Text, out number))
                {
                    form.StartValue = Convert.ToDouble(txtRule2StartValue.Text);
                }
                if (!string.IsNullOrEmpty(txtRule2EndValue.Text) &&
                    double.TryParse(txtRule2EndValue.Text, out number))
                {
                    form.EndValue = Convert.ToDouble(txtRule2EndValue.Text);
                }
                newRule1.Conditions.Add(form);
                newRule1.SummaryElement = cboRule2SummaryElement.SelectedItem.ToString();
                isNeedColor             = true;
                break;

            case "Format Top Or Bottom Ranked Values":
                newRule1.FormateValuesRankType = SetFormateValuesRankType(cboRule3FormatRankType.SelectedItem.ToString());
                if (!string.IsNullOrEmpty(txtRule3RankValue.Text) &&
                    double.TryParse(txtRule3RankValue.Text, out number))
                {
                    newRule1.RankValue = Convert.ToInt32(Convert.ToDouble(txtRule3RankValue.Text.ToString()));
                }
                if (cboRule3SummaryElement.SelectedItem != null)
                {
                    newRule1.SummaryElement = cboRule3SummaryElement.SelectedItem.ToString();
                }
                isNeedColor = true;
                break;

            case "Format Only Values That Are Above Or Below Average":
                newRule1.FormateSelectedAverageValueType = SetFormateSelectedAverageValueType(cboRule4FormatValueType.SelectedItem.ToString());
                if (cboRule4SummaryElement.SelectedItem != null)
                {
                    newRule1.SummaryElement = cboRule4SummaryElement.SelectedItem.ToString();
                }
                isNeedColor = true;
                break;

            case "Format Only Unique Or Duplicate Values":
                newRule1.FormatAllType = SetFormatAllType(cboRule5FormatAllType.SelectedItem.ToString());
                if (cboRule5SummaryElement.SelectedItem != null)
                {
                    newRule1.SummaryElement = cboRule5SummaryElement.SelectedItem.ToString().Trim();
                }
                isNeedColor = true;
                break;

            default:
                if (cboRule1FormatStyle.SelectedIndex == 0)
                {
                    newRule1.FormatStyle = FormatStyle.IconSets;
                }
                if (cboRule1SummaryElement.SelectedItem != null)
                {
                    newRule1.SummaryElement = cboRule1SummaryElement.SelectedItem.ToString();
                }
                newRule1.Image = SetImageName(cboRule1ImageName.Text);
                isNeedColor    = false;
                if (cboValueType1.SelectedIndex == 0)
                {
                    newRule1.ValueType1 = Syncfusion.Windows.Forms.PivotAnalysis.ValueType.Percent;
                }
                else
                {
                    newRule1.ValueType1 = Syncfusion.Windows.Forms.PivotAnalysis.ValueType.Number;
                }
                if (cboValueType2.SelectedIndex == 0)
                {
                    newRule1.ValueType2 = Syncfusion.Windows.Forms.PivotAnalysis.ValueType.Percent;
                }
                else
                {
                    newRule1.ValueType2 = Syncfusion.Windows.Forms.PivotAnalysis.ValueType.Number;
                }
                if (cboValueType3.SelectedIndex == 0)
                {
                    newRule1.ValueType3 = Syncfusion.Windows.Forms.PivotAnalysis.ValueType.Percent;
                }
                else
                {
                    newRule1.ValueType3 = Syncfusion.Windows.Forms.PivotAnalysis.ValueType.Number;
                }
                if (cboValueType4.SelectedIndex == 0)
                {
                    newRule1.ValueType4 = Syncfusion.Windows.Forms.PivotAnalysis.ValueType.Percent;
                }
                else
                {
                    newRule1.ValueType4 = Syncfusion.Windows.Forms.PivotAnalysis.ValueType.Number;
                }
                break;
            }
            PivotGridNewRuleConditionalFormat newRuleFormat1 = new PivotGridNewRuleConditionalFormat();

            newRuleFormat1.NewRuleCollections.Add(newRule1);
            if (isNeedColor)
            {
                newRuleFormat1.PivotCellStyle.BackColor = Color.Red;
                newRuleFormat1.PivotCellStyle.TextColor = Color.White;
            }
            this.pivotGridControl1.TableControl.NewRuleConditionalFormat.Add(newRuleFormat1);
            this.pivotGridControl1.TableControl.Refresh(true);
        }
Exemple #15
0
        /// <summary>
        /// Load the form for Setting the Grid
        /// </summary>
        void Form1_Load(object sender, EventArgs e)
        {
            this.grdDropDown.BeginUpdate();
            this.grdDropDown.DataSource              = CreateTable();
            this.grdDropDown.DisplayMember           = "Name";
            this.grdDropDown.ValueMember             = "Id";
            this.grdDropDown.SelectionMode           = SelectionMode.One;
            this.grdDropDown.ShowColumnHeader        = false;
            this.grdDropDown.ThemesEnabled           = true;
            this.grdDropDown.Grid.VerticalThumbTrack = true;

            this.grdDropDown.Grid.DrawCellDisplayText += new Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventHandler(Grid_DrawCellDisplayText);
            this.grdDropDown.FillLastColumn            = true;
            this.grdDropDown.EndUpdate();
            this.grdDropDown.Grid.QueryCellInfo += new Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventHandler(Grid_QueryCellInfo);


            DataTable dtRuleType = new DataTable();

            dtRuleType.Columns.Add("RuleType");
            dtRuleType.Rows.Add("Format All Cells Based On Their Values");
            dtRuleType.Rows.Add("Format Only Cells That Contain");
            dtRuleType.Rows.Add("Format Top Or Bottom Ranked Values");
            dtRuleType.Rows.Add("Format Only Values That Are Above Or Below Average");
            dtRuleType.Rows.Add("Format Only Unique Or Duplicate Values");

            this.grdRuleType.DisplayMember           = "RuleType";
            this.grdRuleType.SelectionMode           = SelectionMode.One;
            this.grdRuleType.ShowColumnHeader        = false;
            this.grdRuleType.ThemesEnabled           = true;
            this.grdRuleType.Grid.VerticalThumbTrack = true;
            this.grdRuleType.DataSource     = dtRuleType;
            this.grdRuleType.FillLastColumn = true;

            this.grdRuleType.BorderStyle   = BorderStyle.FixedSingle;
            this.grdDropDown.BorderStyle   = BorderStyle.FixedSingle;
            this.grdDropDown.ThemesEnabled = false;
            this.grdRuleType.ThemesEnabled = false;

            // default selection
            this.grdRuleType.Grid.Model.Selections.Add(GridRangeInfo.Cell(1, 1));
            loadRule1Combobox();
            imageSelection(5);

            bool isNeedColor = false;
            NewRuleConditionalFormat newRule1 = new NewRuleConditionalFormat();
            string RuleType = this.grdRuleType.Text;

            newRule1.RuleType = SetRuleType(RuleType);
            ConditionalFormat form = new ConditionalFormat();

            cboRule2ConditionType.SelectedIndex = 0;
            form.ConditionType = SetConditionalType(cboRule2ConditionType.SelectedItem.ToString());
            form.PredicateType = SetPredicateType(cboRule2ConditionType.SelectedItem.ToString());
            if (!string.IsNullOrEmpty(txtRule2StartValue.Text))
            {
                form.StartValue = Convert.ToDouble(txtRule2StartValue.Text);
            }
            if (!string.IsNullOrEmpty(txtRule2EndValue.Text))
            {
                form.EndValue = Convert.ToDouble(txtRule2EndValue.Text);
            }
            newRule1.Conditions.Add(form);
            cboRule2SummaryElement.SelectedIndex = 0;
            this.cboRule1ImageName.TextBox.Text  = "3-Flag";
            newRule1.Image          = SetImageName(this.cboRule1ImageName.TextBox.Text);
            newRule1.SummaryElement = cboRule2SummaryElement.SelectedItem.ToString();
            isNeedColor             = true;
            PivotGridNewRuleConditionalFormat newRuleFormat1 = new PivotGridNewRuleConditionalFormat();

            newRuleFormat1.NewRuleCollections.Add(newRule1);
            if (isNeedColor)
            {
                newRuleFormat1.PivotCellStyle.BackColor = Color.Red;
                newRuleFormat1.PivotCellStyle.TextColor = Color.White;
            }
            this.pivotGridControl1.TableControl.NewRuleConditionalFormat.Add(newRuleFormat1);
            this.pivotGridControl1.TableControl.Refresh(true);
        }
Exemple #16
0
        private void ApplyConditionalFormat()
        {
            bool isNeedColor = false;
            NewRuleConditionalFormat newRule1 = new NewRuleConditionalFormat();
            string RuleType = grdRuleType.Text;

            newRule1.RuleType = SetRuleType(RuleType);
            double number;

            switch (RuleType)
            {
            case "Format all value cells based on certain criteria":
                ConditionalFormat form = new ConditionalFormat();
                form.ConditionType = SetConditionalType(cboRule2ConditionType.SelectedItem.ToString());
                form.PredicateType = SetPredicateType(cboRule2ConditionType.SelectedItem.ToString());
                if (!string.IsNullOrEmpty(txtRule2StartValue.Text) &&
                    double.TryParse(txtRule2StartValue.Text, out number))
                {
                    form.StartValue = Convert.ToDouble(txtRule2StartValue.Text);
                }
                if (!string.IsNullOrEmpty(txtRule2EndValue.Text) &&
                    double.TryParse(txtRule2EndValue.Text, out number))
                {
                    form.EndValue = Convert.ToDouble(txtRule2EndValue.Text);
                }
                newRule1.Conditions.Add(form);
                newRule1.SummaryElement = cboRule2SummaryElement.SelectedItem.ToString();
                isNeedColor             = true;
                break;

            case "Format top or bottom ranked value cells":
                newRule1.FormateValuesRankType = SetFormateValuesRankType(cboRule3FormatRankType.SelectedItem.ToString());
                if (!string.IsNullOrEmpty(txtRule3RankValue.Text) &&
                    double.TryParse(txtRule3RankValue.Text, out number))
                {
                    newRule1.RankValue = Convert.ToInt32(Convert.ToDouble(txtRule3RankValue.Text));
                }
                if (cboRule3SummaryElement.SelectedItem != null)
                {
                    newRule1.SummaryElement = cboRule3SummaryElement.SelectedItem.ToString();
                }
                isNeedColor = true;
                break;

            case "Format only value cells containing above or below average":
                newRule1.FormateSelectedAverageValueType = SetFormateSelectedAverageValueType(cboRule4FormatValueType.SelectedItem.ToString());
                if (cboRule4SummaryElement.SelectedItem != null)
                {
                    newRule1.SummaryElement = cboRule4SummaryElement.SelectedItem.ToString();
                }
                isNeedColor = true;
                break;

            case "Format only unique or duplicate value cells":
                newRule1.FormatAllType = SetFormatAllType(cboRule5FormatAllType.SelectedItem.ToString());
                if (cboRule5SummaryElement.SelectedItem != null)
                {
                    newRule1.SummaryElement = cboRule5SummaryElement.SelectedItem.ToString().Trim();
                }
                isNeedColor = true;
                break;

            default:
                if (cboRule1FormatStyle.SelectedIndex == 0)
                {
                    newRule1.FormatStyle = FormatStyle.IconSets;
                }
                if (cboRule1SummaryElement.SelectedItem != null)
                {
                    newRule1.SummaryElement = cboRule1SummaryElement.SelectedItem.ToString();
                }
                newRule1.Image = SetImageName(cboRule1ImageName.Text);
                if (cboValueType1.Enabled)
                {
                    newRule1.ValueType1 = cboValueType1.SelectedIndex == 0 ? ValueType.Percent : ValueType.Number;
                    newRule1.Value1     = double.Parse(txtValue1.Text);
                }
                if (cboValueType2.Enabled)
                {
                    newRule1.ValueType2 = cboValueType2.SelectedIndex == 0 ? ValueType.Percent : ValueType.Number;
                    newRule1.Value2     = double.Parse(txtValue2.Text);
                }
                if (cboValueType3.Enabled)
                {
                    newRule1.ValueType3 = cboValueType3.SelectedIndex == 0 ? ValueType.Percent : ValueType.Number;
                    newRule1.Value3     = double.Parse(txtValue3.Text);
                }
                if (cboValueType4.Enabled)
                {
                    newRule1.ValueType4 = cboValueType4.SelectedIndex == 0 ? ValueType.Percent : ValueType.Number;
                    newRule1.Value4     = double.Parse(txtValue4.Text);
                }
                break;
            }
            PivotGridNewRuleConditionalFormat newRuleFormat1 = new PivotGridNewRuleConditionalFormat();

            newRuleFormat1.NewRuleCollections.Add(newRule1);
            if (isNeedColor)
            {
                newRuleFormat1.PivotCellStyle.BackColor = Color.Red;
                newRuleFormat1.PivotCellStyle.TextColor = Color.White;
            }
            pivotGridControl1.TableControl.NewRuleConditionalFormat.Add(newRuleFormat1);
            pivotGridControl1.TableControl.Refresh(true);
        }
Exemple #17
0
 public object Visit(ConditionalFormat conditionalFormat)
 {
     return(DoVisit(Utilities.ThrowIfNull(conditionalFormat, "conditionalFormat")));
 }