Skip to content

Commit

Permalink
Fix FIO in DataGrid and some improves
Browse files Browse the repository at this point in the history
  • Loading branch information
DIMANRUS committed Jun 26, 2023
1 parent 0fdd3fe commit 3b91633
Show file tree
Hide file tree
Showing 27 changed files with 197 additions and 166 deletions.
4 changes: 4 additions & 0 deletions SudInfo.Avalonia/App.axaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:SudInfo.Avalonia.Converters"
x:Class="SudInfo.Avalonia.App">
<Application.Styles>
<FluentTheme Mode="Light"/>
Expand All @@ -22,4 +23,7 @@
Value="True"/>
</Style>
</Application.Styles>
<Application.Resources>
<converters:UriAssetToBitmapConverter x:Key="UriAssetToBitmapConverter"/>
</Application.Resources>
</Application>
12 changes: 12 additions & 0 deletions SudInfo.Avalonia/Converters/UriAssetBitmapConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace SudInfo.Avalonia.Converters;

public class UriAssetToBitmapConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
return new Bitmap(assets.Open(new(value.ToString())));
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => string.Empty;
}
10 changes: 7 additions & 3 deletions SudInfo.Avalonia/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
global using Avalonia;
global using Avalonia.Controls;
global using Avalonia.Data.Converters;
global using Avalonia.Markup.Xaml;
global using Avalonia.Media.Imaging;
global using Avalonia.Platform;
global using Avalonia.ReactiveUI;
global using ClosedXML.Excel;
global using MessageBox.Avalonia.DTO;
global using MessageBox.Avalonia.Enums;
global using Microsoft.EntityFrameworkCore;
Expand All @@ -23,8 +27,8 @@
global using System.Collections.Generic;
global using System.Collections.ObjectModel;
global using System.ComponentModel.DataAnnotations;
global using System.Data;
global using System.Globalization;
global using System.Linq;
global using System.Threading.Tasks;
global using System.Windows.Input;
global using ClosedXML.Excel;
global using System.Data;
global using System.Windows.Input;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace SudInfo.Avalonia.ViewModels.WindowViewModels;

