Bug fixes

This commit is contained in:
retr0volkov
2025-07-17 10:30:47 +03:00 Unverified
parent 8ddce4005f
commit edae732fac
21 changed files with 65 additions and 66 deletions
+17 -2
View File
@@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using System.Text.Json; using System.Text.Json;
using GazpromApp.Models; using GazpromApp.Models;
@@ -8,12 +9,26 @@ public static class DataSerialization
{ {
private static void SaveData(string path, string data) private static void SaveData(string path, string data)
{ {
System.IO.File.WriteAllText(path, data); if (!File.Exists(path))
{
File.WriteAllText(path, data);
return;
}
var dir = Path.GetDirectoryName(path) ?? "";
var fileName = Path.GetFileNameWithoutExtension(path);
var ext = Path.GetExtension(path);
var index = 1;
while (File.Exists(Path.Combine(dir, $"{fileName} ({index}){ext}")))
index++;
File.WriteAllText(Path.Combine(dir, $"{fileName} ({index}){ext}"), data);
} }
private static string LoadData(string path) private static string LoadData(string path)
{ {
var text = System.IO.File.ReadAllText(path); var text = File.ReadAllText(path);
return text; return text;
} }
+5 -5
View File
@@ -82,12 +82,14 @@ public partial class MainWindowViewModel : ViewModelBase
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
}); });
if (files.Count < 1) return;
IsLoading = true; IsLoading = true;
foreach (var file in files) foreach (var file in files)
{ {
var url = file.Path.AbsolutePath; var url = file.Path.AbsolutePath;
var decoded = HttpUtility.HtmlDecode(url); var decoded = HttpUtility.UrlDecode(url);
var point = DataSerialization.LoadPoint(decoded); var point = DataSerialization.LoadPoint(decoded);
point?.SetPropertyParents(); point?.SetPropertyParents();
@@ -113,11 +115,9 @@ public partial class MainWindowViewModel : ViewModelBase
await w.StorageProvider.TryGetFolderFromPathAsync( await w.StorageProvider.TryGetFolderFromPathAsync(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
}); });
if (folder.Count != 1) return;
foreach (var point in Points) foreach (var point in Points)
{ DataSerialization.SavePoint(point.GetPoint(), Path.Combine(HttpUtility.UrlDecode(folder[0].Path.AbsolutePath), point.Name + ".json") );
DataSerialization.SavePoint(point.GetPoint(), Path.Combine(HttpUtility.HtmlDecode(folder[0].Path.AbsolutePath), point.Name + ".json") );
}
} }
// Visual and other properties // Visual and other properties
+5 -4
View File
@@ -49,7 +49,7 @@
<TextBlock Grid.Column="0" Grid.Row="1" Margin="20,4,0,4" <TextBlock Grid.Column="0" Grid.Row="1" Margin="20,4,0,4"
Text="{Binding Description}" Text="{Binding Description}"
IsVisible="{Binding !IsDescriptionEditing}"/> IsVisible="{Binding !IsDescriptionEditing}"/>
<TextBox Grid.Column="0" Grid.Row="1" Margin="12,4,0,4" <TextBox Grid.Column="0" Grid.Row="1" Margin="12,4,0,4" AcceptsReturn="True" TextWrapping="Wrap"
Text="{Binding Description}" Text="{Binding Description}"
IsVisible="{Binding IsDescriptionEditing}"/> IsVisible="{Binding IsDescriptionEditing}"/>
<Button Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" Margin="10" <Button Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" Margin="10"
@@ -73,12 +73,12 @@
<Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="5" <Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="5"
Source="{Binding FileName}" /> Source="{Binding FileName}" />
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20" <Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).ViewImageCommand}" Command="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).ViewImageCommand}"
CommandParameter="{Binding .}"> CommandParameter="{Binding .}">
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_eye_show_24_filled (Custom) 16.png"/> <Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_eye_show_24_filled (Custom) 16.png"/>
</Button> </Button>
<Button Grid.Row="1" Grid.Column="3" Width="20" Height="20" <Button Grid.Row="1" Grid.Column="3" Width="20" Height="20"
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).DeleteImageCommand}" Command="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).DeleteImageCommand}"
CommandParameter="{Binding .}"> CommandParameter="{Binding .}">
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/> <Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
</Button> </Button>
@@ -137,7 +137,8 @@
<TextBlock Grid.Column="2" Margin="16,0,0,0" Text="Период: " FontSize="18" VerticalAlignment="Center"/> <TextBlock Grid.Column="2" Margin="16,0,0,0" Text="Период: " FontSize="18" VerticalAlignment="Center"/>
<NumericUpDown Grid.Column="3" AllowSpin="True" Width="120" VerticalAlignment="Center" <NumericUpDown Grid.Column="3" AllowSpin="True" Width="120" VerticalAlignment="Center"
Value="{Binding PeriodValue}"/> Value="{Binding PeriodValue}"
Minimum="0"/>
<ComboBox Grid.Column="4" Width="100" VerticalAlignment="Center" Margin="4,0,0,0" <ComboBox Grid.Column="4" Width="100" VerticalAlignment="Center" Margin="4,0,0,0"
ItemsSource="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).AllPeriods}" ItemsSource="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).AllPeriods}"
SelectedItem="{Binding PeriodType, Mode=TwoWay}" SelectedItem="{Binding PeriodType, Mode=TwoWay}"
-6
View File
@@ -35,10 +35,6 @@ public partial class EditEquipmentDialog : Window
m.Reply(dialog.ShowDialog<ErrorViewModel?>(w)); m.Reply(dialog.ShowDialog<ErrorViewModel?>(w));
}); });
// new property dialog
// edit property dialog
// complete editing equipment // complete editing equipment
WeakReferenceMessenger.Default.Register<EditEquipmentDialog, EditEquipmentDone>(this, static (w, m) => WeakReferenceMessenger.Default.Register<EditEquipmentDialog, EditEquipmentDone>(this, static (w, m) =>
{ {
@@ -56,8 +52,6 @@ public partial class EditEquipmentDialog : Window
{ {
WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this); WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this);
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this); WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
//
//
WeakReferenceMessenger.Default.Unregister<EditEquipmentDone>(this); WeakReferenceMessenger.Default.Unregister<EditEquipmentDone>(this);
} }
} }
+1 -1
View File
@@ -47,7 +47,7 @@
<TextBlock Grid.Column="0" Grid.Row="1" Margin="20,4,0,4" <TextBlock Grid.Column="0" Grid.Row="1" Margin="20,4,0,4"
Text="{Binding Description}" Text="{Binding Description}"
IsVisible="{Binding !IsDescriptionEditing}"/> IsVisible="{Binding !IsDescriptionEditing}"/>
<TextBox Grid.Column="0" Grid.Row="1" Margin="12,4,0,4" <TextBox Grid.Column="0" Grid.Row="1" Margin="12,4,0,4" AcceptsReturn="True" TextWrapping="Wrap"
Text="{Binding Description}" Text="{Binding Description}"
IsVisible="{Binding IsDescriptionEditing}"/> IsVisible="{Binding IsDescriptionEditing}"/>
<Button Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" Margin="10" <Button Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" Margin="10"
+3 -14
View File
@@ -61,6 +61,7 @@ public partial class EditPointDialog : Window
// re registering error when new equipment done // re registering error when new equipment done
WeakReferenceMessenger.Default.Register<EditPointDialog, NewEquipmentDone>(this, (_, _) => WeakReferenceMessenger.Default.Register<EditPointDialog, NewEquipmentDone>(this, (_, _) =>
{ {
if (!WeakReferenceMessenger.Default.IsRegistered<ErrorMessage>(this))
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) => WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
{ {
var dialog = new ErrorView var dialog = new ErrorView
@@ -74,6 +75,7 @@ public partial class EditPointDialog : Window
// re registering view image and error view // re registering view image and error view
WeakReferenceMessenger.Default.Register<EditPointDialog, EditEquipmentDone>(this, (_, _) => WeakReferenceMessenger.Default.Register<EditPointDialog, EditEquipmentDone>(this, (_, _) =>
{ {
if (!WeakReferenceMessenger.Default.IsRegistered<ViewImageMessage>(this))
WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) => WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) =>
{ {
var dialog = new ImageView var dialog = new ImageView
@@ -82,9 +84,7 @@ public partial class EditPointDialog : Window
}; };
m.Reply(dialog.ShowDialog<ImageViewModel?>(w)); m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
}); });
if (!WeakReferenceMessenger.Default.IsRegistered<ErrorMessage>(this))
try
{
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) => WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
{ {
var dialog = new ErrorView var dialog = new ErrorView
@@ -93,17 +93,8 @@ public partial class EditPointDialog : Window
}; };
m.Reply(dialog.ShowDialog<ErrorViewModel?>(w)); m.Reply(dialog.ShowDialog<ErrorViewModel?>(w));
}); });
}
catch (Exception)
{
// ignored
}
}); });
// new property
// edit property
// complete editing point // complete editing point
WeakReferenceMessenger.Default.Register<EditPointDialog, EditPointDone>(this, static (w, m) => WeakReferenceMessenger.Default.Register<EditPointDialog, EditPointDone>(this, static (w, m) =>
{ {
@@ -123,8 +114,6 @@ public partial class EditPointDialog : Window
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this); WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
WeakReferenceMessenger.Default.Unregister<NewEquipmentMessage>(this); WeakReferenceMessenger.Default.Unregister<NewEquipmentMessage>(this);
WeakReferenceMessenger.Default.Unregister<EditEquipmentMessage>(this); WeakReferenceMessenger.Default.Unregister<EditEquipmentMessage>(this);
// new prop
// edit prop
WeakReferenceMessenger.Default.Unregister<EditPointDone>(this); WeakReferenceMessenger.Default.Unregister<EditPointDone>(this);
} }
} }
+1 -1
View File
@@ -31,7 +31,7 @@
<TextBlock Grid.Column="0" Grid.Row="2" Margin="8" Text="Изображение: "/> <TextBlock Grid.Column="0" Grid.Row="2" Margin="8" Text="Изображение: "/>
<TextBox Grid.Column="1" Grid.Row="0" Margin="8" <TextBox Grid.Column="1" Grid.Row="0" Margin="8"
Text="{Binding Name}"/> Text="{Binding Name}"/>
<TextBox Grid.Column="1" Grid.Row="1" Margin="8" <TextBox Grid.Column="1" Grid.Row="1" Margin="8" AcceptsReturn="True" TextWrapping="Wrap"
Text="{Binding Description}"/> Text="{Binding Description}"/>
<Panel Grid.Column="1" Grid.Row="2" Margin="8" IsVisible="{Binding !IsImagesEmpty}"> <Panel Grid.Column="1" Grid.Row="2" Margin="8" IsVisible="{Binding !IsImagesEmpty}">
+1 -1
View File
@@ -31,7 +31,7 @@
<TextBlock Grid.Column="0" Grid.Row="2" Margin="8" Text="Изображение: "/> <TextBlock Grid.Column="0" Grid.Row="2" Margin="8" Text="Изображение: "/>
<TextBox Grid.Column="1" Grid.Row="0" Margin="8" <TextBox Grid.Column="1" Grid.Row="0" Margin="8"
Text="{Binding Name}"/> Text="{Binding Name}"/>
<TextBox Grid.Column="1" Grid.Row="1" Margin="8" <TextBox Grid.Column="1" Grid.Row="1" Margin="8" AcceptsReturn="True" TextWrapping="Wrap"
Text="{Binding Description}"/> Text="{Binding Description}"/>
<Panel Grid.Column="1" Grid.Row="2" Margin="8" IsVisible="{Binding !IsImagesEmpty}"> <Panel Grid.Column="1" Grid.Row="2" Margin="8" IsVisible="{Binding !IsImagesEmpty}">
<ScrollViewer> <ScrollViewer>
+1 -1
View File
@@ -12,7 +12,7 @@ public partial class NewPointDialog : Window
{ {
InitializeComponent(); InitializeComponent();
// done entering new point // done entering a new point
WeakReferenceMessenger.Default.Register<NewPointDialog, NewPointDone>(this, static (w, m) => WeakReferenceMessenger.Default.Register<NewPointDialog, NewPointDone>(this, static (w, m) =>
{ {
w.Close(m.Point); w.Close(m.Point);
@@ -1 +1 @@
6ec01d8198a7aa89515263050c4105434cbcd2354fb50cf2ffbc3673c60121f8 ce571eaa8794cd8018cfc316b7aa3a875ff0192541a3e5a99ac1c0b1fe0464bc
Binary file not shown.
+1 -1
View File
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("GazpromApp")] [assembly: System.Reflection.AssemblyCompanyAttribute("GazpromApp")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7a34fc2dbb087fdbf1bea9de2367b1627dbfd934")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d8cb1c0597162160d03e7987cc85991c880988b8")]
[assembly: System.Reflection.AssemblyProductAttribute("GazpromApp")] [assembly: System.Reflection.AssemblyProductAttribute("GazpromApp")]
[assembly: System.Reflection.AssemblyTitleAttribute("GazpromApp")] [assembly: System.Reflection.AssemblyTitleAttribute("GazpromApp")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
79ee0a1c89f7354058711501fd55995c28018c56cfa0b0de53a84dfaced70957 77f531bfc5aeafe36631b408a11c11c294e011bb2a474f23c97785d02864a447
Binary file not shown.
+2 -2
View File
@@ -44,7 +44,7 @@
"auditLevel": "low", "auditLevel": "low",
"auditMode": "direct" "auditMode": "direct"
}, },
"SdkAnalysisLevel": "9.0.200" "SdkAnalysisLevel": "9.0.300"
}, },
"frameworks": { "frameworks": {
"net8.0": { "net8.0": {
@@ -117,7 +117,7 @@
"privateAssets": "all" "privateAssets": "all"
} }
}, },
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.204/PortableRuntimeIdentifierGraph.json" "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.302/PortableRuntimeIdentifierGraph.json"
} }
} }
} }
+2 -2
View File
@@ -4799,7 +4799,7 @@
"auditLevel": "low", "auditLevel": "low",
"auditMode": "direct" "auditMode": "direct"
}, },
"SdkAnalysisLevel": "9.0.200" "SdkAnalysisLevel": "9.0.300"
}, },
"frameworks": { "frameworks": {
"net8.0": { "net8.0": {
@@ -4872,7 +4872,7 @@
"privateAssets": "all" "privateAssets": "all"
} }
}, },
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.204/PortableRuntimeIdentifierGraph.json" "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.302/PortableRuntimeIdentifierGraph.json"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"version": 2, "version": 2,
"dgSpecHash": "hnfkdEFJuA8=", "dgSpecHash": "tG1MV/2SQjY=",
"success": true, "success": true,
"projectFilePath": "D:\\RiderProjects\\GazpromApp\\GazpromApp.csproj", "projectFilePath": "D:\\RiderProjects\\GazpromApp\\GazpromApp.csproj",
"expectedPackageFiles": [ "expectedPackageFiles": [
+1 -1
View File
@@ -1 +1 @@
"restore":{"projectUniqueName":"D:\\RiderProjects\\GazpromApp\\GazpromApp.csproj","projectName":"GazpromApp","projectPath":"D:\\RiderProjects\\GazpromApp\\GazpromApp.csproj","outputPath":"D:\\RiderProjects\\GazpromApp\\obj\\","projectStyle":"PackageReference","fallbackFolders":["C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"],"originalTargetFrameworks":["net8.0"],"sources":{"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\":{},"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net8.0":{"targetAlias":"net8.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]},"restoreAuditProperties":{"enableAudit":"true","auditLevel":"low","auditMode":"direct"},"SdkAnalysisLevel":"9.0.200"}"frameworks":{"net8.0":{"targetAlias":"net8.0","dependencies":{"AnimatedImage.Avalonia":{"target":"Package","version":"[2.0.0, )"},"Avalonia":{"target":"Package","version":"[11.3.2, )"},"Avalonia.Controls.ItemsRepeater":{"target":"Package","version":"[11.1.5, )"},"Avalonia.Desktop":{"target":"Package","version":"[11.3.2, )"},"Avalonia.Diagnostics":{"target":"Package","version":"[11.3.2, )"},"Avalonia.Fonts.Inter":{"target":"Package","version":"[11.3.2, )"},"Avalonia.Themes.Fluent":{"target":"Package","version":"[11.3.2, )"},"AvaloniaUI.DiagnosticsSupport":{"target":"Package","version":"[2.0.4, )"},"CommunityToolkit.Mvvm":{"target":"Package","version":"[8.2.1, )"},"Microsoft.EntityFrameworkCore":{"target":"Package","version":"[9.0.6, )"},"Microsoft.EntityFrameworkCore.Design":{"include":"Runtime, Build, Native, ContentFiles, Analyzers, BuildTransitive","suppressParent":"All","target":"Package","version":"[9.0.6, )"},"Microsoft.EntityFrameworkCore.Sqlite":{"target":"Package","version":"[9.0.6, )"}},"imports":["net461","net462","net47","net471","net472","net48","net481"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"C:\\Program Files\\dotnet\\sdk\\9.0.204/PortableRuntimeIdentifierGraph.json"}} "restore":{"projectUniqueName":"D:\\RiderProjects\\GazpromApp\\GazpromApp.csproj","projectName":"GazpromApp","projectPath":"D:\\RiderProjects\\GazpromApp\\GazpromApp.csproj","outputPath":"D:\\RiderProjects\\GazpromApp\\obj\\","projectStyle":"PackageReference","fallbackFolders":["C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"],"originalTargetFrameworks":["net8.0"],"sources":{"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\":{},"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net8.0":{"targetAlias":"net8.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]},"restoreAuditProperties":{"enableAudit":"true","auditLevel":"low","auditMode":"direct"},"SdkAnalysisLevel":"9.0.300"}"frameworks":{"net8.0":{"targetAlias":"net8.0","dependencies":{"AnimatedImage.Avalonia":{"target":"Package","version":"[2.0.0, )"},"Avalonia":{"target":"Package","version":"[11.3.2, )"},"Avalonia.Controls.ItemsRepeater":{"target":"Package","version":"[11.1.5, )"},"Avalonia.Desktop":{"target":"Package","version":"[11.3.2, )"},"Avalonia.Diagnostics":{"target":"Package","version":"[11.3.2, )"},"Avalonia.Fonts.Inter":{"target":"Package","version":"[11.3.2, )"},"Avalonia.Themes.Fluent":{"target":"Package","version":"[11.3.2, )"},"AvaloniaUI.DiagnosticsSupport":{"target":"Package","version":"[2.0.4, )"},"CommunityToolkit.Mvvm":{"target":"Package","version":"[8.2.1, )"},"Microsoft.EntityFrameworkCore":{"target":"Package","version":"[9.0.6, )"},"Microsoft.EntityFrameworkCore.Design":{"include":"Runtime, Build, Native, ContentFiles, Analyzers, BuildTransitive","suppressParent":"All","target":"Package","version":"[9.0.6, )"},"Microsoft.EntityFrameworkCore.Sqlite":{"target":"Package","version":"[9.0.6, )"}},"imports":["net461","net462","net47","net471","net472","net48","net481"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"C:\\Program Files\\dotnet\\sdk\\9.0.302/PortableRuntimeIdentifierGraph.json"}}
+1 -1
View File
@@ -1 +1 @@
17522225915601599 17527364972202368
+1 -1
View File
@@ -1 +1 @@
17522225915601599 17527364972202368