Skip to content

Commit 3b91633

Browse files
committed
Fix FIO in DataGrid and some improves
1 parent 0fdd3fe commit 3b91633

27 files changed

+197
-166
lines changed

SudInfo.Avalonia/App.axaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<Application xmlns="https://github.com/avaloniaui"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:converters="using:SudInfo.Avalonia.Converters"
34
x:Class="SudInfo.Avalonia.App">
45
<Application.Styles>
56
<FluentTheme Mode="Light"/>
@@ -22,4 +23,7 @@
2223
Value="True"/>
2324
</Style>
2425
</Application.Styles>
26+
<Application.Resources>
27+
<converters:UriAssetToBitmapConverter x:Key="UriAssetToBitmapConverter"/>
28+
</Application.Resources>
2529
</Application>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace SudInfo.Avalonia.Converters;
2+
3+
public class UriAssetToBitmapConverter : IValueConverter
4+
{
5+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
6+
{
7+
var assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
8+
return new Bitmap(assets.Open(new(value.ToString())));
9+
}
10+
11+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => string.Empty;
12+
}

SudInfo.Avalonia/GlobalUsings.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
global using Avalonia;
22
global using Avalonia.Controls;
3+
global using Avalonia.Data.Converters;
34
global using Avalonia.Markup.Xaml;
5+
global using Avalonia.Media.Imaging;
6+
global using Avalonia.Platform;
47
global using Avalonia.ReactiveUI;
8+
global using ClosedXML.Excel;
59
global using MessageBox.Avalonia.DTO;
610
global using MessageBox.Avalonia.Enums;
711
global using Microsoft.EntityFrameworkCore;
@@ -23,8 +27,8 @@
2327
global using System.Collections.Generic;
2428
global using System.Collections.ObjectModel;
2529
global using System.ComponentModel.DataAnnotations;
30+
global using System.Data;
31+
global using System.Globalization;
2632
global using System.Linq;
2733
global using System.Threading.Tasks;
28-
global using System.Windows.Input;
29-
global using ClosedXML.Excel;
30-
global using System.Data;
34+
global using System.Windows.Input;

