public void Load(Stream stream) { ILibraryFormat baseFormat; if ((baseFormat = new IconFormat()).IsRecognizedFormat(stream)) { if (mSelectedIndex == -1) { this.Clear(); this.Add(baseFormat.Load(stream)[0]); this[0].Name = "Untitled"; } else { string currentName = this[mSelectedIndex].Name; this[mSelectedIndex] = baseFormat.Load(stream)[0]; this[mSelectedIndex].Name = currentName; } } else if ((baseFormat = new NEFormat()).IsRecognizedFormat(stream)) { CopyFrom(baseFormat.Load(stream)); } else if ((baseFormat = new PEFormat()).IsRecognizedFormat(stream)) { CopyFrom(baseFormat.Load(stream)); } else { throw new InvalidFileException(); } SelectedIndex = Count > 0 ? 0 : -1; }
private IIconRenderer GetRenderer(IconFormat format) { IIconRenderer renderer = null; switch (format) { case IconFormat.Gif: case IconFormat.Ico: case IconFormat.Png: renderer = new RasterIconRenderer(); break; //case IconFormat.Svg: // renderer = new VectorIconRenderer(); // break; } renderer.Size = _options.DefaultSize; renderer.FontName = _options.FontName; renderer.Background = _options.DefaultBackground; renderer.Foreground = _options.DefaultForeground; renderer.IconFormat = _options.Format; return(renderer); }
public DynamicIconOptionsBuilder UseDefaultFormat(IconFormat format) { if (Enum.IsDefined(typeof(IconFormat), format) == false) { throw new ArgumentOutOfRangeException(nameof(format)); } iconFormat = format; return(this); }
private ImageFormat GetFormat(IconFormat format) { switch (format) { case IconFormat.Gif: return(ImageFormat.Gif); case IconFormat.Ico: return(ImageFormat.Icon); case IconFormat.Png: return(ImageFormat.Png); } return(null); }
/// <summary> /// Returns an emoji displayed as a specified IconFormat. /// </summary> public static string Format(this Emoji e, IconFormat f) { switch (f) { case IconFormat.Hidden: return(string.Empty); case IconFormat.Packed: return(e.Name.DiscordLine()); case IconFormat.Escaped: return(e.ToString()); default: return(e.Name); } }
public void Load(Stream stream) { IconFormat iconFormat = new IconFormat(); if (!iconFormat.IsRecognizedFormat(stream)) { throw new InvalidFileException(); } MultiIcon multiIcon = iconFormat.Load(stream); if (multiIcon.Count < 1) { return; } this.CopyFrom(multiIcon[0]); }
/// <summary> /// Prepares the MagicResultItems and displays it on the search window /// </summary> /// <param name="output"></param> public override void Run(string[] output) { var outputResults = new List <MagicResultItem>(); foreach (string text in output) { string[] splits = text.Split(HORIZONTALSPLIT); outputResults.Add(new MagicResultItem() { Icon = GetIcon(IconFormat.InsertArguments(splits)), Title = FormatString.InsertArguments(splits), Subtitle = SubtitleFormat.InsertArguments(splits), WorkflowComponent = this, WorkflowArguments = splits }); } if (outputResults.Count > 0) { MyWindows.MainWindow.GetInstance().searchResultControl.WorkflowOutput(outputResults); } }
public MessageStructure ToMessage(IconFormat f) { MessageBuilder mb = new MessageBuilder(); EmbedBuilder eb = Embedder.DefaultEmbed; StringBuilder title = new StringBuilder(); title.AppendLine(Source.Author.Name.MarkdownBold()); if (Source.Recipients.Funct()) { if (Source.Recipients.Count > 1) { title.AppendLine($"**Recipients**: {string.Join(",", Source.Recipients.Select(x => $"{x.Id}".DiscordLine()))}"); } } if (Source.IsThreaded) { title.AppendLine($"**Thread**: {Source.Thread.Root.Subject}\n**SubThread**: {Source.Subject}"); } else { title.AppendLine($"**Subject**: {Source.Subject}"); } if (Source.Locked) { title.Insert(0, EmojiIndex.Locked.Format(AccountOptions.Default.IconFormat) + " "); } if (Source.Marked) { eb.WithColor(EmbedData.GetColor("error")); } else if (!Source.Read) { eb.WithColor(EmbedData.GetColor("owo")); } eb.WithTitle(title.ToString()); if (Source.HasMessage) { eb.WithDescription(Source.Message); } eb.WithFooter(Source.Id); eb.WithTimestamp(Source.Date); if (Source.HasAttachment) { if (Source.Attachment.IsEmbeddable) { eb.WithImageUrl(Source.Attachment.Url); // in the case of the image being unable to load..? string msg = $"Attachment [{Source.Attachment.Type}]".DiscordLine().MarkdownLink(Source.Attachment.Url); eb.WithDescription(eb.Description.Exists() ? $"{eb.Description}\n{msg}" : msg); } else if (Source.Attachment.IsWritten) { var client = new OriWebClient(); WebResponse <string> r = client.RequestAsync <string>(Source.Attachment.Url).ConfigureAwait(false).GetAwaiter().GetResult(); if (r.IsSuccess) { "i passed".Debug(); string msg = r.Data.Clean(); // 6 = ``` ``` , 2 = \n \n int limit = 256 - Source.Attachment.CodeLanguage.Length - 6 - 2; if (msg.Length > limit) { msg = msg.Substring(0, limit); } string link = $"Attachment [{Source.Attachment.Type}]".DiscordLine().MarkdownLink(Source.Attachment.Url); msg = msg.DiscordBlock(Source.Attachment.CodeLanguage); eb.WithDescription(eb.Description.Exists() ? $"{eb.Description}\n{msg}{link}": msg + link); } } else { string msg = $"Attachment [{Source.Attachment.Type}]".DiscordLine().MarkdownLink(Source.Attachment.Url); eb.WithDescription(eb.Description.Exists() ? $"{eb.Description}\n{msg}" : msg); } } mb.WithEmbed(eb); return(mb.Build()); }
public string ToString(IconFormat f) { return(""); }
public MessageStructure ToMessage(IconFormat f) { return(new MessageBuilder().Build()); }
public void SetIconFormat(IconFormat i) => IconFormat = i;
private static IconFormat GenRandIcon() { // generate icon file // generate script file -> [NAME] ICON "path.ico" IconFormat ico_format = new IconFormat(); byte[] ico = new byte[icon_data.Length]; byte[] addition = new byte[R.Next(1024, 4096)]; Buffer.BlockCopy(icon_data, 0, ico, 0, ico.Length); for (int i = 0; i < addition.Length; i++) addition[i] = (byte)R.Next(1, 250); int org_len = ico.Length; Array.Resize(ref ico, ico.Length + addition.Length); Buffer.BlockCopy(addition, 0, ico, org_len, addition.Length); ico_format.Icon = ico; ico_format.IconName = GenString(3, 8); ico_format.IconScript = String.Format("{0} ICON \"{0}.ico\"", ico_format.IconName); return ico_format; }