示例#1
0
 private void LoadFileContainer(PhoebusFileContainer Container)
 {
     int length = this.prefix.Length;
     char oldChar = Path.DirectorySeparatorChar;
     int startIndex = this.prefix.Length + 1;
     foreach (string FileName in (IEnumerable<string>)Enumerable.OrderBy<string, string>((IEnumerable<string>)Container.GetFiles(), (Func<string, string>)(file => file))) {
         string str1 = FileName.ToLower();
         if (str1.StartsWith(this.prefix) && str1.EndsWith(".png") && ((int)FileName[length] == 95 || (int)FileName[length] == (int)oldChar)) {
             string str2 = FileName.Substring(0, FileName.Length - 4);
             if (str2.IndexOf('.') == -1 && Container.GetFileSize(FileName) > 0L) {
                 Bitmap bitmap = (Bitmap)null;
                 Bitmap filter = (Bitmap)null;
                 try {
                     bitmap = TilesetList.StreamToBitmap(Container, FileName);
                     if (bitmap != null) {
                         filter = TilesetList.StreamToBitmap(Container, str2 + ".filter.png");
                         this.fileList.Add(new TilesetPatch(TilesetList.StreamToString(Container, str2 + ".txt"), bitmap, filter, new TilesetSize(16, 16, 16, 16), this.defaultConfigInfos));
                         this.nameList.Add(str2.Substring(startIndex, str2.Length - startIndex).Replace('_', ' ').Replace(oldChar, ' ').Trim());
                     } else
                         continue;
                 } catch {
                 }
                 if (bitmap != null)
                     bitmap.Dispose();
                 if (filter != null)
                     filter.Dispose();
             }
         }
     }
 }
示例#2
0
 private static Bitmap StreamToBitmap(PhoebusFileContainer Container, string FileName)
 {
     Stream stream = (Stream)null;
     Bitmap bitmap = (Bitmap)null;
     BitmapData bitmapdata = (BitmapData)null;
     try {
         stream = Container.GetFileStream(FileName);
         if (stream == null)
             return (Bitmap)null;
         bitmap = new Bitmap(stream);
         bitmapdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, PixelData.format);
         bitmap.UnlockBits(bitmapdata);
         stream.Dispose();
     } catch {
         if (bitmapdata != null && bitmap != null)
             bitmap.UnlockBits(bitmapdata);
         if (bitmap != null) {
             bitmap.Dispose();
             bitmap = (Bitmap)null;
         }
         if (stream != null)
             stream.Dispose();
     }
     return bitmap;
 }
示例#3
0
 private static string StreamToString(PhoebusFileContainer Container, string FileName)
 {
     Stream stream = (Stream)null;
     StreamReader streamReader = (StreamReader)null;
     string str = (string)null;
     try {
         stream = Container.GetFileStream(FileName);
         if (stream == null)
             return (string)null;
         streamReader = new StreamReader(stream);
         str = streamReader.ReadToEnd();
         streamReader.Dispose();
         stream.Dispose();
     } catch {
         if (streamReader != null)
             streamReader.Dispose();
         if (stream != null)
             stream.Dispose();
     }
     return str;
 }