Exemple #1
0
        public static void CreateJumpListImages(string bniFilePath)
        {
            string jlIconsPath = Path.Combine(Path.GetDirectoryName(bniFilePath), "JumpListIcons");
            if (!Directory.Exists(jlIconsPath))
                Directory.CreateDirectory(jlIconsPath);

            using (BniFileParser bni = new BniFileParser(bniFilePath))
            {
                foreach (BniIcon icon in bni.AllIcons)
                {
                    if (icon.SoftwareProductCodes.Length == 0)
                        continue;

                    string filename = icon.SoftwareProductCodes[0] + ".ico";

                    using (Bitmap result = new Bitmap(32, 32, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
                    using (Graphics g = Graphics.FromImage(result))
                    {
                        g.DrawImage(icon.Image, new Rectangle(0, 6, 32, 20));

                        using (Icon ico = Icon.FromHandle(result.GetHicon()))
                        using (FileStream fs = new FileStream(Path.Combine(jlIconsPath, filename), FileMode.OpenOrCreate, FileAccess.Write, FileShare.None))
                        {
                            ico.Save(fs);
                        }
                    }
                }
            }
        }
Exemple #2
0
        public BniIconProvider()
        {
            CreateFailedBitmap();

            string basePath = Path.Combine(JinxBotConfiguration.ApplicationDataPath, "icons.bni");
            if (!File.Exists(basePath))
            {
                try
                {
                    BnFtpRequestBase req = new BnFtpVersion1Request(Product.StarcraftRetail.ProductCode, "icons.bni", null);
                    req.LocalFileName = basePath;
                    req.ExecuteRequest();

                    m_bni = new BniFileParser(basePath);
                    m_valid = true;
                }
                catch { }
            }
            else
            {
                try
                {
                    m_bni = new BniFileParser(basePath);
                    m_valid = true;
                }
                catch { }
            }
        }
Exemple #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                BniFileParser bni = new BniFileParser(@"C:\Projects\jinxbot\branches\mbncsutil\trunk\mbnftp\bin\Debug\icons.bni");
                this.pictureBox1.Image = bni.FullImage;

                foreach (BniIcon icon in bni.AllIcons)
                {
                    this.flowContainer.Controls.Add(new IconRep(icon));
                }
            }
            catch { }

            Bitmap bmp = new Bitmap(28, 12);
            Rectangle bounds = new Rectangle(0, 0, 28, 12);
            using (Graphics g = Graphics.FromImage(bmp))
            using (LinearGradientBrush b = new LinearGradientBrush(bounds, Color.Black, Color.Black, 0, false))
            {
                ColorBlend cb = new ColorBlend();
                cb.Colors = new Color[] { Color.LimeGreen, Color.Lime, Color.Yellow, Color.Orange, Color.OrangeRed, Color.Maroon };
                cb.Positions = new float[] { 0f, 0.1f, 0.4f, 0.6f, 0.9f, 1f };
                b.InterpolationColors = cb;

                g.FillRectangle(b, bounds);
            }
            pictureBox2.Image = bmp;
        }
Exemple #4
0
        /// <summary>
        /// Disposes the object, cleaning up unmanaged and optionally managed resources.
        /// </summary>
        /// <param name="disposing">Whether to clean managed resources.</param>
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (m_bni != null)
                {
                    m_bni.Dispose();
                    m_bni = null;
                }
            }

            m_valid = false;
        }