Skip to content

Commit

Permalink
issue #50: Bind radio buttons to view so we can toggle associated fields
Browse files Browse the repository at this point in the history
  • Loading branch information
lbross committed Apr 1, 2024
1 parent 5ed79c2 commit bd438df
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
20 changes: 10 additions & 10 deletions bagis-pro/DockAdminTools.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -313,21 +313,21 @@
<TextBox Width ="25" Height="20" Text="{Binding FireIncrementYears}"/>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Row="1" VerticalAlignment="Center">
<RadioButton GroupName="timePeriod" Margin="0, 0, 0, 4">Calculate all time periods (1981-2023)</RadioButton>
<RadioButton GroupName="timePeriod" Margin="0, 0, 0, 2">Calculate selected time periods</RadioButton>
<RadioButton GroupName="timePeriod" Tag ="AllTimeChecked" Margin="0, 0, 0, 4" IsChecked="{Binding AllTimeChecked}">Calculate all time periods (1981-2023)</RadioButton>
<RadioButton GroupName="timePeriod" Tag ="SelectedTimeChecked" Margin="0, 0, 0, 2" IsChecked="{Binding SelectedTimeChecked}" Checked="SelectedTime_Checked" Unchecked="SelectedTime_Checked">Calculate selected time periods</RadioButton>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Row="2" Margin="10, 0, 0, 0">
<DockPanel HorizontalAlignment="Left" >
<CheckBox Content="Annual (from " Margin="0, 0, 0, 0" VerticalAlignment="Center"></CheckBox>
<TextBox Width ="40" Height="20" Margin="0, 0, 0, 0">1981</TextBox>
<Label Content="to" Margin="0, 0, 0, 0"/>
<TextBox Width ="40" Height="20" Margin="0, 0, 0, 0">2023</TextBox>
<Label Content=")" Margin="0, 0, 0, 0"/>
<CheckBox x:Name="ckAnnual" Content="Annual (from " Margin="0, 0, 0, 0" IsEnabled="False" VerticalAlignment="Center" />
<TextBox x:Name="tbSelectMinYear" Width ="40" Height="20" IsEnabled="False" Margin="0, 0, 0, 0" >1981</TextBox>
<Label Content="to" Margin="0, 0, 0, 0" />
<TextBox x:Name="tbSelectMaxYear" Width ="40" Height="20" IsEnabled="False" Margin="0, 0, 0, 0" >2023</TextBox>
<Label Content=")" Margin="0, 0, 0, 0" />
</DockPanel>
<DockPanel HorizontalAlignment="Left">
<CheckBox Content="Time periods (the most recent " VerticalAlignment="Center"></CheckBox>
<TextBox Width ="25" Height="20" Text="{Binding FireIncrementYears}"/>
<Label Content="periods)" Margin="0, 0, 0, 0"/>
<CheckBox x:Name="ckPeriods" Content="Time periods (the most recent " VerticalAlignment="Center" IsEnabled="False"/>
<TextBox x:Name="tbIncrementYears" Width ="25" Height="20" Text="{Binding FireIncrementYears}" IsEnabled="False"/>
<Label Content="periods)" Margin="0, 0, 0, 0" />
</DockPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3">
Expand Down
15 changes: 15 additions & 0 deletions bagis-pro/DockAdminTools.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ public partial class DockAdminToolsView : UserControl
public DockAdminToolsView()
{
InitializeComponent();
}
public void SelectedTime_Checked(object s, RoutedEventArgs e)
{
var radio = s as RadioButton;
string strTag = Convert.ToString(radio.Tag);
if (strTag.Equals("SelectedTimeChecked"))
{
bool bChecked = radio.IsChecked ?? false;
ckAnnual.IsEnabled = bChecked;
tbSelectMinYear.IsEnabled = bChecked;
tbSelectMaxYear.IsEnabled = bChecked;
ckPeriods.IsEnabled = bChecked;
tbIncrementYears .IsEnabled = bChecked;
}

}
}
}
23 changes: 21 additions & 2 deletions bagis-pro/DockAdminToolsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected DockAdminToolsViewModel()
Names = new ObservableCollection<BA_Objects.Aoi>();
Names.CollectionChanged += ContentCollectionChanged;
ArchiveChecked = true;
TasksEnabled = false;
TasksEnabled = false;
}

/// <summary>
Expand Down Expand Up @@ -93,7 +93,8 @@ internal static void Show()
private int _intFireBaselineYear;
private string _strFireBaseYearLabel;
private int _intFireIncrementYears;

private bool _bAllTimeChecked = true; //Default
private bool _bSelectedTimeChecked = false;

public string Heading
{
Expand Down Expand Up @@ -331,6 +332,24 @@ public int FireIncrementYears
}
}

public bool AllTimeChecked
{
get { return _bAllTimeChecked; }
set
{
SetProperty(ref _bAllTimeChecked, value, () => AllTimeChecked);
}
}

public bool SelectedTimeChecked
{
get { return _bSelectedTimeChecked; }
set
{
SetProperty(ref _bSelectedTimeChecked, value, () => SelectedTimeChecked);
}
}

public ObservableCollection<BA_Objects.Aoi> Names { get; set; }

// Assigns the propertyChanged event handler to each AOI item
Expand Down

0 comments on commit bd438df

Please sign in to comment.