Projektdateien hinzufügen.
This commit is contained in:
40
Valheim Mod Sync Desktop/Views/FTP.xaml
Normal file
40
Valheim Mod Sync Desktop/Views/FTP.xaml
Normal file
@@ -0,0 +1,40 @@
|
||||
<UserControl x:Class="Valheim_Mod_Sync_Desktop.Views.FTP"
|
||||
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
TextElement.FontWeight="Medium"
|
||||
TextElement.FontSize="14"
|
||||
FontFamily="{materialDesign:MaterialDesignFont}"
|
||||
xmlns:local="clr-namespace:Valheim_Mod_Sync_Desktop"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="356" d:DesignWidth="800"
|
||||
>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="10">
|
||||
<Button Content="Aktualisieren" Click="LoadFileList_Click"/>
|
||||
<Button Content="Download" Click="DownloadButton_Click"/>
|
||||
<Button Content="Upload" Click="UploadButton_Click"/>
|
||||
<Button Content="Löschen" Click="DeleteButton_Click"/>
|
||||
<Button Content="Bearbeiten" Click="EditButton_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
<ListView x:Name="fileList" SelectionChanged="FileList_SelectionChanged" Margin="0,0,0,243" Grid.Row="1">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" />
|
||||
<GridViewColumn Header="Typ" DisplayMemberBinding="{Binding Type}" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
<Button Content="Zurück" Click="BackButton_Click" HorizontalAlignment="Left" Margin="486,0,0,0" VerticalAlignment="Center" />
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
259
Valheim Mod Sync Desktop/Views/FTP.xaml.cs
Normal file
259
Valheim Mod Sync Desktop/Views/FTP.xaml.cs
Normal file
@@ -0,0 +1,259 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Microsoft.Win32;
|
||||
using Renci.SshNet;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Valheim_Mod_Sync_Desktop.Views
|
||||
{
|
||||
|
||||
public partial class FTP : System.Windows.Controls.UserControl
|
||||
{
|
||||
private string ftpUrl = "amp.tbs-server.de";
|
||||
private int port = 2229;
|
||||
private string username = "tbS";
|
||||
private string password = "JLI_._nTH-DyG53Se9";
|
||||
|
||||
public FTP()
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
LoadFileList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private string currentDirectory = "/";
|
||||
|
||||
private void LoadFileList()
|
||||
{
|
||||
try
|
||||
{
|
||||
var connectionInfo = new ConnectionInfo(ftpUrl, port, username,
|
||||
new PasswordAuthenticationMethod(username, password));
|
||||
|
||||
using (var client = new SftpClient(connectionInfo))
|
||||
{
|
||||
client.Connect();
|
||||
|
||||
var files = client.ListDirectory(currentDirectory)
|
||||
.Where(item => !item.IsDirectory) // Filtern Sie nur Dateien
|
||||
.Select(item => new FTPFile(item.Name)) // Erstellen Sie FTPFile Objekte für jede Datei
|
||||
.ToList();
|
||||
|
||||
fileList.ItemsSource = files;
|
||||
}
|
||||
}
|
||||
catch (SshAuthenticationException authEx)
|
||||
{
|
||||
MessageBox.Show("Fehler bei der Authentifizierung: " + authEx.Message);
|
||||
}
|
||||
catch (SshException sshEx)
|
||||
{
|
||||
MessageBox.Show("Fehler beim Verbinden zum SFTP-Server: " + sshEx.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Allgemeiner Fehler: " + ex.Message);
|
||||
}
|
||||
}
|
||||
private void FileList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var selectedItem = fileList.SelectedItem as FTPFile;
|
||||
if (selectedItem != null && selectedItem.IsDirectory)
|
||||
{
|
||||
currentDirectory += selectedItem.Name + "/";
|
||||
LoadFileList();
|
||||
}
|
||||
}
|
||||
|
||||
private void BackButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (currentDirectory != "/")
|
||||
{
|
||||
currentDirectory = currentDirectory.TrimEnd('/');
|
||||
var lastIndex = currentDirectory.LastIndexOf('/');
|
||||
currentDirectory = currentDirectory.Substring(0, lastIndex + 1);
|
||||
LoadFileList();
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadFileList_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LoadFileList();
|
||||
}
|
||||
|
||||
private void DownloadButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FTPFile selectedFile = fileList.SelectedItem as FTPFile;
|
||||
if (selectedFile != null)
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
saveFileDialog.FileName = selectedFile.Name;
|
||||
|
||||
if (saveFileDialog.ShowDialog() == true)
|
||||
{
|
||||
string localFilePath = saveFileDialog.FileName;
|
||||
|
||||
try
|
||||
{
|
||||
// FTP-Verbindung herstellen
|
||||
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUrl + selectedFile.Name);
|
||||
request.Method = WebRequestMethods.Ftp.DownloadFile;
|
||||
request.Credentials = new NetworkCredential(username, password);
|
||||
|
||||
// Datei herunterladen
|
||||
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
|
||||
using (Stream responseStream = response.GetResponseStream())
|
||||
using (FileStream localFileStream = new FileStream(localFilePath, FileMode.Create))
|
||||
{
|
||||
responseStream.CopyTo(localFileStream);
|
||||
}
|
||||
|
||||
MessageBox.Show("Datei erfolgreich heruntergeladen!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Fehler beim Herunterladen der Datei: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UploadButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
if (openFileDialog.ShowDialog() == true)
|
||||
{
|
||||
string localFilePath = openFileDialog.FileName;
|
||||
string fileName = Path.GetFileName(localFilePath);
|
||||
|
||||
try
|
||||
{
|
||||
// FTP-Verbindung herstellen
|
||||
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUrl + fileName);
|
||||
request.Method = WebRequestMethods.Ftp.UploadFile;
|
||||
request.Credentials = new NetworkCredential(username, password);
|
||||
|
||||
// Dateiinhalt lesen
|
||||
byte[] fileContents = File.ReadAllBytes(localFilePath);
|
||||
// Anfrage vorbereiten
|
||||
using (Stream requestStream = request.GetRequestStream())
|
||||
{
|
||||
// Dateiinhalt auf den FTP-Server hochladen
|
||||
requestStream.Write(fileContents, 0, fileContents.Length);
|
||||
}
|
||||
|
||||
MessageBox.Show("Datei erfolgreich hochgeladen!");
|
||||
LoadFileList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Fehler beim Hochladen der Datei: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FTPFile selectedFile = fileList.SelectedItem as FTPFile;
|
||||
if (selectedFile != null)
|
||||
{
|
||||
if (MessageBox.Show("Möchten Sie die Datei '" + selectedFile.Name + "' wirklich löschen?", "Löschen bestätigen", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
// FTP-Verbindung herstellen
|
||||
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUrl + selectedFile.Name);
|
||||
request.Method = WebRequestMethods.Ftp.DeleteFile;
|
||||
request.Credentials = new NetworkCredential(username, password);
|
||||
|
||||
// Datei löschen
|
||||
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
|
||||
{
|
||||
MessageBox.Show("Datei erfolgreich gelöscht!");
|
||||
LoadFileList();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Fehler beim Löschen der Datei: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EditButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FTPFile selectedFile = fileList.SelectedItem as FTPFile;
|
||||
if (selectedFile != null && selectedFile.IsEditable)
|
||||
{
|
||||
try
|
||||
{
|
||||
// FTP-Verbindung herstellen
|
||||
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUrl + selectedFile.Name);
|
||||
request.Method = WebRequestMethods.Ftp.DownloadFile;
|
||||
request.Credentials = new NetworkCredential(username, password);
|
||||
|
||||
// Datei herunterladen
|
||||
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
|
||||
using (Stream responseStream = response.GetResponseStream())
|
||||
using (StreamReader reader = new StreamReader(responseStream))
|
||||
{
|
||||
string fileContent = reader.ReadToEnd();
|
||||
|
||||
// Hier können Sie den Dateiinhalt bearbeiten
|
||||
// ...
|
||||
|
||||
// Beispiel: Anzeigen des bearbeiteten Inhalts in einem Dialogfeld
|
||||
MessageBox.Show("Bearbeiteter Inhalt:\n\n" + fileContent);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Fehler beim Bearbeiten der Datei: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FTPFile
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public bool IsDirectory { get; set; }
|
||||
public bool IsEditable { get; set; }
|
||||
|
||||
public FTPFile(string line)
|
||||
{
|
||||
var fileInfo = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var isDirectory = fileInfo[0][0] == 'd';
|
||||
|
||||
// Setze Name-Eigenschaft
|
||||
Name = fileInfo[fileInfo.Length - 1];
|
||||
|
||||
// Setze IsDirectory-Eigenschaft
|
||||
IsDirectory = isDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
155
Valheim Mod Sync Desktop/Views/Kontakt.xaml
Normal file
155
Valheim Mod Sync Desktop/Views/Kontakt.xaml
Normal file
@@ -0,0 +1,155 @@
|
||||
<UserControl x:Class="Valheim_Mod_Sync_Desktop.Views.Kontakt"
|
||||
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
TextElement.FontWeight="Medium"
|
||||
TextElement.FontSize="14"
|
||||
FontFamily="{materialDesign:MaterialDesignFont}"
|
||||
xmlns:local="clr-namespace:Valheim_Mod_Sync_Desktop"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="381" d:DesignWidth="800"
|
||||
>
|
||||
<Grid
|
||||
Background="{DynamicResource BackgroundGrid}"
|
||||
>
|
||||
|
||||
<Button
|
||||
x:Name="Send"
|
||||
Content="{DynamicResource KontaktSenden}"
|
||||
Click="Send_Click"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,342,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Background="{DynamicResource ButtonBackgroundColor}"
|
||||
BorderBrush="{DynamicResource ButtonBackgroundColor}"
|
||||
Foreground="{DynamicResource ButtonTextColor}" Cursor="Hand"
|
||||
/>
|
||||
|
||||
<TextBox
|
||||
x:Name="Message"
|
||||
TextWrapping="Wrap"
|
||||
Width="770"
|
||||
Margin="15,91,15,54"
|
||||
Background="{DynamicResource TextBoxBackgroundColor}"
|
||||
BorderBrush="{x:Null}"
|
||||
Foreground="{DynamicResource TextBoxTextColor}"
|
||||
SelectionTextBrush="{x:Null}"
|
||||
SelectionBrush="{DynamicResource TextBoxBackgroundColor}"
|
||||
CaretBrush="{x:Null}"
|
||||
Cursor="IBeam"
|
||||
Padding="10 10 10 10"
|
||||
/>
|
||||
<RadioButton
|
||||
x:Name="Bug"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="109,9,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Background="{DynamicResource HeaderTextColor}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
IsChecked="true"
|
||||
>
|
||||
<RadioButton.Content>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
Text="{DynamicResource KontaktFehler}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource HeaderTextColor}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
Margin="0, -3, 0, 0"
|
||||
/>
|
||||
</RadioButton.Content>
|
||||
</RadioButton>
|
||||
<RadioButton
|
||||
x:Name="Suggestion"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="194,9,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Background="{DynamicResource HeaderTextColor}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
>
|
||||
<RadioButton.Content>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
Text="{DynamicResource KontaktVorschlag}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource HeaderTextColor}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
Margin="0,-3,0,0"
|
||||
/>
|
||||
</RadioButton.Content>
|
||||
</RadioButton>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="15,10,0,0"
|
||||
Text="{DynamicResource KontaktBetreff}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource HeaderTextColor}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
/>
|
||||
|
||||
<TextBox
|
||||
x:Name="Name"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="69,35,0,0"
|
||||
Text=""
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
Width="288"
|
||||
Background="{DynamicResource TextBoxBackgroundColor}"
|
||||
BorderBrush="{x:Null}"
|
||||
Foreground="{DynamicResource TextBoxTextColor}" Cursor="IBeam"
|
||||
/>
|
||||
|
||||
<Label
|
||||
Content="{DynamicResource KontaktName}"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="15,35,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource HeaderTextColor}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="Email"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="431,35,0,0"
|
||||
Text=""
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
Width="354"
|
||||
Background="{DynamicResource TextBoxBackgroundColor}"
|
||||
BorderBrush="{x:Null}"
|
||||
Foreground="{DynamicResource TextBoxTextColor}"
|
||||
/>
|
||||
<Label
|
||||
Content="{DynamicResource KontaktEmail}"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,35,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource HeaderTextColor}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
/>
|
||||
<Label
|
||||
Content="{DynamicResource KontaktNachricht}"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="15,65,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource HeaderTextColor}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
/>
|
||||
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
188
Valheim Mod Sync Desktop/Views/Kontakt.xaml.cs
Normal file
188
Valheim Mod Sync Desktop/Views/Kontakt.xaml.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Valheim_Mod_Sync_Desktop.ViewModels;
|
||||
|
||||
namespace Valheim_Mod_Sync_Desktop.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für BugSuggestion.xaml
|
||||
/// </summary>
|
||||
public partial class Kontakt : UserControl
|
||||
{
|
||||
public Kontakt()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private async void Send_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var Betreff = "";
|
||||
if (Bug.IsChecked == true)
|
||||
{
|
||||
Betreff = "Fehler";
|
||||
}else
|
||||
{
|
||||
Betreff = "Vorschlag";
|
||||
}
|
||||
|
||||
bool name = false;
|
||||
bool email = false;
|
||||
bool message = false;
|
||||
bool send = false;
|
||||
bool keininternet = false;
|
||||
bool error = false;
|
||||
|
||||
if (Name.Text == "")
|
||||
{
|
||||
name = true;
|
||||
}
|
||||
|
||||
if (Email.Text == "" | !Email.Text.Contains('@') | !Email.Text.Contains('.'))
|
||||
{
|
||||
email = true;
|
||||
}
|
||||
|
||||
if (Message.Text == "")
|
||||
{
|
||||
message = true;
|
||||
}
|
||||
|
||||
if (!SyncControl.IsConnectionAvailable())
|
||||
|
||||
{
|
||||
keininternet = true;
|
||||
|
||||
var mailcomplete = new MailComplete
|
||||
{
|
||||
Name = Name.Text,
|
||||
Email = Email.Text,
|
||||
Betreff = Betreff,
|
||||
Message = Message.Text
|
||||
};
|
||||
|
||||
string fileName = "Message.json";
|
||||
string jsonString = JsonSerializer.Serialize(mailcomplete);
|
||||
File.WriteAllText(fileName, jsonString);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (Name.Text != "" && Email.Text != "" && Email.Text.Contains('@') && Email.Text.Contains('.') && Message.Text != "" && !keininternet)
|
||||
{
|
||||
send = true;
|
||||
}
|
||||
|
||||
|
||||
if (send)
|
||||
{
|
||||
|
||||
var values = new Dictionary<string, string>
|
||||
{
|
||||
{ "Betreff", "VMS : "+ Betreff},
|
||||
{ "Message", Message.Text },
|
||||
{ "Name", Name.Text },
|
||||
{ "Email", Email.Text }
|
||||
};
|
||||
try {
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
//var content = new FormUrlEncodedContent(values);
|
||||
|
||||
var jsonDictionary = JsonSerializer.Serialize(values);
|
||||
var content = new StringContent(jsonDictionary, Encoding.UTF8, "application/json");
|
||||
var response = await client.PostAsync("https://vms.tbs-server.de/", content);
|
||||
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
Debug.WriteLine(responseString);
|
||||
}catch
|
||||
{
|
||||
error = true;
|
||||
var mailcomplete = new MailComplete
|
||||
{
|
||||
Name = Name.Text,
|
||||
Email = Email.Text,
|
||||
Betreff = Betreff,
|
||||
Message = Message.Text
|
||||
};
|
||||
|
||||
string fileName = "Message.json";
|
||||
string jsonString = JsonSerializer.Serialize(mailcomplete);
|
||||
File.WriteAllText(fileName, jsonString);
|
||||
}
|
||||
}
|
||||
|
||||
if (name | email | message | send | keininternet | error )
|
||||
{
|
||||
//DataContext = new MainViewModel();
|
||||
//MainWindow mainWindow = new MainWindow();
|
||||
//mainWindow.contentControl.Content = new SyncControl();
|
||||
|
||||
|
||||
Benachrichtigung modalWindow = new Benachrichtigung(name, email, message, send, keininternet, error, false, false);
|
||||
modalWindow.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task MessageSend()
|
||||
{
|
||||
bool error = false;
|
||||
|
||||
string fileName = "Message.json";
|
||||
MailComplete mail_read = JsonSerializer.Deserialize<MailComplete>(File.ReadAllText(fileName));
|
||||
|
||||
|
||||
var values = new Dictionary<string, string>
|
||||
{
|
||||
{ "Betreff", "VMS : "+ mail_read.Betreff},
|
||||
{ "Message", mail_read.Message},
|
||||
{ "Name", mail_read.Name},
|
||||
{ "Email", mail_read.Email}
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
//var content = new FormUrlEncodedContent(values);
|
||||
var jsonDictionary = JsonSerializer.Serialize(values);
|
||||
var content = new StringContent(jsonDictionary, Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await client.PostAsync("https://vms.tbs-server.de/", content);
|
||||
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
|
||||
}catch
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
|
||||
bool send = false;
|
||||
|
||||
if (!error)
|
||||
{
|
||||
send = true;
|
||||
File.Delete("Message.json");
|
||||
}
|
||||
|
||||
Benachrichtigung modalWindow = new Benachrichtigung(false, false, false, send, false, error, false, false);
|
||||
modalWindow.ShowDialog();
|
||||
|
||||
}
|
||||
|
||||
public class MailComplete
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Betreff { get; set; }
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
59
Valheim Mod Sync Desktop/Views/Lizenzen.xaml
Normal file
59
Valheim Mod Sync Desktop/Views/Lizenzen.xaml
Normal file
@@ -0,0 +1,59 @@
|
||||
<UserControl x:Class="Valheim_Mod_Sync_Desktop.Views.Lizenzen"
|
||||
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
TextElement.FontWeight="Medium"
|
||||
TextElement.FontSize="14"
|
||||
FontFamily="{materialDesign:MaterialDesignFont}"
|
||||
xmlns:local="clr-namespace:Valheim_Mod_Sync_Desktop"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="356" d:DesignWidth="800"
|
||||
>
|
||||
|
||||
<Grid
|
||||
Background="{DynamicResource BackgroundGrid}"
|
||||
>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
|
||||
<ListView x:Name="fileList" Margin="0,0,0,0" Grid.Row="0" BorderBrush="Black" BorderThickness="1">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridView.ColumnHeaderContainerStyle>
|
||||
<Style TargetType="{x:Type GridViewColumnHeader}">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="BorderBrush" Value="Black"/>
|
||||
</Style>
|
||||
</GridView.ColumnHeaderContainerStyle>
|
||||
<GridViewColumn Header="Lizenz" DisplayMemberBinding="{Binding Name}" Width="250" />
|
||||
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Typ1e}" Width="150"/>
|
||||
<GridViewColumn Header="Aktivierungsstatus" DisplayMemberBinding="{Binding Typ2e}" Width="250"/>
|
||||
<GridViewColumn Header="" DisplayMemberBinding="{Binding Typ3e}" Width="150"/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
|
||||
|
||||
<Button
|
||||
Content="Übernehmen"
|
||||
Click="Übernehmen_Click"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Top"
|
||||
Grid.Row="1"
|
||||
Background="{DynamicResource ButtonBackgroundColor}"
|
||||
BorderBrush="{DynamicResource ButtonBackgroundColor}"
|
||||
Foreground="{DynamicResource ButtonTextColor}"
|
||||
Cursor="Hand"
|
||||
Margin="0,257,0,0" RenderTransformOrigin="0.477,-8.399"
|
||||
/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
47
Valheim Mod Sync Desktop/Views/Lizenzen.xaml.cs
Normal file
47
Valheim Mod Sync Desktop/Views/Lizenzen.xaml.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Microsoft.Win32;
|
||||
using Renci.SshNet;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Valheim_Mod_Sync_Desktop.Views
|
||||
{
|
||||
|
||||
public partial class Lizenzen : System.Windows.Controls.UserControl
|
||||
{
|
||||
|
||||
public Lizenzen()
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void Übernehmen_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
73
Valheim Mod Sync Desktop/Views/Setup.xaml
Normal file
73
Valheim Mod Sync Desktop/Views/Setup.xaml
Normal file
@@ -0,0 +1,73 @@
|
||||
<UserControl x:Class="Valheim_Mod_Sync_Desktop.Views.Setup"
|
||||
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
TextElement.FontWeight="Medium"
|
||||
TextElement.FontSize="14"
|
||||
FontFamily="{materialDesign:MaterialDesignFont}"
|
||||
xmlns:local="clr-namespace:Valheim_Mod_Sync_Desktop"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="381" d:DesignWidth="800"
|
||||
>
|
||||
|
||||
<Grid
|
||||
Background="{DynamicResource BackgroundGrid}"
|
||||
>
|
||||
|
||||
<Button
|
||||
x:Name="SetupBeenden"
|
||||
Content="{DynamicResource SetupIPWeiter}"
|
||||
Click="SetupIPUebertragen"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,343,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Background="{DynamicResource ButtonBackgroundColor}"
|
||||
BorderBrush="{DynamicResource ButtonBackgroundColor}"
|
||||
Foreground="{DynamicResource ButtonTextColor}" Cursor="Hand"
|
||||
/>
|
||||
|
||||
<TextBox
|
||||
x:Name="output"
|
||||
TextWrapping="Wrap"
|
||||
Text="{DynamicResource SetupTextAdmin}"
|
||||
Width="770"
|
||||
Margin="15,54,15,54"
|
||||
Background="{DynamicResource TextBoxBackgroundColor}"
|
||||
BorderBrush="{x:Null}"
|
||||
Foreground="{DynamicResource TextBoxTextColor}"
|
||||
SelectionTextBrush="{x:Null}"
|
||||
SelectionBrush="{x:Null}"
|
||||
CaretBrush="{x:Null}"
|
||||
IsReadOnly="True" Cursor="IBeam"
|
||||
/>
|
||||
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="15,19,0,0"
|
||||
Text="{DynamicResource Server}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource HeaderTextColor}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
/>
|
||||
|
||||
<TextBox
|
||||
x:Name="ServerIP"
|
||||
IsReadOnly="false"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="114,16,0,0"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
Width="671"
|
||||
Background="{DynamicResource TextBoxBackgroundColor}"
|
||||
SelectionTextBrush="{x:Null}"
|
||||
SelectionBrush="{x:Null}"
|
||||
Foreground="{DynamicResource TextBoxTextColor}"
|
||||
BorderBrush="{x:Null}"
|
||||
FontSize="14" Cursor="IBeam"
|
||||
/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
113
Valheim Mod Sync Desktop/Views/Setup.xaml.cs
Normal file
113
Valheim Mod Sync Desktop/Views/Setup.xaml.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
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 Valheim_Mod_Sync_Desktop.Commands;
|
||||
using Valheim_Mod_Sync_Desktop.ViewModels;
|
||||
|
||||
namespace Valheim_Mod_Sync_Desktop.Views
|
||||
{
|
||||
public class LizenzIPReturn
|
||||
{
|
||||
public string admin { get; set; }
|
||||
public string IP_Alt { get; set; }
|
||||
public string IP { get; set; }
|
||||
}
|
||||
|
||||
public partial class Setup : UserControl
|
||||
{
|
||||
public Setup()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
private void SetupIPUebertragen(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (ServerIP.Text == null || !ServerIP.Text.Contains(":"))
|
||||
{
|
||||
output.Text += (string)Application.Current.FindResource("SetupIPFehler");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var LizenzKey = Properties.Settings.Default.Lizenz;
|
||||
var ServerIPClean = ServerIP.Text.Replace(" ", "");
|
||||
|
||||
try
|
||||
{
|
||||
string html = string.Empty;
|
||||
string url = @"https://tbs-server.de//wp-json/lmfwc/v2/vms/check_server_ip/" + LizenzKey + "/" + ServerIPClean;
|
||||
string encoded = System.Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1")
|
||||
.GetBytes(Properties.Settings.Default.benutzername + ":" + Properties.Settings.Default.passwort));
|
||||
|
||||
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.AutomaticDecompression = DecompressionMethods.GZip;
|
||||
request.Headers.Add("Authorization", "Basic " + encoded);
|
||||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||
using (Stream stream = response.GetResponseStream())
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
html = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
LizenzIPReturn lizenzip_return = JsonSerializer.Deserialize<LizenzIPReturn>(html);
|
||||
//Debug.WriteLine(lizenz_return.success);
|
||||
//Debug.WriteLine(lizenz_return.data.timesActivated);
|
||||
//Debug.WriteLine(lizenz_return.data.timesActivatedMax);
|
||||
//Debug.WriteLine(lizenz_return.data.remainingActivations);
|
||||
//Debug.WriteLine(lizenz_return.data.hwid);
|
||||
//Debug.WriteLine(html);
|
||||
|
||||
if (lizenzip_return.IP_Alt != lizenzip_return.IP)
|
||||
{
|
||||
|
||||
output.Text += (string)Application.Current.FindResource("ServerIPUebertragen");
|
||||
ServerIP.IsEnabled = false;
|
||||
SetupBeenden.Content = Application.Current.FindResource("SetupBeenden");
|
||||
SetupBeenden.Click -= new RoutedEventHandler(SetupIPUebertragen);
|
||||
SetupBeenden.Click += new RoutedEventHandler(SetupBeenden_);
|
||||
Properties.Settings.Default.Server = ServerIPClean;
|
||||
Properties.Settings.Default.ModVersion = 0;
|
||||
Properties.Settings.Default.Save();
|
||||
MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
|
||||
mainWindow.Server.Text = ServerIPClean;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
output.Text += (string)Application.Current.FindResource("ServerIPUebertragenFehler");
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex);
|
||||
//output.Text = (string)Application.Current.FindResource("LizenzKeyFehler");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupBeenden_(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MainViewModel mainViewModel = (MainViewModel)Application.Current.MainWindow.DataContext;
|
||||
mainViewModel.SelectedViewModel = new SyncViewModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
95
Valheim Mod Sync Desktop/Views/SyncControl.xaml
Normal file
95
Valheim Mod Sync Desktop/Views/SyncControl.xaml
Normal file
@@ -0,0 +1,95 @@
|
||||
<UserControl x:Class="Valheim_Mod_Sync_Desktop.Views.SyncControl"
|
||||
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
TextElement.FontWeight="Medium"
|
||||
TextElement.FontSize="14"
|
||||
FontFamily="{materialDesign:MaterialDesignFont}"
|
||||
xmlns:local="clr-namespace:Valheim_Mod_Sync_Desktop"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="381" d:DesignWidth="800"
|
||||
>
|
||||
|
||||
<Grid
|
||||
Background="{DynamicResource BackgroundGrid}"
|
||||
>
|
||||
|
||||
<Button
|
||||
x:Name="Sync_Update"
|
||||
Content="{DynamicResource Sync}"
|
||||
Click="Sync"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,343,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Background="{DynamicResource ButtonBackgroundColor}"
|
||||
BorderBrush="{DynamicResource ButtonBackgroundColor}"
|
||||
Foreground="{DynamicResource ButtonTextColor}" Cursor="Hand"
|
||||
/>
|
||||
|
||||
<TextBox
|
||||
x:Name="output"
|
||||
TextWrapping="Wrap"
|
||||
Width="770"
|
||||
Margin="15,54,15,54"
|
||||
Background="{DynamicResource TextBoxBackgroundColor}"
|
||||
BorderBrush="{x:Null}"
|
||||
Foreground="{DynamicResource TextBoxTextColor}"
|
||||
SelectionTextBrush="{x:Null}"
|
||||
SelectionBrush="{x:Null}"
|
||||
CaretBrush="{x:Null}"
|
||||
IsReadOnly="True" Cursor="IBeam"
|
||||
/>
|
||||
|
||||
<Label
|
||||
x:Name="Changelog"
|
||||
Content="{DynamicResource Changelog}"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="656,350,0,0"
|
||||
VerticalAlignment="Top"
|
||||
MouseLeftButtonDown="Changelog_MouseLeftButtonDown"
|
||||
Foreground="{DynamicResource ButtonTextColor}" Cursor="Hand"
|
||||
/>
|
||||
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="15,19,0,0"
|
||||
Text="{DynamicResource ValheimPfad}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource HeaderTextColor}"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
/>
|
||||
|
||||
<TextBox
|
||||
x:Name="Pfad"
|
||||
IsReadOnly="True"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="114,16,0,0"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
Width="554"
|
||||
Background="{DynamicResource TextBoxBackgroundColor}"
|
||||
SelectionTextBrush="{x:Null}"
|
||||
SelectionBrush="{x:Null}"
|
||||
Foreground="{DynamicResource TextBoxTextColor}"
|
||||
BorderBrush="{x:Null}"
|
||||
FontSize="14" Cursor="IBeam"
|
||||
/>
|
||||
|
||||
<Button
|
||||
x:Name="Auswählen_Pfad"
|
||||
Content="{DynamicResource PfadButton}"
|
||||
Click="Auswählen_Pfad_Click"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="684,16,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource ButtonTextColor}"
|
||||
Background="{DynamicResource ButtonBackgroundColor}"
|
||||
BorderBrush="{DynamicResource ButtonBackgroundColor}"
|
||||
Height="24" Cursor="Hand"
|
||||
/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
1158
Valheim Mod Sync Desktop/Views/SyncControl.xaml.cs
Normal file
1158
Valheim Mod Sync Desktop/Views/SyncControl.xaml.cs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user