public void CreateNewFile(string filename) { Source src = new Source(filename); project.AddSource(src); CodeBoxViewModel workspace = new CodeBoxViewModel(src); this.Workspaces.Add(workspace); this.SetActiveWorkspace(workspace); }
public void AddSource(Source src) { if (projectSources.Contains(src)) return; projectSources.Add(src); }
public void OpenProject(string openedProjectName, string openedProjectPath) { this.CleanProject(); string[] split = openedProjectName.Split(new Char[] { '\\', '\t', '\n' }); string pro = split.Last<string>(); if (!pro.EndsWith(PROJECT_FORMAT)) { return; } string[] namesplit = pro.Split(new Char[] { '.' }); this.ProjectName = namesplit.First<string>(); this.ProjectFolder = openedProjectPath; string manifestPath = Path.Combine(openedProjectPath, MANIFEST_FILENAME); try { if (!File.Exists(manifestPath)) { return; } using (FileStream fs = File.Open(manifestPath, FileMode.Open)) { using (StreamReader sr = new StreamReader(fs)) { //Author string line = sr.ReadLine(); string[] linesplit = line.Split(new Char[] { ' ', ':', '\t', '\n' }); this.Author = linesplit.Last<string>().Trim(); //Version line = sr.ReadLine(); linesplit = line.Split(new Char[] { ' ', ':', '\t', '\n' }); this.Version = Convert.ToInt32(linesplit.Last<string>().Trim()); //Main-Class line = sr.ReadLine(); linesplit = line.Split(new Char[] { ' ', ':', '\t', '\n' }); string mainClassFileName = linesplit.Last<string>().Trim(); Source mainClassSource = new Source(mainClassFileName); string mainClassFilePath = Path.Combine(this.ProjectFolder, mainClassFileName); if (!mainClassFilePath.EndsWith(SOURCE_FORMAT)) mainClassFilePath += SOURCE_FORMAT; /* if (File.Exists(mainClassFilePath)) { File.Delete(mainClassFilePath); } */ using (FileStream fstream = File.Open(mainClassFilePath, FileMode.Open)) { using (StreamReader sreader = new StreamReader(fstream)) { mainClassSource.Content = sreader.ReadToEnd().Trim(); } } this.AddSource(mainClassSource); //Sources sr.ReadLine(); while ((line = sr.ReadLine()) != null) { //Debug.WriteLine(line); } } } this.CanRun = true; this.CanSave = true; this.ProcessWriteLineEvent(this, this.ProjectName + ": loaded"); } catch (Exception Ex) { Debug.WriteLine(Ex.ToString()); } }
public CodeBoxViewModel(Source source) { src = source; this.CodeboxText = src.Content; base.DisplayName = src.FileName; }