Exemple #1
0
        public void SaveResource(PhactoryHost.Database.Resource resource)
        {
            bool writeOK = Host.XMLWrite(Host.GetFileInfo(resource).FullName, viewBinding[resource].View.Document);

            if (writeOK)
            {
                Host.RefreshOutput(resource);
                List <PhactoryHost.Database.Resource> dependentResources = new List <PhactoryHost.Database.Resource>();
                foreach (Document.Item item in viewBinding[resource].View.Document.Items)
                {
                    dependentResources.Add(Plugin.ControllerEditor.Host.GetResource(item.ResourceID));
                }
                Host.RefreshDependencies(resource, dependentResources);

                if (Host.IsVerboseOutput())
                {
                    Host.Log(resource.DisplayName + " written");
                }

                WriteIdFile(resource);

                viewBinding[resource].View.SetModified(false);
            }
            else
            {
                Host.Log("Problem while writing " + resource.DisplayName);
            }
        }
Exemple #2
0
        public bool CloseResource(PhactoryHost.Database.Resource resource)
        {
            if (viewBinding.ContainsKey(resource))
            {
                if (IsResourceModified(resource))
                {
                    switch (MessageBox.Show("The file has been modified. Save changes ?", "Confirm file close", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                    {
                    case DialogResult.Yes:
                        SaveResource(resource);
                        break;

                    case DialogResult.No:
                        break;

                    case DialogResult.Cancel:
                        return(false);
                    }
                }

                viewBinding.Remove(resource);
            }

            return(true);
        }
Exemple #3
0
        public void OpenResource(Panel parentPanel, PhactoryHost.Database.Resource resource)
        {
            View.View view = new View.View(resource);
            view.Parent = parentPanel;
            view.Dock   = System.Windows.Forms.DockStyle.Fill;

            ResourceBinding resourceBinding = new ResourceBinding(parentPanel, view);

            viewBinding.Add(resource, resourceBinding);

            resourceBinding.View.Document = Host.XMLRead <Document.Document>(Host.GetFileInfo(resource).FullName);

            if (resourceBinding.View.Document is Document.Document)
            {
                if (Host.IsVerboseOutput())
                {
                    Host.Log(resource.DisplayName + " loaded");
                }
            }
            else
            {
                Host.Log("Problem while loading " + resource.DisplayName);
            }

            view.RefreshUI();
            view.RefreshTitle();

            view.IsReady = true;
        }
Exemple #4
0
        private void treeView_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", true))
            {
                Point pt = this.treeView.PointToClient(new Point(e.X, e.Y));

                TreeNode node    = this.treeView.GetNodeAt(pt);
                Node     docNode = node.Tag as Node;

                if (docNode == null)
                {
                    return;
                }

                if (!docNode.IsFolder)
                {
                    PhactoryHost.Database.Resource resource = App.Controller.Entities.GetResource(docNode.ResourceId);
                    if (App.Controller.Entities.IsOutput(resource))
                    {
                        return;
                    }
                }

                e.Effect = DragDropEffects.Move;
            }
        }
Exemple #5
0
        private void AddTreeViewOutputResourceRecurse(TreeNode uiNode, PhactoryHost.Database.Resource resource)
        {
            App.Controller.View.AppDoEvents();

            foreach (int outputResourceId in resource.IdOutputs)
            {
                PhactoryHost.Database.Resource outputResource = App.Controller.Entities.GetResource(outputResourceId);

                if (App.Controller.UserConfig.HideUnusedResourcesInProjectExplorer)
                {
                    if (outputResource.Id != App.Controller.Entities.StartupResourceId)
                    {
                        if (App.Controller.PluginManager.Host.IsResourceReferencedByOtherResources(outputResource).Count == 0)
                        {
                            continue;
                        }
                    }
                }

                if (outputResource == null)
                {
                    continue;
                }

                TreeNode uiOutputNode = uiNode.Nodes.Add(outputResource.DisplayName);
                uiOutputNode.Tag = outputResource; // WARNING : not a node, but Resource !
                SetTreeViewResource(uiOutputNode, outputResource);

                AddTreeViewOutputResourceRecurse(uiOutputNode, outputResource);
            }
        }
Exemple #6
0
 private void SelectResourceRecursive(TreeNode uiNode, PhactoryHost.Database.Resource resource)
 {
     foreach (TreeNode node in uiNode.Nodes)
     {
         if (node.Text == resource.DisplayName)
         {
             treeView.SelectedNode = node;
         }
         else
         {
             SelectResourceRecursive(node, resource);
         }
     }
 }
Exemple #7
0
        private void addNewResourceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string fileLocation = App.Controller.UserConfig.ResourcePath;

            NewFile newFile = new NewFile();

            newFile.SetFileLocation(fileLocation);
            newFile.ShowDialog(this);
            if (newFile.Valid)
            {
                if (File.Exists(newFile.GetFilename()))
                {
                    App.Controller.View.ShowErrorMessage("Error", "'" + newFile.GetDisplayName() + "' already exists locally, choose another name.");
                    return;
                }

                App.Controller.UserConfig.NewFilePath = newFile.GetFilename();

                string relativePath = Helper.StringHelper.MakeRelativePath(App.Controller.UserConfig.NewFilePath);

                PhactoryHost.Database.Resource resource = new PhactoryHost.Database.Resource();
                resource.Id           = App.Controller.Entities.CreateNewResourceId();
                resource.DisplayName  = newFile.GetDisplayName();
                resource.RelativePath = relativePath;
                App.Controller.Entities.AddResource(resource);

                App.Controller.CreateNewResource(resource);

                Node childTreeNode = new Node();
                childTreeNode.IsFolder   = false;
                childTreeNode.ResourceId = resource.Id;

                Node treeNode = TreeViewSelectedNode.Tag as Node;
                treeNode.ChildNodes.Add(childTreeNode);

                App.Controller.SaveProject();

                TreeViewSelectedNode.Nodes.Clear();
                CreateTreeView(TreeViewSelectedNode, treeNode);

                treeView.BeginUpdate();
                treeView.Sort();
                treeView.EndUpdate();

                TreeNode createdNode = GetDocTreeNode(TreeViewSelectedNode, childTreeNode);
                treeView.SelectedNode = createdNode;
                TreeViewSelectedNode  = createdNode;
            }
        }
