public TreeItemType Create() { return(TreeEditor.AddNewItem(Context.CurrentTree, Context.CreateProject, Context.CreateDiagram, Context.CurrentCanvas.GetCounter())); }
private void Parse(IdCounter counter, TreeDiagram diagram, ITreeItem project, List <ITreeItem> diagrams) { var lines = diagram.Reverse(); var first = lines.First().Split(new char[] { Constants.ArgumentSeparator, '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries); string name = first.Length >= 1 ? first[1] : null; var sb = new StringBuilder(); foreach (var line in lines) { sb.AppendLine(line); } var item = TreeEditor.CreateDiagramItem(name, Context.CreateDiagram, counter); item.SetTag(new Diagram(sb.ToString(), null)); project.Add(item); diagrams.Add(item); int id = int.Parse(name.Split(Constants.TagNameSeparator)[1]); counter.Set(Math.Max(counter.Count, id + 1)); }
private IEnumerable <ITreeItem> Parse(IEnumerable <TreeProject> projects, IdCounter counter, ITreeItem solution) { var items = new List <ITreeItem>(); foreach (var project in projects) { string name = project.Name; var diagrams = project.Diagrams.Reverse(); var item = TreeEditor.CreateProjectItem(name, Context.CreateProject, counter); solution.Add(item); int id = int.Parse(name.Split(Constants.TagNameSeparator)[1]); counter.Set(Math.Max(counter.Count, id + 1)); Parse(counter, diagrams, item, items); } var first = items.FirstOrDefault(); if (first != null) { first.SetSelected(true); } return(items); }
public void Clear(ITree tree, ICanvas canvas, IdCounter counter) { TreeEditor.Clear(tree); counter.Reset(); TagsReset(); SelectedListReset(); canvas.SetTags(null); }
public static IEnumerable <string> GetCurrentProjectDiagrams(ITree tree) { var selected = tree.GetSelectedItem() as ITreeItem; if (selected == null) { return(null); } switch (TreeEditor.GetTreeItemType(selected.GetUid())) { case TreeItemType.Diagram: { var models = new List <string>(); ModelEditor.GenerateProject(selected.GetParent() as ITreeItem, models, false); return(models); } case TreeItemType.Project: { var models = new List <string>(); ModelEditor.GenerateProject(selected, models, false); return(models); } case TreeItemType.Solution: { var solution = tree.GetItems().FirstOrDefault(); if (solution == null) { return(null); } var project = solution.GetItems().FirstOrDefault(); if (project != null) { return(null); } var models = new List <string>(); ModelEditor.GenerateProject(project, models, false); return(models); } default: return(null); } }
public void Parse(ITree tree, TreeSolution solution, IdCounter counter, Func <ITreeItem> CreateTreeSolutionItem) { string tagFileName = solution.TagFileName; string solutionName = solution.Name; var projects = solution.Projects.Reverse(); TagsLoad(tagFileName); var item = TreeEditor.CreateSolutionItem(solutionName, CreateTreeSolutionItem, counter); tree.Add(item); Parse(projects, counter, item); }