Exemple #1
0
        static public bool LoadGraphicOptionsFile(string optionsFilePath)
        {
            bool retValue = false;

            try
            {
                SettingsFileIO settingsFileIO = new SettingsFileIO();
                settingsFileIO.SetSettingsFilePath(optionsFilePath);
                if (settingsFileIO.GetFileType() != SettingsContent.FileType.SETTINGS)
                {
                    return(retValue);
                }

                graphicOptionsValue.optionsFilePath   = optionsFilePath;
                graphicOptionsValue.enableVSync       = Convert.ToBoolean(Int32.Parse(settingsFileIO.ReadValue(settingsSection, "vsync")));
                graphicOptionsValue.enableFullScreen  = Convert.ToBoolean(Int32.Parse(settingsFileIO.ReadValue(settingsSection, "fullscreen")));
                graphicOptionsValue.enableMotionBlur  = Convert.ToBoolean(Int32.Parse(settingsFileIO.ReadValue(settingsSection, "motionblur")));
                graphicOptionsValue.simulatorWidth    = Int32.Parse(settingsFileIO.ReadValue(settingsSection, "simulatorwidth"));
                graphicOptionsValue.simulatorHeight   = Int32.Parse(settingsFileIO.ReadValue(settingsSection, "simulatorheight"));
                graphicOptionsValue.antiAliasingLevel = Int32.Parse(settingsFileIO.ReadValue(settingsSection, "antialiasinglevel"));
                graphicOptionsValue.transparencyLevel = Int32.Parse(settingsFileIO.ReadValue(settingsSection, "transparencylevel"));
                graphicOptionsValue.viewingDistance   = Int32.Parse(settingsFileIO.ReadValue(settingsSection, "viewingdistance"));
                graphicOptionsValue.optionsFileLoaded = true;
                settingsFileIO.Dispose();
                retValue = true;
            }
            catch (Exception) { };
            return(retValue);
        }
Exemple #2
0
        static public void UpdateControlObjectsItem()
        {
            try
            {
                controlObjectFilesCount = 0;
                SettingsContent.UpdateSettingsPath();
                DirectoryInfo  objectPath     = new DirectoryInfo(SettingsContent.controlObjectPath);
                FileInfo[]     objectFiles    = objectPath.GetFiles();
                SettingsFileIO settingsFileIO = new SettingsFileIO();
                foreach (FileInfo fileName in objectFiles)
                {
                    if (fileName.Extension == SettingsContent.universalFileExtName)
                    {
                        try
                        {
                            settingsFileIO.SetSettingsFilePath(fileName.FullName);
                            if (settingsFileIO.GetFileType() == SettingsContent.FileType.OBJECT)
                            {
                                int objectID = Int32.Parse(settingsFileIO.ReadValue(controlObjectSection, "object_id"));
                                controlObjectFilesCount++;
                                if (objectID > controlObjectsCount)
                                {
                                    continue;
                                }

                                controlObjectsInfo[objectID].objectIOMode.Clear();
                                controlObjectsInfo[objectID].objectIODescrible.Clear();
                                controlObjectsInfo[objectID].objectData.Clear();
                                controlObjectsInfo[objectID].objectFilePath = fileName.FullName;
                                //Area control_object
                                controlObjectsInfo[objectID].objectID            = objectID;
                                controlObjectsInfo[objectID].objectName          = settingsFileIO.ReadValue(controlObjectSection, "object_name");
                                controlObjectsInfo[objectID].objectDescribe      = settingsFileIO.ReadValue(controlObjectSection, "object_describle");
                                controlObjectsInfo[objectID].objectSetEnable     = Convert.ToBoolean(Int32.Parse(settingsFileIO.ReadValue(controlObjectSection, "object_set_enable")));
                                controlObjectsInfo[objectID].objectTimerAttached = Convert.ToBoolean(Int32.Parse(settingsFileIO.ReadValue(controlObjectSection, "object_timer_attached")));
                                //Area object_io
                                controlObjectsInfo[objectID].objectIOCount = Int32.Parse(settingsFileIO.ReadValue(objectIOSection, "object_io_count"));
                                for (int i = 0; i < controlObjectsInfo[objectID].objectIOCount; i++)
                                {
                                    controlObjectsInfo[objectID].objectIOMode.Add(
                                        (DevicesManager.DevicesIOMode)Int32.Parse(settingsFileIO.ReadValue(objectIOSection, "object_io_" + i.ToString() + "_mode")));
                                    controlObjectsInfo[objectID].objectIODescrible.Add(settingsFileIO.ReadValue(objectIOSection, "object_io_" + i.ToString() + "_describe"));
                                }
                                //Area object_data_attach
                                controlObjectsInfo[objectID].objectDataCount = Int32.Parse(settingsFileIO.ReadValue(objectDataSection, "object_data_count"));
                                for (int i = 0; i < controlObjectsInfo[objectID].objectDataCount; i++)
                                {
                                    controlObjectsInfo[objectID].objectData.Add(settingsFileIO.ReadValue(objectDataSection, "object_data_" + i.ToString()));
                                }
                            }
                        }
                        catch (Exception) { };
                        settingsFileIO.Dispose();
                    }
                }
            }
            catch (Exception) { };
        }
