Esempio n. 1
0
        private static void Load_emotic()
        {
            DirectoryInfo di = new DirectoryInfo(Settings.AppPath + "emoticons");

            FileInfo[] files = di.GetFiles();
            ex_emotic = new ExtendedEmoticon[files.Length];

            for (int i = 0; i < files.Length; i++)
            {
                using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(files[i].FullName)))
                    using (Bitmap raw = new Bitmap(ms))
                    {
                        ExtendedEmoticon ex = new ExtendedEmoticon();
                        ex.Img = new Bitmap(raw.Width, raw.Height);

                        using (Graphics g = Graphics.FromImage(ex.Img))
                            g.DrawImage(raw, new Point(0, 0));

                        ex.ShortcutText = Path.GetFileNameWithoutExtension(files[i].Name).ToUpper();
                        ex.Height       = ex.Img.Height;
                        ex_emotic[i]    = ex;
                    }
            }

            emotic = new Bitmap[49];
            int       count = 0;
            Rectangle r1    = new Rectangle(0, 0, 16, 16);
            Rectangle r2    = new Rectangle(0, 0, 16, 16);

            using (Bitmap raw = Properties.Resources.emotic)
            {
                for (int y = 0; y < 7; y++)
                {
                    for (int x = 0; x < 7; x++)
                    {
                        emotic[count] = new Bitmap(16, 16);
                        r2.X          = (x * 16);
                        r2.Y          = (y * 16);

                        using (Graphics g = Graphics.FromImage(emotic[count]))
                            g.DrawImage(raw, r1, r2, GraphicsUnit.Pixel);

                        emotic[count].MakeTransparent(Color.Magenta);
                        count++;
                    }
                }
            }

            Emoji.Load();
        }
Esempio n. 2
0
        public ExtEm(ExtendedEmoticon em)
        {
            this.ShortcutText = em.ShortcutText.ToLower();

            int org_width  = em.Img.Width;
            int org_height = em.Img.Height;

            if (org_width <= 50 && org_height <= 50)
            {
                this.preview = new Bitmap(org_width, org_height);

                using (Graphics g = Graphics.FromImage(this.preview))
                {
                    g.Clear(Color.White);
                    g.DrawImage(em.Img, new Point(0, 0));
                }
            }
            else
            {
                double ratioX = (double)50 / org_width;
                double ratioY = (double)50 / org_height;
                double ratio  = Math.Min(ratioX, ratioY);

                int new_width  = (int)(org_width * ratio);
                int new_height = (int)(org_height * ratio);

                this.preview = new Bitmap(new_width, new_height);

                using (Graphics g = Graphics.FromImage(this.preview))
                {
                    g.Clear(Color.White);
                    g.DrawImage(em.Img, 0, 0, new_width, new_height);
                }
            }

            this.Paint += this.PaintPreview;
        }