private void DrawFrameItem(object sender, DrawListViewItemEventArgs e) { AnimIdx edit = Ultima.AnimationEdit.GetAnimation(FileType, CurrBody, CurrAction, CurrDir); Bitmap[] currbits = edit.GetFrames(); Bitmap bmp = currbits[(int)e.Item.Tag]; int width = bmp.Width; int height = bmp.Height; if (listView1.SelectedItems.Contains(e.Item)) { e.Graphics.DrawRectangle(new Pen(Color.Red), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); } else { e.Graphics.DrawRectangle(new Pen(Color.Gray), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); } e.Graphics.DrawImage(bmp, e.Bounds.X, e.Bounds.Y, width, height); e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter); }
private void onPaintFrame(object sender, PaintEventArgs e) { AnimIdx edit = Ultima.AnimationEdit.GetAnimation(FileType, CurrBody, CurrAction, CurrDir); if (edit != null) { Bitmap[] currbits = edit.GetFrames(); e.Graphics.Clear(Color.LightGray); e.Graphics.DrawLine(Pens.Black, new Point(FramePoint.X, 0), new Point(FramePoint.X, pictureBox1.Height)); e.Graphics.DrawLine(Pens.Black, new Point(0, FramePoint.Y), new Point(pictureBox1.Width, FramePoint.Y)); if ((currbits != null) && (currbits.Length > 0)) { if (currbits[trackBar2.Value] != null) { int x = FramePoint.X - ((FrameEdit)edit.Frames[trackBar2.Value]).Center.X; int y = FramePoint.Y - ((FrameEdit)edit.Frames[trackBar2.Value]).Center.Y - currbits[trackBar2.Value].Height; e.Graphics.FillRectangle(Brushes.Transparent, new Rectangle(x, y, currbits[trackBar2.Value].Width, currbits[trackBar2.Value].Height)); e.Graphics.DrawImage(currbits[trackBar2.Value], x, y); } } } }
private void onClickExtractImages(object sender, EventArgs e) { if (FileType != 0) { ToolStripMenuItem menu = (ToolStripMenuItem)sender; ImageFormat format = ImageFormat.Bmp; if (((string)menu.Tag) == ".tiff") { format = ImageFormat.Tiff; } string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; int body, action; if (treeView1.SelectedNode.Parent == null) { body = (int)treeView1.SelectedNode.Tag; action = -1; } else { body = (int)treeView1.SelectedNode.Parent.Tag; action = (int)treeView1.SelectedNode.Tag; } if (action == -1) { for (int a = 0; a < Animations.GetAnimLength(body, FileType); ++a) { for (int i = 0; i < 5; ++i) { AnimIdx edit = Ultima.AnimationEdit.GetAnimation(FileType, body, a, i); if (edit != null) { Bitmap[] bits = edit.GetFrames(); if (bits != null) { for (int j = 0; j < bits.Length; ++j) { string filename = String.Format("anim{5}_{0}_{1}_{2}_{3}{4}", body, a, i, j, menu.Tag, FileType); string file = Path.Combine(path, filename); Bitmap bit = new Bitmap(bits[j]); if (bit != null) { bit.Save(file, format); } bit.Dispose(); } } } } } } else { for (int i = 0; i < 5; ++i) { AnimIdx edit = Ultima.AnimationEdit.GetAnimation(FileType, body, action, i); if (edit != null) { Bitmap[] bits = edit.GetFrames(); if (bits != null) { for (int j = 0; j < bits.Length; ++j) { string filename = String.Format("anim{5}_{0}_{1}_{2}_{3}{4}", body, action, i, j, menu.Tag, FileType); string file = Path.Combine(path, filename); Bitmap bit = new Bitmap(bits[j]); if (bit != null) { bit.Save(file, format); } bit.Dispose(); } } } } } MessageBox.Show( String.Format("Кадры сохранены в {0}", path), "Сохраненно", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } }
private void AfterSelectTreeView(object sender, TreeViewEventArgs e) { if (treeView1.SelectedNode != null) { if (treeView1.SelectedNode.Parent == null) { if (treeView1.SelectedNode.Tag != null) { CurrBody = (int)treeView1.SelectedNode.Tag; } CurrAction = 0; } else { if (treeView1.SelectedNode.Parent.Tag != null) { CurrBody = (int)treeView1.SelectedNode.Parent.Tag; } CurrAction = (int)treeView1.SelectedNode.Tag; } listView1.BeginUpdate(); listView1.Clear(); AnimIdx edit = Ultima.AnimationEdit.GetAnimation(FileType, CurrBody, CurrAction, CurrDir); if (edit != null) { int width = 80; int height = 110; Bitmap[] currbits = edit.GetFrames(); if (currbits != null) { for (int i = 0; i < currbits.Length; ++i) { if (currbits[i] == null) { continue; } ListViewItem item; item = new ListViewItem(i.ToString(), 0); item.Tag = i; listView1.Items.Add(item); if (currbits[i].Width > width) { width = currbits[i].Width; } if (currbits[i].Height > height) { height = currbits[i].Height; } } listView1.TileSize = new Size(width + 5, height + 5); trackBar2.Maximum = currbits.Length - 1; trackBar2.Value = 0; numericUpDownCx.Value = ((FrameEdit)edit.Frames[trackBar2.Value]).Center.X; numericUpDownCy.Value = ((FrameEdit)edit.Frames[trackBar2.Value]).Center.Y; } } listView1.EndUpdate(); pictureBox1.Invalidate(); SetPaletteBox(); } }