Ejemplo n.º 1
0
        public static StructMark ExplodeMark(Glyphs gps)
        {
            StructMark result = default(StructMark);
            string     text   = gps.UnicodeString.Replace("{", "").Replace("}", "").Replace(" ", "");

            string[] array = text.Split(new char[]
            {
                ','
            });
            result.fontSize = gps.FontRenderingEmSize;
            result.y        = gps.OriginY;
            result.type     = text.Substring(0, 1);
            if (array[0].Contains("*"))
            {
                result.locat = "E";
            }
            else
            {
                result.locat = "B";
            }
            result.val = array[0].Replace("*", "");
            if (array.Length > 1)
            {
                result.len = Convert.ToInt32(array[1]);
                if (result.type == "%")
                {
                    result.width = (double)Convert.ToInt32(array[1]);
                    if (array.Length > 2)
                    {
                        result.height = (double)Convert.ToInt32(array[2]);
                    }
                }
            }
            else
            {
                if (result.type == "#")
                {
                    result.len = 1;
                }
                else
                {
                    result.len = 255;
                }
            }
            result.x = gps.OriginX;
            if (result.type == "#" && result.locat == "E")
            {
                result.x = gps.OriginX + result.fontSize * (double)(text.Length + 1) / 2.0;
                int len = result.len;
                result.x = result.x - (double)(len * 12) - (double)((len - 1) * 7) - 2.0;
            }
            if (result.type == "$" && result.locat == "E")
            {
                result.x = gps.OriginX + result.fontSize * (double)(text.Length + 2) / 2.0;
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static UIElement ReplaceMark(Glyphs gps, List <ListValue> dicVal)
        {
            StructMark Mk        = DrawItems.ExplodeMark(gps);
            double     fontSize  = Mk.fontSize;
            double     orgX      = Mk.x;
            double     y         = Mk.y;
            UIElement  result    = new UIElement();
            ListValue  listValue = new ListValue();

            listValue = (
                from m in dicVal
                where m.strMark == Mk.val.Trim()
                select m).FirstOrDefault <ListValue>();
            if (listValue == null)
            {
                listValue         = new ListValue();
                listValue.strMark = Mk.val;
                listValue.strVal  = "";
            }
            else
            {
                if (listValue.strVal == null)
                {
                    listValue.strVal = "";
                }
            }
            if (Mk.val.Contains("archiveid"))
            {
                if (listValue.strType == "1")
                {
                    result = DrawItems.CreatArchiveid(listValue.strVal, orgX, y, fontSize);
                }
                else
                {
                    result = DrawItems.CreatShortArchiveid(listValue.strVal, orgX, y, fontSize);
                }
            }
            else
            {
                if (Mk.type == "#")
                {
                    result = DrawItems.CreatCheck(listValue.strVal, orgX, y, fontSize, Mk.len);
                }
                else
                {
                    if (Mk.type == "!")
                    {
                        result = DrawItems.CreatDate(listValue.strVal, orgX, y, fontSize);
                    }
                    else
                    {
                        if (Mk.type == "%")
                        {
                            result = DrawItems.CreatGlyphs(listValue.strVal, orgX, y, fontSize, Mk.width, Mk.height);
                        }
                        else if (Mk.type == "^")
                        {
                            result = DrawItems.CreatTitleGlyphs(listValue.strVal, orgX, y, fontSize);
                        }
                        else
                        {
                            if (Mk.type == "@")
                            {
                                if (listValue.strVal == "1")
                                {
                                    result = DrawItems.DrawCheck(orgX, y, 20.0);
                                }
                            }
                            else if (Mk.type == "&")
                            {
                                if (Mk.val.Contains("photo"))
                                {
                                    result = DrawItems.DrawImagePhoto(listValue.strVal, orgX, y);
                                }
                                else if (Mk.val.Contains("bchao"))
                                {
                                    result = DrawItems.DrawImageBChao(listValue.strVal, orgX, y);
                                }
                                else if (Mk.val.Contains("ecg"))
                                {
                                    result = DrawItems.DrawImageEcg(listValue.strVal, orgX, y);
                                }
                                else
                                {
                                    result = DrawItems.DrawImage(listValue.strVal, orgX, y);
                                }
                            }
                            else
                            {
                                if (Mk.locat == "E")
                                {
                                    int length = listValue.strVal.Length;
                                    orgX = Mk.x - (double)length * fontSize / 2.0;
                                }
                                //result = DrawItems.CreatGlyphs(listValue.strVal, orgX, y, fontSize, false, Mk.len, false);
                                result = DrawItems.CreatGlyphs(listValue.strVal, orgX, y, fontSize, false, listValue.strVal.Length, false);
                            }
                        }
                    }
                }
            }
            return(result);
        }