Example #1
0
        /// <summary>
        ///     Changes the files content and therefore repairs it.
        /// </summary>
        /// Gets the correct values from the ini-File and compares the actual value from the files.
        /// If the values aren't the same, the wrong values get changed and corrected.
        public void RepairFiles()
        {
            //Get filepath for all files that need to get changed
            foreach (string filepath in _incorrectFiles)
            {
                var configIniHandler = new IniHandler(filepath);
                _tempRootSpecsDir   = configIniHandler.IniReadValue("System", "Root_Specs_Dir");
                _tempRootModulesDir = configIniHandler.IniReadValue("System", "Root_Modules_Dir");
                _tempModulesIniFile = configIniHandler.IniReadValue("System", "Modules_Ini_File");

                //Get which variable needs to get changed

                if (_tempRootSpecsDir != _correctRootSpecsDir)
                {
                    configIniHandler.IniWriteValue("System", "Root_Specs_Dir", _correctRootSpecsDir);
                }
                if (_tempRootModulesDir != _correctRootModulesDir)
                {
                    configIniHandler.IniWriteValue("System", "Root_Modules_Dir", _correctRootModulesDir);
                }
                if (_tempModulesIniFile != _correctModulesIniFile)
                {
                    configIniHandler.IniWriteValue("System", "Modules_Ini_File", _correctModulesIniFile);
                }
            }
        }
Example #2
0
        /// <summary>
        ///     Gets the wrong values from the files and changes them if needed.
        /// </summary>
        /// Gets the correct values from the ini-File and compares the actual value from the files.
        /// If the values aren't the same, the wrong values get changed and corrected.
        public void RepairFiles()
        {
            //Get filepath for all files that need to get changed
            foreach (string filepath in _incorrectFiles)
            {
                var configIniHandler = new IniHandler(filepath);
                _tempRootSpecsDir   = configIniHandler.IniReadValue("System", "Root_Specs_Dir");
                _tempRootModulesDir = configIniHandler.IniReadValue("System", "Root_Modules_Dir");
                _tempModulesIniFile = configIniHandler.IniReadValue("System", "Modules_Ini_File");

                /*
                 * TODO Check if user wants to correct file
                 * Take the whole EntityList as parameter so that the User can choose
                 * which Item to change by clicking on the checkbox.
                 *
                 * [Important]
                 * Check if value updates on changes to checkbox.IsChecked → Is this value also updated here (maybe use static method?)
                 * Use UpdateSourceTrigger="OnValueChanged" in MainWindow.xaml
                 */

                if (_tempRootSpecsDir != _correctRootSpecsDir)
                {
                    configIniHandler.IniWriteValue("System", "Root_Specs_Dir", _correctRootSpecsDir);
                }
                if (_tempRootModulesDir != _correctRootModulesDir)
                {
                    configIniHandler.IniWriteValue("System", "Root_Modules_Dir", _correctRootModulesDir);
                }
                if (_tempModulesIniFile != _correctModulesIniFile)
                {
                    configIniHandler.IniWriteValue("System", "Modules_Ini_File", _correctModulesIniFile);
                }
            }
        }
Example #3
0
        public static void loadInifiles(string currentDirectory)
        {
            if (Program.useIniFiles && File.Exists(currentDirectory + "/RedirectionSettings.ini"))
            {
                //Read from .ini file
                IniHandler settings = new IniHandler(currentDirectory + "/RedirectionSettings.ini");
                //Init values
                Program.loginServerIP = settings.IniReadValue("Config", "serverIP");
                Program.serverWebsite = settings.IniReadValue("Config", "website");
                Program.registerUrl   = settings.IniReadValue("Config", "registerUrl");
                Program.serverName    = settings.IniReadValue("Config", "serverName");

                //DNS settings
                Program.resolveDNS = false;

                //Game settings
                Program.gameVersion  = Int32.Parse(settings.IniReadValue("Config", "gameVersion"));
                Program.patchVersion = settings.IniReadValue("Config", "patchVersion");
                Program.locale       = (byte)Int32.Parse(settings.IniReadValue("Config", "locale"));

                //Port range (lowPort and highPort should cover all your channels and misc. servers like cash shop and farm)
                Program.lowPort  = (ushort)Int32.Parse(settings.IniReadValue("Config", "portRangeMin"));
                Program.highPort = (ushort)Int32.Parse(settings.IniReadValue("Config", "portRangeMax"));
            }
        }
