private XmlObjectsListWrapper LoadWrapperFromFile(string fileName)
        {
            long fileSize = new System.IO.FileInfo(fileName).Length;

            if (fileSize < 1)
            {
                return(null);
            }

            XmlObjectsListWrapper wrapper = null;

            if (fileName.EndsWith(".xml"))
            {
                try
                {
                    wrapper = new XmlObjectsListWrapper(new XmlFileObject(fileName));
                }
                catch (Exception exception)
                {
                    XmlFileManager.WriteStringToLog("Failed to load file with exception:\n" + exception);
                    wrapper = null;
                }
            }
            return(wrapper);
        }
Пример #2
0
        //Global Error Processing. Catch any errors and send them to the log, let application shutdown
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs exception)
        {
            Exception objectAsException = (Exception)exception.ExceptionObject;

            // Process unhandled exception
            XmlFileManager.WriteStringToLog("ERROR MESSAGE: " + objectAsException.Message, true);
            XmlFileManager.WriteStringToLog("ERROR TRACE: " + objectAsException.StackTrace);
        }
        //Global Error Processing happens in the APP view
        //but here I want to catch it as well to save any possible generated xml to the log
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs exception)
        {
            string xmltoWrite = XmlXpathGenerator.GenerateXmlForObjectView(NewObjectFormsPanel);

            if (!String.IsNullOrEmpty(xmltoWrite))
            {
                XmlFileManager.WriteStringToLog(xmltoWrite, true);
            }
        }
Пример #4
0
        public void ResetNewObjectView()
        {
            string xmltoWrite = XmlXpathGenerator.GenerateXmlForObjectView(NewObjectFormViewPanel);

            if (!String.IsNullOrEmpty(xmltoWrite))
            {
                XmlFileManager.WriteStringToLog(xmltoWrite, true);
            }
            NewObjectFormViewPanel.Children.Clear();
            NewObjectFormViewPanel.StackPanelLoadedListWrappers.Clear();
            XmlOutputBox.Text = XmlXpathGenerator.GenerateXmlViewOutput(NewObjectFormViewPanel);
        }
        private void OpenModsOutputFolderMenuItem_Click(object sender, RoutedEventArgs e)
        {
            string modsOutputPth = XmlFileManager.AllModsOutputPath + "Mods\\";

            try
            {
                Process.Start("explorer.exe", @modsOutputPth);
            }
            catch (Exception exception)
            {
                MessageBox.Show("There was an issue opening the mods folder. For more inforation check the log.txt.",
                                "Error Opening Mods Folder", MessageBoxButton.OK, MessageBoxImage.Error);
                XmlFileManager.WriteStringToLog(exception.StackTrace);
            }
        }
        private void MainWindow_Closing(object sender, CancelEventArgs e)
        {
            string xmltoWrite = XmlXpathGenerator.GenerateXmlForObjectView(NewObjectFormsPanel);

            if (!String.IsNullOrEmpty(xmltoWrite))
            {
                XmlFileManager.WriteStringToLog(xmltoWrite, true);
            }
            Properties.Settings.Default.IncludeChildrenSearchTreeTooltip   = IncludeChildrenInOnHoverCheckBox.IsChecked.Value;
            Properties.Settings.Default.IncludeCommentsSearchTreeTooltip   = IncludeCommentsCheckBox.IsChecked.Value;
            Properties.Settings.Default.IncludeAllModsObjectTreeAttributes = IncludeAllModsInBoxesCheckBox.IsChecked.Value;
            Properties.Settings.Default.IgnoreAllAttributesCheckbox        = IgnoreAllAttributesCheckBox.IsChecked.Value;
            Properties.Settings.Default.Save();
            //SaveExternalXaml();
        }
        private void ChangeModTagButton_Click(object sender, RoutedEventArgs e)
        {
            List <string> allCustomModsInPath   = XmlFileManager.GetCustomModFoldersInOutput();
            string        currentSelectedModTag = AllTagsComboBox.Text;
            string        newModName            = ChangeNameAllTagsComboBox.Text;

            //if the current selected mod name is not the last selected
            if (!currentSelectedModTag.Equals(newModName))
            {
                // and is does not exist in the mod output folder already
                if (!allCustomModsInPath.Contains(newModName))
                {
                    if (VerifyTagNameCorrectness(newModName))
                    {
                        try
                        {
                            //We can change the name
                            ChangeModTagName(currentSelectedModTag, newModName);
                            ResetModNameComboBoxes(currentSelectedModTag);
                            string message = "Successfully changed the mod name from " + currentSelectedModTag + " to " + newModName + ".";
                            MessageBox.Show(message, "Change Mod Name", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        catch (Exception exception)
                        {
                            XmlFileManager.WriteStringToLog("ERROR changing mod name. Exception:\n " + exception.ToString() + " \nMessage: " + exception.Message);
                            string message = "Error attempting to change the name for the mod " + currentSelectedModTag + "."
                                             + "\nError:\n\n" +
                                             exception.Message;
                            MessageBox.Show(message, "Change Mod Name Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                }
                //the name already exists
                else
                {
                    string message = "The new mod name cannot already exist in the output location.\n\n" +
                                     "You must use different name or delete the other mod folder in the output location.";
                    MessageBox.Show(message, "Mod Name Exists", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            //The name is the same as the selected mod
            else
            {
                MessageBox.Show("The selected mod, and the new mod name must be different", "Mod Name Unchanged", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        internal bool DeleteModFile(string modTagSetting, string comboBoxTextUnparsed)
        {
            bool didDelete = false;

            //Make sure the strings are available.
            if (String.IsNullOrEmpty(modTagSetting) || String.IsNullOrEmpty(comboBoxTextUnparsed))
            {
                XmlFileManager.WriteStringToLog("The inputs for the delete setting were incorrect. Did not delete file.");
                return(didDelete);
            }
            //Split the string from the box it should be in the form modname_possibledir_filename
            string fileName = "";

            string[] comboBoxTextSplit = comboBoxTextUnparsed.Split("_");
            if (comboBoxTextSplit.Length > 1)
            {
                //Get the very last element, should be the filename without the .xml extention
                //This gets the last one essentially length - 1
                fileName = comboBoxTextSplit[^ 1];
Пример #9
0
        //Global Error Processing happens in the APP view
        //but here I want to catch it as well to save any possible generated localization to the log
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs exception)
        {
            string prepend = "Localization for " + this.GetTitleForWindow() + ":\n";

            XmlFileManager.WriteStringToLog(prepend + LocalizationPreviewBox.Text, false);
        }