Exemple #3
0
        static public PackageInfo ReadPackageInfo(string packageFilePath)
        {
            PackageInfo retValue = new PackageInfo();

            try
            {
                if (!File.Exists(packageFilePath))
                {
                    return(retValue);
                }

                string         packagePath    = Path.GetDirectoryName(packageFilePath);
                SettingsFileIO settingsFileIO = new SettingsFileIO();
                settingsFileIO.SetSettingsFilePath(packageFilePath);
                if (settingsFileIO.GetFileType() != SettingsContent.FileType.RESPACK)
                {
                    return(retValue);
                }
                //Load package
                retValue.packageName        = settingsFileIO.ReadValue(packageInfoSection, "name");
                retValue.packageVersion     = settingsFileIO.ReadValue(packageInfoSection, "version");
                retValue.packageGUID        = settingsFileIO.ReadValue(packageInfoSection, "packageguid");
                retValue.packageDescription = settingsFileIO.ReadValue(packageInfoSection, "description");
                //Load dir
                retValue.packageRouteRelateDir = settingsFileIO.ReadValue(packageDirSection, "route_file");
                retValue.packageRouteDir       = Path.GetFullPath(packagePath + "\\" + retValue.packageRouteRelateDir);
                retValue.packageTrainRelateDir = settingsFileIO.ReadValue(packageDirSection, "train_file");
                retValue.packageTrainDir       = Path.GetFullPath(packagePath + "\\" + retValue.packageTrainRelateDir);
                try
                {
                    retValue.packageRouteImageRelateDir = settingsFileIO.ReadValue(packageDirSection, "route_image");
                    retValue.packageRouteImage          = Image.FromFile(Path.GetFullPath(packagePath) + "\\" + retValue.packageTrainImageRelateDir);
                    retValue.packageTrainRelateDir      = settingsFileIO.ReadValue(packageDirSection, "train_image");
                    retValue.packageTrainImage          = Image.FromFile(Path.GetFullPath(packagePath) + "\\" + retValue.packageTrainRelateDir);
                }
                catch (Exception) { };
                settingsFileIO.Dispose();
                retValue.packageFileLoaded     = true;
                retValue.routeDetailInfoLoaded = false;
                retValue.trainDetailInfoLoaded = false;
            }
            catch (Exception) { };
            return(retValue);
        }
Exemple #4
0
        static public bool UpdatePackageList()
        {
            bool retValue = false;

            try
            {
                //Clear package list
                packageList.packageCount = 0;
                packageList.packageDefineFilePath.Clear();
                packageList.packageGUID.Clear();
                packageList.packageName.Clear();
                //Update
                SettingsContent.UpdateSettingsPath();
                DirectoryInfo  boardPath      = new DirectoryInfo(SettingsContent.packagePath);
                SettingsFileIO settingsFileIO = new SettingsFileIO();
                foreach (DirectoryInfo subDirectory in boardPath.GetDirectories())
                {
                    FileInfo[] packageDefinieFiles = subDirectory.GetFiles();
                    foreach (FileInfo fileName in packageDefinieFiles)
                    {
                        if (fileName.Extension == SettingsContent.universalFileExtName)
                        {
                            string packageDefineFilePath = fileName.FullName;
                            settingsFileIO.SetSettingsFilePath(packageDefineFilePath);
                            if (settingsFileIO.GetFileType() == SettingsContent.FileType.RESPACK)
                            {
                                //MessageBox.Show(packageDefineFilePath);
                                packageList.packageCount++;
                                packageList.packageDefineFilePath.Add(packageDefineFilePath);
                                packageList.packageGUID.Add(settingsFileIO.ReadValue(packageInfoSection, "packageguid"));
                                packageList.packageName.Add(settingsFileIO.ReadValue(packageInfoSection, "name"));
                            }
                            settingsFileIO.Dispose();
                        }
                    }
                }
            }
            catch (Exception) { };
            return(retValue);
        }
Exemple #5
0
        static public bool UpdateBoardItems()
        {
            bool retValue = false;

            try
            {
                //Clear boardList
                boardList.boardCount = 0;
                boardList.boardFilePath.Clear();
                boardList.boardID.Clear();
                boardList.boardName.Clear();
                //Update
                SettingsContent.UpdateSettingsPath();
                DirectoryInfo  boardPath      = new DirectoryInfo(SettingsContent.boardPath);
                FileInfo[]     boardFiles     = boardPath.GetFiles();
                SettingsFileIO settingsFileIO = new SettingsFileIO();
                foreach (FileInfo fileName in boardFiles)
                {
                    if (fileName.Extension == SettingsContent.universalFileExtName)
                    {
                        settingsFileIO.SetSettingsFilePath(fileName.FullName);
                        if (settingsFileIO.GetFileType() == SettingsContent.FileType.BOARD)
                        {
                            boardList.boardCount++;
                            boardList.boardFilePath.Add(fileName.FullName);
                            boardList.boardID.Add(Int32.Parse(settingsFileIO.ReadValue(boardInfoSection, "board_id")));
                            boardList.boardName.Add(settingsFileIO.ReadValue(boardInfoSection, "board_name"));
                        }
                        settingsFileIO.Dispose();
                    }
                }
                retValue = true;
            }
            catch (Exception) { };
            return(retValue);
        }