示例#1
0
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Proffer the service.
            IServiceContainer      serviceContainer = this as IServiceContainer;
            NShaderLanguageService langService      = new NShaderLanguageService();

            langService.SetSite(this);
            serviceContainer.AddService(typeof(NShaderLanguageService),
                                        langService,
                                        true);
        }
示例#2
0
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Proffer the service.
            IServiceContainer      serviceContainer = this as IServiceContainer;
            NShaderLanguageService langService      = new NShaderLanguageService();

            langService.SetSite(this);
            serviceContainer.AddService(typeof(NShaderLanguageService),
                                        langService,
                                        true);


            // Since we register custom text markers we have to ensure the font and color
            // cache is up-to-date.
            ValidateFontAndColorCacheManagerIsUpToDate();
        }
示例#3
0
 public NShaderViewFilter(NShaderLanguageService langService, CodeWindowManager mgr, IVsTextView view)
     : base(mgr, view)
 {
     this.langService = langService;
 }
示例#4
0
文件: NShader.cs 项目: tf1379/nshader
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Trace.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Proffer the service.
            IServiceContainer serviceContainer = this as IServiceContainer;
            NShaderLanguageService langService = new NShaderLanguageService();
            langService.SetSite(this);
            serviceContainer.AddService(typeof(NShaderLanguageService),
                                        langService,
                                        true);


            // Since we register custom text markers we have to ensure the font and color
            // cache is up-to-date.
            ValidateFontAndColorCacheManagerIsUpToDate();
        }
示例#5
0
        /// <summary>
        ///     Initialization of the package; this method is called right after the package is sited, so this is the place
        ///     where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString()));
            base.Initialize();

            IDEBuildLogger.UserRegistryRoot = UserRegistryRoot;

            solutionEventsListener = new SolutionEventsListener(this);
            solutionEventsListener.AfterSolutionBackgroundLoadComplete += solutionEventsListener_AfterSolutionBackgroundLoadComplete;

            // Initialize the build monitor, that will display BuildEngine results in the Build Output pane.
            buildLogPipeGenerator = new BuildLogPipeGenerator(this);

            dte2 = GetGlobalService(typeof(SDTE)) as DTE2;

            // Register the C# language service
            var serviceContainer = this as IServiceContainer;
            var errorListProvider = new ErrorListProvider(this)
            {
                ProviderGuid = new Guid("ad1083c5-32ad-403d-af3d-32fee7abbdf1"),
                ProviderName = "Paradox Shading Language"
            };
            var langService = new NShaderLanguageService(errorListProvider);
            langService.SetSite(this);
            langService.InitializeColors(); // Make sure to initialize colors before registering!
            serviceContainer.AddService(typeof(NShaderLanguageService), langService, true);

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                ParadoxCommands.ServiceProvider = this;
                ParadoxCommands.RegisterCommands(mcs);
            }

            // Get General Output pane (for error logging)
            var generalOutputPane = GetGeneralOutputPane();

            var paradoxSdkDir = ParadoxCommandsProxy.ParadoxSdkDir;
            if (paradoxSdkDir == null)
            {
                generalOutputPane.OutputStringThreadSafe("Could not find Paradox SDK directory.\r\n");
                generalOutputPane.Activate();
            }

            // Start PackageBuildMonitorRemote in a separate app domain
            buildMonitorDomain = ParadoxCommandsProxy.CreateParadoxDomain();
            try
            {
                var remoteCommands = ParadoxCommandsProxy.CreateProxy(buildMonitorDomain);
                remoteCommands.StartRemoteBuildLogServer(new BuildMonitorCallback(dte2), buildLogPipeGenerator.LogPipeUrl);
            }
            catch (Exception e)
            {
                generalOutputPane.OutputStringThreadSafe(string.Format("Error loading Paradox SDK: {0}\r\n", e));
                generalOutputPane.Activate();

                // Unload domain right away
                AppDomain.Unload(buildMonitorDomain);
                buildMonitorDomain = null;
            }

            // Preinitialize the parser in a separate thread
            var thread = new System.Threading.Thread(
                () =>
                {
                    try
                    {
                        ParadoxCommandsProxy.GetProxy().Initialize(null);
                    }
                    catch (Exception ex)
                    {
                        generalOutputPane.OutputStringThreadSafe(string.Format("Error Initializing Paradox Language Service: {0}\r\n", ex.InnerException ?? ex));
                        generalOutputPane.Activate();
                        errorListProvider.Tasks.Add(new ErrorTask(ex.InnerException ?? ex));
                    }
                });
            thread.Start();

            // Register a timer to call our language service during
            // idle periods.
            var mgr = GetService(typeof(SOleComponentManager))
                                       as IOleComponentManager;
            if (m_componentID == 0 && mgr != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
                                              (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
                                              (uint)_OLECADVF.olecadvfRedrawOff |
                                              (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out m_componentID);
            }
        }
示例#6
0
 public NShaderViewFilter(NShaderLanguageService langService, CodeWindowManager mgr, IVsTextView view)
     : base(mgr, view)
 {
     this.langService = langService;
 }
示例#7
0
        /// <summary>
        ///     Initialization of the package; this method is called right after the package is sited, so this is the place
        ///     where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString()));
            base.Initialize();

            IDEBuildLogger.UserRegistryRoot = UserRegistryRoot;

            solutionEventsListener = new SolutionEventsListener(this);
            solutionEventsListener.AfterSolutionBackgroundLoadComplete += solutionEventsListener_AfterSolutionBackgroundLoadComplete;

            dte2 = GetGlobalService(typeof(SDTE)) as DTE2;

            // Register the C# language service
            var serviceContainer = this as IServiceContainer;
            errorListProvider = new ErrorListProvider(this)
            {
                ProviderGuid = new Guid("ad1083c5-32ad-403d-af3d-32fee7abbdf1"),
                ProviderName = "Paradox Shading Language"
            };
            var langService = new NShaderLanguageService(errorListProvider);
            langService.SetSite(this);
            langService.InitializeColors(); // Make sure to initialize colors before registering!
            serviceContainer.AddService(typeof(NShaderLanguageService), langService, true);

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                ParadoxCommands.ServiceProvider = this;
                ParadoxCommands.RegisterCommands(mcs);
            }

            // Register a timer to call our language service during
            // idle periods.
            var mgr = GetService(typeof(SOleComponentManager))
                                       as IOleComponentManager;
            if (m_componentID == 0 && mgr != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
                                              (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
                                              (uint)_OLECADVF.olecadvfRedrawOff |
                                              (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out m_componentID);
            }
        }