Esempio n. 1
0
        private TreeViewItemViewModel(BaseTreeItem treeItem, TreeViewItemViewModel parent)
        {
            _treeItem = treeItem;
            _parent   = parent;

            _children = new ReadOnlyCollection <TreeViewItemViewModel>(_treeItem.Children.Select(child => new TreeViewItemViewModel(child, this)).ToList());
        }
Esempio n. 2
0
        public void ReadXml(XmlReader reader)
        {
            while (reader.Read())
            {
                reader.MoveToContent();

                if (reader.LocalName.Equals("Project") && reader.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }

                if (reader.IsEmptyElement || reader.NodeType == XmlNodeType.EndElement)
                {
                    continue;
                }

                switch (reader.LocalName)
                {
                case "Name":
                    reader.Read();
                    Name = reader.Value;
                    break;

                case "Path":
                    string BasePath = reader.BaseURI.Substring(8, reader.BaseURI.Length - reader.BaseURI.Split('/').Last().Length - 9).Replace('/', '\\');
                    Path = Directory.Exists(reader.Value) ? reader.Value : BasePath;
                    break;

                case "Children":
                    void _readxml(BaseTreeItem rootTreeItem)
                    {
                        while (reader.Read())
                        {
                            if (reader.LocalName.Equals("Children") && reader.NodeType == XmlNodeType.EndElement)
                            {
                                break;
                            }

                            if (reader.NodeType == XmlNodeType.Element && !reader.LocalName.Equals("Name") && !reader.LocalName.Equals("Path") && !reader.LocalName.Equals("Children"))
                            {
                                BaseTreeItem treeItem = (BaseTreeItem)Assembly.GetExecutingAssembly().CreateInstance("GameStoryEdit.TreeData." + reader.LocalName);
                                while (reader.Read())
                                {
                                    if (reader.NodeType == XmlNodeType.EndElement && !reader.LocalName.Equals("Name") && !reader.LocalName.Equals("Path") && !reader.LocalName.Equals("Children"))
                                    {
                                        break;
                                    }
                                    if (reader.IsEmptyElement || reader.NodeType == XmlNodeType.EndElement)
                                    {
                                        continue;
                                    }
                                    switch (reader.LocalName)
                                    {
                                    case "Name":
                                        reader.Read();
                                        treeItem.Name = reader.Value;
                                        break;

                                    case "Path":
                                        reader.Read();
                                        treeItem.Path = Directory.Exists(reader.Value) ? reader.Value : Path.Substring(0, 3) + reader.Value.Substring(3);
                                        break;

                                    case "Children":
                                        _readxml(treeItem);
                                        break;
                                    }
                                }

                                if (treeItem is ScreenPlay sp && sp.Name != null && sp.Path != null)
                                {
                                    sp.FountainEditor = new UserControls.FountainEditor();
                                }

                                rootTreeItem.Children.Add(treeItem);
                            }
                        }
                    }

                    _readxml(this);
                    break;
                }
            }
        }
Esempio n. 3
0
 public TreeViewItemViewModel(BaseTreeItem treeItem)
     : this(treeItem, null)
 {
 }