-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1129 from BornToBeRoot/issue/274
Use dropdown to remove ip address to prevent user errors
- Loading branch information
Showing
6 changed files
with
150 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using NETworkManager.Utilities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Windows.Input; | ||
|
||
namespace NETworkManager.ViewModels | ||
{ | ||
public class DropdownViewModel : ViewModelBase | ||
{ | ||
public ICommand OKCommand { get; } | ||
|
||
public ICommand CancelCommand { get; } | ||
|
||
private string _valueDescription; | ||
public string ValueDescription | ||
{ | ||
get => _valueDescription; | ||
set | ||
{ | ||
if(value == _valueDescription) | ||
return; | ||
|
||
_valueDescription = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
private List<string> _values; | ||
public List<string> Values | ||
{ | ||
get => _values; | ||
set | ||
{ | ||
if (value == _values) | ||
return; | ||
|
||
_values = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
private string _selectedValue; | ||
public string SelectedValue | ||
{ | ||
get => _selectedValue; | ||
set | ||
{ | ||
if (value == _selectedValue) | ||
return; | ||
|
||
_selectedValue = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
public DropdownViewModel(Action<DropdownViewModel> okCommand, Action<DropdownViewModel> cancelHandler, List<string> values, string valueDescription) | ||
{ | ||
ValueDescription = valueDescription; | ||
Values = values; | ||
|
||
SelectedValue = Values.FirstOrDefault(); | ||
|
||
OKCommand = new RelayCommand(p => okCommand(this)); | ||
CancelCommand = new RelayCommand(p => cancelHandler(this)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<UserControl x:Class="NETworkManager.Views.DropdownDialog" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:viewModels="clr-namespace:NETworkManager.ViewModels" | ||
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters" | ||
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization" | ||
mc:Ignorable="d" Loaded="UserControl_Loaded" d:DataContext="{d:DesignInstance viewModels:DropdownViewModel}"> | ||
<UserControl.Resources> | ||
<converters:StringIsNotNullOrEmptyToBooleanConverter x:Key="StringIsNotNullOrEmptyToBooleanConverter" /> | ||
</UserControl.Resources> | ||
<Grid Margin="0,20"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="10" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<Grid Grid.Row="0"> | ||
<Grid.Resources> | ||
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource CenterTextBlock}" /> | ||
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource DefaultTextBox}" /> | ||
</Grid.Resources> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="1*" /> | ||
<ColumnDefinition Width="10" /> | ||
<ColumnDefinition Width="1*" /> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding ValueDescription}" /> | ||
<ComboBox Grid.Column="2" Grid.Row="0" ItemsSource="{Binding Values}" SelectedItem="{Binding SelectedValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> | ||
</Grid> | ||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right"> | ||
<Button Content="{x:Static localization:Strings.OK}" Command="{Binding OKCommand}" IsDefault="True" Margin="0,0,10,0"> | ||
<Button.Style> | ||
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource HighlightedButton}"> | ||
<Setter Property="IsEnabled" Value="False" /> | ||
<Style.Triggers> | ||
<MultiDataTrigger> | ||
<MultiDataTrigger.Conditions> | ||
<Condition Binding="{Binding SelectedValue, Converter={StaticResource StringIsNotNullOrEmptyToBooleanConverter}}" Value="True" /> | ||
</MultiDataTrigger.Conditions> | ||
<MultiDataTrigger.Setters> | ||
<Setter Property="IsEnabled" Value="True" /> | ||
</MultiDataTrigger.Setters> | ||
</MultiDataTrigger> | ||
</Style.Triggers> | ||
</Style> | ||
</Button.Style> | ||
</Button> | ||
<Button Content="{x:Static localization:Strings.Cancel}" Command="{Binding CancelCommand}" IsCancel="True" Style="{StaticResource DefaultButton}" /> | ||
</StackPanel> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace NETworkManager.Views | ||
{ | ||
public partial class DropdownDialog | ||
{ | ||
public DropdownDialog() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e) | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters