コード例 #1
0
ファイル: EditorFactory.cs プロジェクト: philstopford/Eto
        public int ChooseEditorFactory(string pszMkDocument, IVsHierarchy pHier, uint itemid, IntPtr punkDocDataExisting, ref Guid rguidLogicalView, out Guid pguidEditorTypeActual, out Guid pguidLogicalViewActual)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            pguidEditorTypeActual  = Constants.EtoPreviewEditorFactory_guid;
            pguidLogicalViewActual = VSConstants.LOGVIEWID.Designer_guid;
            if (!BuilderInfo.Supports(pszMkDocument))
            {
                return(VSConstants.VS_E_UNSUPPORTEDFORMAT);
            }

            rguidLogicalView = VSConstants.LOGVIEWID.Designer_guid;
            object prjItemObject;
            var    projectItemId = VSConstants.VSITEMID_ROOT;

            pHier.GetProperty(projectItemId, (int)__VSHPROPID.VSHPROPID_ExtObject, out prjItemObject);
            var proj = prjItemObject as EnvDTE.Project;

            // Get or open text buffer
            var textBuffer = GetTextBuffer(punkDocDataExisting, pszMkDocument, ToVsProject(proj));

            if (textBuffer == null)
            {
                return(VSConstants.VS_E_INCOMPATIBLEDOCDATA);
            }



            return(VSConstants.S_OK);
        }
コード例 #2
0
        public int CreateEditorInstance(
            uint grfCreateDoc,
            string pszMkDocument,
            string pszPhysicalView,
            IVsHierarchy pvHier,
            uint itemid,
            System.IntPtr punkDocDataExisting,
            out System.IntPtr ppunkDocView,
            out System.IntPtr ppunkDocData,
            out string pbstrEditorCaption,
            out Guid pguidCmdUI,
            out int pgrfCDW)
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} CreateEditorInstace()", this.ToString()));

            // Initialize to null
            ppunkDocView       = IntPtr.Zero;
            ppunkDocData       = IntPtr.Zero;
            pguidCmdUI         = Constants.EtoPreviewEditorFactory_guid;
            pgrfCDW            = 0;
            pbstrEditorCaption = null;


            if (!BuilderInfo.Supports(pszMkDocument))
            {
                return(VSConstants.VS_E_UNSUPPORTEDFORMAT);
            }

            // Validate inputs
            if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0)
            {
                return(VSConstants.E_INVALIDARG);
            }

            // Get or open text buffer
            var textBuffer = GetTextBuffer(punkDocDataExisting, pszMkDocument);

            if (textBuffer == null)
            {
                return(VSConstants.VS_E_INCOMPATIBLEDOCDATA);
            }

            if (punkDocDataExisting != IntPtr.Zero)
            {
                ppunkDocData = punkDocDataExisting;
                Marshal.AddRef(ppunkDocData);
            }
            else
            {
                ppunkDocData = Marshal.GetIUnknownForObject(textBuffer);
            }

            // Create the Document (editor)
            var editor = new EtoPreviewPane(editorPackage, pszMkDocument, textBuffer);

            ppunkDocView = Marshal.GetIUnknownForObject(editor);
            //pbstrEditorCaption = " [Preview]";
            return(VSConstants.S_OK);
        }
コード例 #3
0
        public int CreateEditorInstance(
            uint grfCreateDoc,
            string pszMkDocument,
            string pszPhysicalView,
            IVsHierarchy pvHier,
            uint itemid,
            System.IntPtr punkDocDataExisting,
            out System.IntPtr ppunkDocView,
            out System.IntPtr ppunkDocData,
            out string pbstrEditorCaption,
            out Guid pguidCmdUI,
            out int pgrfCDW)
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} CreateEditorInstace()", this.ToString()));

            // Initialize to null
            ppunkDocView       = IntPtr.Zero;
            ppunkDocData       = IntPtr.Zero;
            pguidCmdUI         = Constants.EtoPreviewEditorFactory_guid;
            pgrfCDW            = 0;
            pbstrEditorCaption = null;


            if (!BuilderInfo.Supports(pszMkDocument))
            {
                return(VSConstants.VS_E_UNSUPPORTEDFORMAT);
            }

            // Validate inputs
            if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0)
            {
                return(VSConstants.E_INVALIDARG);
            }

            object prjItemObject;
            var    projectItemId = VSConstants.VSITEMID_ROOT;

            pvHier.GetProperty(projectItemId, (int)__VSHPROPID.VSHPROPID_ExtObject, out prjItemObject);
            var proj = prjItemObject as EnvDTE.Project;

            // Get or open text buffer
            var textBuffer = GetTextBuffer(punkDocDataExisting, pszMkDocument, ToVsProject(proj));

            if (textBuffer == null)
            {
                return(VSConstants.VS_E_INCOMPATIBLEDOCDATA);
            }

            if (punkDocDataExisting != IntPtr.Zero)
            {
                ppunkDocData = punkDocDataExisting;
                Marshal.AddRef(ppunkDocData);
            }
            else
            {
                ppunkDocData = Marshal.GetIUnknownForObject(textBuffer);
            }


            var outputFile = GetAssemblyPath(proj);
            var references = GetReferences(proj).ToList();
            //var outputDir = Path.GetDirectoryName(outputFile);

            // Create the Document (editor)
            var editor = new EtoPreviewPane(editorPackage, pszMkDocument, textBuffer, outputFile, references);

            ppunkDocView = Marshal.GetIUnknownForObject(editor);
            //pbstrEditorCaption = " [Preview]";
            return(VSConstants.S_OK);
        }