private void TreeViewRefresh(object sender, EventArgs e) { if (m_serverProxy == null) { return; } if (!m_serverProxy.IsRunning) { return; } //Refresh the entities try { m_sectorEntities = m_serviceClient.GetSectorEntities(); } catch (Exception) { Disconnect(); return; } TRV_Entities.BeginUpdate(); TreeNode sectorObjectsNode; TreeNode sectorEventsNode; if (TRV_Entities.Nodes.Count < 2) { sectorObjectsNode = TRV_Entities.Nodes.Add("Sector Objects"); sectorEventsNode = TRV_Entities.Nodes.Add("Sector Events"); sectorObjectsNode.Name = sectorObjectsNode.Text; sectorEventsNode.Name = sectorEventsNode.Text; } else { sectorObjectsNode = TRV_Entities.Nodes[0]; sectorEventsNode = TRV_Entities.Nodes[1]; } foreach (BaseEntityProxy entity in m_sectorEntities) { entity.PropertyChanged += EntityPropertyChangedCallback; } RenderSectorObjectChildNodes(sectorObjectsNode); sectorObjectsNode.Text = sectorObjectsNode.Name + " (" + m_sectorEntities.Count.ToString() + ")"; TRV_Entities.EndUpdate(); }
private void TRV_Entities_AfterSelect(object sender, TreeViewEventArgs e) { BTN_Entities_Export.Enabled = false; BTN_Entities_New.Enabled = false; BTN_Entities_Delete.Enabled = false; TreeNode selectedNode = e.Node; if (selectedNode == null) { return; } TreeNode parentNode = e.Node.Parent; if (parentNode == null) { return; } if (selectedNode.Tag == null) { return; } var linkedObject = selectedNode.Tag; PG_Entities_Details.SelectedObject = linkedObject; if (linkedObject is CubeGridEntityProxy) { TRV_Entities.BeginUpdate(); RenderCubeGridChildNodes((CubeGridEntityProxy)linkedObject, e.Node); TRV_Entities.EndUpdate(); } if (linkedObject is CharacterEntityProxy) { CharacterEntityProxy character = (CharacterEntityProxy)linkedObject; if (e.Node.Nodes.Count < 1) { TRV_Entities.BeginUpdate(); e.Node.Nodes.Clear(); TreeNode itemsNode = e.Node.Nodes.Add("Items"); itemsNode.Name = itemsNode.Text; //itemsNode.Tag = character.Inventory; TRV_Entities.EndUpdate(); } } if (linkedObject is CargoContainerEntityProxy) { CargoContainerEntityProxy container = (CargoContainerEntityProxy)linkedObject; if (e.Node.Nodes.Count < 1) { TRV_Entities.BeginUpdate(); e.Node.Nodes.Clear(); TreeNode itemsNode = e.Node.Nodes.Add("Items"); itemsNode.Name = itemsNode.Text; itemsNode.Tag = container.Inventory; TRV_Entities.EndUpdate(); } } if (linkedObject is ReactorEntityProxy) { ReactorEntityProxy reactor = (ReactorEntityProxy)linkedObject; if (e.Node.Nodes.Count < 1) { TRV_Entities.BeginUpdate(); e.Node.Nodes.Clear(); TreeNode itemsNode = e.Node.Nodes.Add("Items"); itemsNode.Name = itemsNode.Text; itemsNode.Tag = reactor.Inventory; TRV_Entities.EndUpdate(); } } if (linkedObject is ShipToolBaseEntityProxy) { ShipToolBaseEntityProxy shipTool = (ShipToolBaseEntityProxy)linkedObject; if (e.Node.Nodes.Count < 1) { TRV_Entities.BeginUpdate(); e.Node.Nodes.Clear(); TreeNode itemsNode = e.Node.Nodes.Add("Items"); itemsNode.Name = itemsNode.Text; itemsNode.Tag = shipTool.Inventory; TRV_Entities.EndUpdate(); } } if (linkedObject is ShipDrillEntityProxy) { ShipDrillEntityProxy shipDrill = (ShipDrillEntityProxy)linkedObject; if (e.Node.Nodes.Count < 1) { TRV_Entities.BeginUpdate(); e.Node.Nodes.Clear(); TreeNode itemsNode = e.Node.Nodes.Add("Items"); itemsNode.Name = itemsNode.Text; itemsNode.Tag = shipDrill.Inventory; TRV_Entities.EndUpdate(); } } if (linkedObject is ProductionBlockEntityProxy) { ProductionBlockEntityProxy productionBlock = (ProductionBlockEntityProxy)linkedObject; if (e.Node.Nodes.Count < 2) { TRV_Entities.BeginUpdate(); e.Node.Nodes.Clear(); TreeNode inputNode = e.Node.Nodes.Add("Input"); inputNode.Name = inputNode.Text; inputNode.Tag = productionBlock.InputInventory; TreeNode outputNode = e.Node.Nodes.Add("Output"); outputNode.Name = outputNode.Text; outputNode.Tag = productionBlock.OutputInventory; TRV_Entities.EndUpdate(); } } if (linkedObject is InventoryEntityProxy) { InventoryEntityProxy inventory = (InventoryEntityProxy)linkedObject; if (parentNode.Tag is CubeBlockEntityProxy && parentNode.Parent.Parent.Tag is CubeGridEntityProxy) { CubeGridEntityProxy cubeGrid = (CubeGridEntityProxy)parentNode.Parent.Parent.Tag; CubeBlockEntityProxy cubeBlock = (CubeBlockEntityProxy)parentNode.Tag; long cubeGridEntityId = cubeGrid.EntityId; long cubeBlockEntityId = cubeBlock.EntityId; ushort inventoryIndex = 0; List <InventoryItemEntityProxy> inventoryItems = m_serviceClient.GetInventoryItems(cubeGridEntityId, cubeBlockEntityId, inventoryIndex); UpdateNodeInventoryItemBranch <InventoryItemEntityProxy>(e.Node, inventoryItems); } } }