Modifying equipment works
This commit is contained in:
@@ -2,8 +2,78 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
xmlns:vm="using:GazpromApp.ViewModels"
|
||||
x:Name="Window"
|
||||
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="600"
|
||||
Width="1000" Height="600"
|
||||
x:Class="GazpromApp.Views.EditEquipmentDialog"
|
||||
Title="EditEquipmentDialog">
|
||||
Welcome to Avalonia!
|
||||
x:DataType="vm:EditEquipmentDialogViewModel"
|
||||
Title="EditEquipmentDialog"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Closing="Window_OnClosing"
|
||||
Closed="Window_OnClosed">
|
||||
<Design.DataContext>
|
||||
<vm:EditEquipmentDialogViewModel/>
|
||||
</Design.DataContext>
|
||||
<Grid RowDefinitions="70,150,*,Auto" ColumnDefinitions="*,100,220" x:Name="Root">
|
||||
<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>
|
||||
|
||||
<Grid Grid.Row="0" Grid.RowSpan="2" Grid.Column="2"
|
||||
ColumnDefinitions="*,20,4,20,8" RowDefinitions="8,20,*"
|
||||
IsVisible="{Binding IsImageSelected}">
|
||||
|
||||
<Image Grid.ColumnSpan="5" Grid.RowSpan="3"
|
||||
Source="{Binding Image.FileName, FallbackValue=null}"/>
|
||||
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
|
||||
Command="{Binding ViewImageCommand}">
|
||||
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_eye_show_24_filled (Custom) 16.png"/>
|
||||
</Button>
|
||||
<Button Grid.Row="1" Grid.Column="3" Width="20" Height="20"
|
||||
Command="{Binding DeleteImageCommand}">
|
||||
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Button Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" HorizontalAlignment="Center"
|
||||
IsVisible="{Binding !IsImageSelected}"
|
||||
Command="{Binding AddImageCommand}"
|
||||
CommandParameter="{Binding #Window}">
|
||||
<Image Width="24" Height="24"
|
||||
Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
|
||||
<TabControl Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="2">
|
||||
<TabItem Header="Тех. осмотры">
|
||||
|
||||
</TabItem>
|
||||
<TabItem Header="Свойства">
|
||||
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
<Button Grid.Column="0" Grid.Row="3" Margin="8" Content="Отменить"
|
||||
Command="{Binding CancelEditCommand}"
|
||||
CommandParameter="{Binding #Window}"/>
|
||||
<Button Grid.Column="2" Grid.Row="3" Margin="8" Content="Сохранить" HorizontalAlignment="Right"
|
||||
Command="{Binding CompleteEditCommand}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -1,13 +1,57 @@
|
||||
using Avalonia;
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.Models;
|
||||
using GazpromApp.ViewModels;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class EditEquipmentDialog : Window
|
||||
{
|
||||
public Equipment? Equipment;
|
||||
|
||||
public EditEquipmentDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Design.IsDesignMode)
|
||||
return;
|
||||
|
||||
// view image
|
||||
WeakReferenceMessenger.Default.Register<EditEquipmentDialog, ViewImageMessage>(this, static (w, m) =>
|
||||
{
|
||||
ImageView dialog = new ImageView()
|
||||
{
|
||||
DataContext = m.Image
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
|
||||
});
|
||||
|
||||
// new property dialog
|
||||
|
||||
// edit property dialog
|
||||
|
||||
// complete editing equipment
|
||||
WeakReferenceMessenger.Default.Register<EditEquipmentDialog, EditEquipmentDone>(this, static (w, m) =>
|
||||
{
|
||||
w.Close(m.Equipment);
|
||||
});
|
||||
}
|
||||
|
||||
private void Window_OnClosing(object? sender, WindowClosingEventArgs e)
|
||||
{
|
||||
if (DataContext is EditEquipmentDialogViewModel { IsClosed: false} vm)
|
||||
vm.CancelEditCommand.Execute(this);
|
||||
}
|
||||
|
||||
private void Window_OnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this);
|
||||
//
|
||||
//
|
||||
WeakReferenceMessenger.Default.Unregister<EditEquipmentDone>(this);
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,8 @@
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<Button HorizontalAlignment="Center" VerticalAlignment="Center" IsVisible="{Binding IsImagesEmpty}"
|
||||
<Button HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
IsVisible="{Binding IsImagesEmpty}"
|
||||
Command="{Binding AddImageCommand}"
|
||||
CommandParameter="{Binding #Window}">
|
||||
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
|
||||
@@ -89,9 +90,9 @@
|
||||
<StackPanel>
|
||||
<ItemsRepeater
|
||||
IsVisible="{Binding !IsEquipmentEmpty}"
|
||||
ItemsSource="{Binding Equipment}">
|
||||
ItemsSource="{Binding Equipment}">
|
||||
<ItemsRepeater.Layout>
|
||||
<NonVirtualizingStackLayout Orientation="Vertical"/>
|
||||
<StackLayout Orientation="Vertical"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:EquipmentViewModel">
|
||||
|
||||
@@ -39,15 +39,29 @@ public partial class EditPointDialog : Window
|
||||
});
|
||||
|
||||
// edit equipment
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, EditEquipmentMessage>(this, static (w, m) =>
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, EditEquipmentMessage>(this, (w, m) =>
|
||||
{
|
||||
WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this);
|
||||
EditEquipmentDialog dialog = new EditEquipmentDialog()
|
||||
{
|
||||
DataContext = m.Equipment
|
||||
DataContext = new EditEquipmentDialogViewModel(m.Equipment)
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<EquipmentViewModel?>(w));
|
||||
});
|
||||
|
||||
// re registering view image
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, EditEquipmentDone>(this, (w, m) =>
|
||||
{
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) =>
|
||||
{
|
||||
ImageView dialog = new ImageView()
|
||||
{
|
||||
DataContext = m.Image
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
|
||||
});
|
||||
});
|
||||
|
||||
// new property
|
||||
|
||||
// edit property
|
||||
|
||||
Reference in New Issue
Block a user