public void Initialize() { SetNotifyIconToolTip(); _version = $"{CoreAssembly.Version.Major}.{CoreAssembly.Version.Minor}.{CoreAssembly.Version.Build}"; try { Logger.Info($"Initializing WakaTime v{_version}"); SettingsForm = new SettingsForm(); SettingsForm.ConfigSaved += SettingsFormOnConfigSaved; _wakaTimeConfigFile = new WakaTimeConfigFile(); // Make sure python is installed if (!PythonManager.IsPythonInstalled()) { var dialogResult = MessageBox.Show(@"Let's download and install Python now?", @"WakaTime requires Python", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { var url = PythonManager.PythonDownloadUrl; Downloader.DownloadPython(url, WakaTimeConstants.UserConfigDir); } else MessageBox.Show( @"Please install Python (https://www.python.org/downloads/) and restart Visual Studio to enable the WakaTime plugin.", @"WakaTime", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (!DoesCliExist() || !IsCliLatestVersion()) { try { Directory.Delete($"{WakaTimeConstants.UserConfigDir}\\wakatime-master", true); } catch { /* ignored */ } Downloader.DownloadCli(WakaTimeConstants.CliUrl, WakaTimeConstants.UserConfigDir); } GetSettings(); if (string.IsNullOrEmpty(ApiKey)) PromptApiKey(); StartListeningForWindowChanges(); Logger.Info($"Finished initializing WakaTime v{_version}"); } catch (Exception ex) { Logger.Error("Error initializing Wakatime", ex); } }
private static void InitializeAsync() { try { Logger.Info($"Initializing WakaTime v{Constants.PluginVersion}"); // Settings Form _settingsForm = new Forms.SettingsForm(); _settingsForm.ConfigSaved += SettingsFormOnConfigSaved; // Load config file Config = new ConfigFile(); // Prompt for api key if not already set if (string.IsNullOrEmpty(Config.ApiKey)) { PromptApiKey(); } try { // Make sure python is installed if (!Dependencies.IsPythonInstalled()) { Dependencies.DownloadAndInstallPython(); } if (!Dependencies.DoesCliExist() || !Dependencies.IsCliUpToDate()) { Dependencies.DownloadAndInstallCli(); } } catch (WebException ex) { Logger.Error("Are you behind a proxy? Try setting a proxy in WakaTime Settings with format https://user:pass@host:port. Exception Traceback:", ex); } catch (Exception ex) { Logger.Error("Error detecting dependencies. Exception Traceback:", ex); } // setup timer to process queued heartbeats every 8 seconds _timer.Interval = 1000 * 8; _timer.Elapsed += ProcessHeartbeats; _timer.Start(); Logger.Info($"Finished initializing WakaTime v{Constants.PluginVersion}"); } catch (Exception ex) { Logger.Error("Error Initializing WakaTime", ex); } }
public void InitializeAsync() { Logger.Log("InitializeAsync"); try { Logger.Log(string.Format("Initializing WakaTime v{0}", WakaTimeConstants.PluginVersion)); // Settings Form settingsForm = new Forms.SettingsForm(); settingsForm.ConfigSaved += settingsFormOnConfigSaved; // Load config file wakaTimeConfigFile = new WakaTimeConfigFile(); getSettings(); try { // Make sure python is installed if (!PythonManager.IsPythonInstalled()) { Downloader.DownloadAndInstallPython(); } if (!doesCliExist() || !isCliLatestVersion()) { try { Directory.Delete(Path.Combine(WakaTimeConstants.UserConfigDir, "wakatime-master"), true); } catch { /* ignored */ } Downloader.DownloadAndInstallCli(); } } catch (WebException ex) { Logger.Error("Are you behind a proxy? Try setting a proxy in WakaTime Settings with format https://user:pass@host:port. Exception Traceback:", ex, true); } if (string.IsNullOrEmpty(ApiKey)) { promptApiKey(); } // Setup event handlers AddEventHandlers(); Logger.Log(string.Format("WakaTime v{0} initialised", WakaTimeConstants.PluginVersion), true); } catch (Exception ex) { Logger.Error("Error initialising Wakatime", ex, true); } }
public void InitializeAsync() { _version = string.Format("{0}.{1}.{2}", CoreAssembly.Version.Major, CoreAssembly.Version.Minor, CoreAssembly.Version.Build); try { Logger.Info(string.Format("Initializing WakaTime v{0}", _version)); base.Initialize(); _objDte = (DTE2)GetService(typeof(DTE)); _docEvents = _objDte.Events.DocumentEvents; _windowEvents = _objDte.Events.WindowEvents; _solutionEvents = _objDte.Events.SolutionEvents; _editorVersion = _objDte.Version; _settingsForm = new SettingsForm(); _settingsForm.ConfigSaved += SettingsFormOnConfigSaved; _wakaTimeConfigFile = new WakaTimeConfigFile(); // Make sure python is installed if (!PythonManager.IsPythonInstalled()) { var dialogResult = MessageBox.Show(@"Let's download and install Python now?", @"WakaTime requires Python", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { var url = PythonManager.PythonDownloadUrl; Downloader.DownloadPython(url, WakaTimeConstants.UserConfigDir); } else MessageBox.Show( @"Please install Python (https://www.python.org/downloads/) and restart Visual Studio to enable the WakaTime plugin.", @"WakaTime", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (!DoesCliExist() || !IsCliLatestVersion()) { try { Directory.Delete(string.Format("{0}\\wakatime-master", WakaTimeConstants.UserConfigDir), true); } catch { /* ignored */ } Downloader.DownloadCli(WakaTimeConstants.CliUrl, WakaTimeConstants.UserConfigDir); } GetSettings(); if (string.IsNullOrEmpty(ApiKey)) PromptApiKey(); // 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}", _version)); } catch (Exception ex) { Logger.Error("Error initializing Wakatime", ex); } }
internal static void CommandMenuInit() { _version = string.Format("{0}.{1}.{2}", CoreAssembly.Version.Major, CoreAssembly.Version.Minor, CoreAssembly.Version.Build); try { Logger.Info(string.Format("Initializing WakaTime v{0}", _version)); _editorVersion = (int)Win32.SendMessage(PluginBase.NppData._nppHandle, NppMsg.NPPM_GETNPPVERSION, 0, 0); _settingsForm = new SettingsForm(); _settingsForm.ConfigSaved += SettingsFormOnConfigSaved; _wakaTimeConfigFile = new WakaTimeConfigFile(); var sbIniFilePath = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.NppData._nppHandle, NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath); _iniFilePath = sbIniFilePath.ToString(); if (!Directory.Exists(_iniFilePath)) Directory.CreateDirectory(_iniFilePath); Task.Run(() => { InitializeWakaTimeAsync(); }); GetSettings(); if (string.IsNullOrEmpty(ApiKey)) PromptApiKey(); // add menu item PluginBase.SetCommand(0, "Wakatime Settings", SettingsPopup, new ShortcutKey(false, false, false, Keys.None)); _idMyDlg = 0; Logger.Info(string.Format("Finished initializing WakaTime v{0}", _version)); } catch (Exception ex) { Logger.Error("Error initializing Wakatime", ex); } }
internal static void CommandMenuInit() { try { Logger.Info(string.Format("Initializing WakaTime v{0}", WakaTimeConstants.PluginVersion)); _settingsForm = new SettingsForm(); _settingsForm.ConfigSaved += SettingsFormOnConfigSaved; _wakaTimeConfigFile = new WakaTimeConfigFile(); var sbIniFilePath = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.NppData._nppHandle, NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath); GetSettings(); Task.Run(() => { InitializeWakaTimeAsync(); }); // add menu item PluginBase.SetCommand(0, "Wakatime Settings", SettingsPopup, new ShortcutKey(false, false, false, Keys.None)); _idMyDlg = 0; // prompt for api key if not already set if (string.IsNullOrEmpty(ApiKey)) PromptApiKey(); Logger.Info(string.Format("Finished initializing WakaTime v{0}", WakaTimeConstants.PluginVersion)); } catch (Exception ex) { Logger.Error("Error initializing Wakatime", ex); } }
private static void SettingsPopup() { var form = new SettingsForm(); form.ShowDialog(); }
public void InitializeAsync() { try { Logger.Info(string.Format("Initializing WakaTime v{0}", WakaTimeConstants.PluginVersion)); // VisualStudio Object objDte = (DTE2)GetService(typeof(DTE)); _docEvents = objDte.Events.DocumentEvents; _windowEvents = objDte.Events.WindowEvents; _solutionEvents = objDte.Events.SolutionEvents; // Settings Form _settingsForm = new SettingsForm(); _settingsForm.ConfigSaved += SettingsFormOnConfigSaved; // Load config file _wakaTimeConfigFile = new WakaTimeConfigFile(); GetSettings(); try { // Make sure python is installed if (!PythonManager.IsPythonInstalled()) { Downloader.DownloadAndInstallPython(); } if (!DoesCliExist() || !IsCliLatestVersion()) { Downloader.DownloadAndInstallCli(); } } catch (System.Net.WebException ex) { Logger.Error("Are you behind a proxy? Try setting a proxy in WakaTime Settings with format https://user:pass@host:port. Exception Traceback:", ex); } catch (Exception ex) { Logger.Error("Error detecting dependencies. Exception Traceback:", ex); } if (string.IsNullOrEmpty(ApiKey)) PromptApiKey(); // 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); } }
public void InitializeAsync() { try { Logger.Info(string.Format("Initializing WakaTime v{0}", Constants.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 (!Dependencies.IsPythonInstalled()) { Dependencies.DownloadAndInstallPython(); } if (!Dependencies.DoesCliExist() || !Dependencies.IsCliUpToDate()) { Dependencies.DownloadAndInstallCli(); } } catch (WebException ex) { Logger.Error("Are you behind a proxy? Try setting a proxy in WakaTime 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; // setup timer to process queued heartbeats every 8 seconds timer.Interval = 1000 * 8; timer.Elapsed += ProcessHeartbeats; timer.Start(); Logger.Info(string.Format("Finished initializing WakaTime v{0}", Constants.PluginVersion)); } catch (Exception ex) { Logger.Error("Error Initializing WakaTime", ex); } }
protected override void Initialize() { _version = string.Format("{0}.{1}.{2}", CoreAssembly.Version.Major, CoreAssembly.Version.Minor, CoreAssembly.Version.Build); try { Logger.Debug(string.Format("Initializing WakaTime v{0}", _version)); base.Initialize(); _objDte = (DTE2)GetService(typeof(DTE)); _docEvents = _objDte.Events.DocumentEvents; _windowEvents = _objDte.Events.WindowEvents; _solutionEvents = _objDte.Events.SolutionEvents; _editorVersion = _objDte.Version; _settingsForm = new SettingsForm(); _settingsForm.ConfigSaved += SettingsFormOnConfigSaved; _wakaTimeConfigFile = new WakaTimeConfigFile(); // Make sure python is installed if (!PythonManager.IsPythonInstalled()) { var url = PythonManager.GetPythonDownloadUrl(); Downloader.DownloadPython(url, WakaTimeConstants.UserConfigDir); } if (!DoesCliExist() || !IsCliLatestVersion()) { try { Directory.Delete(string.Format("{0}\\wakatime-master", WakaTimeConstants.UserConfigDir), true); } catch { /* ignored */ } Downloader.DownloadCli(WakaTimeConstants.CliUrl, WakaTimeConstants.UserConfigDir); } GetSettings(); if (string.IsNullOrEmpty(ApiKey)) PromptApiKey(); // 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}", _version)); } catch (Exception ex) { Logger.Error("Error initializing Wakatime", ex); } }
internal static void CommandMenuInit() { _version = string.Format("{0}.{1}.{2}", CoreAssembly.Version.Major, CoreAssembly.Version.Minor, CoreAssembly.Version.Build); try { Logger.Info(string.Format("Initializing WakaTime v{0}", _version)); _editorVersion = (int)Win32.SendMessage(PluginBase.NppData._nppHandle, NppMsg.NPPM_GETNPPVERSION, 0, 0); _settingsForm = new SettingsForm(); _settingsForm.ConfigSaved += SettingsFormOnConfigSaved; _wakaTimeConfigFile = new WakaTimeConfigFile(); var sbIniFilePath = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.NppData._nppHandle, NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath); _iniFilePath = sbIniFilePath.ToString(); if (!Directory.Exists(_iniFilePath)) Directory.CreateDirectory(_iniFilePath); // Make sure python is installed if (!PythonManager.IsPythonInstalled()) { var url = PythonManager.PythonDownloadUrl; Downloader.DownloadPython(url, WakaTimeConstants.UserConfigDir); } if (!DoesCliExist() || !IsCliLatestVersion()) { try { Directory.Delete(string.Format("{0}\\wakatime-master", WakaTimeConstants.UserConfigDir), true); } catch { /* ignored */ } Downloader.DownloadCli(WakaTimeConstants.CliUrl, WakaTimeConstants.UserConfigDir); } GetSettings(); if (string.IsNullOrEmpty(ApiKey)) PromptApiKey(); // add menu item PluginBase.SetCommand(0, "Wakatime Settings", SettingsPopup, new ShortcutKey(false, false, false, Keys.None)); _idMyDlg = 0; Logger.Info(string.Format("Finished initializing WakaTime v{0}", _version)); } catch (Exception ex) { Logger.Error("Error initializing Wakatime", ex); } }