Browse Source

Добавлена тёмная тема

Fox 6 months ago
parent
commit
9b65a5c2fc

+ 1 - 1
Models/FilePath.cs

@@ -8,6 +8,6 @@ namespace LoginGenerator.Models
 {
     public static class FilePath
     {
-        public const string PATH = "C:\\Users\\PunkPC\\Reg.txt";
+        public const string PATH = "RegistrationAssistant.txt";
     }
 }

+ 0 - 0
RegistrationAssistant.txt


+ 17 - 0
ViewModels/DataOutputViewModel.cs

@@ -2,6 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
+using Avalonia.Media;
 using LoginGenerator.Models;
 using ReactiveUI;
 
@@ -24,6 +25,22 @@ namespace LoginGenerator.ViewModels
             SelectedSort = Sort[0];
         }
 
+        private SolidColorBrush background2 = new SolidColorBrush(Colors.White);
+
+        public SolidColorBrush Background2
+        {
+            get => background2;
+            set => this.RaiseAndSetIfChanged(ref background2, value);
+        }
+
+        private SolidColorBrush background = new SolidColorBrush(Colors.White);
+
+        public SolidColorBrush Background
+        {
+            get => background;
+            set => this.RaiseAndSetIfChanged(ref background, value);
+        }
+
         public void FillingUsersList()
         {
             if (!File.Exists(FilePath.PATH))

+ 16 - 4
ViewModels/GeneratePageViewModel.cs

@@ -16,6 +16,7 @@ using System.Drawing.Imaging;
 using Avalonia.Input;
 using Avalonia.Media;
 using System.Drawing;
+using TextCopy;
 
 namespace LoginGenerator.ViewModels
 {
@@ -25,9 +26,11 @@ namespace LoginGenerator.ViewModels
         public Transliteration transliteration = new Transliteration();
         public PasswordGenerator passwordGenerator = new PasswordGenerator();
 
-        private SolidColorBrush background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(255, 255, 255));
+        public bool Theme = false;
 
-        public SolidColorBrush MyProperty
+        private SolidColorBrush background = new SolidColorBrush(Colors.White);
+
+        public SolidColorBrush Background
         {
             get => background;
             set => this.RaiseAndSetIfChanged(ref background, value);
@@ -175,7 +178,7 @@ namespace LoginGenerator.ViewModels
             catch (Exception) { }
         }
 
-        public void TMore_Click(object sender, RoutedEventArgs e)
+        public void RegenLogin()
         {
             try
             {
@@ -309,7 +312,16 @@ namespace LoginGenerator.ViewModels
 
         public void SwitchTheme()
         {
-
+            if(Theme == false)
+            {
+                Background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(80, 80, 80));
+                Theme = true;
+            }
+            else
+            {
+                Background = new SolidColorBrush(Colors.White);
+                Theme = false;
+            }
         }
     }
 }

+ 11 - 0
ViewModels/MainWindowViewModel.cs

@@ -1,4 +1,5 @@
 using Avalonia.Controls;
+using Avalonia.Media;
 using LoginGenerator.Models;
 using ReactiveUI;
 using System;
@@ -36,6 +37,16 @@ namespace LoginGenerator.ViewModels
         {
             US = new DataOutput();
             DataOutputVM.FillingUsersList();
+            if(GeneratePageVM.Theme == true)
+            {
+                DataOutputVM.Background = new SolidColorBrush(Color.FromRgb(80, 80, 80));
+                DataOutputVM.Background2 = new SolidColorBrush(Color.FromRgb(128, 128, 128));
+            }
+            else
+            {
+                DataOutputVM.Background = new SolidColorBrush(Colors.White);
+                DataOutputVM.Background2 = new SolidColorBrush(Color.FromRgb(236, 233, 255));
+            }
         }
 
         public void ViewGeneratePage()

+ 3 - 2
Views/DataOutput.axaml

@@ -6,9 +6,10 @@
              x:Class="LoginGenerator.DataOutput"
              xmlns:vm="using:LoginGenerator.ViewModels"
              x:DataType="vm:MainWindowViewModel"
+
              >
 
-  <Grid Background="#ECE9FF">
+  <Grid Background="{Binding DataOutputVM.Background2}">
     <Grid.RowDefinitions>
       <RowDefinition Height="50"/>
       <RowDefinition Height="*"/>
@@ -23,7 +24,7 @@
       
     </StackPanel>
     
-    <ListBox Background="#F9F8FF" Grid.Row="1" ItemsSource="{Binding DataOutputVM.Userss}">
+    <ListBox Background="{Binding DataOutputVM.Background}" Grid.Row="1" ItemsSource="{Binding DataOutputVM.Userss}">
       <ListBox.ItemsPanel>
         <ItemsPanelTemplate>
           <WrapPanel HorizontalAlignment="Center"/>

