Пример #1
0
        public ProjectItemViewModel GetSelectedBlueprint()
        {
            ProjectItemViewModel selected = SelectedItem;

            if (selected == null)
            {
                return(null);
            }
            if (selected.Type == ProjectItemType.Root)
            {
                return(null);
            }
            if (selected.Type != ProjectItemType.Blueprints)
            {
                selected = GetParentBlueprint(selected);
            }
            if (selected == null)
            {
                return(null);
            }
            else
            {
                return(selected);
            }
        }
Пример #2
0
        public string ImportReferences(string code)
        {
            List <string> imports = new List <string>();

            List <string> lines = new List <string>(System.Text.RegularExpressions.Regex.Split(code, Environment.NewLine));

            foreach (string line in lines)
            {
                System.Text.RegularExpressions.Regex import = new System.Text.RegularExpressions.Regex(@"^#import\s[a-zA-Z0-9\-_()\[\]+~`'.!@#$%^&]+$");
                if (import.IsMatch(line))
                {
                    string name = line.Replace("#import ", String.Empty);
                    if (!imports.Contains(name))
                    {
                        imports.Add(name);
                    }
                }
            }

            foreach (string import in imports)
            {
                ProjectItemViewModel reference = GetReferences().FirstOrDefault(i => i.Name == import);
                if (reference != null)
                {
                    string content = File.Read(reference.Path);
                    code = code.Replace("#import " + import, String.Empty);

                    code += Environment.NewLine + Environment.NewLine + content;
                }
            }

            return(code);
        }
Пример #3
0
        public void PerformSearch()
        {
            if (_MatchingItemEnumerator == null || !_MatchingItemEnumerator.MoveNext())
            {
                VerifyMatchingItemEnumerator();
            }
            if (_MatchingItemEnumerator == null)
            {
                return;
            }

            var item = _MatchingItemEnumerator.Current;

            if (item == null)
            {
                return;
            }

            if (item.Parent != null)
            {
                ProjectItemViewModel parent = (ProjectItemViewModel)item.Parent;
                parent.IsExpanded = true;
            }

            // TODO switch search to filter (hide unmatched items), probably handled by the UI instead

            item.IsSelected = true;
        }
        public void VerifyFiles()
        {
            if (!IsVerifying)
            {
                BeginVerify();
                foreach (PageViewModel page in _Editor.Items)
                {
                    if (!page.IgnoreUpdates)
                    {
                        ProjectItemViewModel item = _Project.GetItemByPath(page.Filename);

                        if (File.LastWriteTime(page.Filename) > page.LastSaved)
                        {
                            string message = String.Format("{0} has been modified outside SE Workbench. Do you want to reload it?", page.ProjectItem.Name);

                            MessageBoxResult result = Services.MessageBox.ShowQuestion(message);
                            if (result == MessageBoxResult.Yes)
                            {
                                page.UpdateContent();
                            }
                            else
                            {
                                page.IgnoreUpdates = true;
                            }
                        }
                    }
                }
                EndVerify();
            }
            VerifyPaths();
        }
        private string BuildScript(string path)
        {
            string result = String.Empty;

            ProjectItemViewModel item = Project.GetItemByPath(path);

            if (item != null)
            {
                string code = File.Read(item.Path);

                List <string> scripts = Project.GetAssociatedScripts(path);
                if (scripts.Count < 1)
                {
                    result += code;
                }
                else
                {
                    result += String.Format("{0}{1}{1}", code, Environment.NewLine);
                    foreach (string script in scripts)
                    {
                        result += String.Format("{0}{1}{1}", script, Environment.NewLine);
                    }
                }

                result = Project.ImportReferences(result);
            }

            return(result);
        }
Пример #6
0
        public void PerformAddBlueprints()
        {
            ProjectItemViewModel rootitem = _RootItem;

            if (rootitem == null)
            {
                return;
            }

            string appdata    = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string blueprints = Path.Combine(appdata, "SpaceEngineers", "Blueprints");

            // TODO implement my own open file dialog to avoid API
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog()
            {
                DefaultExt       = ".sbc",
                Filter           = "Blueprints File (.sbc)|*.sbc",
                Multiselect      = false,
                InitialDirectory = blueprints,
            };

            Nullable <bool> result = dialog.ShowDialog();

            if (result != null && result.Value == true)
            {
                string fullpath = dialog.FileName;

                string       name;
                Interop.Grid grid;

                Interop.Blueprint.Import(fullpath, out name, out grid);
                if (grid != null)
                {
                    string safename = CreateSafeName(name);
                    string savepath = Path.Combine(Path.GetDirectoryName(rootitem.Path), safename);
                    try
                    {
                        Directory.CreateDirectory(savepath);
                        ProjectItem item = new ProjectItem()
                        {
                            Name      = name,
                            Path      = savepath,
                            Blueprint = fullpath,
                            Type      = ProjectItemType.Blueprints,
                            Project   = this,
                        };
                        rootitem.AddChild(item, grid);
                        rootitem.IsExpanded = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.ShowError("Unable to create add blueprint", ex);
                        return;
                    }
                    SaveProject();
                }
            }
        }
