/// <summary> /// Constructor with a single emoticon supplied. /// </summary> /// <param name="emoticon"></param> /// <param name="type"></param> public EmoticonMessage(Emoticon emoticon, EmoticonType type) { if (null == emoticon) throw new ArgumentNullException("emoticon"); emoticons = new List<Emoticon>(); emoticons.Add(emoticon); emoticontype = type; }
void OnEmoteChanged(Emoticon source) { if (frameTimer != null) { frameTimer.Elapsed -= OnTimerElapsed; frameTimer.Stop(); frameTimer.Dispose(); frameTimer = null; } Width = source.Image.Width; Height = source.Image.Height; FrameIndex = 0; if (source.Frames.Length > 1) { frameTimer = new Timer(Emote.Frames[0].Delay); frameTimer.Elapsed += OnTimerElapsed; frameTimer.Start(); } }
protected abstract T GetHeroElement(Emoticon emoticon);
public abstract void SendEmoticon(int clientId, Emoticon emote);
public static PacketWriter Emote(MapEntityIndex mapEntityIndex, Emoticon emoticon) { var pw = GetWriter(ServerPacketID.Emote); pw.Write(mapEntityIndex); pw.WriteEnum(emoticon); return pw; }
private void bMessageSendCustomEmoticon_Click(object sender, EventArgs e) { if (openCustomEmoticonDialog.ShowDialog() != DialogResult.OK) return; MemoryStream mem = new MemoryStream(); Bitmap img = new Bitmap(Image.FromFile(openCustomEmoticonDialog.FileName)); img.Save(mem, ImageFormat.Png); Emoticon emotest = new Emoticon(_messenger.Owner.Account, mem, Path.GetFileName(openCustomEmoticonDialog.FileName), Path.GetFileName(openCustomEmoticonDialog.FileName)); MSNObjectCatalog.GetInstance().Add(emotest); List<Emoticon> emolist = new List<Emoticon>(); emolist.Add(emotest); if (!richTextHistory.Emotions.ContainsKey(emotest.Shortcut)) { richTextHistory.Emotions[emotest.Shortcut] = img; } try { remoteContact.SendEmoticonDefinitions(emolist, EmoticonType.StaticEmoticon); TextMessage emotxt = new TextMessage("Hey, this is a custom emoticon: " + emotest.Shortcut); remoteContact.SendMessage(emotxt); DisplaySystemMessage("You send a custom emoticon with text message: Hey, this is a custom emoticon: [" + emotest.Shortcut + "]."); } catch (Exception) { DisplaySystemMessage("Remote contact not online, emoticon will not be sent."); } }
void HandleGameControl_Emote(Emoticon emoticon) { using (var pw = ClientPacket.Emoticon(emoticon)) { Socket.Send(pw, ClientMessageType.CharacterEmote); } }
protected override void Seed(FORUM_DYSKUSYJNE.Database.ForumDatabase context) { var admin = context.Users.Where(u => u.Username == "Admin").FirstOrDefault(); var roles = context.Roles.FirstOrDefault(); var emoticons = context.Emoticons.FirstOrDefault(); var ranks = context.Ranks.FirstOrDefault(); if (roles == null) { var role1 = new Role() { RoleName = "Admin" }; /* var role2 = new Role() * { * RoleName = "Moderator" * }; */ var role3 = new Role() { RoleName = "User" }; context.Roles.Add(role1); //context.Roles.Add(role2); context.Roles.Add(role3); } if (ranks == null) { var rank1 = new Rank() { RankName = "New member", Requirement = 0, }; var rank2 = new Rank() { RankName = "Junior member", Requirement = 5, }; var rank3 = new Rank() { RankName = "Member", Requirement = 20, }; var rank4 = new Rank() { RankName = "Active member", Requirement = 100, }; context.Ranks.Add(rank1); context.Ranks.Add(rank2); context.Ranks.Add(rank3); context.Ranks.Add(rank4); context.SaveChanges(); } if (admin == null) { var rank = context.Ranks.Where(x => x.RankName == "Active member").First(); var user = new User() { Username = "******", Name = "Maciej", Email = "*****@*****.**", Password = "******", Location = "Poland", BirthdayDate = new DateTime(1990, 05, 05), IsActive = true, Avatar = null, ActivationCode = new Guid(), Rank = rank }; var role = context.Roles.ToList(); user.Role = role; context.Users.Add(user); } var groups = context.Groups.FirstOrDefault(); if (groups == null) { var group1 = new Group() { GroupName = "SUPPORT" }; var group2 = new Group() { GroupName = "COMMUNITY" }; var group3 = new Group() { GroupName = "OFF TOPIC" }; context.Groups.Add(group1); context.Groups.Add(group2); context.Groups.Add(group3); } var sections = context.Sections.FirstOrDefault(); if (sections == null) { var section1 = new Section() { Name = "MEMES", Description = "Here you can post your highly creative memes", GroupId = 6, Order = 1 }; var section2 = new Section() { Name = "HOBBY", Description = "Talk about your interesting hobbies", GroupId = 6, Order = 2 }; var section3 = new Section() { Name = "GENERAL DISCUSSION", Description = "Discuss Heroes of the Storm", GroupId = 5, Order = 1 }; var section4 = new Section() { Name = "COMPETITIVE DISCUSSTION", Description = "Discuss Heroes of the Storm esports, tournaments, teams, and competitive play ", GroupId = 5, Order = 2 }; var section5 = new Section() { Name = "LOOKING FOR GROUP", Description = "Looking to play with a party or wanting to promote the one you’re in? This is the place.", GroupId = 5, Order = 3 }; var section6 = new Section() { Name = "FEEDBACK", Description = "Share and discuss all feedback from Heroes of the Storm ", GroupId = 5, Order = 4 }; var section7 = new Section() { Name = "COMMUNITY CREATIONS", Description = "Share and discuss artwork, cosplay, guides and other creations made by the Heroes of the Storm community.", GroupId = 5, Order = 5 }; var section8 = new Section() { Name = "TECHNICAL SUPPORT", Description = "For problems installing, patching or playing the Heroes of the Storm, please contact us here. ", GroupId = 4, Order = 1 }; var section9 = new Section() { Name = "GAMING AND HARDWARE", Description = "Want to talk about a non-Blizzard games, ask for PC hardware advice or event discuss the latest innovations in science? Come on in.", GroupId = 6, Order = 3 }; var section10 = new Section() { Name = "MEDIA AND LITERATURE", Description = "They inspire entertain and delight – come here to chat about movies, TV, music and literature.", GroupId = 6, Order = 4 }; context.Sections.Add(section1); context.Sections.Add(section2); context.Sections.Add(section3); context.Sections.Add(section4); context.Sections.Add(section5); context.Sections.Add(section6); context.Sections.Add(section7); context.Sections.Add(section8); context.Sections.Add(section9); context.Sections.Add(section10); } if (emoticons == null) { var emote1 = new Emoticon() { Name = "Kreygasm", SourceLink = "https://static-cdn.jtvnw.net/emoticons/v1/41/1.0", }; var emote2 = new Emoticon() { Name = "cmonBruh", SourceLink = "https://static-cdn.jtvnw.net/emoticons/v1/84608/1.0", }; var emote3 = new Emoticon() { Name = "Murky", SourceLink = "https://d1u5p3l4wpay3k.cloudfront.net/hots_es_gamepedia/b/bc/Murky_Happy_Emoji.png?version=305199b68c28fc73fc209659c1551f93", }; var emote4 = new Emoticon() { Name = "Jebaited", SourceLink = "https://static-cdn.jtvnw.net/emoticons/v1/114836/1.0", }; var emote5 = new Emoticon() { Name = "PJSalt", SourceLink = "https://static-cdn.jtvnw.net/emoticons/v1/36/1.0" }; context.Emoticons.Add(emote1); context.Emoticons.Add(emote2); context.Emoticons.Add(emote3); context.Emoticons.Add(emote4); context.Emoticons.Add(emote5); } context.SaveChanges(); }
public static Strcut_CFCBlock FromImage(Emoticon emoticon) { return(CFCBuilder.GetFaceBlockFromImage(emoticon)); }
/// <summary> /// Makes the <see cref="Character"/> use an <see cref="Emoticon"/>. /// </summary> /// <param name="emoticon">The emoticon to use.</param> public void Emote(Emoticon emoticon) { using (var pw = ServerPacket.Emote(MapEntityIndex, emoticon)) { Map.SendToArea(this, pw, ServerMessageType.MapEffect); } }
/// <summary> /// Gets the emoticon as string. /// </summary> /// <param name="emoticon">The emoticon.</param> private static string GetEmoticon(Emoticon emoticon) { string result = string.Empty; if (Enabled) { switch (emoticon) { case Emoticon.Telephone: result = "(T)"; break; case Emoticon.OK: result = "(OK)"; break; case Emoticon.Beer: result = "(b)"; break; case Emoticon.Sunglasses: result = "(H)"; break; case Emoticon.Smile: result = ":)"; break; case Emoticon.Surprised: result = ":-O"; break; case Emoticon.BigSmile: result = ":D"; break; case Emoticon.TongeOut: result = ":P"; break; case Emoticon.Embarassed: result = ":$"; break; case Emoticon.Wink: result = ";)"; break; case Emoticon.GottaRun: result = "(gtr)"; break; case Emoticon.Nerd: result = "8-|"; break; case Emoticon.BrokenHeart: result = "(U)"; break; case Emoticon.Computer: result = "(co)"; break; case Emoticon.Sun: result = "(#)"; break; case Emoticon.HalfMoon: result = "(s)"; break; case Emoticon.Clock: result = "(O)"; break; case Emoticon.Thinking: result = "*-)"; break; case Emoticon.Exclamation: result = "(!!?)"; break; case Emoticon.Sad: result = ":("; break; case Emoticon.WorkItem: result = "(woi)"; break; case Emoticon.Girl: result = "(X)"; break; case Emoticon.Boy: result = "(Z)"; break; case Emoticon.Snail: result = "(sn)"; break; case Emoticon.Bye: result = "(BYE)"; break; case Emoticon.Online: result = "(ol)"; break; case Emoticon.Busy: result = "(busy)"; break; case Emoticon.QuestionMark: result = "(!!)"; break; case Emoticon.Gift: result = "(G)"; break; case Emoticon.Agree: result = "(Y)"; break; case Emoticon.Email: result = "(E)"; break; case Emoticon.Sleepy: result = "|-)"; break; case Emoticon.Umbrella: result = "(um)"; break; case Emoticon.Storm: result = "(ST)"; break; case Emoticon.Money: result = "(mo)"; break; case Emoticon.CoffeeCup: result = "(C)"; break; case Emoticon.Idea: result = "(I)"; break; case Emoticon.Star: result = "(*)"; break; case Emoticon.HotSmile: result = "(H)"; break; case Emoticon.AngrySmile: result = ":@"; break; case Emoticon.ConfusedSmile: result = ":S"; break; case Emoticon.Crying: result = ":'("; break; case Emoticon.Disappointed: result = ":|"; break; case Emoticon.BaringTeeth: result = "8o|"; break; case Emoticon.Sick: result = "+o("; break; case Emoticon.Party: result = "<:o)"; break; case Emoticon.DontTellAnyone: result = ":-#"; break; case Emoticon.Secret: result = ":-*"; break; case Emoticon.Sarcastic: result = "^o)"; break; case Emoticon.Heart: result = "(L)"; break; case Emoticon.Drinks: result = "(D)"; break; case Emoticon.Catface: result = "(@)"; break; case Emoticon.Dogface: result = "(&)"; break; case Emoticon.BlackSheep: result = "(bah)"; break; case Emoticon.Rainbow: result = "(R)"; break; case Emoticon.LeftHug: result = "({)"; break; case Emoticon.RightHug: result = "(})"; break; case Emoticon.RedLips: result = "(K)"; break; case Emoticon.RedRose: result = "(F)"; break; case Emoticon.WiltedRose: result = "(W)"; break; case Emoticon.BirthdayCake: result = "(^)"; break; case Emoticon.Camera: result = "(P)"; break; case Emoticon.MobilePhone: result = "(mp)"; break; case Emoticon.Auto: result = "(au)"; break; case Emoticon.Airplane: result = "(ap)"; break; case Emoticon.Filmstrip: result = "(~)"; break; case Emoticon.Note: result = "(8)"; break; case Emoticon.Pizza: result = "(pi)"; break; case Emoticon.SoccerBall: result = "(so)"; break; case Emoticon.IslandWithPalmTree: result = "(ip)"; break; case Emoticon.Stop: result = "(!)"; break; case Emoticon.Confidential: result = "(QT)"; break; case Emoticon.Disagree: result = "(N)"; break; case Emoticon.WorkFromHome: result = "(@H)"; break; case Emoticon.HoldOn: result = "(W8)"; break; case Emoticon.GoodLuck: result = "(gl)"; break; case Emoticon.CanICallYou: result = "(cic)"; break; case Emoticon.DoNotDisturb: result = "(dnd)"; break; case Emoticon.Games: result = "(ply)"; break; case Emoticon.EyeRolling: result = "8-)"; break; case Emoticon.LetsMeet: result = "(S+)"; break; default: break; } } return(result); }
private void Parse() { EmoticonParser emoticonParser = new EmoticonParser(XmlDataService); LunaraAngry = emoticonParser.Parse("lunara_angry"); }
/// <summary> /// Updates the localized gamestrings to the selected <see cref="Localization"/>. /// </summary> /// <param name="emoticon">The data to be updated.</param> /// <param name="gameStringDocument">Instance of a <see cref="GameStringDocument"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="gameStringDocument"/> is null.</exception> public static void UpdateGameStrings(this Emoticon emoticon, GameStringDocument gameStringDocument) { ArgumentNullException.ThrowIfNull(gameStringDocument, nameof(gameStringDocument)); gameStringDocument.UpdateGameStrings(emoticon); }
private static List <NewImageInfo> ScanImages(IBlogPostHtmlEditor currentEditor, IEditorAccount editorAccount, ContentEditor editor, bool useDefaultTargetSettings) { List <NewImageInfo> newImages = new List <NewImageInfo>(); ApplicationPerformance.ClearEvent("InsertImage"); ApplicationPerformance.StartEvent("InsertImage"); using (new WaitCursor()) { IHTMLElement2 postBodyElement = (IHTMLElement2)((BlogPostHtmlEditorControl)currentEditor).PostBodyElement; if (postBodyElement != null) { foreach (IHTMLElement imgElement in postBodyElement.getElementsByTagName("img")) { string imageSrc = imgElement.getAttribute("srcDelay", 2) as string; if (string.IsNullOrEmpty(imageSrc)) { imageSrc = imgElement.getAttribute("src", 2) as string; } // WinLive 96840 - Copying and pasting images within shared canvas should persist source // decorator settings. "wlCopySrcUrl" is inserted while copy/pasting within canvas. bool copyDecoratorSettings = false; string attributeCopySrcUrl = imgElement.getAttribute("wlCopySrcUrl", 2) as string; if (!string.IsNullOrEmpty(attributeCopySrcUrl)) { copyDecoratorSettings = true; imgElement.removeAttribute("wlCopySrcUrl", 0); } // Check if we need to apply default values for image decorators bool applyDefaultDecorator = true; string attributeNoDefaultDecorator = imgElement.getAttribute("wlNoDefaultDecorator", 2) as string; if (!string.IsNullOrEmpty(attributeNoDefaultDecorator) && string.Compare(attributeNoDefaultDecorator, "TRUE", StringComparison.OrdinalIgnoreCase) == 0) { applyDefaultDecorator = false; imgElement.removeAttribute("wlNoDefaultDecorator", 0); } string applyDefaultMargins = imgElement.getAttribute("wlApplyDefaultMargins", 2) as string; if (!String.IsNullOrEmpty(applyDefaultMargins)) { DefaultImageSettings defaultImageSettings = new DefaultImageSettings(editorAccount.Id, editor.DecoratorsManager); MarginStyle defaultMargin = defaultImageSettings.GetDefaultImageMargin(); // Now apply it to the image imgElement.style.marginTop = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Top); imgElement.style.marginLeft = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Left); imgElement.style.marginBottom = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Bottom); imgElement.style.marginRight = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Right); imgElement.removeAttribute("wlApplyDefaultMargins", 0); } if ((UrlHelper.IsFileUrl(imageSrc) || IsFullPath(imageSrc)) && !ContentSourceManager.IsSmartContent(imgElement)) { Uri imageSrcUri = new Uri(imageSrc); try { BlogPostImageData imageData = BlogPostImageDataList.LookupImageDataByInlineUri(editor.ImageList, imageSrcUri); Emoticon emoticon = EmoticonsManager.GetEmoticon(imgElement); if (imageData == null && emoticon != null) { // This is usually an emoticon copy/paste and needs to be cleaned up. Uri inlineImageUri = editor.EmoticonsManager.GetInlineImageUri(emoticon); imgElement.setAttribute("src", UrlHelper.SafeToAbsoluteUri(inlineImageUri), 0); } else if (imageData == null) { if (!File.Exists(imageSrcUri.LocalPath)) { throw new FileNotFoundException(imageSrcUri.LocalPath); } // WinLive 188841: Manually attach the behavior so that the image cannot be selected or resized while its loading. DisabledImageElementBehavior disabledImageBehavior = new DisabledImageElementBehavior(editor.IHtmlEditorComponentContext); disabledImageBehavior.AttachToElement(imgElement); Size sourceImageSize = ImageUtils.GetImageSize(imageSrcUri.LocalPath); ImagePropertiesInfo imageInfo = new ImagePropertiesInfo(imageSrcUri, sourceImageSize, new ImageDecoratorsList(editor.DecoratorsManager, new BlogPostSettingsBag())); DefaultImageSettings defaultImageSettings = new DefaultImageSettings(editorAccount.Id, editor.DecoratorsManager); // Make sure this is set because some imageInfo properties depend on it. imageInfo.ImgElement = imgElement; bool isMetafile = ImageHelper2.IsMetafile(imageSrcUri.LocalPath); ImageClassification imgClass = ImageHelper2.Classify(imageSrcUri.LocalPath); if (!isMetafile && ((imgClass & ImageClassification.AnimatedGif) != ImageClassification.AnimatedGif)) { // WinLive 96840 - Copying and pasting images within shared canvas should persist source // decorator settings. if (copyDecoratorSettings) { // Try to look up the original copied source image. BlogPostImageData imageDataOriginal = BlogPostImageDataList.LookupImageDataByInlineUri(editor.ImageList, new Uri(attributeCopySrcUrl)); if (imageDataOriginal != null && imageDataOriginal.GetImageSourceFile() != null) { // We have the original image reference, so lets make a clone of it. BlogPostSettingsBag originalBag = (BlogPostSettingsBag)imageDataOriginal.ImageDecoratorSettings.Clone(); ImageDecoratorsList originalDecoratorsList = new ImageDecoratorsList(editor.DecoratorsManager, originalBag); ImageFileData originalImageFileData = imageDataOriginal.GetImageSourceFile(); Size originalImageSize = new Size(originalImageFileData.Width, originalImageFileData.Height); imageInfo = new ImagePropertiesInfo(originalImageFileData.Uri, originalImageSize, originalDecoratorsList); } else { // There are probably decorators applied to the image, but in a different editor so we can't access them. // We probably don't want to apply any decorators to this image, so apply blank decorators and load the // image as full size so it looks like it did before. imageInfo.ImageDecorators = defaultImageSettings.LoadBlankLocalImageDecoratorsList(); imageInfo.InlineImageSizeName = ImageSizeName.Full; } } else if (applyDefaultDecorator) { imageInfo.ImageDecorators = defaultImageSettings.LoadDefaultImageDecoratorsList(); if ((imgClass & ImageClassification.TransparentGif) == ImageClassification.TransparentGif) { imageInfo.ImageDecorators.AddDecorator(NoBorderDecorator.Id); } } else { // Don't use default values for decorators imageInfo.ImageDecorators = defaultImageSettings.LoadBlankLocalImageDecoratorsList(); imageInfo.InlineImageSizeName = ImageSizeName.Full; } } else { ImageDecoratorsList decorators = new ImageDecoratorsList(editor.DecoratorsManager, new BlogPostSettingsBag()); decorators.AddDecorator(editor.DecoratorsManager.GetDefaultRemoteImageDecorators()); imageInfo.ImageDecorators = decorators; } imageInfo.ImgElement = imgElement; imageInfo.DhtmlImageViewer = editorAccount.EditorOptions.DhtmlImageViewer; //discover the "natural" target settings from the DOM string linkTargetUrl = imageInfo.LinkTargetUrl; if (linkTargetUrl == imageSrc) { imageInfo.LinkTarget = LinkTargetType.IMAGE; } else if (!String.IsNullOrEmpty(linkTargetUrl) && !UrlHelper.IsFileUrl(linkTargetUrl)) { imageInfo.LinkTarget = LinkTargetType.URL; } else { imageInfo.LinkTarget = LinkTargetType.NONE; } if (useDefaultTargetSettings) { if (!GlobalEditorOptions.SupportsFeature(ContentEditorFeature.SupportsImageClickThroughs) && imageInfo.DefaultLinkTarget == LinkTargetType.IMAGE) { imageInfo.DefaultLinkTarget = LinkTargetType.NONE; } if (imageInfo.LinkTarget == LinkTargetType.NONE) { imageInfo.LinkTarget = imageInfo.DefaultLinkTarget; } if (imageInfo.DefaultLinkOptions.ShowInNewWindow) { imageInfo.LinkOptions.ShowInNewWindow = true; } imageInfo.LinkOptions.UseImageViewer = imageInfo.DefaultLinkOptions.UseImageViewer; imageInfo.LinkOptions.ImageViewerGroupName = imageInfo.DefaultLinkOptions.ImageViewerGroupName; } Size defaultImageSize = defaultImageSettings.GetDefaultInlineImageSize(); Size initialSize = ImageUtils.GetScaledImageSize(defaultImageSize.Width, defaultImageSize.Height, sourceImageSize); // add to list of new images newImages.Add(new NewImageInfo(imageInfo, imgElement, initialSize, disabledImageBehavior)); } else { // When switching blogs, try to adapt image viewer settings according to the blog settings. ImagePropertiesInfo imageInfo = new ImagePropertiesInfo(imageSrcUri, ImageUtils.GetImageSize(imageSrcUri.LocalPath), new ImageDecoratorsList(editor.DecoratorsManager, imageData.ImageDecoratorSettings)); imageInfo.ImgElement = imgElement; // Make sure the new crop and tilt decorators get loaded imageInfo.ImageDecorators.MergeDecorators(DefaultImageSettings.GetImplicitLocalImageDecorators()); string viewer = imageInfo.DhtmlImageViewer; if (viewer != editorAccount.EditorOptions.DhtmlImageViewer) { imageInfo.DhtmlImageViewer = editorAccount.EditorOptions.DhtmlImageViewer; imageInfo.LinkOptions = imageInfo.DefaultLinkOptions; } // If the image is an emoticon, update the EmoticonsManager with the image's uri so that duplicate emoticons can point to the same file. if (emoticon != null) { editor.EmoticonsManager.SetInlineImageUri(emoticon, imageData.InlineImageFile.Uri); } } } catch (ArgumentException e) { Trace.WriteLine("Could not initialize image: " + imageSrc); Trace.WriteLine(e.ToString()); } catch (DirectoryNotFoundException) { Debug.WriteLine("Image file does not exist: " + imageSrc); } catch (FileNotFoundException) { Debug.WriteLine("Image file does not exist: " + imageSrc); } catch (IOException e) { Debug.WriteLine("Image file cannot be read: " + imageSrc + " " + e); DisplayMessage.Show(MessageId.FileInUse, imageSrc); } } } } } return(newImages); }
public TwitchSmile(Emoticon emoticon) { this.Regex = new Regex(emoticon.Regex); this.Uri = new Uri(emoticon.GetUri(), UriKind.RelativeOrAbsolute); //this.Icon = new BitmapImage(this.Uri); }
protected abstract T GetAnimationObject(Emoticon emoticon);
/// <summary> /// Updates the <paramref name="emoticon"/>'s localized gamestrings to the currently selected <see cref="Localization"/>. /// </summary> /// <param name="emoticon">The data to be updated.</param> /// <exception cref="ArgumentNullException"><paramref name="emoticon"/> is <see langword="null"/>.</exception> public void UpdateGameStrings(Emoticon emoticon) { if (emoticon is null) { throw new ArgumentNullException(nameof(emoticon)); } JsonElement element = JsonGameStringDocument.RootElement; if (element.TryGetProperty("gamestrings", out JsonElement gameStringElement)) { if (gameStringElement.TryGetProperty("emoticon", out JsonElement keyValue)) { if (TryGetValueFromJsonElement(keyValue, "expression", emoticon.Id, out JsonElement expressionElement)) { emoticon.Name = expressionElement.GetString(); } if (TryGetValueFromJsonElement(keyValue, "searchtext", emoticon.Id, out JsonElement searchTextElement)) { string?seachTextValues = searchTextElement.GetString(); if (!string.IsNullOrEmpty(seachTextValues)) { string[] values = seachTextValues.Split(' ', StringSplitOptions.RemoveEmptyEntries); foreach (string value in values) { emoticon.SearchTexts.Add(value); } } } if (TryGetValueFromJsonElement(keyValue, "description", emoticon.Id, out JsonElement descriptionElement)) { emoticon.Description = SetTooltipDescription(descriptionElement.GetString()); } if (TryGetValueFromJsonElement(keyValue, "descriptionlocked", emoticon.Id, out JsonElement descriptionLockedElement)) { emoticon.DescriptionLocked = SetTooltipDescription(descriptionLockedElement.GetString()); } if (TryGetValueFromJsonElement(keyValue, "localizedaliases", emoticon.Id, out JsonElement localizedAliasesElement)) { string?localizedAliasesValue = localizedAliasesElement.GetString(); if (!string.IsNullOrEmpty(localizedAliasesValue)) { string[] values = localizedAliasesValue.Split(' ', StringSplitOptions.RemoveEmptyEntries); foreach (string value in values) { emoticon.LocalizedAliases.Add(value); } } } if (TryGetValueFromJsonElement(keyValue, "aliases", emoticon.Id, out JsonElement aliasesElement)) { string?aliasesValue = aliasesElement.GetString(); if (!string.IsNullOrEmpty(aliasesValue)) { string[] values = aliasesValue.Split(' ', StringSplitOptions.RemoveEmptyEntries); foreach (string value in values) { emoticon.UniversalAliases.Add(value); } } } } } }
/// <summary> /// Sets the Emoticon property. /// </summary> /// <param name="data"></param> public override void ParseBytes(byte[] data) { // set the text property for easy retrieval string body = System.Text.Encoding.UTF8.GetString(data).Trim(); Emoticons = new List<Emoticon>(); string[] values = body.Split('\t'); for (int i = 0; i < values.Length - 1; i += 2) { Emoticon emoticon = new Emoticon(); emoticon.Shortcut = values[i].Trim(); emoticon.SetContext(values[i + 1].Trim()); Emoticons.Add(emoticon); } }
private async void OnPaste(object sender, TextControlPasteEventArgs e) { // If the user tries to paste RTF content from any TOM control (Visual Studio, Word, Wordpad, browsers) // we have to handle the pasting operation manually to allow plaintext only. var package = Clipboard.GetContent(); if (package.AvailableFormats.Contains(StandardDataFormats.Bitmap)) { if (e != null) { e.Handled = true; } var bitmap = await package.GetBitmapAsync(); var media = new ObservableCollection <StorageMedia>(); var fileName = string.Format("image_{0:yyyy}-{0:MM}-{0:dd}_{0:HH}-{0:mm}-{0:ss}.png", DateTime.Now); var cache = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName); using (var stream = await bitmap.OpenReadAsync()) { var result = await ImageHelper.TranscodeAsync(stream, cache, BitmapEncoder.PngEncoderId); var photo = await StoragePhoto.CreateAsync(result, true); if (photo == null) { return; } media.Add(photo); } if (package.AvailableFormats.Contains(StandardDataFormats.Text)) { media[0].Caption = new FormattedText(await package.GetTextAsync(), new TextEntity[0]); } ViewModel.SendMediaExecute(media, media[0]); } else if (package.AvailableFormats.Contains(StandardDataFormats.WebLink)) { } else if (package.AvailableFormats.Contains(StandardDataFormats.StorageItems)) { if (e != null) { e.Handled = true; } var items = await package.GetStorageItemsAsync(); var media = new ObservableCollection <StorageMedia>(); var files = new List <StorageFile>(items.Count); foreach (var file in items.OfType <StorageFile>()) { if (file.ContentType.Equals("image/jpeg", StringComparison.OrdinalIgnoreCase) || file.ContentType.Equals("image/png", StringComparison.OrdinalIgnoreCase) || file.ContentType.Equals("image/bmp", StringComparison.OrdinalIgnoreCase) || file.ContentType.Equals("image/gif", StringComparison.OrdinalIgnoreCase)) { var photo = await StoragePhoto.CreateAsync(file, true); if (photo != null) { media.Add(photo); } } else if (file.ContentType == "video/mp4") { var video = await StorageVideo.CreateAsync(file, true); if (video != null) { media.Add(video); } } files.Add(file); } // Send compressed __only__ if user is dropping photos and videos only if (media.Count > 0 && media.Count == files.Count) { ViewModel.SendMediaExecute(media, media[0]); } else if (files.Count > 0) { ViewModel.SendFileExecute(files); } } else if (package.AvailableFormats.Contains(StandardDataFormats.Text) && package.AvailableFormats.Contains("application/x-tl-field-tags")) { if (e != null) { e.Handled = true; } // This is our field format var text = await package.GetTextAsync(); var data = await package.GetDataAsync("application/x-tl-field-tags") as IRandomAccessStream; var reader = new DataReader(data.GetInputStreamAt(0)); var length = await reader.LoadAsync((uint)data.Size); var count = reader.ReadInt32(); var entities = new List <TextEntity>(count); for (int i = 0; i < count; i++) { var entity = new TextEntity { Offset = reader.ReadInt32(), Length = reader.ReadInt32() }; var type = reader.ReadByte(); switch (type) { case 1: entity.Type = new TextEntityTypeBold(); break; case 2: entity.Type = new TextEntityTypeItalic(); break; case 3: entity.Type = new TextEntityTypePreCode(); break; case 4: entity.Type = new TextEntityTypeTextUrl { Url = reader.ReadString(reader.ReadUInt32()) }; break; case 5: entity.Type = new TextEntityTypeMentionName { UserId = reader.ReadInt32() }; break; } entities.Add(entity); } InsertText(text, entities); } else if (package.AvailableFormats.Contains(StandardDataFormats.Text) && package.AvailableFormats.Contains("application/x-td-field-tags")) { // This is Telegram Desktop mentions format } else if (package.AvailableFormats.Contains(StandardDataFormats.Text) /*&& package.Contains("Rich Text Format")*/) { if (e != null) { e.Handled = true; } var text = await package.GetTextAsync(); var start = Document.Selection.StartPosition; var result = Emoticon.Pattern.Replace(text, (match) => { var emoticon = match.Groups[1].Value; var emoji = Emoticon.Replace(emoticon); if (match.Value.StartsWith(" ")) { emoji = $" {emoji}"; } return(emoji); }); Document.Selection.SetText(TextSetOptions.None, result); Document.Selection.SetRange(start + result.Length, start + result.Length); } }
/// <summary> /// 不分组导入 /// </summary> /// <param name="userID"></param> /// <param name="groupID"></param> /// <param name="emotes"></param> /// <param name="fileCount"></param> /// <param name="saveCount"></param> public void BatchImportEmoticon(int userID, int groupID, Dictionary <string, List <EmoticonItem> > emotes, out int fileCount, out int saveCount) { long maxEmotcionSize; //单个文件最大限制 long canUseSpcaeSize; //总可用空间大小 int canUploadEmoticonCount; //总可用表情数量 int usedEmoticonCount; long usedspaceSize = GetUserEmoticonStat(userID, out usedEmoticonCount); //已用空间大小 canUseSpcaeSize = MaxEmoticonSpace(userID); //取得最大可用空间 canUploadEmoticonCount = MaxEmoticonCount(userID); //取得最大表情数 maxEmotcionSize = MaxEmticonFileSize(userID); //获取单个表情的最大限制 int currentFileSizes = 0; EmoticonGroup currentGroup = GetEmoticonGroup(userID, groupID); saveCount = 0; fileCount = 0; EmoticonCollection emoticons = new EmoticonCollection(); Emoticon tempEmote; string imgUrl; if (emotes.Count > 0) { bool stopSaveFile = false; foreach (KeyValuePair <string, List <EmoticonItem> > group in emotes) { foreach (EmoticonItem item in group.Value) { fileCount++; if (usedspaceSize + currentFileSizes + item.Size > canUseSpcaeSize) { if (!stopSaveFile) { ThrowError(new EmoticonSpaceOverflow(canUseSpcaeSize)); stopSaveFile = true; } break; } if (saveCount + usedEmoticonCount >= canUploadEmoticonCount) { if (!stopSaveFile) { ThrowError(new EmoticonFileCountOverflow(canUploadEmoticonCount)); stopSaveFile = true; } break; } switch (SaveEmoticonFile(userID, item.Data, item.MD5, item.FileName, out imgUrl)) { case EmoticonSaveStatus.Success: tempEmote = new Emoticon(); tempEmote.UserID = userID; tempEmote.GroupID = groupID; tempEmote.FileSize = item.Size; tempEmote.Shortcut = item.Shortcut; tempEmote.MD5 = item.MD5; tempEmote.ImageSrc = imgUrl; emoticons.Add(tempEmote); currentFileSizes += item.Size; saveCount++; break; } } //if (stopSaveFile) // break; } if (emoticons.Count > 0) { CreateEmoticons(userID, emoticons); currentGroup.TotalSizes += currentFileSizes; currentGroup.TotalEmoticons += saveCount; RemoveCacheByGroup(userID, groupID); } } }
public override void ToStream(Stream output) { output.Write(TLUtils.SignatureToBytes(Signature)); Emoticon.ToStream(output); Documents.ToStream(output); }
public void GroupImportEmoticon(int userID, Dictionary <string, List <EmoticonItem> > groupedEmoticonDatas , out int groupCount, out int fileCount, out int saveGroupcount, out int saveFileCount) { bool stopSaveFile = false; long maxEmotcionSize; //单个文件最大限制 long canUseSpcaeSize; //总可用空间大小 int canUploadEmoticonCount; //总可用表情数量 int usedEmoticonCount; long usedspaceSize = GetUserEmoticonStat(userID, out usedEmoticonCount); //已用空间大小 canUseSpcaeSize = MaxEmoticonSpace(userID); //取得最大可用空间 canUploadEmoticonCount = MaxEmoticonCount(userID); //取得最大表情数 maxEmotcionSize = MaxEmticonFileSize(userID); //获取单个表情的最大限制 int currentFileSizes = 0; string imgUrl; groupCount = 0; saveGroupcount = 0; fileCount = 0; saveFileCount = 0; Dictionary <string, EmoticonCollection> groupedEmoticons = new Dictionary <string, EmoticonCollection>(); foreach (KeyValuePair <string, List <EmoticonItem> > groups in groupedEmoticonDatas) { groupCount++; EmoticonCollection emoticons = new EmoticonCollection(); bool hasFileSaved = false; foreach (EmoticonItem item in groups.Value) { fileCount++; if (usedspaceSize + currentFileSizes + item.Size > canUseSpcaeSize) { if (!stopSaveFile) { ThrowError(new EmoticonSpaceOverflow(canUseSpcaeSize)); stopSaveFile = true; } break; } if (saveFileCount + usedEmoticonCount >= canUploadEmoticonCount) { if (!stopSaveFile) { ThrowError(new EmoticonFileCountOverflow(canUploadEmoticonCount)); stopSaveFile = true; } break; } switch (SaveEmoticonFile(userID, item.Data, item.MD5, item.FileName, out imgUrl)) { case EmoticonSaveStatus.Success: Emoticon emote = new Emoticon(); emote.ImageSrc = imgUrl; emote.MD5 = item.MD5; emote.Shortcut = item.Shortcut; emote.FileSize = item.Data.Length; emoticons.Add(emote); hasFileSaved = true; saveFileCount++; currentFileSizes += item.Size; break; } } if (hasFileSaved) { groupedEmoticons.Add(groups.Key, emoticons); } //if (stopSaveFile) // break; } if (groupCount > 0 && saveFileCount > 0) { CreateEmoticonsAndGroups(userID, groupedEmoticons); saveGroupcount = groupedEmoticons.Count; CacheUtil.RemoveBySearch(string.Format(cacheKey_ByGroupRoot, userID)); } }
public static Strcut_CFCBlock FromImage(Emoticon emoticon) { return CFCBuilder.GetFaceBlockFromImage(emoticon); }
protected override JProperty MainElement(Emoticon emoticon) { if (FileOutputOptions.IsLocalizedText) { AddLocalizedGameString(emoticon); } JObject emoticonObject = new JObject(); if (!string.IsNullOrEmpty(emoticon.Name) && !FileOutputOptions.IsLocalizedText) { emoticonObject.Add("expression", emoticon.Name); } if (!string.IsNullOrEmpty(emoticon.HyperlinkId)) { emoticonObject.Add("hyperlinkId", emoticon.HyperlinkId); } if (emoticon.IsAliasCaseSensitive) { emoticonObject.Add("caseSensitive", true); } if (emoticon.IsHidden) { emoticonObject.Add("isHidden", true); } if (emoticon.SearchTexts != null && emoticon.SearchTexts.Any() && !FileOutputOptions.IsLocalizedText) { emoticonObject.Add("searchText", string.Join(' ', emoticon.SearchTexts)); } if (!string.IsNullOrEmpty(emoticon.Description?.RawDescription) && !FileOutputOptions.IsLocalizedText) { emoticonObject.Add("description", GetTooltip(emoticon.Description, FileOutputOptions.DescriptionType)); } if (!string.IsNullOrEmpty(emoticon.DescriptionLocked?.RawDescription) && !FileOutputOptions.IsLocalizedText) { emoticonObject.Add("descriptionLocked", GetTooltip(emoticon.DescriptionLocked, FileOutputOptions.DescriptionType)); } if (emoticon.LocalizedAliases != null && emoticon.LocalizedAliases.Any() && !FileOutputOptions.IsLocalizedText) { emoticonObject.Add(new JProperty("localizedAliases", emoticon.LocalizedAliases)); } if (emoticon.UniversalAliases != null && emoticon.UniversalAliases.Any() && !FileOutputOptions.IsLocalizedText) { emoticonObject.Add(new JProperty("aliases", emoticon.UniversalAliases)); } if (!string.IsNullOrEmpty(emoticon.HeroId)) { emoticonObject.Add(new JProperty("heroId", emoticon.HeroId)); if (!string.IsNullOrEmpty(emoticon.HeroSkinId)) { emoticonObject.Add(new JProperty("heroSkinId", emoticon.HeroSkinId)); } } if (!string.IsNullOrEmpty(emoticon.Image.FileName)) { if (!emoticon.Image.Count.HasValue) { emoticonObject.Add("image", Path.ChangeExtension(emoticon.Image.FileName?.ToLowerInvariant(), StaticImageExtension)); } else { emoticonObject.Add("image", Path.ChangeExtension(emoticon.Image.FileName?.ToLowerInvariant(), AnimatedImageExtension)); } } JProperty?animation = AnimationObject(emoticon); if (animation != null) { emoticonObject.Add(animation); } return(new JProperty(emoticon.Id, emoticonObject)); }
public static PacketWriter Emoticon(Emoticon emoticon) { var pw = GetWriter(ClientPacketID.Emoticon); pw.WriteEnum(emoticon); return pw; }
public TwitchSmile( Emoticon emoticon ) { this.Regex = new Regex(emoticon.Regex); this.Uri = new Uri(emoticon.GetUri(), UriKind.RelativeOrAbsolute); //this.Icon = new BitmapImage(this.Uri); }
internal static Strcut_CFCBlock GetFaceBlockFromImage(Emoticon emoticon) { string filePath = IOUtil.ResolvePath(emoticon.ImageSrc); Strcut_CFCBlock fb = new Strcut_CFCBlock(); //���ļ��� //����ļ��Ƿ�ɾ�� if (!IOUtil.ExistsFile(filePath)) return null; FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); byte[] faceData = new byte[fs.Length]; fs.Read(faceData, 0, (int)fs.Length); //��ȡͼ�� Image img; try { img = Image.FromStream(fs); } catch { fs.Close(); return null; } //Image thumbnail = img.GetThumbnailImage(20, 20, null, IntPtr.Zero); MemoryStream ms = new MemoryStream(); //����ͼͼת����byte���� ImageHelper.CreateThunmbnailImage(img, ms, 20, 20, ImageFormat.Bmp); byte[] thumbnailData = ms.ToArray(); ms.Close(); ms.Dispose(); //thumbnail.Dispose(); //�õ�һ��Ψһ��MD5�ַ��� string md5 = GetMD5(fs); fs.Close(); //fs.Dispose(); //�ļ�������ʽΪ:md5 + ��չ�� string fileName = md5 + Path.GetExtension(emoticon.ImageSrc); //����ͼ�ļ�������ʽΪ��md5 + fixed.bmp string thumbnailName = string.Format("{0}fixed.bmp", md5); //����һ����ݼ� string uintcuts = emoticon.Shortcut; //ȡ���ܵ�֡�� System.Drawing.Imaging.FrameDimension fd = System.Drawing.Imaging.FrameDimension.Resolution; int frameCount = img.FrameDimensionsList.Length; img.Dispose(); fb.MD5 = md5; fb.MD5Length = (uint)md5.Length; fb.uintcuts = uintcuts; fb.uintcutLength = (uint)uintcuts.Length; fb.FaceName = uintcuts; fb.FaceNameLength = (uint)uintcuts.Length; fb.FaceFileName = fileName; fb.FaceFileNameLength = (uint)fileName.Length; fb.ThumbnailFileName = thumbnailName; fb.ThumbnailFileNameLength = (uint)thumbnailName.Length; fb.FaceData = File.ReadAllBytes(IOUtil.ResolvePath(emoticon.ImageSrc)); fb.FileLength = (uint)fb.FaceData.Length; fb.ThumbnailData = thumbnailData; fb.ThumbnailFileLength = (uint)thumbnailData.Length; fb.FrameLength = (uint)frameCount; return fb; }
public UIEmoticon(AnimatedSprite sprite, Emoticon emoticon) { Sprite = sprite; Emoticon = emoticon; }