Example #1
0
        internal static bool IsValidImageResource(DesignerTheme designerTheme, string directory, string path)
        {
            Image image = GetImageFromPath(designerTheme, directory, path);
            bool  flag  = image != null;

            if (image != null)
            {
                image.Dispose();
            }
            return(flag);
        }
Example #2
0
        internal static Image GetImageFromPath(DesignerTheme designerTheme, string directory, string path)
        {
            Bitmap bitmap = null;

            if (path.Contains(Path.DirectorySeparatorChar.ToString()) && (directory.Length > 0))
            {
                string str = HttpUtility.UrlDecode(new Uri(new Uri(directory), path).LocalPath);
                if (File.Exists(str))
                {
                    try
                    {
                        bitmap = new Bitmap(str);
                    }
                    catch
                    {
                    }
                }
            }
            else if (designerTheme.DesignerType != null)
            {
                int length = path.LastIndexOf('.');
                if (length > 0)
                {
                    string baseName = path.Substring(0, length);
                    string name     = path.Substring(length + 1);
                    if (((baseName != null) && (baseName.Length > 0)) && ((name != null) && (name.Length > 0)))
                    {
                        try
                        {
                            ResourceManager manager = new ResourceManager(baseName, designerTheme.DesignerType.Assembly);
                            bitmap = manager.GetObject(name) as Bitmap;
                        }
                        catch
                        {
                        }
                    }
                }
            }
            if (bitmap != null)
            {
                bitmap.MakeTransparent(System.Workflow.Activities.DR.TransparentColor);
            }
            return(bitmap);
        }