2020-06-13 07:27:42 +00:00
|
|
|
|
using GameBaseClassLibrary;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Drawing.Drawing2D;
|
|
|
|
|
using System.Drawing.Imaging;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices.ComTypes;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
using UWUVCI_AIO_WPF.Classes;
|
|
|
|
|
using UWUVCI_AIO_WPF.Properties;
|
2020-10-02 00:38:48 +00:00
|
|
|
|
using Path = System.IO.Path;
|
2020-06-13 07:27:42 +00:00
|
|
|
|
|
|
|
|
|
namespace UWUVCI_AIO_WPF.UI.Windows
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaktionslogik für ImageCreator.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
|
|
public partial class LogoCreator : Window, IDisposable
|
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
private static readonly string tempPath = Path.Combine(Directory.GetCurrentDirectory(), "bin", "temp");
|
|
|
|
|
private static readonly string toolsPath = Path.Combine(Directory.GetCurrentDirectory(), "bin", "Tools");
|
2020-06-13 07:27:42 +00:00
|
|
|
|
BootLogoImage bi = new BootLogoImage();
|
|
|
|
|
Bitmap b;
|
|
|
|
|
string console = "other";
|
|
|
|
|
bool drc = false;
|
2020-07-23 23:12:12 +00:00
|
|
|
|
private bool _disposed;
|
2020-06-13 07:27:42 +00:00
|
|
|
|
|
|
|
|
|
public LogoCreator()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
imageName.Content = "bootLogoTex";
|
|
|
|
|
SetTemplate();
|
2020-06-13 15:53:59 +00:00
|
|
|
|
t_Copy.Text = "18";
|
2020-06-13 07:27:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SetTemplate()
|
|
|
|
|
{
|
|
|
|
|
bi.Frame = new Bitmap(Properties.Resources.bootLogoTex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FileSelect_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MainViewModel mvm = FindResource("mvm") as MainViewModel;
|
2020-06-13 15:53:59 +00:00
|
|
|
|
|
2020-06-13 07:27:42 +00:00
|
|
|
|
string path = mvm.GetFilePath(false, false);
|
|
|
|
|
if (!CheckIfNull(path))
|
|
|
|
|
{
|
|
|
|
|
string copy = "";
|
|
|
|
|
if (new FileInfo(path).Extension.Contains("tga"))
|
|
|
|
|
{
|
|
|
|
|
using (Process conv = new Process())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
conv.StartInfo.UseShellExecute = false;
|
|
|
|
|
conv.StartInfo.CreateNoWindow = true;
|
2020-10-02 00:38:48 +00:00
|
|
|
|
if (Directory.Exists(Path.Combine(tempPath, "image")))
|
2020-06-13 07:27:42 +00:00
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
Directory.Delete(Path.Combine(tempPath, "image"), true);
|
2020-06-13 07:27:42 +00:00
|
|
|
|
}
|
2020-10-02 00:38:48 +00:00
|
|
|
|
Directory.CreateDirectory(Path.Combine(tempPath, "image"));
|
|
|
|
|
conv.StartInfo.FileName = Path.Combine(toolsPath, "tga2png.exe");
|
|
|
|
|
conv.StartInfo.Arguments = $"-i \"{path}\" -o \"{Path.Combine(tempPath, "image")}\"";
|
2020-06-13 07:27:42 +00:00
|
|
|
|
|
|
|
|
|
conv.Start();
|
|
|
|
|
conv.WaitForExit();
|
|
|
|
|
|
2020-10-02 00:38:48 +00:00
|
|
|
|
foreach (string sFile in Directory.GetFiles(Path.Combine(tempPath, "image"), "*.png"))
|
2020-06-13 07:27:42 +00:00
|
|
|
|
{
|
|
|
|
|
copy = sFile;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
copy = path;
|
|
|
|
|
}
|
2021-12-17 05:28:25 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
bi.Frame = new Bitmap(copy);
|
|
|
|
|
b = bi.Create("", 20);
|
|
|
|
|
Image.Source = BitmapToImageSource(b);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
Custom_Message cm = new Custom_Message("Image Issue", "The image you're trying to use will not work, please try a different image.");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
cm.Owner = mvm.mw;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
//left empty on purpose
|
|
|
|
|
}
|
|
|
|
|
cm.ShowDialog();
|
|
|
|
|
}
|
2020-06-13 07:27:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private bool CheckIfNull(string s)
|
|
|
|
|
{
|
|
|
|
|
if (s == null || s.Equals(string.Empty))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
private void Finish_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(@"bin\createdIMG"))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(@"bin\createdIMG");
|
|
|
|
|
}
|
2020-10-02 00:38:48 +00:00
|
|
|
|
if(File.Exists(Path.Combine(@"bin\createdIMG", imageName.Content + ".png")))
|
2020-06-13 07:27:42 +00:00
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
File.Delete(Path.Combine(@"bin\createdIMG", imageName.Content + ".png"));
|
2020-06-13 07:27:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-10-02 00:38:48 +00:00
|
|
|
|
b.Save(Path.Combine(@"bin\createdIMG", imageName.Content + ".png"));
|
2020-06-13 07:27:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TextBox_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
e.Handled = !IsTextAllowed(e.Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static readonly Regex _regex = new Regex("[^0-9]+"); //regex that matches disallowed text
|
2020-07-23 23:12:12 +00:00
|
|
|
|
|
2020-06-13 07:27:42 +00:00
|
|
|
|
private static bool IsTextAllowed(string text)
|
|
|
|
|
{
|
|
|
|
|
return !_regex.IsMatch(text);
|
|
|
|
|
}
|
|
|
|
|
private void TextBoxPasting(object sender, DataObjectPastingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.DataObject.GetDataPresent(typeof(String)))
|
|
|
|
|
{
|
|
|
|
|
String text = (String)e.DataObject.GetData(typeof(String));
|
|
|
|
|
if (!IsTextAllowed(text))
|
|
|
|
|
{
|
|
|
|
|
e.CancelCommand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
e.CancelCommand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void wind_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2020-06-13 15:53:59 +00:00
|
|
|
|
b = bi.Create(t.Text, 20);
|
2020-06-13 07:27:42 +00:00
|
|
|
|
Image.Source = BitmapToImageSource(b);
|
|
|
|
|
}
|
|
|
|
|
BitmapImage BitmapToImageSource(Bitmap bitmap)
|
|
|
|
|
{
|
|
|
|
|
using (MemoryStream memory = new MemoryStream())
|
|
|
|
|
{
|
|
|
|
|
bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Bmp);
|
|
|
|
|
memory.Position = 0;
|
|
|
|
|
BitmapImage bitmapimage = new BitmapImage();
|
|
|
|
|
bitmapimage.BeginInit();
|
|
|
|
|
bitmapimage.StreamSource = memory;
|
|
|
|
|
bitmapimage.CacheOption = BitmapCacheOption.OnLoad;
|
|
|
|
|
bitmapimage.EndInit();
|
|
|
|
|
|
|
|
|
|
return bitmapimage;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DrawImage()
|
|
|
|
|
{
|
2020-06-13 15:53:59 +00:00
|
|
|
|
if(!bi.Frame.Equals(new Bitmap(Properties.Resources.bootLogoTex)))
|
|
|
|
|
{
|
|
|
|
|
bi.Frame = new Bitmap(Properties.Resources.bootLogoTex);
|
|
|
|
|
}
|
|
|
|
|
int fontsize = 18;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
fontsize = Convert.ToInt32(t_Copy.Text);
|
2020-06-14 17:05:01 +00:00
|
|
|
|
if(fontsize == 0)
|
|
|
|
|
{
|
|
|
|
|
fontsize = 1;
|
|
|
|
|
}
|
2020-06-13 15:53:59 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
fontsize = 18;
|
|
|
|
|
}
|
|
|
|
|
b = bi.Create(t.Text, fontsize);
|
2020-06-13 07:27:42 +00:00
|
|
|
|
Image.Source = BitmapToImageSource(b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Players_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Players_TextChanged(object sender, TextChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DrawImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2020-07-23 23:12:12 +00:00
|
|
|
|
Dispose(true);
|
|
|
|
|
GC.SuppressFinalize(this);
|
2020-06-13 07:27:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-23 23:12:12 +00:00
|
|
|
|
private void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
if (_disposed) return;
|
|
|
|
|
if (disposing)
|
|
|
|
|
{
|
|
|
|
|
bi?.Dispose();
|
|
|
|
|
b?.Dispose();
|
|
|
|
|
}
|
2020-06-13 07:27:42 +00:00
|
|
|
|
|
2020-07-23 23:12:12 +00:00
|
|
|
|
_disposed = true;
|
|
|
|
|
}
|
2020-06-13 07:27:42 +00:00
|
|
|
|
|
|
|
|
|
private void RadioButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PLDi_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DrawImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RLEn_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DrawImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void t_TextChanged(object sender, TextChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DrawImage();
|
|
|
|
|
}
|
2020-06-13 15:53:59 +00:00
|
|
|
|
|
|
|
|
|
private void t_Copy_TextChanged(object sender, TextChangedEventArgs e)
|
|
|
|
|
{
|
2020-06-14 14:59:54 +00:00
|
|
|
|
try
|
2020-06-14 07:09:22 +00:00
|
|
|
|
{
|
2020-06-14 17:05:01 +00:00
|
|
|
|
|
2020-06-14 14:59:54 +00:00
|
|
|
|
if (Convert.ToInt32(t_Copy.Text) > 30)
|
|
|
|
|
{
|
|
|
|
|
t_Copy.Text = "30";
|
|
|
|
|
}
|
2020-06-14 07:09:22 +00:00
|
|
|
|
}
|
2020-06-14 14:59:54 +00:00
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
2020-06-14 17:05:01 +00:00
|
|
|
|
|
2020-06-14 14:59:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-13 15:53:59 +00:00
|
|
|
|
DrawImage();
|
|
|
|
|
}
|
2020-06-13 07:27:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|