private void LogTelemetryEvent(string eventName) { string tipGroupId = GroupNameLabel.Content.ToString(); TelemetryHelper.LogTelemetryEvent(VSTipHistoryManager.GetInstance(), eventName, "TipGroupId", tipGroupId, "TipId", currentTip ?? string.Empty); }
public TipOfTheDayWindow(TipCalculator tipCalculator) { InitializeComponent(); Owner = System.Windows.Application.Current.MainWindow; _tipViewModel = new TipViewModel(); this.DataContext = _tipViewModel; _tipCalculator = tipCalculator; _tipHistoryManager = tipCalculator.TipHistoryManager; _tipManager = tipCalculator.TipManager; PopulateDefaultImages(); }
public TipOfTheDayWindow(TipCalculator tipCalculator) { InitializeComponent(); Owner = Application.Current.MainWindow; _tipViewModel = new TipViewModel(); this.DataContext = _tipViewModel; _tipCalculator = tipCalculator; _tipHistoryManager = tipCalculator.TipHistoryManager; _tipManager = tipCalculator.TipManager; // Initialize UI InitializeUIComponents(); }
public static void ShowWindow() { try { // TODO: Perf optimisation: First time, use hard-coded tip. if (IsFirstTime()) { // TODO: Set nextTip to hard-coded First-Tip. // Avoid loading tip parser if user is going to close and never run it again. } _tipManager = new TipManager(); _tipHistoryManager = VSTipHistoryManager.Instance(); _tipCalculator = new TipCalculator(_tipHistoryManager, _tipManager); TipInfo nextTip = GetNewTip(); if (nextTip == null) { // There's no tip to show. Don't show the Tip of the Day window. Debug.WriteLine("Tip of the Day: There's no tip to show. Will not launch TotD dialog."); return; } // We have a tip! Let's create the Tip of the Day UI. TipOfTheDayWindow tipOfTheDayWindow = new TipOfTheDayWindow(_tipCalculator); // Attempt to navigate to the chose tip var success = tipOfTheDayWindow.NavigateToTip(nextTip); if (!success) { // Failed to navigate to tip URI Debug.WriteLine("Tip of the Day: Failed to navigate to tip URI. Will not launch TotD dialog."); return; } // Now show the dialog tipOfTheDayWindow.Show(); // Mark tip as seen _tipHistoryManager.MarkTipAsSeen(nextTip.globalTipId); } catch (Exception e) { // Fail gracefully when window will now show Debug.WriteLine("Unable to open Tip of the Day: " + e.Message); return; } }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { _vsSolution = await GetServiceAsync(typeof(SVsSolution)) as IVsSolution; // 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 this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); await TipOfTheDayCommand.InitializeAsync(this); var initializedHistoryManager = VSTipHistoryManager.GetInstance(); // Hook up to solution events, so that the tip appears when the solution loads _vsSolution.AdviseSolutionEvents(new SolutionEventHandler(), out _solutionEventCookie); }
public TipCalculator(VSTipHistoryManager tipHistoryManager, ITipManager tipManager = null) { TipHistoryManager = tipHistoryManager; TipManager = tipManager ?? new TipManager(); }
public int OnAfterOpenSolution(object pUnkReserved, int fNewSolution) { VSTipHistoryManager.GetInstance().HandleSolutionOpened(); return(VSConstants.S_OK); }
public static ITipHistoryManager GetInstance() { return(_instance ?? (_instance = new VSTipHistoryManager())); }