示例#1
0
        private static void TableListing(object sender, EventArgs e)
        {
            ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                try
                {
                    var output = new StringOutput();
                    int exitCode;

                    using (var pr = new ProcessRunner())
                    {
                        exitCode = pr.CaptureProcess("ptd.exe", "", ProbeEnvironment.CurrentAppSettings.TempDir, output);
                    }
                    if (exitCode != 0)
                    {
                        Shell.ShowError(string.Format("PTD returned exit code {0}.", exitCode));
                    }
                    else
                    {
                        var tempFileName = TempManager.GetNewTempFileName("ptd", ".txt");
                        File.WriteAllText(tempFileName, output.Text);
                        Shell.OpenDocument(tempFileName);
                    }
                }
                catch (Exception ex)
                {
                    Shell.ShowError(ex);
                }
            });
        }
示例#2
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 initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            Log.Initialize();
            ProbeEnvironment.Initialize();
            TempManager.Init(TempDir);
            Snippets.SnippetDeploy.DeploySnippets();
            CodeModel.SignatureDocumentor.Initialize();

            ThreadHelper.ThrowIfNotOnUIThread();

            // Proffer the service.	http://msdn.microsoft.com/en-us/library/bb166498.aspx
            var langService = new ProbeLanguageService(this);

            langService.SetSite(this);
            (this as IServiceContainer).AddService(typeof(ProbeLanguageService), langService, true);

            // Register a timer to call our language service during idle periods.
            var mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;

            if (_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 _componentId);
            }

            _errorTaskProvider = new ErrorTagging.ErrorTaskProvider(this);
            TaskListService.RegisterTaskProvider(_errorTaskProvider, out _errorTaskProviderCookie);

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (mcs != null)
            {
                Commands.InitCommands(mcs);
            }

            _functionScanner = new FunctionFileScanning.FFScanner();

            // Need to keep a reference to Events and DocumentEvents in order for DocumentSaved to be triggered.
            _dteEvents = Shell.DTE.Events;

            _dteDocumentEvents = _dteEvents.DocumentEvents;
            _dteDocumentEvents.DocumentSaved += DocumentEvents_DocumentSaved;

            Microsoft.VisualStudio.PlatformUI.VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged;
        }
示例#3
0
文件: Output.cs 项目: cmrazek/DkTools
 public TempFileOutput(string fileTitle, string extension)
 {
     _fileName = TempManager.GetNewTempFileName(fileTitle, extension);
     _writer   = new StreamWriter(_fileName);
 }