Ejemplo n.º 1
0
        private void tsmiSpriteMoveToIndex_Click(object sender, EventArgs e)
        {
            frmSpriteSendTo form = new frmSpriteSendTo(loadedSSPK.Sprites.Count - 1);

            form.ShowDialog();

            if (form.OK)
            {
                var sel = lbSprites.SelectedIndices;

                if (sel.Count == 1)
                {
                    MoveSpriteToIndex(sel[0], form.Index);

                    return;
                }

                if (form.Index > sel[0])
                {
                    int o = form.Index - sel[0];

                    if (sel[sel.Count - 1] + o < loadedSSPK.Sprites.Count)
                    {
                        int[] seli = new int[lbSprites.SelectedIndices.Count];
                        lbSprites.SelectedIndices.CopyTo(seli, 0);
                        lbSprites.SelectedIndices.Clear();
                        for (int i = 0; i < seli.Length; i++)
                        {
                            int n = seli[i];

                            MoveSpriteToIndex(n + (i * -1), n + (i * -1) + (seli.Length - 1) + o);
                        }

                        return;
                    }
                    else
                    {
                        string msg = "You cannot move that many sprites to this index.\n" +
                                     "Select fewer sprites or lower the index.";

                        MessageBox.Show(msg, "Error");

                        return;
                    }
                }

                if (form.Index < sel[0])
                {
                    int o = sel[0] - form.Index;
                    for (int i = 0; i < lbSprites.SelectedIndices.Count; i++)
                    {
                        int n = lbSprites.SelectedIndices[i];

                        MoveSpriteToIndex(n, n - o);
                    }
                }
            }
        }
        private void tsmiSpriteMoveToIndex_Click(object sender, EventArgs e)
        {
            frmSpriteSendTo form = new frmSpriteSendTo(loadedISPK.Sprites.Count - 1);

            form.ShowDialog();

            if (form.OK)
            {
                var sel = lbSprites.SelectedIndices;

                if (sel.Count == 1)
                {
                    MoveSpriteToIndex(sel[0], form.Index);

                    return;
                }

                if (form.Index > sel[0])
                {
                    int o = form.Index - sel[0];

                    if (sel[sel.Count - 1] + o < loadedISPK.Sprites.Count)
                    {
                        int[] seli = new int[lbSprites.SelectedIndices.Count];
                        lbSprites.SelectedIndices.CopyTo(seli, 0);
                        lbSprites.SelectedIndices.Clear();
                        for (int i = 0; i < seli.Length; i++)
                        {
                            int n = seli[i];

                            MoveSpriteToIndex(n + (i * -1), n + (i * -1) + (seli.Length - 1) + o);
                        }

                        return;
                    }
                    else
                    {
                        string msg = "You cannot move that many sprites to this index.\n" +
                            "Select fewer sprites or lower the index.";

                        MessageBox.Show(msg, "Error");

                        return;
                    }
                }

                if (form.Index < sel[0])
                {
                    int o = sel[0] - form.Index;
                    for (int i = 0; i < lbSprites.SelectedIndices.Count; i++)
                    {
                        int n = lbSprites.SelectedIndices[i];

                        MoveSpriteToIndex(n, n - o);
                    }
                }
            }
        }