private void DirectEdit_Closed(object sender, EventArgs e)
        {
            string currentLoadedMod = Properties.Settings.Default.ModTagSetting;

            this.MainWindowFileController.LoadCustomTagWrappers(currentLoadedMod, this.CurrentModFilesCenterViewComboBox);
            this.CurrentModFilesCenterViewComboBox.SetComboBox(XmlFileManager.GetCustomModFilesInOutput(currentLoadedMod, currentLoadedMod + "_"));
        }
        public void LoadCustomTagWrappers(string nextModTag, ComboBox currentModLoadedFilesCenterViewComboBox)
        {
            string modOutputPath = XmlFileManager.Get_ModOutputPath(nextModTag);

            if (Directory.Exists(modOutputPath))
            {
                string[] modOutputFiles = Directory.GetFiles(modOutputPath);
                SetCustomTagWrapper(modOutputFiles, nextModTag, currentModLoadedFilesCenterViewComboBox);

                if (Directory.Exists(Path.Combine(modOutputPath, XmlFileManager.Xui_Folder_Name)))
                {
                    string[] modXuiOutputFiles = Directory.GetFiles(Path.Combine(modOutputPath, XmlFileManager.Xui_Folder_Name));
                    if (modXuiOutputFiles.Length > 0)
                    {
                        SetCustomTagWrapper(modXuiOutputFiles, nextModTag, currentModLoadedFilesCenterViewComboBox);
                    }
                }
                if (Directory.Exists(Path.Combine(modOutputPath, XmlFileManager.Xui_Menu_Folder_Name)))
                {
                    string[] modXuiMenuOutputFiles = Directory.GetFiles(Path.Combine(modOutputPath, XmlFileManager.Xui_Menu_Folder_Name));
                    if (modXuiMenuOutputFiles.Length > 0)
                    {
                        SetCustomTagWrapper(modXuiMenuOutputFiles, nextModTag, currentModLoadedFilesCenterViewComboBox);
                    }
                }
            }
        }
