Esempio n. 1
0
        internal SLDataBar Clone()
        {
            var db = new SLDataBar();

            db.Is2010                               = Is2010;
            db.MinimumType                          = MinimumType;
            db.MinimumValue                         = MinimumValue;
            db.MaximumType                          = MaximumType;
            db.MaximumValue                         = MaximumValue;
            db.Color                                = Color.Clone();
            db.BorderColor                          = BorderColor.Clone();
            db.NegativeFillColor                    = NegativeFillColor.Clone();
            db.NegativeBorderColor                  = NegativeBorderColor.Clone();
            db.AxisColor                            = AxisColor.Clone();
            db.MinLength                            = MinLength;
            db.MaxLength                            = MaxLength;
            db.ShowValue                            = ShowValue;
            db.Border                               = Border;
            db.Gradient                             = Gradient;
            db.Direction                            = Direction;
            db.NegativeBarColorSameAsPositive       = NegativeBarColorSameAsPositive;
            db.NegativeBarBorderColorSameAsPositive = NegativeBarBorderColorSameAsPositive;
            db.AxisPosition                         = AxisPosition;

            return(db);
        }
Esempio n. 2
0
        /// <summary>
        /// 指定した軸色の長さ(最大値 - 最小値)を計算
        /// </summary>
        /// <param name="axis">軸色</param>
        /// <returns></returns>
        public int CalcAxisLength(AxisColor axis)
        {
            switch (axis)
            {
            case AxisColor.R:
                return(Pixels.Max(v => v.Color.R) - Pixels.Min(v => v.Color.R));

            case AxisColor.G:
                return(Pixels.Max(v => v.Color.G) - Pixels.Min(v => v.Color.G));

            case AxisColor.B:
                return(Pixels.Max(v => v.Color.B) - Pixels.Min(v => v.Color.B));
            }
            return(0);
        }
Esempio n. 3
0
        /// <summary>
        /// 軸色の値を返す
        /// </summary>
        /// <param name="axis">軸</param>
        /// <returns>軸色の値</returns>
        public byte GetAxisColor(AxisColor axis)
        {
            switch (axis)
            {
            case AxisColor.R:
            default:
                return(Color.R);

            case AxisColor.G:
                return(Color.G);

            case AxisColor.B:
                return(Color.B);
            }

            #endregion
        }
