Modifying points works
This commit is contained in:
@@ -2,8 +2,104 @@
|
||||
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.EditPointDialog"
|
||||
Title="EditPointDialog">
|
||||
Welcome to Avalonia!
|
||||
x:DataType="vm:EditPointDialogViewModel"
|
||||
Title="Редактирование/просмотр объекта"
|
||||
Icon="/Assets/ic_fluent_edit_24_filled (Custom).png"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<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">
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Header="Свойства">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
|
||||
</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,6 +1,7 @@
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.ViewModels;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
@@ -10,6 +11,18 @@ public partial class EditPointDialog : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Design.IsDesignMode)
|
||||
return;
|
||||
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) =>
|
||||
{
|
||||
ImageView dialog = new ImageView()
|
||||
{
|
||||
DataContext = m.Image
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
|
||||
});
|
||||
|
||||
WeakReferenceMessenger.Default.Register<EditPointDialog, EditPointDone>(this, static (w, m) =>
|
||||
{
|
||||
w.Close(m.Point);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<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="800" d:DesignHeight="450"
|
||||
Width="{Binding FileName.Size.Width}" Height="{Binding FileName.Size.Height}" MaxWidth="1280" MaxHeight="720"
|
||||
x:Class="GazpromApp.Views.ImageView"
|
||||
x:DataType="vm:ImageViewModel"
|
||||
Title="Просмотр изображения"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<Design.DataContext>
|
||||
<vm:ImageViewModel/>
|
||||
</Design.DataContext>
|
||||
<Image Source="{Binding FileName}"/>
|
||||
</Window>
|
||||
@@ -0,0 +1,18 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
public partial class ImageView : Window
|
||||
{
|
||||
public ImageView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Design.IsDesignMode)
|
||||
return;
|
||||
|
||||
this.ExtendClientAreaToDecorationsHint = true;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:GazpromApp.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
Width="1424" Height="714"
|
||||
x:Class="GazpromApp.Views.MainWindow"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
@@ -58,7 +59,13 @@
|
||||
<ItemsControl ItemsSource="{Binding Points}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="vm:PointViewModel">
|
||||
<Grid ColumnDefinitions="200, *, Auto, Auto" Margin="10,6,18,6" RowDefinitions="12, Auto">
|
||||
<Grid Margin="10,6,18,6" RowDefinitions="12, Auto">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MaxWidth="300"/>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Margin="-2,0,-2,5" Grid.ColumnSpan="4" Height="1" Fill="Gray" Opacity="0.25" VerticalAlignment="Top"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding Name}" FontSize="24" Margin="4" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Description}" Margin="4" VerticalAlignment="Center"/>
|
||||
|
||||
@@ -22,11 +22,12 @@ public partial class MainWindow : Window
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<PointViewModel?>(w));
|
||||
});
|
||||
|
||||
WeakReferenceMessenger.Default.Register<MainWindow, EditPointMessage>(this, static (w, m) =>
|
||||
{
|
||||
EditPointDialog dialog = new EditPointDialog()
|
||||
{
|
||||
DataContext = new EditPointDialogViewModel()
|
||||
DataContext = new EditPointDialogViewModel(m.Point)
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<PointViewModel?>(w));
|
||||
});
|
||||
|
||||
+27
-28
@@ -8,7 +8,7 @@
|
||||
Width="500" Height="500"
|
||||
x:Class="GazpromApp.Views.NewPointDialog"
|
||||
x:DataType="vm:NewPointDialogViewModel"
|
||||
Title="NewPointDialog"
|
||||
Title="Создание нового объекта"
|
||||
Icon="/Assets/ic_fluent_home_add_24_filled (Custom).png"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<Design.DataContext>
|
||||
@@ -33,32 +33,28 @@
|
||||
<TextBox Grid.Column="1" Grid.Row="1" Margin="8"
|
||||
Text="{Binding Description}"/>
|
||||
<Panel Grid.Column="1" Grid.Row="2" Margin="8" IsVisible="{Binding !IsImagesEmpty}">
|
||||
<ScrollViewer HorizontalAlignment="Center">
|
||||
<StackPanel Orientation="Vertical" Spacing="6">
|
||||
<ItemsControl ItemsSource="{Binding Images}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<ItemsRepeater ItemsSource="{Binding Images}" HorizontalAlignment="Center">
|
||||
<ItemsRepeater.Layout>
|
||||
<UniformGridLayout Orientation="Horizontal" MaximumRowsOrColumns="1"/>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate DataType="vm:ImageViewModel">
|
||||
<Grid Margin="6" Width="200" Height="200" Background="LightGray">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MaxHeight="8"/>
|
||||
<RowDefinition MaxHeight="20"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition MaxWidth="20"/>
|
||||
<ColumnDefinition MaxWidth="8"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<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).DeleteImage}"
|
||||
CommandParameter="{Binding .}">
|
||||
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
<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>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
<Button HorizontalAlignment="Center" IsVisible="True"
|
||||
Command="{Binding AddImageCommand}"
|
||||
CommandParameter="{Binding #Window}">
|
||||
@@ -67,15 +63,18 @@
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Panel>
|
||||
<Panel Grid.Column="1" Grid.Row="2" Margin="8" IsVisible="{Binding IsImagesEmpty}">
|
||||
<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="Отменить"/>
|
||||
<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 EnterPoint}"/>
|
||||
Command="{Binding EnterPointCommand}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
Reference in New Issue
Block a user