示例#1
0
        public Style Parse(string s)
        {
            if (s == null || s.Length == 0)
            {
                return(null);
            }
            styleStr = s.ToLower();
            Clear();
            try
            {
                AddParams();
                Style style = new Style();
                style.pen        = sbPen.GetPen();
                style.pen2       = sbPen2.GetPen();
                style.brush      = sbBrush.GetBrush();
                style.imageStyle = sbImage.GetImageStyle();
                style.textStyle  = sbText.GetTextStyle();
                style.extStyle   = sbExt.GetExtStyle();
                return(style.IsNull() ? null : style);
            }
            catch (Exception ex)
            {
//!!!				Log.Exception(ex);
            }
            return(null);
        }
示例#2
0
文件: Pen.cs 项目: AlexAbramov/mosaic
        public Pen GetPen()
        {
            Pen pen = null;

            if (sbBrush.Count > 0)
            {
                Brush br = sbBrush.GetBrush();
                if (br != null)
                {
                    pen = new Pen(br);
                }
            }
            if (pen == null)
            {
                string cStr = GetValue("c");
                if (cStr != null)
                {
                    Color c = GetColor(cStr, "c");
                    if (c.ToArgb() != 0)
                    {
                        pen = new Pen(c);
                    }
                }
            }
            if (pen != null)
            {
                for (int i = 0; i < Count; i++)
                {
                    string key = GetKey(i);
                    switch (key)
                    {
                    case "w":
                        string wStr = GetValue(i);
                        if (wStr != null)
                        {
                            float w = base.GetFloat(wStr, key);
                            if (!float.IsNaN(w))
                            {
                                pen.Width = w;
                            }
                        }
                        break;

                    case "ds":
                        string dsStr = GetValue(i);
                        if (dsStr != null)
                        {
                            object dsObj = base.GetEnum(typeof(DashStyle), dsStr, key);
                            if (dsObj != null)
                            {
                                pen.DashStyle = (DashStyle)dsObj;
                            }
                        }
                        break;
                    }
                }
            }
            return(pen);
        }