Exemplo n.º 1
0
 public void Reset()
 {
     LeftMouseIsDown = RightMouseIsDown = DragDropInProgress = false;
     Source          = new SlotChange {
         OriginalData = BlankData
     };
     Destination = new SlotChange();
     Cursor      = CurrentPath = null;
 }
Exemplo n.º 2
0
        private void ClickDelete(object sender, EventArgs e)
        {
            sender = WinFormsUtil.GetUnderlyingControl(sender);
            int index = Array.IndexOf(PKXBOXES, sender);

            if (!GetShiftedIndex(ref index))
            {
                System.Media.SystemSounds.Exclamation.Play();
                return;
            }

            var    pk   = Results[index];
            string path = pk.Identifier;

#if LOADALL
            if (path.StartsWith(EXTERNAL_SAV))
            {
                WinFormsUtil.Alert(MsgDBDeleteFailBackup);
                return;
            }
#endif
            if (path.Contains(Path.DirectorySeparatorChar))
            {
                // Data from Database: Delete file from disk
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
            else
            {
                // Data from Box: Delete from save file
                int box    = pk.Box - 1;
                int slot   = pk.Slot - 1;
                int offset = SAV.GetBoxOffset(box) + (slot * SAV.SIZE_STORED);
                PKM pkSAV  = SAV.GetStoredSlot(offset);

                if (!pkSAV.DecryptedBoxData.SequenceEqual(pk.DecryptedBoxData)) // data still exists in SAV, unmodified
                {
                    WinFormsUtil.Error(MsgDBDeleteFailModified, MsgDBDeleteFailWarning);
                    return;
                }
                var change = new SlotChange {
                    Box = box, Offset = offset, Slot = slot
                };
                BoxView.M.SetPKM(BoxView.SAV.BlankPKM, change, true, Properties.Resources.slotDel);
            }
            // Remove from database.
            RawDB.Remove(pk);
            Results.Remove(pk);
            // Refresh database view.
            L_Count.Text = string.Format(Counter, Results.Count);
            slotSelected = -1;
            FillPKXBoxes(SCR_Box.Value);
            System.Media.SystemSounds.Asterisk.Play();
        }
Exemplo n.º 3
0
        private void ClickDelete(object sender, EventArgs e)
        {
            sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox;
            int index = Array.IndexOf(PKXBOXES, sender);

            if (index >= RES_MAX)
            {
                System.Media.SystemSounds.Exclamation.Play();
                return;
            }
            index += SCR_Box.Value * RES_MIN;
            if (index >= Results.Count)
            {
                System.Media.SystemSounds.Exclamation.Play();
                return;
            }

            var    pk   = Results[index];
            string path = pk.Identifier;

#if LOADALL
            if (path.StartsWith(EXTERNAL_SAV))
            {
                WinFormsUtil.Alert("Can't delete from a backup save.");
                return;
            }
#endif
            if (path.Contains(Path.DirectorySeparatorChar))
            {
                // Data from Database: Delete file from disk
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
            else
            {
                // Data from Box: Delete from save file
                int box    = pk.Box - 1;
                int slot   = pk.Slot - 1;
                int offset = SAV.GetBoxOffset(box) + slot * SAV.SIZE_STORED;
                PKM pkSAV  = SAV.GetStoredSlot(offset);

                if (!pkSAV.Data.SequenceEqual(pk.Data)) // data still exists in SAV, unmodified
                {
                    WinFormsUtil.Error("Database slot data does not match save data!", "Don't move Pokémon after initializing the Database, please re-open the Database viewer.");
                    return;
                }
                var change = new SlotChange {
                    Box = box, Offset = offset, Slot = slot
                };
                BoxView.M.SetPKM(BoxView.SAV.BlankPKM, change, true, Properties.Resources.slotDel);
            }
            // Remove from database.
            RawDB.Remove(pk);
            Results.Remove(pk);
            // Refresh database view.
            L_Count.Text = string.Format(Counter, Results.Count);
            slotSelected = -1;
            FillPKXBoxes(SCR_Box.Value);
            System.Media.SystemSounds.Asterisk.Play();
        }
Exemplo n.º 4
0
Arquivo: Main.cs Projeto: kwsch/PKHeX
        private void undoSlotChange(SlotChange change)
        {
            int slot = change.Slot;
            int offset = change.Offset;
            PKM pk = (PKM)change.OriginalData;

            if (CB_BoxSelect.SelectedIndex != change.Box)
                CB_BoxSelect.SelectedIndex = change.Box;
            SAV.setStoredSlot(pk, offset);
            getQuickFiller(SlotPictureBoxes[slot], pk);
            getSlotColor(slot, Resources.slotSet);

            Menu_Undo.Enabled = UndoStack.Any();
            Menu_Redo.Enabled = RedoStack.Any();

            SystemSounds.Asterisk.Play();
        }