Пример #3
0
        public void SetExistingValues()
        {
            XmlFileManager fileManager = new XmlFileManager(new CimTools.Legacy.CimToolSettings("TestSaveLoad"));

            fileManager.Data.SetValue("int a", 1, "group 1");

            var foundIntValues = fileManager.Data.GetValues <int>("group 1");

            Assert.AreEqual(1, foundIntValues.Count);
            Assert.AreEqual(1, foundIntValues["int a"]);

            fileManager.Data.SetValue("int a", 2, "group 1");

            foundIntValues = fileManager.Data.GetValues <int>("group 1");
            Assert.AreEqual(1, foundIntValues.Count);
            Assert.AreEqual(2, foundIntValues["int a"]);

            fileManager.Data.SetValue("int b", 3, "group 1");

            foundIntValues = fileManager.Data.GetValues <int>("group 1");
            Assert.AreEqual(2, foundIntValues.Count);
            Assert.AreEqual(2, foundIntValues["int a"]);
            Assert.AreEqual(3, foundIntValues["int b"]);

            fileManager.Data.SetValue("int b", 4, "group 1");

            foundIntValues = fileManager.Data.GetValues <int>("group 1");
            Assert.AreEqual(2, foundIntValues.Count);
            Assert.AreEqual(2, foundIntValues["int a"]);
            Assert.AreEqual(4, foundIntValues["int b"]);
        }
        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;
            }
        }
        public void LoadStartingDirectory(ComboBox searchTreeLoadedFilesComboBox, ComboBox newObjectViewLoadedFilesComboBox, ComboBox currentModLoadedFilesCenterViewComboBox, ComboBox loadedModsSearchViewComboBox, ComboBox CurrentGameFilesCenterViewComboBox)
        {
            Directory.CreateDirectory(XmlFileManager.LoadedFilesPath);
            Directory.CreateDirectory(Path.Combine(XmlFileManager.LoadedFilesPath, XmlFileManager.Xui_Folder_Name));
            Directory.CreateDirectory(Path.Combine(XmlFileManager.LoadedFilesPath, XmlFileManager.Xui_Menu_Folder_Name));
            //Check normal files
            string[] files = Directory.GetFiles(XmlFileManager.LoadedFilesPath, "*.xml");
            LoadFilesPathWrappers(files, searchTreeLoadedFilesComboBox, newObjectViewLoadedFilesComboBox, CurrentGameFilesCenterViewComboBox);
            //Check for Xui files
            string[] xuiFiles = Directory.GetFiles(Path.Combine(XmlFileManager.LoadedFilesPath, XmlFileManager.Xui_Folder_Name));
            if (xuiFiles.Length > 0)
            {
                LoadFilesPathWrappers(xuiFiles, searchTreeLoadedFilesComboBox, newObjectViewLoadedFilesComboBox, CurrentGameFilesCenterViewComboBox);
            }
            //Check for Xui menu files
            string[] xuiMenuFiles = Directory.GetFiles(Path.Combine(XmlFileManager.LoadedFilesPath, XmlFileManager.Xui_Menu_Folder_Name));
            if (xuiMenuFiles.Length > 0)
            {
                LoadFilesPathWrappers(xuiMenuFiles, searchTreeLoadedFilesComboBox, newObjectViewLoadedFilesComboBox, CurrentGameFilesCenterViewComboBox);
            }

            List <string> allCustomTagDirectories = XmlFileManager.GetCustomModFoldersInOutput();

            loadedModsSearchViewComboBox.AddUniqueValueTo("");
            foreach (string nextModTag in allCustomTagDirectories)
            {
                loadedModsSearchViewComboBox.AddUniqueValueTo(nextModTag);
                LoadCustomTagWrappers(nextModTag, currentModLoadedFilesCenterViewComboBox);
            }
        }
 internal void RefreshMainUIComboboxes(ComboBox currentModLoadedFilesCenterViewComboBox, ComboBox loadedModsCenterViewComboBox, ComboBox loadedModsSearchViewComboBox)
 {
     currentModLoadedFilesCenterViewComboBox.SetComboBox(XmlFileManager.GetCustomModFilesInOutput(Properties.Settings.Default.ModTagSetting, Properties.Settings.Default.ModTagSetting + "_"));
     loadedModsCenterViewComboBox.SetComboBox(XmlFileManager.GetCustomModFoldersInOutput());
     loadedModsSearchViewComboBox.SetComboBox(XmlFileManager.GetCustomModFoldersInOutput());
     loadedModsCenterViewComboBox.Text = Properties.Settings.Default.ModTagSetting;
 }
        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);
        }
        public void LoadDirectoryViewControl(ComboBox loadedModsSearchViewComboBox, ComboBox loadedModsCenterViewComboBox, ComboBox currentModFilesCenterViewComboBox)
        {
            CommonOpenFileDialog openFileDialog = new CommonOpenFileDialog
            {
                IsFolderPicker = true
            };

            if (openFileDialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                string fullSelectedPath = openFileDialog.FileName;
                string currentModName   = Path.GetFileName(openFileDialog.FileName);
                bool   hasXmlFiles      = XmlFileManager.CheckLoadedModFolderForXmlFiles(fullSelectedPath);

                if (hasXmlFiles && !fullSelectedPath.ToLower().Contains("config"))
                {
                    currentModFilesCenterViewComboBox.SetComboBox(new List <string>());
                    Properties.Settings.Default.ModTagSetting = currentModName;
                    Properties.Settings.Default.Save();
                    loadedModsSearchViewComboBox.SelectedItem = currentModName;
                    //Copy the files to the output path at Output/Mods/ModName
                    string appOutputPath          = Path.Combine(XmlFileManager.AllModsOutputPath, "Mods", currentModName);
                    bool   overwriteLocalAppFiles = false;
                    if (Directory.Exists(appOutputPath))
                    {
                        MessageBoxResult messageBoxResult = MessageBox.Show(
                            "The mod is already loaded. Do you want to OVERWRITE the local, application files?\n\n" +
                            "WARNING: This feature does not merge the files! If you have changes in the files, they will be overwritten.",
                            "Overwrite Application Mod Files",
                            MessageBoxButton.YesNo,
                            MessageBoxImage.Question);
                        switch (messageBoxResult)
                        {
                        case MessageBoxResult.Yes:
                            overwriteLocalAppFiles = true;
                            break;
                        }
                    }
                    XmlFileManager.CopyAllFilesToPath(fullSelectedPath, appOutputPath, overwriteLocalAppFiles);
                    loadedModsCenterViewComboBox.AddUniqueValueTo(currentModName);
                    loadedModsSearchViewComboBox.AddUniqueValueTo(currentModName);
                    LoadCustomTagWrappers(currentModName, currentModFilesCenterViewComboBox);
                }
                else if (fullSelectedPath.ToLower().Contains("config"))
                {
                    MessageBox.Show(
                        "The was an error loading the mod at " + openFileDialog.FileName + ". If you selected the Config folder, please try again and select the ModFolder",
                        "Error Loading Directory",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
                else
                {
                    MessageBox.Show(
                        "The was an error loading the mod at " + openFileDialog.FileName + ". There was no xml found in the Config folder of the mod. Please check the folder for xml files.",
                        "Missing XML Files!",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
            }
        }
Пример #9
0
        //This function will use a temp file to update the grid, used for adding new rows.
        private void ReloadGridWithExternalChanges(string csvStringUsedToUpdateGrid)
        {
            string pathToTempFile = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "TMP_" + LocalizationFileObject.LOCALIZATION_FILE_NAME);

            XmlFileManager.WriteStringToFile(Directory.GetCurrentDirectory(), "TMP_" + LocalizationFileObject.LOCALIZATION_FILE_NAME, csvStringUsedToUpdateGrid);
            ReloadModLocalizationGrid(pathToTempFile);
        }
        private void SaveButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(ChangeNameAllTagsComboBox.Text))
            {
                string currentSelectedModTag = AllTagsComboBox.Text;
                SaveModInfo(currentSelectedModTag);
            }
            else
            {
                //prompt user to create new mod with text provided
                string           message = "The selected mod name provided does not exist, would you like to create it as a new mod now with all provided modinfo values?";
                MessageBoxResult results = MessageBox.Show(message, "Create New Mod", MessageBoxButton.YesNo, MessageBoxImage.Question);
                switch (results)
                {
                case MessageBoxResult.Yes:
                    List <string> allCustomModsInPath = XmlFileManager.GetCustomModFoldersInOutput();
                    //If the new name is not in te output path
                    if (!allCustomModsInPath.Contains(ChangeNameAllTagsComboBox.Text))
                    {
                        SaveModInfo(ChangeNameAllTagsComboBox.Text);
                    }
                    else
                    {
                        string modExistsMessage = "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(modExistsMessage, "Mod Name Exists", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    break;

                case MessageBoxResult.No:
                    ChangeNameAllTagsComboBox.Text = "";
                    break;
                }
            }
        }
        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 MoveFileMenuHeader_Click(object sender, RoutedEventArgs e)
        {
            string           gameModDirectory = Properties.Settings.Default.GameFolderModDirectory;
            MessageBoxResult result           = MessageBox.Show(
                "This will copy all local generated xmls files at " +
                XmlFileManager.ModConfigOutputPath + "\n" +
                " and replace the files at \n" +
                Path.Combine(gameModDirectory, Properties.Settings.Default.ModTagSetting) + "\n" +
                "Are you sure?",
                "Stage Generated XMLS",
                MessageBoxButton.OKCancel,
                MessageBoxImage.Warning);

            switch (result)
            {
            case MessageBoxResult.OK:
                //User clicked move before setting the Game Mod folder
                if (String.IsNullOrEmpty(gameModDirectory))
                {
                    HandleMissingGameModDirectory();
                }
                //Make sure they set the Game mod directory
                if (!String.IsNullOrEmpty(Properties.Settings.Default.GameFolderModDirectory))
                {
                    XmlFileManager.CopyAllOutputFiles();
                }
                break;
            }
        }
        private string GetCurrentFileContents()
        {
            string parentString = Wrapper.XmlFile.ParentPath ?? "";
            string fileContents = XmlFileManager.GetFileContents(Path.Combine(this.FileLocationPath, parentString), Wrapper.XmlFile.FileName);

            return(fileContents);
        }
        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 DirectEditView_Closing(object sender, CancelEventArgs e)
        {
            if (IsFileChanged())
            {
                MessageBoxResult result = MessageBox.Show(
                    "You have unsaved changes! Would you like to save them now?",
                    "Save Changes",
                    MessageBoxButton.YesNoCancel,
                    MessageBoxImage.Warning);
                switch (result)
                {
                case MessageBoxResult.Yes:
                    string parentString = Wrapper.XmlFile.ParentPath ?? "";
                    string xmlOut       = XmlOutputBox.Text;
                    if (!String.IsNullOrEmpty(xmlOut))
                    {
                        XmlFileManager.WriteStringToFile(Path.Combine(XmlFileManager.ModConfigOutputPath, parentString), Wrapper.XmlFile.FileName, xmlOut, true);
                    }
                    break;

                case MessageBoxResult.Cancel:
                    DirectEditView directEditView = new DirectEditView(this.Wrapper, this.DictionaryKey, this.IsGameFile, this.IsFirstWindowOpen, this.StartingTitle, XmlOutputBox.Text, FileLocationPath, this.UnchangedStartingFileContents);
                    directEditView.Show();
                    break;
                }
            }
        }
        private void MyWindow_Loaded(object sender, RoutedEventArgs e)
        {
            string openingText = "Thank you for downloading the 7 days to die Mod Creator! \n" +
                                 "If you have any issues please report them in the comments on the nexus page.\n\n" +
                                 "IMPORTANT: If you lose work check the log.txt in the Output folder.\n" +
                                 "Any time you close the app or clear the object view, the xml that could be generated is output in that log.\n\n" +
                                 "If you like the application don't forget to leave me a comment or better yet drop an endorsment!\n" +
                                 "Good luck with your mods!";

            this.XmlOutputBox.Text                = openingText;
            this.LoadedListWrappers               = new Dictionary <string, XmlObjectsListWrapper>();
            this.MainWindowFileController         = new MainWindowFileController(this.LoadedListWrappers);
            this.MainWindowViewController         = new MainWindowViewController();
            MainWindowViewController.XmlOutputBox = this.XmlOutputBox;

            MainWindowViewController.LoadedListWrappers = this.LoadedListWrappers;
            SetPanels();
            SetCustomModViewElements();
            SetEvents();
            MainWindowViewController.IncludeAllModsCheckBox = this.IncludeAllModsInBoxesCheckBox;
            this.IncludeCommentsCheckBox.IsChecked          = Properties.Settings.Default.IncludeCommentsSearchTreeTooltip;
            this.IncludeChildrenInOnHoverCheckBox.IsChecked = Properties.Settings.Default.IncludeChildrenSearchTreeTooltip;
            this.IncludeAllModsInBoxesCheckBox.IsChecked    = Properties.Settings.Default.IncludeAllModsObjectTreeAttributes;
            this.IgnoreAllAttributesCheckBox.IsChecked      = Properties.Settings.Default.IgnoreAllAttributesCheckbox;
            this.IgnoreAllAttributesCheckBox.Click         += IgnoreAllAttributesCheckBox_Click;

            MainWindowFileController.LoadStartingDirectory(SearchTreeLoadedFilesComboBox, NewObjectViewLoadedFilesComboBox, CurrentModFilesCenterViewComboBox, LoadedModsSearchViewComboBox, CurrentGameFilesCenterViewComboBox);
            this.LoadedModsCenterViewComboBox.SetComboBox(XmlFileManager.GetCustomModFoldersInOutput());
            this.CurrentModFilesCenterViewComboBox.SetComboBox(XmlFileManager.GetCustomModFilesInOutput(Properties.Settings.Default.ModTagSetting, Properties.Settings.Default.ModTagSetting + "_"));
            this.LoadedModsCenterViewComboBox.Text = Properties.Settings.Default.ModTagSetting;
            SetMainWindowToolTips();
            SetBackgroundFromSetting();
        }
        public LocalizationSettingWindow(Dictionary <string, XmlObjectsListWrapper> loadedListWrappers)
        {
            InitializeComponent();

            Closing += new CancelEventHandler(LocalizatonSettingWindow_Closing);

            AddTooltips();

            StartingMod             = Properties.Settings.Default.ModTagSetting;
            WindowTitle             = StartingMod.ToString();
            this.Title              = GetTitleForWindow();
            this.LoadedListWrappers = loadedListWrappers;

            string pathToModLocalizationFile = XmlFileManager.ModConfigOutputPath + LocalizationFileObject.LOCALIZATION_FILE_NAME;

            ModLocalizationGridUserControl = new LocalizationGridUserControl(pathToModLocalizationFile);
            GridAsCSVAfterUpdate           = ModLocalizationGridUserControl.Maingrid.GridAsCSV();

            List <string> allCustomTagDirectories = XmlFileManager.GetCustomModFoldersInOutput();

            foreach (string nextModTag in allCustomTagDirectories)
            {
                ModSelectionComboBox.AddUniqueValueTo(nextModTag);
            }
            ModSelectionComboBox.SelectedItem = Properties.Settings.Default.ModTagSetting;

            ModSelectionComboBox.DropDownClosed += ModSelectionComboBox_DropDownClosed;

            ModLocalizationScrollViewer.Content = ModLocalizationGridUserControl;

            string pathToGameLocalizationFile = XmlFileManager.LoadedFilesPath + LocalizationFileObject.LOCALIZATION_FILE_NAME;

            GameLocalizationFile = new LocalizationFileObject(pathToGameLocalizationFile);
            TextEditorOptions newOptions = new TextEditorOptions
            {
                EnableRectangularSelection = true,
                EnableTextDragDrop         = true,
                HighlightCurrentLine       = true,
                ShowTabs = true
            };

            LocalizationPreviewBox.ShowLineNumbers  = true;
            LocalizationPreviewBox.TextArea.Options = newOptions;
            LocalizationPreviewBox.Text             = ModLocalizationGridUserControl.Maingrid.GridAsCSV();
            LocalizationPreviewBox.LostFocus       += LocalizationPreviewBox_LostFocus;
            SearchPanel.Install(LocalizationPreviewBox);
            ModLocalizationScrollViewer.GotFocus  += Maingrid_GotOrLostFocus;
            ModLocalizationScrollViewer.LostFocus += Maingrid_GotOrLostFocus;

            SortedSet <string> gameFileKeysSorted = GameLocalizationFile.HeaderKeyToCommonValuesMap.GetValueOrDefault(GameLocalizationFile.KeyColumn);
            List <string>      gameFileKeys       = new List <string>(gameFileKeysSorted);

            GameKeySelectionComboBox.SetComboBox(gameFileKeys);
            GameKeySelectionComboBox.IsEditable      = true;
            GameKeySelectionComboBox.DropDownClosed += GameKeySelectionComboBox_DropDownClosed;
            GameKeySelectionComboBox.PreviewKeyDown += GameKeySelectionComboBox_PreviewKeyDown;

            SetBackgroundColor();
        }
 /// <summary>
 /// Saves updated parameter values
 /// </summary>
 private void SaveParameters()
 {
     // Save parameter values selected from UI
     XmlFileManager.SaveHistoricalParameters(
         SelectedStartDate.ToString("yyyy,MM,dd"),
         SelectedEndDate.ToString("yyyy,MM,dd"),
         SelectedProvider.ProviderName, _filePath);
 }
Пример #19
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);
        }
        private void DeleteModButton_Click(object sender, RoutedEventArgs e)
        {
            string message = "Mod folders cannot be deleted directly in the app. To delete this mod, select a different mod in the combo box, open the output folder in explorer and delete it manually from the mods folder. After, to refresh the app click the reload mods button or you can just restart the app.:\n\n"
                             + XmlFileManager.Get_ModDirectoryOutputPath(LoadedModsCenterViewComboBox.Text);
            string title = "Delete Mod Help";

            MessageBox.Show(message, title, MessageBoxButton.OK, MessageBoxImage.Information);
        }
