also allow changing of profit through tree view
This commit is contained in:
parent
697cbc2bc6
commit
10351af7f9
@ -82,7 +82,7 @@
|
||||
<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">
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" x:Name="CombatZone" Visibility="{Binding IsCombatZone}">
|
||||
<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" />
|
||||
@ -93,6 +93,10 @@
|
||||
<Separator Margin="2,0,2,0" VerticalAlignment="Top"/>
|
||||
<Button Content="Ship" x:Name="Ship" Click="Ship_Click"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" x:Name="SellCargo" Visibility="{Binding IsSellCargo}">
|
||||
<TextBlock Text="Adjust Profit: " TextAlignment="Center" />
|
||||
<TextBox x:Name="Profit" MinWidth="80" HorizontalContentAlignment="Right" Text="{Binding Profit, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="Profit_TextChanged"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</HierarchicalDataTemplate>
|
||||
</HierarchicalDataTemplate.ItemTemplate>
|
||||
|
@ -315,27 +315,6 @@ public partial class MainWindow : Window {
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -401,4 +380,8 @@ public partial class MainWindow : Window {
|
||||
transaction.Type = "Ship";
|
||||
RefreshView();
|
||||
}
|
||||
|
||||
private void Profit_TextChanged(object sender, TextChangedEventArgs e) {
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using EDPlayerJournal.BGS;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace EliteBGS;
|
||||
|
||||
@ -12,6 +13,42 @@ public class UITransaction {
|
||||
|
||||
public bool IsExpanded { get; set; } = true;
|
||||
|
||||
public Visibility IsCombatZone {
|
||||
get {
|
||||
return (Transaction != null && Transaction.GetType() == typeof(CombatZone)) ? Visibility.Visible : Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
|
||||
public Visibility IsSellCargo {
|
||||
get {
|
||||
return (Transaction != null && Transaction.GetType() == typeof(SellCargo)) ? Visibility.Visible : Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Profit from selling, used in the XAML ui for binding
|
||||
/// </summary>
|
||||
public string Profit {
|
||||
get {
|
||||
SellCargo cargo = Transaction as SellCargo;
|
||||
if (cargo == null) {
|
||||
return "";
|
||||
}
|
||||
return cargo.Profit.ToString();
|
||||
}
|
||||
set {
|
||||
SellCargo cargo = Transaction as SellCargo;
|
||||
if (cargo == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
long profit_as_number = Convert.ToInt64(value);
|
||||
cargo.Profit = profit_as_number;
|
||||
} catch (FormatException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Transaction Transaction { get; set; }
|
||||
|
||||
public UITransaction() { }
|
||||
|
Loading…
Reference in New Issue
Block a user