private void RefreshFrameImageList() { listFrameImages.Items.Clear(); if (mSelectedFrame == -1) { return; } for (var i = 0; i < mAnimation.Frames[mSelectedFrame].Count; i++) { var image = mAnimation.Frames[mSelectedFrame][i]; var item = new FrameImageListItem(mSelectedFrame, i, image); listFrameImages.Items.Add(item); } }
/// <exception cref="Exception"></exception> private void RenderDisplayAnimation_MouseUp(object sender, MouseEventArgs e) { RenderDisplayAnimation.Focus(); if (mSelectedFrame == -1) { return; } if (AnimationTimerRunning) { return; } // Place a new Image if (mSelectedAnimation != -1 && (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)) { var imagePos = CalculateNewImagePosition(); var img = new TileAnimationFrameImage { TextureSource = GetTextureSource(pnlTilesetThumbs.Controls[mSelectedAnimation].Name), Scale = 0.5f, Offset = imagePos, IsBackground = (e.Button == MouseButtons.Left) }; img.Scale = (Constants.AnimationWidth / (float)Constants.AnimationTilesetWidth); // Add to animation object mAnimation.Frames[mSelectedFrame].Add(img); // Add to frame image list var item = new FrameImageListItem(mSelectedFrame, mAnimation.Frames[mSelectedFrame].Count - 1, img); var listViewItem = listFrameImages.Items.Add(item); // Select frame image listFrameImages.SelectedItems.Clear(); listFrameImages.SelectedIndices.Add(listFrameImages.Items.IndexOf(listViewItem)); return; } // Select a Image from the frame var frame = mAnimation.Frames[mSelectedFrame]; var intersectionPosition = mMousePosition; int i; for (i = frame.Count - 1; i >= 0; i--) { if (intersectionPosition.Contains(frame[i].GetDestinationRectangle(RenderDisplayCenterPosition))) break; } if (i == -1) { // no collision listFrameImages.SelectedIndices.Clear(); return; } // Search the listImages Index for (var l = 0; l < listFrameImages.Items.Count; l++) { var item = listFrameImages.Items[l] as FrameImageListItem; if (item == null) { throw new Exception("Invalid item data in frame image list at index " + i); } if (item.FrameIndex != mSelectedFrame || item.FrameImageIndex != i) { continue; } listFrameImages.SelectedIndices.Clear(); listFrameImages.SelectedIndices.Add(l); break; } }
/// <exception cref="Exception"></exception> private void RenderDisplayAnimation_MouseUp(object sender, MouseEventArgs e) { RenderDisplayAnimation.Focus(); if (mSelectedFrame == -1) { return; } if (AnimationTimerRunning) { return; } // Place a new Image if (mSelectedAnimation != -1 && (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)) { var imagePos = CalculateNewImagePosition(); var img = new TileAnimationFrameImage { TextureSource = GetTextureSource(pnlTilesetThumbs.Controls[mSelectedAnimation].Name), Scale = 0.5f, Offset = imagePos, IsBackground = (e.Button == MouseButtons.Left) }; img.Scale = (Constants.AnimationWidth / (float)Constants.AnimationTilesetWidth); // Add to animation object mAnimation.Frames[mSelectedFrame].Add(img); // Add to frame image list var item = new FrameImageListItem(mSelectedFrame, mAnimation.Frames[mSelectedFrame].Count - 1, img); var listViewItem = listFrameImages.Items.Add(item); // Select frame image listFrameImages.SelectedItems.Clear(); listFrameImages.SelectedIndices.Add(listFrameImages.Items.IndexOf(listViewItem)); return; } // Select a Image from the frame var frame = mAnimation.Frames[mSelectedFrame]; var intersectionPosition = mMousePosition; int i; for (i = frame.Count - 1; i >= 0; i--) { if (intersectionPosition.Contains(frame[i].GetDestinationRectangle(RenderDisplayCenterPosition))) { break; } } if (i == -1) // no collision { listFrameImages.SelectedIndices.Clear(); return; } // Search the listImages Index for (var l = 0; l < listFrameImages.Items.Count; l++) { var item = listFrameImages.Items[l] as FrameImageListItem; if (item == null) { throw new Exception("Invalid item data in frame image list at index " + i); } if (item.FrameIndex != mSelectedFrame || item.FrameImageIndex != i) { continue; } listFrameImages.SelectedIndices.Clear(); listFrameImages.SelectedIndices.Add(l); break; } }