/** Opens the save dialogue and takes in a list of type PointD and saves * the list of points to the specified XML file. * * Points: List of user-drawn points on the drawing area * * Note: The file paths have only been tested on Windows */ public static void openSaveDialogue(List <PointD> points) { //Initial setup of the save dialog FileChooserDialog fileChooser = new FileChooserDialog("Save", null, FileChooserAction.Save); fileChooser.AddButton(Stock.Cancel, ResponseType.Cancel); fileChooser.AddButton(Stock.Ok, ResponseType.Ok); string tmp = System.IO.Directory.GetCurrentDirectory(); string newTmp = tmp + "/../../Gestures/"; fileChooser.SetCurrentFolder(newTmp); fileChooser.SelectMultiple = false; ResponseType retVal = (ResponseType)fileChooser.Run(); //String manipluation to get the correct file name being saved if (retVal == ResponseType.Ok) { string saveFileName = ""; string[] strippedFileName = { "", "" }; string newFile = fileChooser.Filename.Trim(); if (!newFile.EndsWith(".xml", true, null)) { int nameLength = newFile.Length - newFile.LastIndexOf("\\"); saveFileName = newFile.Substring(newFile.LastIndexOf("\\"), nameLength); strippedFileName = saveFileName.Split('\\'); Console.WriteLine(strippedFileName[1]); newFile += ".xml"; } if (File.Exists(newFile)) { File.Delete(newFile); } FileStream fs = File.Create(newFile); fs.Close(); XMLParser.WriteGesture(points, strippedFileName[1], newFile); GestureTemplate.template newTemplate = new GestureTemplate.template(strippedFileName[1], points); Recognizer.templateList.Add(newTemplate); } fileChooser.Destroy(); }
/** Opens the save dialogue and takes in a list of type PointD and saves * the list of points to the specified XML file. * * Points: List of user-drawn points on the drawing area * * Note: The file paths have only been tested on Windows */ public static void openSaveDialogue(List<PointD> points) { //Initial setup of the save dialog FileChooserDialog fileChooser = new FileChooserDialog ("Save", null, FileChooserAction.Save); fileChooser.AddButton (Stock.Cancel, ResponseType.Cancel); fileChooser.AddButton (Stock.Ok, ResponseType.Ok); string tmp = System.IO.Directory.GetCurrentDirectory(); string newTmp = tmp + "/../../Gestures/"; fileChooser.SetCurrentFolder (newTmp); fileChooser.SelectMultiple = false; ResponseType retVal = (ResponseType)fileChooser.Run (); //String manipluation to get the correct file name being saved if (retVal == ResponseType.Ok) { string saveFileName = ""; string[] strippedFileName = { "", "" }; string newFile = fileChooser.Filename.Trim (); if (!newFile.EndsWith(".xml", true, null)) { int nameLength = newFile.Length - newFile.LastIndexOf ("\\"); saveFileName = newFile.Substring(newFile.LastIndexOf("\\"), nameLength); strippedFileName = saveFileName.Split('\\'); Console.WriteLine (strippedFileName[1]); newFile += ".xml"; } if (File.Exists (newFile)) { File.Delete (newFile); } FileStream fs = File.Create (newFile); fs.Close (); XMLParser.WriteGesture (points, strippedFileName[1], newFile); GestureTemplate.template newTemplate = new GestureTemplate.template (strippedFileName[1], points); Recognizer.templateList.Add (newTemplate); } fileChooser.Destroy (); }