/// <summary> /// Event handler when selected an item in one of the lists /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void list_ItemSelected(object sender, EventArgs e) { ddpPosX.Maximum = animation.MaxSize.Width; ddpPosY.Maximum = animation.MaxSize.Height; ListDirection list = (ListDirection)sender; SelectedSprite = list.SelectedSprite; ddpPosX.Value = SelectedSprite.X; ddpPosY.Value = SelectedSprite.Y; RefreshImage(); }
/// <summary> /// Event handler that saves an animation /// </summary> /// <param name="sender"></param> /// <param name="ev"></param> private void btnSaveAnimation_Click(object sender, EventArgs ev) { int maxAnim = 0; int direction = 4; if (rad8Directions.Checked) { direction = 8; } foreach (Control control in this.Controls) { if (control is ListDirection) { ListDirection list = (ListDirection)control; if (maxAnim < list.Sprites.Count) { maxAnim = list.Sprites.Count; } } } int width = maxAnim * animation.MaxSize.Width; int height = direction * animation.MaxSize.Height; Image charSet = new Bitmap(width, height); Graphics e = Graphics.FromImage(charSet); #region Up int i = 0; int h = 0; foreach (Sprite sprite in listUp.Sprites) { int posX = i * animation.MaxSize.Width; int posY = h; e.DrawImage(sprite.Image, new Point(posX + sprite.X, posY + sprite.Y)); i++; } #endregion #region UpRight if (direction == 8) { i = 0; h++; foreach (Sprite sprite in listUpRight.Sprites) { int posX = i * animation.MaxSize.Width; int posY = h * animation.MaxSize.Height; e.DrawImage(sprite.Image, new Point(posX + sprite.X, posY + sprite.Y)); i++; } } #endregion #region Right i = 0; h++; foreach (Sprite sprite in listRight.Sprites) { int posX = i * animation.MaxSize.Width; int posY = h * animation.MaxSize.Height; e.DrawImage(sprite.Image, new Point(posX + sprite.X, posY + sprite.Y)); i++; } #endregion #region DownRight if (direction == 8) { i = 0; h++; foreach (Sprite sprite in listDownRight.Sprites) { int posX = i * animation.MaxSize.Width; int posY = h * animation.MaxSize.Height; e.DrawImage(sprite.Image, new Point(posX + sprite.X, posY + sprite.Y)); i++; } } #endregion #region Down i = 0; h++; foreach (Sprite sprite in listDown.Sprites) { int posX = i * animation.MaxSize.Width; int posY = h * animation.MaxSize.Height; e.DrawImage(sprite.Image, new Point(posX + sprite.X, posY + sprite.Y)); i++; } #endregion #region DownLeft if (direction == 8) { i = 0; h++; foreach (Sprite sprite in listDownLeft.Sprites) { int posX = i * animation.MaxSize.Width; int posY = h * animation.MaxSize.Height; e.DrawImage(sprite.Image, new Point(posX + sprite.X, posY + sprite.Y)); i++; } } #endregion #region Left i = 0; h++; foreach (Sprite sprite in listLeft.Sprites) { int posX = i * animation.MaxSize.Width; int posY = h * animation.MaxSize.Height; e.DrawImage(sprite.Image, new Point(posX + sprite.X, posY + sprite.Y)); i++; } #endregion #region UpLeft if (direction == 8) { i = 0; h++; foreach (Sprite sprite in listUpLeft.Sprites) { int posX = i * animation.MaxSize.Width; int posY = h * animation.MaxSize.Height; e.DrawImage(sprite.Image, new Point(posX + sprite.X, posY + sprite.Y)); i++; } } #endregion string finalname = Path.GetDirectoryName(currentPath) + "/" + string.Format(animation.Filename, direction, animation.MaxSize.Width); charSet.Save(finalname); e.Dispose(); }