public MainWindow() { InitializeComponent(); DataContext = MainWindowViewModel.Instance; myTbResult.TextChanged += TbResultTextChanged; myTbPath.TextChanged += TbPathTextChanged; myCbOptions.SelectionChanged += CbOptionsSelectionChanged; var navigator = FeatureTour.GetNavigator(); navigator.OnStepEntering(ElementID.Rectangle).Execute(s => { (DataContext as MainWindowViewModel).Placement = (Placement)s.Tag; TabControl.SelectedIndex = 0; }); navigator.OnStepEntering(ElementID.TextBoxResult).Execute(s => TabControl.SelectedIndex = 1); navigator.OnStepEntering(ElementID.ButtonPushMe).Execute(s => TabControl.SelectedIndex = 2); navigator.OnStepEntering(ElementID.CustomView).Execute(s => TabControl.SelectedIndex = 3); navigator.OnStepEntered(ElementID.TextBoxResult).Execute(s => myTbResult.Focus()); navigator.OnStepEntered(ElementID.TextBoxPath).Execute(s => myTbPath.Focus()); navigator.OnStepEntered(ElementID.ComboBoxOption).Execute(s => myCbOptions.Focus()); navigator.OnStepEntered(ElementID.ButtonClear).Execute(s => myBtnClear.Focus()); }
private void CbOptionsSelectionChanged(object sender, SelectionChangedEventArgs e) { if (myCbOptions.SelectedIndex == 1) { var navigator = FeatureTour.GetNavigator(); navigator.IfCurrentStepEquals(ElementID.ComboBoxOption).GoNext(); } }
// Methods private void Clear() { Result = ""; Path = ""; SelectedIndex = 0; FeatureTour.GetNavigator() .IfCurrentStepEquals(ElementID.ButtonClear) .Close(); }
/// <summary> /// Handle special Feature Tour Navigation events /// </summary> private void InitFeatureTourNavigation() { var navigator = FeatureTour.GetNavigator(); navigator.OnStepEntering(FeatureTourElementID.AccountViewButtonSaveHardwareSettings).Execute(s => DataContext = AccountViewModel); navigator.OnStepEntering(FeatureTourElementID.AccountViewTextBoxAccountID).Execute(s => DataContext = AccountViewModel); navigator.OnStepEntering(FeatureTourElementID.AccountViewTextBoxWorkerName).Execute(s => DataContext = AccountViewModel); navigator.OnStepEntering(FeatureTourElementID.WalletViewDataGridWalletAddresses).Execute(s => DataContext = WalletViewModel); }
private void TbResultTextChanged(object sender, TextChangedEventArgs e) { var result = myTbResult.Text.Trim(); if (result == "21") { var navigator = FeatureTour.GetNavigator(); navigator.IfCurrentStepEquals(ElementID.TextBoxResult).GoNext(); } }
// .ctor private MainWindowViewModel() { var navigator = FeatureTour.GetNavigator(); navigator.ForStep(ElementID.TextBoxPath).AttachDoable(s => Path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); navigator.ForStep(ElementID.ComboBoxOption).AttachDoable(s => SelectedIndex = 1); navigator.ForStep(ElementID.TextBoxPath).AttachDoable(s => Path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); PopupStyle.PropertyChanged += (s, e) => StyleText = GetStyleText(); StyleText = GetStyleText(); }
private void TbPathTextChanged(object sender, TextChangedEventArgs e) { var path = myTbPath.Text.Trim(' ', '\\'); var expectedPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop).Trim(' ', '\\'); if (path.Equals(expectedPath, StringComparison.InvariantCultureIgnoreCase)) { var navigator = FeatureTour.GetNavigator(); navigator.IfCurrentStepEquals(ElementID.TextBoxPath).GoNext(); } }
public void OnStepDoable() { var d = new Doable(); var navigator = FeatureTour.GetNavigator(); navigator.ForStep("ID1").AttachDoable(s => d.do1++); navigator.ForStep("ID2").AttachDoable(s => d.do2++, s => true); navigator.ForStep("ID3").AttachDoable(s => d.do3++, s => false); var tour = new Tour(); tour.Steps = new[] { new Step("1", "Header1", "Content1", "ID1"), new Step("2", "Header2", "Content2", "ID2"), new Step("3", "Header3", "Content3", "ID3"), new Step("4", "Header4", "Content4", "ID4"), }; var manager = new VisualElementManagerMock(tour.Steps); var tourRun = new TourRun(tour, manager, new WindowManagerMock(), new PopupNavigatorMock()); tourRun.Start(); AssertIsDoable(d, 0, 0, 0); Assert.IsTrue(tourRun.ShowDoIt()); Assert.IsTrue(tourRun.CanDoIt()); tourRun.DoIt(); AssertIsDoable(d, 1, 0, 0); tourRun.NextStep(); Assert.IsTrue(tourRun.ShowDoIt()); Assert.IsTrue(tourRun.CanDoIt()); tourRun.DoIt(); AssertIsDoable(d, 1, 1, 0); tourRun.NextStep(); Assert.IsTrue(tourRun.ShowDoIt()); Assert.IsFalse(tourRun.CanDoIt()); tourRun.DoIt(); AssertIsDoable(d, 1, 1, 1); tourRun.NextStep(); Assert.IsFalse(tourRun.ShowDoIt()); Assert.IsFalse(tourRun.CanDoIt()); tourRun.DoIt(); AssertIsDoable(d, 1, 1, 1); }
public void TestCompleteRun_2Steps_UsingNavigator() { var navigator = FeatureTour.GetNavigator(); var tour = new Tour(); tour.Steps = new[] { new Step("1", "Header1", "Content1"), new Step("2", "Header2", "Content2"), }; var manager = new VisualElementManagerMock(tour.Steps); var windowManager = new WindowManagerMock(); var popupNavigator = new PopupNavigatorMock(); var tourRun = new TourRun(tour, manager, windowManager, popupNavigator); FeatureTour.SetTourRun(tourRun); tourRun.Start(); Assert.AreEqual(tour.Steps[0], FeatureTour.CurrentStep); Assert.IsTrue(navigator.IfCurrentStepEquals(FeatureTour.CurrentStep.ID).GoNext()); Assert.AreEqual(tour.Steps[1], FeatureTour.CurrentStep); Assert.IsFalse(navigator.IfCurrentStepEquals(FeatureTour.CurrentStep.ID).GoNext()); Assert.AreEqual(tour.Steps[1], FeatureTour.CurrentStep); Assert.IsTrue(navigator.IfCurrentStepEquals(FeatureTour.CurrentStep.ID).GoPrevious()); Assert.AreEqual(tour.Steps[0], FeatureTour.CurrentStep); Assert.IsFalse(navigator.IfCurrentStepEquals(FeatureTour.CurrentStep.ID).GoPrevious()); Assert.AreEqual(tour.Steps[0], FeatureTour.CurrentStep); Assert.IsTrue(navigator.Close()); Assert.AreEqual(null, FeatureTour.CurrentStep); AssertManagerIsClean(popupNavigator, windowManager); FeatureTour.SetCurrentRunNull(); }
public void OnStepEnteredLeavedClosed() { var c = new Counter(); var navigator = FeatureTour.GetNavigator(); navigator.OnStepEntered("ID1").Execute(s => c.entered1++); navigator.OnStepEntered("ID2").Execute(s => c.entered2++); navigator.OnStepLeft("ID1").Execute(s => c.leaved1++); navigator.OnStepLeft("ID2").Execute(s => c.leaved2++); navigator.OnClosed().Execute(s => c.closed++); var tour = new Tour(); tour.Steps = new[] { new Step("1", "Header1", "Content1", "ID1"), new Step("2", "Header2", "Content2", "ID2"), }; var manager = new VisualElementManagerMock(tour.Steps); var tourRun = new TourRun(tour, manager, new WindowManagerMock(), new PopupNavigatorMock()); AssertIsCounter(c, 0, 0, 0, 0, 0); FeatureTour.SetTourRun(tourRun); AssertIsCounter(c, 0, 0, 0, 0, 0); tourRun.Start(); AssertIsCounter(c, 1, 0, 0, 0, 0); tourRun.NextStep(); AssertIsCounter(c, 1, 1, 1, 0, 0); tourRun.PreviousStep(); AssertIsCounter(c, 2, 1, 1, 1, 0); tourRun.Close(); AssertIsCounter(c, 2, 2, 1, 1, 1); FeatureTour.SetCurrentRunNull(); }
private void ButtonMeToOnClick(object sender, RoutedEventArgs e) { var tour = FeatureTour.GetNavigator(); tour.IfCurrentStepEquals(ElementID.ButtonPushMeToo).GoNext(); }