Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="patch"></param>
        /// <param name="atLeastOnePatchIsPasted">Or-s the value with True if the patch is pasted</param>
        /// <returns></returns>
        bool PasteToSelectedPatch(IPatch patch, ref bool atLeastOnePatchIsPasted)
        {
            if ((patch.IsEmptyOrInit || (PcgClipBoard.PastePcgMemory == SelectedPcgMemory)) &&
                !PcgClipBoard.ProtectedPatches.Contains(patch))
            {
                IClipBoardPatches clipBoardPatches = null;
                var overwriteAllowed = CheckOverwriteallowedForPatches(patch, ref clipBoardPatches);

                IClipBoardPatch clipBoardPatchToPaste = null;
                if (clipBoardPatches != null) // Can happen when not allowed to overwrite
                {
                    clipBoardPatchToPaste = PcgClipBoard.GetFirstPatchToPaste(clipBoardPatches.CopiedPatches);
                }

                if (clipBoardPatchToPaste == null)
                {
                    if (overwriteAllowed)
                    {
                        return(false); // Finished pasting (this kind of patches)
                    }
                }
                else
                {
                    atLeastOnePatchIsPasted = true;
                    PcgClipBoard.PastePatch(clipBoardPatchToPaste, patch);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cutPasteAction"></param>
 private void CopyPasteCopySetLists(bool cutPasteAction)
 {
     if (SelectedScopeSet == PcgViewModel.ScopeSet.Banks)
     {
         foreach (var setListSlot in (from ISetList setList in Banks.Where(bank => bank.IsSelected)
                                      from ISetListSlot setListSlot in setList.Patches
                                      where setList.IsLoaded
                                      select setListSlot).Where(setListSlot => cutPasteAction ||
                                                                Settings.Default.CopyPaste_CopyIncompleteSetListSlots ||
                                                                setListSlot.IsCompleteInPcg))
         {
             PcgClipBoard.CopySetListSlotToClipBoard(setListSlot, cutPasteAction);
         }
     }
     else
     {
         foreach (var setListSlot in Patches.Where(patch => patch.IsSelected).Cast <ISetListSlot>().Where(
                      (setListSlot => cutPasteAction ||
                       Settings.Default.CopyPaste_CopyIncompleteSetListSlots ||
                       setListSlot.IsCompleteInPcg)))
         {
             PcgClipBoard.CopySetListSlotToClipBoard(setListSlot, cutPasteAction);
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cutPasteAction"></param>
        private void CopyPasteInit(bool cutPasteAction)
        {
            PcgClipBoard.Clear();

            if (!cutPasteAction)
            {
                PcgClipBoard.CutPasteSelected = false;
            }

            PcgClipBoard.CopyFileName = SelectedPcgMemory.FileName;
            PcgClipBoard.Model        = SelectedPcgMemory.Model;
        }
Exemplo n.º 4
0
        private void RunTest(CopyPaste.PatchDuplication patchNameSetting, string ignoreFragments,
                             int sourceIndex, int destinationCompareIndex,
                             bool patchNamesEqual, int destinationIndex, bool pasted)
        {
            SetUp();
            Settings.Default.CopyPaste_OverwriteFilledPrograms             = true;
            Settings.Default.CopyPaste_PatchDuplicationName                = (int)patchNameSetting;
            Settings.Default.CopyPaste_IgnoreCharactersForPatchDuplication = ignoreFragments;

            var program2  = ((ProgramBank)_pcgOs2.ProgramBanks["I-A"])[sourceIndex]; // I-A000 Kronos grand.
            var commands2 = new CopyPasteCommands();
            var patches   = new ObservableCollectionEx <IPatch> {
                program2
            };

            var clipBoard = new PcgClipBoard();

            program2.IsSelected = true;
            commands2.CopyPasteCopy(clipBoard, _pcgOs2, PcgViewModel.ScopeSet.Patches, true,
                                    false, false, false, false, false, false,
                                    null, patches, false);

            var icBank = (ProgramBank)_pcgOs3.ProgramBanks["I-C"];

            if (patchNamesEqual)
            {
                Assert.AreEqual(program2.Name, icBank[destinationCompareIndex].Name);
            }

            var program3 = icBank[destinationIndex];
            var patches3 = new ObservableCollectionEx <IPatch> {
                program3
            };

            program3.Clear();
            program3.IsSelected = true;
            Assert.AreNotEqual(program2.Name, program3.Name);

            commands2.CopyPastePaste(clipBoard, _pcgOs3, PcgViewModel.ScopeSet.Patches, true,
                                     false, false, false, false, false, false,
                                     null, patches3);

            if (pasted)
            {
                Assert.AreEqual(program2.Name, program3.Name);
            }
            else
            {
                Assert.AreNotEqual(program2.Name, program3.Name);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        private void PastingFinished()
        {
            var count = 0;

            for (var index = 0; index < (int)ProgramBank.SynthesisType.Last; index++)
            {
                count += PcgClipBoard.Programs[index].CopiedPatches.Count;
            }

            if (!((PcgClipBoard.SetListSlots.CopiedPatches.Count == 0) &&
                  (PcgClipBoard.Combis.CopiedPatches.Count == 0) &&
                  (PcgClipBoard.DrumKits.CopiedPatches.Count == 0) &&
                  (PcgClipBoard.DrumPatterns.CopiedPatches.Count == 0) &&
                  (PcgClipBoard.WaveSequences.CopiedPatches.Count == 0) &&
                  (count == 1))) //IMPR: Why count == 1 and not 0? (needs the last to be copied ?)
            {
                PcgClipBoard.Clear();
            }
        }
Exemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cutPasteAction"></param>
 private void CopyPasteCopyCombis(bool cutPasteAction)
 {
     if (SelectedScopeSet == PcgViewModel.ScopeSet.Banks)
     {
         foreach (var combi in (from ICombiBank bank in Banks.Where(bank => bank.IsSelected)
                                from ICombi combi in bank.Patches
                                where bank.IsLoaded
                                select combi).Where(combi => cutPasteAction ||
                                                    Settings.Default.CopyPaste_CopyIncompleteCombis || combi.IsCompleteInPcg))
         {
             PcgClipBoard.CopyCombiToClipBoard(combi, cutPasteAction);
         }
     }
     else
     {
         foreach (var combi in Patches.Where(
                      patch => patch.IsSelected).Cast <ICombi>().Where(
                      combi => cutPasteAction || Settings.Default.CopyPaste_CopyIncompleteCombis || combi.IsCompleteInPcg))
         {
             PcgClipBoard.CopyCombiToClipBoard(combi, cutPasteAction);
         }
     }
 }
Exemplo n.º 7
0
        public void CopyProgramDefault()
        {
            SetUp();

            var program2  = ((ProgramBank)_pcgOs2.ProgramBanks[0])[0];
            var commands2 = new CopyPasteCommands();
            var banks     = new ObservableCollectionEx <IBank>();
            var patches   = new ObservableCollectionEx <IPatch> {
                program2
            };

            var clipBoard = new PcgClipBoard();

            program2.IsSelected = true;
            commands2.CopyPasteCopy(clipBoard, _pcgOs2, PcgViewModel.ScopeSet.Patches, true,
                                    false, false, false, false, false, false,
                                    null, patches, false);

            var commands3 = new CopyPasteCommands();
            var program3  = _pcgOs3.ProgramBanks[0][0];
            var patches3  = new ObservableCollectionEx <IPatch>()
            {
                program3
            };

            banks.Add(program3.Parent as IBank);

            program3.Clear();
            program3.IsSelected = true;
            Assert.AreNotEqual(program2.Name, program3.Name);

            commands3.CopyPastePaste(clipBoard, _pcgOs3, PcgViewModel.ScopeSet.Patches, true,
                                     false, false, false, false, false, false,
                                     banks, patches3);
            Assert.AreEqual(program2.Name, program3.Name);
        }
Exemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cutPasteAction"></param>
 private void CopyPasteCopyWaveSequences(bool cutPasteAction)
 {
     if (SelectedScopeSet == PcgViewModel.ScopeSet.Banks)
     {
         foreach (var waveSequence in from IWaveSequenceBank bank in Banks.Where(bank => bank.IsSelected)
                  where bank.Type != BankType.EType.Gm
                  from IWaveSequence waveSequence in bank.Patches
                  where bank.IsLoaded
                  // Also copy INIT wave sequences (for copying single INIT wave sequences)
                  select waveSequence)
         {
             // Always copy wave sequences.
             PcgClipBoard.CopyWaveSequenceToClipBoard(waveSequence, cutPasteAction);
         }
     }
     else
     {
         foreach (var waveSequence in Patches.Where(patch => patch.IsSelected).Cast <IWaveSequence>())
         {
             // Always copy wave sequences.
             PcgClipBoard.CopyWaveSequenceToClipBoard(waveSequence, cutPasteAction);
         }
     }
 }
Exemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cutPasteAction"></param>
 private void CopyPasteCopyDrumPatterns(bool cutPasteAction)
 {
     if (SelectedScopeSet == PcgViewModel.ScopeSet.Banks)
     {
         foreach (var drumPattern in from IDrumPatternBank bank in Banks.Where(bank => bank.IsSelected)
                  where bank.Type != BankType.EType.Gm
                  from IDrumPattern drumPattern in bank.Patches
                  where bank.IsLoaded
                  // Also copy INIT drum patterns (for copying single INIT programs)
                  select drumPattern)
         {
             // Always copy drum patterns.
             PcgClipBoard.CopyDrumPatternToClipBoard(drumPattern, cutPasteAction);
         }
     }
     else
     {
         foreach (var drumPattern in Patches.Where(patch => patch.IsSelected).Cast <IDrumPattern>())
         {
             // Always copy drum patterns.
             PcgClipBoard.CopyDrumPatternToClipBoard(drumPattern, cutPasteAction);
         }
     }
 }
Exemplo n.º 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cutPasteAction"></param>
 private void CopyPasteCopyPrograms(bool cutPasteAction)
 {
     if (SelectedScopeSet == PcgViewModel.ScopeSet.Banks)
     {
         foreach (var program in from IProgramBank bank in Banks.Where(bank => bank.IsSelected)
                  where bank.Type != BankType.EType.Gm
                  from IProgram program in bank.Patches
                  where bank.IsLoaded
                  // Also copy INIT programs (for copying single INIT programs)
                  select program)
         {
             // Always copy programs.
             PcgClipBoard.CopyProgramToClipBoard(program, cutPasteAction);
         }
     }
     else
     {
         foreach (var program in Patches.Where(patch => patch.IsSelected).Cast <IProgram>())
         {
             // Always copy programs.
             PcgClipBoard.CopyProgramToClipBoard(program, cutPasteAction);
         }
     }
 }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cutPasteAction"></param>
        private void CopyPasteCopyPatches(bool cutPasteAction)
        {
            if (ProgramBanksSelected)
            {
                CopyPasteCopyPrograms(cutPasteAction);
            }
            else if (CombiBanksSelected)
            {
                CopyPasteCopyCombis(cutPasteAction);
            }
            else if (SetListsSelected)
            {
                CopyPasteCopySetLists(cutPasteAction);
            }
            else if (DrumKitBanksSelected)
            {
                CopyPasteCopyDrumKits(cutPasteAction);
            }
            else if (DrumPatternBanksSelected)
            {
                CopyPasteCopyDrumPatterns(cutPasteAction);
            }
            else if (WaveSequenceBanksSelected)
            {
                CopyPasteCopyWaveSequences(cutPasteAction);
            }
            else if (AllPatchesSelected)
            {
                // Copy programs.
                foreach (var program in Patches.Where(patch => patch.IsSelected && (patch is IProgram)))
                {
                    // Always copy programs.
                    PcgClipBoard.CopyProgramToClipBoard(program as IProgram, cutPasteAction);
                }

                // Copy combis.
                foreach (var combi in Patches.Where(
                             patch => patch.IsSelected && (patch is ICombi)).Where(
                             combi =>
                             cutPasteAction || Settings.Default.CopyPaste_CopyIncompleteCombis || ((ICombi)combi).IsCompleteInPcg))
                {
                    PcgClipBoard.CopyCombiToClipBoard(combi as ICombi, cutPasteAction);
                }

                // Copy set list slots.
                foreach (var setListSlot in Patches.Where(patch => patch.IsSelected && (patch is ISetListSlot)).Where(
                             (setListSlot => cutPasteAction ||
                              Settings.Default.CopyPaste_CopyIncompleteSetListSlots ||
                              ((ISetListSlot)setListSlot).IsCompleteInPcg)))
                {
                    PcgClipBoard.CopySetListSlotToClipBoard(setListSlot as ISetListSlot, cutPasteAction);
                }
                // Copy drum kits.
                foreach (var drumKit in Patches.Where(patch => patch.IsSelected && (patch is IDrumKit)))
                {
                    // Always copy drum kits.
                    PcgClipBoard.CopyDrumKitToClipBoard(drumKit as IDrumKit, cutPasteAction);
                }

                // Copy drum patterns.
                foreach (var drumPattern in Patches.Where(patch => patch.IsSelected && (patch is IDrumPattern)))
                {
                    // Always copy patterns.
                    PcgClipBoard.CopyDrumPatternToClipBoard(drumPattern as IDrumPattern, cutPasteAction);
                }

                // Copy wave sequences.
                foreach (var waveSequence in Patches.Where(patch => patch.IsSelected && (patch is IWaveSequence)))
                {
                    // Always copy wave sequences.
                    PcgClipBoard.CopyWaveSequenceToClipBoard(waveSequence as IWaveSequence, cutPasteAction);
                }
            }
        }