Exemple #1
0
        public FormEditor()
        {
            InitializeComponent();

            RenderDisplayAnimation.OnInitialize += RenderDisplayAnimation_OnInitialize;
            RenderDisplayAnimation.OnDraw       += RenderDisplayAnimation_OnDraw;

            Application.Idle += delegate {
                RenderDisplayAnimation.Invalidate();
            };

            SliderCharX.Minimum = -(RenderDisplayAnimation.Width / 2);
            SliderCharX.Maximum = (RenderDisplayAnimation.Width / 2);
            SliderCharY.Minimum = -(RenderDisplayAnimation.Height / 2);
            SliderCharY.Maximum = (RenderDisplayAnimation.Height / 2);
        }
Exemple #2
0
        /// <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;
            }
        }
Exemple #3
0
 private void RenderDisplayAnimation_Click(object sender, EventArgs e)
 {
     RenderDisplayAnimation.Focus();
 }