Bug fix
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform.Storage;
|
||||
@@ -17,8 +18,6 @@ namespace GazpromApp.ViewModels;
|
||||
|
||||
public partial class EditPointDialogViewModel : ViewModelBase
|
||||
{
|
||||
public ObservableCollection<ImageViewModel> Images { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(CompleteEditCommand))]
|
||||
private string? _name;
|
||||
@@ -46,6 +45,8 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
IsDescriptionEditing = !IsDescriptionEditing;
|
||||
IsNameEditing = false;
|
||||
}
|
||||
|
||||
public ObservableCollection<ImageViewModel> Images { get; set; }
|
||||
|
||||
[RelayCommand]
|
||||
private async Task AddImage(Window w)
|
||||
@@ -57,7 +58,7 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
FileTypeFilter = [FilePickerFileTypes.ImageAll],
|
||||
});
|
||||
foreach (var file in files)
|
||||
Images.Add(new ImageViewModel(new Image()) { FileName = new Bitmap(file.Path.AbsolutePath) });
|
||||
Images.Add(new ImageViewModel(new Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(file.Path.AbsolutePath) ) });
|
||||
|
||||
IsImagesEmpty = Images.Count == 0;
|
||||
}
|
||||
@@ -70,7 +71,7 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task ViewImage(ImageViewModel image)
|
||||
private static async Task ViewImage(ImageViewModel image)
|
||||
{
|
||||
_ = await WeakReferenceMessenger.Default.Send(new ViewImageMessage(image));
|
||||
}
|
||||
@@ -80,6 +81,7 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
[RelayCommand(CanExecute = nameof(CanCompleteEdit))]
|
||||
private void CompleteEdit()
|
||||
{
|
||||
IsClosed = true;
|
||||
Point point = new Point()
|
||||
{
|
||||
Name = Name,
|
||||
@@ -90,20 +92,33 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private static void CancelEdit(Window w)
|
||||
private void CancelEdit(Window w)
|
||||
{
|
||||
w.Close();
|
||||
IsClosed = true;
|
||||
WeakReferenceMessenger.Default.Send(new EditPointDone(_point));
|
||||
}
|
||||
|
||||
// Visual and other properties
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isImagesEmpty;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isEquipmentEmpty = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isClosed;
|
||||
|
||||
private readonly PointViewModel _point;
|
||||
|
||||
public EditPointDialogViewModel()
|
||||
{
|
||||
Name = "";
|
||||
Description = "";
|
||||
Images = [];
|
||||
IsImagesEmpty = true;
|
||||
|
||||
_point = new PointViewModel(new Point());
|
||||
}
|
||||
|
||||
public EditPointDialogViewModel(PointViewModel point)
|
||||
@@ -116,5 +131,7 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
Debug.WriteLine(imageViewModel.FileName);
|
||||
}
|
||||
IsImagesEmpty = Images.Count == 0;
|
||||
|
||||
_point = point;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform.Storage;
|
||||
@@ -36,7 +37,7 @@ public partial class NewPointDialogViewModel : ViewModelBase
|
||||
FileTypeFilter = [FilePickerFileTypes.ImageAll],
|
||||
});
|
||||
foreach (var file in files)
|
||||
Images.Add(new ImageViewModel(new Image()) { FileName = new Bitmap(file.Path.AbsolutePath) });
|
||||
Images.Add(new ImageViewModel(new Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(file.Path.AbsolutePath)) });
|
||||
|
||||
IsImagesEmpty = Images.Count == 0;
|
||||
}
|
||||
|
||||
+26
-22
@@ -10,12 +10,36 @@
|
||||
x:DataType="vm:EditPointDialogViewModel"
|
||||
Title="Редактирование/просмотр объекта"
|
||||
Icon="/Assets/ic_fluent_edit_24_filled (Custom).png"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Closing="Window_OnClosing"
|
||||
Closed="Window_OnClosed">
|
||||
<Design.DataContext>
|
||||
<vm:EditPointDialogViewModel/>
|
||||
</Design.DataContext>
|
||||
<Grid RowDefinitions="70,150,*,Auto" ColumnDefinitions="*,100,220" x:Name="Root">
|
||||
<Panel Grid.RowSpan="2" Grid.Column="2" HorizontalAlignment="Center">
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" FontSize="28" Margin="20,4,0,4"
|
||||
Text="{Binding Name}"
|
||||
IsVisible="{Binding !IsNameEditing}"/>
|
||||
<TextBox Grid.Column="0" Grid.Row="0" Margin="12,12,0,4"
|
||||
Text="{Binding Name}"
|
||||
IsVisible="{Binding IsNameEditing}"/>
|
||||
<Button Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center" Margin="10"
|
||||
Command="{Binding EditNameCommand}">
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Margin="20,4,0,4"
|
||||
Text="{Binding Description}"
|
||||
IsVisible="{Binding !IsDescriptionEditing}"/>
|
||||
<TextBox Grid.Column="0" Grid.Row="1" Margin="12,4,0,4"
|
||||
Text="{Binding Description}"
|
||||
IsVisible="{Binding IsDescriptionEditing}"/>
|
||||
<Button Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" Margin="10"
|
||||
Command="{Binding EditDescriptionCommand}">
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
|
||||
<Panel Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" HorizontalAlignment="Center">
|
||||
<ScrollViewer HorizontalAlignment="Center">
|
||||
<StackPanel>
|
||||
<ItemsRepeater HorizontalAlignment="Center"
|
||||
@@ -59,26 +83,6 @@
|
||||
</Button>
|
||||
</Panel>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" FontSize="28" Margin="20,4,0,4"
|
||||
Text="{Binding Name}"
|
||||
IsVisible="{Binding !IsNameEditing}"/>
|
||||
<TextBox Grid.Column="0" Grid.Row="0" Margin="12,12,0,4"
|
||||
Text="{Binding Name}"
|
||||
IsVisible="{Binding IsNameEditing}"/>
|
||||
<Button Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center" Margin="10"
|
||||
Command="{Binding EditNameCommand}">
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Margin="20,4,0,4"
|
||||
Text="{Binding Description}"
|
||||
IsVisible="{Binding !IsDescriptionEditing}"/>
|
||||
<TextBox Grid.Column="0" Grid.Row="1" Margin="12,4,0,4"
|
||||
Text="{Binding Description}"
|
||||
IsVisible="{Binding IsDescriptionEditing}"/>
|
||||
<Button Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" Margin="10"
|
||||
Command="{Binding EditDescriptionCommand}">
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
<TabControl Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="2">
|
||||
<TabItem Header="Оборудование">
|
||||
<ScrollViewer>
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
using Avalonia.Controls;
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.Models;
|
||||
using GazpromApp.ViewModels;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class EditPointDialog : Window
|
||||
{
|
||||
public Point? Point;
|
||||
|
||||
public EditPointDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -14,6 +18,7 @@ public partial class EditPointDialog : Window
|
||||
if (Design.IsDesignMode)
|
||||
return;
|
||||
|
||||
// view image
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) =>
|
||||
{
|
||||
ImageView dialog = new ImageView()
|
||||
@@ -28,4 +33,15 @@ public partial class EditPointDialog : Window
|
||||
w.Close(m.Point);
|
||||
});
|
||||
}
|
||||
|
||||
private void Window_OnClosing(object? sender, WindowClosingEventArgs e)
|
||||
{
|
||||
if (DataContext is EditPointDialogViewModel { IsClosed: false } vm)
|
||||
vm.CancelEditCommand.Execute(this);
|
||||
}
|
||||
|
||||
private void Window_OnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,8 @@ public partial class MainWindow : Window
|
||||
{
|
||||
EditPointDialog dialog = new EditPointDialog()
|
||||
{
|
||||
DataContext = new EditPointDialogViewModel(m.Point)
|
||||
DataContext = new EditPointDialogViewModel(m.Point),
|
||||
Point = m.Point.GetPoint()
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<PointViewModel?>(w));
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
99754bb29314deb0062acd8eb2e60c354c5dca2595b078551064b5cbb81f0742
|
||||
288757c38000c6b91b144251be635a8c5a7164190b6b87d309783f2ccc53212a
|
||||
|
||||
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("GazpromApp")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7beee75d142db7aa3c6c717883de75ca5bcd819e")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+044372eada717f33e07ad756f7ace116ab7fb9a3")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("GazpromApp")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("GazpromApp")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
d49af22cc4de304a3e0a6bfc5beb49f42e4f72fa6595042b67a80c2e9a1a3a11
|
||||
b6d09973f42f27742b27a1ce04303c8022bca7cb68cd245879c5b37de41be396
|
||||
|
||||
@@ -32,6 +32,9 @@ build_property.EnableCodeStyleSeverity =
|
||||
[D:/RiderProjects/GazpromApp/App.axaml]
|
||||
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
|
||||
|
||||
[D:/RiderProjects/GazpromApp/Views/EditEquipmentDialog.axaml]
|
||||
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
|
||||
|
||||
[D:/RiderProjects/GazpromApp/Views/EditPointDialog.axaml]
|
||||
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
|
||||
|
||||
@@ -41,5 +44,8 @@ build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
|
||||
[D:/RiderProjects/GazpromApp/Views/MainWindow.axaml]
|
||||
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
|
||||
|
||||
[D:/RiderProjects/GazpromApp/Views/NewEquipmentDialog.axaml]
|
||||
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
|
||||
|
||||
[D:/RiderProjects/GazpromApp/Views/NewPointDialog.axaml]
|
||||
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
|
||||
|
||||
Reference in New Issue
Block a user