Initial commit
This commit is contained in:
249
Valheim Dashboard/Views/ServerSettingsView.axaml.cs
Normal file
249
Valheim Dashboard/Views/ServerSettingsView.axaml.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Tmds.DBus.Protocol;
|
||||
using Valheim_Dashboard.ViewModels;
|
||||
|
||||
namespace Valheim_Dashboard.Views;
|
||||
|
||||
public partial class ServerSettingsView : UserControl
|
||||
{
|
||||
|
||||
|
||||
private TutorialManager _tutorialManager;
|
||||
|
||||
public ServerSettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.Initialized += (sender, e) =>
|
||||
{
|
||||
var window = this.VisualRoot as Window;
|
||||
|
||||
if (window == null)
|
||||
throw new InvalidOperationException("Das übergeordnete Element ist kein Fenster.");
|
||||
|
||||
// TutorialManager direkt im Code-Behind initialisieren
|
||||
_tutorialManager = new TutorialManager(window);
|
||||
|
||||
// Beispiel: Ein Tutorial starten
|
||||
// StartTutorial();
|
||||
};
|
||||
}
|
||||
|
||||
public void StartTutorial()
|
||||
{
|
||||
var pluginExpander = Plugin;
|
||||
var pluginIpTextBox = plugin_ip;
|
||||
var pluginPortTextBox = plugin_port;
|
||||
var pluginUeberpruefen = plugin_prüfen;
|
||||
var ftpExpander = FTP;
|
||||
var ftpIpTextBox = ftp_ip;
|
||||
var ftpPortTextBox = ftp_port;
|
||||
var ftpBenutzernameTextBox = ftp_benutzername;
|
||||
var ftpPasswortTextBox = ftp_passwort;
|
||||
var ftpUeberpruefen = ftp_prüfen;
|
||||
|
||||
// Schritt 1: Sprechblase anzeigen: Öffnen des Plugin-Expanders oder FTP-Expanders
|
||||
_tutorialManager.HighlightElement(pluginExpander, new SolidColorBrush(Colors.Yellow));
|
||||
_tutorialManager.HighlightElement(ftpExpander, new SolidColorBrush(Colors.Yellow));
|
||||
_tutorialManager.ShowSpeechBubble(pluginExpander, TutorialManager.SpeechBubblePosition.Top, Language.GetString("Server_Schritt_1"), () =>
|
||||
{
|
||||
// Schritt 2: Plugin-Expander öffnen und Sprechblase ändern
|
||||
_tutorialManager.OpenExpander(pluginExpander);
|
||||
_tutorialManager.HighlightElement(pluginExpander, new SolidColorBrush(Colors.Transparent));
|
||||
_tutorialManager.HighlightElement(ftpExpander, new SolidColorBrush(Colors.Transparent));
|
||||
// Beide Felder hervorheben
|
||||
_tutorialManager.HighlightElement(pluginIpTextBox, new SolidColorBrush(Colors.LightBlue));
|
||||
_tutorialManager.HighlightElement(pluginPortTextBox, new SolidColorBrush(Colors.LightBlue));
|
||||
|
||||
_tutorialManager.ShowSpeechBubble(pluginExpander, TutorialManager.SpeechBubblePosition.Right,Language.GetString("Server_Schritt_2"), () =>
|
||||
{
|
||||
// Schritt 3: Beispielwerte in IP- und Port-Felder eintragen
|
||||
pluginIpTextBox.Text = "127.0.0.1";
|
||||
pluginPortTextBox.Text = "2456";
|
||||
_tutorialManager.HighlightElement(pluginUeberpruefen, new SolidColorBrush(Colors.LightBlue));
|
||||
|
||||
|
||||
|
||||
// Nächste Sprechblase: Warten auf Weiter!
|
||||
_tutorialManager.ShowSpeechBubble(pluginExpander, TutorialManager.SpeechBubblePosition.Right,Language.GetString("Server_Schritt_3"), () =>
|
||||
{
|
||||
// Schritt 4: Nächste Aktion einleiten (falls notwendig)
|
||||
_tutorialManager.ClickButton(pluginUeberpruefen);
|
||||
Task.Delay(2000);
|
||||
pluginUeberpruefen.Background = new SolidColorBrush(Colors.Green);
|
||||
pluginUeberpruefen.Content = "Erfolgreich Verbunden!";
|
||||
|
||||
_tutorialManager.ShowSpeechBubble(ftpExpander, TutorialManager.SpeechBubblePosition.Left,
|
||||
Language.GetString("Server_Schritt_4"),
|
||||
() =>
|
||||
{
|
||||
_tutorialManager.CloseExpander(pluginExpander);
|
||||
_tutorialManager.HighlightElement(pluginIpTextBox, new SolidColorBrush(Colors.Transparent));
|
||||
_tutorialManager.HighlightElement(pluginPortTextBox, new SolidColorBrush(Colors.Transparent));
|
||||
_tutorialManager.HighlightElement(pluginUeberpruefen, new SolidColorBrush(Colors.Transparent));
|
||||
pluginIpTextBox.Text = "";
|
||||
pluginPortTextBox.Text = "";
|
||||
pluginUeberpruefen.Background = new SolidColorBrush(Colors.Gray);
|
||||
pluginUeberpruefen.Content = "Verbindung Prüfen";
|
||||
_tutorialManager.OpenExpander(ftpExpander);
|
||||
_tutorialManager.HighlightElement(ftpIpTextBox, new SolidColorBrush(Colors.LightBlue));
|
||||
_tutorialManager.HighlightElement(ftpPortTextBox, new SolidColorBrush(Colors.LightBlue));
|
||||
_tutorialManager.HighlightElement(ftpBenutzernameTextBox, new SolidColorBrush(Colors.LightBlue));
|
||||
_tutorialManager.HighlightElement(ftpPasswortTextBox, new SolidColorBrush(Colors.LightBlue));
|
||||
|
||||
_tutorialManager.ShowSpeechBubble(ftpExpander, TutorialManager.SpeechBubblePosition.Left,
|
||||
Language.GetString("Server_Schritt_5"),
|
||||
async () =>
|
||||
{
|
||||
|
||||
_tutorialManager.WriteText(ftpIpTextBox, "127.0.0.1");
|
||||
_tutorialManager.WriteText(ftpPortTextBox, "21");
|
||||
_tutorialManager.WriteText(ftpBenutzernameTextBox, "ftpUser");
|
||||
_tutorialManager.WriteText(ftpPasswortTextBox, "123456789");
|
||||
|
||||
await _tutorialManager.SmoothScrollToControl(ftp_scroll, ftpUeberpruefen);
|
||||
Task.Delay(2000);
|
||||
|
||||
_tutorialManager.ClickButton(ftpUeberpruefen);
|
||||
ftpUeberpruefen.Background = new SolidColorBrush(Colors.Green);
|
||||
ftpUeberpruefen.Content = "Verbindung Erfolgreich";
|
||||
|
||||
_tutorialManager.ShowSpeechBubble(ftpExpander,
|
||||
TutorialManager.SpeechBubblePosition.Left,
|
||||
Language.GetString("Server_Schritt_6"),
|
||||
() =>
|
||||
{
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
private void Weiter_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.Parent.Parent.Parent is MainWindow mainWindow) {
|
||||
if (mainWindow.DataContext is MainWindowViewModel mainWindowViewModel)
|
||||
{
|
||||
|
||||
mainWindowViewModel.SwitchToFTP(ftpClient);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DataPluginJson
|
||||
{
|
||||
public string ModVersion { get; set; }
|
||||
public string PluginVersion { get; set; }
|
||||
public string HashPlugins { get; set; }
|
||||
public string HashConfig { get; set; }
|
||||
public string HashClientSide { get; set; }
|
||||
public string OldConfigFiles { get; set; }
|
||||
public string OldConfigFolder { get; set; }
|
||||
public string OldConfigFolderFiles { get; set; }
|
||||
public string OldPluginFiles { get; set; }
|
||||
public string OldPluginFolder { get; set; }
|
||||
public string OldPluginFolderFiles { get; set; }
|
||||
public string ConfigFilestoDelete { get; set; }
|
||||
public string ConfigFoldertoDelete { get; set; }
|
||||
public string ConfigFolderFilestoDelete { get; set; }
|
||||
public string PluginFilestoDelete { get; set; }
|
||||
public string PluginFoldertoDelete { get; set; }
|
||||
public string PluginFolderFilestoDelete { get; set; }
|
||||
public string OldClientSideConfigFiles { get; set; }
|
||||
public string OldClientSideConfigFolder { get; set; }
|
||||
public string OldClientSideConfigFolderFiles { get; set; }
|
||||
public string OldClientSidePluginFiles { get; set; }
|
||||
public string OldClientSidePluginFolder { get; set; }
|
||||
public string OldClientSidePluginFolderFiles { get; set; }
|
||||
public string ClientSideConfigFilestoDelete { get; set; }
|
||||
public string ClientSideConfigFoldertoDelete { get; set; }
|
||||
public string ClientSideConfigFolderFilestoDelete { get; set; }
|
||||
public string ClientSidePluginFilestoDelete { get; set; }
|
||||
public string ClientSidePluginFoldertoDelete { get; set; }
|
||||
public string ClientSidePluginFolderFilestoDelete { get; set; }
|
||||
}
|
||||
|
||||
|
||||
private async void Plugin_prüfen_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
HttpClient PluginClient = new HttpClient();
|
||||
|
||||
try
|
||||
{
|
||||
var response = await PluginClient.GetAsync("http://amp.tbs-server.de:2456");
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var data = await response.Content.ReadFromJsonAsync<DataPluginJson>();
|
||||
plugin_prüfen.Background = new SolidColorBrush(Colors.Green);
|
||||
plugin_prüfen.Content = "Verbindung Erfolgreich";
|
||||
Debug.WriteLine(data.ModVersion);
|
||||
}else
|
||||
{
|
||||
plugin_prüfen.Background = new SolidColorBrush(Colors.Red);
|
||||
plugin_prüfen.Content = "Verbindung Fehlgeschlagen";
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
plugin_prüfen.Background = new SolidColorBrush(Colors.Red);
|
||||
plugin_prüfen.Content = "Verbindung Fehlgeschlagen";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private FtpClient ftpClient;
|
||||
private async void Ftp_prüfen_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{Console.WriteLine(ftp_ip.Text + ftp_port.Text + ftp_benutzername.Text + ftp_passwort.Text);
|
||||
|
||||
//ftpClient = new FtpClient("ftp://"+ ftp_ip.Text + ":" +ftp_port.Text, ftp_benutzername.Text, ftp_passwort.Text);
|
||||
FtpViewModel._ftpClient = new FtpClient("ftp://192.168.178.34:21", "tbs_ftp", "JLI_._nTH-DyG53Se9");
|
||||
var files = await ftpClient.ListDirectoryDetailsAsync();
|
||||
|
||||
if (files != null && files.Count > 0)
|
||||
{
|
||||
var name = "tbs";
|
||||
ftp_prüfen.Background = new SolidColorBrush(Colors.Green);
|
||||
ftp_prüfen.Content = "Verbindung Erfolgreich1";
|
||||
Console.WriteLine(files);
|
||||
LizenzView.KeyAuthApp.webhook("aHtrWbrxrZ", "&name="+ LizenzView.lizenz_name[1] +"&data=testabc", "");
|
||||
Console.WriteLine(LizenzView.KeyAuthApp.response.message);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ftp_prüfen.Background = new SolidColorBrush(Colors.Green);
|
||||
ftp_prüfen.Content = "Verbindung Erfolgreich2";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Fehler beim Verbinden: {ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user