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"/>
|
<DatePicker x:Name="startdate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
<Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
<Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
||||||
<DatePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<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"/>
|
<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>
|
||||||
@ -58,19 +56,34 @@
|
|||||||
>
|
>
|
||||||
<TreeView.ItemTemplate>
|
<TreeView.ItemTemplate>
|
||||||
<HierarchicalDataTemplate DataType="{x:Type local:Objective}" ItemsSource="{Binding UITransactions}" ItemContainerStyle="{StaticResource StretchingTreeViewStyle}">
|
<HierarchicalDataTemplate DataType="{x:Type local:Objective}" ItemsSource="{Binding UITransactions}" ItemContainerStyle="{StaticResource StretchingTreeViewStyle}">
|
||||||
<StackPanel Orientation="Horizontal">
|
<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"/>
|
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
|
||||||
<TextBlock Text="System: " Visibility="{Binding HasSystem}" Margin="5,0,0,0"/>
|
<TextBlock Text="System: " Visibility="{Binding HasSystem}" Margin="5,0,0,0"/>
|
||||||
<TextBlock Text="{Binding System}" FontWeight="DemiBold" Visibility="{Binding HasSystem}"/>
|
<TextBlock Text="{Binding System}" FontWeight="DemiBold" Visibility="{Binding HasSystem}"/>
|
||||||
<TextBlock Text="Faction: " Visibility="{Binding HasFaction}" Margin="5,0,0,0"/>
|
<TextBlock Text="Faction: " Visibility="{Binding HasFaction}" Margin="5,0,0,0"/>
|
||||||
<TextBlock Text="{Binding Faction}" FontWeight="DemiBold" Visibility="{Binding HasFaction}"/>
|
<TextBlock Text="{Binding Faction}" FontWeight="DemiBold" Visibility="{Binding HasFaction}"/>
|
||||||
</StackPanel>
|
</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.ItemTemplate>
|
||||||
<HierarchicalDataTemplate>
|
<HierarchicalDataTemplate>
|
||||||
<!-- This will stretch out the width of the item-->
|
<!-- This will stretch out the width of the item-->
|
||||||
<Grid Initialized="Transaction_Initialized"
|
<Grid Initialized="Transaction_Initialized"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Width="{Binding ActualWidth, ElementName=entries, Converter={StaticResource MinusFortyFiveConverter}}"
|
Width="{Binding ActualWidth, ElementName=entries, Converter={StaticResource MinusFortyFiveConverter}}"
|
||||||
|
Margin="0,5,0,5"
|
||||||
>
|
>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
@ -202,55 +202,23 @@ public partial class MainWindow : Window {
|
|||||||
journal = new PlayerJournal(Config.Global.JournalLocation);
|
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) {
|
private void AddCombatZone_Click(object sender, RoutedEventArgs e) {
|
||||||
Objective objective = GetSelectedObjective();
|
System.Windows.Controls.Control control = sender as System.Windows.Controls.Control;
|
||||||
|
if (control == null || control.DataContext == null) {
|
||||||
if (objective == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CombatZoneDialog dialog = new CombatZoneDialog() { Owner = this };
|
Objective objective = control.DataContext as Objective;
|
||||||
|
if (objective == null) {
|
||||||
if (!(dialog.ShowDialog() ?? false)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CombatZone zone = new CombatZone {
|
CombatZone zone = new CombatZone {
|
||||||
Faction = objective.Faction,
|
Faction = objective.Faction,
|
||||||
System = objective.System,
|
System = objective.System,
|
||||||
Grade = dialog.Grade,
|
Grade = "Low",
|
||||||
Type = dialog.Type,
|
Type = "Ship",
|
||||||
Amount = dialog.Amount
|
Amount = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
UITransaction uitransaction = new UITransaction(zone);
|
UITransaction uitransaction = new UITransaction(zone);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user