/// <summary>
        /// 将表情对话框中的表情转换为富文本中的表情
        /// </summary>
        /// <param name="face"></param>
        /// <returns></returns>
        public EmojiModel FaceToEmoji(EmojiModel face)
        {
            if (face.Size == EmojiSize.Small)
            {
                return(null);
            }

            EmojiModel model = null;

            if (face.Type == EmojiType.Emoji)
            {
                if (EmojiMap.TryGetValue(face.Code, out string code))
                {
                    model = EmojiModelList.FirstOrDefault(p => p.Code == code);
                }
            }
            else
            {
                if (QQEmojiMap.TryGetValue(face.Code, out int index))
                {
                    if (QQEmojiModelList.Count > index)
                    {
                        model = QQEmojiModelList[index];
                    }
                }
            }
            return(model);
        }
            /**
             * This probably should be in the TweetStatModel.
             *
             */
            public TweetStatModel GetStats()
            {
                var           Now            = DateTimeOffset.Now.ToUnixTimeSeconds();
                var           PreviousMinute = 60;
                var           PreviousHour   = (60 * 60);
                TwitterAPIDAO dao            = new TwitterAPIDAO();
                string        command        = "SELECT Count(*) AS total";

                command += ", (SELECT SUM(`LIKE`) FROM tweets) AS 'totalLikes'";
                command += ", (SELECT SUM(`reTweet`) FROM tweets) AS 'totalRetweets'";
                command += ", (SELECT COUNT(*) FROM tweets WHERE hasEmoji = 1) AS 'totalEmojis'";
                command += ", (SELECT COUNT(*) FROM tweets WHERE hasImage = 1) AS 'totalImages'";
                command += ", (SELECT COUNT(*) FROM tweets WHERE hasUrl = 1) AS 'totalUrls'";
                command += ", (SELECT COUNT(*) FROM tweets WHERE `date` >= (SELECT MAX(`date`) FROM tweets) - 1) AS 'lastSecond'";
                command += ", (SELECT COUNT(*) FROM tweets WHERE `date` >= (SELECT MAX(`date`) FROM tweets) - " + PreviousMinute + ") AS 'lastMinute'";
                command += ", (SELECT COUNT(*) FROM tweets WHERE `date` >= (SELECT MAX(`date`) FROM tweets) - " + PreviousHour + ") AS 'lastHour'";
                command += "FROM tweets";

                TweetStatModel tweetStats = dao.GetSingleObject(command);

                tweetStats.Emojis    = EmojiModel.GetEmojis();
                tweetStats.Hashtags  = HashtagModel.GetHashtags();
                tweetStats.Languages = LanguageModel.GetLanguages();
                tweetStats.Mentions  = MentionModel.GetMentions();
                tweetStats.Urls      = UrlModel.GetUrls();

                return(tweetStats);
            }
Beispiel #3
0
 internal CachedGuildEmoji(DiscordClient client, EmojiModel model, CachedGuild guild) : base(client, model.Id.Value)
 {
     Guild          = guild;
     RequiresColons = model.RequireColons;
     IsManaged      = model.Managed;
     IsAnimated     = model.Animated;
 }
Beispiel #4
0
        internal CachedGuildEmoji(CachedGuild guild, EmojiModel model) : base(guild.Client, model.Id.Value)
        {
            Guild          = guild;
            RequiresColons = model.RequireColons;
            IsManaged      = model.Managed;
            IsAnimated     = model.Animated;

            Update(model);
        }
Beispiel #5
0
 internal RestGuildEmoji(RestDiscordClient client, EmojiModel model, ulong guildId) : base(client, model.Id.Value)
 {
     GuildId        = guildId;
     Guild          = new RestDownloadable <RestGuild>(options => Client.GetGuildAsync(GuildId, options));
     RequiresColons = model.RequireColons;
     IsManaged      = model.Managed;
     IsAnimated     = model.Animated;
     Update(model);
 }
Beispiel #6
0
        internal RestGuildEmoji(RestDiscordClient client, Snowflake guildId, EmojiModel model) : base(client, model.Id.Value)
        {
            GuildId = guildId;
            Guild   = RestFetchable.Create(this, (@this, options) =>
                                           @this.Client.GetGuildAsync(@this.GuildId, options));
            RequiresColons = model.RequireColons;
            IsManaged      = model.Managed;
            IsAnimated     = model.Animated;

            Update(model);
        }
