/// <summary> /// If the request path starts with the given pathMatch, execute the app configured via configuration parameter instead of /// continuing to the next component in the pipeline. /// </summary> /// <param name="app"></param> /// <param name="pathMatch">The path to match</param> /// <param name="configuration">The branch to take for positive path matches</param> /// <returns></returns> public static IAppBuilder Map(this IAppBuilder app, PathString pathMatch, Action <IAppBuilder> configuration) { if (app == null) { throw new ArgumentNullException("app"); } if (configuration == null) { throw new ArgumentNullException("configuration"); } if (pathMatch.HasValue && pathMatch.Value.EndsWith("/", StringComparison.Ordinal)) { throw new ArgumentException(Resources.Exception_PathMustNotEndWithSlash, "pathMatch"); } // put middleware in pipeline before creating branch var options = new MapOptions { PathMatch = pathMatch }; IAppBuilder result = app.Use <MapMiddleware>(options); // create branch and assign to options IAppBuilder branch = app.New(); configuration(branch); options.Branch = (AppFunc)branch.Build(typeof(AppFunc)); return(result); }
// Constructor public MapOptionsForm(MapOptions options) { // Initialize InitializeComponent(); // Keep settings this.options = options; // Go for all configurations foreach (ConfigurationInfo t in General.Configs) { // Add config name to list int index = config.Items.Add(t); // Is this configuration currently selected? if (string.Compare(t.Filename, options.ConfigFile, true) == 0) { // Select this item config.SelectedIndex = index; } } //mxd. Select the first config if none are selected... if (config.SelectedIndex == -1 && config.Items.Count > 0) { config.SelectedIndex = 0; } }
public async Task <IActionResult> Map([FromBody] MapOptions options) { try { if (options.LocationGetCoord) { var fullAddress = (await _mapServices.GetFullAddress(options.Address)); if (fullAddress.Status == "ZERO_RESULTS") { return(NotFound()); } options.Location = fullAddress.Results.FirstOrDefault().Geometry.Location; options.LocationIsCoord = true; } return(new ObjectResult(_mapServices.GetUrlMap(options))); } catch (Exception e) { _logger.LogError(e.ToString()); return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError, "Error al generarl la referencia de ")); } }
public void Operands() { var map = new MapOptions <Simple>(); var app = new CommandLineApplication(); app.Argument("files", "Input files", true) .Map(map, to => to.Multiple); var result = app.Parse("input1.txt", "input2.txt"); var builder = new ConfigurationBuilder() .AddCommandLineOptions(map.FromCommand(result.SelectedCommand)) .Build(); var options = new Simple(); builder.Bind(options); options .Should() .BeEquivalentTo(new Simple { Multiple = new[] { "input1.txt", "input2.txt" } }); }
public void Options() { var map = new MapOptions <Simple>(); var app = new CommandLineApplication(); app.Option("-d|--debug", "flag", CommandOptionType.NoValue) .Map(map, to => to.Debug); var result = app.Parse("-d"); var builder = new ConfigurationBuilder() .AddCommandLineOptions(map.FromCommand(result.SelectedCommand)) .Build(); var options = new Simple(); builder.Bind(options); options .Should() .BeEquivalentTo(new Simple { Debug = true }); }
public void NotMappedShort() { var map = new MapOptions <Simple>(); var app = new CommandLineApplication(); app.Option("-c", "Input files", CommandOptionType.NoValue); var result = app.Parse("-c"); var builder = new ConfigurationBuilder() .AddCommandLineOptions(map.FromCommand(result.SelectedCommand)) .Build(); var options = new Simple(); builder.Bind(options); options .Should() .BeEquivalentTo(new Simple { C = true }); }
public void NotMapped() { var map = new MapOptions <Simple>(); var app = new CommandLineApplication(); app.Option("-m|--multiple <files>", "Input files", CommandOptionType.MultipleValue); var result = app.Parse("-m", "input1.txt", "--multiple", "input2.txt"); var builder = new ConfigurationBuilder() .AddCommandLineOptions(map.FromCommand(result.SelectedCommand)) .Build(); var options = new Simple(); builder.Bind(options); options .Should() .BeEquivalentTo(new Simple { Multiple = new[] { "input1.txt", "input2.txt" } }); }
public void SingleOrNoValue(bool expected, params string[] args) { var map = new MapOptions <Simple>(); var app = new CommandLineApplication(); app.Option <bool>("-d|--debug", "enable debug", CommandOptionType.SingleOrNoValue) .Map(map, to => to.Debug); var result = app.Parse(args); var builder = new ConfigurationBuilder() .AddCommandLineOptions(map.FromCommand(result.SelectedCommand)) .Build(); var options = new Simple(); builder.Bind(options); options .Should() .BeEquivalentTo(new Simple { Debug = expected }); }
private static IWebHost BuildWebHost(string[] args) { string contentRoot = GetContentRoot(); string dataDir = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "smtp4dev"); if (!Directory.Exists(dataDir)) { Directory.CreateDirectory(dataDir); } //Migrate to new location if (File.Exists(Path.Join(contentRoot, "database.db")) && !File.Exists(Path.Join(dataDir, "database.db"))) { File.Move( Path.Join(contentRoot, "database.db"), Path.Join(dataDir, "database.db") ); } bool noUserSettings; MapOptions <CommandLineOptions> commandLineOptions = TryParseCommandLine(args, out noUserSettings); if (commandLineOptions == null) { Environment.Exit(1); return(null); } Directory.SetCurrentDirectory(dataDir); return(WebHost .CreateDefaultBuilder(args) .UseContentRoot(contentRoot) .ConfigureAppConfiguration( (hostingContext, configBuilder) => { IWebHostEnvironment env = hostingContext.HostingEnvironment; IConfigurationBuilder cb = configBuilder .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); if (!noUserSettings) { cb = cb.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); cb = cb.AddJsonFile(Path.Join(dataDir, "appsettings.json"), optional: true, reloadOnChange: true); } IConfigurationRoot config = cb .AddEnvironmentVariables() .AddCommandLineOptions(commandLineOptions) .Build(); hostingContext.HostingEnvironment.EnvironmentName = config["Environment"]; }) .UseStartup <Startup>() .Build()); }
public Task Init(string id, MapOptions options) { return(_jsRuntime.JsonNetInvokeAsync <bool>( "googleMapJsFunctions.init", id, options)); }
// Constructor public MapOptionsForm(MapOptions options) { int index; // Initialize InitializeComponent(); // Keep settings this.options = options; // Go for all configurations for (int i = 0; i < General.Configs.Count; i++) { // Add config name to list index = config.Items.Add(General.Configs[i]); // Is this configuration currently selected? if (string.Compare(General.Configs[i].Filename, options.ConfigFile, true) == 0) { // Select this item config.SelectedIndex = index; } } // Set the level name levelname.Text = options.CurrentName; // Set strict patches loading strictpatches.Checked = options.StrictPatches; // Fill the resources list datalocations.EditResourceLocationList(options.Resources); }
public GMap() { Options = new MapOptions() { Zoom = 10, Center = new LatLngLiteral(-105D, 54D), MapTypeId = MapTypeId.Roadmap }; }
public ChangeMapForm(string filepathname, MapOptions options) { InitializeComponent(); CodeImp.DoomBuilder.General.ApplyMonoListViewFix(mapslist); this.options = options; this.filepathname = filepathname; }
public static void ParseOptions(HttpRequest request, IDictionary<string, Object> queryDefaults, ref MapOptions options, ref Stylesheet.Style style) { options = (MapOptions)GetIntOption(request, "options", queryDefaults, (int)options); #if LEGACY_STYLES // Handle deprecated/legacy options bits for selecting style style = (options & MapOptions.StyleMaskDeprecated) == MapOptions.PrintStyleDeprecated ? Stylesheet.Style.Atlas : (options & MapOptions.StyleMaskDeprecated) == MapOptions.CandyStyleDeprecated ? Stylesheet.Style.Candy : Stylesheet.Style.Poster; #endif // LEGACY_STYLES if (HasOption(request, "style", queryDefaults)) { switch (GetStringOption(request, "style", queryDefaults).ToLowerInvariant()) { case "poster": style = Stylesheet.Style.Poster; break; case "atlas": style = Stylesheet.Style.Atlas; break; case "print": style = Stylesheet.Style.Print; break; case "candy": style = Stylesheet.Style.Candy; break; case "draft": style = Stylesheet.Style.Draft; break; case "fasa": style = Stylesheet.Style.FASA; break; } } }
static void DeleteOutPath(this MapOptions options) { if (Directory.Exists(options.OutPath)) { Directory.Delete(options.OutPath, true); } }
public void Configure(IApplicationBuilder app) { //Use MapMiddleWare and MapWhenMiddlware directly var whenOption = new MapWhenOptions { Branch = context => context.Response.WriteAsync($"Path: {context.Request.Path} - Path Base: {context.Request.PathBase}"), Predicate = context => context.Request.Path.Value.Contains("hello") }; app.UseMiddleware <MapWhenMiddleware>(whenOption); var mapOption = new MapOptions { Branch = context => context.Response.WriteAsync($"Path: {context.Request.Path} - Path Base: {context.Request.PathBase}"), PathMatch = "/greetings" }; app.UseMiddleware <MapMiddleware>(mapOption); app.Run(context => { context.Response.Headers.Add("content-type", "text/html"); return(context.Response.WriteAsync(@" <a href=""/hello"">/hello</a> <a href=""/greetings"">/greetings</a> ")); }); }
public TestsPage() { this.firstLat = 50.24; this.secondLat = 50.30; this.firstLng = 18.62; this.secondLng = 18.75; this.matTheme = new MatTheme() { Primary = "#CBE54E" }; this.mapOptions = new MapOptions() { DivId = "mapId", Center = new LatLng(50.279133, 18.685578), Zoom = 13, UrlTileLayer = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", SubOptions = new MapSubOptions() { Attribution = "© <a lhref='http://www.openstreetmap.org/copyright'>OpenStreetMap</a>", MaxZoom = 18, TileSize = 512, ZoomOffset = -1, } }; }
public const double MaxScale = 512; // Math.Pow(2, 9); protected void ParseOptions(ref MapOptions options, ref Stylesheet.Style style) { options = (MapOptions)GetIntOption("options", (int)options); #if LEGACY_STYLES // Handle deprecated/legacy options bits for selecting style style = (options & MapOptions.StyleMaskDeprecated) == MapOptions.PrintStyleDeprecated ? Stylesheet.Style.Atlas : (options & MapOptions.StyleMaskDeprecated) == MapOptions.CandyStyleDeprecated ? Stylesheet.Style.Candy : Stylesheet.Style.Poster; #endif // LEGACY_STYLES if (HasOption("style")) { switch (GetStringOption("style").ToLowerInvariant()) { case "poster": style = Stylesheet.Style.Poster; break; case "atlas": style = Stylesheet.Style.Atlas; break; case "print": style = Stylesheet.Style.Print; break; case "candy": style = Stylesheet.Style.Candy; break; } } }
public static MapSpecification PrepareMapFromCenterZoom( int widthPixels, int heightPixels, double centerLatitude, double centerLongitude, double zoom) { // Options MapOptions mapOptions = new MapOptions(); mapOptions.ReturnType = MapReturnType.ReturnImage; mapOptions.Format = new ImageFormat(); mapOptions.Format.Width = widthPixels; mapOptions.Format.Height = heightPixels; mapOptions.Format.MimeType = "image/gif"; mapOptions.Zoom = zoom; // View ViewByScale[] viewByScaleArray = new ViewByScale[1]; viewByScaleArray[0] = new ViewByScale(); viewByScaleArray[0].CenterPoint = new LatLong(); viewByScaleArray[0].CenterPoint.Latitude = centerLatitude; viewByScaleArray[0].CenterPoint.Longitude = centerLongitude; viewByScaleArray[0].MapScale = 1.0; // Specifications MapSpecification mapSpecification = new MapSpecification(); mapSpecification.Options = mapOptions; mapSpecification.Views = viewByScaleArray; mapSpecification.DataSourceName = "MapPoint.NA"; return(mapSpecification); }
public static IAppBuilder MapAndContinue(this IAppBuilder app, PathString pathMatch, Action <IAppBuilder> configuration) { if (app == null) { throw new ArgumentNullException("app"); } if (configuration == null) { throw new ArgumentNullException("configuration"); } if (pathMatch.HasValue && pathMatch.Value.EndsWith("/", StringComparison.Ordinal)) { throw new ArgumentException("Path must not end with slash '/'", "pathMatch"); } // put middleware in pipeline before creating branch var options = new MapOptions { PathMatch = pathMatch }; var result = app.Use <MapAndContinueMiddleware>(options); // create branch and assign to options IAppBuilder branch = app.New(); configuration(branch); options.Branch = (Func <IDictionary <string, object>, Task>)branch.Build(typeof(Func <IDictionary <string, object>, Task>)); return(result); }
/// <summary> /// Branches the request pipeline based on matches of the given request path. If the request path starts with /// the given path, the branch is executed. /// </summary> /// <param name="app">The <see cref="IApplicationBuilder"/> instance.</param> /// <param name="pathMatch">The request path to match.</param> /// <param name="configuration">The branch to take for positive path matches.</param> /// <returns>The <see cref="IApplicationBuilder"/> instance.</returns> public static IApplicationBuilder Map(this IApplicationBuilder app, PathString pathMatch, Action <IApplicationBuilder> configuration) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (pathMatch.HasValue && pathMatch.Value.EndsWith("/", StringComparison.Ordinal)) { throw new ArgumentException("The path must not end with a '/'", nameof(pathMatch)); } // create branch var branchBuilder = app.New(); configuration(branchBuilder); var branch = branchBuilder.Build(); var options = new MapOptions { Branch = branch, PathMatch = pathMatch, }; return(app.Use(next => new MapMiddleware(next, options).Invoke)); }
public void OptionArguments() { var map = new MapOptions <Simple>(); var app = new CommandLineApplication(); app.Option("-f|--files <files>", "Input files", CommandOptionType.MultipleValue) .Map(map, to => to.Multiple); var result = app.Parse("-f", "input1.txt", "--files", "input2.txt"); var builder = new ConfigurationBuilder() .AddJsonFile("test.json") .AddCommandLineOptions(map.FromCommand(result.SelectedCommand)) .Build(); var options = new Simple(); builder.Bind(options); options .Should() .BeEquivalentTo(new Simple { Multiple = new[] { "input1.txt", "input2.txt" }, Single = "my-value" }); }
public override Mipmap Map(MapOptions op, uint mipmap, uint face, bool uncompress) { if (face + offsetFace >= faceCount) { throw new IndexOutOfRangeException("Face index is out of image's range."); } Monitor.Enter(syncRoot); try { // We lock and extract subregion. internalMipmapLocked = internalImage.Map(op, mipmap, face, uncompress); // We check if reading is required. if (op != MapOptions.Write) { lockedMipmap = new Mipmap(width, height, depth, face, mipmap, null, this); } else { } throw new NotImplementedException(); } catch (Exception) { Monitor.Exit(syncRoot); // Rethrow. throw; } }
protected override void OnInitialized() { mapOptions = new MapOptions() { Zoom = 16, Center = new LatLngLiteral() { Lat = -31.74230723298461, Lng = -60.494505564961386 }, MapTypeId = MapTypeId.Roadmap, ZoomControl = true, DisableDefaultUI = true }; polygonOptions = new PolygonOptions() { StrokeWeight = 0, FillOpacity = 0.45f, Draggable = true, Editable = true, FillColor = "#FF0000", StrokeColor = "#FF0000", }; }
private void HideOptions() { if (mapOptions != null) { mapOptions.Cancel(); mapOptions = null; } }
public void Map(MapOptions op) { if (indexBuffer != null) { indexBuffer.Map(op); } query.Map(op); }
public void Map(MapOptions op, params string[] components) { if (indexBuffer != null) { indexBuffer.Map(op); } query.Map(op, components); }
// Constructor public OpenMapOptionsForm(string filepathname) { // Initialize InitializeComponent(); this.Text = "Open Map from " + Path.GetFileName(filepathname); this.filepathname = filepathname; this.options = null; }
public async Task InitAsync(string id, MapOptions options) { DivId = id; await JsFunctionInterop.Init(id, options); MapComponentInstances.Add(id, this); }
public void NullArguments_ArgumentNullException() { var builder = new ApplicationBuilder(serviceProvider: null !); var noMiddleware = new ApplicationBuilder(serviceProvider: null !).Build(); var noOptions = new MapOptions(); Assert.Throws <ArgumentNullException>(() => builder.Map("/foo", configuration: null !)); Assert.Throws <ArgumentNullException>(() => new MapMiddleware(noMiddleware, null !)); }
// Constructor public OpenMapOptionsForm(string filepathname, MapOptions options) { // Initialize InitializeComponent(); this.Text = "Open Map from " + Path.GetFileName(filepathname); this.filepathname = filepathname; this.options = options; datalocations.EditResourceLocationList(options.Resources); }
public void NullArguments_ArgumentNullException() { var builder = new AppBuilder(); var noMiddleware = new AppBuilder().Build<AppFunc>(); var noOptions = new MapOptions(); Assert.Throws<ArgumentNullException>(() => builder.Map(null, ActionNotImplemented)); Assert.Throws<ArgumentNullException>(() => builder.Map("/foo", (Action<IAppBuilder>)null)); Assert.Throws<ArgumentNullException>(() => new MapMiddleware(null, noOptions)); Assert.Throws<ArgumentNullException>(() => new MapMiddleware(noMiddleware, null)); }
public void GenerateMap(MapOptions mapOptions) { Debug.Log(waypoints.Count()); this.mapOptions = mapOptions; Debug.Log("Generating Map with " + this.mapOptions.maxWaypoints + " Waypoints."); CreateWaypoint(Vector3.zero, null); UpdateBackgroundPlane(); this.mapOptions = null; }
private const float WorldUwpMinScale = 96; // Above this: UWP shown above name #endregion Fields #region Constructors public Stylesheet(double scale, MapOptions options, Style style) { grayscale = false; subsectorGrid.visible = ((scale >= SubsectorsMinScale) && options.HasFlag(MapOptions.SubsectorGrid)); sectorGrid.visible = ((scale >= SectorGridMinScale) && options.HasFlag(MapOptions.SectorGrid)); parsecGrid.visible = (scale >= ParsecMinScale); showSomeSectorNames = ((scale >= SectorNameMinScale) && (scale <= SectorNameMaxScale) && ((options & MapOptions.SectorsMask) != 0)); showAllSectorNames = showSomeSectorNames && ((scale >= SectorNameAllSelectedScale) || options.HasFlag(MapOptions.SectorsAll)); subsectorNames.visible = ((scale >= SubsectorNameMinScale) && (scale <= SubsectorNameMaxScale) && ((options & MapOptions.SectorsMask) != 0)); worlds.visible = (scale >= WorldMinScale); pseudoRandomStars.visible = (PseudoRandomStarsMinScale <= scale) && (scale <= PseudoRandomStarsMaxScale); showRifts = (scale <= PseudoRandomStarsMaxScale || style == Style.Candy); float logscale = (float)Math.Log(scale, 2.0); riftOpacity = Util.Clamp((logscale - -2f) / (2f - -2f), 0.0f, 1.0f) * 0.85f; deepBackgroundOpacity = 1.0f - Util.Clamp((logscale - -3f) / (0f - -3f), 0f, 1f); macroRoutes.visible = (scale >= MacroRouteMinScale) && (scale <= MacroRouteMaxScale); macroNames.visible = (scale >= MacroLabelMinScale) && (scale <= MacroLabelMaxScale); showMicroNames = ((scale >= MicroNameMinScale) && ((options & MapOptions.NamesMask) != 0)); capitals.visible = (scale >= MacroWorldsMinScale) && (scale <= MacroWorldsMaxScale); microBorderStyle = (((options & MapOptions.ForceHexes) == 0) && (scale < ParsecHexMinScale)) ? MicroBorderStyle.Square : MicroBorderStyle.Hex; macroBorders.visible = (scale >= MacroBorderMinScale) && (scale < MicroBorderMinScale) && ((options & MapOptions.BordersMask) != 0); microBorders.visible = (scale >= MicroBorderMinScale) && ((options & MapOptions.BordersMask) != 0); fillMicroBorders = microBorders.visible && options.HasFlag(MapOptions.FilledBorders); microRoutes.visible = (scale >= RouteMinScale); worldDetails = !worlds.visible ? 0 : (scale < WorldBasicMinScale) ? WorldDetails.Dotmap : (scale < WorldFullMinScale) ? WorldDetails.Atlas : WorldDetails.Poster; showWorldDetailColors = worldDetails == WorldDetails.Poster && options.HasFlag(MapOptions.WorldColors); lowerCaseAllegiance = (scale < WorldFullMinScale); worlds.textBackgroundStyle = TextBackgroundStyle.Rectangle; hexCoordinateStyle = HexCoordinateStyle.Sector; if (scale < WorldFullMinScale) { // Atlas-style const float x = 0.225f; const float y = 0.125f; BaseTopPosition.X = -x; BaseTopPosition.Y = -y; BaseBottomPosition.X = -x; BaseBottomPosition.Y = y; GasGiantPosition.X = x; GasGiantPosition.Y = -y; AllegiancePosition.X = x; AllegiancePosition.Y = y; BaseMiddlePosition.X = options.HasFlag(MapOptions.ForceHexes) ? -0.35f : -0.2f; BaseMiddlePosition.Y = 0; StarportPosition.X = 0.0f; StarportPosition.Y = -0.24f; worlds.position.X = 0.0f; worlds.position.Y = 0.4f; } else { // Poster-style const float x = 0.25f; const float y = 0.18f; BaseTopPosition.X = -x; BaseTopPosition.Y = -y; BaseBottomPosition.X = -x; BaseBottomPosition.Y = y; GasGiantPosition.X = x; GasGiantPosition.Y = -y; AllegiancePosition.X = x; AllegiancePosition.Y = y; BaseMiddlePosition.X = -0.35f; BaseMiddlePosition.Y = 0f; StarportPosition.X = 0f; StarportPosition.Y = -0.225f; worlds.position.X = 0.0f; worlds.position.Y = 0.37f; // Don't hide hex bottom, leave room for UWP } if (scale >= WorldUwpMinScale) { worldDetails |= WorldDetails.Uwp; BaseBottomPosition.Y = 0.1f; BaseMiddlePosition.Y = (BaseBottomPosition.Y + BaseTopPosition.Y) / 2; AllegiancePosition.Y = 0.1f; } if (worlds.visible) { float fontScale = (scale <= 96f || style == Style.Candy) ? 1f : 96f / (float)scale; worlds.fontInfo = new FontInfo(DEFAULT_FONT, scale < WorldFullMinScale ? 0.2f : 0.15f * fontScale, XFontStyle.Bold); wingdingFont = new FontInfo("Wingdings", scale < WorldFullMinScale ? 0.2f : 0.175f * fontScale); glyphFont = new FontInfo(DEFAULT_FONT, scale < WorldFullMinScale ? 0.175f : 0.15f * fontScale, XFontStyle.Bold); hexNumber.fontInfo = new FontInfo(DEFAULT_FONT, 0.1f * fontScale); worlds.smallFontInfo = new FontInfo(DEFAULT_FONT, scale < WorldFullMinScale ? 0.2f : 0.1f * fontScale, XFontStyle.Regular); starportFont = (scale < WorldFullMinScale) ? worlds.smallFontInfo : worlds.fontInfo; } sectorName.fontInfo = new FontInfo(DEFAULT_FONT, 5.5f); subsectorNames.fontInfo = new FontInfo(DEFAULT_FONT, 1.5f); microBorders.fontInfo = new FontInfo(DEFAULT_FONT, (scale == MicroNameMinScale) ? 0.6f : 0.25f, XFontStyle.Bold); microBorders.smallFontInfo = new FontInfo(DEFAULT_FONT, 0.15f, XFontStyle.Bold); microBorders.largeFontInfo = new FontInfo(DEFAULT_FONT, 0.75f, XFontStyle.Bold); macroNames.fontInfo = new FontInfo(DEFAULT_FONT, 8f / 1.4f, XFontStyle.Bold); macroNames.smallFontInfo = new FontInfo(DEFAULT_FONT, 5f / 1.4f, XFontStyle.Regular); capitals.fillColor = Color.Wheat; capitals.textColor = Color.Red; blueZone.pen.color = Color.Blue; amberZone.pen.color = Color.Gold; redZone.pen.color = Color.Red; macroBorders.pen.color = Color.Red; macroRoutes.pen.color = Color.White; microBorders.pen.color = Color.Gray; Color gridColor = Color.Gray; microRoutes.pen.color = Color.Green; Color foregroundColor = Color.White; backgroundColor = Color.Black; Color lightColor = Color.LightGray; Color darkColor = Color.DarkGray; Color dimColor = Color.DimGray; Color highlightColor = Color.Red; microBorders.textColor = Color.Gold; worldWater.fillColor = Color.DeepSkyBlue; worldNoWater.fillColor = Color.White; worldNoWater.pen.color = Color.Empty; float onePixel = 1f / (float)scale; parsecGrid.pen = new PenInfo(gridColor, onePixel); subsectorGrid.pen = new PenInfo(gridColor, onePixel * 2); sectorGrid.pen = new PenInfo(gridColor, (subsectorGrid.visible ? 4 : 2) * onePixel); microBorders.textStyle.Rotation = 0; microBorders.textStyle.Translation = new PointF(0, 0); microBorders.textStyle.Scale = new SizeF(1.0f, 1.0f); microBorders.textStyle.Uppercase = false; sectorName.textStyle.Rotation = -50; sectorName.textStyle.Translation = new PointF(0, 0); sectorName.textStyle.Scale = new SizeF(0.75f, 1.0f); sectorName.textStyle.Uppercase = false; sectorName.textStyle.Wrap = true; subsectorNames.textStyle = sectorName.textStyle; worlds.textStyle.Rotation = 0; worlds.textStyle.Scale = new SizeF(1.0f, 1.0f); worlds.textStyle.Translation = worlds.position; worlds.textStyle.Uppercase = false; useBackgroundImage = false; useGalaxyImage = false; useWorldImages = false; switch (style) { case Style.Poster: { // This is the default - no changes useGalaxyImage = deepBackgroundOpacity > 0.0f; break; } case Style.Atlas: { deepBackgroundOpacity = 0f; grayscale = true; capitals.fillColor = Color.DarkGray; capitals.textColor = Color.Black; amberZone.pen.color = Color.LightGray; blueZone.pen.color = Color.Gray; // TODO: make dashed redZone.pen.color = Color.Black; macroBorders.pen.color = Color.Black; macroRoutes.pen.color = Color.Gray; microBorders.pen.color = Color.Black; microRoutes.pen.color = Color.Gray; foregroundColor = Color.Black; backgroundColor = Color.White; lightColor = Color.DarkGray; darkColor = Color.DarkGray; dimColor = Color.LightGray; highlightColor = Color.Gray; microBorders.textColor = Color.Gray; worldWater.fillColor = Color.Black; worldNoWater.fillColor = Color.Empty; worldNoWater.fillColor = Color.White; worldNoWater.pen = new PenInfo(Color.Black, onePixel); riftOpacity = Math.Min(riftOpacity, 0.70f); showWorldDetailColors = false; break; } case Style.Print: { deepBackgroundOpacity = 0f; foregroundColor = Color.Black; backgroundColor = Color.White; lightColor = Color.DarkGray; darkColor = Color.DarkGray; dimColor = Color.LightGray; microRoutes.pen.color = Color.Gray; microBorders.textColor = Color.Brown; amberZone.pen.color = Color.Gold; worldNoWater.fillColor = Color.White; worldNoWater.pen = new PenInfo(Color.Black, onePixel); riftOpacity = Math.Min(riftOpacity, 0.70f); break; } case Style.Candy: { useWorldImages = true; pseudoRandomStars.visible = false; useBackgroundImage = deepBackgroundOpacity < 1.0f; useGalaxyImage = deepBackgroundOpacity > 0.0f; microBorderStyle = MicroBorderStyle.Curve; sectorGrid.visible = sectorGrid.visible && (scale >= 4 && scale < 32); subsectorGrid.visible = subsectorGrid.visible && (scale >= 32); parsecGrid.visible = false; subsectorGrid.pen.width = 0.03f * (64.0f / (float)scale); subsectorGrid.pen.DashPattern = new double[] { 10.0, 8.0 }; sectorGrid.pen.width = 0.03f * (64.0f / (float)scale); sectorGrid.pen.DashPattern = new double[] { 10.0, 8.0 }; worlds.textBackgroundStyle = TextBackgroundStyle.Shadow; worldDetails = worldDetails & ~WorldDetails.Starport & ~WorldDetails.Allegiance & ~WorldDetails.Bases & ~WorldDetails.Hex; if (scale < CandyMinWorldNameScale) worldDetails = worldDetails & ~WorldDetails.KeyNames & ~WorldDetails.AllNames; if (scale < CandyMinUwpScale) worldDetails = worldDetails & ~WorldDetails.Uwp; amberZone.pen.color = Color.Goldenrod; sectorName.textStyle.Rotation = 0; sectorName.textStyle.Translation = new PointF(0, -0.25f); sectorName.textStyle.Scale = new SizeF(0.5f, 0.25f); sectorName.textStyle.Uppercase = true; subsectorNames.textStyle.Rotation = 0; subsectorNames.textStyle.Translation = new PointF(0, -0.25f); subsectorNames.textStyle.Scale = new SizeF(0.3f, 0.15f); // Expand subsectorNames.textStyle.Uppercase = true; microBorders.textStyle.Rotation = 0; microBorders.textStyle.Translation = new PointF(0, 0.25f); microBorders.textStyle.Scale = new SizeF(1.0f, 0.5f); // Expand microBorders.textStyle.Uppercase = true; microBorders.pen.color = Color.FromArgb(128, Color.Red); worlds.textStyle.Rotation = 0; worlds.textStyle.Scale = new SizeF(1f, 0.5f); // Expand worlds.textStyle.Translation = new PointF(0, 0); worlds.textStyle.Uppercase = true; if (scale > CandyMaxWorldRelativeScale) { hexContentScale = CandyMaxWorldRelativeScale / (float)scale; } break; } } sectorName.textColor = scale < 16 ? foregroundColor : scale < 48 ? darkColor : dimColor; subsectorNames.textColor = scale < 16 ? foregroundColor : scale < 48 ? darkColor : dimColor; // Cap pen widths when zooming in float penScale = (scale <= 64) ? 1f : (64f / (float)scale); float borderPenWidth = (scale < MicroBorderMinScale) ? 1 : // When rendering vector borders (scale < ParsecMinScale) ? 1 : // When not rendering "hexes" 0.16f * penScale; // ... but cut in half by clipping float routePenWidth = scale <= 16 ? 0.2f : 0.08f * penScale; microBorders.pen.width = borderPenWidth; macroBorders.pen.width = borderPenWidth; microRoutes.pen.width = routePenWidth; amberZone.pen.width = redZone.pen.width = blueZone.pen.width = 0.05f * penScale; macroRoutes.pen.width = borderPenWidth; macroRoutes.pen.DashStyle = XDashStyle.Dash; if (style == Style.Candy) { subsectorNames.textColor = sectorName.textColor = Color.FromArgb(128, Color.Goldenrod); amberZone.pen.width = redZone.pen.width = blueZone.pen.width = 0.035f; microRoutes.pen.width = scale < CandyMaxRouteRelativeScale ? routePenWidth : routePenWidth / 2; macroBorders.pen.width = scale < CandyMaxBorderRelativeScale ? borderPenWidth : borderPenWidth / 4; microBorders.pen.width = scale < CandyMaxBorderRelativeScale ? borderPenWidth : borderPenWidth / 4; } preferredMimeType = (style == Style.Candy) ? System.Net.Mime.MediaTypeNames.Image.Jpeg : Util.MediaTypeName_Image_Png; pseudoRandomStars.fillColor = foregroundColor; macroNames.textColor = foregroundColor; macroNames.textHighlightColor = highlightColor; macroRoutes.textColor = foregroundColor; macroRoutes.textHighlightColor = highlightColor; worlds.textColor = foregroundColor; worlds.textHighlightColor = highlightColor; hexNumber.textColor = lightColor; imageBorderColor = lightColor; }
public RenderContext(ResourceManager resourceManager, Selector selector, RectangleF tileRect, double scale, MapOptions options, Stylesheet styles, Size tileSize) { this.resourceManager = resourceManager; this.selector = selector; this.tileRect = tileRect; this.scale = scale; this.options = options; this.styles = styles; this.tileSize = tileSize; XMatrix m = new XMatrix(); m.TranslatePrepend((float)(-tileRect.Left * scale * Astrometrics.ParsecScaleX), (float)(-tileRect.Top * scale * Astrometrics.ParsecScaleY)); m.ScalePrepend((float)scale * Astrometrics.ParsecScaleX, (float)scale * Astrometrics.ParsecScaleY); imageSpaceToWorldSpace = m; m.Invert(); worldSpaceToImageSpace = m; }
protected void ParseOptions(ref MapOptions options, ref Stylesheet.Style style) { ParseOptions(context.Request, Defaults(context), ref options, ref style); }
public void Paint(XGraphics graphics, RectangleF rect, MapOptions options, Color dotColor, XBrush labelBrush, XFont labelFont) { if (graphics == null) throw new ArgumentNullException("graphics"); Point pt = Astrometrics.LocationToCoordinates(Location); using (RenderUtil.SaveState(graphics)) { graphics.SmoothingMode = XSmoothingMode.HighSpeed; graphics.TranslateTransform(pt.X, pt.Y); graphics.ScaleTransform(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY); const float radius = 3; XBrush brush = new XSolidBrush(dotColor); XPen pen = new XPen(dotColor); graphics.DrawEllipse(brush, -radius / 2, -radius / 2, radius, radius); graphics.SmoothingMode = XSmoothingMode.HighQuality; graphics.DrawEllipse(pen, -radius / 2, -radius / 2, radius, radius); XStringFormat format = (LabelBiasX == -1) ? RenderUtil.StringFormatTopRight : (LabelBiasX == 1) ? RenderUtil.StringFormatTopLeft : RenderUtil.StringFormatTopCenter; XSize size = graphics.MeasureString(Name, labelFont); XPoint pos = new XPoint(0, 0); //pos.X += ( LabelBiasX * radius / 2 ) + ( -size.Width * ( 1 - LabelBiasX ) / 2.0f ); pos.Y += (LabelBiasY * radius / 2) + (-size.Height * (1 - LabelBiasY) / 2.0f); pos.X += (LabelBiasX * radius / 2); //pos.Y += ( LabelBiasY * radius / 2 ); graphics.DrawString(Name, labelFont, labelBrush, pos.X, pos.Y, format); } }
public void DrawName(XGraphics graphics, RectangleF rect, MapOptions options, XFont font, XBrush textBrush, LabelStyle labelStyle) { if (graphics == null) throw new ArgumentNullException("graphics"); RectangleF bounds = TransformedBounds; if (bounds.IntersectsWith(rect)) { if (Name != null) { string str = Name; if (labelStyle.Uppercase) str = str.ToUpperInvariant(); PointF pos = NamePosition;// PointF( bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2 ); using (RenderUtil.SaveState(graphics)) { XMatrix matrix = new XMatrix(); matrix.TranslatePrepend(pos.X, pos.Y); matrix.ScalePrepend(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY); matrix.RotatePrepend(-labelStyle.Rotation); // Rotate it graphics.MultiplyTransform(matrix, XMatrixOrder.Prepend); XSize size = graphics.MeasureString(str, font); graphics.TranslateTransform(-size.Width / 2, -size.Height / 2); // Center the text RectangleF textBounds = new RectangleF(0, 0, (float)size.Width, (float)size.Height * 2); // *2 or it gets cut off at high sizes XTextFormatter tf = new XTextFormatter(graphics); tf.Alignment = XParagraphAlignment.Center; tf.DrawString(str, font, textBrush, textBounds); } } } }
public void Draw(XGraphics graphics, RectangleF rect, MapOptions options, XPen pen) { if (graphics == null) throw new ArgumentNullException("graphics"); RectangleF bounds = TransformedBounds; //graphics.DrawRectangle( new XPen(XColors.Yellow, 1), bounds.X, bounds.Y, bounds.Width, bounds.Height ); if (bounds.IntersectsWith(rect)) { XGraphicsPath path = Path; using (RenderUtil.SaveState(graphics)) { XMatrix matrix = new XMatrix(); matrix.ScalePrepend(ScaleX, ScaleY); matrix.TranslatePrepend(-OriginX, -OriginY); graphics.MultiplyTransform(matrix, XMatrixOrder.Prepend); graphics.DrawPath(pen, path); } } }
public void ParseOptions(HttpRequest request, IDictionary<string, object> queryDefaults, ref MapOptions options, ref Stylesheet.Style style) { options = (MapOptions)GetIntOption("options", queryDefaults, (int)options); #if LEGACY_STYLES // Handle deprecated/legacy options bits for selecting style style = (options & MapOptions.StyleMaskDeprecated) == MapOptions.PrintStyleDeprecated ? Stylesheet.Style.Atlas : (options & MapOptions.StyleMaskDeprecated) == MapOptions.CandyStyleDeprecated ? Stylesheet.Style.Candy : Stylesheet.Style.Poster; #endif // LEGACY_STYLES if (HasOption("style", queryDefaults)) { string opt = GetStringOption("style", queryDefaults).ToLowerInvariant(); if (!s_nameToStyle.ContainsKey(opt)) throw new HttpError(400, "Bad Request", String.Format("Invalid style option: {0}", opt)); style = s_nameToStyle[opt]; } }
private const float WorldUwpMinScale = 96; // Above this: UWP shown above name #endregion Fields #region Constructors public Stylesheet(double scale, MapOptions options, Style style) { float onePixel = 1f / (float)scale; grayscale = false; lightBackground = false; subsectorGrid.visible = ((scale >= SubsectorsMinScale) && options.HasFlag(MapOptions.SubsectorGrid)); sectorGrid.visible = ((scale >= SectorGridMinScale) && options.HasFlag(MapOptions.SectorGrid)); parsecGrid.visible = (scale >= ParsecMinScale); showSomeSectorNames = ((scale >= SectorNameMinScale) && (scale <= SectorNameMaxScale) && ((options & MapOptions.SectorsMask) != 0)); showAllSectorNames = showSomeSectorNames && ((scale >= SectorNameAllSelectedScale) || options.HasFlag(MapOptions.SectorsAll)); subsectorNames.visible = ((scale >= SubsectorNameMinScale) && (scale <= SubsectorNameMaxScale) && ((options & MapOptions.SectorsMask) != 0)); worlds.visible = (scale >= WorldMinScale); pseudoRandomStars.visible = (PseudoRandomStarsMinScale <= scale) && (scale <= PseudoRandomStarsMaxScale); showRifts = (scale <= PseudoRandomStarsMaxScale || style == Style.Candy); t5AllegianceCodes = scale >= T5AllegianceCodeMinScale; float logscale = (float)Math.Log(scale, 2.0); riftOpacity = ScaleInterpolate(0f, 0.85f, scale, 1/4f, 4f); deepBackgroundOpacity = ScaleInterpolate(1f, 0f, scale, 1/8f, 2f); macroRoutes.visible = (scale >= MacroRouteMinScale) && (scale <= MacroRouteMaxScale); macroNames.visible = (scale >= MacroLabelMinScale) && (scale <= MacroLabelMaxScale); megaNames.visible = scale <= MegaLabelMaxScale && ((options & MapOptions.NamesMask) != 0); showMicroNames = ((scale >= MicroNameMinScale) && ((options & MapOptions.NamesMask) != 0)); capitals.visible = (scale >= MacroWorldsMinScale) && (scale <= MacroWorldsMaxScale); hexStyle = (((options & MapOptions.ForceHexes) == 0) && (scale < ParsecHexMinScale)) ? HexStyle.Square : HexStyle.Hex; microBorderStyle = hexStyle == HexStyle.Square ? MicroBorderStyle.Square : MicroBorderStyle.Hex; macroBorders.visible = (scale >= MacroBorderMinScale) && (scale < MicroBorderMinScale) && ((options & MapOptions.BordersMask) != 0); microBorders.visible = (scale >= MicroBorderMinScale) && ((options & MapOptions.BordersMask) != 0); fillMicroBorders = microBorders.visible && options.HasFlag(MapOptions.FilledBorders); microRoutes.visible = (scale >= RouteMinScale); worldDetails = !worlds.visible ? WorldDetails.None : (scale < WorldBasicMinScale) ? WorldDetails.Dotmap : (scale < WorldFullMinScale) ? WorldDetails.Atlas : WorldDetails.Poster; showWorldDetailColors = worldDetails == WorldDetails.Poster && options.HasFlag(MapOptions.WorldColors); lowerCaseAllegiance = (scale < WorldFullMinScale); worlds.textBackgroundStyle = TextBackgroundStyle.Rectangle; hexCoordinateStyle = HexCoordinateStyle.Sector; numberAllHexes = false; if (scale < WorldFullMinScale) { // Atlas-style const float x = 0.225f; const float y = 0.125f; BaseTopPosition.X = -x; BaseTopPosition.Y = -y; BaseBottomPosition.X = -x; BaseBottomPosition.Y = y; GasGiantPosition.X = x; GasGiantPosition.Y = -y; AllegiancePosition.X = x; AllegiancePosition.Y = y; BaseMiddlePosition.X = options.HasFlag(MapOptions.ForceHexes) ? -0.35f : -0.2f; BaseMiddlePosition.Y = 0; StarportPosition.X = 0.0f; StarportPosition.Y = -0.24f; worlds.position.X = 0.0f; worlds.position.Y = 0.4f; } else { // Poster-style const float x = 0.25f; const float y = 0.18f; BaseTopPosition.X = -x; BaseTopPosition.Y = -y; BaseBottomPosition.X = -x; BaseBottomPosition.Y = y; GasGiantPosition.X = x; GasGiantPosition.Y = -y; AllegiancePosition.X = x; AllegiancePosition.Y = y; BaseMiddlePosition.X = -0.35f; BaseMiddlePosition.Y = 0f; StarportPosition.X = 0f; StarportPosition.Y = -0.225f; worlds.position.X = 0.0f; worlds.position.Y = 0.37f; // Don't hide hex bottom, leave room for UWP } if (scale >= WorldUwpMinScale) { worldDetails |= WorldDetails.Uwp; BaseBottomPosition.Y = 0.1f; BaseMiddlePosition.Y = (BaseBottomPosition.Y + BaseTopPosition.Y) / 2; AllegiancePosition.Y = 0.1f; } if (worlds.visible) { float fontScale = (scale <= 96f || style == Style.Candy) ? 1f : 96f / Math.Min((float)scale, 192f); worlds.fontInfo = new FontInfo(DEFAULT_FONT, scale < WorldFullMinScale ? 0.2f : 0.15f * fontScale, XFontStyle.Bold); wingdingFont = new FontInfo("Wingdings", scale < WorldFullMinScale ? 0.2f : 0.175f * fontScale); glyphFont = new FontInfo(DEFAULT_FONT, scale < WorldFullMinScale ? 0.175f : 0.15f * fontScale, XFontStyle.Bold); hexNumber.fontInfo = new FontInfo(DEFAULT_FONT, 0.1f * fontScale); worlds.smallFontInfo = new FontInfo(DEFAULT_FONT, scale < WorldFullMinScale ? 0.2f : 0.1f * fontScale, XFontStyle.Regular); worlds.largeFontInfo = worlds.fontInfo; starportFont = (scale < WorldFullMinScale) ? worlds.smallFontInfo : worlds.fontInfo; } sectorName.fontInfo = new FontInfo(DEFAULT_FONT, 5.5f); subsectorNames.fontInfo = new FontInfo(DEFAULT_FONT, 1.5f); microBorders.fontInfo = new FontInfo(DEFAULT_FONT, (scale == MicroNameMinScale) ? 0.6f : 0.25f, XFontStyle.Bold); microBorders.smallFontInfo = new FontInfo(DEFAULT_FONT, 0.15f, XFontStyle.Bold); microBorders.largeFontInfo = new FontInfo(DEFAULT_FONT, 0.75f, XFontStyle.Bold); macroNames.fontInfo = new FontInfo(DEFAULT_FONT, 8f / 1.4f, XFontStyle.Bold); macroNames.smallFontInfo = new FontInfo(DEFAULT_FONT, 5f / 1.4f, XFontStyle.Regular); macroNames.mediumFontInfo = new FontInfo(DEFAULT_FONT, 6.5f / 1.4f, XFontStyle.Italic); float megaNameScaleFactor = 1.0f * onePixel; megaNames.fontInfo = new FontInfo(DEFAULT_FONT, 24f * megaNameScaleFactor, XFontStyle.Bold); megaNames.mediumFontInfo = new FontInfo(DEFAULT_FONT, 22f * megaNameScaleFactor, XFontStyle.Regular); megaNames.smallFontInfo = new FontInfo(DEFAULT_FONT, 20f * megaNameScaleFactor, XFontStyle.Italic); capitals.fillColor = Color.Wheat; capitals.textColor = Color.Red; blueZone.pen.color = Color.Blue; amberZone.pen.color = Color.Gold; redZone.pen.color = Color.Red; macroBorders.pen.color = Color.Red; macroRoutes.pen.color = Color.White; microBorders.pen.color = Color.Gray; Color gridColor = Color.FromArgb(ScaleInterpolate(0, 255, scale, SectorGridMinScale, SectorGridFullScale), Color.Gray); microRoutes.pen.color = Color.Gray; Color foregroundColor = Color.White; backgroundColor = Color.Black; Color lightColor = Color.LightGray; Color darkColor = Color.DarkGray; Color dimColor = Color.DimGray; Color highlightColor = Color.Red; microBorders.textColor = Color.Gold; worldWater.fillColor = Color.DeepSkyBlue; worldNoWater.fillColor = Color.White; worldNoWater.pen.color = Color.Empty; parsecGrid.pen = new PenInfo(gridColor, onePixel); subsectorGrid.pen = new PenInfo(gridColor, onePixel * 2); sectorGrid.pen = new PenInfo(gridColor, (subsectorGrid.visible ? 4 : 2) * onePixel); worldWater.pen = new PenInfo(Color.Empty, Math.Max(0.01f, onePixel)); microBorders.textStyle.Rotation = 0; microBorders.textStyle.Translation = new PointF(0, 0); microBorders.textStyle.Scale = new SizeF(1.0f, 1.0f); microBorders.textStyle.Uppercase = false; sectorName.textStyle.Rotation = -50; // degrees sectorName.textStyle.Translation = new PointF(0, 0); sectorName.textStyle.Scale = new SizeF(0.75f, 1.0f); sectorName.textStyle.Uppercase = false; sectorName.textStyle.Wrap = true; subsectorNames.textStyle = sectorName.textStyle; worlds.textStyle.Rotation = 0; worlds.textStyle.Scale = new SizeF(1.0f, 1.0f); worlds.textStyle.Translation = worlds.position; worlds.textStyle.Uppercase = false; useBackgroundImage = false; useGalaxyImage = deepBackgroundOpacity > 0.0f; useWorldImages = false; // Cap pen widths when zooming in float penScale = (scale <= 64) ? 1f : (64f / (float)scale); float borderPenWidth = (scale < MicroBorderMinScale) ? 1 : // When rendering vector borders (scale < ParsecMinScale) ? 1 : // When not rendering "hexes" 0.16f * penScale; // ... but cut in half by clipping float routePenWidth = scale <= 16 ? 0.2f : 0.08f * penScale; microBorders.pen.width = borderPenWidth; macroBorders.pen.width = borderPenWidth; microRoutes.pen.width = routePenWidth; amberZone.pen.width = redZone.pen.width = blueZone.pen.width = 0.05f * penScale; macroRoutes.pen.width = borderPenWidth; macroRoutes.pen.DashStyle = XDashStyle.Dash; switch (style) { case Style.Poster: { // This is the default - no changes break; } case Style.Atlas: { grayscale = true; lightBackground = true; capitals.fillColor = Color.DarkGray; capitals.textColor = Color.Black; amberZone.pen.color = Color.LightGray; blueZone.pen.color = Color.Gray; // TODO: make dashed redZone.pen.color = Color.Black; macroBorders.pen.color = Color.Black; macroRoutes.pen.color = Color.Gray; microBorders.pen.color = Color.Black; microRoutes.pen.color = Color.Gray; foregroundColor = Color.Black; backgroundColor = Color.White; lightColor = Color.DarkGray; darkColor = Color.DarkGray; dimColor = Color.LightGray; highlightColor = Color.Gray; microBorders.textColor = Color.Gray; worldWater.fillColor = Color.Black; worldNoWater.fillColor = Color.Empty; worldNoWater.fillColor = Color.White; worldNoWater.pen = new PenInfo(Color.Black, onePixel); riftOpacity = Math.Min(riftOpacity, 0.70f); showWorldDetailColors = false; break; } case Style.FASA: { useGalaxyImage = false; deepBackgroundOpacity = 0f; riftOpacity = 0; Color inkColor = Color.FromArgb(0x5C, 0x40, 0x33); foregroundColor = inkColor; backgroundColor = Color.White; grayscale = true; // TODO: Tweak to be "monochrome" lightBackground = true; capitals.fillColor = inkColor; capitals.textColor = inkColor; amberZone.pen.color = inkColor; amberZone.pen.width = onePixel * 2; blueZone.pen.color = inkColor; // TODO: make dashed redZone.pen.color = Color.Empty; redZone.fillColor = Color.FromArgb(0x80, inkColor); macroBorders.pen.color = inkColor; macroRoutes.pen.color = inkColor; microBorders.pen.color = inkColor; microBorders.pen.width = onePixel * 2; microBorders.fontInfo.size *= 0.6f; microBorders.fontInfo.style = XFontStyle.Regular; microRoutes.pen.color = inkColor; lightColor = Color.FromArgb(0x80, inkColor); darkColor = inkColor; dimColor = inkColor; highlightColor = inkColor; microBorders.textColor = inkColor; hexStyle = HexStyle.Hex; microBorderStyle = MicroBorderStyle.Curve; parsecGrid.pen.color = lightColor; sectorGrid.pen.color = lightColor; subsectorGrid.pen.color = lightColor; worldWater.fillColor = inkColor; worldNoWater.fillColor = inkColor; worldWater.pen.color = Color.Empty; worldNoWater.pen.color = Color.Empty; showWorldDetailColors = false; worldDetails = worldDetails & ~WorldDetails.Starport; worldDetails = worldDetails & ~WorldDetails.Allegiance; worldDetails = worldDetails & ~WorldDetails.Bases; worldDetails = worldDetails & ~WorldDetails.GasGiant; worldDetails = worldDetails & ~WorldDetails.Highlight; worlds.fontInfo.size *= 0.85f; worlds.textStyle.Translation = new PointF(0, 0.25f); numberAllHexes = true; hexCoordinateStyle = HexCoordinateStyle.Subsector; overrideLineStyle = LineStyle.Solid; break; } case Style.Print: { lightBackground = true; foregroundColor = Color.Black; backgroundColor = Color.White; lightColor = Color.DarkGray; darkColor = Color.DarkGray; dimColor = Color.LightGray; microRoutes.pen.color = Color.Gray; microBorders.textColor = Color.Brown; amberZone.pen.color = Color.Gold; worldNoWater.fillColor = Color.White; worldNoWater.pen = new PenInfo(Color.Black, onePixel); riftOpacity = Math.Min(riftOpacity, 0.70f); break; } case Style.Draft: { int inkOpacity = 0xB0; useGalaxyImage = false; lightBackground = true; deepBackgroundOpacity = 0f; backgroundColor = Color.AntiqueWhite; foregroundColor = Color.FromArgb(inkOpacity, Color.Black); highlightColor = Color.FromArgb(inkOpacity, Color.Red); lightColor = Color.FromArgb(inkOpacity, Color.DarkCyan); darkColor = Color.FromArgb(inkOpacity, Color.Black); dimColor = Color.FromArgb(inkOpacity / 2, Color.Black); subsectorGrid.pen.color = Color.FromArgb(inkOpacity, Color.Firebrick); const string FONT_NAME = "Comic Sans MS"; worlds.fontInfo.name = FONT_NAME; worlds.smallFontInfo.name = FONT_NAME; starportFont.name = FONT_NAME; worlds.largeFontInfo.name = FONT_NAME; worlds.largeFontInfo.size = worlds.fontInfo.size * 1.25f; worlds.fontInfo.size *= 0.8f; macroNames.fontInfo.name = FONT_NAME; macroNames.mediumFontInfo.name = FONT_NAME; macroNames.smallFontInfo.name = FONT_NAME; megaNames.fontInfo.name = FONT_NAME; megaNames.mediumFontInfo.name = FONT_NAME; megaNames.smallFontInfo.name = FONT_NAME; microBorders.smallFontInfo.name = FONT_NAME; microBorders.largeFontInfo.name = FONT_NAME; microBorders.fontInfo.name = FONT_NAME; macroBorders.fontInfo.name = FONT_NAME; macroRoutes.fontInfo.name = FONT_NAME; capitals.fontInfo.name = FONT_NAME; macroBorders.smallFontInfo.name = FONT_NAME; microBorders.textStyle.Uppercase = true; sectorName.textStyle.Uppercase = true; subsectorNames.textStyle.Uppercase = true; // TODO: Render small, around edges subsectorNames.visible = false; worlds.textStyle.Uppercase = true; // TODO: Decide on this. It's nice to not overwrite the parsec grid, but // it looks very cluttered, especially amber/red zones. worlds.textBackgroundStyle = TextBackgroundStyle.None; worldDetails = worldDetails & ~WorldDetails.Allegiance; subsectorNames.fontInfo.name = FONT_NAME; sectorName.fontInfo.name = FONT_NAME; worlds.largeFontInfo.style |= XFontStyle.Underline; microBorders.pen.width = onePixel * 4; microBorders.pen.dashStyle = XDashStyle.Dot; worldNoWater.fillColor = foregroundColor; worldWater.fillColor = Color.Empty; worldWater.pen = new PenInfo(foregroundColor, onePixel * 2); amberZone.pen.color = foregroundColor; amberZone.pen.width = onePixel; redZone.pen.width = onePixel * 2; microRoutes.pen.color = Color.Gray; parsecGrid.pen.color = lightColor; microBorders.textColor = Color.FromArgb(inkOpacity, Color.Brown); riftOpacity = Math.Min(riftOpacity, 0.30f); numberAllHexes = true; break; } case Style.Candy: { useWorldImages = true; pseudoRandomStars.visible = false; useBackgroundImage = deepBackgroundOpacity < 0.5f; hexStyle = HexStyle.None; microBorderStyle = MicroBorderStyle.Curve; sectorGrid.visible = sectorGrid.visible && (scale >= 4); subsectorGrid.visible = subsectorGrid.visible && (scale >= 32); parsecGrid.visible = false; subsectorGrid.pen.width = 0.03f * (64.0f / (float)scale); subsectorGrid.pen.DashPattern = new double[] { 10.0, 8.0 }; sectorGrid.pen.width = 0.03f * (64.0f / (float)scale); sectorGrid.pen.DashPattern = new double[] { 10.0, 8.0 }; worlds.textBackgroundStyle = TextBackgroundStyle.Shadow; worldDetails = worldDetails & ~WorldDetails.Starport & ~WorldDetails.Allegiance & ~WorldDetails.Bases & ~WorldDetails.Hex; if (scale < CandyMinWorldNameScale) worldDetails = worldDetails & ~WorldDetails.KeyNames & ~WorldDetails.AllNames; if (scale < CandyMinUwpScale) worldDetails = worldDetails & ~WorldDetails.Uwp; amberZone.pen.color = Color.Goldenrod; sectorName.textStyle.Rotation = 0; sectorName.textStyle.Translation = new PointF(0, -0.25f); sectorName.textStyle.Scale = new SizeF(0.5f, 0.25f); sectorName.textStyle.Uppercase = true; subsectorNames.textStyle.Rotation = 0; subsectorNames.textStyle.Translation = new PointF(0, -0.25f); subsectorNames.textStyle.Scale = new SizeF(0.3f, 0.15f); // Expand subsectorNames.textStyle.Uppercase = true; microBorders.textStyle.Rotation = 0; microBorders.textStyle.Translation = new PointF(0, 0.25f); microBorders.textStyle.Scale = new SizeF(1.0f, 0.5f); // Expand microBorders.textStyle.Uppercase = true; microBorders.pen.color = Color.FromArgb(128, Color.Red); worlds.textStyle.Rotation = 0; worlds.textStyle.Scale = new SizeF(1f, 0.5f); // Expand worlds.textStyle.Translation = new PointF(0, 0); worlds.textStyle.Uppercase = true; if (scale > CandyMaxWorldRelativeScale) hexContentScale = CandyMaxWorldRelativeScale / (float)scale; break; } } sectorName.textColor = scale < 16 ? foregroundColor : scale < 48 ? darkColor : dimColor; subsectorNames.textColor = scale < 16 ? foregroundColor : scale < 48 ? darkColor : dimColor; if (style == Style.Candy) { subsectorNames.textColor = sectorName.textColor = Color.FromArgb(128, Color.Goldenrod); amberZone.pen.width = redZone.pen.width = blueZone.pen.width = 0.035f; microRoutes.pen.width = scale < CandyMaxRouteRelativeScale ? routePenWidth : routePenWidth / 2; macroBorders.pen.width = scale < CandyMaxBorderRelativeScale ? borderPenWidth : borderPenWidth / 4; microBorders.pen.width = scale < CandyMaxBorderRelativeScale ? borderPenWidth : borderPenWidth / 4; } preferredMimeType = (style == Style.Candy) ? System.Net.Mime.MediaTypeNames.Image.Jpeg : Util.MediaTypeName_Image_Png; pseudoRandomStars.fillColor = foregroundColor; megaNames.textColor = foregroundColor; megaNames.textHighlightColor = highlightColor; macroNames.textColor = foregroundColor; macroNames.textHighlightColor = highlightColor; macroRoutes.textColor = foregroundColor; macroRoutes.textHighlightColor = highlightColor; worlds.textColor = foregroundColor; worlds.textHighlightColor = highlightColor; hexNumber.textColor = lightColor; imageBorderColor = lightColor; placeholder.content = "*"; placeholder.fontInfo = new FontInfo("Georgia", 0.6f); placeholder.textColor = foregroundColor; placeholder.position = new PointF(0, 0.17f); }