Exemple #8
0
        public bool IsResourceOpened(PhactoryHost.Database.Resource resource)
        {
            try
            {
                View.View view = viewBinding[resource].View;
                if (view != null)
                {
                    return(true);
                }
            }
            catch
            {
            }

            return(false);
        }
Exemple #9
0
        public void RefreshNodeOutput(PhactoryHost.Database.Resource resource)
        {
            App.Controller.View.AppDoEvents();

            TreeNode treeNode = GetTreeNode(treeView.Nodes[0], resource);

            if (treeNode != null)
            {
                treeNode.Nodes.Clear();
                AddTreeViewOutputResourceRecurse(treeNode, resource);

                treeView.BeginUpdate();
                treeView.Sort();
                treeView.EndUpdate();
            }
        }
Exemple #10
0
        public bool IsResourceSupported(PhactoryHost.Database.Resource resource)
        {
            FileInfo fileInfo = Host.GetFileInfo(resource);

            if (fileInfo == null)
            {
                return(false);
            }

            foreach (PhactoryHost.PluginExtension extension in GetSupportedExtensions())
            {
                if (String.Compare(extension.GetName(), fileInfo.Extension, true) == 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #11
0
        private void WriteIdFileContent(PhactoryHost.Database.Resource resource, string destFilename)
        {
            var document = Host.XMLRead <Document.Document>(Host.GetFileInfo(resource).FullName);

            var title = resource.DisplayName.ToUpper().Replace(" ", "").Replace(".", "") + "H";

            var fileContent = String.Empty;

            fileContent += "// ----------------------------------------------------------------------------\n";
            fileContent += "#ifndef _" + title + "_TRACKFILEID_H_\n";
            fileContent += "#define _" + title + "_TRACKFILEID_H_\n";
            fileContent += "\n";

            fileContent += "// ----------------------------------------------------------------------------\n";
            int fileId = 1;

            foreach (var item in document.Items)
            {
                if (item.TrackLoaderItem)
                {
                    var itemResource = Host.GetResource(item.ResourceID);
                    var itemTitle    = itemResource.DisplayName.ToUpper().Replace(" ", "").Replace(".", "");

                    if (item.IsDuplicate)
                    {
                        fileContent += "#define " + itemTitle + "_TRACKFILEID_" + item.DuplicatedIndex + " " + fileId + "\n";
                    }
                    else
                    {
                        fileContent += "#define " + itemTitle + "_TRACKFILEID " + fileId + "\n";
                    }
                    fileId++;
                }
            }

            fileContent += "\n";

            fileContent += "// ----------------------------------------------------------------------------\n";
            fileContent += "#endif // _" + title + "_TRACKFILEID_H_";

            File.WriteAllText(destFilename, fileContent);
        }
Exemple #12
0
        private void WriteIdFile(PhactoryHost.Database.Resource resource)
        {
            var destFilename = Host.GetFileInfo(resource).FullName + ".h";

            App.Controller.UserConfig.AddExistingResourceFullPath = destFilename;

            string relativePath = StringHelper.MakeRelativePath(destFilename);

            PhactoryHost.Database.Resource idResource = Host.GuessResource(new FileInfo(destFilename));
            if (idResource == null)
            {
                idResource              = new PhactoryHost.Database.Resource();
                idResource.Id           = App.Controller.Entities.CreateNewResourceId();
                idResource.DisplayName  = new FileInfo(destFilename).Name;
                idResource.RelativePath = relativePath;
                App.Controller.Entities.AddResource(idResource);

                App.Controller.CreateNewResource(idResource);

                var project = Host.GetEntities();

                Node folderNode = null;
                project.GetParentFolderTreeNode(project.TreeNode, ref folderNode, resource);
                if (folderNode != null)
                {
                    Node childTreeNode = new Node();
                    childTreeNode.IsFolder   = false;
                    childTreeNode.ResourceId = idResource.Id;

                    folderNode.ChildNodes.Add(childTreeNode);
                }

                App.Controller.SaveProject();
                Host.RefreshDB();
            }

            File.Delete(destFilename);
            WriteIdFileContent(resource, destFilename);

            Host.Log(idResource.DisplayName + " written");
        }
Exemple #13
0
        private TreeNode GetTreeNode(TreeNode rootNode, PhactoryHost.Database.Resource resource)
        {
            Node docNode = rootNode.Tag as Node;

            if (docNode != null)
            {
                if (docNode.ResourceId == resource.Id)
                {
                    return(rootNode);
                }
            }

            foreach (TreeNode childNode in rootNode.Nodes)
            {
                TreeNode outNode = GetTreeNode(childNode, resource);
                if (outNode != null)
                {
                    return(outNode);
                }
            }

            return(null);
        }
Exemple #14
0
 public void OnResourceChanged(PhactoryHost.Database.Resource resource)
 {
 }
Exemple #15
0
        private void addNewResourceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string fileLocation = App.Controller.UserConfig.ResourcePath;

            NewFile newFile = new NewFile();
            newFile.SetFileLocation(fileLocation);
            newFile.ShowDialog(this);
            if (newFile.Valid)
            {
                if (File.Exists(newFile.GetFilename()))
                {
                    App.Controller.View.ShowErrorMessage("Error", "'" + newFile.GetDisplayName() + "' already exists locally, choose another name.");
                    return;
                }

                App.Controller.UserConfig.NewFilePath = newFile.GetFilename();

                string relativePath = Helper.StringHelper.MakeRelativePath(App.Controller.UserConfig.NewFilePath);

                PhactoryHost.Database.Resource resource = new PhactoryHost.Database.Resource();
                resource.Id = App.Controller.Entities.CreateNewResourceId();
                resource.DisplayName = newFile.GetDisplayName();
                resource.RelativePath = relativePath;
                App.Controller.Entities.AddResource(resource);

                App.Controller.CreateNewResource(resource);

                Node childTreeNode = new Node();
                childTreeNode.IsFolder = false;
                childTreeNode.ResourceId = resource.Id;

                Node treeNode = TreeViewSelectedNode.Tag as Node;
                treeNode.ChildNodes.Add(childTreeNode);

                App.Controller.SaveProject();

                TreeViewSelectedNode.Nodes.Clear();
                CreateTreeView(TreeViewSelectedNode, treeNode);

                treeView.BeginUpdate();
                treeView.Sort();
                treeView.EndUpdate();

                TreeNode createdNode = GetDocTreeNode(TreeViewSelectedNode, childTreeNode);
                treeView.SelectedNode = createdNode;
                TreeViewSelectedNode = createdNode;
            }
        }
Exemple #16
0
        public bool IsOutput(Resource resource)
        {
            foreach (Resource iResource in Resources)
            {
                if (iResource.IdOutputs.IndexOf(resource.Id) != -1)
                {
                    return true;
                }
            }

            return false;
        }
Exemple #17
0
        public Node GetTreeNode(Node rootNode, Resource resource)
        {
            if ( !rootNode.IsFolder )
            {
                if (rootNode.ResourceId == resource.Id)
                {
                    return rootNode;
                }
            }

            foreach (Node childNode in rootNode.ChildNodes)
            {
                Node outNode = GetTreeNode(childNode, resource);
                if (outNode != null)
                {
                    return outNode;
                }
            }

            return null;
        }
Exemple #18
0
        public Node GetParentFolderTreeNode(Node rootNode, ref Node folderNode, Resource resource)
        {
            if (rootNode.IsFolder)
            {
                folderNode = rootNode;
            }
            else if (rootNode.ResourceId == resource.Id)
            {
                return rootNode;
            }

            foreach (Node childNode in rootNode.ChildNodes)
            {
                Node outNode = GetParentFolderTreeNode(childNode, ref folderNode, resource);
                if (outNode != null)
                {
                    return outNode;
                }
            }

            return null;
        }
Exemple #19
0
        public bool DeleteResource(Resource resource)
        {
            foreach (Resource iResource in Resources)
            {
                iResource.IdDependencies.Remove(resource.Id);
                iResource.IdOutputs.Remove(resource.Id);
            }

            Resources.Remove(resource);

            return false;
        }
Exemple #20
0
 public bool AddResource(Resource resource)
 {
     Resources.Add(resource);
     return true;
 }
Exemple #21
0
        private void addExistingResourceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!IsFolderNode(TreeViewSelectedNode))
            {
                return;
            }

            OpenFileDialog openFile = new OpenFileDialog();

            string fileLocation = App.Controller.UserConfig.AddExistingResourceFullPath;

            string filterString = "";

            filterString = "All resources (*.*)|*.*";

            List<PhactoryHost.EditorPlugin> pluginEditors = App.Controller.PluginManager.GetPluginEditors();
            foreach (PhactoryHost.EditorPlugin pluginEditor in pluginEditors)
            {
                foreach (PhactoryHost.PluginExtension pluginExtension in pluginEditor.GetSupportedExtensions())
                {
                    filterString += "|" + pluginExtension.GetDescription() + "|" + "*" + pluginExtension.GetName();
                }
            }

            openFile.InitialDirectory = fileLocation;
            openFile.Filter = filterString;
            openFile.FilterIndex = 1;
            openFile.Multiselect = true;
            openFile.RestoreDirectory = true;
            openFile.Title = "Add existing resource";

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                TreeNode createdNode = null;
                int createdNodeCount = 0;

                List<Resource> addedResources = new List<Resource>();

                App.Controller.Log.Append("Adding existing resources..");

                foreach (String srcFilename in openFile.FileNames)
                {
                    FileInfo srcFileInfo = new FileInfo(srcFilename);

                    string destFilename = App.Controller.UserConfig.ResourcePath + srcFileInfo.Name;

                    App.Controller.UserConfig.AddExistingResourceFullPath = srcFileInfo.Directory.FullName;

                    if (Path.GetFullPath(srcFileInfo.FullName) != Path.GetFullPath(destFilename))
                    {
                        bool addResource = true;

                        if (File.Exists(destFilename))
                        {
                            if (MessageBox.Show(destFilename + " already exists !\n\nReplace content?", "Resource exists !", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                File.Delete(destFilename);
                            }
                            else
                            {
                                addResource = false;
                            }
                        }

                        if (addResource)
                        {
                            string relativePath = Helper.StringHelper.MakeRelativePath(destFilename);

                            PhactoryHost.Database.Resource resource = new PhactoryHost.Database.Resource();
                            resource.Id = App.Controller.Entities.CreateNewResourceId();
                            resource.DisplayName = new FileInfo(destFilename).Name;
                            resource.RelativePath = relativePath;
                            App.Controller.Entities.AddResource(resource);

                            App.Controller.CreateNewResource(resource);

                            File.Delete(destFilename);
                            File.Copy(srcFileInfo.FullName, destFilename);

                            Node childTreeNode = new Node();
                            childTreeNode.IsFolder = false;
                            childTreeNode.ResourceId = resource.Id;

                            Node treeNode = TreeViewSelectedNode.Tag as Node;
                            treeNode.ChildNodes.Add(childTreeNode);

                            App.Controller.SaveProject();

                            TreeViewSelectedNode.Nodes.Clear();
                            CreateTreeView(TreeViewSelectedNode, treeNode);

                            createdNode = GetDocTreeNode(TreeViewSelectedNode, childTreeNode);
                            createdNodeCount++;

                            addedResources.Add(resource);
                            App.Controller.InsertFileMostRecentUsed(destFilename);
                        }
                    }
                }

                if (createdNodeCount == 1)
                {
                    treeView.SelectedNode = createdNode;
                    TreeViewSelectedNode = createdNode;
                }
                else
                {
                    treeView.SelectedNode.Expand();
                }

                App.Controller.Log.Append("Refreshing dependencies..");
                foreach (Resource addedResource in addedResources)
                {
                    App.Controller.Build.UpdateDependenciesRecursive(addedResource);
                }

                App.Controller.Log.Append("" + addedResources.Count + " resources imported");
            }
        }
