private void SaveFile()
        {
            string xmlOut    = XmlOutputBox.Text;
            string isInvalid = XmlXpathGenerator.ValidateXml(xmlOut);

            if (isInvalid != null)
            {
                MessageBoxResult saveInvalidXmlDecision = MessageBox.Show(
                    "The xml is not valid! Would you like to save anyway?\n\n" + isInvalid,
                    "Invalid XML!",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Error);
                switch (saveInvalidXmlDecision)
                {
                case MessageBoxResult.No:
                    return;
                }
            }
            string parentPath = Wrapper.XmlFile.ParentPath ?? "";

            if (!String.IsNullOrEmpty(xmlOut))
            {
                XmlFileManager.WriteStringToFile(Path.Combine(this.FileLocationPath, parentPath), Wrapper.XmlFile.FileName, xmlOut);
                if (Properties.Settings.Default.AutoMoveMod)
                {
                    XmlFileManager.CopyAllOutputFiles();
                }
                StartingFileContents = xmlOut;
                this.Title           = this.StartingTitle;
            }
        }
        private void ValidateXmlMenuItem_Click(object sender, RoutedEventArgs e)
        {
            string modOutputPath = XmlFileManager.Get_ModOutputPath(Properties.Settings.Default.ModTagSetting);

            string[]      modOutputFiles = Directory.GetFiles(modOutputPath);
            StringBuilder builder        = new StringBuilder();

            foreach (string modFile in modOutputFiles)
            {
                string isInvalid = XmlXpathGenerator.ValidateXml(XmlFileManager.ReadExistingFile(modFile));
                //The xml is valid
                if (isInvalid == null)
                {
                    builder.AppendLine("File: " + Path.GetFileName(modFile));
                    builder.AppendLine("Valid");
                }
                else
                {
                    builder.Insert(0, isInvalid);
                    builder.Insert(0, "File: " + Path.GetFileName(modFile) + "\n");
                }
            }
            builder.Insert(0, "All files: \n");
            builder.Insert(0, "Xml Validation for mod " + Properties.Settings.Default.ModTagSetting + "\n\n");
            //Remove the trailing newline
            builder.Remove(builder.Length - 2, 2);
            MessageBox.Show(builder.ToString(), "Xml Validation", MessageBoxButton.OK, MessageBoxImage.Information);
            this.MainWindowFileController.LoadCustomTagWrappers(Properties.Settings.Default.ModTagSetting, this.CurrentModFilesCenterViewComboBox);
        }
        private void SaveXmlFile_Click(object sender, RoutedEventArgs e)
        {
            string autoMoveString = "";

            if (!Properties.Settings.Default.AutoMoveDecisionMade)
            {
                CheckAutoMoveProperty("You can change this setting later using the Settings menu.");
            }
            if (Properties.Settings.Default.AutoMoveMod)
            {
                autoMoveString = "Auto move is active! This will also automatically move the files to \n" +
                                 Properties.Settings.Default.GameFolderModDirectory;
            }
            MessageBoxResult result = MessageBox.Show(
                "This will write all current generated xml to the appropriate files in the output location.\n\n" +
                "Are you sure?\n" +
                autoMoveString,
                "Save Generated XML",
                MessageBoxButton.OKCancel,
                MessageBoxImage.Warning);

            switch (result)
            {
            case MessageBoxResult.OK:
                XmlXpathGenerator.SaveAllGeneratedXmlToPath(NewObjectFormsPanel, XmlFileManager.ModConfigOutputPath, true);
                if (Properties.Settings.Default.AutoMoveMod)
                {
                    XmlFileManager.CopyAllOutputFiles();
                }
                this.MainWindowFileController.LoadCustomTagWrappers(Properties.Settings.Default.ModTagSetting, this.CurrentModFilesCenterViewComboBox);
                this.SearchViewModSelectionPanel.Children.Remove(this.LoadedModFilesSearchViewComboBox);
                this.SearchViewModSelectionPanel.Children.Remove(this.LoadedModFilesButton);
                break;
            }
        }
        private void CombineTagsXmlButton_Click(object sender, RoutedEventArgs e)
        {
            string allXml = this.XmlOutputBox.Text;

            if (XmlXpathGenerator.ValidateXml(allXml, errorPrependMessage: "Error: Could not execute combine function because xml is invalid."))
            {
                this.XmlOutputBox.Text = XmlXpathGenerator.CombineAppendTags(this.Wrapper, allXml);
            }
        }
        //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);
            }
        }
Beispiel #6
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 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 ValidateXmlButton_Click(object sender, RoutedEventArgs e)
 {
     XmlXpathGenerator.ValidateXml(XmlOutputBox.Text, doShowValidationMessage: true);
 }
 private void XmlOutputBoxGotKeyboardFocus_Handler(object sender, KeyboardFocusChangedEventArgs e)
 {
     this.XmlOutputBox.Text = XmlXpathGenerator.GenerateXmlViewOutput(NewObjectFormsPanel);
 }