Пример #21
0
        public CimToolBase(CimToolSettings modSettings)
        {
            m_modSettings     = modSettings;
            m_saveFileOptions = new SaveFileManager(modSettings);
            m_xmlOptions      = new XmlFileManager(modSettings);

            m_xmlOptions.Load();
        }
Пример #22
0
        private void SaveLocalizationTableButton_Click(object sender, RoutedEventArgs e)
        {
            SaveLocalization();
            string message = "Successfully saved changes to: \n\n " + XmlFileManager.Get_ModOutputPath(ModSelectionComboBox.SelectedItem.ToString()) + LocalizationFileObject.LOCALIZATION_FILE_NAME;
            string caption = "Save Grid to Localization.txt";

            MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Information);
        }
Пример #23
0
        private void AddNewGridWithRecord(string gameKeyRecord)
        {
            string pathToTempFile = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "TMP_" + LocalizationFileObject.LOCALIZATION_FILE_NAME);

            XmlFileManager.WriteStringToFile(Directory.GetCurrentDirectory(), "TMP_" + LocalizationFileObject.LOCALIZATION_FILE_NAME, gameKeyRecord);
            GameRecordGridUserControl      = new LocalizationGridUserControl(pathToTempFile, true);
            GameRecordScrollViewer.Content = GameRecordGridUserControl;
        }
        //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);
            }
        }
        private void SaveModInfo(string modNameToUse)
        {
            ModInfo newModIfo     = new ModInfo(ModInfoNameBox.Text, ModInfoDescriptionBox.Text, ModInfoAuthorBox.Text, ModInfoVersionBox.Text);
            string  modInfoXmlOut = newModIfo.ToString();

            ModInfo.CreateModInfoFile(modNameToUse);
            XmlFileManager.WriteStringToFile(XmlFileManager.Get_ModDirectoryOutputPath(modNameToUse), ModInfo.MOD_INFO_FILE_NAME, modInfoXmlOut);
            ResetModNameComboBoxes(modNameToUse);
            MessageBox.Show("Saved mod info for " + modNameToUse + ".", "Saving Mod info", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Пример #26
0
        public void SetGetGroupedValues()
        {
            XmlFileManager fileManager = new XmlFileManager(new CimTools.Legacy.CimToolSettings("TestSaveLoad"));

            fileManager.Data.SetValue("float", 12.3f, "group 1");
            fileManager.Data.SetValue("double", 34.5, "group 1");
            fileManager.Data.SetValue("double 2", 67.8, "group 1");
            fileManager.Data.SetValue("string", "a string", "group 1");
            fileManager.Data.SetValue("string 2", "56.7", "group 1");
            fileManager.Data.SetValue("int", 1, "group 1");

            fileManager.Data.SetValue("float", 98.7f, "group 2");
            fileManager.Data.SetValue("double", 65.4, "group 2");

            var foundFloatValues = fileManager.Data.GetValues <float>("group 1");

            Assert.AreEqual(1, foundFloatValues.Count);
            Assert.IsTrue(foundFloatValues.ContainsKey("float"));
            Assert.AreEqual(12.3f, foundFloatValues["float"]);

            foundFloatValues = fileManager.Data.GetValues <float>("group 1", false);
            Assert.AreEqual(5, foundFloatValues.Count);

            var foundDoubleValues = fileManager.Data.GetValues <double>("group 1");

            Assert.AreEqual(2, foundDoubleValues.Count);
            Assert.IsTrue(foundDoubleValues.ContainsKey("double"));
            Assert.IsTrue(foundDoubleValues.ContainsKey("double 2"));
            Assert.AreEqual(34.5, foundDoubleValues["double"]);
            Assert.AreEqual(67.8, foundDoubleValues["double 2"]);

            var foundStringValues = fileManager.Data.GetValues <string>("group 1");

            Assert.AreEqual(2, foundStringValues.Count);
            Assert.IsTrue(foundStringValues.ContainsKey("string"));
            Assert.IsTrue(foundStringValues.ContainsKey("string 2"));
            Assert.AreEqual("a string", foundStringValues["string"]);
            Assert.AreEqual("56.7", foundStringValues["string 2"]);

            var foundIntValues = fileManager.Data.GetValues <int>("group 1");

            Assert.AreEqual(1, foundIntValues.Count);
            Assert.IsTrue(foundIntValues.ContainsKey("int"));
            Assert.AreEqual(1, foundIntValues["int"]);

            foundFloatValues = fileManager.Data.GetValues <float>("group 2");
            Assert.AreEqual(1, foundFloatValues.Count);
            Assert.IsTrue(foundFloatValues.ContainsKey("float"));
            Assert.AreEqual(98.7f, foundFloatValues["float"]);

            foundDoubleValues = fileManager.Data.GetValues <double>("group 2");
            Assert.AreEqual(1, foundDoubleValues.Count);
            Assert.IsTrue(foundDoubleValues.ContainsKey("double"));
            Assert.AreEqual(65.4, foundDoubleValues["double"]);
        }
Пример #27
0
        public void SaveLoadValues()
        {
            XmlFileManager fileManager = new XmlFileManager(new CimTools.Legacy.CimToolSettings("TestSaveLoad"));

            fileManager.Data.SetValue("testUshort", (ushort)2);
            fileManager.Data.SetValue("testFloat", 10.4f);
            fileManager.Data.SetValue("testString", "hello");
            fileManager.Data.SetValue("testDouble", 19.2);
            fileManager.Data.SetValue("testInt", 19);
            fileManager.Data.SetValue("testInt", 2082, "awesome group");
            fileManager.Data.SetValue("testDouble", 106.8, "awesome group");
            fileManager.Data.SetValue("testString", "hello again", "awesome group");
            fileManager.Data.SetValue("testDifferentString", "hello again again", "awesome group");
            fileManager.Data.SetValue("testDifferentGroup", "hi", "not as awesome group");

            bool succeeded = fileManager.Save() == ExportOptionBase.OptionError.NoError;

            Assert.IsTrue(succeeded, "Options failed to save to disk");

            if (succeeded)
            {
                float  floatValue  = 0;
                int    intValue    = 0;
                string stringValue = "";

                fileManager = new XmlFileManager(new CimTools.Legacy.CimToolSettings("TestSaveLoad"));

                bool valid = fileManager.Data.GetValue("testFloat", ref floatValue) == ExportOptionBase.OptionError.NoError;
                Assert.IsFalse(valid);

                fileManager.Load();

                valid = fileManager.Data.GetValue("testFloat", ref floatValue) == ExportOptionBase.OptionError.NoError;
                Assert.IsTrue(valid, "Obtaining \"testFloat\" from the options");
                if (valid)
                {
                    Assert.AreEqual(10.4f, floatValue, "Checking whether the value is a float");
                }

                valid = fileManager.Data.GetValue("testInt", ref intValue, "awesome group") == ExportOptionBase.OptionError.NoError;
                Assert.IsTrue(valid, "Obtaining \"testInt\" from the options under \"awesome group\"");
                if (valid)
                {
                    Assert.AreEqual(2082, intValue, "Checking whether the value is an int");
                }

                valid = fileManager.Data.GetValue("testString", ref stringValue, "awesome group") == ExportOptionBase.OptionError.NoError;
                Assert.IsTrue(valid, "Obtaining \"testString\" from the options under \"awesome group\"");
                if (valid)
                {
                    Assert.AreEqual("hello again", stringValue, "Checking whether the value is a string");
                }
            }
        }
Пример #28
0
        public void ErrorHandling()
        {
            XmlFileManager fileManager = new XmlFileManager(new CimTools.Legacy.CimToolSettings("DoesntExist"));

            Assert.AreEqual(fileManager.Load(), ExportOptionBase.OptionError.FileNotFound);

            int tempIntStorage = 0;

            Assert.AreEqual(fileManager.Data.GetValue <int>("NotAValidName", ref tempIntStorage, "NotAValidGroup"), ExportOptionBase.OptionError.GroupNotFound);
            Assert.AreEqual(fileManager.Data.GetValue <int>("NotAValidName", ref tempIntStorage), ExportOptionBase.OptionError.OptionNotFound);
        }
Пример #29
0
        public void SetGetLooseValues()
        {
            XmlFileManager fileManager = new XmlFileManager(new CimTools.Legacy.CimToolSettings("TestSaveLoad"));

            fileManager.Data.SetValue("testFloat", 10.4f);
            fileManager.Data.SetValue("testString", "hello");
            fileManager.Data.SetValue("testDouble", 19.2);
            fileManager.Data.SetValue("testInt", 19);

            float  floatValue  = 0;
            string stringValue = "";
            double doubleValue = 0;
            int    intValue    = 0;

            bool valid = fileManager.Data.GetValue("testFloat", ref floatValue) == ExportOptionBase.OptionError.NoError;

            Assert.IsTrue(valid, "Retrieving \"testFloat\" option");
            if (valid)
            {
                Assert.AreEqual(10.4f, floatValue);
            }

            valid = fileManager.Data.GetValue("testString", ref stringValue) == ExportOptionBase.OptionError.NoError;
            Assert.IsTrue(valid, "Retrieving \"testString\" option");
            if (valid)
            {
                Assert.AreEqual("hello", stringValue);
            }

            valid = fileManager.Data.GetValue("testDouble", ref doubleValue) == ExportOptionBase.OptionError.NoError;
            Assert.IsTrue(valid, "Retrieving \"testDouble\" option");
            if (valid)
            {
                Assert.AreEqual(19.2, doubleValue);
            }

            valid = fileManager.Data.GetValue("testInt", ref intValue) == ExportOptionBase.OptionError.NoError;
            Assert.IsTrue(valid, "Retrieving \"testInt\" option");
            if (valid)
            {
                Assert.AreEqual(19, intValue);
            }

            valid = fileManager.Data.GetValue("testNotInList", ref floatValue) == ExportOptionBase.OptionError.NoError;
            Assert.IsFalse(valid, "Retrieving \"testNotInList\" option");

            valid = fileManager.Data.GetValue("testInt", ref intValue) == ExportOptionBase.OptionError.NoError;
            Assert.IsTrue(valid, "Retrieving \"testInt\" option");
            if (valid)
            {
                Assert.AreNotEqual("string", intValue);
                Assert.AreNotEqual("19", intValue);
            }
        }
Пример #30
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);
        }
