private void InitializeAsync()
        {
            try
            {
                // VisualStudio Object
                _docEvents      = ObjDte.Events.DocumentEvents;
                _windowEvents   = ObjDte.Events.WindowEvents;
                _solutionEvents = ObjDte.Events.SolutionEvents;

                // Settings Form
                _settingsForm              = new SettingsForm(ref WakaTime);
                _settingsForm.ConfigSaved += SettingsFormOnConfigSaved;

                // Add our command handlers for menu (commands must exist in the .vsct file)
                if (GetService(typeof(IMenuCommandService)) is OleMenuCommandService mcs)
                {
                    // 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;

                WakaTime.InitializeAsync();
            }
            catch (Exception ex)
            {
                WakaTime.Logger.Error("Error Initializing WakaTime", ex);
            }
        }
Exemplo n.º 2
0
        private void InitializeAsync()
        {
            try
            {
                // Settings Form
                SettingsForm              = new SettingsForm(ref WakaTime);
                SettingsForm.ConfigSaved += SettingsFormOnConfigSaved;

                // setup event handlers
                Application.PresentationBeforeClose += ApplicationOnPresentationBeforeClose;
                Application.PresentationOpen        += ApplicationOnPresentationOpen;
                Application.PresentationSave        += ApplicationOnPresentationSave;
                Application.WindowActivate          += ApplicationOnWindowActivate;
                Application.SlideShowBegin          += ApplicationOnSlideShowBegin;
                Application.SlideShowEnd            += ApplicationOnSlideShowEnd;
                Application.SlideShowOnNext         += ApplicationOnSlideShowOnNext;
                Application.SlideShowOnPrevious     += ApplicationOnSlideShowOnPrevious;

                WakaTime.InitializeAsync();
            }
            catch (Exception ex)
            {
                WakaTime.Logger.Error("Error Initializing WakaTime", ex);
            }
        }
Exemplo n.º 3
0
        private async Task InitializeAsync(CancellationToken cancellationToken)
        {
            if (_dte is null)
            {
                _logger.Error("DTE is null");
                return;
            }

            try
            {
                await _wakatime.InitializeAsync();

                // When initialized asynchronously, the current thread may be a background thread at this point.
                // Do any initialization that requires the UI thread after switching to the UI thread.
                await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

                // Visual Studio Events
                _docEvents        = _dte.Events.DocumentEvents;
                _windowEvents     = _dte.Events.WindowEvents;
                _solutionEvents   = _dte.Events.SolutionEvents;
                _debuggerEvents   = _dte.Events.DebuggerEvents;
                _buildEvents      = _dte.Events.BuildEvents;
                _textEditorEvents = _dte.Events.TextEditorEvents;

                // Settings Form
                _settingsForm = new SettingsForm(_wakatime.Config, _logger);

                // Add our command handlers for menu (commands must exist in the .vsct file)
                if (await GetServiceAsync(typeof(IMenuCommandService)) is OleMenuCommandService mcs)
                {
                    // Create the command for the menu item.
                    var menuCommandId = new CommandID(new Guid(GuidList.GuidWakaTimeCmdSetString), 0x100);
                    var menuItem      = new MenuCommand(MenuItemCallback, menuCommandId);
                    mcs.AddCommand(menuItem);
                }

                // setup event handlers
                _docEvents.DocumentOpened           += DocEventsOnDocumentOpened;
                _docEvents.DocumentSaved            += DocEventsOnDocumentSaved;
                _windowEvents.WindowActivated       += WindowEventsOnWindowActivated;
                _solutionEvents.Opened              += SolutionEventsOnOpened;
                _debuggerEvents.OnEnterRunMode      += DebuggerEventsOnEnterRunMode;
                _debuggerEvents.OnEnterDesignMode   += DebuggerEventsOnEnterDesignMode;
                _debuggerEvents.OnEnterBreakMode    += DebuggerEventsOnEnterBreakMode;
                _buildEvents.OnBuildProjConfigBegin += BuildEventsOnBuildProjConfigBegin;
                _buildEvents.OnBuildProjConfigDone  += BuildEventsOnBuildProjConfigDone;
                _textEditorEvents.LineChanged       += TextEditorEventsLineChanged;
            }
            catch (Exception ex)
            {
                _logger.Error("Error Initializing WakaTime", ex);
            }
        }
Exemplo n.º 4
0
        private void InitializeAsync()
        {
            try
            {
                Task.Run(async() => await _wakatime.InitializeAsync()).Wait();

                // Visual Studio Events
                _docEvents        = _dte.Events.DocumentEvents;
                _windowEvents     = _dte.Events.WindowEvents;
                _solutionEvents   = _dte.Events.SolutionEvents;
                _debuggerEvents   = _dte.Events.DebuggerEvents;
                _buildEvents      = _dte.Events.BuildEvents;
                _textEditorEvents = _dte.Events.TextEditorEvents;

                // Settings Form
                _settingsForm = new SettingsForm(_wakatime.Config, _logger);

                // Add our command handlers for menu (commands must exist in the .vsct file)
                if (GetService(typeof(IMenuCommandService)) is OleMenuCommandService mcs)
                {
                    // Create the command for the menu item.
                    var menuCommandId = new CommandID(new Guid(GuidList.GuidWakaTimeCmdSetString), 0x100);
                    var menuItem      = new MenuCommand(MenuItemCallback, menuCommandId);
                    mcs.AddCommand(menuItem);
                }

                // setup event handlers
                _docEvents.DocumentOpened           += DocEventsOnDocumentOpened;
                _docEvents.DocumentSaved            += DocEventsOnDocumentSaved;
                _windowEvents.WindowActivated       += WindowEventsOnWindowActivated;
                _solutionEvents.Opened              += SolutionEventsOnOpened;
                _debuggerEvents.OnEnterRunMode      += DebuggerEventsOnEnterRunMode;
                _debuggerEvents.OnEnterDesignMode   += DebuggerEventsOnEnterDesignMode;
                _debuggerEvents.OnEnterBreakMode    += DebuggerEventsOnEnterBreakMode;
                _buildEvents.OnBuildProjConfigBegin += BuildEventsOnBuildProjConfigBegin;
                _buildEvents.OnBuildProjConfigDone  += BuildEventsOnBuildProjConfigDone;
                _textEditorEvents.LineChanged       += TextEditorEventsLineChanged;
            }
            catch (Exception ex)
            {
                _logger.Error("Error Initializing WakaTime", ex);
            }
        }
Exemplo n.º 5
0
        private void InitializeAsync()
        {
            try
            {
                // Settings Form
                SettingsForm              = new SettingsForm(ref WakaTime);
                SettingsForm.ConfigSaved += SettingsFormOnConfigSaved;

                // setup event handlers
                Application.WorkbookOpen      += ApplicationOnWorkbookOpen;
                Application.WorkbookAfterSave += ApplicationOnWorkbookAfterSave;
                Application.WindowActivate    += ApplicationOnWindowActivate;
                Application.WorkbookActivate  += ApplicationOnWorkbookActivate;

                WakaTime.InitializeAsync();
            }
            catch (Exception ex)
            {
                WakaTime.Logger.Error("Error Initializing WakaTime", ex);
            }
        }