private void OnContentRendered(object sender, EventArgs eventArgs) { try { // NOTE: this works only when the document as been loaded IOleServiceProvider sp = webBrowser.Document as IOleServiceProvider; if (sp != null) { Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046"); Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E"); const int OLECMDID_PRINT = 6; const int OLECMDEXECOPT_DONTPROMPTUSER = 2; dynamic wb; // will be of IWebBrowser2 type, but dynamic is cool sp.QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, out wb); if (wb != null) { // note: this will send to the default printer, if any wb.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, null, null); } } //Remove secret customer info from disk: //File.Delete(path); } catch (Exception ex) { MessageBox.Show("Printing failed. Error: " + ex.Message); } Close(); }
/// <internalonly/> /// <summary> /// Set the standard designer which is responsible for all base events. /// </summary> /// <remarks> /// Called in readystate "complete" state and before external event handling. /// </remarks> private void SetEditDesigner() { // prepare add designer methods IOleServiceProvider isp = (IOleServiceProvider)htmlDoc; if (isp != null && htmlDoc.body != null) { IntPtr ppv = IntPtr.Zero; try { Guid IHtmlEditServicesGuid = new Guid("3050f663-98b5-11cf-bb82-00aa00bdce0b"); Guid SHtmlEditServicesGuid = new Guid("3050f7f9-98b5-11cf-bb82-00aa00bdce0b"); isp.QueryService(ref SHtmlEditServicesGuid, ref IHtmlEditServicesGuid, out ppv); MsHtmlWrap.IHTMLEditServices es = Marshal.GetObjectForIUnknown(ppv) as MsHtmlWrap.IHTMLEditServices; es.AddDesigner(this); } catch { } finally { Marshal.Release(ppv); } } }
/// <summary> /// <para>Provides the site's IUnknown pointer to the object. The object should hold onto this pointer, calling IUnknown::AddRef in doing so. If the object already has a site, it should call that existing site's IUnknown::Release, save the new site pointer, and call the new site's IUnknown::AddRef.</para> /// </summary> /// <param name="pUnkSite"> /// <para>Pointer to the IUnknown interface pointer of the site managing this object. If NULL, the object should call IUnknown::Release on any existing site at which point the object no longer knows its site.</para> /// </param> public void SetSite(object pUnkSite) { if (pUnkSite is IOleServiceProvider) { oleServiceProvider = (IOleServiceProvider)pUnkSite; } }
public VsInteractiveWindowEditorFactoryService(IVsEditorAdaptersFactoryService adaptersFactory, IContentTypeRegistryService contentTypeRegistry, [ImportMany] IEnumerable <Lazy <IVsInteractiveWindowOleCommandTargetProvider, ContentTypeMetadata> > oleCommandTargetProviders) { _adapterFactory = adaptersFactory; _provider = (IOleServiceProvider)InteractiveWindowPackage.GetGlobalService(typeof(IOleServiceProvider)); _contentTypeRegistry = contentTypeRegistry; _oleCommandTargetProviders = oleCommandTargetProviders; }
/// <summary> /// Sets the site object we will be using to resolve services. /// </summary> /// <param name='pUnkSite'> /// The site we will use. This site will only be /// used if it also implements IOleServiceProvider. /// </param> /// <seealso cref='IObjectWithSite'/> void IObjectWithSite.SetSite(object pUnkSite) { if (pUnkSite is IOleServiceProvider) { serviceProvider = (IOleServiceProvider)pUnkSite; } }
public static void SetSilent(WebBrowser browser, bool silent) { if (browser == null) { throw new ArgumentNullException("browser"); } // get an IWebBrowser2 from the document IOleServiceProvider sp = browser.Document as IOleServiceProvider; if (sp != null) { Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046"); Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E"); object webBrowser; sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out webBrowser); if (webBrowser != null) { webBrowser.GetType() .InvokeMember("Silent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.PutDispProperty, null, webBrowser, new object[] { silent }); } } }
/// <summary> /// Gives this class a chance to free its references. /// </summary> public virtual void Dispose() { if (serviceProvider != null) { serviceProvider = null; } }
/// <summary> /// gives this class a chance to free its references. /// </summary> public virtual void Dispose() { if (serviceProvider != null) { serviceProvider = null; } }
public VsInteractiveWindowEditorFactoryService(IVsEditorAdaptersFactoryService adaptersFactory, IContentTypeRegistryService contentTypeRegistry, [ImportMany]IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, ContentTypeMetadata>> oleCommandTargetProviders) { _adapterFactory = adaptersFactory; _provider = (IOleServiceProvider)InteractiveWindowPackage.GetGlobalService(typeof(IOleServiceProvider)); _contentTypeRegistry = contentTypeRegistry; _oleCommandTargetProviders = oleCommandTargetProviders; }
/// <summary> /// <para>Creates a new ServiceProvider object and uses the given interface to resolve services.</para> /// </summary> /// <param name="oleServiceProvider"> /// <para>The IOleServiceProvider interface to use.</para> /// </param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="oleServiceProvider"/> is a null reference (Nothing in Visual Basic).</para> /// </exception> public ServiceProvider(IOleServiceProvider oleServiceProvider) { if (null == oleServiceProvider) { throw new ArgumentNullException("oleServiceProvider"); } this.oleServiceProvider = oleServiceProvider; }
/// <summary> /// <para>Creates a new ServiceProvider object and uses the given interface to resolve services.</para> /// </summary> /// <param name="oleServiceProvider"> /// <para>The IOleServiceProvider interface to use.</para> /// </param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="oleServiceProvider"/> is a null reference (Nothing in Visual Basic).</para> /// </exception> public ServiceProvider(IOleServiceProvider oleServiceProvider) { if (null == oleServiceProvider) { throw new ArgumentNullException("oleServiceProvider"); } this.oleServiceProvider = oleServiceProvider; }
/// <summary> /// <para>Releases unmanaged resources and performs other cleanup operations before the <see cref="ServiceContainer"/> is reclaimed by garbage collection. </para> /// </summary> /// <param name="disposing"><para><c>true</c> if we are disposing; otherwise, <c>false</c> which means the call is coming from our finalizer.</para></param> protected virtual void Dispose(bool disposing) { if (disposing) { if (oleServiceProvider != null) { oleServiceProvider = null; } } }
public static object QueryService(this IOleServiceProvider source, Guid serviceId, Guid requestedIID) { try { object obj; source.QueryService(ref serviceId, ref requestedIID, out obj); return(obj); } catch (COMException) { return(null); } }
private CommandBar FindCommandBar(Guid guidCmdGroup, uint menuID) { // Retrieve IVsProfferComands via DTE's IOleServiceProvider interface IOleServiceProvider sp = (IOleServiceProvider)Connect._applicationObject; Guid guidSvc = typeof(IVsProfferCommands).GUID; Object objService; if (sp.QueryService(ref guidSvc, ref guidSvc, out objService) == 0) { IVsProfferCommands vsProfferCmds = (IVsProfferCommands)objService; return(vsProfferCmds.FindCommandBar(IntPtr.Zero, ref guidCmdGroup, menuID) as CommandBar); } return(null); }
/// <summary> /// http://blogs.msdn.com/dr._ex/archive/2007/04/17/using-ivsproffercommands-to-retrieve-a-visual-studio-commandbar.aspx /// </summary> /// <param name="guidCmdGroup"></param> /// <param name="menuID"></param> /// <returns></returns> private CommandBar GetCommandBar(Guid guidCmdGroup, uint menuID, string commandBarName) { // Make sure the CommandBars collection is properly initialized, before we attempt to // use the IVsProfferCommands service. CommandBar menuBarCommandBar = ((CommandBars)ApplicationObject.CommandBars)[commandBarName]; // Retrieve IVsProfferComands via DTE's IOleServiceProvider interface IOleServiceProvider sp = (IOleServiceProvider)ApplicationObject; Guid guidSvc = typeof(IVsProfferCommands).GUID; Object objService; sp.QueryService(ref guidSvc, ref guidSvc, out objService); IVsProfferCommands vsProfferCmds = (IVsProfferCommands)objService; return(vsProfferCmds.FindCommandBar(IntPtr.Zero, ref guidCmdGroup, menuID) as CommandBar); }
public void SetSilent(WebBrowser browser, bool silent) { IOleServiceProvider sp = browser.Document as IOleServiceProvider; if (sp != null) { var IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046"); var IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E"); object webBrowser; sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out webBrowser); if (webBrowser != null) { webBrowser.GetType().InvokeMember("Silent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.PutDispProperty, null, webBrowser, new object[] { silent }); } } }
// ROK - a total and complete hack. Again I'm bitten by the lack of COM interface isolation in .NET, causing // the need for us to use reflection to hopefully find the COM based implmenetation of the actual project item // site in a member field. I don't know of a worse way to do this, but I don't know of a better one either. private static IEnumerable <IOleServiceProvider> StealServiceProvider(object instance, Type type) { foreach (FieldInfo fi in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetField)) { IOleServiceProvider value = fi.GetValue(instance) as IOleServiceProvider; if (value != null) { yield return(value); } } foreach (IOleServiceProvider sp in StealServiceProvider(instance, type.BaseType)) { yield return(sp); } }
static bool TryQueryService(IOleServiceProvider svcs, Guid guid, out object service) { IntPtr pUnk; if (svcs != null) { int hr = svcs.QueryService(ref guid, ref IID_IUnknown, out pUnk); if (Succeeded(hr) && (pUnk != IntPtr.Zero)) { try { service = Marshal.GetObjectForIUnknown(pUnk); } finally { Marshal.Release(pUnk); } return(true); } } service = null; return(false); }
private void SuppressScriptingErrors() { // get an IWebBrowser2 from the document IOleServiceProvider sp = Browser.Document as IOleServiceProvider; if (sp != null) { Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046"); Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E"); object webBrowser; sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out webBrowser); if (webBrowser != null) { webBrowser.GetType().InvokeMember("Silent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.PutDispProperty, null, webBrowser, new object[] { true }); } } }
static void SetSilent(WebBrowser browser, bool silent) { IOleServiceProvider provider = browser.Document as IOleServiceProvider; if (provider == null) { return; } object webBrowser; provider.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out webBrowser); if (webBrowser == null) { return; } Type webBrowserType = webBrowser.GetType(); webBrowserType.InvokeMember("Silent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.PutDispProperty, null, webBrowser, new object[] { silent }); }
// I have added a button to demonstrate private void Button_Click(object sender, RoutedEventArgs e) { // NOTE: this works only when the document as been loaded IOleServiceProvider sp = webBrowser.Document as IOleServiceProvider; if (sp != null) { Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046"); Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E"); const int OLECMDID_PRINT = 6; const int OLECMDEXECOPT_DONTPROMPTUSER = 2; dynamic wb; // will be of IWebBrowser2 type, but dynamic is cool sp.QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, out wb); if (wb != null) { // note: this will send to the default printer, if any wb.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, null, null); } } }
internal static void SetSilent(System.Windows.Controls.WebBrowser browser, bool silent) { // get an IWebBrowser2 from the document IOleServiceProvider sp = browser?.Document as IOleServiceProvider; if (sp != null) { Guid IID_IWebBrowserApp = new Guid(IWebBrowserAppGUID); Guid IID_IWebBrowser2 = new Guid(IWebBrowser2GUID); object webBrowser; sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out webBrowser); webBrowser?.GetType() .InvokeMember( "Silent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.PutDispProperty, null, webBrowser, new object[] { silent }); } }
private void WebBrowser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e) { #if !DEBUG // get an IWebBrowser2 from the document IOleServiceProvider sp = m_browser.Document as IOleServiceProvider; if (sp != null) { Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046"); Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E"); object webBrowser; sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out webBrowser); if (webBrowser != null) { webBrowser.GetType().InvokeMember("Silent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.PutDispProperty, null, webBrowser, new object[] { true }); } } #endif }
/// <summary> /// Keep WebBrowser Preview control from firing script errors. We need this /// because we may be previewing HTML content that includes script content /// that might not work because of local file restrictions or missing /// resources that can't load from the Web. /// /// Ugh... Keep Web Browser control from showing error dialog - silent operation. /// this is ugly, but it works. /// </summary> /// <param name="browser"></param> /// <param name="silent"></param> static void NoScriptErrors(WebBrowser browser, bool silent) { if (browser == null) { return; } // get an IWebBrowser2 from the document IOleServiceProvider sp = browser.Document as IOleServiceProvider; if (sp != null) { Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046"); Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E"); dynamic webBrowser; sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out webBrowser); if (webBrowser != null) { webBrowser.Silent = silent; } } }
public void RunFinished() { Project silverlightProject = this.GetSilverlightProject(); // Here we create the web project from template. // The location of web template is calculated as a relative path from current(client) template, // which is passed as customParams[0] in current version of VS/VWD(undocumented). if (this._customParams.Length > 0 && this._customParams[0] != null) { string templateDir = Path.GetDirectoryName((string)this._customParams[0]); #if VS10 string webTemplateDir = Path.Combine(templateDir, "BA.Web.10.0"); #else string webTemplateDir = Path.Combine(templateDir, "BA.Web"); #endif if (!Directory.Exists(webTemplateDir)) { // In V1 SP1, we switched to a shorter directory name to avoid a lot of messy path-length // issues. However, some older templates might still have the original directory name. webTemplateDir = Path.Combine(templateDir, "BusinessApplication.Web"); } string webTemplate = Path.Combine(webTemplateDir, "server.vstemplate"); // CSDMain 228876 // Custom parameters can be appended to the path when calling AddFromTemplate. We need to use something other than // $targetframeworkversion$ since we're not calling GetProjectTemplate and $targetframeworkversion$ is already baked in // as the default when calling AddFromTemplate in this manner. The project file and web.config reference // $targetwebframeworkversion$ to complete this. webTemplate += "|$targetwebframeworkversion$=" + this._replacementsDictionary["$targetframeworkversion$"]; string destination = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(silverlightProject.FullName)), this._webProjectName); this._solution2.AddFromTemplate(webTemplate, destination, this._webProjectName, false); } Project webProject = this.GetWebProject(); if (webProject != null) { // Set the WAP as the startup project this._dte2.Solution.SolutionBuild.StartupProjects = webProject.UniqueName; Properties props = webProject.Properties; // Set the start page ProjectItem testPageItem = this.GetAspxTestPage(webProject); if (testPageItem != null) { props.Item("WebApplication.StartPageUrl").Value = testPageItem.Name; props.Item("WebApplication.DebugStartAction").Value = 1; // StartAction.SpecificPage } // Link the server project to the client if (silverlightProject != null) { string projectReference = webProject.FullName; if ((webProject.FullName.Length > 0) && Path.IsPathRooted(webProject.FullName)) { projectReference = MakeProjectPathRelative(projectReference, silverlightProject.FullName); } IVsSolution ivsSolution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution)); IVsHierarchy hierarchy; ivsSolution.GetProjectOfUniqueName(silverlightProject.UniqueName, out hierarchy); IVsBuildPropertyStorage buildPropertyStorage = (IVsBuildPropertyStorage)hierarchy; buildPropertyStorage.SetPropertyValue("LinkedOpenRiaServerProject", null, (uint)_PersistStorageType.PST_PROJECT_FILE, projectReference); buildPropertyStorage.SetPropertyValue("DisableFastUpToDateCheck", null, (uint)_PersistStorageType.PST_PROJECT_FILE, "true"); // Add this client to the list of clients in the server project // Get the IVsHierarchy for each one from the solution IOleServiceProvider oleServiceProvider = this._dte2 as IOleServiceProvider; IVsSolution sln = null; using (ServiceProvider sp = new ServiceProvider(oleServiceProvider)) { // Get the solution sln = sp.GetService(typeof(IVsSolution)) as IVsSolution; System.Diagnostics.Debug.Assert(sln != null, "Unable to get solution object."); } // Get the hierarchies for each project IVsHierarchy webHierarchy; int result; result = sln.GetProjectOfUniqueName(webProject.UniqueName, out webHierarchy); System.Diagnostics.Debug.Assert(result == 0, "Unexpected failure."); if (result == 0 && webHierarchy != null) { IVsHierarchy silverlightHierarchy; result = sln.GetProjectOfUniqueName(silverlightProject.UniqueName, out silverlightHierarchy); System.Diagnostics.Debug.Assert(result == 0, "Unexpected failure."); if (result == 0) { //// Cast the server one to a silverlight project consumer //IVsSilverlightProjectConsumer spc = webHierarchy as IVsSilverlightProjectConsumer; //// Create the Silverlight link //spc.LinkToSilverlightProject("ClientBin", // destination folder // true, //enable silverlight debugging // false, //use cfg specific folders // silverlightHierarchy as IVsSilverlightProject); } } } } // Add Links to .resx files FileInfo webProjectProjectFile = new FileInfo(webProject.FullName); string webProjectDirectory = webProjectProjectFile.DirectoryName; ProjectItem webResourcesFolder = silverlightProject.ProjectItems.AddFolder("Web", null).ProjectItems.AddFolder("Resources", null); foreach (string resxFile in Directory.GetFiles(Path.Combine(webProjectDirectory, "Resources"), "*.resx")) { ProjectItem link = webResourcesFolder.ProjectItems.AddFromFile(resxFile); link.Properties.Item("CustomTool").Value = "PublicResXFileCodeGenerator"; } // We always want to build the RIA Services Projects because we need a couple of things to happen: // 1. CodeGen needs to occur to make the generated classes available in the client project, allowing it to compile // 2. We need the client project to be built so that its controls can be referenced in XAML // Without the build occurring here, VB solutions immediately showed build errors in the error list, and C# // solutions would show errors as soon as any of the XAML files were opened. // We build the silverlight project, which also causes VS to build the Web project because it is a dependency, // instead of the whole solution. That way, if there are additional projects in the solution, as is the case // with the Azure BAT template, those projects won't get built because of the RIA projects. var sb = this._solution2.SolutionBuild; if (silverlightProject != null) { sb.BuildProject(sb.ActiveConfiguration.Name, silverlightProject.UniqueName, /*WaitForBuildToFInish*/ true); } ProjectItem mainPage = this._solution2.FindProjectItem("MainPage.xaml"); System.Diagnostics.Debug.Assert(mainPage != null, "MainPage.xaml should always exist in the Silverlight project."); mainPage.Open(EnvDTE.Constants.vsViewKindPrimary); }
/// <summary> /// <para>Releases unmanaged resources and performs other cleanup operations before the <see cref="ServiceContainer"/> is reclaimed by garbage collection. </para> /// </summary> /// <param name="disposing"><para><c>true</c> if we are disposing; otherwise, <c>false</c> which means the call is coming from our finalizer.</para></param> protected virtual void Dispose(bool disposing) { if (disposing) { if (oleServiceProvider != null) { oleServiceProvider = null; } } }
/// <summary> /// <para>Provides the site's IUnknown pointer to the object. The object should hold onto this pointer, calling IUnknown::AddRef in doing so. If the object already has a site, it should call that existing site's IUnknown::Release, save the new site pointer, and call the new site's IUnknown::AddRef.</para> /// </summary> /// <param name="pUnkSite"> /// <para>Pointer to the IUnknown interface pointer of the site managing this object. If NULL, the object should call IUnknown::Release on any existing site at which point the object no longer knows its site.</para> /// </param> public void SetSite(object pUnkSite) { if (pUnkSite is IOleServiceProvider) { oleServiceProvider = (IOleServiceProvider)pUnkSite; } }
/// <summary> /// Creates a new ServiceProvider object and uses the given interface to resolve /// services. /// </summary> /// <param name='sp'> /// The IOleServiceProvider interface to use. /// </param> public ServiceProvider( IOleServiceProvider sp ) { serviceProvider = sp; }
/// <summary> /// Sets the site object we will be using to resolve services. /// </summary> /// <param name='pUnkSite'> /// The site we will use. This site will only be /// used if it also implements IOleServiceProvider. /// </param> /// <seealso cref='IObjectWithSite'/> void IObjectWithSite.SetSite( object pUnkSite ) { if ( pUnkSite is IOleServiceProvider ) { serviceProvider = ( IOleServiceProvider )pUnkSite; } }
public virtual int SetSite(IOleServiceProvider psp) { ServiceProvider = new ServiceProvider(psp); return(VSConstants.S_OK); }
/// <summary> /// Creates a new ServiceProvider object and uses the given interface to resolve /// services. /// </summary> /// <param name='sp'> /// The IOleServiceProvider interface to use. /// </param> public ServiceProvider(IOleServiceProvider sp) { serviceProvider = sp; }
/// <summary> /// gives this class a chance to free its references. /// </summary> public virtual void Dispose() { if (this.serviceProvider != null) this.serviceProvider = null; }
static bool TryQueryService(IOleServiceProvider svcs, Guid guid, out object service) { IntPtr pUnk; if (svcs != null) { int hr = svcs.QueryService(ref guid, ref IID_IUnknown, out pUnk); if (Succeeded(hr) && (pUnk != IntPtr.Zero)) { try { service = Marshal.GetObjectForIUnknown(pUnk); } finally { Marshal.Release(pUnk); } return true; } } service = null; return false; }
public virtual int SetSite(IOleServiceProvider serviceProvider) { this.serviceProvider = new ServiceProvider(serviceProvider); return(VSConstants.S_OK); }
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; IObjectWithSite ows = (IObjectWithSite)textLines; ows.SetSite(provider); // Create loader for the designer LimnorXmlDesignerLoader2 designerLoader = new LimnorXmlDesignerLoader2(documentMoniker, itemid); // Create the designer using the provider and the loader IVSMDDesigner designer = designerService.CreateDesigner(provider, designerLoader); designerLoader.AddComponentChangeEventHandler(); // Retrieve the design surface DesignSurface designSurface = (DesignSurface)designer; IDesignerHost dh = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); dh.AddService(typeof(INameCreationService), new NameCreationService()); IServiceContainer serviceContainer = dh.GetService(typeof(ServiceContainer)) as IServiceContainer; dh.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(serviceContainer)); //DesignerSerializationService uses CodeDomComponentSerializationService CodeDomComponentSerializationService codeDomComponentSerializationService = new CodeDomComponentSerializationService(serviceContainer); dh.AddService(typeof(ComponentSerializationService), codeDomComponentSerializationService); //LimnorUndoEngine undoEngine = new LimnorUndoEngine(serviceContainer); //undoEngine.Enabled = false;//not use undo during loading //dh.AddService(typeof(UndoEngine), undoEngine); //object v = dh.GetService(typeof(IOleUndoManager)); //if (v != null) //{ // object v2 = dh.GetService(typeof(UndoEngine)); // if (v2 == null) // { // dh.AddService(typeof(UndoEngine), v); // } //} // Create pane with this surface LimnorXmlPane2 limnorXmlPane = new LimnorXmlPane2(designSurface);//, winControlPME); // Get command guid from designer cmdUI = limnorXmlPane.CommandGuid; editorCaption = " [Design]"; if (designerLoader.IsSetup) { } else { if (limnorXmlPane.Loader.ObjectMap != null) { limnorXmlPane.BeginApplyConfig(); } } // Return LimnorXmlPane return(Marshal.GetIUnknownForObject(limnorXmlPane)); } catch (Exception ex) { MathNode.Log(ex); //Trace.WriteLine("Exception: " + ex.Message); // Just rethrow for now throw; } }
public static T QueryService <T>(this IOleServiceProvider source, Guid serviceId) { return((T)QueryService(source, serviceId, typeof(T).GUID)); }