public class PeripheryWindowViewModel : BaseViewModel
{
#region Services
Expand Down Expand Up @@ -55,7 +56,7 @@ public PeripheryWindowViewModel()
#region Public Methods
public async Task SavePeriphery()
{
if (ValidationModel(Periphery))
if (!ValidationModel(Periphery))
return;
if (!IsComputer)
Periphery.Computer = null;
Expand Down
6 changes: 3 additions & 3 deletions SudInfo.Avalonia/Views/Pages/PrintersPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@
<DataGridTextColumn Header="Год выпуска"
Binding="{Binding YearRelease}"
IsReadOnly="True"/>
<DataGridTextColumn Header="Фамилия сотрудника"
Binding="{Binding User.LastName}"
<DataGridTextColumn Header="Сотрудник"
Binding="{Binding Computer.User.FIO}"
Width="*"
IsReadOnly="True"/>
<DataGridTextColumn Header="Кабинет"
<DataGridTextColumn Header="Кабинет"
Binding="{Binding Cabinet}"
IsReadOnly="True"/>
<DataGridTemplateColumn Width="40">
Expand Down
64 changes: 34 additions & 30 deletions SudInfo.Avalonia/Views/Windows/AppWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
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"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
x:Class="SudInfo.Avalonia.Views.Windows.AppWindow"
Title="Приложение"
xmlns:viewModels="clr-namespace:SudInfo.Avalonia.ViewModels.WindowViewModels;assembly=SudInfo.Avalonia"
Expand All @@ -14,33 +16,35 @@
CanResize="False"
Width="600"
Height="400">
<StackPanel Margin="10"
Spacing="5">
<TextBox Text="{Binding AppEntity.Name}"
Watermark="Название"/>
<TextBox Text="{Binding AppEntity.Version}"
Watermark="Версия"/>
<TextBlock Text="Компьютеры"/>
<ListBox Items="{Binding Computers}"
SelectedItems="{Binding AppEntity.Computers}"
SelectionMode="Toggle"
Height="200">
<ListBox.ItemTemplate>
<DataTemplate DataType="models:Computer">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}"/>
<TextBlock Text=" | "/>
<TextBlock Text="{Binding User.FIO}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Content="{Binding SaveButtonText}"
Command="{Binding SaveApp}"
Cursor="Hand"
FontWeight="Bold"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
IsVisible="{Binding ButtonIsVisible}"/>
</StackPanel>
<StackPanel Margin="10"
Spacing="5">
<TextBox Text="{Binding AppEntity.Name}"
Watermark="Название"
MaxLength="100"/>
<TextBox Text="{Binding AppEntity.Version}"
Watermark="Версия"
MaxLength="20"/>
<TextBlock Text="Компьютеры"/>
<ListBox Items="{Binding Computers}"
SelectedItems="{Binding AppEntity.Computers}"
SelectionMode="Toggle"
Height="200">
<ListBox.ItemTemplate>
<DataTemplate DataType="models:Computer">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}"/>
<TextBlock Text=" | "/>
<TextBlock Text="{Binding User.FIO}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Content="{Binding SaveButtonText}"
Command="{Binding SaveApp}"
Cursor="Hand"
FontWeight="Bold"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
IsVisible="{Binding ButtonIsVisible}"/>
</StackPanel>
</Window>
10 changes: 5 additions & 5 deletions SudInfo.Avalonia/Views/Windows/ComputerWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<StackPanel Margin="10"
Spacing="5">
<TextBox Text="{Binding Computer.Name}"
MaxLength="50"
MaxLength="100"
Watermark="Название"/>
<TextBox Text="{Binding Computer.Ip}"
MaxLength="15"
Expand All @@ -31,10 +31,10 @@
Items="{Binding OsesList}"
SelectedItem="{Binding Computer.OS}"/>
<TextBox Text="{Binding Computer.CPU}"
MaxLength="15"
MaxLength="100"
Watermark="CPU"/>
<TextBox Text="{Binding Computer.GPU}"
MaxLength="15"
MaxLength="100"
Watermark="GPU (Необязательно)"/>
<TextBox Text="{Binding Computer.ROM}"
MaxLength="5"
Expand All @@ -46,10 +46,10 @@
MaxLength="4"
Text="{Binding Computer.YearRelease}"/>
<TextBox Text="{Binding Computer.SerialNumber}"
MaxLength="20"
MaxLength="50"
Watermark="Серийный номер"/>
<TextBox Text="{Binding Computer.InventarNumber}"
MaxLength="20"
MaxLength="50"
Watermark="Инвентарный номер"/>
<TextBox Text="{Binding Computer.NumberCabinet}"
MaxLength="4"
Expand Down
9 changes: 3 additions & 6 deletions SudInfo.Avalonia/Views/Windows/ContactWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@
Spacing="5"
Width="280">
<TextBox
MaxLength="50"
MaxLength="100"
Text="{Binding Contact.Name}"
Watermark="Имя"/>
<TextBox Watermark="Номер телефона"
MaxLength="11"
Text="{Binding Contact.Phone}"/>
<TextBox Watermark="Номер телефона"
MaxLength="11"
Text="{Binding Contact.Phone}"/>
<TextBox Watermark="Email"
MaxLength="50"
MaxLength="100"
Text="{Binding Contact.Email}"/>
<TextBox Watermark="Описание"
MaxLength="200"
MaxLength="500"
TextWrapping="Wrap"
Height="130"
Text="{Binding Contact.Description}"/>
Expand Down
6 changes: 3 additions & 3 deletions SudInfo.Avalonia/Views/Windows/MonitorWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<StackPanel Margin="10"
Spacing="5">
<TextBox Text="{Binding Monitor.Name}"
MaxLength="50"
MaxLength="100"
Watermark="Название монитора"/>
<TextBox Text="{Binding Monitor.ScreenSize}"
MaxLength="2"
Expand All @@ -36,10 +36,10 @@
MaxLength="4"
Text="{Binding Monitor.YearRelease}"/>
<TextBox Text="{Binding Monitor.SerialNumber}"
MaxLength="20"
MaxLength="50"
Watermark="Серийный номер"/>
<TextBox Text="{Binding Monitor.InventarNumber}"
MaxLength="20"
MaxLength="50"
Watermark="Инвентарный номер"/>
<StackPanel Orientation="Horizontal">
<CheckBox Name="IsUserBox"
Expand Down
2 changes: 1 addition & 1 deletion SudInfo.Avalonia/Views/Windows/PasswordWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
TextWrapping="Wrap"
Height="150"/>
<TextBox Text="{Binding Password.Link}"
MaxLength="50"
MaxLength="100"
Watermark="Ссылка"/>
<TextBox Text="{Binding Password.Login}"
MaxLength="50"
Expand Down
4 changes: 2 additions & 2 deletions SudInfo.Avalonia/Views/Windows/PeripheryWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
MaxLength="50"
Watermark="Название"/>
<TextBox Text="{Binding Periphery.SerialNumber}"
MaxLength="20"
MaxLength="50"
Watermark="Серийный номер"/>
<TextBox Text="{Binding Periphery.InventarNumber}"
MaxLength="20"
MaxLength="50"
Watermark="Инвентарный номер"/>
<ComboBox
HorizontalAlignment="Stretch"
Expand Down
8 changes: 4 additions & 4 deletions SudInfo.Avalonia/Views/Windows/PrinterWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Width="300"
Height="500"
Height="430"
CanResize="False"
xmlns:viewModels="clr-namespace:SudInfo.Avalonia.ViewModels.WindowViewModels;assembly=SudInfo.Avalonia"
xmlns:i="using:Avalonia.Xaml.Interactivity"
Expand All @@ -21,7 +21,7 @@
<StackPanel Margin="10"
Spacing="5">
<TextBox Watermark="Название"
MaxLength="40"
MaxLength="100"
Text="{Binding Printer.Name}"/>
<TextBox Watermark="IP Адрес"
MaxLength="12"
Expand All @@ -34,10 +34,10 @@
SelectedItem="{Binding Printer.Type}"
HorizontalAlignment="Stretch"/>
<TextBox Text="{Binding Printer.SerialNumber}"
MaxLength="20"
MaxLength="50"
Watermark="Серийный номер"/>
<TextBox Text="{Binding Printer.InventarNumber}"
MaxLength="20"
MaxLength="50"
Watermark="Инвентарный номер"/>
<TextBox Watermark="Год выпуска"
MaxLength="4"
Expand Down
2 changes: 1 addition & 1 deletion SudInfo.Avalonia/Views/Windows/ServerRackWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<StackPanel Margin="10"
Spacing="5">
<TextBox Watermark="Серийный номер"
MaxLength="20"
MaxLength="50"
Text="{Binding ServerRack.InventarNumber}"/>
<Button Content="{Binding SaveButtonText}"
Command="{Binding SaveServerRack}"
Expand Down
6 changes: 3 additions & 3 deletions SudInfo.Avalonia/Views/Windows/ServerWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<StackPanel Margin="10"
Spacing="5">
<TextBox Watermark="Название"
MaxLength="20"
MaxLength="100"
Text="{Binding Server.Name}"/>
<TextBox Watermark="Серийный номер"
MaxLength="20"
MaxLength="50"
Text="{Binding Server.SerialNumber}"/>
<TextBox Watermark="Инвентарный номер"
MaxLength="20"
MaxLength="50"
Text="{Binding Server.InventarNumber}"/>
<TextBox Watermark="IP адрес"
MaxLength="20"
Expand Down
8 changes: 5 additions & 3 deletions SudInfo.EfDataAccessLibrary/Const.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
public static class Const
{
public const string EmptyWithSpaceString = " ";
public const string LengthMore2 = "Длина должна быть больше 2";
public const string FieldRequired = "Требуется к заполнению";
public const string NotValidIp4Message = "Не соответствует формату IP4";
public const string LengthMore2 = "Длина должна быть больше 2.";
public const string FieldRequired = "Требуется к заполнению.";
public const string NotValidIp4Message = "Не соответствует формату IP4.";
public const string NotValidPhoneMessage = "А это не номер трубки, может другой? :)";
public const string Ip4RegularExpression = @"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
public const string NumberGreaterThen0 = "^[1-9][0-9]*$";
public const string NumberCannotBeGreaterThen0Message = "Значение не может быть равно 0.";
}
Loading

0 comments on commit 3b91633

Please sign in to comment.