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) { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} CreateEditorInstace()", this.ToString())); // Initialize to null ppunkDocView = IntPtr.Zero; ppunkDocData = IntPtr.Zero; pguidCmdUI = GuidList.guidEditorFactory; pgrfCDW = 0; pbstrEditorCaption = null; // Validate inputs if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0) { return(VSConstants.E_INVALIDARG); } if (punkDocDataExisting != IntPtr.Zero) { return(VSConstants.VS_E_INCOMPATIBLEDOCDATA); } // Create the Document (editor) var perfWin = _editorPackage.ShowPerformanceExplorer(); ProfilingTarget target; try { var settings = new XmlReaderSettings { XmlResolver = null }; using (var fs = new FileStream(pszMkDocument, FileMode.Open)) using (var reader = XmlReader.Create(fs, settings)) { target = (ProfilingTarget)ProfilingTarget.Serializer.Deserialize(reader); } } catch (IOException e) { MessageBox.Show(Strings.FailedToOpenPerformanceSessionFile.FormatUI(pszMkDocument, e.Message), Strings.ProductTitle); return(VSConstants.E_FAIL); } catch (InvalidOperationException e) { MessageBox.Show(Strings.FailedToReadPerformanceSession.FormatUI(pszMkDocument, e.Message), Strings.ProductTitle); return(VSConstants.E_FAIL); } perfWin.Sessions.OpenTarget( target, pszMkDocument ); pbstrEditorCaption = ""; return(VSConstants.S_OK); }
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) { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} CreateEditorInstace()", this.ToString())); // Initialize to null ppunkDocView = IntPtr.Zero; ppunkDocData = IntPtr.Zero; pguidCmdUI = GuidList.guidEditorFactory; pgrfCDW = 0; pbstrEditorCaption = null; // Validate inputs if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0) { return(VSConstants.E_INVALIDARG); } if (punkDocDataExisting != IntPtr.Zero) { return(VSConstants.VS_E_INCOMPATIBLEDOCDATA); } // Create the Document (editor) var perfWin = _editorPackage.ShowPerformanceExplorer(); ProfilingTarget target; try { using (var fs = new FileStream(pszMkDocument, FileMode.Open)) { target = (ProfilingTarget)ProfilingTarget.Serializer.Deserialize(fs); fs.Close(); } } catch (IOException e) { MessageBox.Show("Failed to open file {0}\r\n\r\n" + e.Message, "Python Tools for Visual Studio"); return(VSConstants.E_FAIL); } catch (InvalidOperationException e) { MessageBox.Show("Failed to read performance session {0}\r\n\r\n" + e.Message, "Python Tools for Visual Studio"); return(VSConstants.E_FAIL); } perfWin.Sessions.OpenTarget( target, pszMkDocument ); pbstrEditorCaption = ""; return(VSConstants.S_OK); }