Exemple #22
0
 public bool CreateEmptyResource(PhactoryHost.Database.Resource resource)
 {
     return(Host.XMLWrite(Host.GetFileInfo(resource).FullName, new Document.Document()));
 }
Exemple #23
0
 public void OnResourceDeleted(PhactoryHost.Database.Resource resource)
 {
 }
Exemple #24
0
        public void RefreshViewTitle(PhactoryHost.Database.Resource resource)
        {
            View.View view = viewBinding[resource].View;

            view.RefreshTitle();
        }
Exemple #25
0
        private void SetTreeViewResource(TreeNode uiNode, PhactoryHost.Database.Resource resource)
        {
            App.Controller.View.AppDoEvents();

            uiNode.ContextMenuStrip = contextMenuStripResource;

            string extension = resource.GetFileExtension();
            string key;

            switch (extension)
            {
            case ".s": key = "FileASM"; break;

            case ".asm": key = "FileASM"; break;

            case ".cxx": key = "FileC"; break;

            case ".c": key = "FileC"; break;

            case ".h": key = "FileH"; break;

            case ".cpp": key = "FileCPP"; break;

            case ".txt": key = "FileTXT"; break;

            case ".cpcbigfile":
            case ".cpcbin2c":
            case ".cpcbitmap":
            case ".cpccloud":
            case ".cpcdsk":
            case ".cpcpack":
            case ".cpctext":
                key = "FileProp"; break;

            case ".bmp": key = "VSProject_imagefile"; break;

            case ".bin":
            case ".dsk":
            case ".raw":
            case ".packed":
            case ".bmp.packed":
            case ".bin.packed": key = "VSObject_Type"; break;

            default:
                key = "FileGeneric"; break;
            }

            uiNode.ImageKey         = key;
            uiNode.SelectedImageKey = key;

            if (App.Controller.Entities.StartupResourceId == resource.Id)
            {
                uiNode.NodeFont = boldFont;

                startupNode = uiNode;
            }
            else
            {
                if (App.Controller.Entities.IsOutput(resource))
                {
                    uiNode.ImageKey         = "VSProject_generatedfile";
                    uiNode.SelectedImageKey = "VSProject_generatedfile";

                    uiNode.NodeFont = italicFont;
                }
                else
                {
                    uiNode.NodeFont = itemFont;
                }
            }
        }
