Skip to content

Commit

Permalink
Next button is disabled in the wizard if the server address is null o…
Browse files Browse the repository at this point in the history
…r just a whitespace(s).
  • Loading branch information
krzysztof-lorenc committed May 13, 2019
1 parent 7d233cf commit 069e427
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
46 changes: 45 additions & 1 deletion src/Soloplan.WhatsON.GUI/Config/Wizard/WizardController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public class WizardController : INotifyPropertyChanged
/// </summary>
private ISubjectPlugin subjectPlugin;

/// <summary>
/// The proposed server address.
/// </summary>
private string proposedServerAddress;

/// <summary>
/// Is proposed address empty flag.
/// </summary>
private bool isProposedAddressEmpty;

/// <summary>
/// Initializes a new instance of the <see cref="WizardController"/> class.
/// </summary>
Expand Down Expand Up @@ -99,6 +109,30 @@ public WizardController(Window ownerWindow)
/// </summary>
public bool IsNotLastStep => !this.IsLastStep;

/// <summary>
/// Gets a value indicating whether this the next step button is enabled.
/// </summary>
/// <value>
/// <c>true</c> if the next step button is enabled; otherwise, <c>false</c>.
/// </value>
public bool IsNextStepEnabled => this.IsNotLastStep && !this.IsProposedAddressEmpty;

/// <summary>
/// Gets a value indicating whether the proposed address is empty.
/// </summary>
/// <value>
/// <c>true</c> if the proposed address is empty; otherwise, <c>false</c>.
/// </value>
public bool IsProposedAddressEmpty
{
get => this.isProposedAddressEmpty;
private set
{
this.isProposedAddressEmpty = value;
this.OnPropertyChanged(nameof(this.IsNextStepEnabled));
}
}

/// <summary>
/// Gets or sets a value indicating whether multi selection mode is active.
/// </summary>
Expand All @@ -107,7 +141,16 @@ public WizardController(Window ownerWindow)
/// <summary>
/// Gets or sets the proposed server address.
/// </summary>
public string ProposedServerAddress { get; set; }
public string ProposedServerAddress
{
get => this.proposedServerAddress;
set
{
this.proposedServerAddress = value;
this.IsProposedAddressEmpty = string.IsNullOrWhiteSpace(value);
this.OnPropertyChanged(nameof(this.IsProposedAddressEmpty));
}
}

/// <summary>
/// Gets a value indicating whether any project is checked.
Expand Down Expand Up @@ -318,6 +361,7 @@ private void OnPageChanged()
this.OnPropertyChanged(nameof(this.IsLastStep));
this.OnPropertyChanged(nameof(this.IsNotLastStep));
this.OnPropertyChanged(nameof(this.IsFinishEnabled));
this.OnPropertyChanged(nameof(this.IsNextStepEnabled));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Soloplan.WhatsON.GUI/Config/Wizard/WizardWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<TextBlock x:Name="StepDescription" TextWrapping="Wrap" Text="Wizard step description" VerticalAlignment="Top" DockPanel.Dock="Top" Margin="0,0,0,10" FontSize="24" FontFamily="Arial" FontWeight="SemiBold"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" DockPanel.Dock="Bottom" Margin="0,15,0,6">
<Button Margin="0,0,10,0" Click="PrevClick" IsEnabled="{Binding Path=IsNotFirstStep}" Width="90">Previous</Button>
<Button Click="NextClick" Visibility="{Binding Path=IsNotLastStep, Converter={StaticResource BoolToVis}}" Width="90">Next</Button>
<Button Click="NextClick" Visibility="{Binding Path=IsNotLastStep, Converter={StaticResource BoolToVis}}" IsEnabled="{Binding Path=IsNextStepEnabled}" Width="90">Next</Button>
<Button Click="FinishClick" Visibility="{Binding Path=IsLastStep, Converter={StaticResource BoolToVis}}" IsEnabled="{Binding Path=IsAnyProjectChecked}" Width="90">Finish</Button>
</StackPanel>
<Frame x:Name="Frame" Content="Frame" NavigationUIVisibility="Hidden"/>
Expand Down

0 comments on commit 069e427

Please sign in to comment.