Пример #1
0
        public TipOfTheDayWindow(TipCalculator tipCalculator)
        {
            InitializeComponent();
            Owner = System.Windows.Application.Current.MainWindow;

            _tipCalculator     = tipCalculator;
            _tipHistoryManager = tipCalculator.TipHistoryManager;
            _tipManager        = tipCalculator.TipManager;
        }
Пример #2
0
        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();
        }
Пример #3
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;
            }
        }
Пример #4
0
 public TipCalculator(ITipHistoryManager tipHistoryManager, ITipManager tipManager = null)
 {
     TipHistoryManager = tipHistoryManager;
     TipManager        = tipManager ?? new TipManager();
 }