Esempio n. 1
0
        public Config(string filePath)
        {
            FilePath = filePath;

            if (!Directory.Exists(Path.GetDirectoryName(FilePath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(FilePath));
            }

            if (File.Exists(FilePath))
            {
                Load();
                var text = File.ReadAllText(FilePath);
                if (!text.Contains("fitToCanvas") && Path.GetFileName(FilePath) == "cameraplus.cfg")
                {
                    fitToCanvas = true;
                }
                if (text.Contains("rotx"))
                {
                    var oldRotConfig = new OldRotConfig();
                    ConfigSerializer.LoadConfig(oldRotConfig, FilePath);

                    var euler = new Quaternion(oldRotConfig.rotx, oldRotConfig.roty, oldRotConfig.rotz, oldRotConfig.rotw).eulerAngles;
                    angx = euler.x;
                    angy = euler.y;
                    angz = euler.z;
                }
            }
            Save();

            _configWatcher = new FileSystemWatcher(Path.GetDirectoryName(FilePath))
            {
                NotifyFilter        = NotifyFilters.LastWrite,
                Filter              = Path.GetFileName(FilePath),
                EnableRaisingEvents = true
            };
            _configWatcher.Changed += ConfigWatcherOnChanged;
        }
Esempio n. 2
0
        public Config(string filePath)
        {
            FilePath = filePath;

            if (File.Exists(FilePath))
            {
                Load();
                var text = File.ReadAllText(FilePath);
                if (text.Contains("rotx"))
                {
                    var oldRotConfig = new OldRotConfig();
                    ConfigSerializer.LoadConfig(oldRotConfig, FilePath);

                    var euler = new Quaternion(oldRotConfig.rotx, oldRotConfig.roty, oldRotConfig.rotz,
                                               oldRotConfig.rotw)
                                .eulerAngles;
                    angx = euler.x;
                    angy = euler.y;
                    angz = euler.z;

                    Save();
                }
            }
            else
            {
                Save();
            }

            _configWatcher = new FileSystemWatcher(Environment.CurrentDirectory)
            {
                NotifyFilter        = NotifyFilters.LastWrite,
                Filter              = "cameraplus.cfg",
                EnableRaisingEvents = true
            };
            _configWatcher.Changed += ConfigWatcherOnChanged;
        }