Skip to content

Commit

Permalink
Путь к Магазину. Работа с авторизацией
Browse files Browse the repository at this point in the history
  • Loading branch information
MilkRen committed May 15, 2024
1 parent e17d6a0 commit 4d0db5f
Show file tree
Hide file tree
Showing 36 changed files with 563 additions and 183 deletions.
3 changes: 3 additions & 0 deletions LauncherDM/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<setting name="Token" serializeAs="String">
<value />
</setting>
<setting name="OfflineMode" serializeAs="String">
<value>False</value>
</setting>
</LauncherDM.Properties.SettingsApp>
<LauncherDM.Source.Settings.SettingsApp>
<setting name="AccessToken" serializeAs="String">
Expand Down
2 changes: 2 additions & 0 deletions LauncherDM/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

<ResourceDictionary Source="Styles/Other/DockPanelStyles.xaml"/>
<ResourceDictionary Source="Styles/Other/LabelStyle.xaml"/>
<ResourceDictionary Source="Styles/Other/TextBoxStyle.xaml"/>
<ResourceDictionary Source="Styles/Other/TextBlockStyle.xaml"/>
<ResourceDictionary Source="Styles/Other/BorderStyle.xaml"/>
<ResourceDictionary Source="Styles/Other/ButtonStyle.xaml"/>
<ResourceDictionary Source="Styles/Other/ContextMenuStyle.xaml"/>
Expand Down
9 changes: 9 additions & 0 deletions LauncherDM/Models/StaticFields.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Reflection;

namespace LauncherDM.Models
{
class StaticFields
{
public static string VersionPatch => Assembly.GetExecutingAssembly().GetName().Version?.ToString();
}
}
38 changes: 37 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.

12 changes: 12 additions & 0 deletions LauncherDM/Properties/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,16 @@
<data name="Email" xml:space="preserve">
<value>Email</value>
</data>
<data name="Version" xml:space="preserve">
<value>Version:</value>
</data>
<data name="Settings" xml:space="preserve">
<value>Settings</value>
</data>
<data name="SettingsSmall" xml:space="preserve">
<value>Small settings</value>
</data>
<data name="AboutSmallText" xml:space="preserve">
<value>This program was created by a small enthusiast!</value>
</data>
</root>
12 changes: 12 additions & 0 deletions LauncherDM/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,16 @@
<data name="Email" xml:space="preserve">
<value>Почта</value>
</data>
<data name="Version" xml:space="preserve">
<value>Версия:</value>
</data>
<data name="Settings" xml:space="preserve">
<value>Настройки</value>
</data>
<data name="SettingsSmall" xml:space="preserve">
<value>Маленькие настройки</value>
</data>
<data name="AboutSmallText" xml:space="preserve">
<value>Данная программа была создана маленьким энтузиастом!</value>
</data>
</root>
12 changes: 12 additions & 0 deletions LauncherDM/Properties/SettingsApp.Designer.cs

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

