Ejemplo n.º 1
0
        /// <summary>
        /// Create an instance of the codeWindowHost
        /// </summary>
        /// <param name="grfCreateDoc"></param>
        /// <param name="fileToLoad"></param>
        /// <param name="pszPhysicalView"></param>
        /// <param name="pvHier"></param>
        /// <param name="itemid"></param>
        /// <param name="punkDocDataExisting"></param>
        /// <param name="ppunkDocView"></param>
        /// <param name="ppunkDocData"></param>
        /// <param name="pbstrEditorCaption"></param>
        /// <param name="pguidCmdUI"></param>
        /// <param name="pgrfCDW"></param>
        /// <returns></returns>
        public int CreateEditorInstance(
            uint grfCreateDoc,
            string pszMkDocument,
            string pszPhysicalView,
            IVsHierarchy pvHier,
            uint itemid,
            IntPtr punkDocDataExisting,
            out IntPtr ppunkDocView,
            out IntPtr ppunkDocData,
            out string pbstrEditorCaption,
            out Guid pguidCmdUI,
            out int pgrfCDW)
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} CreateEditorInstance()", ToString()));

            // Initialize to null
            ppunkDocView = IntPtr.Zero;
            ppunkDocData = IntPtr.Zero;
            pguidCmdUI = GuidList.snippetEditorFactory;
            pgrfCDW = 0;
            pbstrEditorCaption = null;

            // Validate inputs
            if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0)
            {
                Debug.Assert(false, "Only Open or Silent is valid");
                return VSConstants.E_INVALIDARG;
            }
            if (punkDocDataExisting != IntPtr.Zero)
            {
                return VSConstants.VS_E_INCOMPATIBLEDOCDATA;
            }

            // Create the Document (codeWindowHost)
            SnippetEditor snipEditor = new SnippetEditor(editorPackage);
            ppunkDocView = Marshal.GetIUnknownForObject(snipEditor);
            ppunkDocData = Marshal.GetIUnknownForObject(snipEditor);
            pbstrEditorCaption = String.Empty;

            return VSConstants.S_OK;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create the command filter with a reference to the snippet codeWindowHost so that it can
 /// cause the appropriate actions to occur like showing the context menu or running a command
 /// </summary>
 /// <param name="codeWindowHost"></param>
 public CommandFilter(SnippetEditor editor)
 {
     snippetEditor = editor;
 }