Пример #7
0
        public void PerformDelete()
        {
            ProjectItemViewModel selected = SelectedItem;

            if (selected == null)
            {
                return;
            }
            if (selected.Type == ProjectItemType.Reference)
            {
                PerformRemoveReference();
                return;
            }
            if (selected.Type != ProjectItemType.Blueprints && selected.Type != ProjectItemType.Folder && selected.Type != ProjectItemType.File)
            {
                return;
            }

            string message = String.Format("'{0}' will be deleted permanantly?", selected.Name);

            var result = MessageBox.ShowQuestion(message);

            if (result == System.Windows.MessageBoxResult.Yes)
            {
                bool success = false;
                try
                {
                    switch (selected.Type)
                    {
                    case ProjectItemType.Blueprints:
                    case ProjectItemType.Folder:
                        Directory.Delete(selected.Path, true);
                        break;

                    case ProjectItemType.File:
                        File.Delete(selected.Path);
                        break;
                    }
                    success = true;
                }
                catch (Exception ex)
                {
                    MessageBox.ShowError("Unable to delete the selected item", ex);
                }
                finally
                {
                    if (success)
                    {
                        selected.Remove();
                        SaveProject();

                        RaiseFileDeleted(selected);
                    }
                }
            }
        }
Пример #8
0
 public PageViewModel(BaseViewModel parent, string name, string path)
     : base(parent)
 {
     ProjectItemViewModel vm = new ProjectItemViewModel(new Models.ProjectItem())
     {
         Name = name,
         Path = path
     };
     Initialize(parent, vm, Models.PageType.Output);
 }
Пример #9
0
 public void RaiseFileCreated(ProjectItemViewModel item)
 {
     if (item.Type == ProjectItemType.File)
     {
         if (FileCreated != null)
         {
             FileCreated(this, new FileEventArgs(item.Path));
         }
     }
 }
Пример #10
0
 public void RaiseReferenceAdded(ProjectItemViewModel item)
 {
     if (item.Type == ProjectItemType.Reference)
     {
         if (ReferenceAdded != null)
         {
             ReferenceAdded(this, new FileEventArgs(item.Path));
         }
     }
 }
Пример #11
0
        public PageViewModel(BaseViewModel parent, string name, string path) : base(parent)
        {
            ProjectItemViewModel vm = new ProjectItemViewModel(new Models.ProjectItem())
            {
                Name = name,
                Path = path
            };

            Initialize(parent, vm, Models.PageType.Output);
        }
