Removed dialogs for editing equipment and points, and their related resources
This commit is contained in:
@@ -1,225 +0,0 @@
|
||||
<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"
|
||||
xmlns:enums="using:GazpromApp.Enums"
|
||||
x:Name="Window"
|
||||
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="600"
|
||||
Width="1000" Height="600"
|
||||
x:Class="GazpromApp.Views.EditEquipmentDialog"
|
||||
x:DataType="vm:EditEquipmentDialogViewModel"
|
||||
Title="Редактирование/просмотр оборудования"
|
||||
Icon="/Assets/ic_fluent_table_edit_24_filled (Custom).png"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Closing="Window_OnClosing"
|
||||
Closed="Window_OnClosed">
|
||||
<Design.DataContext>
|
||||
<vm:EditEquipmentDialogViewModel/>
|
||||
</Design.DataContext>
|
||||
<Window.Resources>
|
||||
<!-- ReSharper disable Xaml.RedundantResource -->
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<SolidColorBrush x:Key="BackgroundBrush" Color="#f0f0f0"/>
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#d3d3d3"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<SolidColorBrush x:Key="BackgroundBrush" Color="#101010"/>
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#303030"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
<!-- ReSharper restore Xaml.RedundantResource -->
|
||||
<enums:PeriodConverter x:Key="PeriodConverter"/>
|
||||
</Window.Resources>
|
||||
<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" AcceptsReturn="True" TextWrapping="Wrap"
|
||||
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"
|
||||
ItemsSource="{Binding Images}">
|
||||
<ItemsRepeater.Layout>
|
||||
<UniformGridLayout Orientation="Horizontal" MaximumRowsOrColumns="1"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:ImageViewModel">
|
||||
<Border Margin="4" CornerRadius="4" Background="LightGray">
|
||||
<Grid Margin="2" Width="200" Height="200" Background="LightGray"
|
||||
ColumnDefinitions="*,20,4,20,8" RowDefinitions="8,20,*">
|
||||
<Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="5"
|
||||
Source="{Binding FileName}" />
|
||||
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
|
||||
Command="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).ViewImageCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<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 #Root.((vm:EditEquipmentDialogViewModel)DataContext).DeleteImageCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
<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"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<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"/>
|
||||
</Button>
|
||||
</Panel>
|
||||
|
||||
<TabControl Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="2">
|
||||
<TabItem Header="Тех. осмотры">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<ItemsRepeater HorizontalAlignment="Stretch"
|
||||
ItemsSource="{Binding Inspections}">
|
||||
<ItemsRepeater.Layout>
|
||||
<StackLayout Orientation="Vertical" Spacing="8"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:InspectionViewModel">
|
||||
<Border CornerRadius="4" BorderThickness="1"
|
||||
Background="{DynamicResource BackgroundBrush}"
|
||||
BorderBrush="{DynamicResource BorderBrush}">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Panel>
|
||||
<TextBlock Margin="12,6,6,6" VerticalAlignment="Center"
|
||||
IsVisible="{Binding !IsEditing}"
|
||||
Text="{Binding Name}" FontSize="22"/>
|
||||
<TextBox Height="35" Margin="12,14,84,6" FontSize="18"
|
||||
IsVisible="{Binding IsEditing}"
|
||||
Text="{Binding Name}"/>
|
||||
<Button HorizontalAlignment="Right" Margin="0,8,20,0"
|
||||
Command="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).EditInspectionCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</Panel>
|
||||
<Grid ColumnDefinitions="Auto, Auto, Auto, Auto, Auto, *" Margin="8">
|
||||
<TextBlock Margin="10,0,0,0" Text="Дата проведения: " FontSize="18" VerticalAlignment="Center"/>
|
||||
<DatePicker Grid.Column="1" VerticalAlignment="Center"
|
||||
SelectedDate="{Binding InspectionDate}"/>
|
||||
|
||||
<TextBlock Grid.Column="2" Margin="16,0,0,0" Text="Период: " FontSize="18" VerticalAlignment="Center"/>
|
||||
<NumericUpDown Grid.Column="3" AllowSpin="True" Width="120" VerticalAlignment="Center"
|
||||
Value="{Binding PeriodValue}"
|
||||
Minimum="0"/>
|
||||
<ComboBox Grid.Column="4" Width="100" VerticalAlignment="Center" Margin="4,0,0,0"
|
||||
ItemsSource="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).AllPeriods}"
|
||||
SelectedItem="{Binding PeriodType, Mode=TwoWay}"
|
||||
DisplayMemberBinding="{Binding ., Converter={StaticResource PeriodConverter}}"/>
|
||||
<Button Grid.Column="5" Margin="0,0,12,0" HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Command="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).DeleteInspectionCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
<Button HorizontalAlignment="Center" Margin="10" Width="30" Height="30"
|
||||
Command="{Binding AddInspectionCommand}">
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_add_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Header="Свойства">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<TreeView ItemsSource="{Binding Properties}">
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="{x:Type vm:PropertyViewModel}"
|
||||
ItemsSource="{Binding Properties}">
|
||||
<Grid ColumnDefinitions="150,*,Auto,Auto,Auto">
|
||||
<TextBlock Grid.Column="0" FontSize="18" VerticalAlignment="Center"
|
||||
IsVisible="{Binding !IsEditing}"
|
||||
Text="{Binding Name}"/>
|
||||
<TextBox Grid.Column="0"
|
||||
IsVisible="{Binding IsEditing}"
|
||||
Text="{Binding Name}"/>
|
||||
|
||||
<TextBlock Grid.Column="1" FontSize="18" VerticalAlignment="Center"
|
||||
IsVisible="{Binding !IsEditing}"
|
||||
Text="{Binding Value}"/>
|
||||
<TextBox Grid.Column="1"
|
||||
IsVisible="{Binding IsEditing}"
|
||||
Text="{Binding Value}"/>
|
||||
|
||||
<Button Grid.Column="2" Width="30" Height="30" Margin="4" VerticalAlignment="Center"
|
||||
Command="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).AddPropertyCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_add_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
<Button Grid.Column="3" Width="30" Height="30" Margin="4" VerticalAlignment="Center"
|
||||
Command="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).EditPropertyCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Panel>
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom).png"
|
||||
IsVisible="{Binding !IsEditing}"/>
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_save_24_filled (Custom).png"
|
||||
IsVisible="{Binding IsEditing}"/>
|
||||
</Panel>
|
||||
</Button>
|
||||
<Button Grid.Column="4" Width="30" Height="30" Margin="4" VerticalAlignment="Center"
|
||||
Command="{Binding #Root.((vm:EditEquipmentDialogViewModel)DataContext).DeletePropertyCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Image Height="24" Width="24" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</TreeDataTemplate>
|
||||
</TreeView.DataTemplates>
|
||||
</TreeView>
|
||||
<Button HorizontalAlignment="Center" Margin="10" Width="30" Height="30"
|
||||
Command="{Binding AddPropertySimpleCommand}">
|
||||
<Image Height="24" Width="24" Source="avares://GazpromApp/Assets/ic_fluent_add_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</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,57 +0,0 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.ViewModels;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class EditEquipmentDialog : Window
|
||||
{
|
||||
public EditEquipmentDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Design.IsDesignMode)
|
||||
return;
|
||||
|
||||
// view image
|
||||
WeakReferenceMessenger.Default.Register<EditEquipmentDialog, ViewImageMessage>(this, static (w, m) =>
|
||||
{
|
||||
var dialog = new ImageView
|
||||
{
|
||||
DataContext = m.Image
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
|
||||
});
|
||||
|
||||
// error handling
|
||||
WeakReferenceMessenger.Default.Register<EditEquipmentDialog, ErrorMessage>(this, static (w, m) =>
|
||||
{
|
||||
var dialog = new ErrorView
|
||||
{
|
||||
DataContext = m.Error
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ErrorViewModel?>(w));
|
||||
});
|
||||
|
||||
// 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<ErrorMessage>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<EditEquipmentDone>(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<UserControl 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"
|
||||
xmlns:views="using:GazpromApp.Views"
|
||||
xmlns:icons="using:Material.Icons.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="GazpromApp.Views.EditEquipmentView"
|
||||
x:DataType="vm:EditEquipmentViewModel">
|
||||
|
||||
<Design.DataContext>
|
||||
<vm:EditEquipmentViewModel/>
|
||||
</Design.DataContext>
|
||||
<Grid RowDefinitions="70,150,*,Auto" ColumnDefinitions="*,100,220" x:Name="Root">
|
||||
<Grid.Styles>
|
||||
<Style Selector="Button.empty">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</Style>
|
||||
<Style Selector="Button.not-empty">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" FontSize="28" Margin="20,4"
|
||||
Text="{Binding Name, FallbackValue='Название'}"
|
||||
IsVisible="{Binding !IsNameEditing, FallbackValue=true}"/>
|
||||
<TextBox Grid.Column="0" Grid.Row="0" FontSize="28" Margin="20, 4"
|
||||
Text="{Binding Name, FallbackValue='Название'}"
|
||||
IsVisible="{Binding IsNameEditing, FallbackValue=false}"/>
|
||||
<Button Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center" Margin="10" Width="40" Height="40"
|
||||
Command="{Binding EditNameCommand}">
|
||||
<icons:MaterialIcon Kind="Edit" Width="24" Height="24"/>
|
||||
</Button>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Margin="20,4"
|
||||
Text="{Binding Description, FallbackValue='Описание'}"
|
||||
IsVisible="{Binding !IsDescriptionEditing, FallbackValue=true}"/>
|
||||
<TextBox Grid.Column="0" Grid.Row="1" Margin="20,4" AcceptsReturn="True" TextWrapping="Wrap"
|
||||
Text="{Binding Description, FallbackValue='Название'}"
|
||||
IsVisible="{Binding IsDescriptionEditing, FallbackValue=false}"/>
|
||||
<Button Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" Margin="10" Width="40" Height="40"
|
||||
Command="{Binding EditDescriptionCommand}">
|
||||
<icons:MaterialIcon Kind="Edit" Width="24" Height="24"/>
|
||||
</Button>
|
||||
|
||||
<Panel Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" HorizontalAlignment="Center">
|
||||
<ScrollViewer HorizontalAlignment="Center">
|
||||
<StackPanel>
|
||||
<ItemsRepeater HorizontalAlignment="Center"
|
||||
ItemsSource="{Binding Images}">
|
||||
<ItemsRepeater.Layout>
|
||||
<UniformGridLayout Orientation="Horizontal" MaximumRowsOrColumns="1"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:ImageViewModel">
|
||||
<Border Margin="4" CornerRadius="4" Background="LightGray">
|
||||
<Grid Margin="2" Width="200" Height="200" Background="LightGray"
|
||||
ColumnDefinitions="*,32,4,32,8" RowDefinitions="8,32,*">
|
||||
<Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="5"
|
||||
Source="{Binding FileName}" />
|
||||
<Button Grid.Row="1" Grid.Column="1" Width="32" Height="32"
|
||||
Command="{Binding ViewImageCommand}">
|
||||
<icons:MaterialIcon Kind="PrintPreview" Width="24" Height="24"/>
|
||||
</Button>
|
||||
<Button Grid.Row="1" Grid.Column="3" Width="32" Height="32"
|
||||
Command="{Binding DeleteImageCommand}">
|
||||
<icons:MaterialIcon Kind="Delete" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Width="40" Height="40"
|
||||
Classes.empty="{Binding !!Images.Count}"
|
||||
Classes.not-empty="{Binding !Images.Count}"
|
||||
Command="{Binding AddImageCommand}">
|
||||
<icons:MaterialIcon Kind="CameraPlus" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Width="40" Height="40"
|
||||
Classes.empty="{Binding !Images.Count}"
|
||||
Classes.not-empty="{Binding !!Images.Count}"
|
||||
Command="{Binding AddImageCommand}">
|
||||
<icons:MaterialIcon Kind="CameraPlus" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</Panel>
|
||||
|
||||
<TabControl Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3">
|
||||
<TabItem Header="Свойства">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<TreeView ItemsSource="{Binding Properties}">
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="{x:Type vm:PropertyViewModel}"
|
||||
ItemsSource="{Binding Properties}">
|
||||
<views:PropertyView/>
|
||||
</TreeDataTemplate>
|
||||
</TreeView.DataTemplates>
|
||||
</TreeView>
|
||||
<Button HorizontalAlignment="Center" Margin="4" Width="32" Height="32"
|
||||
Command="{Binding AddPropertyCommand}">
|
||||
<icons:MaterialIcon Kind="Add" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Header="Инспекции">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<TreeView ItemsSource="{Binding Inspections}">
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="{x:Type vm:InspectionViewModel}"
|
||||
ItemsSource="{Binding Inspection}">
|
||||
<views:InspectionView/>
|
||||
</TreeDataTemplate>
|
||||
</TreeView.DataTemplates>
|
||||
</TreeView>
|
||||
<Button HorizontalAlignment="Center" Margin="4" Width="32" Height="32"
|
||||
Command="{Binding AddInspectionCommand}">
|
||||
<icons:MaterialIcon Kind="Add" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
<Button Grid.Column="0" Grid.Row="3" Margin="8" Content="Отменить" HorizontalAlignment="Left"
|
||||
Command="{Binding CancelEditCommand}"/>
|
||||
<Button Grid.Column="2" Grid.Row="3" Margin="8" Content="Сохранить" HorizontalAlignment="Right"
|
||||
Command="{Binding CompleteEditCommand}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class EditEquipmentView : UserControl
|
||||
{
|
||||
public EditEquipmentView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
<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="1000" d:DesignHeight="600"
|
||||
Width="1000" Height="600"
|
||||
x:Class="GazpromApp.Views.EditPointDialog"
|
||||
x:DataType="vm:EditPointDialogViewModel"
|
||||
Title="Редактирование/просмотр объекта"
|
||||
Icon="/Assets/ic_fluent_edit_24_filled (Custom).png"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Closing="Window_OnClosing"
|
||||
Closed="Window_OnClosed">
|
||||
<Design.DataContext>
|
||||
<vm:EditPointDialogViewModel/>
|
||||
</Design.DataContext>
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<SolidColorBrush x:Key="BackgroundBrush" Color="#f0f0f0"/>
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#d3d3d3"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<!-- ReSharper disable once Xaml.RedundantResource -->
|
||||
<SolidColorBrush x:Key="BackgroundBrush" Color="#101010"/>
|
||||
<!-- ReSharper disable once Xaml.RedundantResource -->
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#303030"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<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" AcceptsReturn="True" TextWrapping="Wrap"
|
||||
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"
|
||||
ItemsSource="{Binding Images}">
|
||||
<ItemsRepeater.Layout>
|
||||
<UniformGridLayout Orientation="Horizontal" MaximumRowsOrColumns="1"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:ImageViewModel">
|
||||
<Border Margin="4" CornerRadius="4" Background="LightGray">
|
||||
<Grid Margin="2" Width="200" Height="200" Background="LightGray"
|
||||
ColumnDefinitions="*,20,4,20,8" RowDefinitions="8,20,*">
|
||||
<Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="5"
|
||||
Source="{Binding FileName}" />
|
||||
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
|
||||
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).ViewImageCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<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 #Root.((vm:EditPointDialogViewModel)DataContext).DeleteImageCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
<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"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<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"/>
|
||||
</Button>
|
||||
</Panel>
|
||||
|
||||
<TabControl Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="2">
|
||||
<TabItem Header="Оборудование">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<ItemsRepeater
|
||||
ItemsSource="{Binding Equipment}">
|
||||
<ItemsRepeater.Layout>
|
||||
<StackLayout Orientation="Vertical"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:EquipmentViewModel">
|
||||
<Expander HorizontalAlignment="Stretch" Margin="0,4,0,4"
|
||||
Background="{DynamicResource BackgroundBrush}"
|
||||
BorderBrush="{DynamicResource BorderBrush}">
|
||||
<Expander.Header>
|
||||
<Grid Height="54" HorizontalAlignment="Stretch"
|
||||
ColumnDefinitions="52, 300, *, Auto">
|
||||
<Image Height="50" Width="50" Margin="0,2,2,2" HorizontalAlignment="Center" Stretch="Uniform"
|
||||
Source="{Binding Images[0].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>
|
||||
<TabItem Header="Свойства">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<TreeView ItemsSource="{Binding Properties}">
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="{x:Type vm:PropertyViewModel}"
|
||||
ItemsSource="{Binding Properties}">
|
||||
<Grid ColumnDefinitions="150,*,Auto,Auto,Auto">
|
||||
<TextBlock Grid.Column="0" FontSize="18" VerticalAlignment="Center"
|
||||
IsVisible="{Binding !IsEditing}"
|
||||
Text="{Binding Name}"/>
|
||||
<TextBox Grid.Column="0"
|
||||
IsVisible="{Binding IsEditing}"
|
||||
Text="{Binding Name}"/>
|
||||
|
||||
<TextBlock Grid.Column="1" FontSize="18" VerticalAlignment="Center"
|
||||
IsVisible="{Binding !IsEditing}"
|
||||
Text="{Binding Value}"/>
|
||||
<TextBox Grid.Column="1"
|
||||
IsVisible="{Binding IsEditing}"
|
||||
Text="{Binding Value}"/>
|
||||
|
||||
<Button Grid.Column="2" Width="30" Height="30" Margin="4" VerticalAlignment="Center"
|
||||
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).AddPropertyCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_add_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
<Button Grid.Column="3" Width="30" Height="30" Margin="4" VerticalAlignment="Center"
|
||||
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).EditPropertyCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Panel>
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom).png"
|
||||
IsVisible="{Binding !IsEditing}"/>
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_save_24_filled (Custom).png"
|
||||
IsVisible="{Binding IsEditing}"/>
|
||||
</Panel>
|
||||
</Button>
|
||||
<Button Grid.Column="4" Width="30" Height="30" Margin="4" VerticalAlignment="Center"
|
||||
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).DeletePropertyCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Image Height="24" Width="24" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</TreeDataTemplate>
|
||||
</TreeView.DataTemplates>
|
||||
</TreeView>
|
||||
<Button HorizontalAlignment="Center" Margin="10" Width="30" Height="30"
|
||||
Command="{Binding AddPropertySimpleCommand}">
|
||||
<Image Height="24" Width="24" Source="avares://GazpromApp/Assets/ic_fluent_add_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</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,119 +0,0 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.ViewModels;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class EditPointDialog : Window
|
||||
{
|
||||
public EditPointDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Design.IsDesignMode)
|
||||
return;
|
||||
|
||||
// view image
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) =>
|
||||
{
|
||||
var dialog = new ImageView
|
||||
{
|
||||
DataContext = m.Image
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
|
||||
});
|
||||
|
||||
// error
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
|
||||
{
|
||||
var dialog = new ErrorView
|
||||
{
|
||||
DataContext = m.Error
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ErrorViewModel?>(w));
|
||||
});
|
||||
|
||||
// new equipment
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, NewEquipmentMessage>(this, (w, m) =>
|
||||
{
|
||||
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
|
||||
var dialog = new NewEquipmentDialog
|
||||
{
|
||||
DataContext = new NewEquipmentDialogViewModel()
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<EquipmentViewModel?>(w));
|
||||
});
|
||||
|
||||
// edit equipment
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, EditEquipmentMessage>(this, (w, m) =>
|
||||
{
|
||||
WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
|
||||
var dialog = new EditEquipmentDialog
|
||||
{
|
||||
DataContext = new EditEquipmentDialogViewModel(m.Equipment)
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<EquipmentViewModel?>(w));
|
||||
});
|
||||
|
||||
// re registering error when new equipment done
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, NewEquipmentDone>(this, (_, _) =>
|
||||
{
|
||||
if (!WeakReferenceMessenger.Default.IsRegistered<ErrorMessage>(this))
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
|
||||
{
|
||||
var dialog = new ErrorView
|
||||
{
|
||||
DataContext = m.Error
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ErrorViewModel?>(w));
|
||||
});
|
||||
});
|
||||
|
||||
// re registering view image and error view
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, EditEquipmentDone>(this, (_, _) =>
|
||||
{
|
||||
if (!WeakReferenceMessenger.Default.IsRegistered<ViewImageMessage>(this))
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) =>
|
||||
{
|
||||
var dialog = new ImageView
|
||||
{
|
||||
DataContext = m.Image
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
|
||||
});
|
||||
if (!WeakReferenceMessenger.Default.IsRegistered<ErrorMessage>(this))
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ErrorMessage>(this, static (w, m) =>
|
||||
{
|
||||
var dialog = new ErrorView
|
||||
{
|
||||
DataContext = m.Error
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ErrorViewModel?>(w));
|
||||
});
|
||||
});
|
||||
|
||||
// complete editing point
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, EditPointDone>(this, static (w, m) =>
|
||||
{
|
||||
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);
|
||||
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<NewEquipmentMessage>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<EditEquipmentMessage>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<EditPointDone>(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<UserControl 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"
|
||||
xmlns:views="using:GazpromApp.Views"
|
||||
xmlns:icons="using:Material.Icons.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="500"
|
||||
x:Class="GazpromApp.Views.EditPointView"
|
||||
x:DataType="vm:EditPointViewModel">
|
||||
<Design.DataContext>
|
||||
<vm:EditPointViewModel/>
|
||||
</Design.DataContext>
|
||||
<Grid RowDefinitions="70,150,*,Auto" ColumnDefinitions="*,100,220" x:Name="Root">
|
||||
<Grid.Styles>
|
||||
<Style Selector="Button.empty">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</Style>
|
||||
<Style Selector="Button.not-empty">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" FontSize="28" Margin="20,4"
|
||||
Text="{Binding Name, FallbackValue='Название'}"
|
||||
IsVisible="{Binding !IsNameEditing, FallbackValue=true}"/>
|
||||
<TextBox Grid.Column="0" Grid.Row="0" FontSize="28" Margin="20, 4"
|
||||
Text="{Binding Name, FallbackValue='Название'}"
|
||||
IsVisible="{Binding IsNameEditing, FallbackValue=false}"/>
|
||||
<Button Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center" Margin="10" Width="40" Height="40"
|
||||
Command="{Binding EditNameCommand}">
|
||||
<icons:MaterialIcon Kind="Edit" Width="24" Height="24"/>
|
||||
</Button>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Margin="20,4"
|
||||
Text="{Binding Description, FallbackValue='Описание'}"
|
||||
IsVisible="{Binding !IsDescriptionEditing, FallbackValue=true}"/>
|
||||
<TextBox Grid.Column="0" Grid.Row="1" Margin="20,4" AcceptsReturn="True" TextWrapping="Wrap"
|
||||
Text="{Binding Description, FallbackValue='Название'}"
|
||||
IsVisible="{Binding IsDescriptionEditing, FallbackValue=false}"/>
|
||||
<Button Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" Margin="10" Width="40" Height="40"
|
||||
Command="{Binding EditDescriptionCommand}">
|
||||
<icons:MaterialIcon Kind="Edit" Width="24" Height="24"/>
|
||||
</Button>
|
||||
|
||||
<Panel Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" HorizontalAlignment="Center">
|
||||
<ScrollViewer HorizontalAlignment="Center">
|
||||
<StackPanel>
|
||||
<ItemsRepeater HorizontalAlignment="Center"
|
||||
ItemsSource="{Binding Images}">
|
||||
<ItemsRepeater.Layout>
|
||||
<UniformGridLayout Orientation="Horizontal" MaximumRowsOrColumns="1"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:ImageViewModel">
|
||||
<Border Margin="4" CornerRadius="4" Background="LightGray">
|
||||
<Grid Margin="2" Width="200" Height="200" Background="LightGray"
|
||||
ColumnDefinitions="*,32,4,32,8" RowDefinitions="8,32,*">
|
||||
<Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="5"
|
||||
Source="{Binding FileName}" />
|
||||
<Button Grid.Row="1" Grid.Column="1" Width="32" Height="32"
|
||||
Command="{Binding ViewImageCommand}">
|
||||
<icons:MaterialIcon Kind="PrintPreview" Width="24" Height="24"/>
|
||||
</Button>
|
||||
<Button Grid.Row="1" Grid.Column="3" Width="32" Height="32"
|
||||
Command="{Binding DeleteImageCommand}">
|
||||
<icons:MaterialIcon Kind="Delete" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Width="40" Height="40"
|
||||
Classes.empty="{Binding !!Images.Count}"
|
||||
Classes.not-empty="{Binding !Images.Count}"
|
||||
Command="{Binding AddImageCommand}">
|
||||
<icons:MaterialIcon Kind="CameraPlus" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Width="40" Height="40"
|
||||
Classes.empty="{Binding !Images.Count}"
|
||||
Classes.not-empty="{Binding !!Images.Count}"
|
||||
Command="{Binding AddImageCommand}">
|
||||
<icons:MaterialIcon Kind="CameraPlus" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</Panel>
|
||||
|
||||
<ScrollViewer Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Свойства:" FontSize="24" Margin="24,0"/>
|
||||
<TreeView ItemsSource="{Binding Properties}">
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="{x:Type vm:PropertyViewModel}"
|
||||
ItemsSource="{Binding Properties}">
|
||||
<views:PropertyView/>
|
||||
</TreeDataTemplate>
|
||||
</TreeView.DataTemplates>
|
||||
</TreeView>
|
||||
<Button HorizontalAlignment="Center" Margin="4" Width="32" Height="32"
|
||||
Command="{Binding AddPropertyCommand}">
|
||||
<icons:MaterialIcon Kind="Add" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<Button Grid.Column="0" Grid.Row="3" Margin="8" Content="Отменить" HorizontalAlignment="Left"
|
||||
Command="{Binding CancelEditCommand}"/>
|
||||
<Button Grid.Column="2" Grid.Row="3" Margin="8" Content="Сохранить" HorizontalAlignment="Right"
|
||||
Command="{Binding CompleteEditCommand}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class EditPointView : UserControl
|
||||
{
|
||||
public EditPointView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<UserControl 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"
|
||||
xmlns:icons="using:Material.Icons.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="300" d:DesignHeight="500"
|
||||
x:Class="GazpromApp.Views.EquipmentView"
|
||||
x:DataType="vm:EquipmentViewModel">
|
||||
<Expander>
|
||||
<Expander.Header>
|
||||
<Grid ColumnDefinitions="Auto, Auto, *, Auto, Auto">
|
||||
<icons:MaterialIcon Kind="Location" Margin="0,0,8,0" Width="24" Height="24"/>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center" TextWrapping="WrapWithOverflow"
|
||||
Text="{Binding Name}"/>
|
||||
<Button Width="32" Grid.Column="3" Margin="0,0,8,0"
|
||||
Command="{Binding AddEquipmentCommand}">
|
||||
<icons:MaterialIcon Kind="Add" Width="24" Height="24"/>
|
||||
</Button>
|
||||
<Button Width="32" Grid.Column="4" Margin="0,0,8,0"
|
||||
Command="{Binding RemoveEquipmentCommand}">
|
||||
<icons:MaterialIcon Kind="Delete" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Expander.Header>
|
||||
<Grid RowDefinitions="Auto,Auto,Auto" RowSpacing="4" Margin="8,4,8,2">
|
||||
<TextBlock Text="{Binding Description}" />
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||
<TextBlock Text="Оборудований: "/>
|
||||
<TextBlock Text="{Binding Equipments.Count}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal">
|
||||
<TextBlock Text="Свойств: "/>
|
||||
<TextBlock Text="{Binding Properties.Count}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Expander>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class EquipmentView : UserControl
|
||||
{
|
||||
public EquipmentView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<UserControl 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"
|
||||
xmlns:icons="using:Material.Icons.Avalonia"
|
||||
xmlns:enums="using:GazpromApp.Enums"
|
||||
mc:Ignorable="d" d:DesignWidth="930" d:DesignHeight="450"
|
||||
x:Class="GazpromApp.Views.InspectionView"
|
||||
x:DataType="vm:InspectionViewModel">
|
||||
<Design.DataContext>
|
||||
<vm:InspectionViewModel/>
|
||||
</Design.DataContext>
|
||||
<UserControl.Resources>
|
||||
<enums:PeriodConverter x:Key="PeriodConverter"/>
|
||||
</UserControl.Resources>
|
||||
<Border CornerRadius="4" BorderThickness="1">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Grid ColumnDefinitions="*, Auto">
|
||||
<TextBlock Grid.Column="0" Margin="12,6" FontSize="22" Height="50"
|
||||
IsVisible="{Binding !IsEditing}"
|
||||
Text="{Binding Name}"/>
|
||||
<TextBox Grid.Column="0" Margin="12,6" FontSize="18" Height="50"
|
||||
IsVisible="{Binding IsEditing}"
|
||||
Text="{Binding Name}"/>
|
||||
<Button Grid.Column="1" HorizontalAlignment="Right" Margin="12,6" Height="40" Width="40"
|
||||
Command="{Binding EditInspectionCommand}">
|
||||
<icons:MaterialIcon Kind="Edit" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="*, Auto">
|
||||
<WrapPanel VerticalAlignment="Top">
|
||||
<TextBlock Margin="10,2" Text="Дата проведения:"
|
||||
FontSize="18" VerticalAlignment="Center"/>
|
||||
<DatePicker FontSize="18" VerticalAlignment="Center"
|
||||
SelectedDate="{Binding InspectionDate}"/>
|
||||
|
||||
<TextBlock Margin="10,2" Text="Период:" FontSize="18" VerticalAlignment="Center"/>
|
||||
<NumericUpDown AllowSpin="True" Width="120" Margin="10,2" FontSize="18"
|
||||
Value="{Binding PeriodValue}"
|
||||
Minimum="0"/>
|
||||
<ComboBox Width="110" VerticalAlignment="Center" Margin="10,2" FontSize="18"
|
||||
ItemsSource="{Binding AllPeriods}"
|
||||
SelectedItem="{Binding PeriodType, Mode=TwoWay}"
|
||||
DisplayMemberBinding="{Binding .,
|
||||
Converter={StaticResource PeriodConverter}}"/>
|
||||
</WrapPanel>
|
||||
<Button Grid.Column="1" Margin="12,6" Height="40" Width="40"
|
||||
Command="{Binding RemoveInspectionCommand}">
|
||||
<icons:MaterialIcon Kind="Delete" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class InspectionView : UserControl
|
||||
{
|
||||
public InspectionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
+31
-72
@@ -4,43 +4,27 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:anim="https://github.com/whistyun/AnimatedImage.Avalonia"
|
||||
xmlns:vm="using:GazpromApp.ViewModels"
|
||||
xmlns:views="using:GazpromApp.Views"
|
||||
xmlns:icons="using:Material.Icons.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="1024" d:DesignHeight="600"
|
||||
Width="1024" Height="600"
|
||||
x:Class="GazpromApp.Views.MainWindow"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
x:Name="Window"
|
||||
Icon="/Assets/gazpromapp.ico"
|
||||
Title="GazpromApp"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
WindowState="Maximized"
|
||||
Closing="Window_OnClosing">
|
||||
<Design.DataContext>
|
||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||
<vm:MainWindowViewModel/>
|
||||
</Design.DataContext>
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<SolidColorBrush x:Key="BackgroundBrush" Color="#f0f0f0"/>
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#d3d3d3"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<!-- ReSharper disable once Xaml.RedundantResource -->
|
||||
<SolidColorBrush x:Key="BackgroundBrush" Color="#101010"/>
|
||||
<!-- ReSharper disable once Xaml.RedundantResource -->
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#303030"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
|
||||
<DockPanel x:Name="Root">
|
||||
<Menu DockPanel.Dock="Top">
|
||||
<MenuItem Command="{Binding AddPointCommand}">
|
||||
<MenuItem Command="{Binding SyncDbCommand}">
|
||||
<MenuItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_home_add_24_filled (Custom).png"/>
|
||||
<TextBlock Margin="8,0,0,0" Text="Добавить" VerticalAlignment="Center"/>
|
||||
<icons:MaterialIcon Kind="Sync" Width="24" Height="24"/>
|
||||
<TextBlock Margin="8,0,0,0" Text="Сохранить и обновить" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</MenuItem.Header>
|
||||
</MenuItem>
|
||||
@@ -48,7 +32,7 @@
|
||||
CommandParameter="{Binding #Window}">
|
||||
<MenuItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_arrow_export_ltr_24_filled (Custom).png"/>
|
||||
<icons:MaterialIcon Kind="Upload" Width="24" Height="24"/>
|
||||
<TextBlock Margin="8,0,0,0" Text="Экспорт" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</MenuItem.Header>
|
||||
@@ -57,66 +41,41 @@
|
||||
CommandParameter="{Binding #Window}">
|
||||
<MenuItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Width="24" Height="24" Source="avares://GazpromApp/Assets/ic_fluent_arrow_import_24_filled (Custom).png"/>
|
||||
<icons:MaterialIcon Kind="Download" Width="24" Height="24"/>
|
||||
<TextBlock Margin="8,0,0,0" Text="Импорт" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</MenuItem.Header>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<Grid DockPanel.Dock="Top" HorizontalAlignment="Stretch"
|
||||
ColumnDefinitions="*,*,100">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition MaxHeight="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollViewer Grid.ColumnSpan="3">
|
||||
<Grid DockPanel.Dock="Top" HorizontalAlignment="Stretch"
|
||||
ColumnDefinitions="*,2,2*">
|
||||
<ScrollViewer>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<ItemsRepeater ItemsSource="{Binding Points}">
|
||||
<ItemsRepeater.Layout>
|
||||
<StackLayout Orientation="Vertical"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:PointViewModel">
|
||||
<Border CornerRadius="4" BorderThickness="1" Margin="6"
|
||||
Background="{DynamicResource BackgroundBrush}"
|
||||
BorderBrush="{DynamicResource BorderBrush}">
|
||||
<Grid Margin="6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MaxWidth="300"/>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock FontSize="24" Margin="4" VerticalAlignment="Center"
|
||||
Grid.Column="0"
|
||||
Text="{Binding Name}"/>
|
||||
<TextBlock Margin="4" VerticalAlignment="Center"
|
||||
Grid.Column="1"
|
||||
Text="{Binding Description}"/>
|
||||
<Button Grid.Column="2"
|
||||
Command="{Binding #Root.((vm:MainWindowViewModel)DataContext).EditPointCommand}"
|
||||
CommandParameter="{Binding .}"
|
||||
Margin="4">
|
||||
<Image Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
<Button Grid.Column="3"
|
||||
Command="{Binding #Root.((vm:MainWindowViewModel)DataContext).RemovePointCommand}"
|
||||
CommandParameter="{Binding .}"
|
||||
Margin="4">
|
||||
<Image Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
<TreeView ItemsSource="{Binding Points}"
|
||||
SelectionChanged="TreeView_OnSelectionChanged">
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="{x:Type vm:PointViewModel}"
|
||||
ItemsSource="{Binding Equipment}">
|
||||
<views:PointView Padding="0,0,20,0"/>
|
||||
</TreeDataTemplate>
|
||||
<TreeDataTemplate DataType="{x:Type vm:EquipmentViewModel}"
|
||||
ItemsSource="{Binding Equipments}">
|
||||
<views:EquipmentView Padding="0,0,20,0"/>
|
||||
</TreeDataTemplate>
|
||||
</TreeView.DataTemplates>
|
||||
</TreeView>
|
||||
<Button Classes="Accent" Height="32" Width="32" Margin="4" HorizontalAlignment="Center"
|
||||
Command="{Binding AddPointCommand}">
|
||||
<icons:MaterialIcon Kind="Add" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<GridSplitter Background="#b6b6b6" Grid.Column="1" ResizeDirection="Columns"/>
|
||||
<ContentControl Grid.Column="2" Content="{Binding SelectedItemViewModel}"/>
|
||||
<Image Width="100" Height="100" VerticalAlignment="Center"
|
||||
IsVisible="{Binding IsLoading}"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Grid.ColumnSpan="3" Grid.RowSpan="2"
|
||||
anim:ImageBehavior.AnimatedSource="avares://GazpromApp/Assets/loading.gif"/>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
|
||||
+71
-15
@@ -1,4 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.ViewModels;
|
||||
@@ -7,29 +13,79 @@ namespace GazpromApp.Views;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private bool _canClose = false;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Design.IsDesignMode)
|
||||
return;
|
||||
|
||||
WeakReferenceMessenger.Default.Register<MainWindow, RequestImageMessage>(this, HandleImageSelection);
|
||||
WeakReferenceMessenger.Default.Register<MainWindow, ViewImageMessage>(this, HandleImageViewer);
|
||||
WeakReferenceMessenger.Default.Register<MainWindow, ErrorMessage>(this, HandleErrorViewer);
|
||||
WeakReferenceMessenger.Default.Register<MainWindow, SaveChangesResult>(this, HandleSave);
|
||||
}
|
||||
|
||||
private static void HandleImageSelection(MainWindow sender, RequestImageMessage msg)
|
||||
{
|
||||
var files = sender.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
AllowMultiple = true,
|
||||
Title = "Выберите одну или несколько картинок",
|
||||
FileTypeFilter = [FilePickerFileTypes.ImageAll]
|
||||
});
|
||||
|
||||
msg.Reply(files);
|
||||
}
|
||||
|
||||
WeakReferenceMessenger.Default.Register<MainWindow, NewPointMessage>(this, static (w, m) =>
|
||||
private static void HandleImageViewer(MainWindow sender, ViewImageMessage msg)
|
||||
{
|
||||
var dialog = new ImageView
|
||||
{
|
||||
var dialog = new NewPointDialog
|
||||
{
|
||||
DataContext = new NewPointDialogViewModel()
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<PointViewModel?>(w));
|
||||
});
|
||||
|
||||
WeakReferenceMessenger.Default.Register<MainWindow, EditPointMessage>(this, static (w, m) =>
|
||||
DataContext = msg.Image
|
||||
};
|
||||
msg.Reply(dialog.ShowDialog<ImageViewModel?>(sender));
|
||||
}
|
||||
|
||||
private static void HandleErrorViewer(MainWindow sender, ErrorMessage msg)
|
||||
{
|
||||
var dialog = new ErrorView
|
||||
{
|
||||
var dialog = new EditPointDialog
|
||||
{
|
||||
DataContext = new EditPointDialogViewModel(m.Point)
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<PointViewModel?>(w));
|
||||
});
|
||||
DataContext = msg.Error
|
||||
};
|
||||
msg.Reply(dialog.ShowDialog<ErrorViewModel?>(sender));
|
||||
}
|
||||
|
||||
private void TreeView_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.AddedItems.Count > 0)
|
||||
WeakReferenceMessenger.Default.Send(new SelectionChangedMessage((ViewModelBase)e.AddedItems[0]!));
|
||||
}
|
||||
|
||||
private void HandleSave(object sender, SaveChangesResult msg)
|
||||
{
|
||||
if (msg.Cancel) return;
|
||||
if (msg.Save)
|
||||
((MainWindowViewModel)DataContext!).SyncDbCommand.Execute(null);
|
||||
ForceClose();
|
||||
}
|
||||
|
||||
private void ForceClose()
|
||||
{
|
||||
_canClose = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Window_OnClosing(object? sender, WindowClosingEventArgs e)
|
||||
{
|
||||
if (_canClose) return;
|
||||
if (!((MainWindowViewModel)DataContext!).CanSync) return;
|
||||
var dialog = new SaveChangesView
|
||||
{
|
||||
DataContext = new SaveChangesViewModel()
|
||||
};
|
||||
dialog.ShowDialog<SaveChangesViewModel?>(this);
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
<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="Создание нового оборудования"
|
||||
Icon="/Assets/ic_fluent_table_add_24_filled (Custom).png"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Closed="Window_OnClosed">
|
||||
<Design.DataContext>
|
||||
<vm:NewEquipmentDialogViewModel/>
|
||||
</Design.DataContext>
|
||||
<Grid Margin="12" 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" AcceptsReturn="True" TextWrapping="Wrap"
|
||||
Text="{Binding Description}"/>
|
||||
|
||||
<Panel Grid.Column="1" Grid.Row="2" Margin="8" IsVisible="{Binding !IsImagesEmpty}">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<ItemsRepeater ItemsSource="{Binding Images}" HorizontalAlignment="Center">
|
||||
<ItemsRepeater.Layout>
|
||||
<UniformGridLayout Orientation="Horizontal" MaximumRowsOrColumns="1"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:ImageViewModel">
|
||||
<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}" />
|
||||
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
|
||||
Command="{Binding #Root.((vm:NewEquipmentDialogViewModel)DataContext).DeleteImageCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
<Button HorizontalAlignment="Center" IsVisible="True"
|
||||
Command="{Binding AddImageCommand}"
|
||||
CommandParameter="{Binding #Window}">
|
||||
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Panel>
|
||||
|
||||
<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>
|
||||
@@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.ViewModels;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class NewEquipmentDialog : Window
|
||||
{
|
||||
public NewEquipmentDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// done entering new equipment
|
||||
WeakReferenceMessenger.Default.Register<NewEquipmentDialog, NewEquipmentDone>(this, static (w, m) =>
|
||||
{
|
||||
w.Close(m.Equipment);
|
||||
});
|
||||
|
||||
// register to work with errors
|
||||
WeakReferenceMessenger.Default.Register<NewEquipmentDialog, ErrorMessage>(this, static (w, m) =>
|
||||
{
|
||||
var dialog = new ErrorView
|
||||
{
|
||||
DataContext = m.Error
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ErrorViewModel?>(w));
|
||||
});
|
||||
}
|
||||
|
||||
private void Window_OnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Unregister<NewEquipmentDone>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
<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.NewPointDialog"
|
||||
x:DataType="vm:NewPointDialogViewModel"
|
||||
Title="Создание нового объекта"
|
||||
Icon="/Assets/ic_fluent_home_add_24_filled (Custom).png"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Closed="Window_OnClosed">
|
||||
<Design.DataContext>
|
||||
<vm:NewPointDialogViewModel/>
|
||||
</Design.DataContext>
|
||||
<Grid Margin="12" 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" AcceptsReturn="True" TextWrapping="Wrap"
|
||||
Text="{Binding Description}"/>
|
||||
<Panel Grid.Column="1" Grid.Row="2" Margin="8" IsVisible="{Binding !IsImagesEmpty}">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<ItemsRepeater ItemsSource="{Binding Images}" HorizontalAlignment="Center">
|
||||
<ItemsRepeater.Layout>
|
||||
<UniformGridLayout Orientation="Horizontal" MaximumRowsOrColumns="1"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:ImageViewModel">
|
||||
<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}" />
|
||||
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
|
||||
Command="{Binding #Root.((vm:NewPointDialogViewModel)DataContext).DeleteImageCommand}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
<Button HorizontalAlignment="Center" IsVisible="True"
|
||||
Command="{Binding AddImageCommand}"
|
||||
CommandParameter="{Binding #Window}">
|
||||
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Panel>
|
||||
<Panel Grid.Column="1" Grid.Row="2" Margin="8"
|
||||
IsVisible="{Binding IsImagesEmpty}">
|
||||
<Button HorizontalAlignment="Center" IsVisible="True"
|
||||
Command="{Binding AddImageCommand}"
|
||||
CommandParameter="{Binding #Window}">
|
||||
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
|
||||
</Button>
|
||||
</Panel>
|
||||
<Button Grid.Column="0" Grid.Row="3" Margin="8" Content="Отменить"
|
||||
Command="{Binding CancelEnterPointCommand}"
|
||||
CommandParameter="{Binding #Window}"/>
|
||||
<Button Grid.Column="1" Grid.Row="3" Margin="8" Content="Добавить" HorizontalAlignment="Right"
|
||||
Command="{Binding EnterPointCommand}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,36 +0,0 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.ViewModels;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class NewPointDialog : Window
|
||||
{
|
||||
public NewPointDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// done entering a new point
|
||||
WeakReferenceMessenger.Default.Register<NewPointDialog, NewPointDone>(this, static (w, m) =>
|
||||
{
|
||||
w.Close(m.Point);
|
||||
});
|
||||
|
||||
// register to work with errors
|
||||
WeakReferenceMessenger.Default.Register<NewPointDialog, ErrorMessage>(this, static (w, m) =>
|
||||
{
|
||||
var dialog = new ErrorView
|
||||
{
|
||||
DataContext = m.Error
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ErrorViewModel?>(w));
|
||||
});
|
||||
}
|
||||
|
||||
private void Window_OnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<UserControl 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"
|
||||
xmlns:views="using:GazpromApp.Views"
|
||||
xmlns:icons="using:Material.Icons.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="300" d:DesignHeight="500"
|
||||
x:Class="GazpromApp.Views.PointView"
|
||||
x:DataType="vm:PointViewModel">
|
||||
<Expander>
|
||||
<Expander.Header>
|
||||
<Grid ColumnDefinitions="Auto, Auto, *, Auto, Auto">
|
||||
<icons:MaterialIcon Kind="Location" Margin="0,0,8,0" Width="24" Height="24"/>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center" TextWrapping="WrapWithOverflow"
|
||||
Text="{Binding Name}"/>
|
||||
<Button Width="32" Grid.Column="3" Margin="0,0,8,0"
|
||||
Command="{Binding AddEquipmentCommand}">
|
||||
<icons:MaterialIcon Kind="Add" Width="24" Height="24"/>
|
||||
</Button>
|
||||
<Button Width="32" Grid.Column="4" Margin="0,0,8,0"
|
||||
Command="{Binding RemovePointCommand}">
|
||||
<icons:MaterialIcon Kind="Delete" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Expander.Header>
|
||||
<Grid RowDefinitions="Auto,Auto,Auto,Auto" RowSpacing="4" Margin="8,4,8,2">
|
||||
<Grid.Styles>
|
||||
<Style Selector="ItemsRepeater.empty">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</Style>
|
||||
<Style Selector="ItemsRepeater.not-empty">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
<TextBlock Text="{Binding Description}"/>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||
<TextBlock Text="Оборудований: "/>
|
||||
<TextBlock Text="{Binding Equipment.Count}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal">
|
||||
<TextBlock Text="Свойств: "/>
|
||||
<TextBlock Text="{Binding Properties.Count}"/>
|
||||
</StackPanel>
|
||||
<ItemsRepeater Grid.Row="3" Margin="4,8"
|
||||
ItemsSource="{Binding Images}"
|
||||
Classes.empty="{Binding !!Images.Count}"
|
||||
Classes.not-empty="{Binding !Images.Count}">
|
||||
<ItemsRepeater.Layout>
|
||||
<StackLayout Orientation="Horizontal" Spacing="4"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:ImageViewModel">
|
||||
<Image Width="64" Height="64" Source="{Binding FileName}"/>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
</Grid>
|
||||
</Expander>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Windows.Input;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class PointView : UserControl
|
||||
{
|
||||
public PointView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<UserControl 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"
|
||||
xmlns:icons="using:Material.Icons.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="GazpromApp.Views.PropertyView"
|
||||
x:DataType="vm:PropertyViewModel">
|
||||
<Grid ColumnDefinitions="150,*,Auto,Auto,Auto">
|
||||
<TextBlock Grid.Column="0" FontSize="18" VerticalAlignment="Center"
|
||||
IsVisible="{Binding !IsEditing}"
|
||||
Text="{Binding Name}"/>
|
||||
<TextBox Grid.Column="0" FontSize="18"
|
||||
IsVisible="{Binding IsEditing}"
|
||||
Text="{Binding Name}"/>
|
||||
|
||||
<TextBlock Grid.Column="1" FontSize="18" VerticalAlignment="Center"
|
||||
IsVisible="{Binding !IsEditing}"
|
||||
Text="{Binding Value}"/>
|
||||
<TextBox Grid.Column="1"
|
||||
IsVisible="{Binding IsEditing}"
|
||||
Text="{Binding Value}"/>
|
||||
|
||||
<Button Grid.Column="2" Width="32" Height="32" Margin="4" VerticalAlignment="Center"
|
||||
Command="{Binding AddPropertyCommand}">
|
||||
<icons:MaterialIcon Kind="Add" Width="24" Height="24"/>
|
||||
</Button>
|
||||
<Button Grid.Column="3" Width="32" Height="32" Margin="4" VerticalAlignment="Center"
|
||||
Command="{Binding EditPropertyCommand}">
|
||||
<Panel>
|
||||
<icons:MaterialIcon Kind="Edit" Width="24" Height="24"
|
||||
IsVisible="{Binding !IsEditing}"/>
|
||||
<icons:MaterialIcon Kind="ContentSave" Width="24" Height="24"
|
||||
IsVisible="{Binding IsEditing}"/>
|
||||
</Panel>
|
||||
</Button>
|
||||
<Button Grid.Column="4" Width="32" Height="32" Margin="4" VerticalAlignment="Center"
|
||||
Command="{Binding RemovePropertyCommand}">
|
||||
<icons:MaterialIcon Kind="Delete" Width="24" Height="24"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class PropertyView : UserControl
|
||||
{
|
||||
public PropertyView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<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="400" d:DesignHeight="180"
|
||||
Width="400" Height="180"
|
||||
x:Class="GazpromApp.Views.SaveChangesView"
|
||||
x:DataType="vm:SaveChangesViewModel"
|
||||
Title="Не сохраненные данные"
|
||||
Icon="/Assets/ic_fluent_error_circle_24_filled (1) (Custom).png"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Closing="Window_OnClosing"
|
||||
Closed="Window_OnClosed">
|
||||
<Grid x:Name="Root" Margin="16"
|
||||
ColumnDefinitions="50, *" RowDefinitions="50, *, Auto">
|
||||
<Image Grid.Row="0" Grid.Column="0"
|
||||
Source="avares://GazpromApp/Assets/ic_fluent_info_24_filled (Custom).png"/>
|
||||
<Panel Grid.Row="0" Grid.Column="1" Grid.RowSpan="2">
|
||||
<StackPanel Margin="8">
|
||||
<TextBlock Text="Есть несохраненные изменения." FontSize="20" MaxLines="2" TextWrapping="Wrap"/>
|
||||
<TextBlock Text="Уверены что хотите закрыть?" MaxLines="3" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
<Panel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="8">
|
||||
<Button Content="Не сохранять" Background="LightCoral"
|
||||
Command="{Binding DontSaveCommand}"
|
||||
CommandParameter="{Binding #Window}"/>
|
||||
<Button Content="Отмена"
|
||||
Command="{Binding CancelCommand}"
|
||||
CommandParameter="{Binding #Window}"/>
|
||||
<Button Content="Сохранить"
|
||||
Command="{Binding SaveCommand}"
|
||||
CommandParameter="{Binding #Window}"/>
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class SaveChangesView : Window
|
||||
{
|
||||
public bool CanClose = false;
|
||||
public SaveChangesView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_OnClosing(object? sender, WindowClosingEventArgs e)
|
||||
{
|
||||
if (CanClose) return;
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
private void Window_OnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user