Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Triky313 committed Nov 28, 2024
2 parents 1ea80be + 6a21f34 commit 2232072
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 21 deletions.
43 changes: 37 additions & 6 deletions src/StatisticsAnalysisTool/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;

Expand All @@ -37,7 +38,9 @@ protected override async void OnStartup(StartupEventArgs e)

SystemInfo.LogSystemInfo();

AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
DispatcherUnhandledException += Application_DispatcherUnhandledException;

await AutoUpdateController.AutoUpdateAsync();

Expand Down Expand Up @@ -112,25 +115,53 @@ private void RegisterServicesLate()
ServiceLocator.Register<TrackingController>(_trackingController);
}

private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
try
{
Log.Fatal(e.ExceptionObject as Exception, "{message}", MethodBase.GetCurrentMethod()?.DeclaringType);
if (e.ExceptionObject is Exception exception)
{
Log.Fatal(exception, "Unhandled exception in {Source}", MethodBase.GetCurrentMethod()?.DeclaringType);
}
else
{
Log.Fatal("Unhandled exception object: {ExceptionObject} in {Source}", e.ExceptionObject, MethodBase.GetCurrentMethod()?.DeclaringType);
}
}
catch (Exception ex)
{
Log.Fatal(ex, "{message}", MethodBase.GetCurrentMethod()?.DeclaringType);
Log.Fatal(ex, "Error during unhandled exception logging in {Source}", MethodBase.GetCurrentMethod()?.DeclaringType);
}
finally
{
Log.CloseAndFlush();
}
}

private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
Log.Fatal(e.Exception, "Unhandled exception in TaskScheduler");
e.SetObserved();
}

// Fixes a issue in the WPF clipboard handler.
// It is necessary to handle the unhandled exception in the Application.DispatcherUnhandledException event.
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
// Fixes a issue in the WPF clipboard handler.
// It is necessary to handle the unhandled exception in the Application.DispatcherUnhandledException event.
if (e.Exception is COMException { ErrorCode: -2147221040 })
{
e.Handled = true;
return;
}

try
{
Log.Fatal(e.Exception, "Unhandled exception in UI thread");
}
finally
{
Log.CloseAndFlush();
e.Handled = false;
}
}

