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);
        }
        internal static Image GetImageFromPath(DesignerTheme designerTheme, string directory, string path)
        {
            Bitmap bitmap = null;

            if (path.Contains(Path.DirectorySeparatorChar.ToString()) && (directory.Length > 0))
            {
                string str = Uri.UnescapeDataString(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(AmbientTheme.TransparentColor);
            }
            return(bitmap);
        }
 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;
 }
 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;
 }
예제 #5
0
        internal static Image GetImageFromPath(DesignerTheme designerTheme, string directory, string path)
        {
            Bitmap image = null;
            if (path.Contains(Path.DirectorySeparatorChar.ToString()) && directory.Length > 0)
            {
                string imageFilePath = System.Web.HttpUtility.UrlDecode((new Uri(new Uri(directory), path).LocalPath));
                if (File.Exists(imageFilePath))
                {
                    try
                    {
                        image = new Bitmap(imageFilePath);
                    }
                    catch
                    {
                    }
                }
            }
            else if (designerTheme.DesignerType != null)
            {
                int index = path.LastIndexOf('.');
                if (index > 0)
                {
                    string nameSpace = path.Substring(0, index);
                    string name = path.Substring(index + 1);
                    if (nameSpace != null && nameSpace.Length > 0 &&
                        name != null && name.Length > 0)
                    {
                        try
                        {
                            ResourceManager resourceManager = new ResourceManager(nameSpace, designerTheme.DesignerType.Assembly);
                            image = resourceManager.GetObject(name) as Bitmap;
                        }
                        catch
                        {
                        }
                    }
                }
            }

            if (image != null)
                image.MakeTransparent(DR.TransparentColor);

            return image;
        }
예제 #6
0
 internal static bool IsValidImageResource(DesignerTheme designerTheme, string directory, string path)
 {
     Image image = GetImageFromPath(designerTheme, directory, path);
     bool validImage = (image != null);
     if (image != null)
         image.Dispose();
     return validImage;
 }
예제 #7
0
        internal DesignerTheme GetTheme(System.Type designerType)
        {
            bool          readOnly = this.ReadOnly;
            DesignerTheme item     = this.designerThemes.Contains(designerType.FullName) ? this.designerThemes[designerType.FullName] : null;

            try
            {
                this.ReadOnly = false;
                if ((item == null) || ((item.DesignerType != null) && !designerType.Equals(item.DesignerType)))
                {
                    bool flag2 = item != null;
                    ActivityDesignerThemeAttribute attribute = TypeDescriptor.GetAttributes(designerType)[typeof(ActivityDesignerThemeAttribute)] as ActivityDesignerThemeAttribute;
                    if (attribute == null)
                    {
                        throw new InvalidOperationException(DR.GetString("Error_ThemeAttributeMissing", new object[] { designerType.FullName }));
                    }
                    if (attribute.DesignerThemeType == null)
                    {
                        throw new InvalidOperationException(DR.GetString("Error_ThemeTypeMissing", new object[] { designerType.FullName }));
                    }
                    if (attribute.Xml.Length > 0)
                    {
                        Stream manifestResourceStream = designerType.Assembly.GetManifestResourceStream(designerType, attribute.Xml);
                        if (manifestResourceStream == null)
                        {
                            manifestResourceStream = designerType.Assembly.GetManifestResourceStream("System.Workflow.ComponentModel.Design.ActivityDesignerThemes." + attribute.Xml);
                        }
                        XmlReader reader = (manifestResourceStream != null) ? XmlReader.Create(manifestResourceStream) : null;
                        if (reader == null)
                        {
                            reader = XmlReader.Create(new StringReader(attribute.Xml));
                        }
                        if (reader != null)
                        {
                            DesignerSerializationManager serializationManager = new DesignerSerializationManager();
                            using (serializationManager.CreateSession())
                            {
                                ThemeSerializationProvider provider = new ThemeSerializationProvider();
                                try
                                {
                                    ((IDesignerSerializationManager)serializationManager).AddSerializationProvider(provider);
                                    ((IDesignerSerializationManager)serializationManager).Context.Push(this);
                                    WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();
                                    item = serializer.Deserialize(serializationManager, reader) as DesignerTheme;
                                    if ((item != null) && !attribute.DesignerThemeType.IsAssignableFrom(item.GetType()))
                                    {
                                        ((IDesignerSerializationManager)serializationManager).ReportError(new WorkflowMarkupSerializationException(DR.GetString("ThemeTypesMismatch", new object[] { attribute.DesignerThemeType.FullName, item.GetType().FullName })));
                                        item = null;
                                    }
                                    if (serializationManager.Errors.Count > 0)
                                    {
                                        string str = string.Empty;
                                        foreach (object obj2 in serializationManager.Errors)
                                        {
                                            str = str + obj2.ToString() + @"\n";
                                        }
                                    }
                                }
                                finally
                                {
                                    ((IDesignerSerializationManager)serializationManager).RemoveSerializationProvider(provider);
                                    reader.Close();
                                }
                            }
                        }
                    }
                    if (item == null)
                    {
                        try
                        {
                            item = Activator.CreateInstance(attribute.DesignerThemeType, new object[] { this }) as DesignerTheme;
                        }
                        catch
                        {
                            item = new ActivityDesignerTheme(this);
                        }
                    }
                    item.DesignerType = designerType;
                    item.ApplyTo      = designerType.FullName;
                    item.Initialize();
                    if (flag2)
                    {
                        this.designerThemes.Remove(designerType.FullName);
                    }
                    this.designerThemes.Add(item);
                }
                if (item.DesignerType == null)
                {
                    item.DesignerType = designerType;
                }
            }
            finally
            {
                this.ReadOnly = readOnly;
            }
            return(item);
        }