+ 13 - 12
Views/GeneratePage.axaml

@@ -6,14 +6,15 @@
              x:Class="LoginGenerator.GeneratePage"
              xmlns:vm="using:LoginGenerator.ViewModels"
 			       x:DataType="vm:MainWindowViewModel"
+             Background="{Binding GeneratePageVM.Background}"
              >
 
-  <StackPanel  VerticalAlignment="Center" Background="{Binding }">
+  <StackPanel  VerticalAlignment="Center" >
     <TextBlock FontSize="24" FontWeight="Bold" HorizontalAlignment="Center">АССИСТЕНТ РЕГИСТРАЦИИ</TextBlock>
     <StackPanel>
       <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
-        <TextBox Width="615" Watermark="Введите ФИО" Name="FIO"/>
-        <Button Margin="10 0 0 0" Width="75" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="🌗" Click=""/>
+        <TextBox Width="615" Watermark="Введите ФИО" Text="{Binding GeneratePageVM.FIO}" Name="FIO"/>
+        <Button Margin="10 0 0 0" Width="75" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="🌗" Command="{Binding GeneratePageVM.SwitchTheme}"/>
       </StackPanel>
      
       <StackPanel Margin="0 10 0 0" HorizontalAlignment="Center" Orientation="Horizontal">
@@ -24,21 +25,21 @@
       </StackPanel>
 
       <StackPanel Margin="0 10 0 0" HorizontalAlignment="Center" Orientation="Horizontal">
-        <TextBox Width="529" Watermark="Логин" Name="Login"/>
-        <Button Margin="10 0 0 0" Width="75" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="©" Click="LoginCopy"/>
-        <Button Margin="10 0 0 0" Width="75" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="↻" Click="TMore_Click"/>
+        <TextBox Width="529" Watermark="Логин" Text="{Binding GeneratePageVM.Login}" Name="Login"/>
+        <Button Margin="10 0 0 0" Width="75" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="©" Command="{Binding GeneratePageVM.LoginCopy}"/>
+        <Button Margin="10 0 0 0" Width="75" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="↻" Command="{Binding GeneratePageVM.RegenLogin}"/>
       </StackPanel>
 
       <StackPanel Margin="0 10 0 0" HorizontalAlignment="Center" Orientation="Horizontal">
-        <TextBox Width="529" Watermark="Пароль" Name="Pass"/>
-        <Button Margin="10 0 0 0" Width="75" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="©" Click="PassCopy"/>
-        <Button Margin="10 0 0 0" Width="75" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="↻" Click="RegenPass"/>
+        <TextBox Width="529" Watermark="Пароль" Name="Pass" Text="{Binding GeneratePageVM.Pass}"/>
+        <Button Margin="10 0 0 0" Width="75" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="©" Command="{Binding GeneratePageVM.PassCopy}"/>
+        <Button Margin="10 0 0 0" Width="75" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="↻" Command="{Binding GeneratePageVM.RegenPass}"/>
       </StackPanel>
       
       <StackPanel Margin="0 10 0 0" Orientation="Horizontal" HorizontalAlignment="Center">
-        <Button Width="226" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="Записать данные" Click="WriteIn"/>
-        <Button Width="226" Margin="10 0 0 0" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="Скопировать данные" Click="CopyAll_Click"/>
-        <Button Width="226" Margin="10 0 0 0" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="Сгенерировать данные"  Click="GenerateAll"/>
+        <Button Width="226" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="Записать данные" Command="{Binding GeneratePageVM.WriteIn}"/>
+        <Button Width="226" Margin="10 0 0 0" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="Скопировать данные" Command="{Binding GeneratePageVM.CopyAll_Click}"/>
+        <Button Width="226" Margin="10 0 0 0" HorizontalContentAlignment="Center" FontWeight="Bold" BorderBrush="Black" Background="White" Foreground="#545454" Content="Сгенерировать данные"  Command="{Binding GeneratePageVM.GenerateAll}"/>
       </StackPanel>
 
       <StackPanel Margin="0 10 0 0" HorizontalAlignment="Center">

+ 2 - 5
Views/GeneratePage.axaml.cs

@@ -20,16 +20,13 @@ namespace LoginGenerator;
 
 public partial class GeneratePage : UserControl
 {
-    public Transliteration transliteration = new Transliteration();
-    public PasswordGenerator passwordGenerator = new PasswordGenerator();
-
 
     public GeneratePage()
     {
         InitializeComponent();
     }
 
-    private SolidColorBrush background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(255,255,255));
+/*    private SolidColorBrush background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(255,255,255));
 
     public SolidColorBrush MyProperty
     {
@@ -301,5 +298,5 @@ public partial class GeneratePage : UserControl
     private void SwitchTheme(object sender, RoutedEventArgs e)
     {
         
-    }
+    }*/
 }