Exemple #26
0
 public void OnResourceRenamed(PhactoryHost.Database.Resource resource)
 {
 }
Exemple #27
0
        private void addExistingResourceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!IsFolderNode(TreeViewSelectedNode))
            {
                return;
            }

            OpenFileDialog openFile = new OpenFileDialog();

            string fileLocation = App.Controller.UserConfig.AddExistingResourceFullPath;

            string filterString = "";

            filterString = "All resources (*.*)|*.*";

            List <PhactoryHost.EditorPlugin> pluginEditors = App.Controller.PluginManager.GetPluginEditors();

            foreach (PhactoryHost.EditorPlugin pluginEditor in pluginEditors)
            {
                foreach (PhactoryHost.PluginExtension pluginExtension in pluginEditor.GetSupportedExtensions())
                {
                    filterString += "|" + pluginExtension.GetDescription() + "|" + "*" + pluginExtension.GetName();
                }
            }

            openFile.InitialDirectory = fileLocation;
            openFile.Filter           = filterString;
            openFile.FilterIndex      = 1;
            openFile.Multiselect      = true;
            openFile.RestoreDirectory = true;
            openFile.Title            = "Add existing resource";

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                TreeNode createdNode      = null;
                int      createdNodeCount = 0;

                List <Resource> addedResources = new List <Resource>();

                App.Controller.Log.Append("Adding existing resources..");

                foreach (String srcFilename in openFile.FileNames)
                {
                    FileInfo srcFileInfo = new FileInfo(srcFilename);

                    string destFilename = App.Controller.UserConfig.ResourcePath + srcFileInfo.Name;

                    App.Controller.UserConfig.AddExistingResourceFullPath = srcFileInfo.Directory.FullName;

                    if (Path.GetFullPath(srcFileInfo.FullName) != Path.GetFullPath(destFilename))
                    {
                        bool addResource = true;

                        if (File.Exists(destFilename))
                        {
                            if (MessageBox.Show(destFilename + " already exists !\n\nReplace content?", "Resource exists !", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                File.Delete(destFilename);
                            }
                            else
                            {
                                addResource = false;
                            }
                        }

                        if (addResource)
                        {
                            string relativePath = Helper.StringHelper.MakeRelativePath(destFilename);

                            PhactoryHost.Database.Resource resource = new PhactoryHost.Database.Resource();
                            resource.Id           = App.Controller.Entities.CreateNewResourceId();
                            resource.DisplayName  = new FileInfo(destFilename).Name;
                            resource.RelativePath = relativePath;
                            App.Controller.Entities.AddResource(resource);

                            App.Controller.CreateNewResource(resource);

                            File.Delete(destFilename);
                            File.Copy(srcFileInfo.FullName, destFilename);

                            Node childTreeNode = new Node();
                            childTreeNode.IsFolder   = false;
                            childTreeNode.ResourceId = resource.Id;

                            Node treeNode = TreeViewSelectedNode.Tag as Node;
                            treeNode.ChildNodes.Add(childTreeNode);

                            App.Controller.SaveProject();

                            TreeViewSelectedNode.Nodes.Clear();
                            CreateTreeView(TreeViewSelectedNode, treeNode);

                            createdNode = GetDocTreeNode(TreeViewSelectedNode, childTreeNode);
                            createdNodeCount++;

                            addedResources.Add(resource);
                            App.Controller.InsertFileMostRecentUsed(destFilename);
                        }
                    }
                }

                if (createdNodeCount == 1)
                {
                    treeView.SelectedNode = createdNode;
                    TreeViewSelectedNode  = createdNode;
                }
                else
                {
                    treeView.SelectedNode.Expand();
                }

                App.Controller.Log.Append("Refreshing dependencies..");
                foreach (Resource addedResource in addedResources)
                {
                    App.Controller.Build.UpdateDependenciesRecursive(addedResource);
                }

                App.Controller.Log.Append("" + addedResources.Count + " resources imported");
            }
        }
