Пример #1
0
        private void Remove_Click(object sender, EventArgs e)
        {
            foreach (int i in lvFiles.SelectedIndices)
            {
                CPCBigFile.Document.File item = Document.Files[i];
                if (item.ResourceCPCBigFileID != -1)
                {
                    MessageBox.Show("Can not modify external items", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            List <int> indices = new List <int>();

            foreach (int index in lvFiles.SelectedIndices)
            {
                Document.File file = Document.Files[index];

                List <PhactoryHost.Database.Resource> otherReferencingResources = Plugin.ControllerEditor.Host.IsOutputResourcesReferencedByOtherResources(Plugin.ControllerEditor.Host.GetResource(file.ResourceID), Plugin.ControllerEditor.Host.GetResource(Resource.Id));
                if (otherReferencingResources.Count > 0)
                {
                    Plugin.ControllerEditor.Host.ShowCantRemoveBecauseOtherResources(Plugin.ControllerEditor.Host.GetResource(file.ResourceID), Plugin.ControllerEditor.Host.GetResource(Resource.Id), otherReferencingResources);
                    return;
                }
                else
                {
                    indices.Add(index);
                }
            }

            // reverse delete
            for (int iIndex = indices.Count - 1; iIndex >= 0; iIndex--)
            {
                int index = indices[iIndex];

                Document.Files.RemoveAt(index);
                lvFiles.Items.RemoveAt(index);
            }

            if (indices.Count > 0)
            {
                SetModified(true);
                RefreshUI();
            }
        }
        protected void CreateNodeForDocumentPart(Document.DocumentPart documentPart, TreeNode parentNode)
        {
            if (documentPart is Document.Site)
            {
                Document.Site site = documentPart as Document.Site;
                TreeNode      node = new TreeNode("site: " + project.Name);
                node.Tag      = site;
                node.ImageKey = node.SelectedImageKey = "site";

                foreach (Document.DocumentPart childPart in site.Contents)
                {
                    CreateNodeForDocumentPart(childPart, node);
                }

                treeControl.Nodes.Add(node);
            }
            else if (documentPart is Document.Folder)
            {
                Document.Folder folder = documentPart as Document.Folder;
                TreeNode        node   = new TreeNode("folder: " + folder.Name);
                node.Tag      = folder;
                node.ImageKey = node.SelectedImageKey = "folder_closed";

                foreach (Document.DocumentPart childPart in folder.Contents)
                {
                    CreateNodeForDocumentPart(childPart, node);
                }

                parentNode.Nodes.Add(node);
            }
            else // File
            {
                Document.File file = documentPart as Document.File;
                TreeNode      node = new TreeNode("file: " + file.Name + ", mapped to: " + file.MappedTo);
                node.Tag      = file;
                node.ImageKey = node.SelectedImageKey = "parameter";

                parentNode.Nodes.Add(node);
            }
        }