Exemple #1
0
        private static AContentItem CreateFromCsv(string[] tokens)
        {
            if (tokens.Length < 2)
            {
                return(null);
            }
            var name       = tokens[0].Trim().ToUpper();
            var parentName = tokens[1].ToUpper();

            if (name.Length == 0 || parentName.Length == 0)
            {
                return(null);
            }
            if (!resourceDic.ContainsKey(parentName))
            {
                return(null);
            }
            var parent = resourceDic[parentName];

            if (parent is BaseImage)
            {
                var parentImage = parent as BaseImage;
                parentImage.Load(Config.TextDrawingMode == TextDrawingMode.WINAPI);
                if (!parentImage.Enabled)
                {
                    return(null);
                }
                var rect     = new Rectangle(new Point(0, 0), parentImage.Bitmap.Size);
                var noresize = false;
                if (tokens.Length >= 6)
                {
                    var rectValue = new int[4];
                    var sccs      = true;
                    for (var i = 0; i < 4; i++)
                    {
                        sccs &= int.TryParse(tokens[i + 2], out rectValue[i]);
                    }
                    if (sccs)
                    {
                        rect = new Rectangle(rectValue[0], rectValue[1], rectValue[2], rectValue[3]);
                    }
                    if (tokens.Length >= 7)
                    {
                        var keywordTokens = tokens[6].Split('|');
                        foreach (var keyword in keywordTokens)
                        {
                            switch (keyword.Trim().ToUpper())
                            {
                            case "NORESIZE":
                                throw new NotImplCodeEE();
                                noresize = true;
                                break;
                            }
                        }
                    }
                }
                var image = new CroppedImage(name, parentImage, rect, noresize);
                return(image);
            }
            return(null);
        }
Exemple #2
0
        static private AContentItem CreateFromCsv(string[] tokens)
        {
            if (tokens.Length < 2)
            {
                return(null);
            }
            string name       = tokens[0].Trim().ToUpper();
            string parentName = tokens[1].ToUpper();

            if (name.Length == 0 || parentName.Length == 0)
            {
                return(null);
            }
            AContentFile parent = null;

            if (!resourceDic.TryGetValue(parentName, out parent))
            {
                return(null);
            }
            if (parent is BaseImage)
            {
                BaseImage parentImage = parent as BaseImage;
                //parentImage.Load(Config.TextDrawingMode == TextDrawingMode.WINAPI);
                parentImage.Load(false);
                if (!parentImage.Enabled)
                {
                    return(null);
                }
                Rectangle rect     = new Rectangle(new Point(0, 0), parentImage.Bitmap.size);
                bool      noresize = false;
                if (tokens.Length >= 6)
                {
                    int[] rectValue = new int[4];
                    bool  sccs      = true;
                    for (int i = 0; i < 4; i++)
                    {
                        sccs &= int.TryParse(tokens[i + 2], out rectValue[i]);
                    }
                    if (sccs)
                    {
                        rect = new Rectangle(rectValue[0], rectValue[1], rectValue[2], rectValue[3]);
                    }
                    if (tokens.Length >= 7)
                    {
                        string[] keywordTokens = tokens[6].Split('|');
                        foreach (string keyword in keywordTokens)
                        {
                            switch (keyword.Trim().ToUpper())
                            {
                            case "NORESIZE":
                                throw new NotImplCodeEE();
                                noresize = true;
                                break;
                            }
                        }
                    }
                }
                CroppedImage image = new CroppedImage(name, parentImage, rect, noresize);
                return(image);
            }
            return(null);
        }