Exemple #28
0
 public void SetLine(PhactoryHost.Database.Resource resource, int line)
 {
 }
Exemple #29
0
        private void WriteIdFile(PhactoryHost.Database.Resource resource)
        {
            var destFilename = Host.GetFileInfo(resource).FullName + ".h";
            App.Controller.UserConfig.AddExistingResourceFullPath = destFilename;

            string relativePath = StringHelper.MakeRelativePath(destFilename);

            PhactoryHost.Database.Resource idResource = Host.GuessResource(new FileInfo(destFilename));
            if (idResource == null)
            {
                idResource = new PhactoryHost.Database.Resource();
                idResource.Id = App.Controller.Entities.CreateNewResourceId();
                idResource.DisplayName = new FileInfo(destFilename).Name;
                idResource.RelativePath = relativePath;
                App.Controller.Entities.AddResource(idResource);

                App.Controller.CreateNewResource(idResource);

                var project = Host.GetEntities();

                Node folderNode = null;
                project.GetParentFolderTreeNode(project.TreeNode, ref folderNode, resource);
                if ( folderNode != null )
                {
                    Node childTreeNode = new Node();
                    childTreeNode.IsFolder = false;
                    childTreeNode.ResourceId = idResource.Id;

                    folderNode.ChildNodes.Add(childTreeNode);
                }

                App.Controller.SaveProject();
                Host.RefreshDB();
            }

            File.Delete(destFilename);
            WriteIdFileContent(resource, destFilename);

            Host.Log(idResource.DisplayName + " written");
        }
Exemple #30
0
        public void SelectResource(Resource resource)
        {
            RefreshDB();

            TreeNodeCollection nodes = this.treeView.Nodes;
            foreach (TreeNode node in nodes)
            {
                SelectResourceRecursive(node, resource);
            }
        }