Exemplo n.º 1
0
 public void Do(params object[] args)
 {
     Array = args as Album[];
     List  = new List <Album>();
     foreach (var al in Array)
     {
         var arr   = new Album[al.Tables.Count];
         var path  = al.Name;
         var regex = new Regex("\\d+");
         var match = regex.Match(path);
         if (!match.Success)
         {
             continue;
         }
         var prefix = path.Substring(0, match.Index);
         var suffix = path.Substring(match.Index + match.Length);
         var code   = int.Parse(match.Value);
         al.Adjust();
         var data = al.Data;
         var ms   = new MemoryStream(data);
         for (var i = 0; i < arr.Length; i++)
         {
             var name = prefix + Npks.CompleteCode(code + i) + suffix;
             arr[i]      = Npks.ReadNPK(ms, al.Name)[0];
             arr[i].Path = al.Path.Replace(al.Name, name);
             arr[i].Tables.Clear();
             arr[i].Tables.Add(al.Tables[i]);
             ms.Seek(0, SeekOrigin.Begin);
         }
         ms.Close();
         Connector.RemoveFile(al);
         Connector.AddFile(false, arr);
         List.AddRange(arr);
     }
 }
Exemplo n.º 2
0
        public void TestMethod3()
        {
            var dir = @"D:\avatar_new\image";

            foreach (var prof in pairs.Keys)
            {
                foreach (var part in part_array)
                {
                    var file = $@"{dir}\{prof}\{part}";

                    var path = $"d:/avatar_ex/image/{prof}/{part}";
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    var list = Npks.Load(file);

                    foreach (var img in list)
                    {
                        var tables = img.Tables;
                        var match  = Regex.Match(img.Name, "\\d+");
                        if (match.Success)
                        {
                            var code = int.Parse(match.Value);
                            for (var i = 0; i < tables.Count; i++)
                            {
                                img.TableIndex = i;
                                var image = img[pairs[prof]];
                                ImageToJson(path, prof, part, img.Name, Npks.CompleteCode(code + i), image);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void Do(params object[] args)
 {
     Array = args as Album[];
     if (Array.Length > 0)
     {
         var regex = new Regex("\\d+");
         var match = regex.Match(Array[0].Name);
         if (match.Success)
         {
             var code     = int.Parse(match.Value);
             var code_str = Npks.CompleteCode(code / 100 * 100);
             Album = Array[0].Clone();
             Album.ConvertTo(Handle.Img_Version.Ver6);
             Album.Adjust();
             Album.Tables.Clear();
             Album.Path = Array[0].Path.Replace(match.Value, code_str);
             var max   = 0;
             var table = new List <Color>();
             foreach (var al in Array)
             {
                 if (al.CurrentTable.Count > max)
                 {
                     max   = al.CurrentTable.Count;
                     table = al.CurrentTable;
                 }
                 Album.Tables.Add(al.CurrentTable);
             }
             foreach (var tl in Album.Tables)
             {
                 if (tl.Count < max)
                 {
                     tl.AddRange(table.GetRange(tl.Count, max - tl.Count));
                 }
             }
             Connector.RemoveFile(Array);
             Connector.AddFile(false, Album);
         }
     }
 }