Skip to content

Commit

Permalink
Библ. готова
Browse files Browse the repository at this point in the history
  • Loading branch information
MilkRen committed May 31, 2024
1 parent c1add29 commit fa45c32
Show file tree
Hide file tree
Showing 22 changed files with 686 additions and 43 deletions.
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 @@ -164,4 +164,16 @@
<data name="InTheLibrary" xml:space="preserve">
<value>In the library</value>
</data>
<data name="Game" xml:space="preserve">
<value>Game</value>
</data>
<data name="Program" xml:space="preserve">
<value>Program</value>
</data>
<data name="Download" xml:space="preserve">
<value>DOWNLOAD</value>
</data>
<data name="Run" xml:space="preserve">
<value>RUN</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 @@ -286,4 +286,16 @@
<data name="InTheLibrary" xml:space="preserve">
<value>В библиотеке</value>
</data>
<data name="Game" xml:space="preserve">
<value>Игра</value>
</data>
<data name="Program" xml:space="preserve">
<value>Программа </value>
</data>
<data name="Download" xml:space="preserve">
<value>СКАЧАТЬ</value>
</data>
<data name="Run" xml:space="preserve">
<value>ЗАПУСТИТЬ</value>
</data>
</root>
4 changes: 3 additions & 1 deletion LauncherDM/Services/DialogWindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ public void OpenAccountRecovery()
public void OpenMainWindow()
{
var mainWindow = new MainWindow();
mainWindow.DataContext = new MainWindowViewModel(mainWindow.Close, mainWindow.DragMove,
var MainWindowVM = new MainWindowViewModel(mainWindow.Close, mainWindow.DragMove,
new ToolbarToWindowViewModel(new WindowService(mainWindow), mainWindow.Hide, widthMax: 30),
ResourcesHelper, ServerRequest);
mainWindow.DataContext = MainWindowVM;
UpdateUI.PullUi.Subscribe(MainWindowVM);
mainWindow.Owner = Application.Current.MainWindow;
mainWindow.Show();
}
Expand Down
7 changes: 5 additions & 2 deletions LauncherDM/Services/Interfaces/ILibraryUserControlService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using ServerTCP.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -8,6 +9,8 @@ namespace LauncherDM.Services.Interfaces
{
interface ILibraryUserControlService
{
string GetAllItems();
SaleGamesForXml GetGamesItem();

SaleProgramsForXml GetProgramItem();
}
}
40 changes: 37 additions & 3 deletions LauncherDM/Services/LibraryUserControlService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using LauncherDM.Services.Interfaces;
using ServerTCP;
using ServerTCP.Models;
using System.IO;
using System.Xml.Serialization;

namespace LauncherDM.Services
{
Expand All @@ -12,10 +15,41 @@ public LibraryUserControlService(ServerRequestService serverRequest)
_serverRequest = serverRequest;
}

public string GetAllItems()
public SaleGamesForXml GetGamesItem()
{
var requestMessageServer = _serverRequest.SendMessageRequest(MessageHeader.MessageType.AllGamesOrPrograms, true);
return requestMessageServer.Message.ToString();
var requestMessageServer = _serverRequest.SendMessageRequest(MessageHeader.MessageType.GamesItemUser, true);
var xml = new XmlSerializer(typeof(SaleGamesForXml));
var programsForXml = new SaleGamesForXml();
using (StringReader textReader = new StringReader(requestMessageServer.Message.ToString()))
{
try
{
programsForXml = (SaleGamesForXml)xml.Deserialize(textReader);
}
catch
{ }
}
return programsForXml;
}

SaleProgramsForXml ILibraryUserControlService.GetProgramItem()
{
var requestMessageServer = _serverRequest.SendMessageRequest(MessageHeader.MessageType.ProgramsItemUser, true);

var xml = new XmlSerializer(typeof(SaleProgramsForXml));
var programsForXml = new SaleProgramsForXml();
using (StringReader textReader = new StringReader(requestMessageServer.Message.ToString()))
{
try
{
programsForXml = (SaleProgramsForXml)xml.Deserialize(textReader);
}
catch
{ }
}
return programsForXml;
}


}
}
6 changes: 5 additions & 1 deletion LauncherDM/Services/ServerRequestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ public MessageHeader SendMessageRequest(MessageHeader.MessageType messageType, b
tcpClient = new TcpClient();
tcpClient.Connect(_endPoint);

var messageHeader = new MessageHeader(messageType, MessageLanguages.Language);
MessageHeader messageHeader = null;
if (loadToken)
messageHeader = new MessageHeader(messageType, MessageLanguages.Language, SettingsApp.Default.Token);
else
messageHeader = new MessageHeader(messageType, MessageLanguages.Language);
byte[] headerBytes = messageHeader.MessageToArray(loadToken);
NetworkStream tcpStream = tcpClient.GetStream();
tcpStream.Write(headerBytes);
Expand Down
67 changes: 67 additions & 0 deletions LauncherDM/Styles/Other/ButtonStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,71 @@
</Style.Triggers>-->
</Style>


<Style x:Key="ButtonDownload" TargetType="Button">
<Setter Property="FontFamily" Value="#Cascadia Mono SemiLight"/>
<Setter Property="Background" Value="#FF2BA9FF" />
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border CornerRadius="3" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>

<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" To="#33c02b" Duration="0:0:0.3"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" To="#FF2BA9FF" Duration="0:0:0.3"/>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</Style.Triggers>
</Style>

<Style x:Key="ButtonRun" TargetType="Button">
<Setter Property="FontFamily" Value="#Cascadia Mono SemiLight"/>
<Setter Property="Background" Value="#33c02b" />
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border CornerRadius="3" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>

<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" To="#FF2BA9FF" Duration="0:0:0.3"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" To="#33c02b" Duration="0:0:0.3"/>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</Style.Triggers>
</Style>

</ResourceDictionary>
5 changes: 5 additions & 0 deletions LauncherDM/Styles/Other/TextBlockStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@
<Setter Property="Foreground" Value="White"/>
</Style>

<Style x:Key="TitleLibItemTextBlock" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Cascadia Code SemiBold"/>
<Setter Property="Foreground" Value="White"/>
</Style>

</ResourceDictionary>
11 changes: 10 additions & 1 deletion LauncherDM/ViewModels/ItemsViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using LauncherDM.Infastructure.Commands;
using LauncherDM.Infastructure.Commands.Base;
using LauncherDM.Infrastructure.ReactiveUI;
using ServerTCP;
using ServerTCP.Models;

namespace LauncherDM.ViewModels
{
internal class ItemsViewModel : ViewModel.Base.ViewModel
internal class ItemsViewModel : ViewModel.Base.ViewModel, Infrastructure.ReactiveUI.Base.IObserver<LoadUI>
{

#region Binding
Expand Down Expand Up @@ -98,5 +99,13 @@ public ItemsViewModel(Games games, string progPath, LambdaCommand lambdaCommand
ToolTipProgramsText = string.Concat(Description.Substring(0, Description.Length / 4), "...");
ClickProgramCommand = lambdaCommand;
}

public void Update(LoadUI data)
{
if (data.UpdateUI)
{
AllPropertyChanged();
}
}
}
}
1 change: 1 addition & 0 deletions LauncherDM/ViewModels/LibrarySelectItemViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using LauncherDM.Infastructure.Commands;
using LauncherDM.Infastructure.Commands.Base;
using LauncherDM.Infrastructure.ReactiveUI;

namespace LauncherDM.ViewModels
{
Expand Down
Loading

0 comments on commit fa45c32

Please sign in to comment.