/// <summary> /// /// </summary> /// <param name="pathToSvg"></param> /// <param name="svgConfig"></param> public List <SvgElement> readScheme(string pathToSvg, SvgConfig svgConfig) { List <SvgElement> elements = new List <SvgElement>(); SvgDocument svg = SvgDocument.Open(pathToSvg); foreach (SchemeValue schemeVal in svgConfig.BindingTags) { SvgElement element = readSchemeTag(svg, schemeVal.id); elements.Add(element); } return(elements); }
public static void writeToXML(string pathSvgCfg, SchemeEditor editor) { SvgConfig schemeEditorXML = new SvgConfig(); schemeEditorXML.SchemeAgeBars = editor.SchemeAgeBars; schemeEditorXML.SchemeGraphicsList = editor.SchemeGraphicsList; schemeEditorXML.SchemeTags = editor.SchemeTags; schemeEditorXML.SchemeTextlist = editor.SchemeTextlist; schemeEditorXML.BindingTags = editor.BindingTags; XmlSerializer serializer = new XmlSerializer(typeof(SvgConfig)); using (StreamWriter writer = new StreamWriter(pathSvgCfg)) { serializer.Serialize(writer, schemeEditorXML); } }
/// <summary> /// /// </summary> /// <returns></returns> public SvgConfig readSchemeConfig(string path) { if (!path.Contains(PathDef.PhysicalPath)) { path = PathDef.PhysicalPath + path; } string xmlConfig = System.IO.File.ReadAllText(path); SvgConfig svgConfig = new SvgConfig(); var serializer = new XmlSerializer(typeof(SvgConfig)); //object result; //StringReader stringReader = new StringReader(xmlConfig); StreamReader reader = new StreamReader(path); svgConfig = (SvgConfig)serializer.Deserialize(reader); //svgConfig = (SvgConfig)result; return(svgConfig); }
// GET: SvgScheme /// <summary> /// Action to view new schemes /// </summary> /// <returns>View with path to svg in </returns> public ActionResult Index() { string pathToSvg = null, pathToCfg = null; List <SvgElement> elements = new List <SvgElement>(); NewSchemesHandler schemesHandler = new NewSchemesHandler(); //first get all needed session data getConfigPath(ref pathToSvg, ref pathToCfg); //read xml config SvgConfig svgConfig = schemesHandler.readSchemeConfig(pathToCfg); //get all values for svg scheme List <ResponseValue> responses = schemesHandler.readData(svgConfig, svgConfig.BindingTags, (int)Session["id"]); //set values from responses SvgDocument svg = schemesHandler.setValue(responses, svgConfig, pathToSvg); /* * if (svgConfig != null) * //read all dynamic members * elements = schemesHandler.readScheme(pathToSvg, svgConfig); */ if (!pathToSvg.Contains(PathDef.PhysicalPath)) { pathToSvg = PathDef.PhysicalPath + pathToSvg; } string pathToNewSvg = pathToSvg + "_scheme_" + DateTime.Now.Ticks + ".png"; //System.IO.File.Create(pathToNewSvg); /*svg.Write(pathToNewSvg); * * SvgDocument newSvg = SvgDocument.Open(pathToNewSvg); */ //var bitmap = svg.Draw(); //bitmap.Save(pathToNewSvg, ImageFormat.Png); ViewBag.SvgXml = svg.GetXML(); return(View()); }