//https://web.archive.org/web/20130921190426/http://tech.pro/tutorial/798/csharp-tutorial-xml-serialization public static string SaveProject(Project project) { string status = project.Name + " Saved!"; if (!Directory.Exists("Projects")) { Directory.CreateDirectory("Projects"); } if (!File.Exists(project.Name)) { File.Delete(project.Name); } try { //XmlSerializer serializer = new XmlSerializer(typeof(Project)); //TextWriter textWriter = new StreamWriter(@"Projects\" + project.Name + ".xml"); //serializer.Serialize(textWriter, project); //textWriter.Close(); XMLGenerator xml = new XMLGenerator(project); CreateDocument("Projects", xml.DocumentName, "xml", xml.GenerateDoc(), true); } catch (Exception ex) { status = ex.ToString(); } return status; }
public NewProjectDialog(Project p) { InitializeComponent(); this.DataContext = new vmNewProjectDialog(p); //project = p; //txt_name.Text = p.Name; txt_name.Focus(); }
private void LoadProjects() { Project js = new Project(); js.Tools.Add(new JavascriptTool()); Projects.Add(js); CurrentProject = Projects.ElementAt(0); }
//================================================================================================================================================ // Delegate Command Methods //================================================================================================================================================ #region OnAddProject(object parameter) protected void OnAddProject(object parameter) { Project p = new Project(); Projects.Add(p); //Items.Add(p); NewProjectDialog npd = new NewProjectDialog(p); npd.ShowDialog(); TreeViewItem tvi = new TreeViewItem(); tvi.Header = p.Name; tvi.DataContext = p; TreeViewItems.Add(tvi); CurrentItem = tvi; }
public vmNewProjectDialog(Project p) { CurrentProject = p; }
//================================================================================================================================================ // Constructors //================================================================================================================================================ #region XMLGenerator public XMLGenerator(Project projRef) { ProjectRef = projRef; DocumentName = ProjectRef.Name; }