Ejemplo n.º 1
0
 public TreeItemType Create()
 {
     return(TreeEditor.AddNewItem(Context.CurrentTree,
                                  Context.CreateProject,
                                  Context.CreateDiagram,
                                  Context.CurrentCanvas.GetCounter()));
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public void Clear(ITree tree, ICanvas canvas, IdCounter counter)
 {
     TreeEditor.Clear(tree);
     counter.Reset();
     TagsReset();
     SelectedListReset();
     canvas.SetTags(null);
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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);
        }