Beispiel #7
0
 internal DiscordEmoji(EmojiModel model)
 {
     Id    = model.Id;
     Name  = model.Name;
     Roles = model.Roles?.Select(x => new DiscordRole(x)).ToArray();
     if (model.User != null)
     {
         User = new DiscordUser(model.User);
     }
     RequireColons = model.RequireColons;
     Managed       = model.Managed;
     Animated      = model.Animated;
     Available     = model.Available;
 }
Beispiel #8
0
        public FaceViewModel(FaceManager faceManager, EmojiManager emojiManager, IEventAggregator ea)
        {
            EmojiFaceList = faceManager.EmojiFaceList;
            QQFaceList    = faceManager.QQFaceList;

            ClickFaceCommand = ReactiveCommand.Create <EmojiModel>(face =>
            {
                EmojiModel emoji = emojiManager.FaceToEmoji(face);
                if (emoji != null)
                {
                    ea.GetEvent <InputEmojiEvent>().Publish(emoji);
                }
            });
        }
        /// <summary>
        /// 输入表情
        /// </summary>
        /// <param name="emoji"></param>
        private void InputEmoji(EmojiModel emoji)
        {
            ContentControl image = new ContentControl
            {
                Content = emoji,
                Width   = 20,
                Height  = 20,
                Style   = (Style)FindResource("FaceImgStyle")
            };
            var container = new InlineUIContainer(image, rtb.CaretPosition)
            {
                BaselineAlignment = BaselineAlignment.Bottom
            };

            rtb.CaretPosition = container.ElementEnd;
            rtb.Focus();
        }
     public static IEmoji ToEmoji(this EmojiModel model)
     {
         if (model.Id == null)
         {
             return new Emoji
                    {
                        Name = model.Name
                    }
         }
         ;
         else
         {
             return new CustomEmoji
                    {
                        Id         = model.Id.Value,
                        Name       = model.Name,
                        IsAnimated = model.Animated
                    }
         };
     }
 }
        private bool TryAddEmoji(EmojiModel emoji, TextBlock document, string str)
        {
            if (str.Contains(emoji.ToString()))
            {
                string left = str.Substring(0, str.IndexOf(emoji.ToString()));
                if (left.Length != 0)
                {
                    if (left.Contains("[") || left.Contains("<span class=\"emoji emoji"))
                    {
                        SetToTextBlock(document, left);
                    }
                    else
                    {
                        document.Inlines.Add(new Run(left));
                    }
                }
                ContentControl image = new ContentControl
                {
                    Content = emoji,
                    Width   = 20,
                    Height  = 20,
                    Style   = (Style)Application.Current.FindResource("FaceImgStyle")
                };
                var container = new InlineUIContainer(image)
                {
                    BaselineAlignment = BaselineAlignment.Bottom
                };
                document.Inlines.Add(container);

                str = str.Remove(0, (left + emoji.ToString()).Length);
                SetToTextBlock(document, str);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #12
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            EmojiModel  model = (EmojiModel)value;
            int         size  = model.Size == EmojiSize.Medium ? 28 : 20;
            BitmapFrame res   = null;

            if (model.Size == EmojiSize.Medium)
            {
                if (model.Type == EmojiType.Emoji)
                {
                    res = emoji_face_res;
                }
                else
                {
                    res = qq_face_res;
                }
            }
            else
            {
                if (model.Type == EmojiType.Emoji)
                {
                    res = emoji_res;
                }
                else
                {
                    res = qq_emoji_res;
                }
            }

            if (res == null)
            {
                return(null);
            }

            return(new CroppedBitmap(res, new Int32Rect((int)model.Position.X, (int)model.Position.Y, size, size)));
        }
Beispiel #13
0
 internal void Update(EmojiModel model)
 {
     Name        = model.Name;
     RoleIds     = model.Roles;
     IsAvailable = model.Available;
 }
Beispiel #14
0
 internal void Update(EmojiModel model)
 {
     Name    = model.Name;
     RoleIds = model.Roles.Select(x => new Snowflake(x)).ToImmutableArray();
 }
Beispiel #15
0
 internal void Update(EmojiModel model)
 {
     Name        = model.Name;
     RoleIds     = model.Roles.ToSnowflakeList();
     IsAvailable = model.Available;
 }