コード例 #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;
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        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
ファイル: PageViewModel.cs プロジェクト: gilgame/SEWorkbench
 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);
        }
コード例 #14
0
        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);
                }
            }
        }
コード例 #32
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);
            }
        }
コード例 #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
ファイル: PageViewModel.cs プロジェクト: gilgame/SEWorkbench
 public PageViewModel(BaseViewModel parent, ProjectItemViewModel item)
     : base(parent)
 {
     Initialize(parent, item, Models.PageType.Page);
 }
コード例 #39
0
ファイル: PageViewModel.cs プロジェクト: gilgame/SEWorkbench
        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);
            }
        }