Compare commits
No commits in common. "main" and "dtlauncher-old-2021" have entirely different histories.
main
...
dtlauncher
363
.gitignore
vendored
@ -1,22 +1,365 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Bb]in/
|
||||
.bin/
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Oo]ut/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
[Pp]ublish/
|
||||
|
||||
# IDE files
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
.vscode/
|
||||
.vshistory/
|
||||
.idea/
|
||||
.editorconfig
|
||||
*.user
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
#backups
|
||||
.old*/
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
*.editorconfig
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="launcher-client-avalonia-win64" type="DotNetFolderPublish" factoryName="Publish to folder">
|
||||
<riderPublish configuration="Release" delete_existing_files="true" platform="Any CPU" produce_single_file="true" runtime="win-x64" target_folder="$PROJECT_DIR$/launcher-client-avalonia/publish/win-x64" target_framework="net6.0" uuid_high="-4890976677488079081" uuid_low="-5731196012681532756" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@ -1,30 +0,0 @@
|
||||
<Application x:Class="Launcher.Client.Avalonia.GUI.App"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Application.Resources>
|
||||
<SolidColorBrush x:Key="MyBackgroundColor" Color="#232328" />
|
||||
<SolidColorBrush x:Key="MyDarkTr"
|
||||
Opacity="0.8"
|
||||
Color="#141419" />
|
||||
<SolidColorBrush x:Key="MyGray" Color="#46464B" />
|
||||
<SolidColorBrush x:Key="MyWhite" Color="#F0F0F0" />
|
||||
<SolidColorBrush x:Key="MyGreen" Color="#28C311" />
|
||||
<SolidColorBrush x:Key="MyRed" Color="#E5160A" />
|
||||
<SolidColorBrush x:Key="MySelectionColor" Color="#B7800A" />
|
||||
</Application.Resources>
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme Mode="Dark" />
|
||||
|
||||
<Style Selector="TextBox.MyTextBoxStyle" />
|
||||
<Style Selector="Label.MyLabelStyle" />
|
||||
<Style Selector="Button.MyButtonStyle" >
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
@ -1,38 +0,0 @@
|
||||
global using Avalonia;
|
||||
global using Avalonia.Controls;
|
||||
global using Avalonia.Media;
|
||||
global using Avalonia.Media.Imaging;
|
||||
global using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
|
||||
namespace Launcher.Client.Avalonia.GUI
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
public static SolidColorBrush MyDark, MySoftDark, MyWhite, MyGreen, MyOrange, MySelectionColor;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
MyDark = (SolidColorBrush)Resources["MyDarkTr"];
|
||||
MySoftDark = (SolidColorBrush)Resources["MyGray"];
|
||||
MyWhite = (SolidColorBrush)Resources["MyWhite"];
|
||||
MyGreen = (SolidColorBrush)Resources["MyGreen"];
|
||||
MyOrange = (SolidColorBrush)Resources["MySelectionColor"];
|
||||
MySelectionColor = (SolidColorBrush)Resources["MySelectionColor"];
|
||||
}
|
||||
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
CurrentLauncherWindow = new LauncherWindow();
|
||||
desktop.MainWindow = CurrentLauncherWindow;
|
||||
CurrentLauncherWindow.Show();
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,180 +0,0 @@
|
||||
<Window x:Class="Launcher.Client.Avalonia.GUI.LauncherWindow"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Launcher.Client.Avalonia.GUI"
|
||||
Title="Launcher"
|
||||
Width="800"
|
||||
Height="500"
|
||||
MinWidth="800"
|
||||
MinHeight="500"
|
||||
Background="{DynamicResource MyBackgroundColor}">
|
||||
<Grid ColumnDefinitions="5,*,5" RowDefinitions="5,35,5,*,5">
|
||||
<Image x:Name="BackgroundImage"
|
||||
Grid.RowSpan="5"
|
||||
Grid.ColumnSpan="3"
|
||||
HorizontalAlignment="Center"
|
||||
Stretch="UniformToFill" />
|
||||
|
||||
<Grid x:Name="TopPanelGrid"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
ColumnDefinitions="*,5,*,5,*,5,*">
|
||||
<local:TabButton x:Name="LibraryButton"
|
||||
Grid.Column="0"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Library"
|
||||
FontSize="18" />
|
||||
<local:TabButton x:Name="DownloadsButton"
|
||||
Grid.Column="2"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Downloads"
|
||||
FontSize="18" />
|
||||
<local:TabButton x:Name="LogButton"
|
||||
Grid.Column="4"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Log"
|
||||
FontSize="18" />
|
||||
<local:TabButton x:Name="SettingsButton"
|
||||
Grid.Column="6"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Settings"
|
||||
FontSize="18" />
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="LibraryGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
ColumnDefinitions="220,5,*,5,220"
|
||||
IsVisible="true">
|
||||
<ScrollViewer Grid.Column="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Template="{DynamicResource myScrollViewer}"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel x:Name="ProgramsPanel" />
|
||||
</ScrollViewer>
|
||||
<Grid x:Name="ProgramGrid"
|
||||
Grid.Column="2"
|
||||
RowDefinitions="35,5,35,5,70,5,*">
|
||||
<Label x:Name="NameLabel"
|
||||
Grid.Row="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="name"
|
||||
FontSize="19"
|
||||
FontWeight="Bold" />
|
||||
<StackPanel Grid.Row="2"
|
||||
HorizontalAlignment="Right"
|
||||
ClipToBounds="True"
|
||||
Orientation="Horizontal">
|
||||
<Button x:Name="RemoveButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Background="{DynamicResource MyRed}"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Remove" />
|
||||
<Button x:Name="InstallButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Install" />
|
||||
<Button x:Name="UpdateButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Update" />
|
||||
<Button x:Name="LaunchButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Background="{DynamicResource MyGreen}"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Launch" />
|
||||
</StackPanel>
|
||||
<TextBox x:Name="DescriptionBox"
|
||||
Grid.Row="4"
|
||||
Classes="MyTextBoxStyle"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto" />
|
||||
<TextBox x:Name="ProgramLogBox"
|
||||
Grid.Row="6"
|
||||
Classes="MyTextBoxStyle"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto" />
|
||||
</Grid>
|
||||
<Grid Grid.Row="0"
|
||||
Grid.Column="4"
|
||||
RowDefinitions="95,*">
|
||||
<Grid Grid.Row="0"
|
||||
ColumnDefinitions="*,*"
|
||||
RowDefinitions="30,30,30">
|
||||
|
||||
<Label Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="version:" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Background="{DynamicResource MyDarkTr}"
|
||||
Template="{DynamicResource MyComboBox}">
|
||||
<ComboBoxItem IsSelected="True">
|
||||
<Label Background="Transparent"
|
||||
Classes="MyLabelStyle"
|
||||
Content="v1" />
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<Label Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="directory:" />
|
||||
<Label Name="ProgramDirectoryLabel"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Classes="MyLabelStyle"
|
||||
Content="0" />
|
||||
<Label Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="size:" />
|
||||
<Label Name="ProgramSizeLabel"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Classes="MyLabelStyle"
|
||||
Content="0" />
|
||||
</Grid>
|
||||
<ScrollViewer Name="ProgramSettingsViever"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
VerticalContentAlignment="Top"
|
||||
Template="{DynamicResource myScrollViewer}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
<Grid x:Name="DownloadsGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
IsVisible="false" />
|
||||
|
||||
<Grid x:Name="LogGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
IsVisible="false"
|
||||
RowDefinitions="30,*">
|
||||
<Label x:Name="LogfileLabel"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="logfile"
|
||||
FontStyle="Italic" />
|
||||
<TextBox x:Name="LogBox"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Classes="MyTextBoxStyle"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto" />
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="SettingsGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
IsVisible="false" />
|
||||
</Grid>
|
||||
</Window>
|
||||
@ -1,103 +0,0 @@
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Threading;
|
||||
using DTLib.Logging;
|
||||
|
||||
namespace Launcher.Client.Avalonia.GUI;
|
||||
|
||||
public partial class LauncherWindow : Window
|
||||
{
|
||||
public LauncherWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
LogBox.Text = Logger.Buffer;
|
||||
Logger.MessageSent += LogHandler;
|
||||
LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Path.Sep)+1);
|
||||
LogfileLabel.PointerPressed += (_,_)=>
|
||||
Process.Start("explorer.exe", LauncherLogger.LogfileDir.ToString()!);
|
||||
LogfileLabel.PointerEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor;
|
||||
LogfileLabel.PointerLeave += (_,_)=>LogfileLabel.Foreground=App.MyWhite;
|
||||
LibraryButton.TabGrid = LibraryGrid;
|
||||
DownloadsButton.TabGrid = DownloadsGrid;
|
||||
LogButton.TabGrid = LogGrid;
|
||||
SettingsButton.TabGrid = SettingsGrid;
|
||||
LibraryButton.Click += SelectTab;
|
||||
DownloadsButton.Click += SelectTab;
|
||||
LogButton.Click += SelectTab;
|
||||
SettingsButton.Click += SelectTab;
|
||||
ProgramGrid.IsVisible = false;
|
||||
SelectTab(LibraryButton, null);
|
||||
FillProgramsPanel();
|
||||
Logger.LogInfo(nameof(LauncherWindow),"launcher started");
|
||||
try
|
||||
{
|
||||
throw new Exception("aaa");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogError(nameof(LauncherWindow), ex);
|
||||
}
|
||||
}
|
||||
|
||||
void LogHandler(string m) => Dispatcher.UIThread.InvokeAsync(()=>LogBox.Text += m);
|
||||
|
||||
|
||||
private TabButton CurrentTab;
|
||||
void SelectTab(object sender, RoutedEventArgs _)
|
||||
{
|
||||
if(CurrentTab!=null)
|
||||
{
|
||||
CurrentTab.Background = App.MyDark;
|
||||
CurrentTab.TabGrid.IsVisible = false;
|
||||
}
|
||||
var selected = (TabButton)sender;
|
||||
selected.Background = App.MySelectionColor;
|
||||
selected.TabGrid.IsVisible = true;
|
||||
CurrentTab = selected;
|
||||
}
|
||||
|
||||
public Program[] Programs;
|
||||
|
||||
private void FillProgramsPanel()
|
||||
{
|
||||
Logger.LogInfo(nameof(LauncherWindow),"reading descriptors...");
|
||||
var descriptors = Directory.GetFiles("descriptors");
|
||||
Programs = new Program[descriptors.Length];
|
||||
for (ushort i = 0; i < descriptors.Length; i++)
|
||||
{
|
||||
var descriptor = descriptors[i];
|
||||
if(descriptor.EndsWith(".descriptor"))
|
||||
{
|
||||
Logger.LogInfo(nameof(LauncherWindow), descriptor.ToString());
|
||||
Programs[i] = new Program(descriptors[i]);
|
||||
ProgramsPanel.Children.Add(Programs[i].ProgramLabel);
|
||||
Programs[i].ProgramSelectedEvent += SelectProgram;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Program DisplayingProgram;
|
||||
public void SelectProgram(Program selectedProg)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DisplayingProgram != null)
|
||||
{
|
||||
DisplayingProgram.ProgramLabel.Foreground = App.MyWhite;
|
||||
DisplayingProgram.ProgramLabel.FontWeight = FontWeight.Normal;
|
||||
}
|
||||
else ProgramGrid.IsVisible = true;
|
||||
|
||||
selectedProg.ProgramLabel.Foreground = App.MySelectionColor;
|
||||
selectedProg.ProgramLabel.FontWeight = FontWeight.Bold;
|
||||
|
||||
NameLabel.Content = selectedProg.Name;
|
||||
DescriptionBox.Text = selectedProg.Description;
|
||||
BackgroundImage.Source = new Bitmap(
|
||||
$"{Directory.GetCurrent()}{Path.Sep}backgrounds{Path.Sep}{selectedProg.BackgroundFile}");
|
||||
ProgramSettingsViever.Content = selectedProg.SettingsPanel;
|
||||
DisplayingProgram = selectedProg;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{ LogError("SelectProgram()",ex); }
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
<Window x:Class="Launcher.Client.Avalonia.GUI.MessageBox"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Height="100"
|
||||
Width="200"
|
||||
Background="{DynamicResource MyBackgroundColor}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>* 30</Grid.RowDefinitions>
|
||||
<TextBox Name="TextBlock" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||
Foreground="{DynamicResource MyWhite}"
|
||||
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
IsReadOnly="True" TextWrapping="Wrap"
|
||||
FontSize="14"/>
|
||||
<Button Grid.Row="1" Click="Button_OnClick"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Bottom"
|
||||
Foreground="{DynamicResource MyWhite}"
|
||||
FontSize="16">
|
||||
OK
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
@ -1,25 +0,0 @@
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace Launcher.Client.Avalonia.GUI;
|
||||
|
||||
public partial class MessageBox : Window
|
||||
{
|
||||
public MessageBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public static void Show(string title, string text)
|
||||
{
|
||||
var mb = new MessageBox();
|
||||
mb.Title = title;
|
||||
mb.TextBlock.Text = text;
|
||||
mb.Topmost = true;
|
||||
mb.Show();
|
||||
}
|
||||
|
||||
private void Button_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
<UserControl x:Class="Launcher.Client.Avalonia.GUI.ProgramLabel"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Launcher.Client.Avalonia.GUI"
|
||||
Height="50"
|
||||
Background="{DynamicResource MyDarkTr}"
|
||||
BorderBrush="{Binding Foreground, RelativeSource={RelativeSource Self}}"
|
||||
BorderThickness="3"
|
||||
Foreground="{DynamicResource MyWhite}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding $parent[local:ProgramLabel].Height}" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image x:Name="IconImage"
|
||||
Grid.Column="0"
|
||||
Margin="3,3,3,3"
|
||||
Stretch="Fill" />
|
||||
|
||||
<Label Name="NameLabel"
|
||||
Grid.Column="1"
|
||||
VerticalContentAlignment="Center"
|
||||
Content="label"
|
||||
FontFamily="Unispace"
|
||||
FontSize="15"
|
||||
FontWeight="Normal"
|
||||
Foreground="{Binding $parent[local:ProgramLabel].Foreground}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -1,14 +0,0 @@
|
||||
namespace Launcher.Client.Avalonia.GUI;
|
||||
|
||||
public partial class ProgramLabel : UserControl
|
||||
{
|
||||
public ProgramLabel() => InitializeComponent();
|
||||
|
||||
public ProgramLabel(string label, string icon)
|
||||
{
|
||||
InitializeComponent();
|
||||
NameLabel.Content = label;
|
||||
IconImage.Source = new Bitmap(
|
||||
$"{Directory.GetCurrent()}{Path.Sep}icons{Path.Sep}{icon}");
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
<UserControl x:Class="Launcher.Client.Avalonia.GUI.ProgramSettingsPanelItem"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Launcher.Client.Avalonia.GUI"
|
||||
Background="Transparent">
|
||||
<Grid ColumnDefinitions="*,*">
|
||||
<Label Name="KeyLabel"
|
||||
Grid.Column="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="{Binding $parent[local:ProgramSettingsPanelItem].SettingKey}"
|
||||
FontFamily="default"
|
||||
FontSize="16"
|
||||
ToolTip.Tip="{Binding $self.Content}" />
|
||||
<TextBox Name="ValueBox"
|
||||
Grid.Column="1"
|
||||
Classes="MyTextBoxStyle"
|
||||
IsReadOnly="False"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled"
|
||||
Text="{Binding $parent[local:ProgramSettingsPanelItem].SettingValue}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -1,41 +0,0 @@
|
||||
namespace Launcher.Client.Avalonia.GUI;
|
||||
|
||||
public partial class ProgramSettingsPanelItem : UserControl
|
||||
{
|
||||
public static readonly StyledProperty<string> SettingKeyProp =
|
||||
AvaloniaProperty.Register<ProgramSettingsPanelItem, string>(
|
||||
"SettingKey");
|
||||
public string SettingKey
|
||||
{
|
||||
get => GetValue(SettingKeyProp);
|
||||
set => SetValue(SettingKeyProp, value);
|
||||
//TODO deal with textblock size
|
||||
/*KeyLabel.ToolTip = new ToolTip
|
||||
{
|
||||
Content = value,
|
||||
Foreground = App.MyWhite,
|
||||
Background = App.MySoftDark
|
||||
};*/
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<string> SettingValueProp =
|
||||
AvaloniaProperty.Register<ProgramSettingsPanelItem, string>("SettingValue");
|
||||
public string SettingValue
|
||||
{
|
||||
get => GetValue(SettingValueProp);
|
||||
set => SetValue(SettingValueProp, value);
|
||||
}
|
||||
|
||||
public event Action<ProgramSettingsPanelItem> UpdatedEvent;
|
||||
|
||||
public ProgramSettingsPanelItem() => InitializeComponent();
|
||||
|
||||
public ProgramSettingsPanelItem(string key, string value)
|
||||
{
|
||||
InitializeComponent();
|
||||
SettingKey = key;
|
||||
SettingValue = value;
|
||||
//TODO invoke UpdatedEvent only when focus changed
|
||||
ValueBox.TextInput += (_,_)=> UpdatedEvent?.Invoke(this);
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
using Avalonia.Styling;
|
||||
|
||||
namespace Launcher.Client.Avalonia.GUI;
|
||||
|
||||
public partial class TabButton : Button, IStyleable
|
||||
{
|
||||
Type IStyleable.StyleKey => typeof(Button);
|
||||
|
||||
public static readonly StyledProperty<Grid> TabGridProp = AvaloniaProperty.Register<TabButton, Grid>("TabGrid");
|
||||
public Grid TabGrid
|
||||
{
|
||||
get => GetValue(TabGridProp);
|
||||
set => SetValue(TabGridProp, value);
|
||||
}
|
||||
|
||||
public TabButton() :base() {}
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Launcher.Client.Avalonia</RootNamespace>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<DebugType>full</DebugType>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<ApplicationIcon>Resources/logo-D.ico</ApplicationIcon>
|
||||
<TrimMode>copyused</TrimMode>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<TargetCulture Label="Invariant" />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="0.10.18" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.18" Condition="'$(Configuration)' == 'Debug'" />
|
||||
<PackageReference Include="XamlNameReferenceGenerator" Version="1.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Launcher.Client\Launcher.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AvaloniaXaml Remove="publish\**" />
|
||||
<EmbeddedResource Remove="publish\**" />
|
||||
<Compile Remove="publish\**" />
|
||||
<None Remove="publish\**" />
|
||||
<Compile Update="GUI\App.axaml.cs">
|
||||
<DependentUpon>App.axaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<!--Target Name="PostBuild-Release" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
|
||||
<Exec Command="cp -f bin/Release/runtimes/linux-x64/native/* bin/Release/" />
|
||||
<Exec Command="cp -f bin/Release/runtimes/win-x64/native/* bin/Release/" />
|
||||
<Exec Command="rm -rf bin/Release/runtimes" />
|
||||
</Target>
|
||||
<Target Name="PostBuild-Debug" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Debug'">
|
||||
<Exec Command="cp -f bin/Debug/runtimes/linux-x64/native/* bin/Debug/" />
|
||||
<Exec Command="cp -f bin/Debug/runtimes/win-x64/native/* bin/Debug/" />
|
||||
<Exec Command="rm -rf bin/Debug/runtimes" />
|
||||
</Target!-->
|
||||
|
||||
</Project>
|
||||
@ -1,52 +0,0 @@
|
||||
global using System;
|
||||
global using System.Diagnostics;
|
||||
global using System.Net;
|
||||
global using System.Text;
|
||||
global using System.Collections.Generic;
|
||||
global using System.Linq;
|
||||
global using DTLib;
|
||||
global using DTLib.Dtsod;
|
||||
global using DTLib.Filesystem;
|
||||
global using DTLib.Extensions;
|
||||
global using Launcher.Client;
|
||||
global using static Launcher.Client.LauncherClient;
|
||||
global using static Launcher.Client.Avalonia.LauncherMain;
|
||||
using DTLib.Ben.Demystifier;
|
||||
using DTLib.Logging;
|
||||
using Launcher.Client.Avalonia.GUI;
|
||||
|
||||
namespace Launcher.Client.Avalonia;
|
||||
|
||||
public static class LauncherMain
|
||||
{
|
||||
public static LauncherWindow CurrentLauncherWindow;
|
||||
|
||||
//it's being used by Avalonia xml preview
|
||||
public static AppBuilder BuildAvaloniaApp() =>
|
||||
AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.LogToTrace();
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
LauncherClient.Init();
|
||||
var traceHandler = new ConsoleTraceListener();
|
||||
Trace.AutoFlush = true;
|
||||
Trace.Listeners.Add(traceHandler);
|
||||
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogError("STARTUP", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogError(string context, Exception ex)
|
||||
{
|
||||
string errmsg = ex.ToStringDemystified();
|
||||
MessageBox.Show($"{context} ERROR", errmsg);
|
||||
Logger.LogError("Main", errmsg);
|
||||
}
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
using Launcher.Client.Avalonia.GUI;
|
||||
|
||||
namespace Launcher.Client.Avalonia;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly string Directory;
|
||||
public readonly string Description;
|
||||
public readonly string IconFile;
|
||||
public readonly string BackgroundFile;
|
||||
public readonly string LaunchFile;
|
||||
public readonly string LaunchArgs;
|
||||
|
||||
public readonly ProgramLabel ProgramLabel;
|
||||
|
||||
public readonly string SettingsFile;
|
||||
public readonly DtsodV23 Settings;
|
||||
|
||||
public readonly StackPanel SettingsPanel;
|
||||
|
||||
private Process ProgramProcess;
|
||||
|
||||
public event Action<Program> ProgramSelectedEvent;
|
||||
|
||||
public Program(IOPath descriptorFile)
|
||||
{
|
||||
DtsodV23 descriptor= new(File.ReadAllText(descriptorFile));
|
||||
Name = descriptor["name"];
|
||||
Directory = descriptor["directory"];
|
||||
Description = descriptor["description"];
|
||||
IconFile = descriptor["icon"];
|
||||
BackgroundFile = descriptor["background"];
|
||||
string startcommand = descriptor["launchcommand"];
|
||||
LaunchFile = startcommand.Remove(startcommand.IndexOf(' '));
|
||||
LaunchArgs = startcommand.Remove(0,startcommand.IndexOf(' '));
|
||||
|
||||
ProgramLabel = new ProgramLabel(Name, IconFile);
|
||||
ProgramLabel.PointerPressed += (_, _) => ProgramSelectedEvent?.Invoke(this);
|
||||
|
||||
SettingsFile = $"settings{Path.Sep}{Directory}.settings";
|
||||
Settings = File.Exists(SettingsFile)
|
||||
? DtsodConverter.UpdateByDefault(
|
||||
new DtsodV23(File.ReadAllText(SettingsFile)),
|
||||
descriptor["default_settings"])
|
||||
: descriptor["default_settings"];
|
||||
File.WriteAllText(SettingsFile, Settings.ToString());
|
||||
SettingsPanel = new StackPanel();
|
||||
foreach (var setting in Settings)
|
||||
{
|
||||
ProgramSettingsPanelItem settingUi = new(setting.Key, setting.Value);
|
||||
settingUi.UpdatedEvent += UpdateSetting;
|
||||
SettingsPanel.Children.Add(settingUi);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateSetting(ProgramSettingsPanelItem uiElem)
|
||||
{
|
||||
Settings[uiElem.SettingKey] = uiElem.SettingValue;
|
||||
File.WriteAllText(SettingsFile, Settings.ToString());
|
||||
}
|
||||
|
||||
public void Launch()
|
||||
{
|
||||
if(ProgramProcess.HasExited)
|
||||
throw new Exception($"can't start program <{Name}>, because it hadn't stopped yet");
|
||||
ProgramProcess = Process.Start(LaunchFile, LaunchArgs);
|
||||
if (ProgramProcess is null)
|
||||
throw new Exception($"program <{Name}> started, but ProgramProcess is null");
|
||||
CurrentLauncherWindow.LaunchButton.Content = "Stop";
|
||||
ProgramProcess.Exited += ProgramExitedHandler;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (!ProgramProcess.HasExited)
|
||||
throw new Exception($"can't stop program <{Name}>, because it had stopped already");
|
||||
ProgramProcess.Kill(true);
|
||||
}
|
||||
|
||||
void ProgramExitedHandler(object sender, EventArgs eargs)
|
||||
{
|
||||
CurrentLauncherWindow.LaunchButton.Content = "Start";
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 437 KiB |
@ -1,7 +0,0 @@
|
||||
#descriptor_version: 3;
|
||||
name: "Conan Exiles";
|
||||
description: "Сурвайвл на анриале в сеттинге Конана Варвара.";
|
||||
directory: "conan_exiles";
|
||||
icon: "conan_exiles.png";
|
||||
background: "conan_exiles_background.png";
|
||||
launchcommand: "cmd /c echo hello && pause";
|
||||
@ -1,7 +0,0 @@
|
||||
#descriptor_version: 3;
|
||||
name: "Divinity 2 Developer's Cut";
|
||||
description: "РПГ от Larian. Вид от третьего лица, проработанный мир, интересная боёвка.";
|
||||
directory: "divinity2_devcut";
|
||||
icon: "divinity2devcut.png";
|
||||
background: "divinity2devcut_background.jpg";
|
||||
launchcommand: "";
|
||||
@ -1,5 +0,0 @@
|
||||
[fonts]
|
||||
unispace.ttf
|
||||
unispace_bd.ttf
|
||||
unispace_it.ttf
|
||||
unispace_bd_it.ttf
|
||||
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
@ -1,265 +0,0 @@
|
||||
<Application x:Class="Launcher.Client.WPF.GUI.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Application.Resources>
|
||||
<SolidColorBrush x:Key="MyBackgroundColor" Color="#232328"/>
|
||||
<SolidColorBrush x:Key="MyDarkTr"
|
||||
Opacity="0.8"
|
||||
Color="#141419" />
|
||||
<SolidColorBrush x:Key="MyGray" Color="#46464B" />
|
||||
<SolidColorBrush x:Key="MyWhite" Color="#F0F0F0" />
|
||||
<SolidColorBrush x:Key="MyGreen" Color="#28C311" />
|
||||
<SolidColorBrush x:Key="MyRed" Color="#E5160A" />
|
||||
<SolidColorBrush x:Key="MySelectionColor" Color="#B7800A" />
|
||||
|
||||
|
||||
<ControlTemplate x:Key="myScrollBar" TargetType="{x:Type ScrollBar}">
|
||||
<Grid x:Name="Bg" SnapsToDevicePixels="True">
|
||||
<Border Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderBrush="{DynamicResource MyDarkTr}"
|
||||
BorderThickness="0" />
|
||||
<Track x:Name="PART_Track"
|
||||
IsDirectionReversed="True"
|
||||
IsEnabled="{TemplateBinding IsMouseOver}">
|
||||
<Track.Thumb>
|
||||
<Thumb>
|
||||
<Thumb.Style>
|
||||
<Style TargetType="{x:Type Thumb}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Thumb}">
|
||||
<Border x:Name="rectangle"
|
||||
Width="6"
|
||||
Height="{TemplateBinding Height}"
|
||||
Background="{DynamicResource MyGray}"
|
||||
SnapsToDevicePixels="True" />
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="rectangle" Property="Background" Value="{DynamicResource MyGray}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsDragging" Value="True">
|
||||
<Setter TargetName="rectangle" Property="Background" Value="{DynamicResource MySelectionColor}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Thumb.Style>
|
||||
</Thumb>
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="myScrollViewer" TargetType="{x:Type ScrollViewer}">
|
||||
<Grid x:Name="Grid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Rectangle x:Name="Corner"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
|
||||
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
CanContentScroll="{TemplateBinding CanContentScroll}"
|
||||
CanHorizontallyScroll="False"
|
||||
CanVerticallyScroll="False"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||
<ScrollBar x:Name="PART_VerticalScrollBar"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
AutomationProperties.AutomationId="VerticalScrollBar"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Cursor="Arrow"
|
||||
Maximum="{TemplateBinding ScrollableHeight}"
|
||||
Minimum="0"
|
||||
Template="{DynamicResource myScrollBar}"
|
||||
ViewportSize="{TemplateBinding ViewportHeight}"
|
||||
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
|
||||
Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<ScrollBar x:Name="PART_HorizontalScrollBar"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
AutomationProperties.AutomationId="HorizontalScrollBar"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Cursor="Arrow"
|
||||
Maximum="{TemplateBinding ScrollableWidth}"
|
||||
Minimum="0"
|
||||
Orientation="Horizontal"
|
||||
Template="{DynamicResource myScrollBar}"
|
||||
ViewportSize="{TemplateBinding ViewportWidth}"
|
||||
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
|
||||
Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="MyTextBoxStyle" TargetType="TextBox">
|
||||
<Setter Property="IsReadOnly" Value="True" />
|
||||
<Setter Property="Background" Value="{DynamicResource MyDarkTr}" />
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource MyWhite}" />
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource MySelectionColor}" />
|
||||
<Setter Property="Template" Value="{DynamicResource myTextBox}" />
|
||||
<Setter Property="TextWrapping" Value="Wrap" />
|
||||
</Style>
|
||||
<ControlTemplate x:Key="myTextBox" TargetType="{x:Type TextBoxBase}">
|
||||
<Border Name="Border"
|
||||
Padding="0"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderBrush="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderThickness="2">
|
||||
<ScrollViewer x:Name="PART_ContentHost"
|
||||
Margin="0"
|
||||
Template="{DynamicResource myScrollViewer}" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="Border" Property="Background" Value="Black" />
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="White" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="MyButtonStyle" TargetType="Button">
|
||||
<Setter Property="Template" Value="{DynamicResource MyButton}" />
|
||||
<Setter Property="Background" Value="{DynamicResource MyDarkTr}" />
|
||||
<Setter Property="BorderThickness" Value="3" />
|
||||
<Setter Property="FontFamily" Value="Unispace" />
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource MyWhite}" />
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="MyButton" TargetType="Button">
|
||||
<Border x:Name="Border"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderBrush="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<Grid>
|
||||
<Border x:Name="Border_fade"
|
||||
Background="{DynamicResource MyWhite}"
|
||||
Opacity="0.2"
|
||||
Visibility="Hidden" />
|
||||
<Border x:Name="Border_fade2"
|
||||
Background="{DynamicResource MyGray}"
|
||||
Opacity="0.4"
|
||||
Visibility="Hidden" />
|
||||
<ContentPresenter Margin="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
RecognizesAccessKey="True" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter TargetName="Border_fade" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="true">
|
||||
<Setter TargetName="Border_fade" Property="Visibility" Value="Hidden" />
|
||||
<Setter TargetName="Border_fade2" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="MyLabelStyle" TargetType="Label">
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="Background" Value="{DynamicResource MyDarkTr}" />
|
||||
<Setter Property="FontFamily" Value="Unispace" />
|
||||
<Setter Property="FontStyle" Value="Normal" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource MyWhite}" />
|
||||
<!-->disables some shit which removes underscores from Content<!-->
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Label}">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
RecognizesAccessKey="False" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="MyComboBox" TargetType="ComboBox">
|
||||
<Grid>
|
||||
<ToggleButton Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="5*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border x:Name="Border"
|
||||
Grid.ColumnSpan="2"
|
||||
Background="{DynamicResource MyDarkTr}" />
|
||||
<Border Grid.Column="0"
|
||||
Margin="1"
|
||||
Background="{DynamicResource MyDarkTr}" />
|
||||
<Path x:Name="Arrow"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Data="M 0 0 L 4 4 L 8 0 Z"
|
||||
Fill="{DynamicResource MySelectionColor}" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="ToggleButton.IsMouseOver" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource MySelectionColor}" />
|
||||
</Trigger>
|
||||
<Trigger Property="ToggleButton.IsChecked" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource MySelectionColor}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</ToggleButton.Template>
|
||||
</ToggleButton>
|
||||
<ContentPresenter Name="ContentSite"
|
||||
Margin="3"
|
||||
Content="{TemplateBinding SelectionBoxItem}"
|
||||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
|
||||
IsHitTestVisible="False" />
|
||||
<TextBox x:Name="PART_EditableTextBox"
|
||||
IsReadOnly="{TemplateBinding IsReadOnly}"
|
||||
Visibility="Hidden" />
|
||||
<Popup Name="Popup"
|
||||
AllowsTransparency="True"
|
||||
Focusable="False"
|
||||
IsOpen="{TemplateBinding IsDropDownOpen}"
|
||||
Placement="Bottom"
|
||||
PopupAnimation="Slide">
|
||||
<Grid Name="DropDown"
|
||||
MinWidth="{TemplateBinding ActualWidth}"
|
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||
SnapsToDevicePixels="True">
|
||||
<Border x:Name="DropDownBorder" Background="{DynamicResource MyDarkTr}" />
|
||||
<ScrollViewer SnapsToDevicePixels="True">
|
||||
<StackPanel IsItemsHost="True" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Popup>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@ -1,30 +0,0 @@
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Launcher.Client.WPF.GUI;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
public static SolidColorBrush MyDark,MySoftDark, MyWhite, MyGreen, MyOrange, MySelectionColor;
|
||||
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
base.OnStartup(e);
|
||||
MyDark = (SolidColorBrush)Resources["MyDarkTr"];
|
||||
MySoftDark = (SolidColorBrush)Resources["MyGray"];
|
||||
MyWhite = (SolidColorBrush)Resources["MyWhite"];
|
||||
MyGreen = (SolidColorBrush)Resources["MyGreen"];
|
||||
MyOrange = (SolidColorBrush)Resources["MySelectionColor"];
|
||||
MySelectionColor = (SolidColorBrush)Resources["MySelectionColor"];
|
||||
_Main(e.Args);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
LogError("STARTUP",ex);
|
||||
Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,226 +0,0 @@
|
||||
<Window x:Class="Launcher.Client.WPF.GUI.LauncherWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Launcher.Client.WPF.GUI"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="Launcher"
|
||||
Width="800"
|
||||
Height="500"
|
||||
MinWidth="800"
|
||||
MinHeight="500"
|
||||
Background="{DynamicResource MyBackgroundColor}"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="5" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="5" />
|
||||
</Grid.RowDefinitions>
|
||||
<Image x:Name="BackgroundImage"
|
||||
Grid.RowSpan="5"
|
||||
Grid.ColumnSpan="3"
|
||||
HorizontalAlignment="Center"
|
||||
Stretch="UniformToFill" />
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local:TabButton x:Name="LibraryButton"
|
||||
Grid.Column="0"
|
||||
Content="Library"
|
||||
FontSize="18"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<local:TabButton x:Name="DownloadsButton"
|
||||
Grid.Column="2"
|
||||
Content="Downloads"
|
||||
FontSize="18"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<local:TabButton x:Name="LogButton"
|
||||
Grid.Column="4"
|
||||
Content="Log"
|
||||
FontSize="18"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<local:TabButton x:Name="SettingsButton"
|
||||
Grid.Column="6"
|
||||
Content="Settings"
|
||||
FontSize="18"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="LibraryGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Visibility="Visible">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="220" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="220" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ScrollViewer Grid.Column="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Template="{DynamicResource myScrollViewer}"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel x:Name="ProgramsPanel" />
|
||||
</ScrollViewer>
|
||||
<Grid x:Name="ProgramGrid" Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="35" />
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition Height="35" />
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition Height="70" />
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label x:Name="NameLabel"
|
||||
Grid.Row="0"
|
||||
Content="name"
|
||||
FontSize="19"
|
||||
FontWeight="Bold"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<StackPanel Grid.Row="2"
|
||||
HorizontalAlignment="Right"
|
||||
ClipToBounds="True"
|
||||
Orientation="Horizontal">
|
||||
<Button x:Name="RemoveButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Background="{DynamicResource MyRed}"
|
||||
Content="Remove"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<Button x:Name="InstallButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Content="Install"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<Button x:Name="UpdateButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Content="Update"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<Button x:Name="LaunchButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Background="{DynamicResource MyGreen}"
|
||||
Content="Launch"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
</StackPanel>
|
||||
<TextBox x:Name="DescriptionBox"
|
||||
Grid.Row="4"
|
||||
Style="{DynamicResource MyTextBoxStyle}"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
<TextBox x:Name="ProgramLogBox"
|
||||
Grid.Row="6"
|
||||
Style="{DynamicResource MyTextBoxStyle}"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</Grid>
|
||||
<Grid Grid.Row="0" Grid.Column="4">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="95" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="30" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Content="version:"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Background="{DynamicResource MyDarkTr}"
|
||||
Template="{DynamicResource MyComboBox}">
|
||||
<ComboBoxItem IsSelected="True">
|
||||
<Label Background="Transparent"
|
||||
Content="v1"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<Label Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Content="directory:"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<Label Name="ProgramDirectoryLabel"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Content="0"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<Label Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Content="size:"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<Label Name="ProgramSizeLabel"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Content="0"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
</Grid>
|
||||
<ScrollViewer Name="ProgramSettingsViever"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
VerticalContentAlignment="Top"
|
||||
Template="{DynamicResource myScrollViewer}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
<Grid x:Name="DownloadsGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Visibility="Hidden" />
|
||||
|
||||
<Grid x:Name="LogGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Visibility="Hidden">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Label x:Name="LogfileLabel"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Content="logfile"
|
||||
FontStyle="Italic"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<TextBox x:Name="LogBox"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Style="{DynamicResource MyTextBoxStyle}"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="SettingsGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Visibility="Hidden" />
|
||||
</Grid>
|
||||
</Window>
|
||||
@ -1,96 +0,0 @@
|
||||
using System.Windows.Media.Imaging;
|
||||
using DTLib.Logging;
|
||||
|
||||
namespace Launcher.Client.WPF.GUI;
|
||||
|
||||
public partial class LauncherWindow : Window
|
||||
{
|
||||
public LauncherWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
LogBox.Text = Logger.Buffer;
|
||||
Logger.MessageSent += LogHandler;
|
||||
LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Path.Sep)+1);
|
||||
LogfileLabel.MouseLeftButtonDown += (_,_)=>
|
||||
Process.Start("explorer.exe", LauncherLogger.LogfileDir.ToString()!);
|
||||
LogfileLabel.MouseEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor;
|
||||
LogfileLabel.MouseLeave += (_,_)=>LogfileLabel.Foreground=App.MyWhite;
|
||||
LibraryButton.TabGrid = LibraryGrid;
|
||||
DownloadsButton.TabGrid = DownloadsGrid;
|
||||
LogButton.TabGrid = LogGrid;
|
||||
SettingsButton.TabGrid = SettingsGrid;
|
||||
LibraryButton.Click += SelectTab;
|
||||
DownloadsButton.Click += SelectTab;
|
||||
LogButton.Click += SelectTab;
|
||||
SettingsButton.Click += SelectTab;
|
||||
ProgramGrid.Visibility = Visibility.Hidden;
|
||||
SelectTab(LibraryButton, null);
|
||||
FillProgramsPanel();
|
||||
Logger.LogInfo(nameof(LauncherWindow),"launcher started");
|
||||
}
|
||||
|
||||
void LogHandler(string m) => Dispatcher.Invoke(()=>LogBox.Text += m);
|
||||
|
||||
|
||||
private TabButton CurrentTab;
|
||||
void SelectTab(object sender, RoutedEventArgs _)
|
||||
{
|
||||
if(CurrentTab!=null)
|
||||
{
|
||||
CurrentTab.Background = App.MyDark;
|
||||
CurrentTab.TabGrid.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
var selected = (TabButton)sender;
|
||||
selected.Background = App.MySelectionColor;
|
||||
selected.TabGrid.Visibility = Visibility.Visible;
|
||||
CurrentTab = selected;
|
||||
}
|
||||
|
||||
public Program[] Programs;
|
||||
|
||||
private void FillProgramsPanel()
|
||||
{
|
||||
Logger.LogInfo(nameof(LauncherWindow),"reading descriptors...");
|
||||
var descriptors = Directory.GetFiles("descriptors");
|
||||
Programs = new Program[descriptors.Length];
|
||||
for (ushort i = 0; i < descriptors.Length; i++)
|
||||
{
|
||||
var descriptor = descriptors[i];
|
||||
if(descriptor.EndsWith(".descriptor"))
|
||||
{
|
||||
Logger.LogInfo(nameof(LauncherWindow),descriptor.ToString());
|
||||
Programs[i] = new Program(descriptors[i]);
|
||||
ProgramsPanel.Children.Add(Programs[i].ProgramLabel);
|
||||
Programs[i].ProgramSelectedEvent += SelectProgram;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Program DisplayingProgram;
|
||||
public void SelectProgram(Program selectedProg)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DisplayingProgram != null)
|
||||
{
|
||||
DisplayingProgram.ProgramLabel.Foreground = App.MyWhite;
|
||||
DisplayingProgram.ProgramLabel.FontWeight = FontWeights.Normal;
|
||||
}
|
||||
else ProgramGrid.Visibility = Visibility.Visible;
|
||||
|
||||
selectedProg.ProgramLabel.Foreground = App.MySelectionColor;
|
||||
selectedProg.ProgramLabel.FontWeight = FontWeights.Bold;
|
||||
|
||||
NameLabel.Content = selectedProg.Name;
|
||||
DescriptionBox.Text = selectedProg.Description;
|
||||
BackgroundImage.Source =
|
||||
new BitmapImage(new Uri(
|
||||
$"{Directory.GetCurrent()}{Path.Sep}backgrounds{Path.Sep}{selectedProg.BackgroundFile}",
|
||||
UriKind.Absolute));
|
||||
ProgramSettingsViever.Content = selectedProg.SettingsPanel;
|
||||
DisplayingProgram = selectedProg;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{ LogError("SelectProgram()",ex); }
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
<UserControl x:Class="Launcher.Client.WPF.GUI.ProgramLabel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Launcher.Client.WPF.GUI"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Height="50"
|
||||
Background="{DynamicResource MyDarkTr}"
|
||||
BorderBrush="{Binding Foreground, RelativeSource={RelativeSource Self}}"
|
||||
BorderThickness="3"
|
||||
Foreground="{DynamicResource MyWhite}"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding Height, RelativeSource={RelativeSource FindAncestor, AncestorType=local:ProgramLabel}}" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image x:Name="IconImage"
|
||||
Grid.Column="0"
|
||||
Margin="3,3,3,3"
|
||||
Stretch="Fill" />
|
||||
|
||||
<Label Name="NameLabel"
|
||||
Grid.Column="1"
|
||||
VerticalContentAlignment="Center"
|
||||
Content="label"
|
||||
FontFamily="Unispace"
|
||||
FontSize="15"
|
||||
FontWeight="Normal"
|
||||
Foreground="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ProgramLabel}}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -1,16 +0,0 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace Launcher.Client.WPF.GUI;
|
||||
|
||||
public partial class ProgramLabel : UserControl
|
||||
{
|
||||
public ProgramLabel(string label, string icon)
|
||||
{
|
||||
InitializeComponent();
|
||||
NameLabel.Content = label;
|
||||
IconImage.Source = new BitmapImage(new Uri(
|
||||
$"{Directory.GetCurrent()}{Path.Sep}icons{Path.Sep}{icon}",
|
||||
UriKind.Absolute));
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
<UserControl x:Class="Launcher.Client.WPF.GUI.ProgramSettingsPanelItem"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Launcher.Client.WPF.GUI"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignWidth="100"
|
||||
d:DesignHeight="30"
|
||||
mc:Ignorable="d"
|
||||
Background="Transparent">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Name="KeyLabel" Grid.Column="0"
|
||||
Content="{Binding SettingKey, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ProgramSettingsPanelItem}}"
|
||||
Style="{DynamicResource MyLabelStyle}"
|
||||
FontFamily="default"
|
||||
FontSize="16"/>
|
||||
<TextBox Name="ValueBox" Grid.Column="1"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
Style="{DynamicResource MyTextBoxStyle}"
|
||||
VerticalScrollBarVisibility="Disabled"
|
||||
IsReadOnly="False"
|
||||
Text="{Binding SettingValue, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ProgramSettingsPanelItem}}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -1,45 +0,0 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Launcher.Client.WPF.GUI;
|
||||
|
||||
public partial class ProgramSettingsPanelItem : UserControl
|
||||
{
|
||||
public static readonly DependencyProperty SettingKeyProp = DependencyProperty.Register(
|
||||
"SettingKey",
|
||||
typeof(string),
|
||||
typeof(ProgramSettingsPanelItem));
|
||||
public string SettingKey
|
||||
{
|
||||
get => (string)GetValue(SettingKeyProp);
|
||||
set
|
||||
{
|
||||
SetValue(SettingKeyProp, value);
|
||||
KeyLabel.ToolTip = new ToolTip
|
||||
{
|
||||
Content = value,
|
||||
Foreground = App.MyWhite,
|
||||
Background = App.MySoftDark
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SettingValueProp = DependencyProperty.Register(
|
||||
"SettingValue",
|
||||
typeof(string),
|
||||
typeof(ProgramSettingsPanelItem));
|
||||
public string SettingValue
|
||||
{
|
||||
get => (string)GetValue(SettingValueProp);
|
||||
set => SetValue(SettingValueProp, value);
|
||||
}
|
||||
|
||||
public event Action<ProgramSettingsPanelItem> UpdatedEvent;
|
||||
|
||||
public ProgramSettingsPanelItem(string key, string value)
|
||||
{
|
||||
InitializeComponent();
|
||||
SettingKey = key;
|
||||
SettingValue = value;
|
||||
ValueBox.TextChanged += (_,_)=> UpdatedEvent?.Invoke(this);
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Launcher.Client.WPF.GUI;
|
||||
|
||||
public class TabButton : Button
|
||||
{
|
||||
public static readonly DependencyProperty TabGridProp = DependencyProperty.Register(
|
||||
"TabGrid",
|
||||
typeof(Grid),
|
||||
typeof(TabButton));
|
||||
public Grid TabGrid
|
||||
{
|
||||
get => (Grid)GetValue(TabGridProp);
|
||||
set => SetValue(TabGridProp, value);
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<UseWPF>true</UseWPF>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<RootNamespace>Launcher.Client.WPF</RootNamespace>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<DebugType>full</DebugType>
|
||||
<ApplicationIcon>Resources\logo-D.ico</ApplicationIcon>
|
||||
<TargetCulture Label="Invariant" />
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="GUI\App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<XamlRuntime>Wpf</XamlRuntime>
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Launcher.Client\Launcher.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,40 +0,0 @@
|
||||
global using DTLib;
|
||||
global using DTLib.Dtsod;
|
||||
global using DTLib.Filesystem;
|
||||
global using DTLib.Extensions;
|
||||
global using System;
|
||||
global using System.Diagnostics;
|
||||
global using System.Net;
|
||||
global using System.Text;
|
||||
global using System.Collections.Generic;
|
||||
global using System.Linq;
|
||||
global using System.Windows;
|
||||
global using Launcher.Client;
|
||||
global using static Launcher.Client.LauncherClient;
|
||||
global using static Launcher.Client.WPF.LauncherMain;
|
||||
using DTLib.Ben.Demystifier;
|
||||
using DTLib.Logging;
|
||||
using Launcher.Client.WPF.GUI;
|
||||
|
||||
namespace Launcher.Client.WPF;
|
||||
|
||||
public static class LauncherMain
|
||||
{
|
||||
public static LauncherWindow CurrentLauncherWindow;
|
||||
|
||||
public static void _Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("aaa\nbbb\nccc");
|
||||
return;
|
||||
LauncherClient.Init();
|
||||
CurrentLauncherWindow = new LauncherWindow();
|
||||
CurrentLauncherWindow.Show();
|
||||
}
|
||||
|
||||
public static void LogError(string context, Exception ex)
|
||||
{
|
||||
string errmsg = ex.ToStringDemystified();
|
||||
MessageBox.Show(errmsg);
|
||||
Logger.LogError(context, errmsg);
|
||||
}
|
||||
}
|
||||
@ -1,86 +0,0 @@
|
||||
using System.Windows.Controls;
|
||||
using Launcher.Client.WPF.GUI;
|
||||
|
||||
namespace Launcher.Client.WPF;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly string Directory;
|
||||
public readonly string Description;
|
||||
public readonly string IconFile;
|
||||
public readonly string BackgroundFile;
|
||||
public readonly string LaunchFile;
|
||||
public readonly string LaunchArgs;
|
||||
|
||||
public readonly ProgramLabel ProgramLabel;
|
||||
|
||||
public readonly string SettingsFile;
|
||||
public readonly DtsodV23 Settings;
|
||||
|
||||
public readonly StackPanel SettingsPanel;
|
||||
|
||||
private Process ProgramProcess;
|
||||
|
||||
public event Action<Program> ProgramSelectedEvent;
|
||||
|
||||
public Program(IOPath descriptorFile)
|
||||
{
|
||||
DtsodV23 descriptor= new(File.ReadAllText(descriptorFile));
|
||||
Name = descriptor["name"];
|
||||
Directory = descriptor["directory"];
|
||||
Description = descriptor["description"];
|
||||
IconFile = descriptor["icon"];
|
||||
BackgroundFile = descriptor["background"];
|
||||
string startcommand = descriptor["launchcommand"];
|
||||
LaunchFile = startcommand.Remove(startcommand.IndexOf(' '));
|
||||
LaunchArgs = startcommand.Remove(0,startcommand.IndexOf(' '));
|
||||
|
||||
ProgramLabel = new ProgramLabel(Name, IconFile);
|
||||
ProgramLabel.MouseLeftButtonDown += (_, _) => ProgramSelectedEvent?.Invoke(this);
|
||||
|
||||
SettingsFile = $"settings{Path.Sep}{Directory}.settings";
|
||||
Settings = File.Exists(SettingsFile)
|
||||
? DtsodConverter.UpdateByDefault(
|
||||
new DtsodV23(File.ReadAllText(SettingsFile)),
|
||||
descriptor["default_settings"])
|
||||
: descriptor["default_settings"];
|
||||
File.WriteAllText(SettingsFile, Settings.ToString());
|
||||
SettingsPanel = new StackPanel();
|
||||
foreach (var setting in Settings)
|
||||
{
|
||||
ProgramSettingsPanelItem settingUi = new(setting.Key, setting.Value);
|
||||
settingUi.UpdatedEvent += UpdateSetting;
|
||||
SettingsPanel.Children.Add(settingUi);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateSetting(ProgramSettingsPanelItem uiElem)
|
||||
{
|
||||
Settings[uiElem.SettingKey] = uiElem.SettingValue;
|
||||
File.WriteAllText(SettingsFile, Settings.ToString());
|
||||
}
|
||||
|
||||
public void Launch()
|
||||
{
|
||||
if(ProgramProcess.HasExited)
|
||||
throw new Exception($"can't start program <{Name}>, because it hadn't stopped yet");
|
||||
ProgramProcess = Process.Start(LaunchFile, LaunchArgs);
|
||||
if (ProgramProcess is null)
|
||||
throw new Exception($"program <{Name}> started, but ProgramProcess is null");
|
||||
CurrentLauncherWindow.LaunchButton.Content = "Stop";
|
||||
ProgramProcess.Exited += ProgramExitedHandler;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (!ProgramProcess.HasExited)
|
||||
throw new Exception($"can't stop program <{Name}>, because it had stopped already");
|
||||
ProgramProcess.Kill(true);
|
||||
}
|
||||
|
||||
void ProgramExitedHandler(object sender, EventArgs eargs)
|
||||
{
|
||||
CurrentLauncherWindow.LaunchButton.Content = "Start";
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
using DTLib.Logging;
|
||||
|
||||
namespace Launcher.Client;
|
||||
|
||||
public class BufferedLogger : ILogger
|
||||
{
|
||||
public bool DebugLogEnabled { get; set; } =
|
||||
#if DEBUG
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
public bool InfoLogEnabled { get; set; } = true;
|
||||
public bool WarnLogEnabled { get; set; } = true;
|
||||
public bool ErrorLogEnabled { get; set; } = true;
|
||||
|
||||
public ILogFormat Format { get; set; } = new DefaultLogFormat();
|
||||
|
||||
private readonly StringBuilder _buffer = new();
|
||||
public string Buffer
|
||||
{
|
||||
get { lock (_buffer) return _buffer.ToString(); }
|
||||
}
|
||||
|
||||
public event Action<string> MessageSent;
|
||||
|
||||
|
||||
public void Log(string context, LogSeverity severity, object message, ILogFormat format)
|
||||
{
|
||||
string msgConnected = Format.CreateMessage(context, severity, message);
|
||||
MessageSent?.Invoke(msgConnected);
|
||||
lock (_buffer) _buffer.Append(msgConnected);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<RootNamespace>Launcher.Client</RootNamespace>
|
||||
<DebugType>full</DebugType>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Resources\**\*" />
|
||||
<EmbeddedResource Include="Resources\**\*" />
|
||||
<Compile Remove="debug_assets\**\*" />
|
||||
<None Update="debug_assets\**\*" CopyToOutputDirectory="Always" Condition="'$(Configuration)' == 'Debug'" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DTLib.Dtsod" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib.Logging" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib.Network" Version="1.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,40 +0,0 @@
|
||||
global using System;
|
||||
global using System.Diagnostics;
|
||||
global using System.Net;
|
||||
global using System.Text;
|
||||
global using System.Collections.Generic;
|
||||
global using System.Linq;
|
||||
global using DTLib;
|
||||
global using DTLib.Dtsod;
|
||||
global using DTLib.Filesystem;
|
||||
global using DTLib.Extensions;
|
||||
using DTLib.Logging;
|
||||
|
||||
namespace Launcher.Client;
|
||||
|
||||
public static class LauncherClient
|
||||
{
|
||||
public static LauncherConfig Config;
|
||||
public static readonly LauncherLogger Logger = new();
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
Logger.LogInfo(nameof(LauncherClient),"launcher starting...");
|
||||
Config = new LauncherConfig();
|
||||
#if DEBUG
|
||||
const string debug_assets = "debug_assets";
|
||||
foreach (string file in Directory.GetFiles(debug_assets))
|
||||
File.Copy(file, file.Remove(0, file.LastIndexOf(Path.Sep) + 1), true);
|
||||
foreach (string subdir in Directory.GetDirectories(debug_assets))
|
||||
Directory.Copy(subdir, subdir.Remove(0, subdir.LastIndexOf(Path.Sep) + 1), true);
|
||||
Directory.Delete(debug_assets);
|
||||
#endif
|
||||
Directory.Create("descriptors");
|
||||
Directory.Create("icons");
|
||||
Directory.Create("backgrounds");
|
||||
Directory.Create("installed");
|
||||
Directory.Create("settings");
|
||||
File.WriteAllText($"descriptors{Path.Sep}default.descriptor.template",
|
||||
EmbeddedResources.ReadText("Launcher.Client.Resources.default.descriptor.template"));
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
namespace Launcher.Client;
|
||||
|
||||
public class LauncherConfig
|
||||
{
|
||||
|
||||
public record struct Server(IPEndPoint EndPoint, string Domain)
|
||||
{
|
||||
public Server(string domain, int port) : this
|
||||
(new IPEndPoint(Dns.GetHostAddresses(domain)[0], port), domain)
|
||||
{ }
|
||||
public Server(IPAddress address, int port) : this
|
||||
(new IPEndPoint(address, port), "")
|
||||
{ }
|
||||
}
|
||||
|
||||
public const int Version=1;
|
||||
public Server[] ServerAddresses;
|
||||
|
||||
const string configFile = "launcher.dtsod";
|
||||
public LauncherConfig()
|
||||
{
|
||||
// читает дефолтный конфиг из ресурсов
|
||||
DtsodV23 updatedConfig;
|
||||
DtsodV23 updatedDefault = new(EmbeddedResources.ReadText("Launcher.Client.Resources.launcher.dtsod"));
|
||||
// проверка и обновление конфига
|
||||
if (File.Exists(configFile))
|
||||
{
|
||||
DtsodV23 oldConfig = new(File.ReadAllText(configFile));
|
||||
updatedConfig = DtsodConverter.UpdateByDefault(oldConfig, updatedDefault);
|
||||
}
|
||||
else updatedConfig = updatedDefault;
|
||||
|
||||
// парсит парсит полученный дтсод в LauncherConfig
|
||||
List<object> serversD = updatedConfig["server"];
|
||||
ServerAddresses = new Server[serversD.Count];
|
||||
ushort i = 0;
|
||||
foreach (DtsodV23 serverD in serversD)
|
||||
{
|
||||
int port = serverD["port"];
|
||||
// server must have <domain> or <ip> property
|
||||
ServerAddresses[i++] = serverD.TryGetValue("domain", out dynamic dom)
|
||||
? new Server(dom, port)
|
||||
: new Server(IPAddress.Parse(serverD["ip"]), port);
|
||||
}
|
||||
|
||||
WriteToFile();
|
||||
}
|
||||
|
||||
// записывает обновлённый конфиг в файл
|
||||
public void WriteToFile()
|
||||
{
|
||||
StringBuilder b = new();
|
||||
b.Append("version: ").Append(Version).Append(";\n");
|
||||
foreach (var server in ServerAddresses)
|
||||
{
|
||||
b.Append("$server: {\n\t");
|
||||
if (server.Domain == "")
|
||||
b.Append("ip: \"").Append(server.EndPoint.Address);
|
||||
else b.Append("domain: \"").Append(server.Domain);
|
||||
b.Append("\";\n\tport: ")
|
||||
.Append(server.EndPoint.Port)
|
||||
.Append(";\n};\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
using DTLib.Logging;
|
||||
|
||||
namespace Launcher.Client;
|
||||
|
||||
public class LauncherLogger : CompositeLogger
|
||||
{
|
||||
public static readonly IOPath LogfileDir = "launcher-logs";
|
||||
public readonly string LogfileName;
|
||||
public event Action<string> MessageSent;
|
||||
public string Buffer => _bufferedLogger.Buffer;
|
||||
|
||||
|
||||
FileLogger _fileLogger = new(LogfileDir,"launcher-client");
|
||||
ConsoleLogger _consoleLogger = new();
|
||||
BufferedLogger _bufferedLogger = new BufferedLogger();
|
||||
|
||||
public LauncherLogger()
|
||||
{
|
||||
_loggers = new ILogger[] { _fileLogger, _consoleLogger, _bufferedLogger };
|
||||
LogfileName = _fileLogger.LogfileName.Str;
|
||||
_bufferedLogger.MessageSent += s => MessageSent?.Invoke(s);
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
namespace Launcher.Client;
|
||||
|
||||
public class ProgramDescriptor
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
#descriptor_version: 3;
|
||||
name: ""; #label, which displays in launcher
|
||||
description: ""; #desctiption, which displays in launcher
|
||||
directory: ""; #name of program directory on server and client
|
||||
icon: ""; #name of the icon file
|
||||
background: ""; #name of the background file
|
||||
launchcommand: ""; #command, which starts the program
|
||||
@ -1,6 +0,0 @@
|
||||
version: 1;
|
||||
|
||||
$server: {
|
||||
ip: "127.0.0.1";
|
||||
port: 25000;
|
||||
};
|
||||
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 437 KiB |
@ -1,7 +0,0 @@
|
||||
#descriptor_version: 3;
|
||||
name: "Conan Exiles";
|
||||
description: "Сурвайвл на анриале в сеттинге Конана Варвара.";
|
||||
directory: "conan_exiles";
|
||||
icon: "conan_exiles.png";
|
||||
background: "conan_exiles_background.png";
|
||||
launchcommand: "cmd /c echo hello && pause";
|
||||
@ -1,7 +0,0 @@
|
||||
#descriptor_version: 3;
|
||||
name: "Divinity 2 Developer's Cut";
|
||||
description: "РПГ от Larian. Вид от третьего лица, проработанный мир, интересная боёвка.";
|
||||
directory: "divinity2_devcut";
|
||||
icon: "divinity2devcut.png";
|
||||
background: "divinity2devcut_background.jpg";
|
||||
launchcommand: "";
|
||||
@ -1,5 +0,0 @@
|
||||
[fonts]
|
||||
unispace.ttf
|
||||
unispace_bd.ttf
|
||||
unispace_it.ttf
|
||||
unispace_bd_it.ttf
|
||||
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
@ -1,26 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<RootNamespace>Launcher.Server</RootNamespace>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<DebugType>full</DebugType>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="launcher-server.dtsod">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DTLib.Dtsod" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib.Logging" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib.Network" Version="1.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,208 +0,0 @@
|
||||
global using DTLib;
|
||||
global using DTLib.Dtsod;
|
||||
global using DTLib.Filesystem;
|
||||
global using DTLib.Network;
|
||||
global using DTLib.Extensions;
|
||||
global using System;
|
||||
global using System.Net;
|
||||
global using System.Net.Sockets;
|
||||
global using System.Text;
|
||||
global using System.Threading;
|
||||
global using System.Linq;
|
||||
using DTLib.Logging;
|
||||
|
||||
namespace Launcher.Server;
|
||||
|
||||
static class Server
|
||||
{
|
||||
static readonly Socket mainSocket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
static DtsodV23 config;
|
||||
private static readonly CompositeLogger Logger = new(
|
||||
new ConsoleLogger(),
|
||||
new FileLogger("logs", "launcher-server"));
|
||||
|
||||
static readonly object manifestLocker = new();
|
||||
|
||||
static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.Title = "Launcher.Server";
|
||||
Console.InputEncoding = Encoding.Unicode;
|
||||
Console.OutputEncoding = Encoding.Unicode;
|
||||
DTLibInternalLogging.SetLogger(Logger);
|
||||
config = new DtsodV23(File.ReadAllText("launcher-server.dtsod"));
|
||||
Logger.LogInfo("Main", $"""
|
||||
local address: {config["local_ip"]}
|
||||
public address: {OldNetwork.GetPublicIP()}
|
||||
port: {config["local_port"]}
|
||||
""");
|
||||
mainSocket.Bind(new IPEndPoint(IPAddress.Parse(config["local_ip"]), config["local_port"]));
|
||||
mainSocket.Listen(1000);
|
||||
CreateManifests();
|
||||
Logger.LogInfo("Main", "server started succesfully");
|
||||
// запуск отдельного потока для каждого юзера
|
||||
Logger.LogInfo("Main", "waiting for users");
|
||||
while (true)
|
||||
{
|
||||
var userSocket = mainSocket.Accept();
|
||||
var userThread = new Thread((obj) => HandleUser((Socket)obj));
|
||||
userThread.Start(userSocket);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError("Main", ex);
|
||||
if (mainSocket.Connected)
|
||||
{
|
||||
mainSocket.Shutdown(SocketShutdown.Both);
|
||||
mainSocket.Close();
|
||||
}
|
||||
}
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
// запускается для каждого юзера в отдельном потоке
|
||||
static void HandleUser(Socket handlerSocket)
|
||||
{
|
||||
Logger.LogInfo("HandleUser", "user connecting...");
|
||||
try
|
||||
{
|
||||
// запрос хеша пароля и логина
|
||||
handlerSocket.SendPackage("requesting hash".ToBytes());
|
||||
var hasher = new Hasher();
|
||||
var hash = hasher.HashCycled(handlerSocket.GetPackage(), 64);
|
||||
FSP fsp = new(handlerSocket);
|
||||
// запрос от апдейтера
|
||||
if (hash == hasher.HashCycled("updater".ToBytes(),64))
|
||||
{
|
||||
Logger.LogInfo("HandleUser", "user is updater");
|
||||
handlerSocket.SendPackage("updater".ToBytes());
|
||||
// обработка запросов
|
||||
while (true)
|
||||
{
|
||||
if (handlerSocket.Available >= 2)
|
||||
{
|
||||
var request = handlerSocket.GetPackage().ToString();
|
||||
switch (request)
|
||||
{
|
||||
case "requesting launcher update":
|
||||
Logger.LogInfo("HandleUser", "updater requested client.exe");
|
||||
fsp.UploadFile("share\\launcher.exe");
|
||||
break;
|
||||
case "register new user":
|
||||
Logger.LogInfo("HandleUser", "new user registration requested");
|
||||
handlerSocket.SendPackage("ready".ToBytes());
|
||||
string req = StringConverter.MergeToString(
|
||||
hasher.HashCycled(handlerSocket.GetPackage(), 64).HashToString(),
|
||||
":\n{\n\tusername: \"", handlerSocket.GetPackage().ToString(),
|
||||
"\";\n\tuuid: \"null\";\n};");
|
||||
var filepath = Path.Concat("registration_requests", DateTime.Now.ToString(MyTimeFormat.ForFileNames), ".req");
|
||||
File.WriteAllText(filepath, req);
|
||||
Logger.LogInfo("HandleUser", $"text wrote to file <{filepath}>");
|
||||
break;
|
||||
default:
|
||||
throw new Exception("unknown request: " + request);
|
||||
}
|
||||
}
|
||||
else Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
// запрос от юзера
|
||||
else if (FindUser(hash, out var user))
|
||||
{
|
||||
Logger.LogInfo("HandleUser", "user is " + user.name);
|
||||
handlerSocket.SendPackage("launcher".ToBytes());
|
||||
// обработка запросов
|
||||
while (true)
|
||||
{
|
||||
if (handlerSocket.Available >= 2)
|
||||
{
|
||||
var request = handlerSocket.GetPackage().ToString();
|
||||
switch (request)
|
||||
{
|
||||
case "requesting file download":
|
||||
var requestedFile = Path.Concat("share",handlerSocket.GetPackage().ToString());
|
||||
Logger.LogInfo("HandleUser", $"user {user.name} requested file {requestedFile}");
|
||||
if (requestedFile == "share/manifest.dtsod")
|
||||
lock (manifestLocker)
|
||||
fsp.UploadFile(requestedFile.ToString());
|
||||
else fsp.UploadFile(requestedFile.ToString());
|
||||
break;
|
||||
case "requesting uuid":
|
||||
Logger.LogInfo("HandleUser", "user " + user.name + " requested uuid");
|
||||
handlerSocket.SendPackage(user.uuid.ToBytes());
|
||||
break;
|
||||
case "excess files found":
|
||||
Logger.LogInfo("HandleUser", "user " + user.name + " sent excess files list");
|
||||
fsp.DownloadFile(Path.Concat(
|
||||
"excesses",user.name, DateTime.Now.ToString(MyTimeFormat.ForFileNames),".txt")
|
||||
.ToString());
|
||||
break;
|
||||
case "sending launcher error":
|
||||
string error = handlerSocket.GetPackage().ToString();
|
||||
Logger.LogWarn("HandleUser", "user "+ user.name + "is sending error:\n"+error);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("unknown request: " + request);
|
||||
}
|
||||
}
|
||||
else Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
// неизвестный юзер
|
||||
else
|
||||
{
|
||||
Logger.LogWarn("HandleUser", $"user with hash {hash.HashToString()} not found");
|
||||
handlerSocket.SendPackage("user not found".ToBytes());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarn("HandleUser", ex);
|
||||
if (mainSocket.Connected)
|
||||
{
|
||||
mainSocket.Shutdown(SocketShutdown.Both);
|
||||
mainSocket.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (handlerSocket.Connected)
|
||||
handlerSocket.Shutdown(SocketShutdown.Both);
|
||||
handlerSocket.Close();
|
||||
Logger.LogInfo("HandleUser", "user disconnected");
|
||||
}
|
||||
}
|
||||
|
||||
static void CreateManifests()
|
||||
{
|
||||
lock (manifestLocker)
|
||||
{
|
||||
Directory.Create("share\\download_if_not_exist");
|
||||
Directory.Create("share\\sync_always");
|
||||
Directory.Create("share\\sync_and_remove");
|
||||
|
||||
FSP.CreateManifest("share\\download_if_not_exist");
|
||||
FSP.CreateManifest("share\\sync_always");
|
||||
foreach (string dir in Directory.GetDirectories("share\\sync_and_remove"))
|
||||
FSP.CreateManifest(dir);
|
||||
File.WriteAllText("share\\sync_and_remove\\dirlist.dtsod",
|
||||
"dirs: [\""+
|
||||
Directory.GetDirectories("share\\sync_and_remove")
|
||||
.MergeToString("\",\"")
|
||||
.Replace("share\\sync_and_remove\\", "")+
|
||||
"\"];");
|
||||
}
|
||||
}
|
||||
|
||||
static bool FindUser(byte[] hash, out (string name, string uuid) user)
|
||||
{
|
||||
DtsodV23 usersdb = new(File.ReadAllText("users.dtsod"));
|
||||
user = new ValueTuple<string, string>();
|
||||
if (!usersdb.ContainsKey(hash.HashToString())) return false;
|
||||
user.name = usersdb[hash.HashToString()]["username"];
|
||||
user.uuid = usersdb[hash.HashToString()]["uuid"];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,2 +0,0 @@
|
||||
local_ip: "10.1.10.44";
|
||||
local_port: 25000;
|
||||
@ -1,7 +0,0 @@
|
||||
# dtlauncher
|
||||
|
||||
launcher for my... idk.. something
|
||||
|
||||
\
|
||||
requires DTLib\
|
||||
https://github.com/Timerix22/DTLib
|
||||
6
dtlauncher-client-win/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
</configuration>
|
||||
165
dtlauncher-client-win/App.xaml
Normal file
@ -0,0 +1,165 @@
|
||||
<Application x:Class="dtlauncher_client_win.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:dtlauncher_client_win">
|
||||
<Application.Resources>
|
||||
<ControlTemplate x:Key="myScrollBar" TargetType="{x:Type ScrollBar}">
|
||||
<Grid x:Name="Bg" SnapsToDevicePixels="True">
|
||||
<Border BorderBrush="Transparent" BorderThickness="0"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}" Grid.Row="1"/>
|
||||
<Track x:Name="PART_Track" IsDirectionReversed="True" IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="1">
|
||||
<Track.Thumb>
|
||||
<Thumb>
|
||||
<Thumb.Style>
|
||||
<Style TargetType="{x:Type Thumb}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True"/>
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Thumb}">
|
||||
<Border x:Name="rectangle" CornerRadius="2" Background="#FF9A9FC5" Height="{TemplateBinding Height}" SnapsToDevicePixels="True" Width="{TemplateBinding Width}"/>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" TargetName="rectangle" Value="#FF9A9FC5"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsDragging" Value="True">
|
||||
<Setter Property="Background" TargetName="rectangle" Value="#FF515ED1"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Thumb.Style>
|
||||
</Thumb>
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="myScrollViewer" TargetType="{x:Type ScrollViewer}">
|
||||
<Grid x:Name="Grid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Rectangle x:Name="Corner" Grid.Column="1" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Grid.Row="1"/>
|
||||
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
|
||||
<ScrollBar Template="{DynamicResource myScrollBar}" Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}" x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
|
||||
<ScrollBar Template="{DynamicResource myScrollBar}" Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}" x:Name="PART_HorizontalScrollBar" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="myTabControl" TargetType="{x:Type TabControl}">
|
||||
<Grid KeyboardNavigation.TabNavigation="Local">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TabPanel
|
||||
Name="HeaderPanel"
|
||||
Grid.Row="0"
|
||||
Panel.ZIndex="1"
|
||||
Margin="0,0,4,0"
|
||||
IsItemsHost="True"
|
||||
KeyboardNavigation.TabIndex="1"
|
||||
Background="Transparent" />
|
||||
<Border
|
||||
Name="Border"
|
||||
Grid.Row="1"
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="0"
|
||||
CornerRadius="2"
|
||||
KeyboardNavigation.TabNavigation="Local"
|
||||
KeyboardNavigation.DirectionalNavigation="Contained"
|
||||
KeyboardNavigation.TabIndex="2" >
|
||||
<ContentPresenter
|
||||
Name="PART_SelectedContentHost"
|
||||
Margin="4"
|
||||
ContentSource="SelectedContent"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="#FFF0F0F0" />
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="Transparent" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="myTabItem" TargetType="{x:Type TabItem}">
|
||||
<Grid>
|
||||
<Border
|
||||
x:Name="Border"
|
||||
Margin="0,0,-4,0"
|
||||
Background="#FF4D4D4D"
|
||||
BorderBrush="#FF73C300"
|
||||
BorderThickness="2,2,2,2"
|
||||
CornerRadius="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}" >
|
||||
<ContentPresenter x:Name="ContentSite"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
ContentSource="Header"
|
||||
Margin="12,2,12,2"
|
||||
RecognizesAccessKey="True"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Panel.ZIndex" Value="100" />
|
||||
<Setter TargetName="Border" Property="Background" Value="#FF0A11A2" />
|
||||
<Setter TargetName="Border" Property="BorderThickness" Value="3,3,3,3" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="Border" Property="Background" Value="Transparent" />
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="white" />
|
||||
</Trigger>
|
||||
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="myTextBox" TargetType="{x:Type TextBoxBase}">
|
||||
<Border
|
||||
Name="Border"
|
||||
Padding="2"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="1" >
|
||||
<ScrollViewer Margin="0" x:Name="PART_ContentHost" Template="{DynamicResource myScrollViewer}"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="Border" Property="Background" Value="Black"/>
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="White"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="roundedButton" TargetType="Button">
|
||||
<Border x:Name="Border"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderBrush="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
CornerRadius="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<ContentPresenter Margin="2" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" RecognizesAccessKey="True"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="#FF4E4E59"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="#FF38384F"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
34
dtlauncher-client-win/App.xaml.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using DTLib.Filesystem;
|
||||
|
||||
namespace dtlauncher_client_win
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
try
|
||||
{
|
||||
if (e.Args.Length > 0 && e.Args[0] == "updated")
|
||||
{
|
||||
LoginWindow window = new();
|
||||
window.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!File.Exists("updater.exe")) throw new Exception("file <updater.exe> not found");
|
||||
Process.Start("cmd", "/c timeout 1 && start updater.exe");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{ MessageBox.Show($"STARTUP ERROR:\n{ex.Message}\n{ex.StackTrace}"); }
|
||||
//Current.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
98
dtlauncher-client-win/LauncherWindow.xaml
Normal file
@ -0,0 +1,98 @@
|
||||
<Window x:Class="dtlauncher_client_win.LauncherWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:dtlauncher_client_win"
|
||||
mc:Ignorable="d"
|
||||
Title="DTLauncher" Width="800" Height="500" MinWidth="800" MinHeight="500" Background="#FF232328">
|
||||
<Grid x:Name="MainGrid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="10"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="10"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="8"/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="10"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Rectangle Fill="#FF474747" Grid.Row="2" Grid.ColumnSpan="3" Margin="0,5,0,0"/>
|
||||
<Grid Grid.Column="1" Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="8"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="8"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="HomeButton" Content="Home" FontWeight="Bold" FontFamily="Unispace" FontSize="20"
|
||||
Grid.Column="0" Background="Transparent" Foreground="#FF2CDA11"
|
||||
BorderThickness="3" Template="{DynamicResource roundedButton}"/>
|
||||
<Button x:Name="LogButton" Content="Log" FontWeight="Bold" FontFamily="Unispace" FontSize="20"
|
||||
Grid.Column="2" Background="Transparent" Foreground="#FFF0F0F0"
|
||||
BorderThickness="3" Template="{DynamicResource roundedButton}"/>
|
||||
<Button x:Name="SettingsButton" Content="Settings" FontWeight="Bold" FontFamily="Unispace" FontSize="20"
|
||||
Grid.Column="4" Background="Transparent" Foreground="#FFF0F0F0"
|
||||
BorderThickness="3" Template="{DynamicResource roundedButton}"/>
|
||||
|
||||
</Grid>
|
||||
<Grid x:Name="HomeGrid" Visibility="Visible" Grid.Row="3" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="240"/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Fill="#FF474747" Grid.Column="1" Margin="3,0,3,-10"/>
|
||||
<Rectangle Fill="#FF474747" Grid.Column="3" Margin="3,0,3,-10"/>
|
||||
<ScrollViewer x:Name="ProgramsScrollViever" Template="{DynamicResource myScrollViewer}"
|
||||
Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<StackPanel x:Name="ProgramsPanel">
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<Image x:Name="BackgroundImage" Grid.Column="2" HorizontalAlignment="Stretch" Stretch="Fill" Margin="0,40,0,0" />
|
||||
<Label x:Name="NameLabel" Grid.Column="2" Grid.Row="0" Margin="0,0,0,361"
|
||||
FontSize="16" FontWeight="Bold" FontFamily="Unispace" Foreground="#FFF0F0F0"/>
|
||||
<Button x:Name="InstallButton" Content="Install" FontWeight="Bold" FontFamily="Unispace" FontSize="17"
|
||||
Grid.Column="2" Background="#FFB97523" Foreground="#FFF0F0F0"
|
||||
BorderThickness="3" Template="{DynamicResource roundedButton}" Margin="0,72,167,0"
|
||||
HorizontalAlignment="Right" Width="123" Height="37" VerticalAlignment="Top"/>
|
||||
<Button x:Name="LaunchButton" Content="Launch" FontWeight="Bold" FontFamily="Unispace" FontSize="17"
|
||||
Grid.Column="2" Background="#FFB97523" Foreground="#FFF0F0F0"
|
||||
BorderThickness="3" Template="{DynamicResource roundedButton}" Margin="0,72,20,0"
|
||||
HorizontalAlignment="Right" Width="123" Height="37" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="DescriptionBox" Template="{DynamicResource myTextBox}" Opacity="0.8"
|
||||
VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" BorderThickness="0"
|
||||
Background="#FF141419" Foreground="#FFF0F0F0" SelectionBrush="#FF3E759E"
|
||||
FontSize="14" IsReadOnly="True" Grid.Column="2" Grid.Row="0" Margin="0,160,0,0"/>
|
||||
<Border BorderBrush="#FF141419" BorderThickness="1" Grid.Column="2" Grid.Row="0" Margin="0,160,0,0"/>
|
||||
<ScrollViewer x:Name="DownloadsScrollViever" Template="{DynamicResource myScrollViewer}" VerticalContentAlignment="Top"
|
||||
Grid.Column="4" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<StackPanel x:Name="DownloadsPanel">
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
</Grid>
|
||||
<Grid x:Name="LogGrid" Visibility="Hidden" Grid.Row="3" Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="34"/>
|
||||
<RowDefinition Height="10*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label x:Name="LogfileLabel" Content="logfile" Grid.Column="0" Grid.Row="0"
|
||||
FontSize="20" FontWeight="Bold" FontFamily="Unispace" Foreground="#FFF0F0F0"/>
|
||||
<TextBox x:Name="LogBox" Template="{DynamicResource myTextBox}"
|
||||
VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" BorderThickness="0"
|
||||
Background="#FF141419" Foreground="#FFF0F0F0" SelectionBrush="#FF3E759E"
|
||||
FontSize="14" IsReadOnly="True" Grid.Column="0" Grid.Row="1"/>
|
||||
</Grid>
|
||||
<Grid x:Name="SettingsGrid" Visibility="Hidden" Grid.Row="3" Grid.Column="1">
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
118
dtlauncher-client-win/LauncherWindow.xaml.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using DTLib;
|
||||
using DTLib.Filesystem;
|
||||
|
||||
namespace dtlauncher_client_win
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для LauncherWindow.xaml
|
||||
/// </summary>
|
||||
public partial class LauncherWindow : Window
|
||||
{
|
||||
public Socket mainSocket;
|
||||
string logfile;
|
||||
public delegate void LaunchDel();
|
||||
public LaunchDel Launch = () => { };
|
||||
public delegate void InstallDel();
|
||||
public LaunchDel Install = () => { };
|
||||
public ProgramLabel[] programsArray;
|
||||
public int PreviousProgramNum = 0;
|
||||
|
||||
public LauncherWindow(Socket _socket, string _logfile, string _log)
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
mainSocket = _socket;
|
||||
logfile = _logfile;
|
||||
LogBox.Text += _log;
|
||||
PublicLog.LogEvent += Log;
|
||||
PublicLog.LogNoTimeEvent += Log;
|
||||
Closed += AppClose;
|
||||
// переключение вкладок кнопками
|
||||
var green = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(44, 220, 17));
|
||||
var white = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(240, 240, 240));
|
||||
HomeButton.Click += (s, e) =>
|
||||
{
|
||||
LogGrid.Visibility = Visibility.Hidden;
|
||||
SettingsGrid.Visibility = Visibility.Hidden;
|
||||
HomeGrid.Visibility = Visibility.Visible;
|
||||
LogButton.Foreground = white;
|
||||
SettingsButton.Foreground = white;
|
||||
HomeButton.Foreground = green;
|
||||
};
|
||||
LogButton.Click += (s, e) =>
|
||||
{
|
||||
HomeGrid.Visibility = Visibility.Hidden;
|
||||
SettingsGrid.Visibility = Visibility.Hidden;
|
||||
LogGrid.Visibility = Visibility.Visible;
|
||||
HomeButton.Foreground = white;
|
||||
SettingsButton.Foreground = white;
|
||||
LogButton.Foreground = green;
|
||||
};
|
||||
SettingsButton.Click += (s, e) =>
|
||||
{
|
||||
HomeGrid.Visibility = Visibility.Hidden;
|
||||
LogGrid.Visibility = Visibility.Hidden;
|
||||
SettingsGrid.Visibility = Visibility.Visible;
|
||||
HomeButton.Foreground = white;
|
||||
LogButton.Foreground = white;
|
||||
SettingsButton.Foreground = green;
|
||||
};
|
||||
// считывание дескрипторов программ
|
||||
string[] descriptors = Directory.GetFiles("descriptors", "*.desc");
|
||||
programsArray = new ProgramLabel[descriptors.Length];
|
||||
Log(descriptors.Length + " descriptors found\n");
|
||||
for (int i = 0; i < descriptors.Length; i++)
|
||||
{
|
||||
programsArray[i] = new ProgramLabel(descriptors[i], i, this);
|
||||
ProgramsPanel.Children.Add(programsArray[i]);
|
||||
Log(programsArray[i].Text + " added to ProgramsPanel\n");
|
||||
}
|
||||
LaunchButton.Click += (s, e) => Launch();
|
||||
InstallButton.Click += (s, e) => Install();
|
||||
//mainSocket.FSP_Download(new FSP_FileObject("share\\file.arc", "downloads\\file.arc"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string mes = $"LauncherWindow() error:\n{ex.Message}\n{ex.StackTrace}\n";
|
||||
MessageBox.Show(mes);
|
||||
Log(mes);
|
||||
}
|
||||
}
|
||||
|
||||
public void Log(string msg)
|
||||
{
|
||||
if (LogBox.Text[LogBox.Text.Length - 1] == '\n') msg = "[" + DateTime.Now.ToString() + "]: " + msg;
|
||||
File.AppendAllText(logfile, msg);
|
||||
LogBox.Text += msg;
|
||||
}
|
||||
|
||||
public void Log(params string[] input)
|
||||
{
|
||||
if (input.Length == 1) Log(input[0]);
|
||||
if (input.Length % 2 == 0)
|
||||
{
|
||||
StringBuilder strB = new();
|
||||
for (ushort i = 0; i < input.Length; i++)
|
||||
strB.Append(input[++i]);
|
||||
Log(strB.ToString());
|
||||
}
|
||||
else throw new Exception("error in Log(): every text string must have color string before");
|
||||
}
|
||||
|
||||
void AppClose(object sender, EventArgs e)
|
||||
{
|
||||
if (mainSocket.Connected)
|
||||
{
|
||||
mainSocket.Shutdown(SocketShutdown.Both);
|
||||
mainSocket.Close();
|
||||
}
|
||||
Log("dtlauncher closing\n");
|
||||
App.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
51
dtlauncher-client-win/LoginWindow.xaml
Normal file
@ -0,0 +1,51 @@
|
||||
<Window x:Class="dtlauncher_client_win.LoginWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:dtlauncher_client_win"
|
||||
mc:Ignorable="d"
|
||||
Title="DTLauncher login window" Width="500" Height="350" Background="#FF232328" MinWidth="500" MinHeight="350">
|
||||
<Grid ScrollViewer.VerticalScrollBarVisibility="Disabled" Margin="0" MinWidth="492" MinHeight="320">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="20*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25*"/>
|
||||
<RowDefinition Height="174*"/>
|
||||
<RowDefinition Height="23*"/>
|
||||
<RowDefinition Height="72*"/>
|
||||
<RowDefinition Height="25*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Canvas Height="200" Margin="20,14,20,8" Width="450" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="3" Grid.RowSpan="3">
|
||||
<TextBox x:Name="LoginBox" HorizontalAlignment="Center" Height="30" TextWrapping="Wrap" Text="" VerticalAlignment="Center"
|
||||
Width="300" RenderTransformOrigin="0.534,-0.193" Background="#FF4B4B5A" Foreground="#FFF0F0F0" SelectionBrush="#FF2E628B"
|
||||
FontSize="17" BorderThickness="2" IsUndoEnabled="False" MaxLength="25" MaxLines="1" BorderBrush="#FFF0F0F0" MinWidth="300"
|
||||
MinHeight="29" Canvas.Left="130" Canvas.Top="21"/>
|
||||
<PasswordBox x:Name="PasswBox" HorizontalAlignment="Center" VerticalAlignment="Center" Width="300" Height="30" FontSize="17"
|
||||
Background="#FF4B4B5A" Foreground="#FFF0F0F0" SelectionBrush="#FF2E628B" MaxLength="25" BorderThickness="2"
|
||||
BorderBrush="#FFF0F0F0" MinWidth="300" MinHeight="30" Canvas.Left="130" Canvas.Top="83"/>
|
||||
<Label Content="login:" HorizontalAlignment="Center" VerticalAlignment="Center" Height="40" Width="90" Foreground="#FFF0F0F0"
|
||||
FontSize="20" FontWeight="Bold" RenderTransformOrigin="0.764,0.578" FontFamily="Unispace" MinWidth="74" MinHeight="40"
|
||||
VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Canvas.Left="34" Canvas.Top="17"/>
|
||||
<Label Content="password:" HorizontalAlignment="Center" VerticalAlignment="Center" Height="40" Width="119" Foreground="#FFF0F0F0"
|
||||
FontSize="20" FontWeight="Bold" FontFamily="Unispace" MinHeight="40" MinWidth="111" VerticalContentAlignment="Center"
|
||||
HorizontalContentAlignment="Center" Canvas.Left="1" Canvas.Top="77"/>
|
||||
<Button x:Name="RegisterButton" Content="register" Width="117" Height="40" FontSize="20"
|
||||
FontWeight="Bold" Foreground="#FFF0F0F0" Background="#FF383844"
|
||||
FontFamily="Unispace" BorderThickness="3" MinHeight="40" MinWidth="117" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" Canvas.Left="71" Canvas.Top="138" Template="{DynamicResource roundedButton}"/>
|
||||
<Button x:Name="LoginButton" Content="login" Width="117" Height="40" FontSize="20" FontWeight="Bold"
|
||||
Foreground="#FFF0F0F0" Background="#FFB97523" FontFamily="Unispace"
|
||||
BorderThickness="3" MinHeight="40" MinWidth="117" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Canvas.Left="272" Canvas.Top="138" Template="{DynamicResource roundedButton}"/>
|
||||
</Canvas>
|
||||
<TextBox x:Name="LogBox" Template="{DynamicResource myTextBox}"
|
||||
VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" BorderThickness="0"
|
||||
Background="Transparent" Foreground="#FFF0F0F0" SelectionBrush="#FF3E759E"
|
||||
FontSize="14" IsReadOnly="True" Grid.Column="1" Grid.Row="3"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
158
dtlauncher-client-win/LoginWindow.xaml.cs
Normal file
@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using DTLib;
|
||||
using DTLib.Dtsod;
|
||||
using DTLib.Filesystem;
|
||||
using DTLib.Network;
|
||||
using DTLib.Extensions;
|
||||
|
||||
namespace dtlauncher_client_win
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для LoginWindow.xaml
|
||||
/// </summary>
|
||||
public partial class LoginWindow : Window
|
||||
{
|
||||
public Socket mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
public string logfile = $"logs\\client-{DateTime.Now}.log".Replace(':', '-').Replace(' ', '_');
|
||||
DtsodV21 config;
|
||||
|
||||
public LoginWindow()
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
LogBox.Text = " \n"; // костыль для работы Log()
|
||||
Directory.Create("logs");
|
||||
Directory.Create("downloads");
|
||||
Directory.Create("installed");
|
||||
Directory.Create("installscripts");
|
||||
Directory.Create("launchinfo");
|
||||
PublicLog.LogEvent += Log;
|
||||
PublicLog.LogNoTimeEvent += Log;
|
||||
LoginButton.Click += Login;
|
||||
RegisterButton.Click += Register;
|
||||
Log("[" + DateTime.Now.ToString() + "]: launcher is starting\n");
|
||||
config = new(File.ReadAllText("client.dtsod"));
|
||||
Closed += AppClose;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log("error:\n" + e.Message + "\n" + e.StackTrace + '\n');
|
||||
}
|
||||
}
|
||||
|
||||
void Register(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var hasher = new Hasher();
|
||||
string filename = $"register-{LoginBox.Text}.req";
|
||||
string content = hasher.HashCycled(hasher.Hash(LoginBox.Text.ToBytes(), PasswBox.Password.ToBytes()), 512).HashToString() + ": " + LoginBox.Text;
|
||||
//File.WriteAllText(filename, hasher.HashCycled(hasher.Hash(LoginBox.Text.ToBytes(), PasswBox.Password.ToBytes()), 512).HashToString() + ": " + LoginBox.Text);
|
||||
//Log($"request file created:{Directory.GetCurrentDirectory()}\\register-{LoginBox.Text}.req {hasher.Hash(LoginBox.Text.ToBytes(), PasswBox.Password.ToBytes()).Length}");
|
||||
if (mainSocket.Connected)
|
||||
{
|
||||
mainSocket.Shutdown(SocketShutdown.Both);
|
||||
mainSocket.Close();
|
||||
mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
}
|
||||
Log($"server address: <{config["server_domain"]}>\nserver port: <{config["server_port"]}>\n");
|
||||
mainSocket.Connect(new IPEndPoint(Dns.GetHostAddresses(config["server_domain"])[0], (int)config["server_port"]));
|
||||
Log("g", "connecting to server...\n");
|
||||
mainSocket.ReceiveTimeout = 2000;
|
||||
string recieved = mainSocket.GetPackage().BytesToString();
|
||||
if (recieved != "requesting hash") throw new Exception($"Login() error: invalid request <{recieved}> <{recieved.Length}>");
|
||||
mainSocket.SendPackage(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 });
|
||||
recieved = mainSocket.GetPackage().BytesToString();
|
||||
if (recieved != "updater") throw new Exception($"invalid central server answer <{recieved}>");
|
||||
mainSocket.SendPackage("register new user".ToBytes());
|
||||
recieved = mainSocket.GetPackage().BytesToString();
|
||||
if (recieved != "ok") throw new Exception($"invalid central server answer <{recieved}>");
|
||||
mainSocket.SendPackage(content.ToBytes());
|
||||
Log("g", "registration request sent\n");
|
||||
//mainSocket.SendPackage(filename.ToBytes());
|
||||
//mainSocket.FSP_Upload(filename);
|
||||
//mainSocket.Shutdown(SocketShutdown.Both);
|
||||
//mainSocket.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string mes = $"LoginWindow.Register() error:\n{ex.Message}\n{ex.StackTrace}\n";
|
||||
MessageBox.Show(mes);
|
||||
Log(mes);
|
||||
}
|
||||
}
|
||||
|
||||
void Login(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (mainSocket.Connected)
|
||||
{
|
||||
mainSocket.Shutdown(SocketShutdown.Both);
|
||||
mainSocket.Close();
|
||||
mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
}
|
||||
Log($"server address: <{config["server_domain"]}>\nserver port: <{config["server_port"]}>\n");
|
||||
mainSocket.Connect(new IPEndPoint(Dns.GetHostAddresses(config["server_domain"])[0], (int)config["server_port"]));
|
||||
Log("g", "connecting to server...\n");
|
||||
mainSocket.ReceiveTimeout = 2000;
|
||||
string recieved = mainSocket.GetPackage().BytesToString();
|
||||
if (recieved != "requesting hash") throw new Exception($"Login() error: invalid request <{recieved}> <{recieved.Length}>");
|
||||
var hasher = new Hasher();
|
||||
mainSocket.SendPackage(hasher.HashCycled(hasher.Hash(LoginBox.Text.ToBytes(), PasswBox.Password.ToBytes()), 512));
|
||||
recieved = mainSocket.GetPackage().BytesToString();
|
||||
if (recieved != "success") throw new Exception($"Login() error: invalid server answer <{recieved}>");
|
||||
Log("succesfully connected\n");
|
||||
// вызов нового окна
|
||||
PublicLog.LogEvent -= Log;
|
||||
PublicLog.LogNoTimeEvent -= Log;
|
||||
var lauWin = new LauncherWindow(mainSocket, logfile, LogBox.Text);
|
||||
lauWin.Show();
|
||||
Closed -= AppClose;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string mes = $"LoginWindow.Login() error:\n{ex.Message}\n{ex.StackTrace}\n";
|
||||
MessageBox.Show(mes);
|
||||
Log(mes);
|
||||
}
|
||||
}
|
||||
|
||||
public void Log(string msg)
|
||||
{
|
||||
if (LogBox.Text[LogBox.Text.Length - 1] == '\n') msg = "[" + DateTime.Now.ToString() + "]: " + msg;
|
||||
File.AppendAllText(logfile, msg);
|
||||
LogBox.Text += msg;
|
||||
}
|
||||
|
||||
public void Log(params string[] input)
|
||||
{
|
||||
if (input.Length == 1) Log(input[0]);
|
||||
if (input.Length % 2 == 0)
|
||||
{
|
||||
StringBuilder strB = new();
|
||||
for (ushort i = 0; i < input.Length; i++)
|
||||
strB.Append(input[++i]);
|
||||
Log(strB.ToString());
|
||||
}
|
||||
else throw new Exception("error in Log(): every text string must have color string before");
|
||||
}
|
||||
|
||||
void AppClose(object sender, EventArgs e)
|
||||
{
|
||||
if (mainSocket.Connected)
|
||||
{
|
||||
mainSocket.Shutdown(SocketShutdown.Both);
|
||||
mainSocket.Close();
|
||||
}
|
||||
Log("dtlauncher closing\n");
|
||||
App.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
33
dtlauncher-client-win/ProgramLabel.xaml
Normal file
@ -0,0 +1,33 @@
|
||||
<UserControl x:Class="dtlauncher_client_win.ProgramLabel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:dtlauncher_client_win"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="25" d:DesignWidth="140" BorderThickness="0">
|
||||
<UserControl.Template>
|
||||
<ControlTemplate TargetType="UserControl">
|
||||
<ContentPresenter />
|
||||
</ControlTemplate>
|
||||
</UserControl.Template>
|
||||
<Grid x:Name="grid" Background="#FF232328" MouseLeftButtonDown="ProgramShow">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="25"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border x:Name="Border" Grid.ColumnSpan="2"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProgramLabel}}}"
|
||||
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProgramLabel}}}"
|
||||
BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProgramLabel}}}"
|
||||
CornerRadius="{Binding CornerRadius, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProgramLabel}}}"/>
|
||||
<Image x:Name="IconImage" Grid.Column="0" Stretch="Fill" Margin="3,2,2,3" Width="20" Height="20"
|
||||
Source="{Binding Icon, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProgramLabel}}}"/>
|
||||
<Label Name="NameLabel" Grid.Column="1" VerticalContentAlignment="Center"
|
||||
Content="{Binding Text, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProgramLabel}}}"
|
||||
FontSize="{Binding FontSize, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProgramLabel}}}"
|
||||
FontFamily="{Binding FontFamily,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProgramLabel}}}"
|
||||
FontWeight="{Binding FontWeight, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProgramLabel}}}"
|
||||
Foreground="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProgramLabel}}}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
125
dtlauncher-client-win/ProgramLabel.xaml.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Imaging;
|
||||
using DTLib.Dtsod;
|
||||
|
||||
namespace dtlauncher_client_win
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для ProgramLabel.xaml
|
||||
/// </summary>
|
||||
public partial class ProgramLabel : UserControl
|
||||
{
|
||||
public static DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(ProgramLabel));
|
||||
public string Text
|
||||
{
|
||||
get => (string)GetValue(TextProperty);
|
||||
set => SetValue(TextProperty, value);
|
||||
}
|
||||
|
||||
public static DependencyProperty IconProperty = DependencyProperty.Register("Icon", typeof(BitmapImage), typeof(ProgramLabel));
|
||||
public BitmapImage Icon
|
||||
{
|
||||
get => (BitmapImage)GetValue(IconProperty);
|
||||
set => SetValue(IconProperty, value);
|
||||
}
|
||||
|
||||
public static DependencyProperty CornerRadiusProperty = DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ProgramLabel));
|
||||
public CornerRadius CornerRadius
|
||||
{
|
||||
get => (CornerRadius)GetValue(CornerRadiusProperty);
|
||||
set => SetValue(CornerRadiusProperty, value);
|
||||
}
|
||||
|
||||
public int Number;
|
||||
LauncherWindow Window;
|
||||
//public string background;
|
||||
//public string description;
|
||||
//public string installScript;
|
||||
//public string installDir;
|
||||
DtsodV21 descriptor;
|
||||
DtsodV21 launchinfo;
|
||||
|
||||
public ProgramLabel() => InitializeComponent();
|
||||
|
||||
public ProgramLabel(string descriptorFile, int number, LauncherWindow window)
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
Window = window;
|
||||
Number = number;
|
||||
descriptor = new(File.ReadAllText(descriptorFile));
|
||||
launchinfo = new(File.ReadAllText("launchinfo\\" + descriptor["id"]));
|
||||
FontSize = 14;
|
||||
Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(240, 240, 240));
|
||||
Text = descriptor["name"];
|
||||
NameLabel.Content = descriptor["name"];
|
||||
IconImage.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory() + "\\icons\\" + descriptor["id"], UriKind.Absolute));
|
||||
//background = Directory.GetCurrentDirectory() + "\\descriptors\\" + descriptor["background"];
|
||||
//installScript = descriptor["script"];
|
||||
//installDir = descriptor["installdir"];
|
||||
//launchInfo = descriptor["LaunchInfo"];
|
||||
//description = descriptor["description"].Replace("\\n", "\n");
|
||||
//Window.Log(Text + " " + Icon + " " + Number);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string mes = $"ProgramLabel() error:\n{ex.Message}\n{ex.StackTrace}\n";
|
||||
MessageBox.Show(mes);
|
||||
Window.Log(mes);
|
||||
}
|
||||
}
|
||||
|
||||
void ProgramShow(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Window.programsArray[Window.PreviousProgramNum].Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(240, 240, 240));
|
||||
Window.programsArray[Window.PreviousProgramNum].FontWeight = FontWeights.Normal;
|
||||
Window.programsArray[Window.PreviousProgramNum].FontSize = 14;
|
||||
Window.PreviousProgramNum = Number;
|
||||
Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(170, 170, 240));
|
||||
FontWeight = FontWeights.Bold;
|
||||
FontSize = 13;
|
||||
Window.NameLabel.Content = Text;
|
||||
Window.DescriptionBox.Text = descriptor["description"];
|
||||
Window.BackgroundImage.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory() + "\\backgrounds\\" + descriptor["id"], UriKind.Absolute));
|
||||
Window.Launch = () =>
|
||||
{
|
||||
switch (descriptor["id"])
|
||||
{
|
||||
case "anarx_1.12":
|
||||
Window.Install();
|
||||
Window.Log($"launching file <{launchinfo["launchfile"]}>\n");
|
||||
Process.Start(launchinfo["launchfile"]);
|
||||
break;
|
||||
default:
|
||||
Window.Log($"launching file <{launchinfo["launchfile"]}>\n");
|
||||
Process.Start(launchinfo["launchfile"]);
|
||||
break;
|
||||
}
|
||||
};
|
||||
Window.Install = () =>
|
||||
{
|
||||
Window.Log($"launching installation script <{descriptor["id"]}>\n");
|
||||
var scriptrunner = new DTScript.ScriptRunner
|
||||
{
|
||||
debug = false,
|
||||
mainSocket = Window.mainSocket
|
||||
};
|
||||
scriptrunner.RunScriptFile("installscripts\\" + descriptor["id"]);
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string mes = $"ProgramLabel.ProgramShow() error:\n{ex.Message}\n{ex.StackTrace}\n";
|
||||
MessageBox.Show(mes);
|
||||
Window.Log(mes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
53
dtlauncher-client-win/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// Общие сведения об этой сборке предоставляются следующим набором
|
||||
// набор атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
|
||||
// связанные со сборкой.
|
||||
[assembly: AssemblyTitle("dtlauncher-client-win")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("dtlauncher-client-win")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
|
||||
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
|
||||
// из модели COM, установите атрибут ComVisible для этого типа в значение true.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//Чтобы начать создание локализуемых приложений, задайте
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> в файле .csproj
|
||||
//в <PropertyGroup>. Например, при использовании английского (США)
|
||||
//в своих исходных файлах установите <UICulture> в en-US. Затем отмените преобразование в комментарий
|
||||
//атрибута NeutralResourceLanguage ниже. Обновите "en-US" в
|
||||
//строка внизу для обеспечения соответствия настройки UICulture в файле проекта.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //где расположены словари ресурсов по конкретным тематикам
|
||||
//(используется, если ресурс не найден на странице,
|
||||
// или в словарях ресурсов приложения)
|
||||
ResourceDictionaryLocation.SourceAssembly //где расположен словарь универсальных ресурсов
|
||||
//(используется, если ресурс не найден на странице,
|
||||
// в приложении или в каких-либо словарях ресурсов для конкретной темы)
|
||||
)]
|
||||
|
||||
|
||||
// Сведения о версии для сборки включают четыре следующих значения:
|
||||
//
|
||||
// Основной номер версии
|
||||
// Дополнительный номер версии
|
||||
// Номер сборки
|
||||
// Номер редакции
|
||||
//
|
||||
// Можно задать все значения или принять номера сборки и редакции по умолчанию
|
||||
// используя "*", как показано ниже:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
70
dtlauncher-client-win/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,70 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код был создан программным средством.
|
||||
// Версия среды выполнения: 4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
|
||||
// код создан повторно.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace dtlauncher_client_win.Properties
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
|
||||
/// </summary>
|
||||
// Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
|
||||
// класс с помощью таких средств, как ResGen или Visual Studio.
|
||||
// Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
|
||||
// с параметром /str или заново постройте свой VS-проект.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("dtlauncher_client_win.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Переопределяет свойство CurrentUICulture текущего потока для всех
|
||||
/// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
dtlauncher-client-win/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
29
dtlauncher-client-win/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace dtlauncher_client_win.Properties
|
||||
{
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
dtlauncher-client-win/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
2
dtlauncher-client-win/client.dtsod
Normal file
@ -0,0 +1,2 @@
|
||||
server_domain: "m1net.keenetic.pro";
|
||||
server_port: 25001;
|
||||
132
dtlauncher-client-win/dtlauncher-client-win.csproj
Normal file
@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{367793EE-4757-4ADD-BF7E-960DC9EB6DF9}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>dtlauncher_client_win</RootNamespace>
|
||||
<AssemblyName>dtlauncher-client-win</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Build|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>dtlauncher_client_win.App</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>logo-D.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="LauncherWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="LoginWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="LauncherConfig.cs" />
|
||||
<Compile Include="LauncherWindow.xaml.cs">
|
||||
<DependentUpon>LauncherWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LoginWindow.xaml.cs">
|
||||
<DependentUpon>LoginWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="ProgramLabel.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ProgramLabel.xaml.cs">
|
||||
<DependentUpon>ProgramLabel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="client.dtsod">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\DTLib\DTLib\DTLib.csproj">
|
||||
<Project>{ce793497-2d5c-42d8-b311-e9b32af9cdfb}</Project>
|
||||
<Name>DTLib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\dtscript\dtscript.csproj">
|
||||
<Project>{e02ea967-fd29-47d2-b25b-ba684b784aee}</Project>
|
||||
<Name>dtscript</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="logo-D.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>del /f /q dtlauncher-client-win.exe.config
|
||||
copy dtlauncher-client-win.exe ..\..\dtlauncher-server-win\bin\share\client\dtlauncher-client-win.exe
|
||||
copy client.dtsod ..\..\dtlauncher-server-win\bin\share\client\client.dtsod</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
6
dtlauncher-server-win/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
</configuration>
|
||||
208
dtlauncher-server-win/DtlauncherServer.cs
Normal file
@ -0,0 +1,208 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using DTLib;
|
||||
using DTLib.Dtsod;
|
||||
using DTLib.Filesystem;
|
||||
using DTLib.Network;
|
||||
using DTLib.Extensions;
|
||||
|
||||
namespace dtlauncher_server
|
||||
{
|
||||
class DtlauncherServer
|
||||
{
|
||||
static readonly string logfile = $"logs\\dtlauncher-server-{DateTime.Now}.log".Replace(':', '-').Replace(' ', '_');
|
||||
static readonly Socket mainSocket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
static DtsodV21 config;
|
||||
static DTLib.Loggers.DefaultLogger Info = new("logs", "dtlaunchet_server");
|
||||
|
||||
//static readonly Dictionary<Socket, Thread> users = new();
|
||||
|
||||
static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.Title = "dtlauncher server";
|
||||
Console.InputEncoding = Encoding.Unicode;
|
||||
Console.OutputEncoding = Encoding.Unicode;
|
||||
PublicLog.LogEvent += Info.Log;
|
||||
PublicLog.LogNoTimeEvent += Info.Log;
|
||||
/*var outBuilder = new StringBuilder();
|
||||
string time = DateTime.Now.ToString().Replace(':', '-').Replace(' ', '_');
|
||||
foreach (var _file in Directory.GetFiles(@"D:\!dtlauncher-server\share\public\Conan_Exiles"))
|
||||
{
|
||||
var file = _file.Remove(0, 35);
|
||||
outBuilder.Append("Download(\"");
|
||||
outBuilder.Append(file);
|
||||
outBuilder.Append("\", \"downloads\\");
|
||||
outBuilder.Append(file);
|
||||
outBuilder.Append("\");\n");
|
||||
outBuilder.Append("Run(\"cmd\", \"/c unarc.exe x -dpinstalled downloads\\");
|
||||
outBuilder.Append(file);
|
||||
outBuilder.Append(" >> logs\\installation-Conan_Exiles-");
|
||||
outBuilder.Append(time);
|
||||
outBuilder.Append(".log\");\n");
|
||||
outBuilder.Append("FileDelete(\"downloads\\");
|
||||
outBuilder.Append(file);
|
||||
outBuilder.Append("\");\n");
|
||||
}
|
||||
Info.Log("c", "\n\n" + outBuilder.ToString() + "\n\n");*/
|
||||
config = config = new(File.ReadAllText("server.dtsod"));
|
||||
int f = (int)config["server_port"];
|
||||
Info.Log("b", "local address: <", "c", config["server_ip"], "b",
|
||||
">\npublic address: <", "c", OldNetwork.GetPublicIP(), "b",
|
||||
">\nport: <", "c", config["server_port"].ToString(), "b", ">\n");
|
||||
mainSocket.Bind(new IPEndPoint(IPAddress.Parse(config["server_ip"]), (int)config["server_port"]));
|
||||
mainSocket.Listen(1000);
|
||||
Info.Log("g", "server started succesfully\n");
|
||||
//
|
||||
/*DTLib.Timer userCkeckTimer = new(true, 3000, () =>
|
||||
{
|
||||
foreach (Socket usr in users.Keys)
|
||||
{
|
||||
if (usr.)
|
||||
{
|
||||
Info.Log("y", $"closing unused user <{usr.RemoteEndPoint.Serialize()[0]}> thread\n");
|
||||
users[usr].Abort();
|
||||
users.Remove(usr);
|
||||
}
|
||||
}
|
||||
});*/
|
||||
// запуск отдельного потока для каждого юзера
|
||||
while (true)
|
||||
{
|
||||
Socket userSocket = mainSocket.Accept();
|
||||
var userThread = new Thread(new ParameterizedThreadStart((obj) => UserHandle((Socket)obj)));
|
||||
//users.Add(userSocket, userThread);
|
||||
userThread.Start(userSocket);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Info.Log("r", $"dtlauncher_server.Main() error:\n{ex.Message}\n{ex.StackTrace}\n");
|
||||
mainSocket.Close();
|
||||
}
|
||||
Info.Log("press any key to close... ");
|
||||
Console.ReadKey();
|
||||
Info.Log("gray", "\n");
|
||||
}
|
||||
|
||||
// запускается для каждого юзера в отдельном потоке
|
||||
static void UserHandle(Socket handlerSocket)
|
||||
{
|
||||
Info.Log("b", "user connecting... ");
|
||||
//Socket fspSocket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
//fspSocket.Bind()
|
||||
FSP fsp = new(handlerSocket);
|
||||
try
|
||||
{
|
||||
handlerSocket.SendPackage("requesting hash".ToBytes());
|
||||
byte[] hash = handlerSocket.GetPackage();
|
||||
// запрос от апдейтера
|
||||
if (hash.HashToString() == "ffffffffffffffff")
|
||||
{
|
||||
Info.LogNoTime("c", "client is updater\n");
|
||||
CreateManifest("share\\client\\");
|
||||
Info.Log("g", "client files manifest created\n");
|
||||
handlerSocket.SendPackage("updater".ToBytes());
|
||||
while (true)
|
||||
{
|
||||
if (handlerSocket.Available >= 2)
|
||||
{
|
||||
string request = handlerSocket.GetPackage().BytesToString();
|
||||
string recieved, filepath;
|
||||
switch (request)
|
||||
{
|
||||
case "requesting file download":
|
||||
filepath = "share\\client\\" + handlerSocket.GetPackage().BytesToString();
|
||||
fsp.UploadFile(filepath);
|
||||
break;
|
||||
case "register new user":
|
||||
Info.Log("b", "new user registration requested\n");
|
||||
handlerSocket.SendPackage("ok".ToBytes());
|
||||
//filepath = handlerSocket.GetPackage().BytesToString();
|
||||
//if (!filePath.EndsWith(".req")) throw new Exception($"wrong registration request file: <{filepath}>");
|
||||
//Info.Log("b", $"downloading file registration_requests\\{filepath}\n");
|
||||
//handlerSocket.FSP_Download($"registration_requests\\{filepath}");
|
||||
recieved = handlerSocket.GetPackage().BytesToString();
|
||||
filepath = $"registration_requests\\{recieved.Remove(0, recieved.IndexOf(':') + 2)}.req";
|
||||
File.WriteAllText(filepath, recieved);
|
||||
Info.Log("b", $"text wrote to file <", "c", "registration_requests\\{filepath}", "b", ">\n");
|
||||
break;
|
||||
default:
|
||||
throw new Exception("unknown request: " + request);
|
||||
}
|
||||
}
|
||||
else Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
// запрос от лаунчера
|
||||
else
|
||||
{
|
||||
Info.LogNoTime("c", "client is launcher\n");
|
||||
string login;
|
||||
lock (new object())
|
||||
{
|
||||
login = OldFilework.ReadFromConfig("users.db", hash.HashToString());
|
||||
}
|
||||
handlerSocket.SendPackage("success".ToBytes());
|
||||
Info.Log("g", "user <", "c", login, "g", "> succesfully logined\n");
|
||||
while (true)
|
||||
{
|
||||
if (handlerSocket.Available >= 64)
|
||||
{
|
||||
string request = handlerSocket.GetPackage().BytesToString();
|
||||
switch (request)
|
||||
{
|
||||
// ответ на NetWork.Ping()
|
||||
/*case "ping":
|
||||
handlerSocket.Send("pong".ToBytes());
|
||||
break;*/
|
||||
// отправка списка активных серверов
|
||||
/*case "requesting servers list":
|
||||
|
||||
break;*/
|
||||
case "requesting file download":
|
||||
fsp.UploadFile("share\\public\\" + handlerSocket.GetPackage().BytesToString());
|
||||
break;
|
||||
default:
|
||||
throw new Exception("unknown request: " + request);
|
||||
}
|
||||
}
|
||||
else Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Info.Log("y", $"UserStart() error:\n message:\n {ex.Message}\n{ex.StackTrace}\n");
|
||||
handlerSocket.Shutdown(SocketShutdown.Both);
|
||||
handlerSocket.Close();
|
||||
Thread.CurrentThread.Abort();
|
||||
}
|
||||
}
|
||||
|
||||
// вычисляет и записывает в manifest.dtsod хеши файлов из files_list.dtsod
|
||||
public static void CreateManifest(string dir)
|
||||
{
|
||||
if (!dir.EndsWith("\\")) dir += "\\";
|
||||
List<string> files = Directory.GetAllFiles(dir);
|
||||
if (files.Contains(dir + "manifest.dtsod")) files.Remove(dir + "manifest.dtsod");
|
||||
StringBuilder manifestBuilder = new();
|
||||
Hasher hasher = new();
|
||||
for (int i = 0; i < files.Count; i++)
|
||||
{
|
||||
files[i] = files[i].Remove(0, dir.Length);
|
||||
manifestBuilder.Append(files[i]);
|
||||
manifestBuilder.Append(": \"");
|
||||
byte[] hash = hasher.HashFile(dir + files[i]);
|
||||
manifestBuilder.Append(hash.HashToString());
|
||||
manifestBuilder.Append("\";\n");
|
||||
}
|
||||
File.WriteAllText(dir + "manifest.dtsod", manifestBuilder.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
53
dtlauncher-server-win/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// Общие сведения об этой сборке предоставляются следующим набором
|
||||
// набор атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
|
||||
// связанные со сборкой.
|
||||
[assembly: AssemblyTitle("dtlauncher-server-win")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("dtlauncher-server-win")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
|
||||
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
|
||||
// из модели COM, установите атрибут ComVisible для этого типа в значение true.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//Чтобы начать создание локализуемых приложений, задайте
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> в файле .csproj
|
||||
//в <PropertyGroup>. Например, при использовании английского (США)
|
||||
//в своих исходных файлах установите <UICulture> в en-US. Затем отмените преобразование в комментарий
|
||||
//атрибута NeutralResourceLanguage ниже. Обновите "en-US" в
|
||||
//строка внизу для обеспечения соответствия настройки UICulture в файле проекта.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //где расположены словари ресурсов по конкретным тематикам
|
||||
//(используется, если ресурс не найден на странице,
|
||||
// или в словарях ресурсов приложения)
|
||||
ResourceDictionaryLocation.SourceAssembly //где расположен словарь универсальных ресурсов
|
||||
//(используется, если ресурс не найден на странице,
|
||||
// в приложении или в каких-либо словарях ресурсов для конкретной темы)
|
||||
)]
|
||||
|
||||
|
||||
// Сведения о версии для сборки включают четыре следующих значения:
|
||||
//
|
||||
// Основной номер версии
|
||||
// Дополнительный номер версии
|
||||
// Номер сборки
|
||||
// Номер редакции
|
||||
//
|
||||
// Можно задать все значения или принять номера сборки и редакции по умолчанию
|
||||
// используя "*", как показано ниже:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
70
dtlauncher-server-win/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,70 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код был создан программным средством.
|
||||
// Версия среды выполнения: 4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
|
||||
// код создан повторно.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace dtlauncher_server_win.Properties
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
|
||||
/// </summary>
|
||||
// Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
|
||||
// класс с помощью таких средств, как ResGen или Visual Studio.
|
||||
// Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
|
||||
// с параметром /str или заново постройте свой VS-проект.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("dtlauncher_server_win.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Переопределяет свойство CurrentUICulture текущего потока для всех
|
||||
/// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
dtlauncher-server-win/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
29
dtlauncher-server-win/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace dtlauncher_server_win.Properties
|
||||
{
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
dtlauncher-server-win/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
115
dtlauncher-server-win/dtlauncher-server-win.csproj
Normal file
@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{8B9889A7-93DC-4914-92D1-8209BD3BA71A}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>dtlauncher_server_win</RootNamespace>
|
||||
<AssemblyName>dtlauncher-server-win</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Build|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DtlauncherServer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="server.dtsod">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.8 %28x86 и x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\DTLib\DTLib\DTLib.csproj">
|
||||
<Project>{ce793497-2d5c-42d8-b311-e9b32af9cdfb}</Project>
|
||||
<Name>DTLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>del /f /q dtlauncher-server-win.exe.config</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
2
dtlauncher-server-win/server.dtsod
Normal file
@ -0,0 +1,2 @@
|
||||
server_ip: "10.1.10.44";
|
||||
server_port: 25001;
|
||||
@ -1,49 +1,49 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.1.32104.313
|
||||
VisualStudioVersion = 17.0.31815.197
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher.Server", "Launcher.Server\Launcher.Server.csproj", "{1F4D14EB-AF48-4B6C-A91B-B294D4281173}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher.Client.WPF", "Launcher.Client.WPF\Launcher.Client.WPF.csproj", "{A1F770F3-F6B1-4854-9BF0-093F85064B88}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{F567AA49-E96B-43BD-95B5-A71F9FCB64E1}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.gitignore = .gitignore
|
||||
README.md = README.md
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dtlauncher-client-win", "dtlauncher-client-win\dtlauncher-client-win.csproj", "{367793EE-4757-4ADD-BF7E-960DC9EB6DF9}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{CE793497-2D5C-42D8-B311-E9B32AF9CDFB} = {CE793497-2D5C-42D8-B311-E9B32AF9CDFB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher.Client.Avalonia", "Launcher.Client.Avalonia\Launcher.Client.Avalonia.csproj", "{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dtlauncher-server-win", "dtlauncher-server-win\dtlauncher-server-win.csproj", "{8B9889A7-93DC-4914-92D1-8209BD3BA71A}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{CE793497-2D5C-42D8-B311-E9B32AF9CDFB} = {CE793497-2D5C-42D8-B311-E9B32AF9CDFB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher.Client", "Launcher.Client\Launcher.Client.csproj", "{87427137-840D-4D09-A101-9481110682BD}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "updater", "updater\updater.csproj", "{4784D974-A342-4202-9430-90FE5AC00FC7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dtscript", "dtscript\dtscript.csproj", "{E02EA967-FD29-47D2-B25B-BA684B784AEE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTLib", "..\DTLib\DTLib\DTLib.csproj", "{CE793497-2D5C-42D8-B311-E9B32AF9CDFB}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sulution Files", "Sulution Files", "{09AA971D-CD70-4D93-BBA9-810C842830D8}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.gitignore = .gitignore
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Build|Any CPU = Build|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1F4D14EB-AF48-4B6C-A91B-B294D4281173}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1F4D14EB-AF48-4B6C-A91B-B294D4281173}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1F4D14EB-AF48-4B6C-A91B-B294D4281173}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1F4D14EB-AF48-4B6C-A91B-B294D4281173}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A1F770F3-F6B1-4854-9BF0-093F85064B88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A1F770F3-F6B1-4854-9BF0-093F85064B88}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A1F770F3-F6B1-4854-9BF0-093F85064B88}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A1F770F3-F6B1-4854-9BF0-093F85064B88}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BC1FC2A0-159A-4F17-B076-B39775FB6AAC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{87427137-840D-4D09-A101-9481110682BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{87427137-840D-4D09-A101-9481110682BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{87427137-840D-4D09-A101-9481110682BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{87427137-840D-4D09-A101-9481110682BD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{367793EE-4757-4ADD-BF7E-960DC9EB6DF9}.Build|Any CPU.ActiveCfg = Build|Any CPU
|
||||
{367793EE-4757-4ADD-BF7E-960DC9EB6DF9}.Build|Any CPU.Build.0 = Build|Any CPU
|
||||
{8B9889A7-93DC-4914-92D1-8209BD3BA71A}.Build|Any CPU.ActiveCfg = Build|Any CPU
|
||||
{8B9889A7-93DC-4914-92D1-8209BD3BA71A}.Build|Any CPU.Build.0 = Build|Any CPU
|
||||
{4784D974-A342-4202-9430-90FE5AC00FC7}.Build|Any CPU.ActiveCfg = Build|Any CPU
|
||||
{4784D974-A342-4202-9430-90FE5AC00FC7}.Build|Any CPU.Build.0 = Build|Any CPU
|
||||
{E02EA967-FD29-47D2-B25B-BA684B784AEE}.Build|Any CPU.ActiveCfg = Build|Any CPU
|
||||
{E02EA967-FD29-47D2-B25B-BA684B784AEE}.Build|Any CPU.Build.0 = Build|Any CPU
|
||||
{CE793497-2D5C-42D8-B311-E9B32AF9CDFB}.Build|Any CPU.ActiveCfg = Release-net48|Any CPU
|
||||
{CE793497-2D5C-42D8-B311-E9B32AF9CDFB}.Build|Any CPU.Build.0 = Release-net48|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {96D7F599-27F9-420C-835D-FAF63EE78D0E}
|
||||
SolutionGuid = {E6569C0C-DD32-4F7D-AD4C-DBC5434D2F8C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
6
dtscript/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
33
dtscript/MainClass.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using DTLib;
|
||||
using DTLib.Filesystem;
|
||||
|
||||
namespace DTScript;
|
||||
|
||||
public class MainClass
|
||||
{
|
||||
static DTLib.Loggers.DefaultLogger Info = new("logs", "dtlaunchet_server");
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Create("dtscript-logs");
|
||||
PublicLog.LogEvent += Info.Log;
|
||||
PublicLog.LogNoTimeEvent += Info.Log;
|
||||
var scripter = new ScriptRunner();
|
||||
if (args.Length == 0 || args.Length > 2) throw new Exception("enter script file path\n");
|
||||
else if (args.Length == 1) scripter.RunScriptFile(args[0]);
|
||||
else if (args.Length == 2 && args[0] == "-debug")
|
||||
{
|
||||
scripter.debug = true;
|
||||
scripter.Debug("y", "debug is enabled\n");
|
||||
scripter.RunScriptFile(args[1]);
|
||||
}
|
||||
else throw new Exception("unknown args\n");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{ Info.Log("r", $"dtscript.Main() error:\n{ex.Message}\n{ex.StackTrace}\n"); }
|
||||
Info.Log("gray", " \n");
|
||||
}
|
||||
}
|
||||
35
dtscript/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Общие сведения об этой сборке предоставляются следующим набором
|
||||
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
|
||||
// связанные с этой сборкой.
|
||||
[assembly: AssemblyTitle("dtscript")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("dtscript")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
|
||||
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
|
||||
// из модели COM задайте для атрибута ComVisible этого типа значение true.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM
|
||||
[assembly: Guid("e02ea967-fd29-47d2-b25b-ba684b784aee")]
|
||||
|
||||
// Сведения о версии сборки состоят из указанных ниже четырех значений:
|
||||
//
|
||||
// Основной номер версии
|
||||
// Дополнительный номер версии
|
||||
// Номер сборки
|
||||
// Номер редакции
|
||||
//
|
||||
// Можно задать все значения или принять номера сборки и редакции по умолчанию
|
||||
// используя "*", как показано ниже:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
465
dtscript/ScriptRunner.cs
Normal file
@ -0,0 +1,465 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Sockets;
|
||||
using System.Linq;
|
||||
using DTLib;
|
||||
using DTLib.Filesystem;
|
||||
using DTLib.Network;
|
||||
|
||||
namespace DTScript;
|
||||
|
||||
//
|
||||
// основной класс скриптового интерпретатора
|
||||
//
|
||||
public class ScriptRunner
|
||||
{
|
||||
// выводит текст через DTLib если дебаг включен
|
||||
public bool debug = false;
|
||||
public Socket mainSocket;
|
||||
public FSP fsp;
|
||||
|
||||
internal void Debug(params string[] msg)
|
||||
{
|
||||
if (debug) PublicLog.Log(msg);
|
||||
}
|
||||
|
||||
// cчитывание текста из файла и запуск выполнения
|
||||
public void RunScriptFile(string scriptfile)
|
||||
{
|
||||
Debug("g", @"----\ " + scriptfile + " /----\n");
|
||||
try { Execute(SplitScript(File.ReadAllText(scriptfile))); }
|
||||
catch (Exception e) { PublicLog.Log("r", $"dtscript RunScriptFile() error:\n{e.Message}\n{e.StackTrace}\n", "gray", " \n"); }
|
||||
}
|
||||
|
||||
int globalindex = -1;
|
||||
List<Dictionary<string, object>> Storage = new();
|
||||
|
||||
object GetValue(string key)
|
||||
{
|
||||
Debug("m", "GetValue(", "c", "<", "b", key, "c", ">", "m", ")\n");
|
||||
for (int i = 0; i <= globalindex; i++)
|
||||
if (Storage[i].ContainsKey(key)) return Storage[i][key];
|
||||
throw new Exception($"GetValue() exception: storage doesn't contain key<{key}>");
|
||||
}
|
||||
|
||||
void SetValue(string key, object value)
|
||||
{
|
||||
Debug("m", "SetValue(", "c", "<", "b", key, "c", "> ", "c", "<", "b", value.ToString(), "c", ">", "m", ")\n");
|
||||
for (int i = 0; i <= globalindex; i++)
|
||||
if (Storage[i].ContainsKey(key))
|
||||
{
|
||||
Storage[i][key] = value;
|
||||
Debug(Storage[i][key].ToString());
|
||||
return;
|
||||
}//throw new Exception($"SetValue() exception: storage alredy contains key<{key}>");
|
||||
Storage[globalindex].Add(key, value);
|
||||
}
|
||||
|
||||
dynamic Execute(List<Construction> script)
|
||||
{
|
||||
Debug("y", " executing...\n");
|
||||
// создание локального
|
||||
globalindex++;
|
||||
List<Construction> subscript;
|
||||
Storage.Add(new Dictionary<string, object>());
|
||||
// запуск цикла
|
||||
for (int index = 0; index < script.Count; index++)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
PublicLog.Log(new string[] {
|
||||
"y","\noperator: ", "m",script[index].Operator, "y"," options: ", "c", "<", "b", script[index].Options[0], "c", ">"});
|
||||
for (ushort n = 1; n < script[index].Options.Length; n++)
|
||||
PublicLog.Log("w", ", ", "c", "<", "b", script[index].Options[n], "c", ">");
|
||||
PublicLog.Log("\n");
|
||||
}
|
||||
switch (script[index].Operator)
|
||||
{
|
||||
case "return":
|
||||
Debug("g", "script ended");
|
||||
return GetValue(script[index].Options[0]);
|
||||
case "Run":
|
||||
var proc = new Process();
|
||||
proc.StartInfo.FileName = script[index].Options[0].Replace("\"", "");
|
||||
proc.StartInfo.Arguments = script[index].Options[1].Replace("\"", "");
|
||||
/*if (script[index].Options.Length == 3 && script[index].Options[2] == "true")
|
||||
{
|
||||
proc.StartInfo.CreateNoWindow = true;
|
||||
Debug("g", $"process {script[index].Operator} started in hidden mode\n");
|
||||
}
|
||||
else if (script[index].Options.Length == 3 && script[index].Options[2] == "false")
|
||||
{
|
||||
proc.StartInfo.CreateNoWindow = false;
|
||||
Debug("g", $"process {script[index].Operator} started in not hidden mode\n");
|
||||
}
|
||||
else throw new Exception("invalid arguments in Run().\n it must be: Run(string exe_file, string arguments, true/false nowindow)\n");
|
||||
proc.StartInfo.UseShellExecute = false;*/
|
||||
proc.Start();
|
||||
proc.WaitForExit();
|
||||
proc.Close();
|
||||
break;
|
||||
case "Log":
|
||||
Debug("y", $"Log() has {script[index].Options.Length} args\n");
|
||||
PublicLog.Log(CalcString(script[index].Options.ToList()));
|
||||
break;
|
||||
case "ShowFiles":
|
||||
Debug("y", $"Log() has {script[index].Options.Length} args\n");
|
||||
foreach (string file in Directory.GetFiles(CalcString(script[index].Options.ToList())))
|
||||
PublicLog.Log(file + '\n');
|
||||
break;
|
||||
case "bool":
|
||||
if (script[index].Options.Length > 2 && script[index].Options[1] == "=")
|
||||
{
|
||||
List<string> expr = new();
|
||||
for (ushort n = 2; n < script[index].Options.Length; n++)
|
||||
expr.Add(script[index].Options[n]);
|
||||
// сравнение и добавление результата в storage[globalindex]
|
||||
SetValue(script[index].Options[0], Compare(expr));
|
||||
Debug(new string[] {"y"," bool ","b", script[index].Options[0],
|
||||
"w", " = ", "c", GetValue(script[index].Options[0]).ToString() + '\n'});
|
||||
}
|
||||
else throw new Exception("error: incorrect bool defination\n");
|
||||
break;
|
||||
case "num":
|
||||
if (script[index].Options.Length > 2 && script[index].Options[1] == "=")
|
||||
{
|
||||
List<string> expr = new();
|
||||
for (ushort n = 2; n < script[index].Options.Length; n++)
|
||||
{
|
||||
expr.Add(script[index].Options[n]);
|
||||
}
|
||||
SetValue(script[index].Options[0], (double)Calc(expr));
|
||||
Debug(new string[] {"y"," num ","b", script[index].Options[0],
|
||||
"w", " = ", "c", GetValue(script[index].Options[0]).ToString() + '\n'});
|
||||
}
|
||||
else throw new Exception("Execute() error: incorrect double defination\n");
|
||||
break;
|
||||
case "string":
|
||||
if (script[index].Options.Length > 2 && script[index].Options[1] == "=")
|
||||
{
|
||||
List<string> expr = new();
|
||||
for (ushort n = 2; n < script[index].Options.Length; n++)
|
||||
{
|
||||
expr.Add(script[index].Options[n]);
|
||||
}
|
||||
SetValue(script[index].Options[0], CalcString(expr));
|
||||
Debug(new string[] {"y"," string ","b", script[index].Options[0],
|
||||
"w", " = ", "c", GetValue(script[index].Options[0]).ToString() + '\n'});
|
||||
}
|
||||
break;
|
||||
case "while":
|
||||
if (script[index + 1].Operator != "{") throw new Exception("Execute() error: expect { after for()");
|
||||
subscript = SplitScript(script[index + 1].Options[0]);
|
||||
while (Compare(script[index].Options.ToList()))
|
||||
{
|
||||
Execute(subscript);
|
||||
}
|
||||
index++;
|
||||
break;
|
||||
case "if":
|
||||
if (script[index + 1].Operator != "{") throw new Exception("Execute() error: expect { after for()");
|
||||
subscript = SplitScript(script[index + 1].Options[0]);
|
||||
if (Compare(script[index].Options.ToList()))
|
||||
{
|
||||
Execute(subscript);
|
||||
}
|
||||
index++;
|
||||
break;
|
||||
case "Download":
|
||||
if (fsp is null) fsp = new(mainSocket);
|
||||
fsp.DownloadFile(script[index].Options[0], script[index].Options[1]);
|
||||
break;
|
||||
case "DirDelete":
|
||||
Directory.Delete(script[index].Options[0]);
|
||||
break;
|
||||
case "FileDelete":
|
||||
File.Delete(script[index].Options[0]);
|
||||
break;
|
||||
case "FileWrite":
|
||||
File.Create(script[index].Options[0]);
|
||||
File.WriteAllText(script[index].Options[0], script[index].Options[1]);
|
||||
break;
|
||||
case "FileAppend":
|
||||
File.Create(script[index].Options[0]);
|
||||
File.AppendAllText(script[index].Options[0], script[index].Options[1]);
|
||||
break;
|
||||
default:
|
||||
throw new Exception($"Execute() error: invalid construct: {script[index].Operator}\n");
|
||||
}
|
||||
}
|
||||
Storage.RemoveAt(globalindex);
|
||||
globalindex--;
|
||||
return null;
|
||||
|
||||
// операции со строками
|
||||
string CalcString(List<string> expr)
|
||||
{
|
||||
Debug("m", "CalcString(");
|
||||
foreach (string part in expr)
|
||||
Debug("c", "<", "b", part, "c", ">");
|
||||
Debug("m", ")", "y", " started\n");
|
||||
// извлечение значений переменных
|
||||
for (ushort n = 0; n < expr.Count; n++)
|
||||
{
|
||||
switch (expr[n][0])
|
||||
{
|
||||
case '+':
|
||||
break;
|
||||
case '"':
|
||||
if (!expr[n].EndsWith("\"")) throw new Exception("Calc() error: invalid value <" + expr[n] + ">\n");
|
||||
break;
|
||||
default:
|
||||
expr[n] = GetValue(expr[n]).ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
// вычисление
|
||||
string rezult = "";
|
||||
for (ushort i = 0; i < expr.Count; i++)
|
||||
{
|
||||
|
||||
if (expr[i] == "+")
|
||||
{
|
||||
i++;
|
||||
rezult += expr[i];
|
||||
}
|
||||
else rezult = i == 0 ? expr[0] : throw new Exception($"error in Calc(): arg {expr[i]}\n");
|
||||
}
|
||||
if (rezult.Contains("\\n")) rezult = rezult.Replace("\\n", "\n");
|
||||
if (rezult.Contains("\"")) rezult = rezult.Replace("\"", "");
|
||||
Debug("y", " returns <", "b", $"{rezult}", "y", ">\n");
|
||||
return rezult;
|
||||
}
|
||||
// операции с числами
|
||||
double Calc(List<string> expr)
|
||||
{
|
||||
Debug("m", "Calc(");
|
||||
foreach (string part in expr)
|
||||
Debug("c", "<", "b", part, "c", ">");
|
||||
Debug("m", ")", "y", " started\n");
|
||||
// извлечение значений переменных
|
||||
for (ushort n = 0; n < expr.Count; n++)
|
||||
{
|
||||
switch (expr[n][0])
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
case '+':
|
||||
case '-':
|
||||
case '*':
|
||||
case '/':
|
||||
break;
|
||||
default:
|
||||
expr[n] = GetValue(expr[n]).ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
// вычисление
|
||||
double rezult = new();
|
||||
for (ushort i = 0; i < expr.Count; i++)
|
||||
switch (expr[i][0])
|
||||
{
|
||||
case '+':
|
||||
i++;
|
||||
rezult += Convert.ToDouble(expr[i]);
|
||||
break;
|
||||
case '-':
|
||||
i++;
|
||||
rezult -= Convert.ToDouble(expr[i]);
|
||||
break;
|
||||
case '*':
|
||||
i++;
|
||||
rezult *= Convert.ToDouble(expr[i]);
|
||||
break;
|
||||
case '/':
|
||||
i++;
|
||||
rezult /= Convert.ToDouble(expr[i]);
|
||||
break;
|
||||
default:
|
||||
if (i == 0) rezult += Convert.ToDouble(expr[i]);
|
||||
else throw new Exception($"error in Calc(): arg {expr[i]}\n");
|
||||
break;
|
||||
}
|
||||
Debug("y", " returns <", "b", $"{rezult}", "y", ">\n");
|
||||
return rezult;
|
||||
}
|
||||
// сравнение
|
||||
bool Compare(List<string> expr)
|
||||
{
|
||||
Debug("m", "Compare(");
|
||||
foreach (string part in expr)
|
||||
Debug("c", "<", "b", part, "c", ">");
|
||||
Debug("m", ")", "y", " started\n");
|
||||
// вычисление значений правой и левой части неравенства
|
||||
char act = '\0';
|
||||
double rezult_0 = new(), rezult_1;
|
||||
var _expr = new List<string>();
|
||||
for (ushort n = 0; n < expr.Count; n++)
|
||||
{
|
||||
Debug("m", $" <{expr[n]}>\n");
|
||||
switch (expr[n][0])
|
||||
{
|
||||
case '<':
|
||||
case '>':
|
||||
act = expr[n][0];
|
||||
rezult_0 = Calc(_expr);
|
||||
_expr.Clear();
|
||||
break;
|
||||
case '!':
|
||||
case '=':
|
||||
act = expr[n][0];
|
||||
rezult_0 = Calc(_expr);
|
||||
_expr.Clear();
|
||||
n++;
|
||||
break;
|
||||
default:
|
||||
_expr.Add(expr[n]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Debug("y", " rezult_0 = <", "b", rezult_0.ToString(), "y", ">\n");
|
||||
rezult_1 = Calc(_expr);
|
||||
Debug("y", " rezult_1 = <", "b", rezult_1.ToString(), "y", ">\n");
|
||||
Debug("y", " act = <", "b", act.ToString(), "y", ">\n");
|
||||
bool output = act switch
|
||||
{
|
||||
'<' => rezult_0 < rezult_1,
|
||||
'>' => rezult_0 > rezult_1,
|
||||
'!' => rezult_0 != rezult_1,
|
||||
'=' => rezult_0 == rezult_1,
|
||||
_ => throw new Exception($"error: incorrect comparsion symbol: <{act}>\n"),
|
||||
};
|
||||
Debug("y", " return <", "c", $"{output}", "y", ">\n");
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
List<Construction> SplitScript(string text)
|
||||
{
|
||||
// лист для хранения обработанного текста
|
||||
List<Construction> script = new();
|
||||
string construct = "";
|
||||
string option = "";
|
||||
List<string> options = new();
|
||||
for (int index = 0; index < text.Length; index++)
|
||||
{
|
||||
switch (text[index])
|
||||
{
|
||||
// конец распознания конструкта
|
||||
case ';':
|
||||
Debug(text[index].ToString() + '\n');
|
||||
// добавление конструкта и его параметров в лист
|
||||
if (construct != "") script.Add(new Construction(construct, options));
|
||||
construct = "";
|
||||
option = "";
|
||||
options.Clear();
|
||||
break;
|
||||
// распознание параметров конструкта
|
||||
case '(':
|
||||
Debug(text[index].ToString());
|
||||
while (text[index] != ')')
|
||||
{
|
||||
index++;
|
||||
switch (text[index])
|
||||
{
|
||||
case '"':
|
||||
Debug("g", text[index].ToString());
|
||||
do
|
||||
{
|
||||
option += text[index];
|
||||
index++;
|
||||
Debug("g", text[index].ToString());
|
||||
} while (text[index] != '"');
|
||||
option += text[index];
|
||||
break;
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\r':
|
||||
case '\n':
|
||||
break;
|
||||
case ')':
|
||||
case ',':
|
||||
Debug(text[index].ToString());
|
||||
options.Add(option);
|
||||
option = "";
|
||||
break;
|
||||
// математика
|
||||
case '+':
|
||||
case '-':
|
||||
case '*':
|
||||
case '/':
|
||||
case '!':
|
||||
case '=':
|
||||
Debug(text[index].ToString());
|
||||
if (option != "") options.Add(option);
|
||||
option = "";
|
||||
options.Add(text[index].ToString());
|
||||
break;
|
||||
default:
|
||||
option += text[index];
|
||||
Debug("c", text[index].ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (debug && text[index + 1] == ';') PublicLog.Log("y", "\n " + options.Count + " options have read\n");
|
||||
break;
|
||||
// очистка конструкта от лишних символов
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\r':
|
||||
case '\n':
|
||||
break;
|
||||
//
|
||||
case '{':
|
||||
Debug("SplitScript() found <{>");
|
||||
// добавление конструкта и его параметров в лист
|
||||
if (construct != "") script.Add(new Construction(construct, options));
|
||||
options.Clear();
|
||||
option = "";
|
||||
construct = "";
|
||||
index++;
|
||||
short bracketBalance = 1;
|
||||
while (bracketBalance != 0)
|
||||
{
|
||||
if (text[index] == '{') bracketBalance++;
|
||||
if (text[index] == '}') bracketBalance--;
|
||||
option += text[index];
|
||||
index++;
|
||||
}
|
||||
option.Remove(option.Length - 1);
|
||||
script.Add(new Construction("{", new List<string> { option }));
|
||||
option = "";
|
||||
break;
|
||||
case '}':
|
||||
//throw new Exception($"SplitScript() error: unexpected '}}' on line {line}\n");
|
||||
break;
|
||||
default:
|
||||
construct += text[index];
|
||||
Debug("m", text[index].ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// возврат листа
|
||||
return script;
|
||||
}
|
||||
|
||||
class Construction
|
||||
{
|
||||
public string Operator { get; private set; }
|
||||
public string[] Options { get; private set; }
|
||||
public Construction(string oper, List<string> opts)
|
||||
{
|
||||
Operator = oper;
|
||||
Options = opts.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
98
dtscript/dtscript.csproj
Normal file
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{E02EA967-FD29-47D2-B25B-BA684B784AEE}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>dtscript</RootNamespace>
|
||||
<AssemblyName>dtscript</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Build|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<LangVersion>preview</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>DTScript.MainClass</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>dtscript.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainClass.cs" />
|
||||
<Compile Include="ScriptRunner.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 и x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="dtscript.ico" />
|
||||
<Content Include="dtscript_doc.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\DTLib\DTLib\DTLib.csproj">
|
||||
<Project>{ce793497-2d5c-42d8-b311-e9b32af9cdfb}</Project>
|
||||
<Name>DTLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>del /q /f dtscript.exe.config
|
||||
copy dtscript.exe ..\..\dtlauncher-server-win\bin\share\client\dtscript.exe</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
BIN
dtscript/dtscript.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
26
dtscript/dtscript.sln
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30611.23
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dtscript", "dtscript.csproj", "{E02EA967-FD29-47D2-B25B-BA684B784AEE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTLib", "..\DTLib\DTLib.csproj", "{CE793497-2D5C-42D8-B311-E9B32AF9CDFB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
build|Any CPU = build|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E02EA967-FD29-47D2-B25B-BA684B784AEE}.build|Any CPU.ActiveCfg = build|Any CPU
|
||||
{E02EA967-FD29-47D2-B25B-BA684B784AEE}.build|Any CPU.Build.0 = build|Any CPU
|
||||
{CE793497-2D5C-42D8-B311-E9B32AF9CDFB}.build|Any CPU.ActiveCfg = Build|Any CPU
|
||||
{CE793497-2D5C-42D8-B311-E9B32AF9CDFB}.build|Any CPU.Build.0 = Build|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A1D642E1-876E-4187-91D5-526827AE36A2}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
63
dtscript/dtscript_doc.txt
Normal file
@ -0,0 +1,63 @@
|
||||
Мне было лень изучать жабаскрып, потому всего за полгода я сделал вот этот dtscript (как выразился Абикак, "питоний джабаскрып").
|
||||
Синтаксис dtscript не завист от пробелов, табов, переносов строк. Конец одной конструкции определяется по символу ';' или '}' (если перед этим был символ '{')
|
||||
|
||||
|
||||
========================================[переменные]========================================
|
||||
|
||||
объявление переменной и присвоение значения синтаксически никак не отличаются:
|
||||
тип(имя = значение);
|
||||
|
||||
у переменных есть контекст:
|
||||
bool(h=false);
|
||||
if (...)
|
||||
{
|
||||
bool(j=true);
|
||||
Log("w", h); выведет true, так как есть доступ к переменным предыдущих уровней
|
||||
}
|
||||
Log("w", j); выдаст ошибку "KeyNotFoundException", так как вызывается с предшествующего объявлению переменной уровня
|
||||
|
||||
┌────────┬────────────────┬───────────┬───────────────────┐
|
||||
│ тип │ аналог в c# │ операции │ пример │
|
||||
├────────┼────────────────┼───────────┼───────────────────┤
|
||||
│ bool │ System.Boolean │ <,>,==,!= │ bool(a=1<3); │
|
||||
├────────┼────────────────┼───────────┼───────────────────┤
|
||||
│ num │ System.Double │ +,-,*,/ │ num(a=9.6); │
|
||||
├────────┼────────────────┼───────────┼───────────────────┤
|
||||
│ string │ System.String │ + │ string(a="text"); │
|
||||
└────────┴────────────────┴───────────┴───────────────────┘
|
||||
|
||||
|
||||
==========================================[методы]==========================================
|
||||
|
||||
Oбъявлять свои методы пока что нельзя, можно только использовать встроенные:
|
||||
метод; если нет параметров
|
||||
Метод(параметр0, параметр1...); параметрами могут быть значения и переменные, но не выражения
|
||||
|
||||
┌────────────────────────────┬─────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────┐
|
||||
│ метод │ аналог в с# │ шо делает │
|
||||
├────────────────────────────┼─────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
|
||||
│ pause │ System.Console.ReadKey() │ приостанавливает выполнение скрипта до нажатия клавиши │
|
||||
├────────────────────────────┼─────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
|
||||
│ break │ break │ прекращает выполнение уровня скрипта │
|
||||
├────────────────────────────┼─────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
|
||||
│ Log("w", "text", ...) │ DTLib.ColoredConsole.Write(params string[]) │ выводит в консоль цветной текст │
|
||||
├────────────────────────────┼─────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
|
||||
│ Run("файл.ехе","аргументы")│ System.Diagnostics.Process.Start(string) │ запускает прогу │
|
||||
├────────────────────────────┼─────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
|
||||
│ Download("f0", "f1") │ DTLib.NetWork.FSP_Download(this Socket, string, string) │ скачивает файл по FSP протоколу │
|
||||
└────────────────────────────┴─────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────┘
|
||||
|
||||
|
||||
=========================================[операторы]========================================
|
||||
|
||||
Параметром может быть переменная, но не выражение.
|
||||
|
||||
while (bool)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
if (bool)
|
||||
{
|
||||
...
|
||||
}
|
||||
6
updater/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
</configuration>
|
||||