Gilgame.SEWorkbench.ViewModels.ProjectItemViewModel.AddChild C# (CSharp) Method

AddChild() public method

public AddChild ( ProjectItem item ) : ProjectItemViewModel
item Gilgame.SEWorkbench.Models.ProjectItem
return ProjectItemViewModel
        public ProjectItemViewModel AddChild(ProjectItem item)
        {
            return AddChild(item, null);
        }

Same methods

ProjectItemViewModel::AddChild ( ProjectItem item, Interop grid ) : ProjectItemViewModel

Usage Example

コード例 #1
0
        private void CreateNewProjectTemplate()
        {
            if (_RootItem == null)
            {
                return;
            }

            string demofolder = "Library";
            string rootpath   = Path.GetDirectoryName(_RootItem.Path);
            string folderpath = Path.Combine(rootpath, demofolder);
            string filepath   = Path.Combine(folderpath, String.Format("NewScript.csx"));

            try
            {
                Directory.CreateDirectory(folderpath);
                ProjectItem folder = new ProjectItem()
                {
                    Name    = demofolder,
                    Path    = folderpath,
                    Type    = ProjectItemType.Folder,
                    Project = this,
                };

                File.Write(filepath, Services.NewFile.Contents);
                ProjectItem file = new ProjectItem()
                {
                    Name    = Path.GetFileNameWithoutExtension(filepath),
                    Path    = filepath,
                    Type    = ProjectItemType.File,
                    Project = this,
                };

                ProjectItemViewModel newfile = null;

                _RootItem.AddChild(folder);
                if (_RootItem.Children.Count > 0)
                {
                    foreach (ProjectItemViewModel item in _RootItem.Children)
                    {
                        if (item.Type == ProjectItemType.Folder)
                        {
                            newfile = item.AddChild(file);
                            if (item.Children.Count > 0)
                            {
                                item.Children[0].IsSelected = true;
                            }
                            item.IsExpanded = true;

                            break;
                        }
                    }
                }

                if (newfile != null)
                {
                    RaiseFileCreated(newfile);
                }
            }
            catch (Exception ex)
            {
                MessageBox.ShowError("Unable to create new project template", ex);
            }
        }
All Usage Examples Of Gilgame.SEWorkbench.ViewModels.ProjectItemViewModel::AddChild