Ejemplo n.º 1
0
        public VirtualControl()
        {
            KeyboardNavigation.SetDirectionalNavigation(this, KeyboardNavigationMode.None);
            PreviewMouseDown += OnMouseDown;
            MouseMove        += OnMouseMove;
            MouseUp          += OnMouseUp;
            PreviewKeyDown   += OnKeyDown;
            ContextMenu       = VirtualContextMenu();
            AddChildren(InnerMsg);
            SelectedNodes.CollectionChanged += SelectedUiElementsOnCollectionChanged;
            AllowDrop = true;
            Drop     += VirtualControl_Drop;
            var init = false;

            GotFocus  += (s, e) => Hub.CurrentHost = this;
            SearchForm = new Search(this);
            Loaded    += (sender, args) =>
            {
                if (!init)
                {
                    InitRoot();
                    init = true;
                }
            };
            NodesTree = new NodesTree(this);
        }
Ejemplo n.º 2
0
        public ContentTreeNode Expand(params string[] names)
        {
            var sb = new StringBuilder();

            for (var i = 0; i < names.Length; i++)
            {
                if (i == 0)
                {
                    continue;
                }
                sb.Append(names[i]);
                sb.Append(" => ");
                var node = NodesTree.FindTreeNode(e =>
                                                  e.Parent != null &&
                                                  e.Parent.Data.Name.Equals(names[i - 1]) &&
                                                  e.Data.Name.Equals(names[i])).Data;

                if (i != names.Length - 1)
                {
                    node.Expand(false);
                }
                else
                {
                    return(node);
                }
            }

            return(null);
        }
Ejemplo n.º 3
0
        public void SelectPaletteItem(PaletteItem item, bool isMultiDrop)
        {
            if (item != _selectedPaletteItem)
            {
                _isMultiDrop = isMultiDrop && (item != null);

                if (_selectedPaletteItem != null)
                {
                    //FSelectedPaletteItem.ListView.ButtonView = false;
                    // FSelectedPaletteItem.ListView.SelectedTextColor = Color.Navy;
                }

                _selectedPaletteItem = item;

                if (_selectedPaletteItem != null)
                {
                    //FSelectedPaletteItem.ListView.ButtonView = true;
                    //FSelectedPaletteItem.ListView.SelectedItem =
                    //    FSelectedPaletteItem.ListView.GroupViewItems.IndexOf(FSelectedPaletteItem);

                    _selectedPaletteItem.Selected = true;

                    // if (FIsMultiDrop)
                    //     FSelectedPaletteItem.ListView.SelectedTextColor = Color.Blue;*/

                    NodesTree.PaletteItem = _selectedPaletteItem;
                    SetStatus(_selectedPaletteItem.Description);
                    //FPointerGroupView.ButtonView = false;
                }
                else
                {
                    NodesTree.PaletteItem = null;
                    SetStatus(String.Empty);
                    //FPointerGroupView.ButtonView = true;
                }

                NodesTree.Select();
            }
        }
Ejemplo n.º 4
0
        // TODO: Clean up this method, split in smaller parts, update it as more info is available
        private bool Read(BinaryReader br)
        {
            try
            {
                Header header = new Header();
                header.Read(br);
                NodesTree nodesTree = new NodesTree();
                nodesTree.Read(br);
                Name = nodesTree.name;
                br.BaseStream.Seek(header.ContentsTableOffset, SeekOrigin.Begin);
                ContentsTable contentsTable = new ContentsTable();
                contentsTable.Read(br);
                MaterialsHeader materialsHeader = new MaterialsHeader();
                materialsHeader.Read(br);
                ObjectsTable objectsTable = new ObjectsTable();
                objectsTable.SetCount(contentsTable.objectsCount);
                objectsTable.Read(br);
                SubObjectsTable subObjectsTable = new SubObjectsTable();
                subObjectsTable.SetCount(contentsTable.subObjectsCount);
                subObjectsTable.Read(br);

                // In theory, it could be read all the data from current stream position
                //      but it would be safer to read by using the already read offsets

                // Read the materials table
                MaterialsTable materialsTable = new MaterialsTable();
                materialsTable.SetCount(materialsHeader.materialsCount);
                br.BaseStream.Seek(materialsHeader.materialsTableOffset, SeekOrigin.Begin);
                materialsTable.Read(br);
                // Build the materials list
                for (int i = 0; i < materialsTable.GetCount(); i++)
                {
                    Material mat = materialsTable[i].GetMaterial(br);
                    Materials.Add(mat);
                }

                // TODO: Read data for all the subobjects


                // Read data for all the objects
                for (int i = 0; i < objectsTable.GetCount(); i++)
                {
                    Model model = new Model();
                    br.BaseStream.Seek(objectsTable[i].nameAddress, SeekOrigin.Begin);
                    model.name = Text.ReadText(br);
                    if (objectsTable[i].materialDefsAddress != null && objectsTable[i].materialDefsCount > 0)
                    {
                        br.BaseStream.Seek(objectsTable[i].materialDefsAddress.Value, SeekOrigin.Begin);
                        MaterialDef matDef = new MaterialDef();
                        matDef.Read(br);
                        model.materialIndices = matDef.materialIndices;
                    }
                    if (objectsTable[i].childDefsAddress != null && objectsTable[i].childsDefsCount > 0)
                    {
                        br.BaseStream.Seek(objectsTable[i].childDefsAddress.Value, SeekOrigin.Begin);
                        ChildsDef childsDef = new ChildsDef();
                        childsDef.SetCount(objectsTable[i].childsDefsCount);
                        childsDef.Read(br);
                        // TODO: Decide how to add it to the model
                    }
                    if (objectsTable[i].data1Address != null && objectsTable[i].data1Count > 0)
                    {
                        List <int> meshesAddress = new List <int>();
                        br.BaseStream.Seek(objectsTable[i].data1Address.Value, SeekOrigin.Begin);
                        for (int j = 0; j < objectsTable[i].data1Count; j++)
                        {
                            int address = (int)ReadRelativeOffset(br);
                            meshesAddress.Add(address);
                        }
                        for (int j = 0; j < objectsTable[i].data1Count; j++)
                        {
                            br.BaseStream.Seek(meshesAddress[j], SeekOrigin.Begin);
                            Def def = new Def();
                            if (!def.Read(br))
                            {
                                return(false);
                            }
                            if (def.nextChunk != null && def.nextChunk is MeshDef)
                            {
                                MeshDef md = (MeshDef)def.nextChunk;
                                for (int k = 0; k < md.meshesData.Count; k++)
                                {
                                    MeshData data = md.meshesData[k];
                                    Mesh     mesh = new Mesh(data.boundingBox, data.vertices, data.triangles, data.textureVertices);
                                    model.meshes.Add(mesh);
                                }
                            }
                        }
                    }
                    Models.Add(model);
                }
            }
            catch
            {
                // TODO: Handle here any error reading
                return(false);
            }
            return(true);
        }
Ejemplo n.º 5
0
 public CategoryTreeViewModel()
 {
     NodesTree   = new NodesTree();
     CurrentNode = NodesTree.SelectedNode;
 }