Example #4
0
        /// <summary>
        /// Reads the content from the files and calls SetEntityContent to save the values.
        /// </summary>
        /// <param name="directoryOfFoldersList">List with the path to the folders</param>
        private void ReadFileContent(IEnumerable <string> directoryOfFoldersList)
        {
            var prefix = _resEdit.GetPrefix();

            foreach (var filepath in directoryOfFoldersList)
            {
                //Analyzes the Filepath and checks if it contains the prefix selected in the Settings
                //Prepare the path to the files
                if (filepath.Substring(_workingDirectory.Length, prefix.Length) != prefix)
                {
                    continue;
                }
                var projIniHandler   = new IniHandler($@"{filepath}\project.ini");
                var configIniHandler = new IniHandler($@"{filepath}\Config\config.ini");

                //Get content from project.ini
                _tempProjectName   = projIniHandler.IniReadValue("GENERAL", "PROJECTNAME");
                _tempProjectId     = projIniHandler.IniReadValue("GENERAL", "PROJECTID");
                _tempProjectGuid   = projIniHandler.IniReadValue("GENERAL", "PROJECTGUID");
                _tempPwProject     = projIniHandler.IniReadValue("ProjectWise", "PWProject");
                _tempPwProjectGuid = projIniHandler.IniReadValue("ProjectWise", "PWProjectGUID");

                //get content from config.ini
                _tempRootSpecsDir   = configIniHandler.IniReadValue("System", "Root_Specs_Dir");
                _tempRootModulesDir = configIniHandler.IniReadValue("System", "Root_Modules_Dir");
                _tempModulesIniFile = configIniHandler.IniReadValue("System", "Modules_Ini_File");

                //Search for wrong values and set the
                if (_tempRootSpecsDir != _correctRootSpecsDir || _tempRootModulesDir != _correctRootModulesDir ||
                    _tempModulesIniFile != _correctModulesIniFile) //MODULES INI FILE
                {
                    _tempIsChecked = true;
                    _incorrectFiles.Add($@"{filepath}\Config\config.ini"); //TODO check onenote for infos (Buhler AG → iniTool)
                }
                else
                {
                    _tempIsChecked = false;
                }

                //Add content to _entityContent
                SetEntityContents(filepath, _tempIsChecked, _tempProjectName, _tempProjectId, _tempProjectGuid,
                                  _tempPwProject, _tempPwProjectGuid, _tempRootSpecsDir, _tempRootModulesDir, _tempModulesIniFile);
            }
        }
Example #5
0
        private void SetCorrectFiles(IEnumerable <string> fileArray, string dir)
        {
            var prefix = _resEdit.GetPrefix();

            foreach (var filepath in fileArray)
            {
                if (filepath.Substring(dir.Length, prefix.Length) != prefix)
                {
                    continue;
                }
                var projIniHandler   = new IniHandler($@"{filepath}\project.ini");
                var configIniHandler = new IniHandler($@"{filepath}\Config\config.ini");

                //get content form project.ini
                _tempProjectName   = projIniHandler.IniReadValue("GENERAL", "PROJECTNAME");
                _tempProjectId     = projIniHandler.IniReadValue("GENERAL", "PROJECTID");
                _tempProjectGuid   = projIniHandler.IniReadValue("GENERAL", "PROJECTGUID");
                _tempPwProject     = projIniHandler.IniReadValue("ProjectWise", "PWProject");
                _tempPwProjectGuid = projIniHandler.IniReadValue("ProjectWise", "PWProjectGUID");

                //get content from config.ini
                _tempRootSpecsDir   = configIniHandler.IniReadValue("System", "Root_Specs_Dir");
                _tempRootModulesDir = configIniHandler.IniReadValue("System", "Root_Modules_Dir");
                _tempModulesIniFile = configIniHandler.IniReadValue("System", "Modules_Ini_File");

                //Search for files
                if (_tempRootSpecsDir != _correctRootSpecsDir || _tempRootModulesDir != _correctRootModulesDir ||
                    _tempModulesIniFile != _correctModulesIniFile) //MODULES INI FILE
                {
                    _tempIsChecked = true;
                    _incorrectFiles.Add($@"{filepath}\Config\config.ini"); //TODO was here
                }
                else
                {
                    _tempIsChecked = false;
                }

                //Add content to contentList
                SetContentList(filepath, _tempIsChecked, _tempProjectName, _tempProjectId, _tempProjectGuid,
                               _tempPwProject, _tempPwProjectGuid, _tempRootSpecsDir, _tempRootModulesDir, _tempModulesIniFile);
            }
        }
Example #6
0
        /// <summary>
        /// Gets the path of the workspace.
        /// </summary>
        /// <returns name="workspacePath"></returns>
        /// Returns the path.
        public string GetWorkspace()
        {
            var workspacePath = _iniHandler.IniReadValue("GENERAL", "workspacePath");

            if (!string.IsNullOrEmpty(workspacePath))
            {
                return(workspacePath);
            }

            MessageBox.Show("No workspace selected!", "Error", MessageBoxButton.OK);
            return(null);
        }
        public string getSavePath()
        {
            string ret = handler.IniReadValue("basic", "savepath");

            if (ret == "")
            {
                ret = saveFolder;
            }
            return(ret);
        }