mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-13 07:24:52 +01:00
add simple installer/uninstaller
This commit is contained in:
42
ServerSelector/Views/MainView.axaml
Normal file
42
ServerSelector/Views/MainView.axaml
Normal file
@@ -0,0 +1,42 @@
|
||||
<UserControl 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"
|
||||
xmlns:vm="clr-namespace:ServerSelector.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="370" d:DesignHeight="170"
|
||||
x:Class="ServerSelector.Views.MainView"
|
||||
x:DataType="vm:MainViewModel"
|
||||
>
|
||||
<Design.DataContext>
|
||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||
<vm:MainViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<StackPanel>
|
||||
<WrapPanel Margin="5">
|
||||
<TextBlock VerticalAlignment="Center" Margin="5">Game path: </TextBlock>
|
||||
<TextBox x:Name="txtGamePath">C:\NIKKE\NIKKE\game</TextBox>
|
||||
</WrapPanel>
|
||||
|
||||
<WrapPanel Margin="5">
|
||||
<TextBlock VerticalAlignment="Center" Margin="5">Launcher path: </TextBlock>
|
||||
<TextBox x:Name="txtLauncherPath">C:\NIKKE\Launcher</TextBox>
|
||||
</WrapPanel>
|
||||
|
||||
|
||||
<WrapPanel Margin="5">
|
||||
<TextBlock VerticalAlignment="Center" Margin="5">Server: </TextBlock>
|
||||
|
||||
<ComboBox SelectedIndex="0" x:Name="CmbServerSelection">
|
||||
<ComboBox.Items>
|
||||
<ComboBoxItem>Official</ComboBoxItem>
|
||||
<ComboBoxItem>Local</ComboBoxItem>
|
||||
</ComboBox.Items>
|
||||
</ComboBox>
|
||||
</WrapPanel>
|
||||
|
||||
<Button HorizontalAlignment="Right" Margin="5" Click="Save_Click">Save</Button>
|
||||
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
37
ServerSelector/Views/MainView.axaml.cs
Normal file
37
ServerSelector/Views/MainView.axaml.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Avalonia.Controls;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace ServerSelector.Views;
|
||||
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
public MainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
CmbServerSelection.SelectedIndex = ServerSwitcher.IsUsingOfficalServer() ? 0 : 1;
|
||||
}
|
||||
|
||||
private void Save_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ServerSwitcher.SaveCfg(CmbServerSelection.SelectedIndex == 0, txtGamePath.Text, txtLauncherPath.Text);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
ShowWarningMsg("Failed to save configuration: " + ex.ToString(), "Error");
|
||||
}
|
||||
}
|
||||
|
||||
// for some stupid reason avalonia does not support message boxes.
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type);
|
||||
|
||||
public static void ShowWarningMsg(string text, string title)
|
||||
{
|
||||
MessageBox(IntPtr.Zero, text, title, 0x00000030);
|
||||
}
|
||||
}
|
||||
12
ServerSelector/Views/MainWindow.axaml
Normal file
12
ServerSelector/Views/MainWindow.axaml
Normal file
@@ -0,0 +1,12 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:ServerSelector.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:views="clr-namespace:ServerSelector.Views"
|
||||
mc:Ignorable="d" d:DesignWidth="370" d:DesignHeight="170"
|
||||
x:Class="ServerSelector.Views.MainWindow"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
Title="Server Switcher Utility" Width="370" Height="170" CanResize="False">
|
||||
<views:MainView />
|
||||
</Window>
|
||||
11
ServerSelector/Views/MainWindow.axaml.cs
Normal file
11
ServerSelector/Views/MainWindow.axaml.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace ServerSelector.Views;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user