public void TestHeaderLabelEnabledWhen_WizardStepTextSet() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); SetWizardControlSize(wizardControl); wizardControl.Start(); //--------------Assert PreConditions---------------- Assert.AreEqual("ControlForStep1", wizardControl.CurrentControl.Name); //Assert.IsFalse(wizardControl.HeadingLabel.Visible); //Assert.AreEqual(wizardControl.Height - wizardControl.NextButton.Height - 62, wizardControl.WizardStepPanel.Height); //---------------Execute Test ---------------------- wizardControl.Next(); //---------------Test Result ----------------------- IWizardStep currentStep = wizardController.GetCurrentStep(); Assert.AreEqual("ControlForStep2", wizardControl.CurrentControl.Name); Assert.AreSame(currentStep, wizardControl.CurrentControl); Assert.IsTrue(((IWizardStepStub)currentStep).IsInitialised); //Assert.IsTrue(wizardControl.HeadingLabel.Visible); //Assert.IsTrue(wizardControl.HeadingLabel.Text.Length > 0); //Assert.AreEqual(step.HeaderText, wizardControl.HeadingLabel.Text); //Assert.AreEqual(wizardControl.Height - wizardControl.NextButton.Height - 62 - wizardControl.HeadingLabel.Height, wizardControl.WizardStepPanel.Height); }
public void Test_Previous_ShouldCallUndoMoveOnForPreviousStep() { //---------------Set up test pack------------------- WizardController controller = new WizardController(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(controller); var step1 = CreateWizardStepStub(); controller.AddStep(step1); var step2 = CreateWizardStepStub(); controller.AddStep(step2); step1.AllowMoveOn = true; step2.AllowMoveBack = true; controller.GetFirstStep(); controller.GetNextStep(); //---------------Assert Precondition---------------- Assert.IsTrue(controller.CanMoveBack()); Assert.AreSame(step2, controller.GetCurrentStep()); Assert.IsFalse(step1.UndoMoveOnWasCalled); Assert.IsFalse(step2.UndoMoveOnWasCalled); //---------------Execute Test ---------------------- wizardControl.Previous(); //---------------Test Result ----------------------- Assert.AreSame(step1, controller.GetCurrentStep()); Assert.IsTrue(step1.UndoMoveOnWasCalled); Assert.IsFalse(step2.UndoMoveOnWasCalled); }
public void Test_PreviousButtonDisabledIfCanMoveBackFalse_FromPreviousTep() { //TODO: setup with 3 steps set step 2 allow move back false //and go next next next previous and then ensure that canMoveBack false //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); wizardController.ForTestingAddWizardStep(CreateWizardStepStub()); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.ControlForStep2.AllowMoveBack = false; wizardControl.Start(); //---------------Assert Preconditions ---------------------- Assert.IsFalse(wizardController.ControlForStep2.CanMoveBack()); //---------------Execute Test ---------------------- wizardControl.Next(); wizardControl.Next(); wizardControl.Previous(); //---------------Assert result ----------------------- Assert.AreSame(wizardControl.CurrentControl, wizardController.ControlForStep2); Assert.IsFalse(((IWizardStepStub)wizardControl.CurrentControl).AllowMoveBack); Assert.IsFalse(wizardControl.PreviousButton.Enabled); }
public void Test_Previous_WhenLastStep_WhenNotCanFinishOnSecondStep_ShouldEnableNextButtonAndDisableFinishButton() { //---------------Set up test pack------------------- IWizardControllerSpy controller = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(controller); var step1 = controller.ControlForStep1; var step2 = controller.ControlForStep2; var step3 = controller.ControlForStep3; step1.AllowMoveOn = true; step3.AllowMoveBack = true; step2.AllowFinish = false; controller.GetFirstStep(); MoveToLastStep(wizardControl); //---------------Assert Precondition---------------- Assert.IsTrue(controller.CanMoveBack()); Assert.AreSame(step3, controller.GetCurrentStep()); Assert.IsFalse(step2.CanFinish()); Assert.IsTrue(controller.IsLastStep(), "Should be last step"); Assert.IsTrue(wizardControl.FinishButton.Enabled, "Last step so finish enabled"); Assert.IsFalse(wizardControl.NextButton.Enabled, "last step so next disabled"); //---------------Execute Test ---------------------- wizardControl.Previous(); //---------------Test Result ----------------------- Assert.IsFalse(controller.IsLastStep(), "Should be last step"); Assert.AreSame(step2, controller.GetCurrentStep()); Assert.IsFalse(wizardControl.FinishButton.Enabled, "Not Last step and CanFinish False so finish disabled"); Assert.IsTrue(wizardControl.NextButton.Enabled, "Not last step so Next Enabled"); }
public WizardHandler(IWizardControl[] pages) { m_form = new Dialog(); m_form.Title = Strings.WizardHandler.WizardFormTitle; #if DEBUG m_form.Title += " (DEBUG)"; #endif m_form.Pages.Clear(); if (pages == null || pages.Length == 0) { long count = 0; lock (Program.MainLock) count = Program.DataConnection.GetObjects<Schedule>().Length; if (count == 0) m_form.Pages.AddRange(new IWizardControl[] { new Wizard_pages.FirstLaunch() }); else m_form.Pages.AddRange(new IWizardControl[] { new Wizard_pages.MainPage() }); } else m_form.Pages.AddRange(pages); m_form.DefaultImage = Properties.Resources.Duplicati; m_form.Dialog.Icon = Properties.Resources.TrayNormal; m_form.Finished += new System.ComponentModel.CancelEventHandler(m_form_Finished); }
public void TestHeaderLabelDisabledWhen_WizardStepTextSetBackToNull() { // this test doesn't do what it says?! //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); SetWizardControlSize(wizardControl); wizardControl.Start(); wizardControl.Next(); //--------------Assert PreConditions---------------- wizardController.GetCurrentStep(); Assert.AreEqual("ControlForStep2", wizardControl.CurrentControl.Name); //Assert.IsTrue(wizardControl.HeadingLabel.Visible); //removed the label and am now putting the header on the form // due to problems with giz hiding the some wizard controls that where double clicked //Assert.IsTrue(wizardControl.HeadingLabel.Text.Length > 0); //Assert.AreEqual(step.HeaderText, wizardControl.HeadingLabel.Text); //Assert.AreEqual(wizardControl.Height - wizardControl.NextButton.Height - 62 - wizardControl.HeadingLabel.Height, wizardControl.WizardStepPanel.Height); //---------------Execute Test ---------------------- wizardControl.Previous(); //---------------Test Result ----------------------- wizardController.GetCurrentStep(); Assert.AreEqual("ControlForStep1", wizardControl.CurrentControl.Name); //Assert.IsFalse(wizardControl.HeadingLabel.Visible); //Assert.IsFalse(wizardControl.HeadingLabel.Text.Length > 0); //Assert.AreEqual(step.HeaderText, wizardControl.HeadingLabel.Text); //Assert.AreEqual(wizardControl.Height - wizardControl.NextButton.Height - 62, wizardControl.WizardStepPanel.Height); }
public RawContainer(IWizardControl nextpage, Library.Interface.IBackend backend, IDictionary<string, string> settings) : base(nextpage, backend.SupportedCommands, settings, "backend:" + backend.ProtocolKey, backend.DisplayName, backend.Description) { InitializeComponent(); m_backend = backend; ProtocolKey.Text = m_backend.ProtocolKey + "://"; }
///<summary> /// Create a wizard control manager with the wizard control it is managing ///</summary> ///<param name="wizardControl"></param> ///<exception cref="ArgumentNullException"></exception> public WizardControlManager(IWizardControl wizardControl) { if (wizardControl == null) { throw new ArgumentNullException("wizardControl"); } WizardControl = wizardControl; }
public PageOne(SharedViewModel viewModel, IWizardControl wizardControl) { InitializeComponent(); ViewModel = viewModel; _wizardControl = wizardControl; }
public GUIContainer(IWizardControl nextpage, Library.Interface.IGUIControl @interface) : this() { m_autoFillValues = false; m_interface = @interface; m_nextpage = nextpage; base.PageEnter += new PageChangeHandler(GUIContainer_PageEnter); base.PageLeave += new PageChangeHandler(GUIContainer_PageLeave); }
private int GetControlIndex(IWizardControl control) { int i=0; foreach (IWizardControl item in _parent.ListControls) { if (item == control) return i; i++; } throw new ArgumentOutOfRangeException("control"); }
public void TestStart() { //Setup ----------------------------------------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); //Execute --------------------------------------------------- wizardControl.Start(); //Assert Results -------------------------------------------- Assert.AreEqual("ControlForStep1", wizardControl.CurrentControl.Name); Assert.AreEqual(wizardController.ControlForStep1.Name, wizardControl.CurrentControl.Name); }
public void Test_NextPreviousIn_theCorrectOrder() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); //--------------Assert PreConditions---------------- //---------------Execute Test ---------------------- IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); //---------------Test Result ----------------------- Assert.Less(wizardControl.NextButton.Left, wizardControl.PreviousButton.Left); //---------------Tear Down ------------------------- }
public string GetDescription(IWizardControl ctrl) { if (null == ctrl) { return("<Error>"); } string name = ctrl.GetType().Name; name = name.Substring(0, name.Length - "Control".Length); name += "Description"; string result = _thisType.InvokeMember(name, System.Reflection.BindingFlags.GetProperty, null, this, null) as string; return(result); }
public void Test_SetWizardController_CallsStart() { //Setup ---------------------------------------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(_controller); wizardControl.Width = 300; //Execute --------------------------------------------------- wizardControl.WizardController = wizardController; //Assert Results -------------------------------------------- Assert.AreEqual("ControlForStep1", wizardControl.CurrentControl.Name); Assert.AreEqual(wizardController.ControlForStep1.Name, wizardControl.CurrentControl.Name); Assert.AreEqual(0, wizardControl.PreviousButton.TabIndex); Assert.AreEqual(1, wizardControl.NextButton.TabIndex); }
public void Test_WizardControllerCancelsWizardSteps() { //---------------Set up test pack------------------- WizardController wizardController = new WizardController(); IWizardStep wzrdStep = MockRepository.GenerateMock <IWizardStep>(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.AddStep(wzrdStep); //--------------Assert PreConditions---------------- wzrdStep.AssertWasNotCalled(step => step.CancelStep()); //---------------Execute Test ---------------------- wizardControl.CancelButton.PerformClick(); //---------------Test Result ----------------------- wzrdStep.AssertWasCalled(step => step.CancelStep()); }
/// <summary> /// Initializes a new GridContainer wizard page /// </summary> /// <param name="nextpage">The page to activate for the next button</param> /// <param name="commands">The list of supported commands</param> /// <param name="options">The list of saved options, if any</param> /// <param name="key">The item key, used to differentiate between different instances of the setup</param> /// <param name="displayname">The displayname for the page</param> /// <param name="description">The description for the page</param> public GridContainer(IWizardControl nextpage, IList <Library.Interface.ICommandLineArgument> commands, IDictionary <string, string> options, string key, string displayname, string description) : this() { m_autoFillValues = false; m_commands = commands; m_options = options; m_tablekey = "GridContainer:Table:" + key; m_cachekey = "GridContainer:Cache:" + key; m_displayname = displayname; m_description = description; m_nextpage = nextpage; base.PageEnter += new PageChangeHandler(GridContainer_PageEnter); base.PageLeave += new PageChangeHandler(GridContainer_PageLeave); }
/// <summary> /// Initializes a new GridContainer wizard page /// </summary> /// <param name="nextpage">The page to activate for the next button</param> /// <param name="commands">The list of supported commands</param> /// <param name="options">The list of saved options, if any</param> /// <param name="key">The item key, used to differentiate between different instances of the setup</param> /// <param name="displayname">The displayname for the page</param> /// <param name="description">The description for the page</param> public GridContainer(IWizardControl nextpage, IList<Library.Interface.ICommandLineArgument> commands, IDictionary<string, string> options, string key, string displayname, string description) : this() { m_autoFillValues = false; m_commands = commands; m_options = options; m_tablekey = "GridContainer:Table:" + key; m_cachekey = "GridContainer:Cache:" + key; m_displayname = displayname; m_description = description; m_nextpage = nextpage; base.PageEnter += new PageChangeHandler(GridContainer_PageEnter); base.PageLeave += new PageChangeHandler(GridContainer_PageLeave); }
public void Test_Next_ShouldCallWizardControllerNext() { //---------------Set up test pack------------------- IWizardController controller = MockRepository.GenerateMock <IWizardController>(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(controller); string message; controller.Stub(wizardController => wizardController.CanMoveOn(out message)).Return(true); controller.Stub(controller1 => controller1.GetNextStep()).Return(CreateWizardStepStub()); //---------------Assert Precondition---------------- Assert.IsTrue(controller.CanMoveOn(out message)); controller.AssertWasNotCalled(cntrler => cntrler.CompleteCurrentStep()); //---------------Execute Test ---------------------- wizardControl.Next(); //---------------Test Result ----------------------- controller.AssertWasCalled(cntrler => cntrler.CompleteCurrentStep()); }
public void Test_FinishButton_WhenAtLastStep_ShouldBeEnabled() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.ControlForStep3.AllowFinish = true; wizardControl.Start(); wizardControl.Next(); wizardControl.Next(); //---------------Assert Preconditions ---------------------- Assert.IsTrue(wizardController.IsLastStep()); //---------------Execute Test ---------------------- wizardControl.Finish(); //---------------Test Result ----------------------- Assert.IsTrue(wizardControl.FinishButton.Enabled); }
public void Test_FinishButton_WhenCanFinishTrue_ShouldBeEnabled() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.ControlForStep2.AllowFinish = true; wizardControl.Start(); //---------------Assert Preconditions ---------------------- Assert.IsTrue(wizardController.ControlForStep2.AllowFinish); Assert.IsTrue(wizardController.ControlForStep2.CanFinish()); //---------------Execute Test ---------------------- wizardControl.Next(); //---------------Assert result ----------------------- Assert.AreSame(wizardControl.CurrentControl, wizardController.ControlForStep2); Assert.IsTrue(wizardControl.FinishButton.Enabled, "Finish button should be enabled"); }
public void Test_NextClickAtLastStep_WhenCanMoveOnfalse_DoesNotFinish() { //---------------Set up test pack------------------- IWizardControllerSpy controller = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(controller);// new WizardControl(_controller); controller.ControlForStep1.AllowMoveOn = true; controller.ControlForStep2.AllowMoveOn = false; wizardControl.Start(); wizardControl.NextButton.PerformClick(); //---------------Execute Test ---------------------- wizardControl.NextButton.PerformClick(); //---------------Test Result ----------------------- // Finish should not have been called because CanMoveOn on step two is returning false and should prevent // the wizard from finishing. Assert.IsFalse(controller.FinishWizardWasCalled); }
public void TestFinishButton_WhenClicked_WhenCanMoveOn_ShouldFireFinishEvent() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.AllowCanMoveOn = true; wizardControl.Start(); //--------------Assert PreConditions---------------- Assert.IsFalse(wizardController.FinishWizardWasCalled); string message; Assert.IsTrue(wizardController.CanMoveOn(out message)); //---------------Execute Test ---------------------- wizardControl.Finish(); //---------------Test Result ----------------------- Assert.IsTrue(wizardController.FinishWizardWasCalled, "Finish should be called"); }
public void Test_PreviousButtonDisabledIfCanMoveBackFalse() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.ControlForStep2.AllowMoveBack = false; wizardControl.Start(); //---------------Assert Preconditions ---------------------- Assert.IsFalse(wizardController.ControlForStep2.CanMoveBack()); //---------------Execute Test ---------------------- wizardControl.Next(); //---------------Assert result ----------------------- Assert.AreSame(wizardControl.CurrentControl, wizardController.ControlForStep2); Assert.IsFalse(((IWizardStepStub)wizardControl.CurrentControl).AllowMoveBack); Assert.IsFalse(wizardControl.PreviousButton.Enabled); }
private void SetActiveControl(IWizardControl control) { try { foreach (Control item in panelControls.Controls) item.Visible = false; (control as Control).Visible = true; _currentControl = control ; nextButton.Enabled = false; backButton.Enabled = !IsFirstControl(_currentControl); if (IsLastControl(_currentControl)) { finishButton.Location = nextButton.Location; nextButton.Visible = false; finishButton.Visible = true; } else { nextButton.Visible = true; finishButton.Visible = false; } (_currentControl as IWizardControl).Translate(); (_currentControl as IWizardControl).Activate(); labelCaption.Text = (_currentControl as IWizardControl).Caption; labelDescription.Text = (_currentControl as IWizardControl).Description; if ((_currentControl as IWizardControl).Image == ImageType.Question) imageBox.Image = imageListIcons.Images[0]; else imageBox.Image = imageListIcons.Images[1]; nextButton.Enabled = (_currentControl as IWizardControl).IsReadyForNextStep; if (CurrentLanguageID == 1031) labelCurrentStep.Text = string.Format("Schritt {0} von {1}", GetControlIndex(_currentControl) + 1, IsAddinProject == true ? _listControls.Count : _listControls.Count - 2); else labelCurrentStep.Text = string.Format("Step {0} of {1}", GetControlIndex(_currentControl) + 1, IsAddinProject == true ? _listControls.Count : _listControls.Count - 2); labelCurrentStep.Tag = new string[] { (GetControlIndex(_currentControl) + 1).ToString(), _listControls.Count.ToString() }; (_currentControl as IWizardControl).ReadyStateChanged += new ReadyStateChangedHandler(currentControl_ReadyStateChanged); } catch (Exception ex) { MessageBox.Show("SetActiveControl " + ex.Message); } }
private bool IsFirstControl(IWizardControl control) { return (_listControls[0] == control); }
private bool IsLastControl(IWizardControl control) { return (_listControls[_listControls.Count - 1] == control); }
private void Reset() { while (panelControls.Controls.Count > 0) panelControls.Controls.RemoveAt(0); _listControls.Clear(); if (null != _currentControl) { IWizardControl control = _currentControl as IWizardControl; control.ReadyStateChanged -= new ReadyStateChangedHandler(currentControl_ReadyStateChanged); _currentControl = null; } panelHint.Visible = true; panelWizardHost.Visible = false; }
protected void Page_Load(object sender, System.EventArgs e) { iconIBN.Href = Page.ResolveUrl("~/portal.ico"); RegisterScripts(); btnNext.Attributes.Add("onclick", "DisableButtons(this);"); if (ControlName != null || ControlName != String.Empty) { _wizard = (IWizardControl)LoadControl(ControlName); phControl.Controls.Add((Control)_wizard); } if (!IsPostBack) { BindGloabalValues(); // BindCurrentData(); } }
protected virtual void DisplayPage(IWizardControl page) { PageChangedArgs args = new PageChangedArgs(this, this.Pages.IndexOf(page) == this.Pages.Count - 1, m_isBack ? PageChangedDirection.Back : PageChangedDirection.Next); page.Control.Visible = false; page.Enter(this, args); InfoPanel.Visible = !page.FullSize; TitleLabel.Text = page.Title; InfoLabel.Text = page.HelpText; PageIcon.Image = page.Image == null ? DefaultImage : page.Image; ContentPanel.Controls.Clear(); ContentPanel.Controls.Add(page.Control); page.Control.Dock = DockStyle.Fill; m_isLastPage = args.TreatAsLast; //Not sure this works under Mono... //TODO: The scaling sucks... /*try { this.Icon = System.Drawing.Icon.FromHandle(new System.Drawing.Bitmap(PageIcon.Image).GetHicon()); } catch { }*/ UpdateButtons(); page.Control.Visible = true; page.Display(this, args); }
private void SetActiveControl(Control control) { try { foreach (Control item in panelControls.Controls) item.Visible = false; control.Visible = true; _currentControl = control as IWizardControl; nextButton.Enabled = false; backButton.Enabled = !IsFirstControl(_currentControl); if (IsLastControl(_currentControl)) { finishButton.Location = nextButton.Location; nextButton.Visible = false; finishButton.Visible = true; } else { nextButton.Visible = true; finishButton.Visible = false; } _currentControl.Translate(); _currentControl.Activate(); labelCaption.Text = _currentControl.Caption; labelDescription.Text = _currentControl.Description; if (_currentControl.Image == ImageType.Question) imageBox.Image = imageListIcons.Images[0]; else imageBox.Image = imageListIcons.Images[1]; nextButton.Enabled = _currentControl.IsReadyForNextStep; if (NetOfficeProject.TargetLanguage == TargetLanguage.German) labelCurrentStep.Text = string.Format("Schritt {0} von {1}", GetControlIndex(_currentControl) + 1, _parent.ListControls.Count); else labelCurrentStep.Text = string.Format("Step {0} of {1}", GetControlIndex(_currentControl) + 1, _parent.ListControls.Count); labelCurrentStep.Tag = new string[] { (GetControlIndex(_currentControl) + 1).ToString(), _parent.ListControls.Count.ToString()}; } catch (Exception ex) { MessageBox.Show("SetActiveControl " + ex.Message); } }
void currentControl_ReadyStateChanged(IWizardControl sender) { try { nextButton.Enabled = sender.IsReadyForNextStep; } catch (Exception exception) { ErrorDialog dialog = new ErrorDialog(exception, NetOfficeProject.TargetLanguage); dialog.ShowDialog(); } }
///<summary> /// Create a wizard control manager with the wizard control it is managing ///</summary> ///<param name="wizardControl"></param> ///<exception cref="ArgumentNullException"></exception> public WizardControlManager(IWizardControl wizardControl) { if (wizardControl == null) throw new ArgumentNullException("wizardControl"); WizardControl = wizardControl; }
public string GetDescription(IWizardControl ctrl) { if (null == ctrl) return "<Error>"; string name = ctrl.GetType().Name; name = name.Substring(0, name.Length - "Control".Length); name += "Description"; string result = _thisType.InvokeMember(name, System.Reflection.BindingFlags.GetProperty, null, this, null) as string; return result; }
private static void SetWizardControlSize(IWizardControl wizardControl) { wizardControl.Width = 500; wizardControl.Height = 412; }
private void MoveToLastStep(IWizardControl wizardControl) { wizardControl.Next(); wizardControl.Next(); }
public void SetupFixture() { _controller = CreateWizardControllerStub(); _wizardControl = GetControlFactory().CreateWizardControl(_controller);// new WizardControl(_controller); }