Bläddra i källkod

Начало создание личного кабинета

ПроваленкоЛН 1 vecka sedan
förälder
incheckning
1d6f1332c8

BIN
AvaloniaApplication2/Assets/picture.png


+ 4 - 0
AvaloniaApplication2/AvaloniaApplication2.csproj

@@ -13,6 +13,10 @@
     <AvaloniaResource Include="Assets\**" />
   </ItemGroup>
 
+  <ItemGroup>
+    <None Remove="Assets\picture.png" />
+  </ItemGroup>
+
   <ItemGroup>
     <PackageReference Include="Avalonia" Version="11.2.0" />
     <PackageReference Include="Avalonia.Desktop" Version="11.2.0" />

+ 27 - 0
AvaloniaApplication2/Converters/ImageConverter.cs

@@ -0,0 +1,27 @@
+using Avalonia.Data.Converters;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Avalonia.Media.Imaging;
+using System.IO;
+using Avalonia.Platform;
+
+
+namespace AvaloniaApplication2.Converters
+{
+    internal class ImageConverter : IValueConverter
+    {
+        public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
+        {
+            return value == null ? new Bitmap(AssetLoader.Open(new Uri("avares://AvaloniaApplication2/Assets/picture.png"))) : new Bitmap(new MemoryStream((byte[])value));
+        }
+
+        public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 22 - 1
AvaloniaApplication2/Views/Personal.axaml

@@ -3,8 +3,29 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:vm="using:AvaloniaApplication2.ViewModels"			
+			 xmlns:conv="using:AvaloniaApplication2.Converters"
 			 mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
              x:Class="AvaloniaApplication2.Personal"
 			 x:DataType="vm:PersonalVM">
- 
+	<UserControl.Resources>
+		<conv:ImageConverter x:Key="myImageConverter"/>
+	</UserControl.Resources>
+
+	<Grid>
+		<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+			<TextBlock>
+				<TextBlock.Text>
+					<MultiBinding StringFormat="{} Добро пожаловать, {0} - Вы {1}">
+						<Binding Path="User.Fio"></Binding>
+						<Binding Path="User.RoleNavigation.Role1"></Binding>
+						</MultiBinding>
+				</TextBlock.Text>
+			</TextBlock>
+			<StackPanel Orientation="Horizontal">
+			<TextBlock Text="Ваш логин:"></TextBlock>
+			<TextBlock Text="{Binding User.Login}"></TextBlock>			
+			</StackPanel>
+			<Image Height="100" Width="100" Source="{Binding User.Image,Converter={StaticResource myImageConverter}}"></Image>
+		</StackPanel>
+	</Grid>
 </UserControl>