add functionality to change grade of combat zones in the tree
This commit is contained in:
parent
8d95a42698
commit
22396c9b22
@ -8,6 +8,12 @@
|
|||||||
xmlns:Util="clr-namespace:EliteBGS.Util" d:DataContext="{d:DesignInstance Type=Util:AppConfig}" x:Name="window" x:Class="EliteBGS.MainWindow"
|
xmlns:Util="clr-namespace:EliteBGS.Util" d:DataContext="{d:DesignInstance Type=Util:AppConfig}" x:Name="window" x:Class="EliteBGS.MainWindow"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Elite: Dangerous BGS Helper" Height="520" Width="890" Icon="EliteBGS.ico" Closing="window_Closing">
|
Title="Elite: Dangerous BGS Helper" Height="520" Width="890" Icon="EliteBGS.ico" Closing="window_Closing">
|
||||||
|
<Window.Resources>
|
||||||
|
<Style x:Key="StretchingTreeViewStyle" TargetType="TreeViewItem" BasedOn="{StaticResource {x:Type TreeViewItem}}">
|
||||||
|
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||||
|
</Style>
|
||||||
|
<local:MinusFortyFiveConverter x:Key="MinusFortyFiveConverter" />
|
||||||
|
</Window.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
@ -44,20 +50,50 @@
|
|||||||
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
|
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
|
||||||
<Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" />
|
<Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" />
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
<TreeView CheckBox.Checked="TreeView_CheckBox_Updated" CheckBox.Unchecked="TreeView_CheckBox_Updated" x:Name="entries" Margin="0,0,0,0" Grid.ColumnSpan="3" Grid.Row="2" KeyUp="entries_KeyUp">
|
<TreeView CheckBox.Checked="TreeView_CheckBox_Updated"
|
||||||
|
CheckBox.Unchecked="TreeView_CheckBox_Updated"
|
||||||
|
x:Name="entries" Margin="0,0,0,0"
|
||||||
|
Grid.ColumnSpan="3" Grid.Row="2"
|
||||||
|
KeyUp="entries_KeyUp"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
HorizontalContentAlignment="Stretch"
|
||||||
|
>
|
||||||
<TreeView.ItemTemplate>
|
<TreeView.ItemTemplate>
|
||||||
<HierarchicalDataTemplate DataType="{x:Type local:Objective}" ItemsSource="{Binding UITransactions}">
|
<HierarchicalDataTemplate DataType="{x:Type local:Objective}" ItemsSource="{Binding UITransactions}" ItemContainerStyle="{StaticResource StretchingTreeViewStyle}">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
|
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
|
||||||
<TextBlock Text="{Binding Name}" Margin="5,0" />
|
<TextBlock Text="{Binding Name}" Margin="5,0" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<HierarchicalDataTemplate.ItemTemplate>
|
<HierarchicalDataTemplate.ItemTemplate>
|
||||||
<HierarchicalDataTemplate>
|
<HierarchicalDataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<!-- This will stretch out the width of the item-->
|
||||||
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
|
<Grid Initialized="Transaction_Initialized"
|
||||||
<TextBlock Text="{Binding CompletedAt}" Margin="5,0,5,0" HorizontalAlignment="Right"/>
|
HorizontalAlignment="Stretch"
|
||||||
<TextBlock Text="{Binding Name}" FontWeight="DemiBold"/>
|
Width="{Binding ActualWidth, ElementName=entries, Converter={StaticResource MinusFortyFiveConverter}}"
|
||||||
</StackPanel>
|
>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
|
||||||
|
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
|
||||||
|
<TextBlock Text="{Binding CompletedAt}" Margin="5,0,5,0" HorizontalAlignment="Right" TextAlignment="Center"/>
|
||||||
|
<TextBlock Text="{Binding Name}" FontWeight="DemiBold" TextAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
|
<Separator Visibility="Hidden" Grid.Column="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" />
|
||||||
|
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" x:Name="CombatZone">
|
||||||
|
<Button x:Name="Low" Content="Low" Click="Low_Click"/>
|
||||||
|
<Separator Margin="2,0,2,0" VerticalAlignment="Top"/>
|
||||||
|
<Button Content="Med" x:Name="Med" Click="Med_Click" />
|
||||||
|
<Separator Margin="2,0,2,0" VerticalAlignment="Top"/>
|
||||||
|
<Button Content="High" x:Name="High" Click="High_Click"/>
|
||||||
|
<Separator Margin="2,0,2,0" VerticalAlignment="Top"/>
|
||||||
|
<Button Content="On Foot" x:Name="OnFoot" Click="OnFoot_Click"/>
|
||||||
|
<Separator Margin="2,0,2,0" VerticalAlignment="Top"/>
|
||||||
|
<Button Content="Ship" x:Name="Ship" Click="Ship_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
</HierarchicalDataTemplate>
|
</HierarchicalDataTemplate>
|
||||||
</HierarchicalDataTemplate.ItemTemplate>
|
</HierarchicalDataTemplate.ItemTemplate>
|
||||||
</HierarchicalDataTemplate>
|
</HierarchicalDataTemplate>
|
||||||
|
@ -11,6 +11,7 @@ using EDPlayerJournal.BGS;
|
|||||||
using EDPlayerJournal.Entries;
|
using EDPlayerJournal.Entries;
|
||||||
using EliteBGS.BGS;
|
using EliteBGS.BGS;
|
||||||
using EliteBGS.Util;
|
using EliteBGS.Util;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace EliteBGS;
|
namespace EliteBGS;
|
||||||
|
|
||||||
@ -183,7 +184,7 @@ public partial class MainWindow : Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void entries_KeyUp(object sender, KeyEventArgs e) {
|
private void entries_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) {
|
||||||
if (e.Key == Key.Delete) {
|
if (e.Key == Key.Delete) {
|
||||||
RemoveCurrentObjective();
|
RemoveCurrentObjective();
|
||||||
}
|
}
|
||||||
@ -312,4 +313,92 @@ public partial class MainWindow : Window {
|
|||||||
loadentries?.Close();
|
loadentries?.Close();
|
||||||
loadentries = null;
|
loadentries = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Transaction_Initialized(object sender, EventArgs e) {
|
||||||
|
Grid grid = sender as Grid;
|
||||||
|
if (grid == null || grid.DataContext == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UITransaction t = grid.DataContext as UITransaction;
|
||||||
|
if (t == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool iscombatzone = (t.Transaction.GetType() == typeof(CombatZone));
|
||||||
|
|
||||||
|
var children = grid
|
||||||
|
.Children
|
||||||
|
.OfType<StackPanel>()
|
||||||
|
.Where(x => x.Name == "CombatZone")
|
||||||
|
;
|
||||||
|
|
||||||
|
foreach (var child in children ) {
|
||||||
|
child.Visibility = (iscombatzone ? Visibility.Visible : Visibility.Collapsed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TransactionType GetTransaction<TransactionType>(object sender) where TransactionType : Transaction {
|
||||||
|
System.Windows.Controls.Control? button = sender as System.Windows.Controls.Control;
|
||||||
|
if (button == null || button.DataContext == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
UITransaction transaction = button.DataContext as UITransaction;
|
||||||
|
if (transaction == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return transaction.Transaction as TransactionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Low_Click(object sender, RoutedEventArgs e) {
|
||||||
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
||||||
|
if (transaction == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction.Grade = "Low";
|
||||||
|
RefreshView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Med_Click(object sender, RoutedEventArgs e) {
|
||||||
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
||||||
|
if (transaction == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction.Grade = "Medium";
|
||||||
|
RefreshView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void High_Click(object sender, RoutedEventArgs e) {
|
||||||
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
||||||
|
if (transaction == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction.Grade = "High";
|
||||||
|
RefreshView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnFoot_Click(object sender, RoutedEventArgs e) {
|
||||||
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
||||||
|
if (transaction == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction.Type = "OnFoot";
|
||||||
|
RefreshView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Ship_Click(object sender, RoutedEventArgs e) {
|
||||||
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
||||||
|
if (transaction == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction.Type = "Ship";
|
||||||
|
RefreshView();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
19
EliteBGS/MinusFortyFiveConverter.cs
Normal file
19
EliteBGS/MinusFortyFiveConverter.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace EliteBGS;
|
||||||
|
|
||||||
|
public class MinusFortyFiveConverter : IValueConverter {
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public object Convert(
|
||||||
|
object value, Type targetType, object parameter, CultureInfo culture) {
|
||||||
|
return (double)value - 45;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public object ConvertBack(
|
||||||
|
object value, Type targetType, object parameter, CultureInfo culture) {
|
||||||
|
throw new NotSupportedException("Cannot convert back");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user