public object Clone()
        {
            StyleProperties styleProperties = (StyleProperties)MemberwiseClone();

            if (m_nameMap != null)
            {
                styleProperties.m_nameMap         = new Hashtable(m_nameMap.Count);
                styleProperties.m_valueCollection = new ArrayList(m_valueCollection.Count);
                {
                    foreach (DictionaryEntry item in m_nameMap)
                    {
                        styleProperties.m_nameMap.Add((string)item.Key, item.Value);
                        object obj   = m_valueCollection[(int)item.Value];
                        object value = null;
                        if (obj is string)
                        {
                            value = string.Copy(obj as string);
                        }
                        else if (obj is int)
                        {
                            value = (int)obj;
                        }
                        else if (obj is ReportSize)
                        {
                            value = ((ReportSize)obj).DeepClone();
                        }
                        styleProperties.m_valueCollection[(int)item.Value] = value;
                    }
                    return(styleProperties);
                }
            }
            return(styleProperties);
        }
Beispiel #2
0
 internal StyleEnumerator(StyleProperties sharedProps, StyleProperties nonSharedProps)
 {
     m_sharedProperties    = sharedProps;
     m_nonSharedProperties = nonSharedProps;
     m_total = 0;
     if (m_sharedProperties != null)
     {
         m_total += m_sharedProperties.Count;
     }
     if (m_nonSharedProperties != null)
     {
         m_total += m_nonSharedProperties.Count;
     }
 }
 internal void SetStyleProperty(string styleName, bool isExpression, bool needNonSharedProps, bool needSharedProps, object styleProperty)
 {
     if (isExpression)
     {
         if (needNonSharedProps)
         {
             if (m_nonSharedProperties == null)
             {
                 m_nonSharedProperties = new StyleProperties();
             }
             m_nonSharedProperties.Set(styleName, styleProperty);
         }
     }
     else if (needSharedProps)
     {
         if (m_sharedProperties == null)
         {
             m_sharedProperties = new StyleProperties(42);
         }
         m_sharedProperties.Set(styleName, styleProperty);
     }
 }
        public void SetStyle(Style.StyleName style, object value, bool isShared)
        {
            object obj  = null;
            bool   flag = false;

            switch (style)
            {
            case Style.StyleName.BorderColor:
            case Style.StyleName.BorderColorTop:
            case Style.StyleName.BorderColorLeft:
            case Style.StyleName.BorderColorRight:
            case Style.StyleName.BorderColorBottom:
            case Style.StyleName.BackgroundColor:
            case Style.StyleName.Color:
                if (value is ReportColor)
                {
                    obj = (value as ReportColor);
                }
                else if (value is string)
                {
                    obj = new ReportColor(value as string);
                }
                if (obj == null)
                {
                    throw new ReportRenderingException(ErrorCode.rrInvalidStyleArgumentType, "ReportColor");
                }
                obj  = ((ReportColor)obj).ToString();
                flag = true;
                break;

            case Style.StyleName.BorderStyle:
            case Style.StyleName.BorderStyleTop:
            case Style.StyleName.BorderStyleLeft:
            case Style.StyleName.BorderStyleRight:
            case Style.StyleName.BorderStyleBottom:
                if (value != null)
                {
                    obj = (value as string);
                    if (obj == null)
                    {
                        throw new ReportRenderingException(ErrorCode.rrInvalidStyleArgumentType, "String");
                    }
                    if (!Validator.ValidateBorderStyle(obj as string, out string _))
                    {
                        throw new ReportRenderingException(ErrorCode.rrInvalidBorderStyle, obj);
                    }
                }
                flag = true;
                break;

            case Style.StyleName.BorderWidth:
            case Style.StyleName.BorderWidthTop:
            case Style.StyleName.BorderWidthLeft:
            case Style.StyleName.BorderWidthRight:
            case Style.StyleName.BorderWidthBottom:
            case Style.StyleName.FontSize:
            case Style.StyleName.PaddingLeft:
            case Style.StyleName.PaddingRight:
            case Style.StyleName.PaddingTop:
            case Style.StyleName.PaddingBottom:
            case Style.StyleName.LineHeight:
                if (value is ReportSize)
                {
                    obj = (value as ReportSize);
                }
                else if (value is string)
                {
                    obj = new ReportSize(value as string);
                }
                if (obj == null)
                {
                    throw new ReportRenderingException(ErrorCode.rrInvalidStyleArgumentType, "ReportSize");
                }
                flag = true;
                break;

            case Style.StyleName.NumeralVariant:
            {
                if (!int.TryParse(value as string, out int result))
                {
                    throw new ReportRenderingException(ErrorCode.rrInvalidStyleArgumentType, "Int32");
                }
                obj  = result;
                flag = true;
                break;
            }

            default:
                if (value != null)
                {
                    obj = (value as string);
                    if (obj == null)
                    {
                        throw new ReportRenderingException(ErrorCode.rrInvalidStyleArgumentType, "String");
                    }
                }
                flag = true;
                break;
            }
            if (!flag)
            {
                return;
            }
            if (isShared)
            {
                if (m_sharedProperties == null)
                {
                    m_sharedProperties = new StyleProperties();
                }
                m_sharedProperties.Set(style.ToString(), obj);
            }
            else
            {
                if (m_nonSharedProperties == null)
                {
                    m_nonSharedProperties = new StyleProperties();
                }
                m_nonSharedProperties.Set(style.ToString(), obj);
            }
        }