www.pudn.com > Fetion.rar > CustomEmotionUtils.cs


namespace Imps.Client.Pc.CustomEmotionUI 
{ 
    using Imps.Client.Core; 
    using System; 
    using System.Drawing; 
    using System.Drawing.Imaging; 
 
    internal class CustomEmotionUtils 
    { 
        public static Image ClearImage(Image srcImage) 
        { 
            if (srcImage == null) 
            { 
                return null; 
            } 
            if (ImageAnimator.CanAnimate(srcImage)) 
            { 
                FrameDimension dimension = new FrameDimension(srcImage.FrameDimensionsList[0]); 
                int frameCount = srcImage.GetFrameCount(dimension); 
                Bitmap bitmap = null; 
                try 
                { 
                    srcImage.SelectActiveFrame(dimension, 0); 
                    bitmap = new Bitmap(srcImage); 
                    for (int i = 1; i < frameCount; i++) 
                    { 
                        srcImage.SelectActiveFrame(dimension, i); 
                    } 
                } 
                catch 
                { 
                    return bitmap; 
                } 
                if (bitmap != null) 
                { 
                    bitmap.Dispose(); 
                } 
            } 
            return srcImage; 
        } 
 
        public static string GetCustomEmotionStatusDesc(CustomEmotionStatus ceStatus, User currentUser) 
        { 
            switch (ceStatus) 
            { 
                case CustomEmotionStatus.OK: 
                    return "操作成功"; 
 
                case CustomEmotionStatus.ExistSameStartShortInSystemEmotions: 
                    return "存在左匹配相同的系统表情"; 
 
                case CustomEmotionStatus.ExistSameStartShort: 
                    return "存在左匹配相同的自定义表情"; 
 
                case CustomEmotionStatus.LimitExceeded: 
                    return "自定义表情的个数超过了限制"; 
 
                case CustomEmotionStatus.ShortCutExist: 
                    return "快捷键已经存在(自定义表情)"; 
 
                case CustomEmotionStatus.ShortCutExistSystemEmotion: 
                    return "快捷键已经存在(系统表情包括此快捷键)"; 
 
                case CustomEmotionStatus.FileNotFound: 
                    return "图片文件不存在"; 
 
                case CustomEmotionStatus.FileFormatError: 
                    return "文件格式不符合"; 
 
                case CustomEmotionStatus.FileLengthError: 
                    return string.Format("文件大小超过指定的大小(默认{0}K)", GetMaxEmotionPicSize(currentUser)); 
 
                case CustomEmotionStatus.FileSizeError: 
                    return string.Format("文件尺寸超过指定的大小(默认{0})", currentUser.Configuration.SystemSetting.SysConversationSetting.MaxEmotionPicRect); 
 
                case CustomEmotionStatus.FileExist: 
                    return "此表情已存在"; 
 
                case CustomEmotionStatus.SaveError: 
                    return "保存失败,IO错误"; 
 
                case CustomEmotionStatus.UnKonwError: 
                    return "未知错误"; 
            } 
            return "返回错误"; 
        } 
 
        public static int GetMaxEmotionPicSize(User currentUser) 
        { 
            return (currentUser.Configuration.SystemSetting.SysConversationSetting.MaxEmotionPicSize / 0x400); 
        } 
    } 
}