public void InitializeAsync()
{
try
{
Logger.Info(string.Format("Initializing WakaTime v{0}", WakaTimeConstants.PluginVersion));
// VisualStudio Object
_docEvents = ObjDte.Events.DocumentEvents;
_windowEvents = ObjDte.Events.WindowEvents;
_solutionEvents = ObjDte.Events.SolutionEvents;
// Settings Form
_settingsForm = new SettingsForm();
_settingsForm.ConfigSaved += SettingsFormOnConfigSaved;
try
{
// Make sure python is installed
if (!PythonManager.IsPythonInstalled())
{
Downloader.DownloadAndInstallPython();
}
if (!DoesCliExist() || !IsCliLatestVersion())
{
Downloader.DownloadAndInstallCli();
}
}
catch (WebException ex)
{
Logger.Error("Are you behind a proxy? Try setting a proxy in iTimeTrack Settings with format https://user:pass@host:port. Exception Traceback:", ex);
}
catch (Exception ex)
{
Logger.Error("Error detecting dependencies. Exception Traceback:", ex);
}
// Add our command handlers for menu (commands must exist in the .vsct file)
var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (mcs != null)
{
// Create the command for the menu item.
var menuCommandId = new CommandID(GuidList.GuidWakaTimeCmdSet, (int)PkgCmdIdList.UpdateWakaTimeSettings);
var menuItem = new MenuCommand(MenuItemCallback, menuCommandId);
mcs.AddCommand(menuItem);
}
// setup event handlers
_docEvents.DocumentOpened += DocEventsOnDocumentOpened;
_docEvents.DocumentSaved += DocEventsOnDocumentSaved;
_windowEvents.WindowActivated += WindowEventsOnWindowActivated;
_solutionEvents.Opened += SolutionEventsOnOpened;
Logger.Info(string.Format("Finished initializing WakaTime v{0}", WakaTimeConstants.PluginVersion));
}
catch (Exception ex)
{
Logger.Error("Error initializing Wakatime", ex);
}
}