move combat zone adding to the tree view
This commit is contained in:
parent
93359321d6
commit
04a839417e
@ -43,8 +43,6 @@
|
||||
<DatePicker x:Name="startdate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
||||
<DatePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<Separator Height="26.2857142857143" Margin="0" VerticalAlignment="Top"/>
|
||||
<Button x:Name="AddCombatZone" Content="Add Combat Zone Win" VerticalAlignment="Stretch" Margin="0,0,0,0.286" RenderTransformOrigin="0.5,0.505" Click="AddCombatZone_Click"/>
|
||||
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
|
||||
<Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" />
|
||||
</ToolBar>
|
||||
@ -58,19 +56,34 @@
|
||||
>
|
||||
<TreeView.ItemTemplate>
|
||||
<HierarchicalDataTemplate DataType="{x:Type local:Objective}" ItemsSource="{Binding UITransactions}" ItemContainerStyle="{StaticResource StretchingTreeViewStyle}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="System: " Visibility="{Binding HasSystem}" Margin="5,0,0,0"/>
|
||||
<TextBlock Text="{Binding System}" FontWeight="DemiBold" Visibility="{Binding HasSystem}"/>
|
||||
<TextBlock Text="Faction: " Visibility="{Binding HasFaction}" Margin="5,0,0,0"/>
|
||||
<TextBlock Text="{Binding Faction}" FontWeight="DemiBold" Visibility="{Binding HasFaction}"/>
|
||||
</StackPanel>
|
||||
<Grid
|
||||
HorizontalAlignment="Stretch"
|
||||
Width="{Binding ActualWidth, ElementName=entries, Converter={StaticResource MinusFortyFiveConverter}}"
|
||||
>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal">
|
||||
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="System: " Visibility="{Binding HasSystem}" Margin="5,0,0,0"/>
|
||||
<TextBlock Text="{Binding System}" FontWeight="DemiBold" Visibility="{Binding HasSystem}"/>
|
||||
<TextBlock Text="Faction: " Visibility="{Binding HasFaction}" Margin="5,0,0,0"/>
|
||||
<TextBlock Text="{Binding Faction}" FontWeight="DemiBold" Visibility="{Binding HasFaction}"/>
|
||||
</StackPanel>
|
||||
<Separator Visibility="Hidden" Grid.Column="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" />
|
||||
<StackPanel Grid.Column="2">
|
||||
<Button x:Name="AddCombatZone" Content="Add Combat Zone" Click="AddCombatZone_Click" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<HierarchicalDataTemplate.ItemTemplate>
|
||||
<HierarchicalDataTemplate>
|
||||
<!-- This will stretch out the width of the item-->
|
||||
<Grid Initialized="Transaction_Initialized"
|
||||
HorizontalAlignment="Stretch"
|
||||
Width="{Binding ActualWidth, ElementName=entries, Converter={StaticResource MinusFortyFiveConverter}}"
|
||||
Margin="0,5,0,5"
|
||||
>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
|
@ -202,55 +202,23 @@ public partial class MainWindow : Window {
|
||||
journal = new PlayerJournal(Config.Global.JournalLocation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the currently selected objective, even if a log entry in said objective
|
||||
/// is selected instead. If nothing is selected, returns null.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Objective GetSelectedObjective() {
|
||||
var obj = entries.SelectedItem;
|
||||
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (obj.GetType() == typeof(Objective)) {
|
||||
return obj as Objective;
|
||||
}
|
||||
|
||||
// Some form of entry perhaps?
|
||||
if (obj.GetType().IsSubclassOf(typeof(Transaction))) {
|
||||
Transaction entry = obj as Transaction;
|
||||
Objective objective = entries.Items
|
||||
.OfType<Objective>()
|
||||
.First(x => x.Transactions.Contains(entry))
|
||||
;
|
||||
|
||||
return objective;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void AddCombatZone_Click(object sender, RoutedEventArgs e) {
|
||||
Objective objective = GetSelectedObjective();
|
||||
|
||||
if (objective == null) {
|
||||
System.Windows.Controls.Control control = sender as System.Windows.Controls.Control;
|
||||
if (control == null || control.DataContext == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CombatZoneDialog dialog = new CombatZoneDialog() { Owner = this };
|
||||
|
||||
if (!(dialog.ShowDialog() ?? false)) {
|
||||
Objective objective = control.DataContext as Objective;
|
||||
if (objective == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CombatZone zone = new CombatZone {
|
||||
Faction = objective.Faction,
|
||||
System = objective.System,
|
||||
Grade = dialog.Grade,
|
||||
Type = dialog.Type,
|
||||
Amount = dialog.Amount
|
||||
Grade = "Low",
|
||||
Type = "Ship",
|
||||
Amount = 1
|
||||
};
|
||||
|
||||
UITransaction uitransaction = new UITransaction(zone);
|
||||
|
Loading…
Reference in New Issue
Block a user