Adding equipment works
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
x:Class="GazpromApp.Views.EditEquipmentDialog"
|
||||
Title="EditEquipmentDialog">
|
||||
Welcome to Avalonia!
|
||||
</Window>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class EditEquipmentDialog : Window
|
||||
{
|
||||
public EditEquipmentDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,54 @@
|
||||
<TabItem Header="Оборудование">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
|
||||
<ItemsRepeater
|
||||
IsVisible="{Binding !IsEquipmentEmpty}"
|
||||
ItemsSource="{Binding Equipment}">
|
||||
<ItemsRepeater.Layout>
|
||||
<NonVirtualizingStackLayout Orientation="Vertical"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:EquipmentViewModel">
|
||||
<Expander HorizontalAlignment="Stretch" Margin="0,4,0,4">
|
||||
<Expander.Header>
|
||||
<Grid Height="54" HorizontalAlignment="Left"
|
||||
ColumnDefinitions="52, 300, *, Auto">
|
||||
<Image Height="50" Width="50" Margin="0,2,2,2" HorizontalAlignment="Center" Stretch="Uniform"
|
||||
Source="{Binding Image.FileName, FallbackValue=null}"/>
|
||||
<TextBlock Grid.Column="1" FontSize="20" VerticalAlignment="Center" Margin="4,0,0,0"
|
||||
Text="{Binding Name}"/>
|
||||
<TextBlock Grid.Column="2" FontSize="15" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Stretch"
|
||||
Text="{Binding Description}"/>
|
||||
</Grid>
|
||||
</Expander.Header>
|
||||
<Grid ColumnDefinitions="Auto, *, Auto, Auto">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock FontSize="18" Text="Ближайший ТО: "/>
|
||||
<TextBlock FontSize="18" Text="{Binding NearestInspection}"/>
|
||||
<TextBlock FontSize="18" Text="Свойств: " Margin="18, 0,0,0"/>
|
||||
<TextBlock FontSize="18" Text="{Binding Properties.Count}"/>
|
||||
</StackPanel>
|
||||
<Button Grid.Column="2"
|
||||
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).EditEquipmentCommand}"
|
||||
CommandParameter="{Binding .}"
|
||||
Margin="4,0,4,0">
|
||||
<Image Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
<Button Grid.Column="3"
|
||||
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).DeleteEquipmentCommand}"
|
||||
CommandParameter="{Binding .}"
|
||||
Margin="4,0,4,0">
|
||||
<Image Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Expander>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
<Button Height="30" Width="30" HorizontalAlignment="Center" Margin="0,20,0,0"
|
||||
Command="{Binding AddEquipmentCommand}">
|
||||
<Image Height="24" Width="24" Source="avares://GazpromApp/Assets/ic_fluent_add_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
|
||||
@@ -28,6 +28,31 @@ public partial class EditPointDialog : Window
|
||||
m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
|
||||
});
|
||||
|
||||
// new equipment
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, NewEquipmentMessage>(this, static (w, m) =>
|
||||
{
|
||||
NewEquipmentDialog dialog = new NewEquipmentDialog()
|
||||
{
|
||||
DataContext = new NewEquipmentDialogViewModel()
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<EquipmentViewModel?>(w));
|
||||
});
|
||||
|
||||
// edit equipment
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, EditEquipmentMessage>(this, static (w, m) =>
|
||||
{
|
||||
EditEquipmentDialog dialog = new EditEquipmentDialog()
|
||||
{
|
||||
DataContext = m.Equipment
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<EquipmentViewModel?>(w));
|
||||
});
|
||||
|
||||
// new property
|
||||
|
||||
// edit property
|
||||
|
||||
// complete editing point
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, EditPointDone>(this, static (w, m) =>
|
||||
{
|
||||
w.Close(m.Point);
|
||||
@@ -43,5 +68,10 @@ public partial class EditPointDialog : Window
|
||||
private void Window_OnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<NewEquipmentMessage>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<EditEquipmentMessage>(this);
|
||||
// new prop
|
||||
// edit prop
|
||||
WeakReferenceMessenger.Default.Unregister<EditPointDone>(this);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,8 @@
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
Title="GazpromApp"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
WindowStartupLocation="CenterScreen"
|
||||
>
|
||||
|
||||
<Design.DataContext>
|
||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
xmlns:vm="using:GazpromApp.ViewModels"
|
||||
x:Name="Window"
|
||||
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="500"
|
||||
Width="500" Height="500"
|
||||
x:Class="GazpromApp.Views.NewEquipmentDialog"
|
||||
x:DataType="vm:NewEquipmentDialogViewModel"
|
||||
Title="Создание нового оборудования"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Closed="Window_OnClosed">
|
||||
<Design.DataContext>
|
||||
<vm:NewEquipmentDialogViewModel/>
|
||||
</Design.DataContext>
|
||||
<Grid x:Name="Root">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition MaxWidth="120"/>
|
||||
<ColumnDefinition MinWidth="300"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MaxHeight="50"/>
|
||||
<RowDefinition MaxHeight="100"/>
|
||||
<RowDefinition MinHeight="200" Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Margin="8" Text="Название: "/>
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Margin="8" Text="Описание: "/>
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" Margin="8" Text="Изображение: "/>
|
||||
<TextBox Grid.Column="1" Grid.Row="0" Margin="8"
|
||||
Text="{Binding Name}"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="1" Margin="8"
|
||||
Text="{Binding Description}"/>
|
||||
|
||||
<Grid Grid.Column="1" Grid.Row="2" Margin="2"
|
||||
ColumnDefinitions="*,20,8,20,8" RowDefinitions="8,20,*"
|
||||
IsVisible="True">
|
||||
<Image Stretch="Uniform" Grid.RowSpan="3" Grid.ColumnSpan="3"
|
||||
Source="{Binding Image.FileName, FallbackValue=null}"/>
|
||||
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
|
||||
IsVisible="{Binding IsImageSelected}"
|
||||
Command="{Binding AddImageCommand}"
|
||||
CommandParameter="{Binding #Window}">
|
||||
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom) 16.png"/>
|
||||
</Button>
|
||||
<Button Grid.Row="1" Grid.Column="3" Width="20" Height="20"
|
||||
IsVisible="{Binding IsImageSelected}"
|
||||
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="2" Grid.Column="1" HorizontalAlignment="Center"
|
||||
IsVisible="{Binding !IsImageSelected}"
|
||||
Command="{Binding AddImageCommand}"
|
||||
CommandParameter="{Binding #Window}">
|
||||
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
|
||||
<Button Grid.Column="0" Grid.Row="3" Margin="8" Content="Отменить"
|
||||
Command="{Binding CancelEnterEquipmentCommand}"
|
||||
CommandParameter="{Binding #Window}"/>
|
||||
<Button Grid.Column="1" Grid.Row="3" Margin="8" Content="Добавить" HorizontalAlignment="Right"
|
||||
Command="{Binding EnterEquipmentCommand}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Messages;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class NewEquipmentDialog : Window
|
||||
{
|
||||
public NewEquipmentDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
WeakReferenceMessenger.Default.Register<NewEquipmentDialog, NewEquipmentDone>(this, static (w, m) =>
|
||||
{
|
||||
w.Close(m.Equipment);
|
||||
});
|
||||
}
|
||||
|
||||
private void Window_OnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Unregister<NewEquipmentDone>(this);
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,8 @@
|
||||
<Border Margin="4" CornerRadius="4" Background="LightGray">
|
||||
<Grid Margin="2" Width="200" Height="200" Background="LightGray"
|
||||
ColumnDefinitions="*,20,8" RowDefinitions="8,20,*">
|
||||
<Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="3" Source="{Binding FileName}" />
|
||||
<Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="3"
|
||||
Source="{Binding FileName}" />
|
||||
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
|
||||
Command="{Binding #Root.((vm:NewPointDialogViewModel)DataContext).DeleteImageCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
|
||||
Reference in New Issue
Block a user