⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 impsresources.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client
{
    using Imps.Utils;
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Globalization;
    using System.IO;
    using System.Reflection;
    using System.Resources;
    using System.Threading;
    using System.Windows.Forms;

    public sealed class ImpsResources
    {
        private static CultureInfo _impsCulture;
        private static string[] _localeDirs;
        private static Assembly _ourAssembly;
        private const string _ourNamespace = "Imps.Client.Resource";
        private static ResourceManager _resourceManager;

        static ImpsResources()
        {
            Initialize();
        }

        private ImpsResources()
        {
        }

        private static bool CheckForSignature(Stream input, byte[] signature)
        {
            long position = input.Position;
            byte[] buffer = new byte[signature.Length];
            int num2 = input.Read(buffer, 0, buffer.Length);
            bool flag = false;
            if (num2 == signature.Length)
            {
                flag = true;
                for (int i = 0; i < signature.Length; i++)
                {
                    flag &= signature[i] == buffer[i];
                }
            }
            input.Position = position;
            return flag;
        }

        private static ResourceManager CreateResourceManager()
        {
            return ResourceManager.CreateFileBasedResourceManager("ImpsResources.Strings", ResourcesDir, null);
        }

        public static Cursor GetCursor(string cursorName)
        {
            return new Cursor(GetResourceStream(cursorName));
        }

        public static Icon GetIcon(string fileName)
        {
            Stream resourceStream = GetResourceStream(fileName);
            Icon icon = null;
            if (resourceStream != null)
            {
                icon = new Icon(resourceStream);
            }
            return icon;
        }

        public static Icon GetIconFromImage(Image image)
        {
            Icon icon = null;
            if (image != null)
            {
                icon = Icon.FromHandle(((Bitmap) image).GetHicon());
                image.Dispose();
            }
            return icon;
        }

        public static Icon GetIconFromImage(string fileName)
        {
            Stream input = GetResourceStream(fileName);
            Icon icon = null;
            if (input != null)
            {
                Image image = LoadImage(input);
                icon = Icon.FromHandle(((Bitmap) image).GetHicon());
                image.Dispose();
                input.Close();
            }
            return icon;
        }

        public static Icon GetIconFromStream(Stream input)
        {
            Icon icon = null;
            if (input != null)
            {
                Image image = LoadImage(input);
                if (image == null)
                {
                    return null;
                }
                icon = Icon.FromHandle(((Bitmap) image).GetHicon());
                image.Dispose();
                input.Close();
            }
            return icon;
        }

        public static Image GetImage(string fileName)
        {
            Stream input = GetResourceStream(fileName);
            Image image = null;
            if (input != null)
            {
                image = LoadImage(input);
            }
            return image;
        }

        public static Image GetImageBmpOrPng(string fileNameNoExt)
        {
            Image image = GetImage(fileNameNoExt + ".bmp");
            if (image == null)
            {
                image = GetImage(fileNameNoExt + ".png");
            }
            return image;
        }

        public static string[] GetInstalledLocales()
        {
            string path = ResourcesDir;
            string searchPattern = "ImpsResources.Strings*.resources";
            string[] files = Directory.GetFiles(path, searchPattern);
            string[] textArray2 = new string[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                string text7;
                string text3 = files[i];
                Path.GetDirectoryName(text3);
                string fileName = Path.GetFileName(text3);
                string text6 = fileName.Substring(0, fileName.Length - ".resources".Length).Substring("ImpsResources.Strings".Length);
                if ((text6.Length > 0) && (text6[0] == '.'))
                {
                    text7 = text6.Substring(1);
                }
                else if (text6.Length == 0)
                {
                    text7 = "zh-CN";
                }
                else
                {
                    text7 = text6;
                }
                textArray2[i] = text7;
            }
            return textArray2;
        }

        private static string[] GetLocaleDirs()
        {
            string text2 = Path.Combine(ResourcesDir, "Resources");
            List<string> list = new List<string>();
            for (CultureInfo parent = _impsCulture; parent.Name != ""; parent = parent.Parent)
            {
                string path = Path.Combine(text2, parent.Name);
                if (Directory.Exists(path))
                {
                    list.Add(path);
                }
            }
            return list.ToArray();
        }

        public static string[] GetLocaleNameChain()
        {
            List<string> list = new List<string>();
            for (CultureInfo parent = _impsCulture; parent.Name != ""; parent = parent.Parent)
            {
                list.Add(parent.Name);
            }
            return list.ToArray();
        }

        public static Stream GetResourceStream(string fileName)
        {
            Stream manifestResourceStream = null;
            if (manifestResourceStream == null)
            {
                string name = "Imps.Client.Resource." + fileName;
                manifestResourceStream = _ourAssembly.GetManifestResourceStream(name);
            }
            return manifestResourceStream;
        }

        public static string GetString(string stringName)
        {
            return _resourceManager.GetString(stringName, _impsCulture).Replace(@"\r\n", "\r\n");
        }

        private static void Initialize()
        {
            _resourceManager = CreateResourceManager();
            _ourAssembly = Assembly.GetExecutingAssembly();
            _impsCulture = new CultureInfo("zh-CN");
            _localeDirs = GetLocaleDirs();
        }

        public static bool IsGdiPlusImageAllowed(Stream input)
        {
            byte[] signature = new byte[] { 0xd7, 0xcd, 0xc6, 0x9a };
            byte[] buffer3 = new byte[4];
            buffer3[0] = 1;
            byte[] buffer2 = buffer3;
            if (!CheckForSignature(input, buffer2))
            {
                return !CheckForSignature(input, signature);
            }
            return false;
        }

        public static Image LoadImage(Stream input)
        {
            Image image = Image.FromStream(input);
            if ((image.RawFormat == ImageFormat.Wmf) || (image.RawFormat == ImageFormat.Emf))
            {
                image.Dispose();
            }
            return image;
        }

        public static Image LoadImage(string fileName)
        {
            Image image;
            try
            {
                using (FileStream input = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    image = LoadImage(input);
                }
            }
            catch
            {
                image = null;
            }
            return image;
        }

        public static CultureInfo Culture
        {
            get
            {
                return _impsCulture;
            }
            set
            {
                Thread.CurrentThread.CurrentUICulture = value;
                Initialize();
            }
        }

        public static string ResourcesDir
        {
            get
            {
                return FilePathHelper.AppBaseDir;
            }
        }

        public static ResourceManager Strings
        {
            get
            {
                return _resourceManager;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -