Beispiel #1
0
        /// <summary>
        /// Handels the Click on the "Cancel" button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancelSettingsClick(object sender, RoutedEventArgs e)
        {
            EmergencyInstallation emergency = new EmergencyInstallation();

            emergency.setEmergencyInstallationPath(AppConfig.readFromAppConfig("emergencyInstallationPath"));
            Close();
        }
Beispiel #2
0
        //Constructor
        public EmergencyInstallation()
        {
            this.setEmergencyInstallationPath(AppConfig.readFromAppConfig("emergencyInstallationPath"));
#if DEBUG
            setEmergencyInstallationPath(@"D:\Program Files (x86)\Emergency 5");
#endif
            EmergencyInstallation.setIsEmergencyInstalled(this.getEmergencyInstallationPath());
        }
Beispiel #3
0
        /// <summary>
        /// Runs Emergency 5
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_RunEmergency_Click(object sender, RoutedEventArgs e)
        {
            ModTools.writeJsonModFile(dataContext.InstalledMods, dataContext.AppDataModificationsJsonFile);

            EmergencyInstallation myEmergencyInstallation = new EmergencyInstallation();

            try
            {
                System.Diagnostics.Process.Start(myEmergencyInstallation.getEmergencyInstallationPath() + @"\bin\em5_launcher.exe");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #4
0
        //constructor
        //
        public MainWindow()
        {
            // default Initialization Stuff
            //
            InitializeComponent();
            DataContext = new DataPool();

            // start datacontext
            //
            dataContext.ModTools = new ModTools(dataContext.AppDataModificationsJsonFile);
            dataContext.EmergencyInstallation = new EmergencyInstallation();
            dataContext.Login         = new Login();
            dataContext.InstalledMods = dataContext.ModTools.getInstalledModifications();
            dataContext.Watcher       = new FileSystemWatcher();
            dataContext.MainWindow    = this;

            //initial value for username
            //
            if (AppConfig.readFromAppConfig("username") != "")
            {
                dataContext.Login.UserName = AppConfig.readFromAppConfig("username");
            }
            else
            {
                dataContext.Login.UserName = Properties.Resources.notLoggedIn;
            }

            //hidde success textbox
            //
            txbSuccessfullSaved.Visibility = Visibility.Hidden;

            // check if emergency is installed, if not disable the mod-box (well... because of this datacontext it looks not that nice...
            //
            if (EmergencyInstallation.getIsEmergencyInstalled() && dataContext.EmergencyInstallation.verifyEmergencyInstallation(dataContext.EmergencyInstallation.getEmergencyInstallationPath()))
            {
                lblEmergencyNotInstalled.Visibility = Visibility.Hidden;
            }
            else
            {
                liModificationList.Visibility = Visibility.Hidden;
            }

            // FileWatcher for App.config stuff
            //
            dataContext.Watcher.Path                = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); // Pretty long...
            dataContext.Watcher.Filter              = "EmergencyX Client.exe.config";
            dataContext.Watcher.NotifyFilter        = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
            dataContext.Watcher.EnableRaisingEvents = true;
            dataContext.Watcher.Changed            += this.OnFileChange;

            //check weather user is logged in or not
            //
            if (AppConfig.readFromAppConfig("rememberMe").Equals("True"))
            {
                try
                {
                    dataContext.Login.TokenLogin();
                    txbSuccessfullSaved.Text       = Properties.Resources.successFullLoggedIn;
                    txbSuccessfullSaved.Visibility = Visibility.Visible;
                    btnLogin.Visibility            = Visibility.Hidden;
                    btnLogout.Visibility           = Visibility.Visible;
                }
                catch (NotSuccessFullLoggedInException noe)
                {
                    MessageBox.Show(Properties.Resources.loginFailed, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }