我想创建一个小时计数器来监控我在项目中的开发时间。当某个项目在 Visual Studio 2008 中处于活动状态时,我希望增加时间。
我可以以编程方式找出当前在 VS2008 中处于活动状态的 *.csproj 文件吗?
我想创建一个小时计数器来监控我在项目中的开发时间。当某个项目在 Visual Studio 2008 中处于活动状态时,我希望增加时间。
我可以以编程方式找出当前在 VS2008 中处于活动状态的 *.csproj 文件吗?
You can get the loaded solution via the DTE.Solution
property, and the active document via DTE.ActiveDocument
. There isn't really an "active project" because you never really activate projects, you only open solutions (which can contain multiple projects) and files (which happen to be in projects).
I suspect for a time-tracking requirement, getting the current solution would probably suffice. However, if you need to specifically distinguish between projects in the solution, you can do this using DTE.ActiveDocument.ProjectItem.ContainingProject
.