Beispiel #1
0
        /// <summary>
        /// The station removed.
        /// </summary>
        public void StationRemoved()
        {
            FlexibleMessageBox.Show(_stationNativeWindow,
                                    "This station has been shut down by the manager",
                                    "Station Shut Down",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
            if (WaitingForManagerPage != null)
            {
                WaitingForManagerPage.Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(delegate { WaitingForManagerPage.StationRemoved(); }));
            }

            if (BallotRequestPage != null)
            {
                BallotRequestPage.Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(delegate { BallotRequestPage.StationRemoved(); }));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Adds the model to the viewport
        /// </summary>
        /// <param name="ttModel">The model to add</param>
        /// <param name="materialDictionary">The dictionary of texture data for the model</param>
        /// <param name="item">The item associated with the model</param>
        /// <param name="race">The race of the model</param>
        public async Task AddModel(TTModel ttModel, Dictionary <int, ModelTextureData> materialDictionary, IItemModel item, XivRace race)
        {
            // Because the full model is skinned, it requires the bones to exist so we check them here
            var sklb = new Sklb(_gameDirectory);
            var skel = await sklb.CreateParsedSkelFile(ttModel.Source);

            // If we have weights, but can't find a skel, bad times.
            if (skel == null)
            {
                throw new InvalidDataException("Unable to resolve model skeleton.");
            }

            try
            {
                _fmvm.AddModelToView(ttModel, materialDictionary, item, race);
            }
            catch (Exception ex)
            {
                FlexibleMessageBox.Show(ex.Message, UIMessages.ModelAddErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void RunGame()
        {
            _updateWorker.CancelAsync();
            Settings.Instance.LastLaunchedWotC = false;

            // Check for WOTC only mods
            if (Settings.Mods.Active.Count(e => e.BuiltForWOTC) > 0)
            {
                if (FlexibleMessageBox.Show(this,
                                            "Are you sure you want to proceed? Please be warned that this is very likely to crash your game. Offending mods:\r\n" +
                                            String.Join("\r\n", Settings.Mods.Active.Where(e => e.BuiltForWOTC).Select(e => e.Name)),
                                            "You are trying to launch vanilla game with mods built for WOTC", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    RunVanilla();
                }
            }
            else
            {
                RunVanilla();
            }
        }
        private async void Menu_Backup_Click(object sender, RoutedEventArgs e)
        {
            var result = FlexibleMessageBox.Show(UIMessages.CreateBackupsMessage, UIMessages.CreateBackupsTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                var gameDirectory    = new DirectoryInfo(Settings.Default.FFXIV_Directory);
                var problemChecker   = new ProblemChecker(gameDirectory);
                var backupsDirectory = new DirectoryInfo(Properties.Settings.Default.Backup_Directory);
                try
                {
                    await problemChecker.BackupIndexFiles(backupsDirectory);
                }
                catch (Exception ex)
                {
                    FlexibleMessageBox.Show(string.Format(UIMessages.BackupFailedErrorMessage, ex.Message), UIMessages.BackupFailedTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                await this.ShowMessageAsync(UIMessages.BackupCompleteTitle, UIMessages.BackupCompleteMessage);
            }
        }
        private async void Menu_ScanForSets_Click(object sender, RoutedEventArgs e)
        {
            var r = FlexibleMessageBox.Show("This will scan the entire FFXIV file system for new item sets.\n\nThis operation can take up to an hour.\nAre you sure you wish to proceed?.", "Set Scan Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);

            if (r == System.Windows.Forms.DialogResult.OK)
            {
                await LockUi("Scanning for new Item Sets", "This can take up to roughly an hour, depending on computer specs.");

                // Stop the worker, in case it was reading from the file for some reason.
                XivCache.CacheWorkerEnabled = false;

                try
                {
                    await Task.Run(XivCache.RebuildAllRoots);
                } catch (Exception ex)
                {
                    FlexibleMessageBox.Show("Item Scan Error", "An error occured while trying to scan for new item sets.\n\n" + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                await UnlockUi();
            }
        }
Beispiel #6
0
        private void applyButton_Click(object sender, EventArgs e)
        {
            if (BandwithTextbox.Text.Length > 0 && BandwithTextbox.Text != "0")
            {
                if (BandwithComboBox.SelectedIndex == -1)
                {
                    FlexibleMessageBox.Show("You need to select something from the combobox");
                    return;
                }
                else
                {
                    Properties.Settings.Default.BandwithLimit = $"{BandwithTextbox.Text.Replace(" ", "")}{BandwithComboBox.Text}";
                }
            }
            else
            {
                Properties.Settings.Default.BandwithLimit = "";
            }

            Properties.Settings.Default.Save();
        }
Beispiel #7
0
        private void RunVanilla()
        {
            if (IsModUpdateTaskRunning)
            {
                ShowModUpdateRunningMessageBox();
                return;
            }

            // Check for WOTC only mods
            if (Settings.Mods.Active.Count(e => e.BuiltForWOTC) > 0)
            {
                if (FlexibleMessageBox.Show(this,
                                            "Are you sure you want to proceed? Please be warned that this is very likely to crash your game. Offending mods:\r\n" +
                                            String.Join("\r\n", Settings.Mods.Active.Where(e => e.BuiltForWOTC).Select(e => e.Name)),
                                            "You are trying to launch vanilla game with mods built for WOTC", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Log.Warn("User chose to run Vanilla XCOM with WotC mods");
                }
                else
                {
                    return;
                }
            }

            Settings.Instance.LastLaunchedWotC = false;
            ChallengeMode = false;
            Save();

            if (Program.XEnv is Xcom2Env x2Env)
            {
                x2Env.UseWotC = false;
                Program.XEnv.RunGame(Settings.GamePath, Settings.GetArgumentString());
            }


            if (Settings.CloseAfterLaunch)
            {
                Close();
            }
        }
Beispiel #8
0
        /// <summary>
        /// Called when the make manager button is clicked
        /// </summary>
        /// <param name="sender">
        /// autogenerated
        /// </param>
        /// <param name="e">
        /// autogenerated
        /// </param>
        private void MakeManagerButtonClick(object sender, RoutedEventArgs e)
        {
            Boolean result = false;
            Boolean cancel = false;

            _ui._stationWindow.Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(
                    delegate {
                var d   = new CheckMasterPasswordDialog(_ui, "The master password is required to promote a check-in station to a manager.");
                d.Owner = _ui._stationWindow;
                result  = (Boolean)d.ShowDialog();
                cancel  = d.IsCancel;
            }));

            if (cancel)
            {
                return;
            }

            if (result)
            {
                if (ManagerstationGrid.SelectedItem != null &&
                    _ui.MakeManager(((StationStatus)ManagerstationGrid.SelectedItem).Address))
                {
                }
                else
                {
                    FlexibleMessageBox.Show(_ui._stationNativeWindow, "Could not connect to the specified station", "No Connection", MessageBoxButtons.OK);
                }
            }
            else
            {
                FlexibleMessageBox.Show(_ui._stationNativeWindow,
                                        "You have entered an incorrect master password, please try again.",
                                        "Incorrect Master Password",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
            }
        }
Beispiel #9
0
        private async void calculateAirmassButton_Click_1(object sender, EventArgs e)
        {
            //this.cancelButton.Enabled = true;
            //this.calculateAirmassButton.Enabled = false;

            var progressIndicator = new Progress <int>(ReportProgress);

            cts = new CancellationTokenSource();
            try
            {
                await EmulatePCM(progressIndicator, cts.Token);


                //EmulatePCMSync();
            }
            catch (OperationCanceledException)
            {
                this.progressBar.Value = 0;
            }
            catch (Exception ex)
            {
                var    currentStack = new System.Diagnostics.StackTrace(true);
                string stackTrace   = currentStack.ToString();

                FlexibleMessageBox.Show("Failed to process file due to: " + Environment.NewLine + stackTrace,
                                        "Error",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information,
                                        MessageBoxDefaultButton.Button2);
            }
            finally
            {
                this.cancelButton.Enabled           = false;
                this.calculateAirmassButton.Enabled = true;
            }

            this.progressBar.Value = 0;

            return;
        }
Beispiel #10
0
        private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            mpName = modPackName.Text;

            if (File.Exists(mpDir + "\\" + mpName + ".ttmp"))
            {
                if (FlexibleMessageBox.Show(mpName + " already exists.\n\nWould you like to Overwrite the file?",
                                            "Overwrite Confimration", Forms.MessageBoxButtons.YesNo, Forms.MessageBoxIcon.Question) ==
                    Forms.DialogResult.Yes)
                {
                    File.Delete(mpDir + "\\" + mpName + ".ttmp");
                }
                else
                {
                    FlexibleMessageBox.Show("Please choose a different name.", "Overwrite Declined",
                                            Forms.MessageBoxButtons.OK, Forms.MessageBoxIcon.Information);
                    return;
                }
            }


            BackgroundWorker backgroundWorker = new BackgroundWorker();

            backgroundWorker.WorkerReportsProgress = true;
            backgroundWorker.DoWork             += BackgroundWorker_DoWork;
            backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted;
            backgroundWorker.ProgressChanged    += BackgroundWorker_ProgressChanged;

            pd       = new ProgressDialog();
            pd.Title = "ModPack Maker";
            pd.ImportingLabel.Content = "Creating ModPack...";
            pd.Owner = App.Current.MainWindow;
            pd.Show();

            sw.Restart();
            dt.Start();

            CreateButton.IsEnabled = false;
            backgroundWorker.RunWorkerAsync();
        }
        private void BtnAddToDb_Click(object sender, EventArgs e)
        {
            // Check if all required inputs are filled
            if (!CheckAllFilled())
            {
                string message = "Niet alle gegevens zijn ingevuld. \rVul alle benodigde velden in!";
                string header  = "Niet Ingevuld";
                FlexibleMessageBox.Show(message, header, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            // Check whether the given item already exists
            if (DoesItemExist())
            {
                string message = "Het opgegeven nummer bestaat al. \rHeeft u het juiste nummer ingevuld?";
                string header  = "Artikel bestaat al!";
                FlexibleMessageBox.Show(message, header, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // Add the item to the database
            if (AddItemToDB())
            {
                FlexibleMessageBox.Show("Het artikel is toegevoegd", "Succes");
                // Reset user input
                TxbNummer.Clear();
                TxbOmschrijving.Clear();
                TxbPrijs.Clear();
                TxbVoorraad.Clear();
                CbbAfdeling.SelectedIndex = 0;
            }
            else
            {
                string message = "Er is iets fout gegaan, probeer het opnieuw.\r" +
                                 "Neem contact op met de helpdesk indien dit probleem zich blijft voordoen";
                string header = "An Error Occured";
                FlexibleMessageBox.Show(message, header, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private async Task <bool> CheckIndexFiles()
        {
            var xivDataFiles   = new XivDataFile[] { XivDataFile._0A_Exd, XivDataFile._01_Bgcommon, XivDataFile._04_Chara, XivDataFile._06_Ui };
            var problemChecker = new ProblemChecker(_gameDirectory);

            try
            {
                foreach (var xivDataFile in xivDataFiles)
                {
                    var errorFound = await problemChecker.CheckIndexDatCounts(xivDataFile);

                    if (errorFound)
                    {
                        await problemChecker.RepairIndexDatCounts(xivDataFile);
                    }
                }
            }
            catch (Exception ex)
            {
                var result = FlexibleMessageBox.Show("A critical error occurred when attempting to read the FFXIV index files.\n\nWould you like to restore your index backups?\n\nError: " + ex.Message, "Critical Index Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    var indexBackupsDirectory = new DirectoryInfo(Settings.Default.Backup_Directory);
                    var success = await problemChecker.RestoreBackups(indexBackupsDirectory);

                    if (!success)
                    {
                        FlexibleMessageBox.Show("Unable to restore Index Backups, shutting down TexTools.", "Critical Error Shutdown", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                        return(false);
                    }
                }
                else
                {
                    FlexibleMessageBox.Show("Shutting Down TexTools.", "Critical Error Shutdown", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return(false);
                }
            }
            return(true);
        }
Beispiel #13
0
        //uninstalls an app
        public static ProcessOutput UninstallGame(string GameName)
        {
            ADB.WakeDevice();
            ProcessOutput output = new ProcessOutput("", "");

            string packageName = Sideloader.gameNameToPackageName(GameName);

            DialogResult dialogResult = FlexibleMessageBox.Show($"Are you sure you want to uninstall {packageName}? this CANNOT be undone!", "WARNING!", MessageBoxButtons.YesNo);

            if (dialogResult != DialogResult.Yes)
            {
                return(output);
            }

            output = ADB.UninstallPackage(packageName);

            //remove both data and obb if there is any
            Sideloader.RemoveFolder("/sdcard/Android/obb/" + packageName);
            Sideloader.RemoveFolder("/sdcard/Android/data/" + packageName);

            return(output);
        }
Beispiel #14
0
        static async Task <int> Write_exception(string Ex, bool show = false)
        {
            Dictionary <string, object> aws_body = new Dictionary <string, object>();
            string       Wrtim  = DateTime.Now.ToString("yyyyMMddHHmmss");
            var          claims = Mpf.Gen_Claims();
            Dsave_return Dr;

            aws_body.Clear();
            aws_body["ukey"]          = Enc256.Encrypt(Mpf.cid + Mpf.Mpck.Dlab, Mpf.cid + Mpf.Mpck.Dlab, Mpf.Mpck.Iterations);
            aws_body["wrtim"]         = Wrtim;
            aws_body["exception"]     = Ex;
            Application.UseWaitCursor = true;
            Dr = await Aws.Save_exception(Mpf.Mpck.Url, Mpf.enck, Mpf.Mpck.Salt, claims, aws_body);

            Application.UseWaitCursor = false;
            if (show)
            {
                FlexibleMessageBox.Show(Ex, "Unhandled Exception");
            }

            return(Dr.code);
        }
Beispiel #15
0
        private async Task CheckDatSizes()
        {
            var filesToCheck = new XivDataFile[]
            { XivDataFile._0A_Exd, XivDataFile._01_Bgcommon, XivDataFile._04_Chara, XivDataFile._06_Ui };

            foreach (var file in filesToCheck)
            {
                AddText($"\t{file.GetDataFileName()} Dat Files", textColor);

                try
                {
                    var result = await _problemChecker.CheckForEmptyDatFiles(file);

                    if (result.Count > 0)
                    {
                        foreach (var datNum in result)
                        {
                            AddText($"\n\t{datNum} \t\u2716\t", "Red");
                            AddText($"\nFixing...", "Black");

                            File.Delete($"{_gameDirectory}\\{file.GetDataFileName()}.win32.dat{datNum}");

                            AddText($"\t\u2714\n", "Green");
                        }
                    }
                    else
                    {
                        AddText("\t\u2714\n", "Green");
                    }
                }
                catch (Exception ex)
                {
                    FlexibleMessageBox.Show(
                        $"{UIMessages.ProblemCheckDatIssueMessage}\n{ex.Message}", UIMessages.ProblemCheckErrorTitle,
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #16
0
 /// <summary>
 /// Opens a window in which the user can select an Excel file
 /// </summary>
 public static void SelectExcelFile()
 {
     using (OpenFileDialog FileReader = new OpenFileDialog())
     {
         FileReader.InitialDirectory = Properties.Settings.Default.InitialDir;
         FileReader.Filter           = "Excel files(*.xlsx)|*.xlsx";
         FileReader.RestoreDirectory = true;
         if (FileReader.ShowDialog() == DialogResult.OK)
         {
             DataSet ExcelDataSet = ReadExcelFile(FileReader.FileName);
             if (ExcelDataSet.Tables.Count < 1 || ExcelDataSet.Tables[0].Rows.Count < 1)
             {
                 string mess = "Er is iets fout gegaan bij het openen van het geselecteerde bestand.\nIndien het bestand al open is in een ander programma dient u dat proggramma eerst te sluiten.\n\nProbeer het daarna opnieuw.";
                 string head = "An Error Occured";
                 FlexibleMessageBox.Show(mess, head, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             (int Afdelingen, int Artikelen) = AddExcelToDB(ExcelDataSet);
             // the following will result if the selected file isn't according to the format.
             if (Afdelingen == int.MinValue && Artikelen == int.MinValue)
             {
                 DialogResult result = FlexibleMessageBox.Show("Het geselecteerde Bestand voldoet niet aan de eisen!", "Verkeerd Bestand", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                 if (result == DialogResult.Cancel)
                 {
                     return;
                 }
                 else if (result == DialogResult.Retry)
                 {
                     SelectExcelFile();
                     return;
                 }
             }
             string message = $"Er zijn ({Afdelingen}) afdelingen toegevoegd.\nEr zijn ({Artikelen}) artikelen toegevoegd.";
             string header  = "Toegevoegd:";
             FlexibleMessageBox.Show(message, header);
         }
     }
 }
Beispiel #17
0
        /// <summary>
        /// Creates the ModList which stores data on which items have been modded
        /// </summary>
        public static void CreateModList()
        {
            string md = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/TexTools";

            if (!Properties.Settings.Default.Modlist_Directory.Equals(""))
            {
                md = Path.GetDirectoryName(Properties.Settings.Default.Modlist_Directory);
            }

            Directory.CreateDirectory(md);

            if (!File.Exists(md + "/TexTools.modlist"))
            {
                try
                {
                    File.Create(md + "/TexTools.modlist");
                }
                catch (Exception e)
                {
                    FlexibleMessageBox.Show("[Create] Error Creating .modlist File \n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private async void Menu_LoadSets_Click(object sender, RoutedEventArgs e)
        {
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter           = "db files (*.db)|*.db";
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    // Stop the worker, in case it was reading from the file for some reason.
                    XivCache.CacheWorkerEnabled = false;

                    //Get the path of specified file
                    var filePath   = openFileDialog.FileName;
                    var targetPath = new DirectoryInfo(Path.Combine(XivCache.GameInfo.GameDirectory.Parent.Parent.FullName, "item_sets.db"));
                    File.Delete(targetPath.FullName);
                    File.Copy(filePath, targetPath.FullName);

                    FlexibleMessageBox.Show("Item Sets loaded.\nRestarting TexTools.", "TexTools Restarting", MessageBoxButtons.OK);
                    Restart();
                }
            }
        }
Beispiel #19
0
        private void showStacktraceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var obj = treeListView.SelectedObject;

            if (obj == null)
            {
                return;
            }

            var log = (Log)obj;

            if (log.IsDefault())
            {
                return;
            }

            var descAddition = log.HasDescription() ? log.Description + "\n\n" : "";

            if (log.Stacktrace != null)
            {
                FlexibleMessageBox.Show(log.Header + "\n\n" + descAddition + log.Stacktrace, "Stacktrace", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #20
0
        /// <summary>
        /// Called whn File -&gt; Export data is clicked
        /// </summary>
        /// <param name="sender">
        /// auto generated
        /// </param>
        /// <param name="e">
        /// auto generated
        /// </param>
        private void ExportDataClick(object sender, RoutedEventArgs e)
        {
            if (_ui._station == null)
            {
                FlexibleMessageBox.Show(_ui._stationNativeWindow, "There is no election data to report.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            var d = new CheckMasterPasswordDialog(_ui, "The master password is required to export election data.");

            d.Owner = this;
            d.ShowDialog();

            if (d.DialogResult.HasValue &&
                d.DialogResult == true)
            {
                if (d.IsCancel)
                {
                    return;
                }

                var saveDialog = new Microsoft.Win32.SaveFileDialog {
                    Title = "Generate Reports"
                };
                saveDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
                saveDialog.ShowDialog();
                if (!saveDialog.FileName.Equals(string.Empty))
                {
                    _ui.ExportData(saveDialog.FileName);
                }
                System.Diagnostics.Process.Start(saveDialog.FileName);
            }
            else
            {
                FlexibleMessageBox.Show(_ui._stationNativeWindow,
                                        "Master password entered incorrectly, please try again.", "Incorrect Master Password", MessageBoxButtons.OK);
            }
        }
        /// <summary>
        /// Creates files that will contain modded information
        /// </summary>
        private void MakeModContainers()
        {
            var ffxivDir = new DirectoryInfo(Properties.Settings.Default.FFXIV_Directory);

            var newModListDirectory = new DirectoryInfo(Path.Combine(ffxivDir.Parent.Parent.FullName, "XivMods.json"));

            if (Properties.Settings.Default.Modlist_Directory.Equals(""))
            {
                string md = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/TexTools/TexTools.modlist";
                Properties.Settings.Default.Modlist_Directory = md;
                Properties.Settings.Default.Save();
            }

            if (!File.Exists(Properties.Settings.Default.Modlist_Directory))
            {
                CreateDat.CreateModList();
            }

            if (File.Exists(newModListDirectory.FullName))
            {
                FlexibleMessageBox.Show("You are using an older version of TexTools.\n\n" +
                                        "Importing with this version may cause issues.", "Conflicting Versions", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            foreach (var datName in Info.ModDatDict)
            {
                var datPath = string.Format(Info.datDir, datName.Key, datName.Value);

                if (!File.Exists(datPath))
                {
                    CreateDat.MakeDat();
                    CreateDat.ChangeDatAmounts();
                }
            }
        }
Beispiel #22
0
        private async void CopyButton_Click(object sender, RoutedEventArgs e)
        {
            var to   = ToBox.Text;
            var from = FromBox.Text;

            try
            {
                if (string.IsNullOrWhiteSpace(to) || string.IsNullOrWhiteSpace(from))
                {
                    return;
                }
                to   = to.Trim().ToLower();
                from = from.Trim().ToLower();

                if (!to.EndsWith(".mdl") || !from.EndsWith(".mdl"))
                {
                    return;
                }

                var toRoot = await XivCache.GetFirstRoot(to);

                var fromRoot = await XivCache.GetFirstRoot(from);

                var df = IOUtil.GetDataFileFromPath(to);

                var _mdl = new Mdl(XivCache.GameInfo.GameDirectory, df);

                await _mdl.CopyModel(from, to, XivStrings.TexTools, true);

                FlexibleMessageBox.Show("Model Copied Successfully.", "Model Copy Confirmation", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                Close();
            }
            catch (Exception ex)
            {
                FlexibleMessageBox.Show("Model Copied Failed.\n\nError: " + ex.Message, "Model Copy Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Initializes the Cache and loads the item tree for the first time when done.
        /// </summary>
        /// <returns></returns>
        private async Task InitializeCache()
        {
            var gameDir = new DirectoryInfo(Properties.Settings.Default.FFXIV_Directory);
            var lang    = XivLanguages.GetXivLanguage(Properties.Settings.Default.Application_Language);

            await LockUi(UIStrings.Updating_Cache, UIStrings.Updating_Cache_Message, this);

            // Kick this in a new thread because the cache call will lock up the one it's on if it has to do a rebuild.
            await Task.Run(async() =>
            {
                bool cacheOK = true;
                try
                {
                    // If the cache needs to be rebuilt, this will synchronously block until it is done.
                    XivCache.SetGameInfo(gameDir, lang);
                } catch (Exception ex)
                {
                    cacheOK = false;
                    FlexibleMessageBox.Show("An error occurred while attempting to rebuild the cache.\n" + ex.Message, "Cache Rebuild Error.", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                }

                await Dispatcher.Invoke(async() =>
                {
                    await UnlockUi();

                    if (cacheOK)
                    {
                        await RefreshTree();
                    }

                    if (InitialLoadComplete != null)
                    {
                        InitialLoadComplete.Invoke(this, null);
                    }
                });
            });
        }
Beispiel #24
0
        /// <summary>
        /// Called when the end election button is clicked
        /// </summary>
        /// <param name="sender">
        /// autogenerated
        /// </param>
        /// <param name="e">
        /// autogenerated
        /// </param>
        private void EndElectionButtonClick(object sender, RoutedEventArgs e)
        {
            Boolean result = false;
            Boolean cancel = false;

            _ui._stationWindow.Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(
                    delegate {
                var d   = new CheckMasterPasswordDialog(_ui, "The master password is required to end the election.");
                d.Owner = _ui._stationWindow;
                result  = (Boolean)d.ShowDialog();
                cancel  = d.IsCancel;
            }));

            if (cancel)
            {
                return;
            }

            if (result)
            {
                if (_activeUpdateThread != null)
                {
                    _activeUpdateThread.Abort();
                }

                _ui.AnnounceEndElection();
                _ui.ManagerOverviewPage = null;
                _parent.Navigate(new EndedElectionPage(_parent, _ui));
            }
            else
            {
                FlexibleMessageBox.Show(_ui._stationNativeWindow,
                                        "You have entered an incorrect master password, please try again.", "Incorrect Master Password", MessageBoxButtons.OK);
            }
        }
Beispiel #25
0
        /// <summary>
        /// Checks for any missing images in library (i.e. image exists in library but not on disk); gives
        /// user message box notif and returns true if missing image(s) found; returns false otherwise
        /// </summary>
        /// <returns>True if missing image(s) found, false otherwise</returns>
        public bool CheckMissing()
        {
            List <string> missingImages = new List <string>();

            // Loop over each WBImage in library
            foreach (WBImage image in LibraryList.ToList())
            {
                // Check if image does not exist at WBImage's associated path (or no permissions to that file)
                if (!File.Exists(image.Path))
                {
                    // Add this image's file name to the list of missing images
                    missingImages.Add(Path.GetFileName(image.Path));

                    // Remove this WBImage from the library
                    LibraryList.Remove(image);
                }
            }

            // If missing images found, show message box explaining this to user and return true
            if (missingImages.Count > 0)
            {
                string message = "The following image files are missing and were removed from the library:\n\n";
                foreach (string filename in missingImages)
                {
                    message += filename + "\n";
                }
                message += "\nThese files may have been moved or deleted, or WallBrite may not have permission to access them. If you're sure " +
                           "the files are still where they were, try running WallBrite as administrator to make sure it has permissions to access them.";

                FlexibleMessageBox.Show(message, "Missing Files", WinForms.MessageBoxButtons.OK, WinForms.MessageBoxIcon.Warning);
                return(true);
            }

            // If no missing images found, return false
            return(false);
        }
Beispiel #26
0
        private void ImportDataThread(object parameter)
        {
            Tuple <string, string> p = parameter as Tuple <string, string>;
            string filePath          = p.Item1;
            string keyPath           = p.Item2;
            Thread t = new Thread(BlinkVisibility);

            t.Name = "Blinker";
            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            if (_ui.ImportData(filePath, keyPath, _local))
            {
                Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(delegate {
                    _parent.Navigate(new PrecinctChoicePage(_parent, _ui));
                }));
                t.Abort();
            }
            else
            {
                t.Abort();
                Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(
                        delegate {
                    FlexibleMessageBox.Show(_ui._stationNativeWindow, "Could not import data from specified files.", "Import Failed", MessageBoxButtons.OK);
                }));
            }
            Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(delegate {
                LoadingLabel.Visibility = Visibility.Hidden;
                UpdateButtons();
            }));
        }
        /// <summary>
        /// Saves the material to file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            var mw = MainWindow.GetMainWindow();
            await mw.LockUi();

            try
            {
                var mtrlLib = new Mtrl(XivCache.GameInfo.GameDirectory);

                var item = mw.GetSelectedItem();
                await mtrlLib.ImportMtrl(_mtrl, item, XivStrings.TexTools);

                MaterialSaved.Invoke(this, null);
            }
            catch (Exception ex)
            {
                FlexibleMessageBox.Show("Unable to save Material.\n\nError: " + ex.Message, "Material Save Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            finally
            {
                await mw.UnlockUi();
            }
        }
        /// <summary>
        /// The event handler for the done button clicked
        /// </summary>
        private void DoneButton_Click(object sender, RoutedEventArgs e)
        {
            if (ModGroupTitle.Text.Equals(string.Empty))
            {
                ModGroupTitle.Focus();
                ModGroupTitle.BorderBrush = Brushes.Red;
                ControlsHelper.SetFocusBorderBrush(ModGroupTitle, Brushes.Red);
            }
            else if (!_editMode && _groupNames.Contains(ModGroupTitle.Text) || _editMode && !_editGroupName.Equals(ModGroupTitle.Text) && _groupNames.Contains(ModGroupTitle.Text))
            {
                ModGroupTitle.Focus();
                ModGroupTitle.BorderBrush = Brushes.Red;
                ControlsHelper.SetFocusBorderBrush(ModGroupTitle, Brushes.Red);

                FlexibleMessageBox.Show(
                    $"\"{ModGroupTitle.Text}\" group already exists, please rename the group.\n\nIf you would like to add to that group instead, go back and click the edit button.",
                    "Group Name already exists.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                DialogResult = true;
                Close();
            }
        }
        private async void ResetButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ResetButton.IsEnabled  = false;
                CancelButton.IsEnabled = false;
                SaveButton.IsEnabled   = false;
                ResetButton.Content    = "Working...";

                await CMP.DisableRgspMod(Race, Gender);

                this.Close();
            }
            catch (Exception ex)
            {
                FlexibleMessageBox.Show("Cannot save changes:\n\nError: " + ex.Message, "Save Scaling Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);

                ResetButton.IsEnabled  = true;
                CancelButton.IsEnabled = true;
                SaveButton.IsEnabled   = true;
                ResetButton.Content    = "Restore Defaults";
                return;
            }
        }
        /// <summary>
        /// The event handler for the done button clicked
        /// </summary>
        private void DoneButton_Click(object sender, RoutedEventArgs e)
        {
            if (ModGroupTitle.Text.Equals(string.Empty))
            {
                ModGroupTitle.Focus();
                ModGroupTitle.BorderBrush = Brushes.Red;
                ControlsHelper.SetFocusBorderBrush(ModGroupTitle, Brushes.Red);
            }
            else if (!_editMode && _groupNames.Contains(ModGroupTitle.Text) || _editMode && !_editGroupName.Equals(ModGroupTitle.Text) && _groupNames.Contains(ModGroupTitle.Text))
            {
                ModGroupTitle.Focus();
                ModGroupTitle.BorderBrush = Brushes.Red;
                ControlsHelper.SetFocusBorderBrush(ModGroupTitle, Brushes.Red);

                FlexibleMessageBox.Show(
                    $"\"{ModGroupTitle.Text}\" {UIMessages.ExistingGroupMessage}",
                    UIMessages.ExistingGroupTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                DialogResult = true;
                Close();
            }
        }