예제 #1
0
        private async void Paste(Avalonia.Point dominoPoint, PointerReleasedEventArgs e)
        {
            bool pasteFailed = true;

            try
            {
                if (!(CurrentProject is ICopyPasteable))
                {
                    await Errorhandler.RaiseMessage(_("Copy/Paste is not supported in this project."), _("Paste"), Errorhandler.MessageType.Warning);
                }
                // find closest domino
                int domino = FindDominoAtPosition(dominoPoint, int.MaxValue).idx;
                if (PossiblePastePositions.Contains(domino))
                {
                    PasteFilter paste = new PasteFilter(CurrentProject as ICopyPasteable, startindex, toCopy.ToArray(), domino);
                    paste.Apply();
                    undoStack.Push(paste);
                    pasteFailed = false;
                    if (e.KeyModifiers != KeyModifiers.Control)
                    {
                        SelectionTool.Select(paste.paste_target, true);
                    }
                }
            }
            catch (InvalidOperationException ex)
            {
                await Errorhandler.RaiseMessage(ex.Message, _("Error"), Errorhandler.MessageType.Error);
            }
            finally
            {
                FinalizePaste(e.KeyModifiers != KeyModifiers.Control && !pasteFailed);
            }
        }
예제 #2
0
 private void Paste()
 {
     try
     {
         if (!(CurrentProject is ICopyPasteable))
         {
             Errorhandler.RaiseMessage("Could not paste in this project.", "Paste", Errorhandler.MessageType.Warning);
         }
         if (selectedDominoes.Count == 0)
         {
             return;
         }
         int pasteindex = selectedDominoes.First();
         RemoveFromSelectedDominoes(pasteindex);
         ClearFullSelection(true);
         PasteFilter paste = new PasteFilter(CurrentProject as ICopyPasteable, startindex, toCopy.ToArray(), pasteindex);
         paste.Apply();
         undoStack.Push(paste);
         DisplaySettingsTool.ClearPastePositions();
         UpdateUIElements();
     }
     catch (InvalidOperationException ex)
     {
         Errorhandler.RaiseMessage(ex.Message, "Error", Errorhandler.MessageType.Error);
     }
 }
예제 #3
0
        public static void CopyPasteFieldTest(StructureParameters s)
        {
            int[] source_area = new int[100];
            int   start       = 33;
            int   end         = 459 + 126 * 10;

            for (int j = 0; j < 100; j++)
            {
                source_area[j] = start + j;
            }
            PasteFilter paste = new PasteFilter(s, start, source_area, end);

            paste.Apply();
            s.Generate().GenerateImage().Save("tests/StructureFilterTests/nachPaste.png");
            paste.Undo();
            s.Generate().GenerateImage().Save("tests/StructureFilterTests/nachPasteUndo.png");
        }
예제 #4
0
        public static void CopyPasteFieldTest(FieldParameters fp)
        {
            int[] source_area = new int[400];
            int   startx      = 20;
            int   starty      = 20;
            int   target_x    = 30;
            int   target_y    = 30;

            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 20; j++)
                {
                    source_area[j * 20 + i] = fp.current_width * (j + starty) + (startx + i);
                }
            }
            PasteFilter paste = new PasteFilter(fp, fp.current_width * starty + startx, source_area, fp.current_width * target_y + target_x);

            paste.Apply();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachPaste.png");
            paste.Undo();
            fp.Generate().GenerateImage().Save("tests/FilterTests/nachPasteUndo.png");
        }