PageRenderTime 49ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/NShaderVS2008/NShader.cs

http://nshader.codeplex.com
C# | 176 lines | 107 code | 16 blank | 53 comment | 1 complexity | 57356fdce717dd4721d435ef9ac03cf5 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. #region Header Licence
  2. // ---------------------------------------------------------------------
  3. //
  4. // Copyright (c) 2009 Alexandre Mutel and Microsoft Corporation.
  5. // All rights reserved.
  6. //
  7. // This code module is part of NShader, a plugin for visual studio
  8. // to provide syntax highlighting for shader languages (hlsl, glsl, cg)
  9. //
  10. // ------------------------------------------------------------------
  11. //
  12. // This code is licensed under the Microsoft Public License.
  13. // See the file License.txt for the license details.
  14. // More info on: http://nshader.codeplex.com
  15. //
  16. // ------------------------------------------------------------------
  17. #endregion
  18. using System;
  19. using System.Diagnostics;
  20. using System.Globalization;
  21. using System.Runtime.InteropServices;
  22. using System.ComponentModel.Design;
  23. using Microsoft.VisualStudio;
  24. using Microsoft.VisualStudio.Shell;
  25. using Microsoft.VisualStudio.Shell.Interop;
  26. namespace NShader
  27. {
  28. /// <summary>
  29. /// This is the class that implements the package exposed by this assembly.
  30. ///
  31. /// The minimum requirement for a class to be considered a valid package for Visual Studio
  32. /// is to implement the IVsPackage interface and register itself with the shell.
  33. /// This package uses the helper classes defined inside the Managed Package Framework (MPF)
  34. /// to do it: it derives from the Package class that provides the implementation of the
  35. /// IVsPackage interface and uses the registration attributes defined in the framework to
  36. /// register itself and its components with the shell.
  37. /// </summary>
  38. // This attribute tells the registration utility (regpkg.exe) that this class needs
  39. // to be registered as package.
  40. [PackageRegistration(UseManagedResourcesOnly = true)]
  41. // A Visual Studio component can be registered under different regitry roots; for instance
  42. // when you debug your package you want to register it in the experimental hive. This
  43. // attribute specifies the registry root to use if no one is provided to regpkg.exe with
  44. // the /root switch.
  45. #if VISUAL_STUDIO_2010
  46. [DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\11.0")]
  47. #else
  48. [DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\9.0")]
  49. #endif
  50. // This attribute is used to register the informations needed to show the this package
  51. // in the Help/About dialog of Visual Studio.
  52. // Loaded from Package IVsInstalledProduct methods
  53. #if !VISUAL_STUDIO_2010
  54. [InstalledProductRegistration(true, "#110", "#112", NShaderVersion.VERSION, IconResourceID = 400)]
  55. #endif
  56. //[InstalledProductRegistration(true, null, null, null)]
  57. // In order be loaded inside Visual Studio in a machine that has not the VS SDK installed,
  58. // package needs to have a valid load key (it can be requested at
  59. // http://msdn.microsoft.com/vstudio/extend/). This attributes tells the shell that this
  60. // package has a load key embedded in its resources.
  61. #if !VISUAL_STUDIO_2010
  62. [ProvideLoadKey("Standard", NShaderVersion.VERSION, "NShader", "Alexandre Mutel", 113)]
  63. #endif
  64. [ProvideService(typeof(NShaderLanguageService), ServiceName = "Shader Language Service")]
  65. [ProvideLanguageServiceAttribute(typeof(NShaderLanguageService),
  66. "Shader Language",
  67. 0,
  68. EnableCommenting = true,
  69. EnableFormatSelection = true,
  70. EnableLineNumbers = true
  71. )]
  72. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.HLSL_FX)]
  73. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.HLSL_FXH)]
  74. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.HLSL_HLSL)]
  75. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.HLSL_VSH)]
  76. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.HLSL_PSH)]
  77. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.SL_FX)]
  78. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.GLSL_FRAG)]
  79. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.GLSL_VERT)]
  80. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.GLSL_FP)]
  81. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.GLSL_VP)]
  82. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.GLSL_GEOM)]
  83. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.GLSL_GLSL)]
  84. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.CG_CG)]
  85. [ProvideLanguageExtensionAttribute(typeof(NShaderLanguageService), NShaderSupportedExtensions.CG_CGFX)]
  86. [Guid(GuidList.guidNShaderPkgString)]
  87. public sealed class NShader : Package, IVsInstalledProduct
  88. {
  89. /// <summary>
  90. /// Default constructor of the package.
  91. /// Inside this method you can place any initialization code that does not require
  92. /// any Visual Studio service because at this point the package object is created but
  93. /// not sited yet inside Visual Studio environment. The place to do all the other
  94. /// initialization is the Initialize method.
  95. /// </summary>
  96. public NShader()
  97. {
  98. Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
  99. }
  100. /////////////////////////////////////////////////////////////////////////////
  101. // Overriden Package Implementation
  102. #region Package Members
  103. /// <summary>
  104. /// Initialization of the package; this method is called right after the package is sited, so this is the place
  105. /// where you can put all the initilaization code that rely on services provided by VisualStudio.
  106. /// </summary>
  107. protected override void Initialize()
  108. {
  109. Trace.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
  110. base.Initialize();
  111. // Proffer the service.
  112. IServiceContainer serviceContainer = this as IServiceContainer;
  113. NShaderLanguageService langService = new NShaderLanguageService();
  114. langService.SetSite(this);
  115. serviceContainer.AddService(typeof(NShaderLanguageService),
  116. langService,
  117. true);
  118. }
  119. #endregion
  120. #region Implementation of IVsInstalledProduct
  121. public int IdBmpSplash(out uint pIdBmp)
  122. {
  123. pIdBmp = 0;
  124. return VSConstants.S_OK;
  125. }
  126. public int OfficialName(out string pbstrName)
  127. {
  128. pbstrName = VSPackageResourceManager.GetString("110");
  129. return VSConstants.S_OK;
  130. }
  131. public int ProductID(out string pbstrPID)
  132. {
  133. pbstrPID = NShaderVersion.VERSION;
  134. return VSConstants.S_OK;
  135. }
  136. public int ProductDetails(out string pbstrProductDetails)
  137. {
  138. pbstrProductDetails = VSPackageResourceManager.GetString("112");
  139. return VSConstants.S_OK;
  140. }
  141. public int IdIcoLogoForAboutbox(out uint pIdIco)
  142. {
  143. pIdIco = 400;
  144. return VSConstants.S_OK;
  145. }
  146. private static System.Resources.ResourceManager resourceMan;
  147. internal static System.Resources.ResourceManager VSPackageResourceManager
  148. {
  149. get
  150. {
  151. if (ReferenceEquals(resourceMan, null))
  152. {
  153. resourceMan = new System.Resources.ResourceManager("NShader.VSPackage", typeof(NShader).Assembly);
  154. }
  155. return resourceMan;
  156. }
  157. }
  158. #endregion
  159. }
  160. }