Kaynağa Gözat

Небольшая починочка

ПроваленкоЛН 1 hafta önce
ebeveyn
işleme
e88846bc41

+ 7 - 7
AvaloniaApplication2/ViewModels/RegVM.cs

@@ -19,8 +19,8 @@ namespace AvaloniaApplication2.ViewModels
         {
             bool valid = IsPasswordValid(_pass);
             
-                if (!MainWindowViewModel.myconnection.Users.Any(user => user.Login == NewUser.Login))
-                {
+            if (MainWindowViewModel.myconnection.Users.Any(user => user.Login == NewUser.Login) == false)
+            {
                 if (valid)
                 {
                     if (_pass != string.Empty)
@@ -31,11 +31,11 @@ namespace AvaloniaApplication2.ViewModels
                     MainWindowViewModel.myconnection.Users.Add(NewUser);
                     MainWindowViewModel.myconnection.SaveChanges();
                     MainWindowViewModel.Instance.Page = new AuthAndReg();
-                }
-                else
-                {
-                    ErrorMessage = "Логин занят";
-                }
+                }              
+            }
+            else
+            {
+                ErrorMessage = "Логин занят";
             }
         }
 

+ 9 - 0
AvaloniaApplication2/Views/Auth.axaml

@@ -7,4 +7,13 @@
 			 x:DataType="vm:AuthVM"
              x:Class="AvaloniaApplication2.Auth">
   
+	<Grid>
+		<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+			<TextBox Text="{Binding Login}" Watermark="Логин"></TextBox>
+			<TextBox Text="{Binding Password}" Watermark="Пароль"></TextBox>
+			<Button Command="{Binding AutoUser}">
+				<TextBlock Text="Авторизоваться"></TextBlock>
+			</Button>
+			</StackPanel>
+		</Grid>
 </UserControl>

+ 2 - 0
AvaloniaApplication2/Views/Auth.axaml.cs

@@ -1,6 +1,7 @@
 using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Markup.Xaml;
+using AvaloniaApplication2.ViewModels;
 
 namespace AvaloniaApplication2;
 
@@ -9,5 +10,6 @@ public partial class Auth : UserControl
     public Auth()
     {
         InitializeComponent();
+        DataContext = new AuthVM();
     }
 }

+ 15 - 18
AvaloniaApplication2/Views/RegUser.axaml

@@ -6,26 +6,23 @@
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
 			 x:DataType="vm:RegVM"
              x:Class="AvaloniaApplication2.RegUser">
-
+	
 	<Grid>
 		<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
-			<Grid>
-				<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
-					<TextBlock Text="{Binding ErrorMessage}"></TextBlock>
-					<TextBox Text="{Binding NewUser.Fio}" Watermark="ФИО"></TextBox>
-					<TextBox Text="{Binding NewUser.Login}"  Watermark="Логин"></TextBox>
-					<TextBox Text="{Binding Pass}"  Watermark="Пароль"></TextBox>
-					<TextBlock Text="{Binding Addimage}" ></TextBlock>
-					<Button Command="{Binding AddPhoto}">
-						<TextBlock Text="Добавить изображение">
-						</TextBlock>
-					</Button>
-					<Button Command="{Binding Reg}">
-						<TextBlock Text="Зарегистрироватьcя">
-						</TextBlock>
-					</Button>
-				</StackPanel>
-			</Grid>
+			<TextBlock Text="{Binding ErrorMessage}"></TextBlock>
+			<TextBox Text="{Binding NewUser.Fio}" Watermark="ФИО"></TextBox>
+			<TextBox Text="{Binding NewUser.Login}" Watermark="Логин"></TextBox>
+			<TextBox Text="{Binding Pass}" Watermark="Пароль"></TextBox>
+			<TextBlock Text="{Binding Addimage}"></TextBlock>
+			<Button Command="{Binding AddPhoto}">
+				<TextBlock Text="Добавить изображение">
+				</TextBlock>
+			</Button>
+			<Button Command="{Binding Reg}">
+				<TextBlock Text="Зарегистрироваться">
+				</TextBlock>
+			</Button>
 		</StackPanel>
 	</Grid>
+	
 </UserControl>

+ 2 - 0
AvaloniaApplication2/Views/RegUser.axaml.cs

@@ -1,6 +1,7 @@
 using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Markup.Xaml;
+using AvaloniaApplication2.ViewModels;
 
 namespace AvaloniaApplication2;
 
@@ -9,5 +10,6 @@ public partial class RegUser : UserControl
     public RegUser()
     {
         InitializeComponent();
+        DataContext = new RegVM();
     }
 }