using System; using System.IO; using System.Windows; using System.Diagnostics; using Launcher_Client.Networking; using System.Windows.Threading; namespace Launcher_Client { class Utility { public static String LocalPath = String.Format("{0}\\", Environment.CurrentDirectory); public static void Information(String Message, params Object[] Arguments) { String FormattedMessage = String.Format(Message, Arguments); MessageBox.Show(FormattedMessage, Properties.Settings.Default.ServerName, MessageBoxButton.OK, MessageBoxImage.Information); } public static void Error(String Message, params Object[] Arguments) { String FormattedMessage = String.Format(Message, Arguments); if (FormattedMessage.Contains(Properties.Settings.Default.ConnectIP)) { FormattedMessage = FormattedMessage.Replace(Properties.Settings.Default.ConnectIP, "IP Hidden!"); } MessageBox.Show(FormattedMessage, Properties.Settings.Default.ServerName, MessageBoxButton.OK, MessageBoxImage.Information); } public static Boolean Question(String Message, params Object[] Arguments) { String FormattedMessage = String.Format(Message, Arguments); MessageBoxResult Result = MessageBox.Show(FormattedMessage, Properties.Settings.Default.ServerName, MessageBoxButton.YesNo, MessageBoxImage.Information); if (Result == MessageBoxResult.Yes) { return true; } return false; } public static void StartSecurity(String Token) { if (File.Exists(String.Format("{0}{1}", LocalPath, Properties.Settings.Default.SecurityExe))) { Process OpenGame = new Process(); ProcessStartInfo GameStartInfo = new ProcessStartInfo() { Arguments = String.Format("-osk_server {0} -osk_store {1} -p {2}", Properties.Settings.Default.ConnectIP, "http://evictionstudios.com/DaShop/", 9010), FileName = String.Format("{0}Lumia.exe", LocalPath) }; FileStream TokenStream = File.Open("C:/Token.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); StreamWriter TokenWriter = new StreamWriter(TokenStream); TokenWriter.WriteLine(Token); TokenWriter.Flush(); TokenWriter.Close(); TokenStream.Close(); File.SetAttributes("C:/Token.txt", FileAttributes.Hidden); OpenGame.EnableRaisingEvents = true; OpenGame.Exited += GameStart_Exited; OpenGame.StartInfo = GameStartInfo; OpenGame.Start(); } else { Error("{0} Is Missing!", Properties.Settings.Default.SecurityExe); Shutdown(); } } private static void GameStart_Exited(Object Sender, EventArgs Args) { Utility.Shutdown(); } public static void DeleteFile(String FilePath) { try { if (File.Exists(FilePath)) { File.Delete(FilePath); } } catch { } } public static Int64 ConvertToMegabytes(Int64 Amount) { return (Amount / 1024L) / 1024L; } public static void Shutdown() { Environment.Exit(-1); } } }