SudInfo.Avalonia/ViewModels/WindowViewModels/PeripheryWindowViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace SudInfo.Avalonia.ViewModels.WindowViewModels;
2+
23
public class PeripheryWindowViewModel : BaseViewModel
34
{
45
#region Services
@@ -55,7 +56,7 @@ public PeripheryWindowViewModel()
5556
#region Public Methods
5657
public async Task SavePeriphery()
5758
{
58-
if (ValidationModel(Periphery))
59+
if (!ValidationModel(Periphery))
5960
return;
6061
if (!IsComputer)
6162
Periphery.Computer = null;

SudInfo.Avalonia/Views/Pages/PrintersPage.axaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@
7777
<DataGridTextColumn Header="Год выпуска"
7878
Binding="{Binding YearRelease}"
7979
IsReadOnly="True"/>
80-
<DataGridTextColumn Header="Фамилия сотрудника"
81-
Binding="{Binding User.LastName}"
80+
<DataGridTextColumn Header="Сотрудник"
81+
Binding="{Binding Computer.User.FIO}"
8282
Width="*"
8383
IsReadOnly="True"/>
84-
<DataGridTextColumn Header="Кабинет"
84+
<DataGridTextColumn Header="Кабинет"
8585
Binding="{Binding Cabinet}"
8686
IsReadOnly="True"/>
8787
<DataGridTemplateColumn Width="40">

SudInfo.Avalonia/Views/Windows/AppWindow.axaml

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
5+
mc:Ignorable="d"
6+
d:DesignWidth="800"
7+
d:DesignHeight="450"
68
x:Class="SudInfo.Avalonia.Views.Windows.AppWindow"
79
Title="Приложение"
810
xmlns:viewModels="clr-namespace:SudInfo.Avalonia.ViewModels.WindowViewModels;assembly=SudInfo.Avalonia"
@@ -14,33 +16,35 @@
1416
CanResize="False"
1517
Width="600"
1618
Height="400">
17-
<StackPanel Margin="10"
18-
Spacing="5">
19-
<TextBox Text="{Binding AppEntity.Name}"
20-
Watermark="Название"/>
21-
<TextBox Text="{Binding AppEntity.Version}"
22-
Watermark="Версия"/>
23-
<TextBlock Text="Компьютеры"/>
24-
<ListBox Items="{Binding Computers}"
25-
SelectedItems="{Binding AppEntity.Computers}"
26-
SelectionMode="Toggle"
27-
Height="200">
28-
<ListBox.ItemTemplate>
29-
<DataTemplate DataType="models:Computer">
30-
<StackPanel Orientation="Horizontal">
31-
<TextBlock Text="{Binding Name}"/>
32-
<TextBlock Text=" | "/>
33-
<TextBlock Text="{Binding User.FIO}"/>
34-
</StackPanel>
35-
</DataTemplate>
36-
</ListBox.ItemTemplate>
37-
</ListBox>
38-
<Button Content="{Binding SaveButtonText}"
39-
Command="{Binding SaveApp}"
40-
Cursor="Hand"
41-
FontWeight="Bold"
42-
HorizontalAlignment="Stretch"
43-
HorizontalContentAlignment="Center"
44-
IsVisible="{Binding ButtonIsVisible}"/>
45-
</StackPanel>
19+
<StackPanel Margin="10"
20+
Spacing="5">
21+
<TextBox Text="{Binding AppEntity.Name}"
22+
Watermark="Название"
23+
MaxLength="100"/>
24+
<TextBox Text="{Binding AppEntity.Version}"
25+
Watermark="Версия"
26+
MaxLength="20"/>
27+
<TextBlock Text="Компьютеры"/>
28+
<ListBox Items="{Binding Computers}"
29+
SelectedItems="{Binding AppEntity.Computers}"
30+
SelectionMode="Toggle"
31+
Height="200">
32+
<ListBox.ItemTemplate>
33+
<DataTemplate DataType="models:Computer">
34+
<StackPanel Orientation="Horizontal">
35+
<TextBlock Text="{Binding Name}"/>
36+
<TextBlock Text=" | "/>
37+
<TextBlock Text="{Binding User.FIO}"/>
38+
</StackPanel>
39+
</DataTemplate>
40+
</ListBox.ItemTemplate>
41+
</ListBox>
42+
<Button Content="{Binding SaveButtonText}"
43+
Command="{Binding SaveApp}"
44+
Cursor="Hand"
45+
FontWeight="Bold"
46+
HorizontalAlignment="Stretch"
47+
HorizontalContentAlignment="Center"
48+
IsVisible="{Binding ButtonIsVisible}"/>
49+
</StackPanel>
4650
</Window>

SudInfo.Avalonia/Views/Windows/ComputerWindow.axaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<StackPanel Margin="10"
2222
Spacing="5">
2323
<TextBox Text="{Binding Computer.Name}"
24-
MaxLength="50"
24+
MaxLength="100"
2525
Watermark="Название"/>
2626
<TextBox Text="{Binding Computer.Ip}"
2727
MaxLength="15"
@@ -31,10 +31,10 @@
3131
Items="{Binding OsesList}"
3232
SelectedItem="{Binding Computer.OS}"/>
3333
<TextBox Text="{Binding Computer.CPU}"
34-
MaxLength="15"
34+
MaxLength="100"
3535
Watermark="CPU"/>
3636
<TextBox Text="{Binding Computer.GPU}"
37-
MaxLength="15"
37+
MaxLength="100"
3838
Watermark="GPU (Необязательно)"/>
3939
<TextBox Text="{Binding Computer.ROM}"
4040
MaxLength="5"
@@ -46,10 +46,10 @@
4646
MaxLength="4"
4747
Text="{Binding Computer.YearRelease}"/>
4848
<TextBox Text="{Binding Computer.SerialNumber}"
49-
MaxLength="20"
49+
MaxLength="50"
5050
Watermark="Серийный номер"/>
5151
<TextBox Text="{Binding Computer.InventarNumber}"
52-
MaxLength="20"
52+
MaxLength="50"
5353
Watermark="Инвентарный номер"/>
5454
<TextBox Text="{Binding Computer.NumberCabinet}"
5555
MaxLength="4"

SudInfo.Avalonia/Views/Windows/ContactWindow.axaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,17 @@
1717
Spacing="5"
1818
Width="280">
1919
<TextBox
20-
MaxLength="50"
20+
MaxLength="100"
2121
Text="{Binding Contact.Name}"
2222
Watermark="Имя"/>
2323
<TextBox Watermark="Номер телефона"
2424
MaxLength="11"
2525
Text="{Binding Contact.Phone}"/>
26-
<TextBox Watermark="Номер телефона"
27-
MaxLength="11"
28-
Text="{Binding Contact.Phone}"/>
2926
<TextBox Watermark="Email"
30-
MaxLength="50"
27+
MaxLength="100"
3128
Text="{Binding Contact.Email}"/>
3229
<TextBox Watermark="Описание"
33-
MaxLength="200"
30+
MaxLength="500"
3431
TextWrapping="Wrap"
3532
Height="130"
3633
Text="{Binding Contact.Description}"/>

SudInfo.Avalonia/Views/Windows/MonitorWindow.axaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<StackPanel Margin="10"
2222
Spacing="5">
2323
<TextBox Text="{Binding Monitor.Name}"
24-
MaxLength="50"
24+
MaxLength="100"
2525
Watermark="Название монитора"/>
2626
<TextBox Text="{Binding Monitor.ScreenSize}"
2727
MaxLength="2"
@@ -36,10 +36,10 @@
3636
MaxLength="4"
3737
Text="{Binding Monitor.YearRelease}"/>
3838
<TextBox Text="{Binding Monitor.SerialNumber}"
39-
MaxLength="20"
39+
MaxLength="50"
4040
Watermark="Серийный номер"/>
4141
<TextBox Text="{Binding Monitor.InventarNumber}"
42-
MaxLength="20"
42+
MaxLength="50"
4343
Watermark="Инвентарный номер"/>
4444
<StackPanel Orientation="Horizontal">
4545
<CheckBox Name="IsUserBox"

SudInfo.Avalonia/Views/Windows/PasswordWindow.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
TextWrapping="Wrap"
2222
Height="150"/>
2323
<TextBox Text="{Binding Password.Link}"
24-
MaxLength="50"
24+
MaxLength="100"
2525
Watermark="Ссылка"/>
2626
<TextBox Text="{Binding Password.Login}"
2727
MaxLength="50"

0 commit comments

Comments
 (0)