예제 #1
0
        /// <summary>
        /// Open a file in a document window
        /// </summary>
        /// <param name="newFile">Open the file as a new file</param>
        /// <param name="openWith">Use a dialog box to determine which editor to use</param>
        /// <param name="logicalView">In MultiView case determines view to be activated by IVsMultiViewDocumentView. For a list of logical view GUIDS, see constants starting with LOGVIEWID_ defined in NativeMethods class</param>
        /// <param name="docDataExisting">IntPtr to the IUnknown interface of the existing document data object</param>
        /// <param name="windowFrame">A reference to the window frame that is mapped to the file</param>
        /// <param name="windowFrameAction">Determine the UI action on the document window</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
        public override int Open(bool newFile, bool openWith, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction)
        {
            windowFrame = null;
            Guid      editorType = VSConstants.LOGVIEWID_Primary;
            string    fullPath   = this.GetFullPathForDocument();
            XFileType type       = XFileTypeHelpers.GetFileType(fullPath);

            switch (type)
            {
            case XFileType.SourceCode:
            case XFileType.Header:
            case XFileType.PreprocessorOutput:
            case XFileType.NativeResource:
            case XFileType.License:
            case XFileType.Template:
                editorType = GuidStrings.guidSourcecodeEditorFactory;
                break;

            case XFileType.VOForm:
            case XFileType.VOMenu:
            case XFileType.VODBServer:
            case XFileType.VOFieldSpec:
                // the primary view is the normal editor which is defined with an attribute on the package
                // we only have to tell it what to do when we want to see the code.
                if (logicalView == VSConstants.LOGVIEWID.Code_guid)
                {
                    editorType = GuidStrings.guidVSXmlEditor;
                }
                break;
            }
            return(base.Open(newFile, openWith, 0, ref editorType, null, ref logicalView, docDataExisting, out windowFrame, windowFrameAction));
        }
예제 #2
0
        protected override bool RenameDocument(string oldName, string newName, out HierarchyNode newNodeOut)
        {
            var result = base.RenameDocument(oldName, newName, out newNodeOut);

            if (result)
            {
                XSharpProjectNode project = ProjectMgr as XSharpProjectNode;
                if (project != null)
                {
                    project.ProjectModel.RemoveFile(oldName);
                    project.ProjectModel.AddFile(newName);
                    project.ProjectModel.Walk();
                }
                _fileType = XFileTypeHelpers.GetFileType(newName);
            }
            return(result);
        }
예제 #3
0
        internal static bool IsXSharpDocument(this ITextDocumentFactoryService factory, ITextBuffer buffer)
        {
            string path = "";

            if (buffer.Properties.ContainsProperty(typeof(XFile)))
            {
                return(buffer.GetFile() != null);
            }
            // When not found then locate the file in the XSolution by its name
            if (factory != null)
            {
                ITextDocument doc = null;
                if (factory.TryGetTextDocument(buffer, out doc))
                {
                    path = doc.FilePath;
                }
            }
            // Find and attach the X# document when we have it, or a null to indicate that we have searched
            // and not found it
            var file = XSolution.FindFile(path);

            if (file == null)
            {
                var type = XFileTypeHelpers.GetFileType(path);
                switch (type)
                {
                case XFileType.SourceCode:
                case XFileType.Header:
                    file = XSolution.AddOrphan(path);
                    break;

                default:
                    if (type.IsVOBinary())
                    {
                        file = XSolution.AddOrphan(path);
                    }
                    break;
                }
            }
            if (file != null)
            {
                file.Interactive = true;
                buffer.Properties.AddProperty(typeof(XFile), file);
            }
            return(file != null);
        }
예제 #4
0
        static public int ImageIndex(string fileName)
        {
            int ret;

            switch (XFileTypeHelpers.GetFileType(fileName))
            {
            case XFileType.SourceCode:
                ret = XSharpImageListIndex.Source + XProjectNode.imageOffset;
                break;

            case XFileType.Header:
            case XFileType.PreprocessorOutput:
                ret = XSharpImageListIndex.Source + XProjectNode.imageOffset;
                break;

            case XFileType.VOForm:
                ret = XSharpImageListIndex.Form + XProjectNode.imageOffset;
                break;

            case XFileType.VOMenu:
                ret = XSharpImageListIndex.Menu + XProjectNode.imageOffset;
                break;

            case XFileType.VODBServer:
                ret = XSharpImageListIndex.Server + XProjectNode.imageOffset;
                break;

            case XFileType.VOFieldSpec:
                ret = XSharpImageListIndex.FieldSpec + XProjectNode.imageOffset;
                break;

            default:
                ret = -1;
                break;
            }
            return(ret);
        }
예제 #5
0
 public static string GetProjectItemType(string url)
 {
     return(GetProjectItemType(XFileTypeHelpers.GetFileType(url)));
 }
예제 #6
0
 public static string GetItemType(string fileName)
 {
     return(GetProjectItemType(XFileTypeHelpers.GetFileType(fileName)));
 }