Beispiel #1
0
        void _Insert(string s)
        {
            var sci  = InsertInControl;
            var pos8 = sci.Z.CurrentPos8;

            switch (s)
            {
            case "text": _AddParameter(sci, pos8, ", (KText)\"%\""); return;

            case "sleepMs": _AddParameter(sci, pos8, ", 100"); return;

            case "keyCode": _AddParameter(sci, pos8, ", KKey.Left"); return;

            case "scanCode": _AddParameter(sci, pos8, ", (1, false)"); return;

            case "action": _AddParameter(sci, pos8, ", new Action(() => { AMouse.RightClick(); })"); return;
            }

            if (s.Length == 2 && s[0] != '#' && !AChar.IsAsciiAlpha(s[0]))
            {
                s = s[0] == '\\' ? "|" : s[..1];                                                                       //eg 2@ or /? or \|
Beispiel #2
0
        /// <summary>
        /// Gets image type from string.
        /// </summary>
        /// <param name="anyFile">When the string is valid but not of any image type, return ShellIcon instead of None.</param>
        /// <param name="s">File path etc. See <see cref="ImageType"/>.</param>
        /// <param name="length">If -1, calls CharPtr_.Length(s).</param>
        internal static ImageType ImageTypeFromString(bool anyFile, byte *s, int length = -1)
        {
            if (length < 0)
            {
                length = BytePtr_.Length(s);
            }
            if (length < (anyFile ? 2 : 8))
            {
                return(ImageType.None);                                       //C:\x.bmp or .h
            }
            char c1 = (char)s[0], c2 = (char)s[1];

            //special strings
            switch (c1)
            {
            case '~': return((c2 == ':') ? ImageType.Base64CompressedBmp : ImageType.None);

            case 'i': if (BytePtr_.AsciiStarts(s, "image:"))
                {
                    return(ImageType.Base64PngGifJpg);
                }
                break;

            case 'r': if (BytePtr_.AsciiStarts(s, "resource:"))
                {
                    return(ImageType.Resource);
                }
                break;
            }

            //file path
            if (length >= 8 && (c1 == '%' || (c2 == ':' && AChar.IsAsciiAlpha(c1)) || (c1 == '\\' && c2 == '\\')))              //is image file path?
            {
                byte *ext = s + length - 3;
                if (ext[-1] == '.')
                {
                    if (BytePtr_.AsciiStartsi(ext, "bmp"))
                    {
                        return(ImageType.Bmp);
                    }
                    if (BytePtr_.AsciiStartsi(ext, "png"))
                    {
                        return(ImageType.PngGifJpg);
                    }
                    if (BytePtr_.AsciiStartsi(ext, "gif"))
                    {
                        return(ImageType.PngGifJpg);
                    }
                    if (BytePtr_.AsciiStartsi(ext, "jpg"))
                    {
                        return(ImageType.PngGifJpg);
                    }
                    if (BytePtr_.AsciiStartsi(ext, "ico"))
                    {
                        return(ImageType.Ico);
                    }
                    if (BytePtr_.AsciiStartsi(ext, "cur"))
                    {
                        return(ImageType.Cur);
                    }
                    if (BytePtr_.AsciiStartsi(ext, "ani"))
                    {
                        return(ImageType.Cur);
                    }
                }
                else if (AChar.IsAsciiDigit(ext[2]))                    //can be like C:\x.dll,10
                {
                    byte *k = ext + 1, k2 = s + 8;
                    for (; k > k2; k--)
                    {
                        if (!AChar.IsAsciiDigit(*k))
                        {
                            break;
                        }
                    }
                    if (*k == '-')
                    {
                        k--;
                    }
                    if (*k == ',' && k[-4] == '.' && AChar.IsAsciiAlpha(k[-1]))
                    {
                        return(ImageType.IconLib);
                    }
                }
            }

            if (anyFile)
            {
                return(ImageType.ShellIcon);                    //can be other file type, URL, .ext, :: ITEMIDLIST, ::{CLSID}
            }
            return(ImageType.None);
        }