Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            Loaded += (_, __) =>
            {
                Task.Run(() =>
                {
                    var jsonBytes = Properties.Resources.emoji_en_US;
                    var json      = Encoding.UTF8.GetString(jsonBytes);

                    var emojis = fastJSON.JSON.ToObject <Dictionary <string, string[]> >(json);
                    foreach (var e in emojis)
                    {
                        Emojis.Add(new EmojItem
                        {
                            Keywords = e.Value,
                            Emoji    = e.Key
                        });
                    }
                }).ContinueWith(t =>
                {
                    Dispatcher.Invoke(() =>
                    {
                        CollectionView        = CollectionViewSource.GetDefaultView(Emojis);
                        lc.ItemsSource        = CollectionView;
                        borderMask.Visibility = Visibility.Collapsed;
                    });
                });
            };
        }
Exemplo n.º 2
0
        public static void Init()
        {
            byte[] bytes     = Encoding.BigEndianUnicode.GetBytes("🇦");
            int    modeIndex = bytes.Length - 1; //last

            for (int i = 0; i < 26; i++)
            {
                string ustr = Encoding.BigEndianUnicode.GetString(bytes);
                Emojis.Add(new Emoji(ustr));
                bytes[modeIndex]++;
            }

            bytes     = Encoding.BigEndianUnicode.GetBytes("0\u20e3");
            modeIndex = 1; //second
            for (int i = 0; i < 10; i++)
            {
                string ustr = Encoding.BigEndianUnicode.GetString(bytes);
                Emojis.Add(new Emoji(ustr));
                bytes[modeIndex]++;
            }
        }
Exemplo n.º 3
0
        public static void LoadEmojis()
        {
            // Construct a directory of Emojis
            var emojiDirectory = Path.Combine(Path.GetDirectoryName(Assembly), "Emojis");

            // Loop through all of the directories and map the glyphs to their appropriate libraries
            foreach (var emoji in new DirectoryInfo(emojiDirectory).EnumerateFiles("*.png", SearchOption.AllDirectories))
            {
                try
                {
                    // Created a lazily loaded glyph that points to the appropriate path
                    Emojis.Add(Path.GetFileNameWithoutExtension(emoji.Name), new LazyImage {
                        Path = new Uri(emoji.FullName, UriKind.RelativeOrAbsolute)
                    });
                }
                catch (Exception)
                {
                    // An error occurred when creating the Emoji, ignore it (it will be handled in the provider)
                }
            }
        }
Exemplo n.º 4
0
        public static void Init()
        {
            byte[] bytes     = Encoding.BigEndianUnicode.GetBytes("🇦");
            int    lastIndex = bytes.Length - 1;

            for (int i = 0; i < 26; i++)
            {
                string ustr = Encoding.BigEndianUnicode.GetString(bytes);
                Emojis.Add(new Emoji(ustr));
                bytes[lastIndex]++;
            }

            bytes     = Encoding.Unicode.GetBytes("\x0030\xFE0F\x20E3");
            lastIndex = 0;
            for (int i = 0; i < 10; i++)
            {
                string ustr = Encoding.Unicode.GetString(bytes);
                Console.WriteLine(ustr);
                Emojis.Add(new Emoji(ustr));
                bytes[lastIndex]++;
            }
        }