Пример #1
0
        /// <summary>
        /// Collects info about data and injects it into track's assets list.
        /// </summary>
        public void RegisterAssets(Track track)
        {
            try
            {
                var filePaths = NTDFiles.Items;
                foreach (string file in filePaths)
                {
                    // WEB ASSET
                    if (Regex.IsMatch(file, WebAssetPattern))
                    {
                        Match  m   = Regex.Match(file, WebAssetPattern);
                        string url = m.Groups[1].Value;

                        WebAsset webAsset = new WebAsset(url);
                        track.Assets.Add(webAsset);
                        continue;
                    }

                    // MODIFY
                    if (_modifyMode)
                    {
                        Match m = Regex.Match(file, ModifyTrackPattern);
                        if (m.Success)
                        {
                            int indexOfAsset = int.Parse(m.Groups[1].Value) - 1;
                            track.Assets.Add(_track.Assets[indexOfAsset]);
                            continue;
                        }
                    }

                    // OTHER FILES
                    FileInfo fi    = new FileInfo(file);
                    Type     type  = AssetConverter.GetAssetTypeByExtension(fi.Extension);
                    var      bytes = File.ReadAllBytes(file);

                    var basset = new BinaryAsset(type, bytes);
                    var asset  = AssetConverter.ResolveBinaryAsset(basset);
                    track.Assets.Add(asset);
                }
            } catch (Exception e)
            {
                throw new ForUserException(
                          "A Problem occured during registering assets. Details: " + e.Message);
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nsPath"></param>
        /// <returns></returns>
        public static Track ReadTrack(string nsPath)
        {
            try
            {
                Track t = new Track();
                using (BinaryReader reader = new BinaryReader(File.OpenRead(nsPath)))
                {
                    // TRACK INFO
                    t.TrackInfo.Name        = reader.ReadString();
                    t.TrackInfo.Author      = reader.ReadString();
                    t.TrackInfo.ImageLen    = reader.ReadInt32();
                    t.TrackInfo.Image       = reader.ReadBytes(t.TrackInfo.ImageLen);
                    t.TrackInfo.SliderValue = reader.ReadDouble();
                    t.TrackInfo.Encrypted   = reader.ReadBoolean();

                    string password = null;
                    if (t.TrackInfo.Encrypted)
                    {
                        var dialog = InfoDialog.ShowValueDialog("Enter the password:"******"Fail with interpreting the track.");
            }
        }