Beispiel #1
0
        public static DrawInfo GetDrawInfoByXmlNode(XmlNode _node)
        {
            DrawInfo result;

            try
            {
                if (_node == null)
                {
                    throw new NullReferenceException();
                }
                string valueByAttribute = XmlCommomOp.GetValueByAttribute(_node, "Style");
                if (valueByAttribute == null)
                {
                    DrawDriverXmlOp.SetDrawInfoByXmlNode(_node);
                }
                DrawInfoString objString = new DrawInfoString();
                string[]       supportAttributeByXmlNode = DrawDriverXmlOp.GetSupportAttributeByXmlNode(_node);
                for (int i = 0; i < supportAttributeByXmlNode.Length; i++)
                {
                    DrawDriverXmlOp.SetStyle(ref objString, supportAttributeByXmlNode[i], _node, valueByAttribute);
                }
                DrawInfo drawInfo = CommonMethods.DrawInfoStringToDrawInfo(objString);
                result = drawInfo;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Beispiel #2
0
 public static DrawInfo DrawInfoStringToDrawInfo(DrawInfoString objString)
 {
     if (objString == null)
     {
         throw new NullReferenceException();
     }
     return(new DrawInfo
     {
         Left = CommonMethods.StringToInt32(objString.Left, 0),
         Top = CommonMethods.StringToInt32(objString.Top, 0),
         Width = CommonMethods.StringToInt32(objString.Width),
         Height = CommonMethods.StringToInt32(objString.Height),
         Align = CommonMethods.StringToAlignType(objString.Align, AlignType.Center),
         Valign = CommonMethods.StringToValignType(objString.Valign, ValignType.Middle),
         FontColor = CommonMethods.StringToFontColor(objString.FontColor, null),
         BgColor = CommonMethods.StringToColor(objString.BgColor),
         Border = CommonMethods.StringToBorder(objString.Border, null)
     });
 }
Beispiel #3
0
 private static void SetStyle(ref DrawInfoString objString, string strName, XmlNode _node, string strStyle)
 {
     try
     {
         if (objString == null)
         {
             throw new NullReferenceException();
         }
         if (strName == null)
         {
             throw new NullReferenceException();
         }
         if (_node == null)
         {
             throw new NullReferenceException();
         }
         if (strStyle == null)
         {
             throw new NullReferenceException();
         }
         if (strName.Trim().ToLower().Equals("left"))
         {
             objString.Left = XmlCommomOp.GetValueByAttribute(_node, strName);
             if (objString.Left == null)
             {
                 objString.Left = CommonMethods.GetStyleValue(strStyle, strName);
             }
         }
         else if (strName.Trim().ToLower().Equals("top"))
         {
             objString.Top = XmlCommomOp.GetValueByAttribute(_node, strName);
             if (objString.Top == null)
             {
                 objString.Top = CommonMethods.GetStyleValue(strStyle, strName);
             }
         }
         else if (strName.Trim().ToLower().Equals("width"))
         {
             objString.Width = XmlCommomOp.GetValueByAttribute(_node, strName);
             if (objString.Width == null)
             {
                 objString.Width = CommonMethods.GetStyleValue(strStyle, strName);
             }
         }
         else if (strName.Trim().ToLower().Equals("height"))
         {
             objString.Height = XmlCommomOp.GetValueByAttribute(_node, strName);
             if (objString.Height == null)
             {
                 objString.Height = CommonMethods.GetStyleValue(strStyle, strName);
             }
         }
         else if (strName.Trim().ToLower().Equals("align"))
         {
             objString.Align = XmlCommomOp.GetValueByAttribute(_node, strName);
             if (objString.Align == null)
             {
                 objString.Align = CommonMethods.GetStyleValue(strStyle, strName);
             }
         }
         else if (strName.Trim().ToLower().Equals("valign"))
         {
             objString.Valign = XmlCommomOp.GetValueByAttribute(_node, strName);
             if (objString.Valign == null)
             {
                 objString.Valign = CommonMethods.GetStyleValue(strStyle, strName);
             }
         }
         else if (strName.Trim().ToLower().Equals("fontcolor"))
         {
             objString.FontColor = XmlCommomOp.GetValueByAttribute(_node, strName);
             if (objString.FontColor == null)
             {
                 objString.FontColor = CommonMethods.GetStyleValue(strStyle, strName);
             }
         }
         else if (strName.Trim().ToLower().Equals("bgcolor"))
         {
             objString.BgColor = XmlCommomOp.GetValueByAttribute(_node, strName);
             if (objString.BgColor == null)
             {
                 objString.BgColor = CommonMethods.GetStyleValue(strStyle, strName);
             }
         }
         else if (strName.Trim().ToLower().Equals("border"))
         {
             objString.Border = XmlCommomOp.GetValueByAttribute(_node, strName);
             if (objString.Border == null)
             {
                 objString.Border = CommonMethods.GetStyleValue(strStyle, strName);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #4
0
        public static DrawInfoString StringToDrawInfoString(string str)
        {
            DrawInfoString result;

            try
            {
                if (str == null)
                {
                    throw new NullReferenceException();
                }
                DrawInfoString drawInfoString = new DrawInfoString();
                string[]       array          = str.Split(new char[]
                {
                    ';'
                });
                for (int i = 0; i < array.Length; i++)
                {
                    string text = array[i].Trim();
                    if (text.Length > 0)
                    {
                        string[] array2 = text.Split(new char[]
                        {
                            ':'
                        });
                        if (array2.Length >= 2)
                        {
                            string text2 = array2[0].Trim().ToLower();
                            string text3 = array2[1].Trim().ToLower();
                            if (text2.Equals("left"))
                            {
                                drawInfoString.Left = text3;
                            }
                            else if (text2.Equals("top"))
                            {
                                drawInfoString.Top = text3;
                            }
                            else if (text2.Equals("width"))
                            {
                                drawInfoString.Width = text3;
                            }
                            else if (text2.Equals("height"))
                            {
                                drawInfoString.Height = text3;
                            }
                            else if (text2.Equals("align"))
                            {
                                drawInfoString.Align = text3;
                            }
                            else if (text2.Equals("valign"))
                            {
                                drawInfoString.Valign = text3;
                            }
                            else if (text2.Equals("fontcolor"))
                            {
                                drawInfoString.FontColor = text3;
                            }
                            else if (text2.Equals("bgcolor"))
                            {
                                drawInfoString.BgColor = text3;
                            }
                            else if (text2.Equals("border"))
                            {
                                drawInfoString.Border = text3;
                            }
                        }
                    }
                }
                result = drawInfoString;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }