private void panel1_Paint(object sender, PaintEventArgs e) { if (listBox1.SelectedIndex < frames.Count && listBox1.SelectedIndex >= 0) { for (int i = 0; i < frames[listBox1.SelectedIndex].Units.Length; i++) { FrameUnit fu = frames[listBox1.SelectedIndex].Units[i]; try { Image image = Image.FromFile(String.Format(@"../../PicResource/Effect/{0}.PNG", fu.frameid)); if (fu.parm != 0) { switch (fu.parm) { case 1: image.RotateFlip(RotateFlipType.Rotate90FlipNone); break; case 2: image.RotateFlip(RotateFlipType.Rotate180FlipNone); break; case 3: image.RotateFlip(RotateFlipType.Rotate270FlipNone); break; case 4: image.RotateFlip(RotateFlipType.RotateNoneFlipX); break; case 5: image.RotateFlip(RotateFlipType.Rotate90FlipX); break; case 6: image.RotateFlip(RotateFlipType.Rotate180FlipX); break; case 7: image.RotateFlip(RotateFlipType.Rotate270FlipX); break; default: ImagePixelTool.Effect((Bitmap)image, (ImagePixelEffects)(fu.parm / 10), fu.parm % 10); break; } } e.Graphics.DrawImage(image, fu.x, fu.y, fu.width, fu.height); image.Dispose(); } catch { } } } }
private void listBoxFiles_SelectedIndexChanged() { if (target >= 0 && items.Count > target) { StreamReader sr = new StreamReader(path + "/" + items[target].Path); sr.ReadLine(); int frameCount = int.Parse(sr.ReadLine()); frames.Clear(); listBox1.Items.Clear(); for (int i = 0; i < frameCount; i++) { int frameUnitCount = int.Parse(sr.ReadLine()); Frame frame = new Frame(); frame.Units = new FrameUnit[frameUnitCount]; listBox1.Items.Add(listBox1.Items.Count + 1); for (int j = 0; j < frameUnitCount; j++) { String read = sr.ReadLine(); String[] arrays = read.Split('\t'); FrameUnit fu = new FrameUnit(); fu.frameid = int.Parse(arrays[0]); fu.x = int.Parse(arrays[1]); fu.y = int.Parse(arrays[2]); fu.width = int.Parse(arrays[3]); fu.height = int.Parse(arrays[4]); if (arrays.Length >= 6) { fu.parm = int.Parse(arrays[5]); } frame.Units[j] = fu; } frames.Add(frame); } sr.Close(); } }