Пример #12
0
        public void PerformAddFile()
        {
            ProjectItemViewModel selected = SelectedItem;

            if (selected == null)
            {
                return;
            }
            if (selected.Type != ProjectItemType.Blueprints && selected.Type != ProjectItemType.Collection && selected.Type != ProjectItemType.Folder)
            {
                selected = GetParentFolder(selected);
            }
            if (selected == null || selected.Type == ProjectItemType.Root)
            {
                return;
            }

            Views.NewItemDialog view   = new Views.NewItemDialog();
            Nullable <bool>     result = view.ShowDialog();

            if (result != null && result.Value == true)
            {
                string fullpath = Path.Combine(selected.Path, String.Format("{0}.csx", view.ItemName));
                try
                {
                    string starter = Services.NewFile.Contents;

                    File.Write(fullpath, starter);

                    ProjectItemViewModel newfile = null;

                    string      name = Path.GetFileNameWithoutExtension(fullpath);
                    ProjectItem item = new ProjectItem()
                    {
                        Name    = name,
                        Path    = fullpath,
                        Type    = ProjectItemType.File,
                        Project = this
                    };
                    newfile             = selected.AddChild(item);
                    selected.IsExpanded = true;

                    if (newfile != null)
                    {
                        RaiseFileCreated(newfile);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.ShowError("Unable to create new file", ex);
                    return;
                }
                SaveProject();
            }
        }
Пример #13
0
        private bool ReferencesExists(ProjectItemViewModel root)
        {
            foreach (ProjectItemViewModel child in root.Children)
            {
                if (child.Type == ProjectItemType.References)
                {
                    return(true);
                }
            }

            return(false);
        }
        private void Project_SelectionChanged(object sender, EventArgs e)
        {
            ProjectItemViewModel item = Project.GetSelectedBlueprint();

            if (item != null)
            {
                Blueprint.SetBlueprint(item.Grid);
            }
            else
            {
                Blueprint.SetBlueprint(null);
            }
        }
Пример #15
0
        public void PerformAddFolder()
        {
            ProjectItemViewModel selected = SelectedItem;

            if (selected == null)
            {
                return;
            }
            if (selected.Type != ProjectItemType.Root && selected.Type != ProjectItemType.Blueprints && selected.Type != ProjectItemType.Collection && selected.Type != ProjectItemType.Folder)
            {
                selected = GetParentFolder(selected);
            }
            if (selected == null)
            {
                return;
            }

            Views.NewItemDialog view   = new Views.NewItemDialog();
            Nullable <bool>     result = view.ShowDialog();

            if (result != null && result.Value == true)
            {
                string name = view.ItemName;

                string fullpath = Path.Combine(selected.Path, name);
                if (selected.Type == ProjectItemType.Root)
                {
                    fullpath = Path.Combine(Path.GetDirectoryName(selected.Path), name);
                }

                try
                {
                    Directory.CreateDirectory(fullpath);
                    ProjectItem item = new ProjectItem()
                    {
                        Name    = name,
                        Path    = fullpath,
                        Type    = ProjectItemType.Folder,
                        Project = this,
                    };
                    selected.AddChild(item);
                    selected.IsExpanded = true;
                }
                catch (Exception ex)
                {
                    MessageBox.ShowError("Unable to create new directory", ex);
                    return;
                }
                SaveProject();
            }
        }
Пример #16
0
        public ProjectItemViewModel(ProjectItem item, ProjectItemViewModel parent) : base(parent)
        {
            _Model = item;

            _Children = new Services.ObservableSortedList <ProjectItemViewModel>(
                (from child in _Model.Children select new ProjectItemViewModel(child, this)).ToList <ProjectItemViewModel>(),
                new Comparers.ProjectItemComparer()
                );

            _Grid = new Services.ObservableSortedList <GridItemViewModel>(
                new GridItemViewModel[] { },
                new Comparers.GridItemComparer()
                );
        }
Пример #17
0
        public ProjectItemViewModel GetSelectedFile()
        {
            ProjectItemViewModel selected = SelectedItem;

            if (selected == null)
            {
                return(null);
            }
            if (selected.Type == ProjectItemType.File)
            {
                return(selected);
            }
            return(null);
        }
Пример #18
0
        public ProjectItemViewModel AddChild(ProjectItem item, Interop.Grid grid)
        {
            ProjectItemViewModel vm = new ProjectItemViewModel(item, this);

            if (grid != null)
            {
                vm.Grid.Add(CreateGridViewModel(grid));
            }

            _Children.Add(vm);
            Model.Children.Add(item);

            return(vm);
        }
Пример #19
0
 public void RaiseFileDeleted(ProjectItemViewModel item)
 {
     if (item.Type == ProjectItemType.File)
     {
         if (FileDeleted != null)
         {
             FileDeleted(this, new FileEventArgs(item.Path));
         }
     }
     foreach (ProjectItemViewModel child in item.Children)
     {
         RaiseFileDeleted(child);
     }
 }
Пример #20
0
        public ProjectItemViewModel(ProjectItem item, ProjectItemViewModel parent)
            : base(parent)
        {
            _Model = item;

            _Children = new Services.ObservableSortedList<ProjectItemViewModel>(
                (from child in _Model.Children select new ProjectItemViewModel(child, this)).ToList<ProjectItemViewModel>(),
                new Comparers.ProjectItemComparer()
            );

            _Grid = new Services.ObservableSortedList<GridItemViewModel>(
                new GridItemViewModel[] { },
                new Comparers.GridItemComparer()
            );
        }
Пример #21
0
        public void SetRootItem(ProjectItem root)
        {
            if (root == null)
            {
                _RootItem = null;
                _First.Clear();
                return;
            }

            SetProject(root, this);

            _RootItem = new ProjectItemViewModel(root);

            _First.Clear();
            _First.Add(_RootItem);
        }
Пример #22
0
 public ProjectItemViewModel GetItemByPath(ProjectItemViewModel item, string path)
 {
     if (item.Path == path)
     {
         return(item);
     }
     foreach (ProjectItemViewModel child in item.Children)
     {
         ProjectItemViewModel result = GetItemByPath(child, path);
         if (result != null)
         {
             return(result);
         }
     }
     return(null);
 }
Пример #23
0
        private void Initialize(BaseViewModel parent, ProjectItemViewModel item, Models.PageType type)
        {
            _ProjectItem = item;

            _Model     = new Models.Page();
            Header     = item.Name;
            Identifier = Guid.NewGuid();
            Type       = type;

            item.PropertyChanged += ProjectItem_PropertyChanged;

            BuildEditor();

            _CloseFileCommand  = new Commands.DelegateCommand(PerformCloseFile);
            _SelectPageCommand = new Commands.DelegateCommand(PerformSelectPage);
        }
Пример #24
0
        private ProjectItemViewModel GetParentFolder(ProjectItemViewModel child)
        {
            if (child == null || child.Parent == null)
            {
                return(null);
            }

            ProjectItemViewModel parent = (ProjectItemViewModel)child.Parent;

            if (parent.Type == ProjectItemType.Root || parent.Type == ProjectItemType.Collection || parent.Type == ProjectItemType.Blueprints || parent.Type == ProjectItemType.Folder)
            {
                return(parent);
            }
            else
            {
                return(GetParentFolder(parent));
            }
        }
Пример #25
0
        public void RaiseSelectionChanged()
        {
            RaisePropertyChanged("SelectedItemType");

            ProjectItemViewModel selected = SelectedItem;

            if (selected == null)
            {
                selected = _RootItem;
            }

            if (selected.Type != ProjectItemType.Blueprints && selected.Type != ProjectItemType.Folder)
            {
                selected = GetParentFolder(selected);
            }

            SelectionChanged(this, EventArgs.Empty);
        }
Пример #26
0
        public List <string> GetAssociatedScripts(string path)
        {
            List <string> scripts = new List <string>();

            ProjectItemViewModel item = GetItemByPath(path);

            if (item != null)
            {
                ProjectItemViewModel collection = GetParentCollection(item);
                if (collection != null)
                {
                    List <string> add = new List <string>();
                    scripts.AddRange(CollectScripts(path, collection, add));
                }
            }

            return(scripts);
        }
Пример #27
0
        private IEnumerable <ProjectItemViewModel> FindMatches(string text, ProjectItemViewModel item)
        {
            if (item == null)
            {
                yield return(null);
            }
            if (item.NameContainsText(text))
            {
                yield return(item);
            }

            foreach (ProjectItemViewModel child in item.Children)
            {
                foreach (ProjectItemViewModel match in FindMatches(text, child))
                {
                    yield return(match);
                }
            }
        }
Пример #28
0
 public ProjectItemViewModel GetParentBlueprint(ProjectItemViewModel item)
 {
     if (item == null || item.Type == ProjectItemType.Root)
     {
         return(null);
     }
     if (item.Type == ProjectItemType.Blueprints)
     {
         return(item);
     }
     if (item.Parent == null)
     {
         return(null);
     }
     else
     {
         ProjectItemViewModel parent = (ProjectItemViewModel)item.Parent;
         return(GetParentBlueprint(parent));
     }
 }
Пример #29
0
        private List <string> CollectScripts(string path, ProjectItemViewModel item, List <string> scripts)
        {
            if (item == null)
            {
                return(scripts);
            }

            if (item.Type == ProjectItemType.File && item.Path != path)
            {
                string code = File.Read(item.Path);
                scripts.Add(code);
            }
            foreach (ProjectItemViewModel child in item.Children)
            {
                List <string> empty = new List <string>();
                scripts.AddRange(CollectScripts(path, child, empty));
            }

            return(scripts);
        }
Пример #30
0
 private ProjectItemViewModel GetParentCollection(ProjectItemViewModel item)
 {
     if (item == null || item.Type == ProjectItemType.Root)
     {
         return(null);
     }
     if (item.Type == ProjectItemType.Collection)
     {
         return(item);
     }
     if (item.Parent == null)
     {
         return(null);
     }
     else
     {
         ProjectItemViewModel parent = (ProjectItemViewModel)item.Parent;
         return(GetParentCollection(parent));
     }
 }
Пример #31
0
        private IEnumerable <ProjectItemViewModel> FindSelected(ProjectItemViewModel item)
        {
            if (item == null)
            {
                yield return(null);
            }

            if (item.IsSelected)
            {
                yield return(item);
            }

            foreach (ProjectItemViewModel child in item.Children)
            {
                foreach (ProjectItemViewModel match in FindSelected(child))
                {
                    // TODO fix collection modified exception
                    yield return(match);
                }
            }
        }
        public void PerformOpenItem(ProjectItemViewModel item)
        {
            if (item != null)
            {
                if (!File.Exists(item.Path))
                {
                    return;
                }

                foreach (PageViewModel page in Editor.Items)
                {
                    if (page.Filename == item.Path)
                    {
                        page.IsActive = true;
                        return;
                    }
                }

                PageViewModel newpage = new PageViewModel(this, item);
                Editor.Items.Add(newpage);
            }
        }
Пример #33
0
        public ProjectItemViewModel AddChild(ProjectItem item, Interop.Grid grid)
        {
            ProjectItemViewModel vm = new ProjectItemViewModel(item, this);
            if (grid != null)
            {
                vm.Grid.Add(CreateGridViewModel(grid));
            }

            _Children.Add(vm);
            Model.Children.Add(item);

            return vm;
        }
Пример #34
0
 public ProjectItemViewModel GetItemByPath(ProjectItemViewModel item, string path)
 {
     if (item.Path == path)
     {
         return item;
     }
     foreach (ProjectItemViewModel child in item.Children)
     {
         ProjectItemViewModel result = GetItemByPath(child, path);
         if (result != null)
         {
             return result;
         }
     }
     return null;
 }
Пример #35
0
 public void RaiseReferenceAdded(ProjectItemViewModel item)
 {
     if (item.Type == ProjectItemType.Reference)
     {
         if (ReferenceAdded != null)
         {
             ReferenceAdded(this, new FileEventArgs(item.Path));
         }
     }
 }
Пример #36
0
 private void RemoveChild(ProjectItemViewModel child)
 {
     Model.Children.Remove(child.Model);
     _Children.Remove(child);
 }
Пример #37
0
 private ProjectItemViewModel GetParentCollection(ProjectItemViewModel item)
 {
     if (item == null || item.Type == ProjectItemType.Root)
     {
         return null;
     }
     if (item.Type == ProjectItemType.Collection)
     {
         return item;
     }
     if (item.Parent == null)
     {
         return null;
     }
     else
     {
         ProjectItemViewModel parent = (ProjectItemViewModel)item.Parent;
         return GetParentCollection(parent);
     }
 }
Пример #38
0
 public PageViewModel(BaseViewModel parent, ProjectItemViewModel item)
     : base(parent)
 {
     Initialize(parent, item, Models.PageType.Page);
 }
Пример #39
0
        private void Initialize(BaseViewModel parent, ProjectItemViewModel item, Models.PageType type)
        {
            _ProjectItem = item;

            _Model = new Models.Page();
            Header = item.Name;
            Identifier = Guid.NewGuid();
            Type = type;

            item.PropertyChanged += ProjectItem_PropertyChanged;

            BuildEditor();

            _CloseFileCommand = new Commands.DelegateCommand(PerformCloseFile);
            _SelectPageCommand = new Commands.DelegateCommand(PerformSelectPage);
        }
Пример #40
0
        public void SetRootItem(ProjectItem root)
        {
            if (root == null)
            {
                _RootItem = null;
                _First.Clear();
                return;
            }

            SetProject(root, this);

            _RootItem = new ProjectItemViewModel(root);

            _First.Clear();
            _First.Add(_RootItem);
        }
Пример #41
0
 public ProjectItemViewModel GetParentBlueprint(ProjectItemViewModel item)
 {
     if (item == null || item.Type == ProjectItemType.Root)
     {
         return null;
     }
     if (item.Type == ProjectItemType.Blueprints)
     {
         return item;
     }
     if (item.Parent == null)
     {
         return null;
     }
     else
     {
         ProjectItemViewModel parent = (ProjectItemViewModel)item.Parent;
         return GetParentBlueprint(parent);
     }
 }
Пример #42
0
        private List<BackupItem> GetBackups(ProjectItemViewModel item)
        {
            BackupManager manager = new BackupManager(this.Model.Path);

            List<BackupItem> result = new List<BackupItem>();

            if (item.Type == ProjectItemType.File)
            {
                BackupItem backup = manager.GetBackup(item.Path);
                if (backup != null)
                {
                    result.Add(backup);
                }
            }

            foreach(ProjectItemViewModel child in item.Children)
            {
                result.AddRange(GetBackups(child));
            }

            return result;
        }
Пример #43
0
        private IEnumerable<ProjectItemViewModel> FindSelected(ProjectItemViewModel item)
        {
            if (item == null)
            {
                yield return null;
            }

            if (item.IsSelected)
            {
                yield return item;
            }

            foreach (ProjectItemViewModel child in item.Children)
            {
                foreach (ProjectItemViewModel match in FindSelected(child))
                {
                    // TODO fix collection modified exception
                    yield return match;
                }
            }
        }
Пример #44
0
 public void RaiseFileDeleted(ProjectItemViewModel item)
 {
     if (item.Type == ProjectItemType.File)
     {
         if (FileDeleted != null)
         {
             FileDeleted(this, new FileEventArgs(item.Path));
         }
     }
     foreach (ProjectItemViewModel child in item.Children)
     {
         RaiseFileDeleted(child);
     }
 }
Пример #45
0
 public void RaiseFileCreated(ProjectItemViewModel item)
 {
     if (item.Type == ProjectItemType.File)
     {
         if (FileCreated != null)
         {
             FileCreated(this, new FileEventArgs(item.Path));
         }
     }
 }
Пример #46
0
        public void PerformOpenItem(ProjectItemViewModel item)
        {
            if (item != null)
            {
                if (!File.Exists(item.Path))
                {
                    return;
                }

                foreach (PageViewModel page in Editor.Items)
                {
                    if (page.Filename == item.Path)
                    {
                        page.IsActive = true;
                        return;
                    }
                }

                PageViewModel newpage = new PageViewModel(this, item);
                Editor.Items.Add(newpage);
            }
        }
Пример #47
0
        private bool ReferencesExists(ProjectItemViewModel root)
        {
            foreach(ProjectItemViewModel child in root.Children)
            {
                if (child.Type == ProjectItemType.References)
                {
                    return true;
                }
            }

            return false;
        }
Пример #48
0
        private IEnumerable<ProjectItemViewModel> FindMatches(string text, ProjectItemViewModel item)
        {
            if (item == null)
            {
                yield return null;
            }
            if (item.NameContainsText(text))
            {
                yield return item;
            }

            foreach (ProjectItemViewModel child in item.Children)
            {
                foreach (ProjectItemViewModel match in FindMatches(text, child))
                {
                    yield return match;
                }
            }
        }
Пример #49
0
        private ProjectItemViewModel GetParentFolder(ProjectItemViewModel child)
        {
            if (child == null || child.Parent == null)
            {
                return null;
            }

            ProjectItemViewModel parent = (ProjectItemViewModel)child.Parent;
            if (parent.Type == ProjectItemType.Root || parent.Type == ProjectItemType.Collection || parent.Type == ProjectItemType.Blueprints || parent.Type == ProjectItemType.Folder)
            {
                return parent;
            }
            else
            {
                return GetParentFolder(parent);
            }
        }
Пример #50
0
        private List<string> CollectScripts(string path, ProjectItemViewModel item, List<string> scripts)
        {
            if (item == null)
            {
                return scripts;
            }

            if (item.Type == ProjectItemType.File && item.Path != path)
            {
                string code = File.Read(item.Path);
                scripts.Add(code);
            }
            foreach (ProjectItemViewModel child in item.Children)
            {
                List<string> empty = new List<string>();
                scripts.AddRange(CollectScripts(path, child, empty));
            }

            return scripts;
        }
Пример #51
0
        private void LoadBlueprints(ProjectItemViewModel item, bool failed)
        {
            if (item.Type == ProjectItemType.Blueprints)
            {
                string name;
                Interop.Grid grid;

                Interop.Blueprint.Import(item.Blueprint, out name, out grid);

                if (grid == null)
                {
                    failed = true;
                }
                else
                {
                    item.SetGrid(grid);
                }
            }
            foreach (ProjectItemViewModel child in item.Children)
            {
                LoadBlueprints(child, failed);
            }
        }