Exemplo n.º 1
0
        public static ELImg Parse(string tag)
        {
            ELImg img = new ELImg();

            if (tag == null)
            {
                return(img);
            }

            Match p = Regex.Match(tag, @"\bsrc\s*=\s*""(.+?)""", RegexOptions.IgnoreCase);

            if (p.Success)
            {
                img.src  = p.Groups[1].Value;
                img.path = ELSrcToPath(img.src);
            }

            p = Regex.Match(tag, @"\bwidth\s*=\s*""(\d+)""", RegexOptions.IgnoreCase);
            if (p.Success)
            {
                img.width = int.Parse(p.Groups[1].Value);
            }

            p = Regex.Match(tag, @"\bheight\s*=\s*""(\d+)""", RegexOptions.IgnoreCase);
            if (p.Success)
            {
                img.height = int.Parse(p.Groups[1].Value);
            }

            p = Regex.Match(tag, @"\bsize\s*=\s*""(\d+)\s*x\s*(\d+)""", RegexOptions.IgnoreCase);
            if (p.Success)
            {
                img.width  = int.Parse(p.Groups[1].Value);
                img.height = int.Parse(p.Groups[2].Value);
            }

            p = Regex.Match(tag, @"\bvalign\s*=\s*""(.+?)""", RegexOptions.IgnoreCase);
            if (p.Success)
            {
                img.valign = p.Groups[1].Value;
            }

            return(img);
        }
Exemplo n.º 2
0
        string fixImg(string text)
        {
            // <img src="C:\Jiver\tooltip album artwork\wvy.png" size="379x100">,

            Regex re  = new Regex("<img(.+?)>", RegexOptions.IgnoreCase);
            Match m   = re.Match(text);
            int   pos = 0;

            while (m.Success)
            {
                ELImg  img  = ELImg.Parse(m.Groups[1].Value);
                string html = img.ToHTML();

                text = text.Remove(m.Index, m.Length);
                text = text.Insert(m.Index, html);

                pos = m.Index + html.Length;
                m   = re.Match(text, pos);
            }
            return(text);
        }
Exemplo n.º 3
0
        public InsertImg(string tag) : this()
        {
            ELImg img = ELImg.Parse(tag);

            txtPath.Text = img.path ?? "";
            if (img.width > 0)
            {
                txtWidth.Text = img.width.ToString();
            }
            if (img.height > 0)
            {
                txtHeight.Text = img.height.ToString();
            }
            switch (img.valign?.ToLower())
            {
            case "top":
            case "middle":
            case "bottom":
                comboVAlign.Text  = img.valign;
                chkVAlign.Checked = true;
                break;
            }
            SelectedImg = img;
        }