Skip to content

Commit

Permalink
Аккаунты, криптография, серелизация xml и магазин
Browse files Browse the repository at this point in the history
  • Loading branch information
MilkRen committed May 19, 2024
1 parent 0acb2bb commit 858dfdb
Show file tree
Hide file tree
Showing 31 changed files with 501 additions and 122 deletions.
2 changes: 2 additions & 0 deletions LauncherDM/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<ResourceDictionary Source="Styles/Other/ButtonStyle.xaml"/>
<ResourceDictionary Source="Styles/Other/ContextMenuStyle.xaml"/>
<ResourceDictionary Source="Styles/Other/ImageStyle.xaml"/>
<ResourceDictionary Source="Styles/Other/TabControlStyle.xaml"/>
<ResourceDictionary Source="Styles/Other/TabPanelStyle.xaml"/>

</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Expand Down
4 changes: 2 additions & 2 deletions LauncherDM/Infrastructure/Commands/lambdaCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

namespace LauncherDM.Infastructure.Commands
{
public class lambdaCommand : Command
public class LambdaCommand : Command
{
private readonly Action<object> _execute;
private readonly Func<object, bool> _canExecute;

public lambdaCommand(Action<object> Execute, Func<object, bool> CanExecute = null)
public LambdaCommand(Action<object> Execute, Func<object, bool> CanExecute = null)
{
_execute = Execute ?? throw new ArgumentNullException(nameof(Execute));
_canExecute = CanExecute;
Expand Down
4 changes: 4 additions & 0 deletions LauncherDM/LauncherDM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<None Remove="Source\Images\ToolBar\Down.png" />
<None Remove="Source\Images\ToolBar\DownBlack.png" />
<None Remove="Source\Images\ToolBar\Maximize.png" />
<None Remove="Source\Images\ToolBar\MaximizeBlack.png" />
<None Remove="Source\Images\ToolBar\MaximizeRev.png" />
<None Remove="Source\Images\ToolBar\Minimize.png" />
<None Remove="Source\Images\ToolBar\MinimizeBlack.png" />
Expand Down Expand Up @@ -87,6 +88,9 @@
<Resource Include="Source\Images\ToolBar\Maximize.png">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Resource>
<Resource Include="Source\Images\ToolBar\MaximizeBlack.png">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Resource>
<Resource Include="Source\Images\ToolBar\MaximizeRev.png">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Resource>
Expand Down
49 changes: 49 additions & 0 deletions LauncherDM/Models/Users.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using ServerTCP.Сryptographies;

namespace LauncherDM.Models
{
[Serializable]
public class Users
{
public string Login { get; set; }

public string Password { get; set; }

public string ImagePath { get; set; }

private string Key = "fdjiaobzfddarkmilk";
public Users() { }

public Users(string login, string password, string imagePath)
{
Login = login;
Password = password;
ImagePath = imagePath;
}

public void cryptPassword()
{
var hash = SHA256.HashData(Encoding.UTF8.GetBytes(Password));
var convertHash = Convert.ToHexString(hash);
using (var myAes = Aes.Create())
{
byte[] aesKey = SHA256Managed.Create().ComputeHash(Encoding.UTF8.GetBytes(Key));
byte[] aesIV = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Key));
myAes.Key = aesKey;
myAes.IV = aesIV;
var tokenResult = Convert.ToBase64String(CryptoAes.EncryptStringToBytes_Aes(convertHash, myAes.Key, myAes.IV));
Password = tokenResult;
}
}
}

[Serializable]
public class UsersList
{
public List<Users> UserList { get; set; } = new List<Users>();
}
}
47 changes: 46 additions & 1 deletion LauncherDM/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions LauncherDM/Properties/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,19 @@
<data name="English" xml:space="preserve">
<value>English</value>
</data>
<data name="ErrorLogin" xml:space="preserve">
<value>Incorrect username or password.</value>
</data>
<data name="ErrorLoginloggedIn" xml:space="preserve">
<value>This account is already logged in.</value>
</data>
<data name="Attention" xml:space="preserve">
<value>Attention!</value>
</data>
<data name="AccountListIsFull" xml:space="preserve">
<value>The list of accounts is full. Remove unnecessary accounts.</value>
</data>
<data name="Account" xml:space="preserve">
<value>Account</value>
</data>
</root>
15 changes: 15 additions & 0 deletions LauncherDM/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,19 @@
<data name="English" xml:space="preserve">
<value>Английский</value>
</data>
<data name="ErrorLogin" xml:space="preserve">
<value>Неправильный логин или пароль.</value>
</data>
<data name="ErrorLoginloggedIn" xml:space="preserve">
<value>Этот аккаунт уже авторизован.</value>
</data>
<data name="Attention" xml:space="preserve">
<value>Внимание!</value>
</data>
<data name="AccountListIsFull" xml:space="preserve">
<value>Список аккаунтов переполнен. Уберите ненужные аккаунты.</value>
</data>
<data name="Account" xml:space="preserve">
<value>Аккаунт</value>
</data>
</root>
25 changes: 16 additions & 9 deletions LauncherDM/Services/DialogWindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,46 @@ class DialogWindowService : IDialogWindowService

public Action DragMoveAction { get; set; }

public ResourcesHelperService ResourcesHelperService = new ResourcesHelperService();

public void OpenWindow(object viewModel)
{
if (viewModel is LoadingWindowViewModel)
{
var authorization = new AuthorizationWindow();
authorization.DataContext = new AuthorizationWindowViewModel(authorization.DragMove ,authorization.Close,
new ToolbarToWindowViewModel(new WindowService(authorization), visibilitySettings: Visibility.Visible));
authorization.DataContext = new AuthorizationWindowViewModel(authorization.DragMove, authorization.Close,
new ToolbarToWindowViewModel(new WindowService(authorization), visibilitySettings: Visibility.Visible),
ResourcesHelperService);
authorization.Owner = Application.Current.MainWindow;
authorization.Show();
return;
}
else if (viewModel is AccountUserControlViewModel or AuthorizationWindowViewModel)
{
var regAndLogWindow = new RegAndLogWindow();
regAndLogWindow.DataContext = new RegAndLogWindowViewModel(regAndLogWindow.Close, new ToolbarToWindowViewModel(new WindowService(regAndLogWindow)),
new ResourcesHelperService());
regAndLogWindow.DataContext = new RegAndLogWindowViewModel(regAndLogWindow.DragMove, regAndLogWindow.Close,
new ToolbarToWindowViewModel(new WindowService(regAndLogWindow), regAndLogWindow.Close),
ResourcesHelperService);
regAndLogWindow.ShowDialog();
return;
}
else if (viewModel is ToolbarToWindowViewModel)
{
var settingsMini = new SettingsMiniWindow();
settingsMini.DataContext = new SettingsMiniWindowViewModel(settingsMini.DragMove,
new ToolbarToWindowViewModel(new WindowService(settingsMini), settingsMini.Close, visibilityMinBut:Visibility.Hidden),
new ResourcesHelperService());
new ToolbarToWindowViewModel(new WindowService(settingsMini), settingsMini.Close, ResourcesHelperService.LocalizationGet("Settings"),
visibilityMinBut:Visibility.Hidden), ResourcesHelperService);
settingsMini.ShowDialog();
return;
}
else if (viewModel is RegAndLogWindowViewModel)
{
//((ViewModel.Base.ViewModel)viewModel).Dispose();
var mainWindow = new MainWindow();
mainWindow.DataContext = new MainWindowViewModel();
mainWindow.Owner = Application.Current.MainWindow;
mainWindow.DataContext = new MainWindowViewModel(mainWindow.DragMove,
new ToolbarToWindowViewModel(new WindowService(mainWindow), mainWindow.Close, widthMax:30),
ResourcesHelperService);
//mainWindow.Owner = Application.Current.MainWindow;
mainWindow.Show();
return;
}
Expand All @@ -75,7 +82,7 @@ public void OpenLoadingWindow()
{
var loadingWindow = new LoadingWindow();
loadingWindow.DataContext = new LoadingWindowViewModel(loadingWindow.DragMove, loadingWindow.Hide,
new WindowService(loadingWindow), new ResourcesHelperService());
new WindowService(loadingWindow), ResourcesHelperService);
loadingWindow.Show();
}