Expand Down
39 changes: 39 additions & 0 deletions src/StatisticsAnalysisTool/Localization/localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -37339,6 +37339,45 @@
"seg": "Backup storage directory path"
}
]
},
{
"tuid": "CURRENT_REPAIR_COSTS",
"tuv": [
{
"lang": "de-DE",
"seg": "Aktuelle Reparaturkosten"
},
{
"lang": "en-US",
"seg": "Current repair costs"
}
]
},
{
"tuid": "SHOW_TOTAL_AVG_PRICES_ON_ITEM",
"tuv": [
{
"lang": "de-DE",
"seg": "Durchschn. Gesamtpreis auf Item anzeigen"
},
{
"lang": "en-US",
"seg": "Show total avg prices on Item"
}
]
},
{
"tuid": "TOTAL_CHEST_VALUE",
"tuv": [
{
"lang": "de-DE",
"seg": "Gesamter Truhenwert"
},
{
"lang": "en-US",
"seg": "Total chest value"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,7 @@ public class MainWindowTranslation
public static string Gathering => LocalizationController.Translation("GATHERING");
public static string CopyShortDamageMeterToTheClipboard => LocalizationController.Translation("COPY_SHORT_DAMAGE_METER_TO_THE_CLIPBOARD");
public static string Guild => LocalizationController.Translation("GUILD");
public static string CurrentRepairCosts => LocalizationController.Translation("CURRENT_REPAIR_COSTS");
public static string ShowTotalAvgPricesOnItem => LocalizationController.Translation("SHOW_TOTAL_AVG_PRICES_ON_ITEM");
public static string TotalChestValue => LocalizationController.Translation("TOTAL_CHEST_VALUE");
}
4 changes: 2 additions & 2 deletions src/StatisticsAnalysisTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.8.0.*")]
[assembly: AssemblyFileVersion("7.8.0.0")]
[assembly: AssemblyVersion("7.8.1.*")]
[assembly: AssemblyFileVersion("7.8.1.0")]
17 changes: 16 additions & 1 deletion src/StatisticsAnalysisTool/StorageHistory/ContainerItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using StatisticsAnalysisTool.Common;
using System.Windows;
using StatisticsAnalysisTool.Common;
using StatisticsAnalysisTool.Models;
using StatisticsAnalysisTool.ViewModels;

Expand All @@ -8,6 +9,7 @@ public class ContainerItem : BaseViewModel
{
private int _itemIndex;
private int _quantity;
private Visibility _averagePricesDisplayedOnItemVisibility = Visibility.Collapsed;

public int ItemIndex
{
Expand All @@ -28,5 +30,18 @@ public int Quantity
OnPropertyChanged();
}
}

public Visibility AveragePricesDisplayedOnItemVisibility
{
get => _averagePricesDisplayedOnItemVisibility;
set
{
_averagePricesDisplayedOnItemVisibility = value;
OnPropertyChanged();
}
}

public Item Item => ItemController.GetItemByIndex(ItemIndex);

public double TotalAvgEstMarketValue => Quantity * Item?.AverageEstMarketValue ?? 0;
}
49 changes: 48 additions & 1 deletion src/StatisticsAnalysisTool/StorageHistory/VaultBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using System.Windows;
using System.Windows.Data;
using StatisticsAnalysisTool.Enumerations;

namespace StatisticsAnalysisTool.StorageHistory;

Expand All @@ -23,6 +24,8 @@ public class VaultBindings : BaseViewModel
private ListCollectionView _vaultCollectionView;
private List<VaultSearchItem> _vaultSearchList = new();
private string _searchText;
private bool _isAveragePricesDisplayedOnItem;
private double _totalContainerValue;

public VaultBindings()
{
Expand Down Expand Up @@ -82,7 +85,19 @@ public VaultContainer VaultContainerSelected
set
{
_vaultContainerSelected = value;
VaultContainerContent = _vaultContainer?.FirstOrDefault(x => x.Guid == _vaultContainerSelected?.Guid)?.Items ?? new ObservableCollection<ContainerItem>();
VaultContainerContent = new ObservableCollection<ContainerItem>(
(_vaultContainer?.FirstOrDefault(x => x.Guid == _vaultContainerSelected?.Guid)?.Items ?? new ObservableCollection<ContainerItem>())
.Select(containerItem =>
{
containerItem.AveragePricesDisplayedOnItemVisibility =
IsAveragePricesDisplayedOnItem
&& containerItem.Item?.EstimatedMarketValueStatus is PastTime.New or PastTime.AlmostNew or PastTime.LittleNew or PastTime.BitOld or PastTime.Old or PastTime.VeryOld or PastTime.VeryVeryOld
? Visibility.Visible
: Visibility.Collapsed;
return containerItem;
}));

TotalContainerValue = VaultContainerContent.Sum(x => x.TotalAvgEstMarketValue);
LastUpdate = _vaultContainerSelected?.LastUpdate ?? new DateTime(0);
LastUpdateVisibility = _vaultContainerSelected?.LastUpdate.Ticks <= 1 ? Visibility.Hidden : Visibility.Visible;
OnPropertyChanged();
Expand Down Expand Up @@ -119,6 +134,38 @@ public List<VaultSearchItem> VaultSearchList
}
}

public bool IsAveragePricesDisplayedOnItem
{
get => _isAveragePricesDisplayedOnItem;
set
{
_isAveragePricesDisplayedOnItem = value;
foreach (ContainerItem containerItem in VaultContainerContent ?? new ObservableCollection<ContainerItem>())
{
if (IsAveragePricesDisplayedOnItem
&& containerItem.Item?.EstimatedMarketValueStatus is PastTime.New or PastTime.AlmostNew or PastTime.LittleNew or PastTime.BitOld or PastTime.Old or PastTime.VeryOld or PastTime.VeryVeryOld)
{
containerItem.AveragePricesDisplayedOnItemVisibility = Visibility.Visible;
}
else
{
containerItem.AveragePricesDisplayedOnItemVisibility = Visibility.Collapsed;
}
}
OnPropertyChanged();
}
}

public double TotalContainerValue
{
get => _totalContainerValue;
set
{
_totalContainerValue = value;
OnPropertyChanged();
}
}

public string SearchText
{
get => _searchText;
Expand Down
11 changes: 11 additions & 0 deletions src/StatisticsAnalysisTool/StorageHistory/VaultContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class VaultContainer : BaseViewModel
private string _icon;
private ObservableCollection<ContainerItem> _items = new();
private double _repairCosts;
private double _totalValue;

public DateTime LastUpdate
{
Expand Down Expand Up @@ -72,4 +73,14 @@ public double RepairCosts
OnPropertyChanged();
}
}

public double TotalValue
{
get => _totalValue;
set
{
_totalValue = value;
OnPropertyChanged();
}
}
}
13 changes: 7 additions & 6 deletions src/StatisticsAnalysisTool/Styles/ItemSearchStyles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
<TextBlock TextWrapping="Wrap" Text="{Binding LocalizedNameAndEnglish}" />
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/silver.png" Width="12" Height="12" ToolTip="{Binding TranslationEstMarketValue, IsAsync=True, Mode=OneWay}" />
<Label Content="{Binding AverageEstMarketValue, IsAsync=True, Mode=OneWay, StringFormat=N0, ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}}"
ToolTip="{Binding LastEstimatedUpdateTimeString, IsAsync=True, Mode=OneWay}">
<Label.Style>
<Style TargetType="{x:Type Label}">
<TextBlock Text="{Binding AverageEstMarketValue, IsAsync=True, Mode=OneWay, StringFormat='{}{0:N0}', ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}}"
ToolTip="{Binding LastEstimatedUpdateTimeString, IsAsync=True, Mode=OneWay}">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="5,0,0,0"/>
<Setter Property="Foreground" Value="{StaticResource SolidColorBrush.Text.6}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding EstimatedMarketValueStatus, IsAsync=True}" Value="{x:Static enum:PastTime.VeryVeryOld}">
Expand All @@ -55,8 +56,8 @@
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
</TextBlock.Style>
</TextBlock>
</StackPanel>
</StackPanel>
</Grid>
Expand Down
53 changes: 50 additions & 3 deletions src/StatisticsAnalysisTool/Styles/StorageHistoryStyle.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:models="clr-namespace:StatisticsAnalysisTool.Models"
xmlns:networkModel="clr-namespace:StatisticsAnalysisTool.Models.NetworkModel"
xmlns:storageHistory="clr-namespace:StatisticsAnalysisTool.StorageHistory">
xmlns:storageHistory="clr-namespace:StatisticsAnalysisTool.StorageHistory"
xmlns:glob="clr-namespace:System.Globalization;assembly=System.Runtime"
xmlns:enum="clr-namespace:StatisticsAnalysisTool.Enumerations">

