Ejemplo n.º 1
0
        public virtual int AddNewScript(HierarchyNode parent)
        {
            string new_name = "NewScript";
            int marker = 1;
            string name = new_name + marker.ToString() + ".ctl";
            while (!Utilities.IsNameUniqueInFirstLevelOfNode(this, name) && marker < 100)
            {
                ++marker;
                name = new_name + marker.ToString() + ".ctl";
            }
            if (marker < 100)
            {
                System.IO.File.Create(ProjectMgr.ProjectFolder + "\\" + name);
                CogaenEditFile file = new CogaenEditFile(name, this.ProjectMgr, null);
                parent.AddChild(file);
                IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ProjectMgr.Site, SolutionExplorer);
                // This happens in the context of adding a new folder.
                // Since we are already in solution explorer, it is extremely unlikely that we get a null return.
                // If we do, the newly created folder will not be selected, and we will not attempt the rename
                // command (since we are selecting the wrong item).
                if (uiWindow != null)
                {
                    // we need to get into label edit mode now...
                    // so first select the new guy...
                    int result = uiWindow.ExpandItem(this.ProjectMgr, file.ID, EXPANDFLAGS.EXPF_SelectItem);
                    ErrorHandler.ThrowOnFailure(result);
                    // them post the rename command to the shell. Folder verification and creation will
                    // happen in the setlabel code...
                    IVsUIShell shell = this.ProjectMgr.Site.GetService(typeof(SVsUIShell)) as IVsUIShell;

                    Debug.Assert(shell != null, "Could not get the ui shell from the project");
                    if (shell == null)
                    {
                        return VSConstants.E_FAIL;
                    }

                    object dummy = null;
                    Guid cmdGroup = VsMenus.guidStandardCommandSet97;
                    ErrorHandler.ThrowOnFailure(shell.PostExecCommand(ref cmdGroup, (uint)VsCommands.Rename, 0, ref dummy));
                }
                return VSConstants.S_OK;
            }
            else
                return VSConstants.E_FAIL;
        }
Ejemplo n.º 2
0
        private void saveProjectTemplate(XmlDocument xmlDoc, XmlElement elementNode, CogaenEditFile template)
        {
            XmlElement file = xmlDoc.CreateElement("File");
            XmlAttribute filename = xmlDoc.CreateAttribute("Filename");
            filename.Value = template.Caption;
            file.Attributes.Append(filename);

            //XmlAttribute scriptname = xmlDoc.CreateAttribute("Script");
            //scriptname.Value = template.Script.Name;
            //file.Attributes.Append(scriptname);

            elementNode.AppendChild(file);
        }
Ejemplo n.º 3
0
 public int OpenPreloadedDocument(IObjectBuilder objectBuilder, string filename, CogaenEditFile file)
 {
     EditorControl.ObjectBuilderControl.DataContext = objectBuilder;
     this.fileName = filename;
     this.openFile = file;
     return VSConstants.S_OK;
 }