Esempio n. 4
0
        private SQLiteParameter[] GetSqlParameters()
        {
            List <SQLiteParameter> SqlParmColl = new List <SQLiteParameter>();

            try
            {
                SqlParmColl.Add(CommonDB.AddSqlParm("@ID", ID, DbType.Int64));
                SqlParmColl.Add(CommonDB.AddSqlParm("@DisplayID", DisplayID, DbType.Int64));
                SqlParmColl.Add(CommonDB.AddSqlParm("@oIndex", oIndex, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@DlgType", DlgType, DbType.Byte));
                SqlParmColl.Add(CommonDB.AddSqlParm("@DlgIndex", DlgIndex, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Left", Left, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Right", Right, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Top", Top, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Bottom", Bottom, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Y_ViewLable", Y_ViewLable, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@X_ViewLable", X_ViewLable, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Y_Index", Y_Index, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@X_Index", X_Index, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Fill", Fill, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@BackColor", BackColor.ToArgb(), DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@AxisColor", AxisColor.ToArgb(), DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@AxisWidth", AxisWidth, DbType.Int16));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Font", Font, DbType.String));
                SqlParmColl.Add(CommonDB.AddSqlParm("@FontColor", FontColor.ToArgb(), DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@LastRev", LastRev, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@LockPosition", LockPosition, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@LockEdit", LockEdit, DbType.Boolean));
                SqlParmColl.Add(CommonDB.AddSqlParm("@Layer", Layer, DbType.Int32));
                SqlParmColl.Add(CommonDB.AddSqlParm("@CompiledExp", CompiledExp, DbType.Binary));
                SqlParmColl.Add(CommonDB.AddSqlParm("@validexpression", validexpression, DbType.Boolean));
                return(SqlParmColl.ToArray());
            }
            catch (SQLiteException Exc)
            {
                throw Exc;
            }
        }
        internal SLDataBar2010 Clone()
        {
            var db = new SLDataBar2010();

            db.Cfvo1                                = Cfvo1.Clone();
            db.Cfvo2                                = Cfvo2.Clone();
            db.FillColor                            = FillColor.Clone();
            db.BorderColor                          = BorderColor.Clone();
            db.NegativeFillColor                    = NegativeFillColor.Clone();
            db.NegativeBorderColor                  = NegativeBorderColor.Clone();
            db.AxisColor                            = AxisColor.Clone();
            db.MinLength                            = MinLength;
            db.MaxLength                            = MaxLength;
            db.ShowValue                            = ShowValue;
            db.Border                               = Border;
            db.Gradient                             = Gradient;
            db.Direction                            = Direction;
            db.NegativeBarColorSameAsPositive       = NegativeBarColorSameAsPositive;
            db.NegativeBarBorderColorSameAsPositive = NegativeBarBorderColorSameAsPositive;
            db.AxisPosition                         = AxisPosition;

            return(db);
        }
Esempio n. 6
0
        internal SLDataBar2010 ToDataBar2010()
        {
            var db = new SLDataBar2010();

            switch (MinimumType)
            {
            case SLConditionalFormatAutoMinMaxValues.Automatic:
                db.Cfvo1.Type    = X14.ConditionalFormattingValueObjectTypeValues.AutoMin;
                db.Cfvo1.Formula = string.Empty;
                break;

            case SLConditionalFormatAutoMinMaxValues.Formula:
                db.Cfvo1.Type    = X14.ConditionalFormattingValueObjectTypeValues.Formula;
                db.Cfvo1.Formula = MinimumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Number:
                db.Cfvo1.Type    = X14.ConditionalFormattingValueObjectTypeValues.Numeric;
                db.Cfvo1.Formula = MinimumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Percent:
                db.Cfvo1.Type    = X14.ConditionalFormattingValueObjectTypeValues.Percent;
                db.Cfvo1.Formula = MinimumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Percentile:
                db.Cfvo1.Type    = X14.ConditionalFormattingValueObjectTypeValues.Percentile;
                db.Cfvo1.Formula = MinimumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Value:
                db.Cfvo1.Type    = X14.ConditionalFormattingValueObjectTypeValues.Min;
                db.Cfvo1.Formula = string.Empty;
                break;
            }

            switch (MaximumType)
            {
            case SLConditionalFormatAutoMinMaxValues.Automatic:
                db.Cfvo2.Type    = X14.ConditionalFormattingValueObjectTypeValues.AutoMax;
                db.Cfvo2.Formula = string.Empty;
                break;

            case SLConditionalFormatAutoMinMaxValues.Formula:
                db.Cfvo2.Type    = X14.ConditionalFormattingValueObjectTypeValues.Formula;
                db.Cfvo2.Formula = MaximumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Number:
                db.Cfvo2.Type    = X14.ConditionalFormattingValueObjectTypeValues.Numeric;
                db.Cfvo2.Formula = MaximumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Percent:
                db.Cfvo2.Type    = X14.ConditionalFormattingValueObjectTypeValues.Percent;
                db.Cfvo2.Formula = MaximumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Percentile:
                db.Cfvo2.Type    = X14.ConditionalFormattingValueObjectTypeValues.Percentile;
                db.Cfvo2.Formula = MaximumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Value:
                db.Cfvo2.Type    = X14.ConditionalFormattingValueObjectTypeValues.Max;
                db.Cfvo2.Formula = string.Empty;
                break;
            }

            db.FillColor           = Color.Clone();
            db.BorderColor         = BorderColor.Clone();
            db.NegativeFillColor   = NegativeFillColor.Clone();
            db.NegativeBorderColor = NegativeBorderColor.Clone();
            db.AxisColor           = AxisColor.Clone();
            db.MinLength           = MinLength;
            db.MaxLength           = MaxLength;
            db.ShowValue           = ShowValue;
            db.Border    = Border;
            db.Gradient  = Gradient;
            db.Direction = Direction;
            db.NegativeBarColorSameAsPositive       = NegativeBarColorSameAsPositive;
            db.NegativeBarBorderColorSameAsPositive = NegativeBarBorderColorSameAsPositive;
            db.AxisPosition = AxisPosition;

            return(db);
        }
        internal void FromDataBar(X14.DataBar db)
        {
            SetAllNull();

            using (var oxr = OpenXmlReader.Create(db))
            {
                var i = 0;
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(X14.ConditionalFormattingValueObject))
                    {
                        if (i == 0)
                        {
                            Cfvo1.FromConditionalFormattingValueObject(
                                (X14.ConditionalFormattingValueObject)oxr.LoadCurrentElement());
                            ++i;
                        }
                        else if (i == 1)
                        {
                            Cfvo2.FromConditionalFormattingValueObject(
                                (X14.ConditionalFormattingValueObject)oxr.LoadCurrentElement());
                            ++i;
                        }
                    }
                    else if (oxr.ElementType == typeof(X14.FillColor))
                    {
                        FillColor.FromFillColor((X14.FillColor)oxr.LoadCurrentElement());
                    }
                    else if (oxr.ElementType == typeof(X14.BorderColor))
                    {
                        BorderColor.FromBorderColor((X14.BorderColor)oxr.LoadCurrentElement());
                    }
                    else if (oxr.ElementType == typeof(X14.NegativeFillColor))
                    {
                        NegativeFillColor.FromNegativeFillColor((X14.NegativeFillColor)oxr.LoadCurrentElement());
                    }
                    else if (oxr.ElementType == typeof(X14.NegativeBorderColor))
                    {
                        NegativeBorderColor.FromNegativeBorderColor((X14.NegativeBorderColor)oxr.LoadCurrentElement());
                    }
                    else if (oxr.ElementType == typeof(X14.BarAxisColor))
                    {
                        AxisColor.FromBarAxisColor((X14.BarAxisColor)oxr.LoadCurrentElement());
                    }
                }
            }

            if (db.MinLength != null)
            {
                MinLength = db.MinLength.Value;
            }
            if (db.MaxLength != null)
            {
                MaxLength = db.MaxLength.Value;
            }
            if (db.ShowValue != null)
            {
                ShowValue = db.ShowValue.Value;
            }
            if (db.Border != null)
            {
                Border = db.Border.Value;
            }
            if (db.Gradient != null)
            {
                Gradient = db.Gradient.Value;
            }
            if (db.Direction != null)
            {
                Direction = db.Direction.Value;
            }
            if (db.NegativeBarColorSameAsPositive != null)
            {
                NegativeBarColorSameAsPositive = db.NegativeBarColorSameAsPositive.Value;
            }
            if (db.NegativeBarBorderColorSameAsPositive != null)
            {
                NegativeBarBorderColorSameAsPositive = db.NegativeBarBorderColorSameAsPositive.Value;
            }
            if (db.AxisPosition != null)
            {
                AxisPosition = db.AxisPosition.Value;
            }
        }
        internal X14.DataBar ToDataBar(bool RenderFillColor)
        {
            var db = new X14.DataBar();

            if (MinLength != 10)
            {
                db.MinLength = MinLength;
            }

            // according to Open XML specs, this cannot be more than 100 percent.
            if (MaxLength > 100)
            {
                MaxLength = 100;
            }
            if (MaxLength != 90)
            {
                db.MaxLength = MaxLength;
            }

            if (!ShowValue)
            {
                db.ShowValue = ShowValue;
            }
            if (Border)
            {
                db.Border = Border;
            }
            if (!Gradient)
            {
                db.Gradient = Gradient;
            }
            if (Direction != X14.DataBarDirectionValues.Context)
            {
                db.Direction = Direction;
            }
            if (NegativeBarColorSameAsPositive)
            {
                db.NegativeBarColorSameAsPositive = NegativeBarColorSameAsPositive;
            }
            if (!NegativeBarBorderColorSameAsPositive)
            {
                db.NegativeBarBorderColorSameAsPositive = NegativeBarBorderColorSameAsPositive;
            }
            if (AxisPosition != X14.DataBarAxisPositionValues.Automatic)
            {
                db.AxisPosition = AxisPosition;
            }

            db.Append(Cfvo1.ToConditionalFormattingValueObject());
            db.Append(Cfvo2.ToConditionalFormattingValueObject());

            // The condition is mainly if the priority of the parent rule exists. See Open XML specs.
            if (RenderFillColor)
            {
                db.Append(FillColor.ToFillColor());
            }

            if (Border)
            {
                db.Append(BorderColor.ToBorderColor());
            }
            if (!NegativeBarColorSameAsPositive)
            {
                db.Append(NegativeFillColor.ToNegativeFillColor());
            }
            if (!NegativeBarBorderColorSameAsPositive && Border)
            {
                db.Append(NegativeBorderColor.ToNegativeBorderColor());
            }
            if (AxisPosition != X14.DataBarAxisPositionValues.None)
            {
                db.Append(AxisColor.ToBarAxisColor());
            }

            return(db);
        }