-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from SeaDevTeam/0.4.3
version 0.4.3 beta
- Loading branch information
Showing
51 changed files
with
2,797 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Application x:Class="ClientHandler.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:ClientHandler" | ||
StartupUri="MainWindow.xaml" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ui:Resources Theme="Dark" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace ClientHandler | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.ApplicationModel; | ||
using Windows.ApplicationModel.AppService; | ||
using Windows.Foundation.Collections; | ||
#pragma warning disable CS8602 // Dereference of a possibly null reference. | ||
|
||
namespace ClientHandler | ||
{ | ||
public class AppServiceHandler | ||
{ | ||
public static AppServiceConnection? Connection { get; set; } | ||
public static async void InitializeAppServiceConnection() | ||
{ | ||
Connection = new AppServiceConnection(); | ||
Connection.AppServiceName = "SDL Logging System"; | ||
Connection.PackageFamilyName = Package.Current.Id.FamilyName; | ||
Connection.RequestReceived += Connection_RequestReceived; ; | ||
Connection.ServiceClosed += Connection_ServiceClosed; ; | ||
|
||
AppServiceConnectionStatus status = await Connection.OpenAsync(); | ||
if (status != AppServiceConnectionStatus.Success) | ||
{ | ||
} | ||
} | ||
|
||
public static void Connection_ServiceClosed(AppServiceConnection sender, AppServiceClosedEventArgs args) | ||
{ | ||
} | ||
|
||
public static void Connection_RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) | ||
{ | ||
foreach (var item in args.Request.Message) | ||
{ | ||
if(item.Key == "Command") | ||
{ | ||
if(item.Value.ToString() == "KillMC") | ||
{ | ||
Program.ProcessUtil.Process.Kill(); | ||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net6.0-windows10.0.22000.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<UseWPF>true</UseWPF> | ||
<SupportedOSPlatformVersion>10.0.18362.0</SupportedOSPlatformVersion> | ||
<ApplicationIcon>icon.ico</ApplicationIcon> | ||
<StartupObject>ClientHandler.Program</StartupObject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="icon.ico" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="WPF-UI" Version="2.0.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<ui:UiWindow x:Class="ClientHandler.MainWindow" | ||
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:ClientHandler" | ||
mc:Ignorable="d" | ||
ExtendsContentIntoTitleBar="True" | ||
WindowBackdropType="Mica" | ||
Title="MainWindow" Height="450" Width="800" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||
Style="{StaticResource UiWindow}"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
|
||
<ui:TitleBar Title="SDL Logging System" Grid.Row="0"/> | ||
|
||
<Grid Grid.Row="1" Margin="12,6,12,12"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="auto"/> | ||
<RowDefinition Height="*"/> | ||
</Grid.RowDefinitions> | ||
<StackPanel Margin="0,0,0,5" Grid.Row="0" HorizontalAlignment="Right" Orientation="Horizontal"> | ||
<ui:Button Click="btnSaveLogs_Click" x:Name="btnSaveLogs" Content="Save" Icon="Save28"/> | ||
<ui:Button Click="btnKillGame_Click" x:Name="btnKillGame" Icon="Dismiss20" Margin="5,0" Content="Kill Minecraft"/> | ||
</StackPanel> | ||
<RichTextBox x:Name="txtLogs" Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" IsReadOnly="True"/> | ||
</Grid> | ||
</Grid> | ||
</ui:UiWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
using Windows.ApplicationModel; | ||
using Windows.ApplicationModel.AppService; | ||
using Wpf.Ui.Controls; | ||
#pragma warning disable CS8602 // Dereference of a possibly null reference. | ||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
namespace ClientHandler | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : UiWindow | ||
{ | ||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
Program.ProcessUtil.OutputReceived += ProcessUtil_OutputReceived; | ||
Program.ProcessUtil.Exited += ProcessUtil_Exited; | ||
Program.ProcessUtil.StartWithEvents(); | ||
} | ||
|
||
private void ProcessUtil_Exited(object? sender, EventArgs e) | ||
{ | ||
Application.Current.Shutdown(); | ||
} | ||
|
||
|
||
private void ProcessUtil_OutputReceived(object? sender, string e) | ||
{ | ||
var x = new Windows.Foundation.Collections.ValueSet(); | ||
x.Add("Log", e); | ||
try | ||
{ | ||
_ = AppServiceHandler.Connection.SendMessageAsync(x); | ||
} | ||
catch { } | ||
this.Dispatcher.Invoke(delegate | ||
{ | ||
txtLogs.AppendText(e); | ||
}); | ||
} | ||
|
||
private void btnKillGame_Click(object sender, RoutedEventArgs e) | ||
{ | ||
Program.ProcessUtil.Process.Kill(); | ||
} | ||
|
||
private void btnSaveLogs_Click(object sender, RoutedEventArgs e) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Xml; | ||
|
||
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type. | ||
#pragma warning disable CS8603 // Possible null reference return. | ||
namespace ClientHandler | ||
{ | ||
class Program | ||
{ | ||
public static ProcessUtil? ProcessUtil { get; set; } | ||
static void Main(string[] args) | ||
{ | ||
var l = GetEnviromentVar("LocalAppData"); | ||
var path = Path.Combine(l, @"Packages\SeaDevs.Launcher.UWP_0dk3ndwmrga1t\LocalState"); | ||
string arguements = ""; | ||
string fileName = ""; | ||
string workdir = ""; | ||
string logs = ""; | ||
using (StreamReader sr = File.OpenText(Path.Combine(path, "StartInfo.xml"))) | ||
{ | ||
var s = sr.BaseStream; | ||
|
||
XmlReaderSettings settings = new XmlReaderSettings(); | ||
settings.Async = true; | ||
using (XmlReader reader = XmlReader.Create(s, settings)) | ||
{ | ||
reader.Read(); | ||
reader.ReadStartElement("Process"); | ||
reader.ReadToFollowing("StartInfo"); | ||
arguements = reader.GetAttribute("Arguments"); | ||
fileName = reader.GetAttribute("FileName"); | ||
logs = reader.GetAttribute("GameLogs"); | ||
workdir = reader.GetAttribute("WorkingDirectory"); | ||
reader.Close(); | ||
} | ||
try | ||
{ | ||
s.Close(); | ||
sr.Close(); | ||
} | ||
catch | ||
{ | ||
|
||
} | ||
} | ||
|
||
if (args.Length > 2) | ||
{ | ||
if (args[2] == "/admin") | ||
{ | ||
string appPath = | ||
Path.Combine(AppDomain.CurrentDomain.BaseDirectory + | ||
@"\ClientHandler.exe"); | ||
|
||
ProcessStartInfo Restartinfo = new ProcessStartInfo(); | ||
Restartinfo.Verb = "runas"; | ||
if (logs != "True") | ||
{ | ||
Restartinfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
Restartinfo.CreateNoWindow = true; | ||
} | ||
Restartinfo.UseShellExecute = true; | ||
Restartinfo.FileName = appPath; | ||
try | ||
{ | ||
Process.Start(Restartinfo); | ||
} | ||
catch | ||
{ | ||
Console.WriteLine("User Cancelled the request..."); | ||
Console.ReadLine(); | ||
} | ||
return; | ||
} | ||
} | ||
//Console.WriteLine(arguements); | ||
//Console.WriteLine(fileName); | ||
//Console.WriteLine(workdir); | ||
var info = new ProcessStartInfo { FileName = fileName, Arguments = arguements, WorkingDirectory = workdir }; | ||
if (logs == "True") | ||
{ | ||
ProcessUtil = new ProcessUtil(new Process { StartInfo = info }); | ||
// create a thread | ||
Thread newWindowThread = new Thread(new ThreadStart(() => | ||
{ | ||
var app = new App(); | ||
app.InitializeComponent(); | ||
app.Dispatcher.Invoke(delegate | ||
{ | ||
app.Run(); | ||
}); | ||
})); | ||
|
||
// set the apartment state | ||
newWindowThread.SetApartmentState(ApartmentState.STA); | ||
|
||
|
||
// start the thread | ||
newWindowThread.Start(); | ||
} | ||
else | ||
{ | ||
Process.Start(info); | ||
} | ||
} | ||
static string GetEnviromentVar(string variableName) | ||
{ | ||
return Environment.GetEnvironmentVariable(variableName); | ||
} | ||
} | ||
public class StartApp | ||
{ | ||
public StartApp() | ||
{ | ||
} | ||
} | ||
public class ProcessUtil | ||
{ | ||
public event EventHandler<string>? OutputReceived; | ||
public event EventHandler? Exited; | ||
|
||
public Process Process { get; private set; } | ||
|
||
public ProcessUtil(Process process) | ||
{ | ||
this.Process = process; | ||
} | ||
|
||
public void StartWithEvents() | ||
{ | ||
Process.StartInfo.CreateNoWindow = true; | ||
Process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
Process.StartInfo.UseShellExecute = false; | ||
Process.StartInfo.RedirectStandardError = true; | ||
Process.StartInfo.RedirectStandardOutput = true; | ||
Process.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8; | ||
Process.StartInfo.StandardErrorEncoding = System.Text.Encoding.UTF8; | ||
Process.EnableRaisingEvents = true; | ||
Process.ErrorDataReceived += (s, e) => OutputReceived?.Invoke(this, e.Data ?? ""); | ||
Process.OutputDataReceived += (s, e) => OutputReceived?.Invoke(this, e.Data ?? ""); | ||
Process.Exited += (s, e) => Exited?.Invoke(this, new EventArgs()); | ||
|
||
Process.Start(); | ||
Process.BeginErrorReadLine(); | ||
Process.BeginOutputReadLine(); | ||
} | ||
|
||
public Task WaitForExitTaskAsync() | ||
{ | ||
return Task.Run(() => | ||
{ | ||
Process.WaitForExit(); | ||
}); | ||
} | ||
} | ||
} |
Binary file not shown.
Oops, something went wrong.