Expand Down
6 changes: 0 additions & 6 deletions LauncherDM/Services/Interfaces/IRegAndLogWindowService.cs

This file was deleted.

12 changes: 12 additions & 0 deletions LauncherDM/Services/Interfaces/IXmlService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Generic;
using LauncherDM.Models;

namespace LauncherDM.Services.Interfaces
{
internal interface IXmlService
{
void SerializationUsersXml(UsersList userlist);

UsersList DeserializeUsersXMl();
}
}
8 changes: 0 additions & 8 deletions LauncherDM/Services/RegAndLogWindowServiceService.cs

This file was deleted.

40 changes: 40 additions & 0 deletions LauncherDM/Services/XmlService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using LauncherDM.Models;
using LauncherDM.Services.Interfaces;

namespace LauncherDM.Services
{
internal class XmlService : IXmlService
{
private const string FileName = "Users.xml";

public void SerializationUsersXml(UsersList userlist)
{
var xml = new XmlSerializer(typeof(UsersList));
using (var fs = new FileStream(FileName, FileMode.OpenOrCreate))
{
xml.Serialize(fs, userlist);
}
}

public UsersList DeserializeUsersXMl()
{
var userslist = new UsersList();
var xml = new XmlSerializer(typeof(UsersList));
using (var fs = File.Open(FileName, FileMode.OpenOrCreate))
{
try
{
userslist = (UsersList)xml.Deserialize(fs);
}
catch
{
}
}
return userslist;
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions LauncherDM/Styles/Other/ButtonStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,19 @@
</Setter>
</Style>

<Style x:Key="ButtonMinimize" TargetType="Button">
<Style x:Key="ButtonMaximize" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Width" Value="30"/>
<Setter Property="Height" Value="28"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
<Image x:Name="image" Source="/Source/Images/ToolBar/Minimize.png" Width="15" Height="15"/>
<Image x:Name="image" Source="/Source/Images/ToolBar/Maximize.png" Width="15" Height="15"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="image" Property="Source" Value="/Source/Images/ToolBar/MinimizeBlack.png"/>
<Setter TargetName="image" Property="Source" Value="/Source/Images/ToolBar/MaximizeBlack.png"/>
<Setter Property="Background" Value="DarkRed"/>
</Trigger>
</ControlTemplate.Triggers>
Expand All @@ -210,19 +210,19 @@
</Setter>
</Style>

<Style x:Key="ButtonMaximize" TargetType="Button">
<Style x:Key="ButtonMinimize" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Width" Value="30"/>
<Setter Property="Height" Value="28"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
<Image x:Name="image" Source="/Source/Images/ToolBar/Maximize.png" Width="15" Height="15"/>
<Image x:Name="image" Source="/Source/Images/ToolBar/Minimize.png" Width="15" Height="15"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="image" Property="Source" Value="/Source/Images/ToolBar/MaximizeRev.png"/>
<Setter TargetName="image" Property="Source" Value="/Source/Images/ToolBar/MinimizeBlack.png"/>
<Setter Property="Background" Value="DarkRed"/>
</Trigger>
</ControlTemplate.Triggers>
Expand Down
6 changes: 6 additions & 0 deletions LauncherDM/Styles/Other/TabControlStyle.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">



</ResourceDictionary>
8 changes: 8 additions & 0 deletions LauncherDM/Styles/Other/TabPanelStyle.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Style x:Key="CenterTabPanel" TargetType="TabPanel">
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>

</ResourceDictionary>
Loading

0 comments on commit 858dfdb

Please sign in to comment.