3 changes: 3 additions & 0 deletions LauncherDM/Properties/SettingsApp.settings
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
<Setting Name="Token" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="OfflineMode" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
12 changes: 11 additions & 1 deletion LauncherDM/Services/DialogWindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public void OpenWindow(object viewModel)
{
var authorization = new AuthorizationWindow();
authorization.DataContext = new AuthorizationWindowViewModel(authorization.DragMove ,authorization.Close,
new ToolbarToWindowViewModel(new WindowService(authorization), visibilitySettings: Visibility.Visible));
new ToolbarToWindowViewModel(new WindowService(authorization), visibilitySettings: Visibility.Visible));
authorization.Owner = Application.Current.MainWindow;
authorization.Show();
return;
}
Expand All @@ -35,6 +36,15 @@ public void OpenWindow(object viewModel)
regAndLogWindow.Show();
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());
settingsMini.ShowDialog();
return;
}
else if (viewModel is RegAndLogWindowViewModel)
{
var mainWindow = new MainWindow();
Expand Down
12 changes: 0 additions & 12 deletions LauncherDM/Services/Interfaces/IWindowAnimationsService.cs

This file was deleted.

3 changes: 2 additions & 1 deletion LauncherDM/Services/LoadingWindowService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using LauncherDM.Models;
using LauncherDM.Services.Interfaces;
using ServerTCP;

Expand Down Expand Up @@ -27,7 +28,7 @@ public string GetTitle()

public bool CheckUpdate()
{
var version = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
var version = StaticFields.VersionPatch;
var requestMessageServer = _serverRequest.SendMessageRequest(MessageHeader.MessageType.Version);
return requestMessageServer?.Message.ToString() == version;
}
Expand Down
3 changes: 1 addition & 2 deletions LauncherDM/Services/ResourcesHelperService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
using LauncherDM.Services.Interfaces;
using ServerTCP;
using System.Globalization;
using System.Threading;
using LauncherDM.Properties;

namespace LauncherDM.Services
{
class ResourcesHelperService : IResourcesHelperService
internal class ResourcesHelperService : IResourcesHelperService
{
public string LocalizationGet(string resource)
{
Expand Down
13 changes: 0 additions & 13 deletions LauncherDM/Services/WindowAnimationsService.cs

This file was deleted.

22 changes: 22 additions & 0 deletions LauncherDM/Styles/Other/ButtonStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,28 @@
</Style.Triggers>
</Style>

<Style x:Key="ButtonLanguages" TargetType="Button">
<Setter Property="FontFamily" Value="#Cascadia Mono SemiLight"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<StackPanel Orientation="Horizontal" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
<Label FontSize="{TemplateBinding FontSize}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Ellipse Fill="White" Width="15" Height="15" />
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>

</Style>

<Style x:Key="ButtonRegistrationAccount" TargetType="Button">
<Setter Property="FontFamily" Value="#Cascadia Mono SemiLight"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Width" Value="125"/>
<Setter Property="VerticalAlignment" Value="Center"/>
Expand Down Expand Up @@ -286,6 +307,7 @@
</Style>

<Style x:Key="ButtonForgot" TargetType="Button">
<Setter Property="FontFamily" Value="#Cascadia Mono SemiLight"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Width" Value="36"/>
<Setter Property="Height" Value="36"/>
Expand Down
10 changes: 10 additions & 0 deletions LauncherDM/Styles/Other/TextBlockStyle.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Style x:Key="ToolTipTextBlock" TargetType="TextBlock">
<Setter Property="FontFamily" Value="#Cascadia Mono SemiLight"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Transparent"/>
</Style>

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

<Style x:Key="DescFont" TargetType="TextBox">
<Setter Property="FontFamily" Value="#Cascadia Mono SemiLight"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Style.Triggers>
<EventTrigger RoutedEvent="Button.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1" To="0.5" Duration="0:0:1" AutoReverse="True" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
2 changes: 1 addition & 1 deletion LauncherDM/ViewModels/AuthorizationWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void OnMoveWindowCommandExecuted(object p)

#region Ctor

public AuthorizationWindowViewModel(Action dragMove, Action closeWindowAction ,ToolbarToWindowViewModel toolbarVM)
public AuthorizationWindowViewModel(Action dragMove, Action closeWindowAction, ToolbarToWindowViewModel toolbarVM)
{
_dragMoveAction = dragMove;
_closeAction = closeWindowAction;
Expand Down
7 changes: 5 additions & 2 deletions LauncherDM/ViewModels/LoadingWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using LauncherDM.Properties;

namespace LauncherDM.ViewModels
{
Expand Down Expand Up @@ -116,8 +117,8 @@ private void Loading()
{
ICheckNetworkService checkNetwork = new CheckNetworkService();
ILoadingWindowService server = new LoadingWindowService(new ServerRequestService());
OpenWindow();
return;
SettingsApp.Default.OfflineMode = false;
SettingsApp.Default.Save();

Task.Run(() =>
{
Expand Down Expand Up @@ -145,6 +146,8 @@ private void Loading()
{
IDialogMessageBoxService dialogMessageBox = new DialogMessageBoxService();
dialogMessageBox.DialogShow(_resourcesHelper.LocalizationGet("Error"), _resourcesHelper.LocalizationGet("ServerClose"));
SettingsApp.Default.OfflineMode = true;
SettingsApp.Default.Save();
OpenWindow();
break;
}
Expand Down
3 changes: 2 additions & 1 deletion LauncherDM/ViewModels/RegAndLogWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Reflection;
using LauncherDM.Infastructure.Commands.Base;
using LauncherDM.Infastructure.Commands;
using LauncherDM.Models;

namespace LauncherDM.ViewModels
{
Expand Down Expand Up @@ -37,7 +38,7 @@ class RegAndLogWindowViewModel : ViewModel.Base.ViewModel

public string ForgotPasswordText => _resourcesHelper.LocalizationGet("ForgotPassword");

public string VersionText => string.Concat("Version: ", Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty);
public string VersionText => string.Concat(_resourcesHelper.LocalizationGet("Version"), "", StaticFields.VersionPatch);

#region ToolBar

Expand Down
Loading

0 comments on commit 4d0db5f

Please sign in to comment.