<DataTemplate x:Key="ContainerItemTemplate" DataType="{x:Type storageHistory:ContainerItem}">
<Grid Height="80" Width="80" Margin="1">
Expand All @@ -22,6 +23,52 @@
<TextBlock Text="{Binding Quantity}" Foreground="{StaticResource SolidColorBrush.Text.1}" />
</Viewbox>
</Border>
<TextBlock Background="#c0000000" Text="{Binding TotalAvgEstMarketValue, IsAsync=True, Mode=OneWay, StringFormat='{}{0:N0}', ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}}"
ToolTip="{Binding Item.LastEstimatedUpdateTimeString, IsAsync=True, Mode=OneWay}" Visibility="{Binding AveragePricesDisplayedOnItemVisibility}">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Width" Value="70" />
<Setter Property="Height" Value="20" />
<Setter Property="Padding" Value="0" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="Foreground" Value="{StaticResource SolidColorBrush.Text.6}"/>
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Item.EstimatedMarketValueStatus, IsAsync=True}" Value="{x:Static enum:PastTime.VeryVeryOld}">
<Setter Property="Foreground" Value="{StaticResource SolidColorBrush.TimeValue.PastTime.7}"/>
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding Item.EstimatedMarketValueStatus, IsAsync=True}" Value="{x:Static enum:PastTime.VeryOld}">
<Setter Property="Foreground" Value="{StaticResource SolidColorBrush.TimeValue.PastTime.6}"/>
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding Item.EstimatedMarketValueStatus, IsAsync=True}" Value="{x:Static enum:PastTime.Old}">
<Setter Property="Foreground" Value="{StaticResource SolidColorBrush.TimeValue.PastTime.5}"/>
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding Item.EstimatedMarketValueStatus, IsAsync=True}" Value="{x:Static enum:PastTime.BitOld}">
<Setter Property="Foreground" Value="{StaticResource SolidColorBrush.TimeValue.PastTime.4}"/>
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding Item.EstimatedMarketValueStatus, IsAsync=True}" Value="{x:Static enum:PastTime.LittleNew}">
<Setter Property="Foreground" Value="{StaticResource SolidColorBrush.TimeValue.PastTime.3}"/>
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding Item.EstimatedMarketValueStatus, IsAsync=True}" Value="{x:Static enum:PastTime.AlmostNew}">
<Setter Property="Foreground" Value="{StaticResource SolidColorBrush.TimeValue.PastTime.2}"/>
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding Item.EstimatedMarketValueStatus, IsAsync=True}" Value="{x:Static enum:PastTime.New}">
<Setter Property="Foreground" Value="{StaticResource SolidColorBrush.TimeValue.PastTime.1}"/>
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Grid>
</DataTemplate>
Expand Down Expand Up @@ -111,7 +158,7 @@
<Grid Height="50">
<Border Style="{StaticResource Container.Border}">
<DockPanel VerticalAlignment="Top" HorizontalAlignment="Stretch" Margin="0,0,10,0">
<Grid Margin="0,0, 5, 0" HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid Margin="0,0,5,0" HorizontalAlignment="Center" VerticalAlignment="Center">
<Image Source="{Binding Item.Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource VaultSearchItem.Icon}" />
</Grid>
<StackPanel Orientation="Vertical">
Expand Down
Loading

0 comments on commit 2232072

Please sign in to comment.