Пример #31
0
        public void XmlFileSavesClass()
        {
            _testName = MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString();
            Cleanup();

            var orig = TestResourceFactory.CreateRandom().WithId(1234) as MockClassC;

            using (var repo = new XmlFileManager<MockClassC>())
            {
                repo.WorkingPath = "";
                repo.SaveToFile(orig, _testName + ".xml", ".");
            }

            using (var repo = new XmlFileManager<MockClassC>())
            {
                var item = repo.LoadFromFile(_testName + ".xml");

                Assert.AreEqual(item.Id, orig.Id);
                Assert.AreEqual(item.Name, orig.Name);
                Assert.AreEqual(item.GetSomeCheckSum[0], orig.GetSomeCheckSum[0]);
                Assert.AreEqual(item.Location.X, orig.Location.X);
                Assert.AreEqual(item.Location.Y, orig.Location.Y);
                Assert.AreEqual(item.Location.Z, orig.Location.Z);
                Assert.AreEqual(item.Location.W, orig.Location.W);
                Assert.AreEqual(item.ReferenceCode, orig.ReferenceCode);
                Assert.AreEqual(item.ReplicationID, orig.ReplicationID);
            }
        }
Пример #32
0
        public void XmlFileSavesBinaryReadsXml()
        {
            _testName = MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString();
            Cleanup();

            var orig = TestResourceFactory.CreateRandom().WithId(1234) as MockClassC;

            using (var repo = new XmlFileManager<MockClassC>())
            {
                repo.WorkingPath = "";
                var xml = XmlSerializationHelper.Serialize(orig);
                var buffer = UTF8Encoding.UTF8.GetBytes(xml);

                repo.SaveToFile(buffer, _testName + ".xml", ".");
            }

            using (var repo = new XmlFileManager<MockClassC>())
            {
                repo.WorkingPath = "";
                var item = repo.LoadFromFile(_testName + ".xml", ".");

                Assert.AreEqual(item.Id, orig.Id);
                Assert.AreEqual(item.Name, orig.Name);
                Assert.AreEqual(item.GetSomeCheckSum[0], orig.GetSomeCheckSum[0]);
                Assert.AreEqual(item.Location.X, orig.Location.X);
                Assert.AreEqual(item.Location.Y, orig.Location.Y);
                Assert.AreEqual(item.Location.Z, orig.Location.Z);
                Assert.AreEqual(item.Location.W, orig.Location.W);
                Assert.AreEqual(item.ReferenceCode, orig.ReferenceCode);
                Assert.AreEqual(item.ReplicationID, orig.ReplicationID);

                var stream = repo.LoadAsStream(_testName + ".xml", ".");

                Assert.IsNotNull(stream);
            }
        }