コード例 #1
0
ファイル: Connect.cs プロジェクト: ilya11211/nprof
        void IDTExtensibility2.OnConnection( object oApplication, Extensibility.ext_ConnectMode cmConnectMode, object oAddInInstance, ref System.Array arrCustom )
        {
            _pApplication = ( _DTE )oApplication;
            _pAddInInstance = ( EnvDTE.AddIn )oAddInInstance;

            _pf = new ProfilerForm();
            _pf.Owner = null;
            _pf.Closed += new EventHandler(_pf_Closed);

            // Hook up to run events
            Command cmdDebug;

            cmdDebug = _pApplication.Commands.Item( "Debug.Start", 1 );
            _cmdevDebugStart = _pApplication.Events.get_CommandEvents( cmdDebug.Guid, cmdDebug.ID );
            _cmdevDebugStart.BeforeExecute += new EnvDTE._dispCommandEvents_BeforeExecuteEventHandler( OnBeforeRun );
            _cmdevDebugStart.AfterExecute += new EnvDTE._dispCommandEvents_AfterExecuteEventHandler( OnAfterRun );

            cmdDebug = _pApplication.Commands.Item( "Debug.StartWithoutDebugging", 1 );
            _cmdevNoDebugStart = _pApplication.Events.get_CommandEvents( cmdDebug.Guid, cmdDebug.ID );
            _cmdevNoDebugStart.BeforeExecute += new EnvDTE._dispCommandEvents_BeforeExecuteEventHandler( OnBeforeRun );
            _cmdevNoDebugStart.AfterExecute += new EnvDTE._dispCommandEvents_AfterExecuteEventHandler( OnAfterRun );

            if ( cmConnectMode == Extensibility.ext_ConnectMode.ext_cm_UISetup )
            {
                object[] contextGUIDS = new object[] { };
                foreach ( Command cmd in _pApplication.Commands )
                {
                    try
                    {
                        if ( cmd.Name != null && cmd.Name.StartsWith( "NProf.Connect" ) )
                            cmd.Delete();
                    }
                    catch ( Exception )
                    {
                    }
                }

                try
                {
                    CommandBar barNProf = _pApplication.CommandBars[ "nprof Profiling" ];
                    if ( barNProf != null )
                        barNProf.Delete();
                }
                catch ( Exception )
                {
                }

                Command command = _pApplication.Commands.AddNamedCommand(
                    _pAddInInstance,
                    "Enable",
                    "Enable nprof",
                    "Toggle nprof integration",
                    true,
                    0,
                    ref contextGUIDS,
                    (int)vsCommandStatus.vsCommandStatusUnsupported );

                CommandBar barTools = ( CommandBar )_pApplication.CommandBars[ "Tools" ];
                CommandBar barMenu = ( CommandBar )_pApplication.Commands.AddCommandBar( "nprof Profiling", vsCommandBarType.vsCommandBarTypeMenu, barTools, 1 );

                CommandBarControl cbc = command.AddControl( barMenu, 1 );
            }
        }
コード例 #2
0
ファイル: Connect.cs プロジェクト: ilya11211/nprof
        void IDTExtensibility2.OnDisconnection( Extensibility.ext_DisconnectMode dmDisconnectMode, ref System.Array arrCustom )
        {
            // Remove command handlers
            _cmdevDebugStart.BeforeExecute -= new EnvDTE._dispCommandEvents_BeforeExecuteEventHandler( OnBeforeRun );
            _cmdevDebugStart.AfterExecute -= new EnvDTE._dispCommandEvents_AfterExecuteEventHandler( OnAfterRun );
            _cmdevDebugStart = null;

            _cmdevNoDebugStart.BeforeExecute -= new EnvDTE._dispCommandEvents_BeforeExecuteEventHandler( OnBeforeRun );
            _cmdevNoDebugStart.AfterExecute -= new EnvDTE._dispCommandEvents_AfterExecuteEventHandler( OnAfterRun );
            _cmdevNoDebugStart = null;

            _pApplication = null;
            _pAddInInstance = null;

            _pf = null;
        }
コード例 #3
0
ファイル: Connect.cs プロジェクト: ilya11211/nprof
 private void _pf_Closed(object sender, EventArgs e)
 {
     _pf = new ProfilerForm();
     _pf.Owner = null;
     _pf.Closed += new EventHandler( _pf_Closed );
 }
コード例 #4
0
ファイル: Application.cs プロジェクト: ilya11211/nprof
        static void Main( string[] args )
        {
            EnableVisualStyles();

            // Always print GPL notice
            Console.WriteLine( "NProf version {0} (C) 2003 by Matthew Mastracci", Profiler.Version );
            Console.WriteLine( "http://nprof.sourceforge.net" );
            Console.WriteLine();
            Console.WriteLine( "This is free software, and you are welcome to redistribute it under certain" );
            Console.WriteLine( "conditions set out by the GNU General Public License.  A copy of the license" );
            Console.WriteLine( "is available in the distribution package and from the NProf web site." );
            Console.WriteLine();

            ProfilerForm pf = new ProfilerForm();
            if ( args.Length > 0 )
            {
                pf.InitialProject = CreateProjectInfo( args );

                // If we're in command-line mode and we couldn't create a project, return
                if ( pf.InitialProject == null )
                    return;
            }

            Console.Out.Flush();
            System.Threading.Thread.CurrentThread.Name = "GUI Thread";
            System.Windows.Forms.Application.Run( pf );
        }