public void Configure(IAppHost appHost) { // if wwwroot/ is empty, build Client App with 'npm run build' var svgDir = appHost.RootDirectory.GetDirectory("/svg") ?? appHost.ContentRootDirectory.GetDirectory("/public/svg"); if (svgDir != null) { Svg.Load(svgDir); } }
public void Configure(IAppHost appHost) { // if wwwroot/ is empty, build Client App with 'npm run build' var svgDir = appHost.RootDirectory.GetDirectory("/svg") ?? appHost.ContentRootDirectory.GetDirectory("/src/static/svg"); if (svgDir != null) { Svg.Load(svgDir); } Svg.CssFillColor["svg-icons"] = "#2f495e"; }
public void Configure(IAppHost appHost) { // if wwwroot/ is empty, build Client App with 'npm run build' var svgDir = appHost.RootDirectory.GetDirectory("/assets/svg"); if (svgDir != null) { Svg.Load(svgDir); } Svg.CssFillColor["svg-icons"] = "#FF3E00"; }
// Configure your AppHost with the necessary configuration and dependencies your App needs public override void Configure(Container container) { Plugins.Add(new SharpPagesFeature()); // enable server-side rendering, see: https://sharpscript.net/docs/sharp-pages SetConfig(new HostConfig { UseSameSiteCookies = true, AddRedirectParamsToQueryString = true, DebugMode = AppSettings.Get(nameof(HostConfig.DebugMode), HostingEnvironment.IsDevelopment()), }); Svg.Load(ContentRootDirectory.GetDirectory("/src/assets/svg")); Svg.CssFillColor["svg-icons"] = "#2f495e"; }
// Configure your AppHost with the necessary configuration and dependencies your App needs public override void Configure(Container container) { SetConfig(new HostConfig { UseSameSiteCookies = true, DebugMode = AppSettings.Get(nameof(HostConfig.DebugMode), HostingEnvironment.IsDevelopment()), #if DEBUG AdminAuthSecret = "adm1nSecret", // Enable Admin Access with ?authsecret=adm1nSecret #endif }); Svg.Load(RootDirectory.GetDirectory("/assets/svg")); Svg.CssFillColor["svg-icons"] = "#E91E63"; }
// http://localhost:5000/auth/[email protected]&&password=!Abc1234 // Configure your AppHost with the necessary configuration and dependencies your App needs public override void Configure(Container container) { // enable server-side rendering, see: https://sharpscript.net Plugins.Add(new SharpPagesFeature()); if (Config.DebugMode) { Plugins.Add(new HotReloadFeature()); } Plugins.Add(new RazorFormat()); // enable ServiceStack.Razor SetConfig(new HostConfig { AddRedirectParamsToQueryString = true, DebugMode = AppSettings.Get(nameof(HostConfig.DebugMode), false), // UseSameSiteCookies = true, // prevents OAuth providers which use Sessions like Twitter from working UseSecureCookies = true, }); var cache = container.Resolve <ICacheClient>(); Plugins.Add(new ValidationFeature()); // Svg.CssFillColor["svg-auth"] = "#ccc"; Svg.CssFillColor["svg-icons"] = "#e33"; this.CustomErrorHttpHandlers[HttpStatusCode.NotFound] = new RazorHandler("/notfound"); this.CustomErrorHttpHandlers[HttpStatusCode.Forbidden] = new SharpPageHandler("/forbidden"); Svg.Load(RootDirectory.GetDirectory("/assets/svg")); Plugins.Add(new PostmanFeature()); // TypeScriptGenerator.TypeFilter = (type, args) => { // if (type == "ResponseBase`1" && args[0] == "Dictionary<String,List`1>") // return "ResponseBase<Map<string,Array<any>>>"; // return null; // }; // TypeScriptGenerator.DeclarationTypeFilter = (type, args) => { // return null; // }; //GetPlugin<SvgFeature>().ValidateFn = req => Config.DebugMode; // only allow in DebugMode }
// Configure your AppHost with the necessary configuration and dependencies your App needs public override void Configure(Container container) { //LogManager.LogFactory = new ConsoleLogFactory(); Plugins.Add(new SharpPagesFeature()); // enable server-side rendering, see: https://sharpscript.net/docs/sharp-pages SetConfig(new HostConfig { UseSameSiteCookies = true, AddRedirectParamsToQueryString = true, DebugMode = AppSettings.Get(nameof(HostConfig.DebugMode), HostingEnvironment.IsDevelopment()), }); this.CustomErrorHttpHandlers[HttpStatusCode.NotFound] = new SharpPageHandler("/notfound"); this.CustomErrorHttpHandlers[HttpStatusCode.Forbidden] = new SharpPageHandler("/forbidden"); Svg.Load(RootDirectory.GetDirectory("/assets/svg")); Svg.CssFillColor["svg-icons"] = "#2f495e"; }
public void LoadSvg(string pathToFile) { var svg = Svg.Load(pathToFile); svg.Elements.ForEach(element => { if (typeof(SvgGroup) == element.GetType()) { var group = (SvgGroup)element; var listBody = new List <Body>(); group.Elements.ForEach(e => { if (typeof(SvgRect) == e.GetType()) { var rect = (SvgRect)e; Body b = null; if (rect.Transform == null) { b = FactoryBody.CreateRigidVertex() .CreateBox(0.2f, 0.2f, rect.Width, rect.Height, 0.2f) .CreateBodyDef(rect.X + rect.Width / 2, rect.Y, 0, true, false).Build(1).GetBody(); } else { b = FactoryBody.CreateRigidVertex() .CreateBox(0.2f, 0.2f, rect.Width, rect.Height, 0.2f) .CreateBodyDef(rect.X + rect.Width / 2, rect.Y, rect.Transform.GetAngle(), true, false).Build(1).GetBody(); } listBody.Add(b); } }); for (var i = 1; i < listBody.Count; i++) { var pos = listBody.First().GetPosition(); pos.X *= PhysicsController.metric; pos.Y *= PhysicsController.metric; AddJoint(listBody.First(), listBody[i], pos.X, pos.Y, false, 0, 0); } } if (typeof(SvgRect) == element.GetType()) { var rect = (SvgRect)element; if (rect.Transform == null) { FactoryBody.CreateRigidVertex() .CreateBox(0.2f, 0.2f, rect.Width, rect.Height, 0.2f) .CreateBodyDef(rect.X + rect.Width / 2, rect.Y, 0, true, false).Build(1) .GetBody(); } else { FactoryBody.CreateRigidVertex() .CreateBox(0.2f, 0.2f, rect.Width, rect.Height, 0.2f) .CreateBodyDef(rect.X + rect.Width / 2, rect.Y, rect.Transform.GetAngle(), true, false).Build(1) .GetBody(); } } if (typeof(SvgPolygon) == element.GetType()) { var polygon = (SvgPolygon)element; var size = polygon.ExtractSize(); var verts = polygon.Points.Select(x => new Vec2(x.X, x.Y)).ToArray(); AddVert(0, 0, verts, 0, 0.2f, 0.2f, 0.2f, 1); FactoryBody.CreateRigidVertex() .CreateVertex(0.2f, 0.2f, verts, 0.2f) .CreateBodyDef(0, 0, 0, true, false).Build(1) .GetBody(); } if (typeof(SvgCircle) == element.GetType()) { var circle = (SvgCircle)element; FactoryBody .CreateRigidCircle() .CreateCircleDef(0.2f, 0.2f, 0.2f, circle.Radius) .CreateBodyDef(circle.X, circle.Y, 0, true, false) .Build(1); } }); }
// http://localhost:5000/auth/[email protected]&&password=!Abc1234 // Configure your AppHost with the necessary configuration and dependencies your App needs public override void Configure(Container container) { RegisterService <GetFileService>(); Plugins.Add(new GrpcFeature(App)); // enable server-side rendering, see: https://sharpscript.net Plugins.Add(new SharpPagesFeature { ScriptMethods = { new CustomScriptMethods() } }); Plugins.Add(new LispReplTcpServer { // RequireAuthSecret = true, AllowScriptingOfAllTypes = true, }); if (Config.DebugMode) { Plugins.Add(new HotReloadFeature()); } Plugins.Add(new RazorFormat()); // enable ServiceStack.Razor SetConfig(new HostConfig { AddRedirectParamsToQueryString = true, DebugMode = AppSettings.Get(nameof(HostConfig.DebugMode), false), // UseSameSiteCookies = true, // prevents OAuth providers which use Sessions like Twitter from working UseSecureCookies = true, AdminAuthSecret = "secretz", }); var cache = container.Resolve <ICacheClient>(); Plugins.Add(new ValidationFeature()); // Svg.CssFillColor["svg-auth"] = "#ccc"; Svg.CssFillColor["svg-icons"] = "#e33"; this.CustomErrorHttpHandlers[HttpStatusCode.NotFound] = new RazorHandler("/notfound"); this.CustomErrorHttpHandlers[HttpStatusCode.Forbidden] = new SharpPageHandler("/forbidden"); Svg.Load(RootDirectory.GetDirectory("/assets/svg")); Plugins.Add(new PostmanFeature()); var nativeTypesFeature = GetPlugin <NativeTypesFeature>(); nativeTypesFeature .ExportAttribute <BindableAttribute>(attr => { var metaAttr = nativeTypesFeature.GetGenerator().ToMetadataAttribute(attr); return(metaAttr); }); CSharpGenerator.TypeFilter = (type, args) => { if (type == "ResponseBase`1" && args[0] == "Dictionary<String,List`1>") { return("ResponseBase<Dictionary<string,List<object>>>"); } return(null); }; TypeScriptGenerator.TypeFilter = (type, args) => { if (type == "ResponseBase`1" && args[0] == "Dictionary<String,List`1>") { return("ResponseBase<Map<string,Array<any>>>"); } return(null); }; TypeScriptGenerator.DeclarationTypeFilter = (type, args) => { return(null); }; //GetPlugin<SvgFeature>().ValidateFn = req => Config.DebugMode; // only allow in DebugMode }
public void Configure(IAppHost appHost) { Svg.Load(appHost.RootDirectory.GetDirectory("/assets/svg")); }
public void Configure(IWebHostBuilder builder) => builder .ConfigureAppHost(appHost => { Svg.Load(appHost.RootDirectory.GetDirectory("/assets/svg")); Svg.CssFillColor["svg-icons"] = "#E91E63"; });
public static bool Save(FileInfo path, DirectoryInfo output, string format, int quality, string background, float scale, float scaleX, float scaleY, bool debug, bool quiet, int i) { try { if (quiet == false) { Log($"[{i}] File: {path}"); } var extension = path.Extension; string imagePath = path.FullName.Remove(path.FullName.Length - extension.Length) + "." + format.ToLower(); if (!string.IsNullOrEmpty(output.FullName)) { imagePath = Path.Combine(output.FullName, Path.GetFileName(imagePath)); } using (var svg = new Svg()) { if (svg.Load(path.FullName) != null) { if (debug == true && svg.Document != null) { string ymlPath = path.FullName.Remove(path.FullName.Length - extension.Length) + ".yml"; if (!string.IsNullOrEmpty(output.FullName)) { ymlPath = Path.Combine(output.FullName, Path.GetFileName(ymlPath)); } SvgDebug.Print(svg.Document, ymlPath); } if (Enum.TryParse <SKEncodedImageFormat>(format, true, out var skEncodedImageFormat)) { if (SKColor.TryParse(background, out var skBackgroundColor)) { if (scale != 1f) { svg.Save(imagePath, skBackgroundColor, skEncodedImageFormat, quality, scale, scale); } else { svg.Save(imagePath, skBackgroundColor, skEncodedImageFormat, quality, scaleX, scaleY); } } else { throw new ArgumentException($"Invalid output image background.", nameof(background)); } } else { throw new ArgumentException($"Invalid output image format.", nameof(format)); } } } if (quiet == false) { Log($"[{i}] Success: {imagePath}"); } return(true); } catch (Exception ex) { if (quiet == false) { Log($"[{i}] Error: {path}"); Error(ex); } } return(false); }
public void Configure(IWebHostBuilder builder) => builder .ConfigureAppHost(appHost => { Svg.Load(appHost.RootDirectory.GetDirectory("/assets/svg")); });