public void Convert(IMapGraphic mapGraphic, string outputFilename) { var xmlDocument = mapGraphic.GetSvgXmlDocument(); var svgDocument = SvgDocument.Open(xmlDocument); var image = new System.Drawing.Bitmap((int)(svgDocument.Width.Value * Scale), (int)(svgDocument.Height.Value * Scale)); svgDocument.Draw(image); image.Save(outputFilename); }
public IList <string> FullProcess(ISpreadsheet spreadsheet, IMapGraphic mapGraphic, IEnumerable <IMapGraphicConverter> converters, string outputFolderPath, RenderPreferences preferences, Products products) { var countyIds = spreadsheet .Where(x => x.HasTruthyValue(products)) .Select(x => x[ID_COLUMN]); try { mapGraphic.FillReferenceBoxes(preferences.DefaultColor); mapGraphic.FillCounties(preferences.DefaultColor); mapGraphic.StrokeReferenceBoxes(preferences.LineColor); mapGraphic.StrokeOuterBorder(preferences.LineColor); mapGraphic.Fill(preferences.PresenceColor, countyIds); mapGraphic.Fill(preferences.PresenceColor, ELEMENTID_REF_PRESENCE_BOX); if (!preferences.ShowCountyNames) { mapGraphic.HideCountyNames(); } if (preferences.ShowCountyLines) { mapGraphic.StrokeCounties(preferences.LineColor); } else { mapGraphic.ReduceStrokeCounties(); mapGraphic.StrokeCounties(preferences.DefaultColor); mapGraphic.Stroke(preferences.PresenceColor, countyIds); } mapGraphic.SetText(ELEMENTID_REF_PRESENCE_TEXT, products.GetWithPresenceText()); mapGraphic.SetText(ELEMENTID_REF_NO_PRESENCE_TEXT, products.GetWithoutPresenceText()); } catch { throw new ApplicationException("Error applying color to elements, verify elementIds and SVG file."); } var resultFileNames = new List <string>(); var baseFilename = Path.Combine(outputFolderPath, string.Format("COPsync-presence-map-{0:yyyyMMddHHmmss}", DateTime.Now)); foreach (var converter in converters) { try { var convertedFilename = Path.ChangeExtension(baseFilename, converter.DefaultExtension); converter.Convert(mapGraphic, convertedFilename); resultFileNames.Add(convertedFilename); } catch (Exception e) { throw new ApplicationException(string.Format("Error converting the file using {0}:\n{1}", converter.GetType(), e.Message)); } } return(resultFileNames); }
public void Convert(IMapGraphic mapGraphic, string outputFilename) { var inkscapeExe = GetInkscapePath(); if (inkscapeExe == null) { throw new ApplicationException("Inkscape is required to convert."); } using (var tfh = new TemporalFileHelper()) { var xmlDocument = mapGraphic.GetSvgXmlDocument(); xmlDocument.Save(tfh.TemporalFileName); var arguments = string.Format("--file {0} {1} {2}", tfh.TemporalFileName, ConvertOption, outputFilename); Process p = Process.Start(inkscapeExe, arguments); p.WaitForExit(); } }
public void Convert(IMapGraphic mapGraphic, string outputFilename) { using (var tfh = new TemporalFileHelper()) { var xmlDocument = mapGraphic.GetSvgXmlDocument(); xmlDocument.Save(tfh.TemporalFileName); using (WebClient client = new WebClient()) { client.Headers["Content-Type"] = "binary/octet-stream"; StringBuilder sb = new StringBuilder(); var result = client.UploadFile( "https://api.cloudconvert.com/convert?" + "apikey=" + _apikey + "&input=upload" + "&inputformat=svg" + "&outputformat=" + OutputFormat, tfh.TemporalFileName); File.WriteAllBytes(outputFilename, result); } } }
public void Convert(IMapGraphic mapGraphic, string outputFilename) { var xmlDocument = mapGraphic.GetSvgXmlDocument(); xmlDocument.Save(outputFilename); }
public void LoadMap(Map map) { mapGraphic = mapLoader.LoadMap(map); Invalidate(); mapChanged = true; }
private static FieldMapController CreateMapController(IMapGraphic mapGraphic, ScreenConstants screenConstants = null) { if(screenConstants == null) screenConstants = DefaultScreenConstant; var mapLoaderFake = new Mock<IMapLoader>(); mapLoaderFake.Setup(l => l.LoadMap(It.IsAny<Map>())).Returns(mapGraphic); var mapController = new FieldMapController(mapLoaderFake.Object, screenConstants); mapController.Setup(); mapController.LoadMap(null); return mapController; }