private void SetText(string text) { try { FrameXmlDesignerLoader.ValidateOnWrite(text); } catch (Exception ex) { // TODO: show error in the Error List Trace.WriteLine(ex); } int endLine, endCol; textLines.GetLastLineIndex(out endLine, out endCol); int len = (text == null) ? 0 : text.Length; //fix location of the string IntPtr pText = Marshal.StringToCoTaskMemAuto(text); try { textLines.ReplaceLines(0, 0, endLine, endCol, pText, len, null); } finally { Marshal.FreeCoTaskMem(pText); } }
private IntPtr CreateDesignerView(IVsHierarchy hierarchy, uint itemid, IVsTextLines textLines, ref string editorCaption, ref Guid cmdUI, string documentMoniker) { // Request the Designer Service IVSMDDesignerService designerService = (IVSMDDesignerService)GetService(typeof(IVSMDDesignerService)); try { // Get the service provider IOleServiceProvider provider = serviceProvider.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider; // Create loader for the designer FrameXmlDesignerLoader designerLoader = new FrameXmlDesignerLoader(textLines, documentMoniker, itemid); // Create the designer using the provider and the loader IVSMDDesigner designer = designerService.CreateDesigner(provider, designerLoader); #if !HIDE_FRAME_XML_PANE // Retrieve the design surface DesignSurface designSurface = (DesignSurface)designer; // Create pane with this surface FrameXmlPane frameXmlPane = new FrameXmlPane(designSurface); designerLoader.InitializeFrameXmlPane(frameXmlPane); // Get command guid from designer cmdUI = frameXmlPane.CommandGuid; editorCaption = " [Design]"; // Return FrameXmlPane return(Marshal.GetIUnknownForObject(frameXmlPane)); #else object view = designer.View; cmdUI = designer.CommandGuid; editorCaption = " [Design]"; designerLoader.InitializeFrameXmlPane(null); // Return view return(Marshal.GetIUnknownForObject(view)); #endif } catch (Exception ex) { // Just rethrow for now throw; } }