예제 #1
0
파일: TsiFile.cs 프로젝트: whiteschool/cmdr
        private TsiFile(string traktorVersion)
        {
            TraktorVersion = traktorVersion;

            _devices          = new List <Device>();
            _devicesContainer = new DeviceMappingsContainer();
        }
예제 #2
0
        private TsiFile(string traktorVersion)
        {
            TraktorVersion = traktorVersion;
            OptimizeFXList = false;            // this ONLY gets the actual value on the SAVE command

            _devices          = new List <Device>();
            _devicesContainer = new DeviceMappingsContainer();
        }
예제 #3
0
        public TsiFile(Stream source)
        {
            string data = XDocument
                          .Load(source)
                          .XPathSelectElement(XPATH_TO_DATA)
                          .Attribute("Value")
                          .Value;

            byte[] decoded = Convert.FromBase64String(data);

            _devicesContainer = new DeviceMappingsContainer(new MemoryStream(decoded));
            Devices           = _devicesContainer.Devices.List.AsReadOnly();
            _source           = source;
        }
예제 #4
0
파일: TsiFile.cs 프로젝트: pestrela/cmdr
        private void load(TsiXmlDocument xml, bool RemoveUnusedMIDIDefinitions)
        {
            // Traktor version, optional (only for "Traktor Settings.tsi")
            var browserDirRoot = xml.GetEntry <BrowserDirRoot>();

            if (browserDirRoot != null)
            {
                Match m = REGEX_TRAKTOR_FOLDER.Match(browserDirRoot.Value);
                if (m.Success) // Overwrite version if possible
                {
                    TraktorVersion = m.Groups[1].Value;
                }
            }

            // Effects, optional (FxSettings.Load may return null)
            // can this move below ?
            FxSettings = FxSettings.Load(xml);

            // Devices
            StringXmlEntry controllerConfigController = xml.GetEntry <DeviceIoConfigController>();

            if (controllerConfigController != null)
            {
                byte[] decoded = Convert.FromBase64String(controllerConfigController.Value);
                _devicesContainerControllers = new DeviceMappingsContainer(new MemoryStream(decoded));
                var _devices_tmp = _devicesContainerControllers.Devices.List.Select(d => new Device(max_id++, d, RemoveUnusedMIDIDefinitions, false)).ToList();

                // append to whole list
                _devices.AddRange(_devices_tmp);
            }

            StringXmlEntry controllerConfigKeyboard = xml.GetEntry <DeviceIoConfigKeyboard>();

            if (controllerConfigKeyboard != null)
            {
                byte[] decoded = Convert.FromBase64String(controllerConfigKeyboard.Value);
                _devicesContainerKeyboard = new DeviceMappingsContainer(new MemoryStream(decoded));
                var _devices_tmp = _devicesContainerKeyboard.Devices.List.Select(d => new Device(max_id++, d, RemoveUnusedMIDIDefinitions, true)).ToList();

                // append to whole list
                _devices.AddRange(_devices_tmp);
            }

            load_FX();
        }
예제 #5
0
        public TsiFile(string filePath)
        {
            this.filePath = filePath;
            fileContents  = File.ReadAllText(filePath);

            XDocument xml;

            using (TextReader textReader = new StringReader(fileContents))
            {
                xml = XDocument.Load(textReader);
            }

            string data = xml.XPathSelectElement(XPATH_TO_DATA).Attribute("Value").Value;

            byte[] decoded = Convert.FromBase64String(data);

            _devicesContainer = new DeviceMappingsContainer(new MemoryStream(decoded));
            Devices           = _devicesContainer.Devices.List.AsReadOnly();
        }
예제 #6
0
파일: TsiFile.cs 프로젝트: whiteschool/cmdr
        private void load(TsiXmlDocument xml)
        {
            // Traktor version, optional (only for "Traktor Settings.tsi")
            var browserDirRoot = xml.GetEntry <BrowserDirRoot>();

            if (browserDirRoot != null)
            {
                Match m = REGEX_TRAKTOR_FOLDER.Match(browserDirRoot.Value);
                if (m.Success) // Overwrite version if possible
                {
                    TraktorVersion = m.Groups[1].Value;
                }
            }

            // effects, optional (FxSettings.Load may return null)
            FxSettings = FxSettings.Load(xml);

            // devices
            var controllerConfig = xml.GetEntry <DeviceIoConfigController>();

            if (controllerConfig != null)
            {
                byte[] decoded = Convert.FromBase64String(controllerConfig.Value);
                _devicesContainer = new DeviceMappingsContainer(new MemoryStream(decoded));
                int id = 0;
                _devices = _devicesContainer.Devices.List.Select(d => new Device(id++, d)).ToList();

                var effectSelectorInCommands  = getCriticalEffectSelectorInCommands();
                var effectSelectorOutCommands = getCriticalEffectSelectorOutCommands();
                if (effectSelectorInCommands.Any() || effectSelectorOutCommands.Any())
                {
                    // need FxSettings for interpretation but not provided by file itself?
                    if (FxSettings == null)
                    {
                        // call for help
                        string rId     = new FileInfo(Path).Name;
                        var    request = new EffectIdentificationRequest(rId);
                        var    handler = EffectIdentificationRequest;
                        if (handler != null)
                        {
                            handler(this, request);

                            // wait for help
                            while (!request.Handled)
                            {
                                Thread.Sleep(100);
                            }

                            if (request.FxSettings != null)
                            {
                                FxSettings = request.FxSettings;
                            }
                        }
                    }

                    // if possible, replace effect indices with ids
                    if (FxSettings != null)
                    {
                        restoreEffectSelectorCommands(effectSelectorInCommands, effectSelectorOutCommands);
                    }
                    else
                    {
                        _ignoreFx = true;
                    }
                }
            }
        }