Exemple #1
0
        //-------- Helper functions --------

        internal bool NavigateToTip(TipInfo nextTip, bool markAsSeen = true)
        {
            if (nextTip == null || string.IsNullOrEmpty(nextTip.contentUri))
            {
                // Unable to navigate. No tip content URI.
                return(false);
            }

            currentTip = nextTip.globalTipId;

            // Render the new tip content in the tip viewer
            ShowTipContent(nextTip);

            // Display Group settings
            UpdateGroupDisplayElements(nextTip);

            // Mark tip as shown
            if (markAsSeen)
            {
                _tipHistoryManager.MarkTipAsSeen(currentTip);
            }

            // Output telemetry: Tip Shown (Consider making this conditional on "markAsSeen")
            LogTelemetryEvent(TelemetryConstants.TipShownEvent);

            return(true);
        }
Exemple #2
0
        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;
            }
        }
Exemple #3
0
        //-------- Helper functions --------

        internal bool NavigateToTip(TipInfo nextTip, bool markAsSeen = true)
        {
            if (nextTip == null || string.IsNullOrEmpty(nextTip.contentUri))
            {
                // Unable to navigate. No tip content URI.
                return(false);
            }

            // Navigate to the Tip URI
            currentTip = nextTip.globalTipId;
            TipContentBrowser.Navigate(new Uri(nextTip.contentUri));

            // Mark tip as shown
            if (markAsSeen)
            {
                _tipHistoryManager.MarkTipAsSeen(nextTip.globalTipId);
            }

            return(true);
        }