private void btnOk_Click(object sender, System.Windows.RoutedEventArgs e) { string spriteName = tbSpriteName.Text; string imageName = tbImageName.Text; bool isAnimation = (bool)cbIsAnimation.IsChecked; string frameNum = tbFrameNum.Text; string frameSpeed = tbFrameSpeed.Text; if ((spriteName != "" && imageName != "" && isAnimation && frameNum != "" && frameSpeed != "") || (spriteName != "" && imageName != "" && !isAnimation)) { if (this.SelectedSprite != null) { this.SelectedSprite.SpriteName = spriteName; this.SelectedSprite.ImageName = imageName; if (isAnimation) { this.SelectedSprite.FrameNum = int.Parse(frameNum); this.SelectedSprite.Speed = int.Parse(frameSpeed); } } else { this.SelectedSprite = new Sprite(spriteName, imageName, int.Parse(frameNum), int.Parse(frameSpeed), false); this.Sprites.Add(this.SelectedSprite); RefreshListBox(); } } }
private void listBoxSprites_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { string spriteName = (string)((ListBoxItem)e.AddedItems[0]).Content; var selectedSprite = GetSpriteBySpriteName(spriteName); if (selectedSprite != null) this.SelectedSprite = selectedSprite; View(); }
private void btnAdd_Click(object sender, System.Windows.RoutedEventArgs e) { this.SelectedSprite = null; }
public static void ConvertSpriteToSpriteInfo(Sprite from, SpriteInfo to) { if (from != null && to != null) to = new SpriteInfo(from.SpriteName, from.ImageName, from.FrameNum, from.Speed); }
public static void ConvertSpriteInfoTOSprite(SpriteInfo from, Sprite to) { if(from != null && to != null) to = new Sprite(from.SpriteName, from.ImageName, from.FrameNum, from.Speed, false); }