internal static string Get(SvgIcon Name) { if (Name != SvgIcon.None) { try { if (Svg.Cached.TryGetValue(Name, out string iconCache)) { return(iconCache); } else { var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "media", "icons", "svg", Svg.All[Name]); var svg = File.ReadAllText(path); var match = new Regex("<svg(S*?)[^>]*>[.\\s\\S]*?</svg>", RegexOptions.IgnoreCase).Match(svg); if (match.Success) { var icon = new Regex("<svg(S*?)[^>]*>").Replace(match.Value, "").Replace("</svg>", "").Replace("\n", ""); Svg.Cached.TryAdd(Name, icon); return(icon); } } } finally { } } return(""); }
private void InitializeAlertToast(AlertMode mode, string message) { InitializeDialog(); HideAllStacks(); AlertStack.IsVisible = true; switch (mode) { case AlertMode.Error: AlertIcon.Source = SvgIcon.GetSvgImageSource("Kheling.Mobile.Resources.error.svg", 32, 32, Color.Red); AlertMessage.TextColor = Color.Red; break; case AlertMode.Warning: AlertIcon.Source = SvgIcon.GetSvgImageSource("Kheling.Mobile.Resources.warning.svg", 32, 32, Color.Yellow); AlertMessage.TextColor = Color.Black; break; case AlertMode.Info: AlertIcon.Source = SvgIcon.GetSvgImageSource("Kheling.Mobile.Resources.info.svg", 32, 32, Color.Green); AlertMessage.TextColor = Color.Black; break; } AlertMessage.Text = message; }
protected override Android.Graphics.Drawables.Drawable GetIconDrawable(FileImageSource icon) { if (icon.File.StartsWith("svg:")) { string resourceid = icon.File.Replace("svg:", ""); SKBitmap skBitmap = SvgIcon.GetSvgBitmap(resourceid, 100, 100, new Xamarin.Forms.Color()); return(new BitmapDrawable(context.Resources, skBitmap.ToBitmap())); } else { return(base.GetIconDrawable(icon)); } }
private BitmapDrawable GetDrawable(string svgEntryImage) { var svg = SvgIcon.GetSvgBitmap(svgEntryImage, element.SvgWidthRequest, element.SvgHeightRequest, element.SvgColor); return(new BitmapDrawable(Resources, svg.ToBitmap())); }