Пример #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
        public async void AddColumn(bool addRight, int index = -1, IDominoShape colorReference = null)
        {
            var selected = GetSelectedDominoes();

            try
            {
                if (selected.Count > 0 || index != -1)
                {
                    int selDomino = selected.Count > 0 ? selected.First() : index;
                    int color     = (colorReference ?? dominoTransfer[selDomino]).Color;
                    if (CurrentProject is IRowColumnAddableDeletable)
                    {
                        AddColumns addRows = new AddColumns((CurrentProject as IRowColumnAddableDeletable), selDomino, 1, color, addRight);
                        ClearCanvas();
                        ExecuteOperation(addRows);

                        RecreateCanvasViewModel();
                        SelectionTool.Select(addRows.added_indizes, true);
                        UpdateUIElements();
                        DisplaySettingsTool.SliceImage();
                    }
                    else
                    {
                        await Errorhandler.RaiseMessage(_("Adding columns is not supported in this project."), _("Add Row"), Errorhandler.MessageType.Warning);
                    }
                }
            }
            catch (InvalidOperationException ex)
            {
                await Errorhandler.RaiseMessage(ex.Message, _("Error"), Errorhandler.MessageType.Error);
            }
        }
Пример #3
0
        private void SelectAllStonesWithColor()
        {
            if (SelectedColor == null)
            {
                return;
            }
            var        selectedIndex = CurrentProject.colors.RepresentionForCalculation.ToList().IndexOf(SelectedColor.DominoColor);
            bool       isAnySelected = false;
            List <int> AllWithColor  = new List <int>();
            List <int> Deselect      = new List <int>();

            foreach (var d in Dominoes)
            {
                if (d.State == EditingDominoStates.Selected)
                {
                    isAnySelected = true;
                    if (d.domino.Color != selectedIndex)
                    {
                        Deselect.Add(d.idx);
                    }
                }
                if (d.domino.Color == selectedIndex)
                {
                    AllWithColor.Add(d.idx);
                }
            }
            if (isAnySelected)
            {
                SelectionTool.Select(Deselect, false);
            }
            else
            {
                SelectionTool.Select(AllWithColor, true);
            }
            UpdateUIElements();
        }
Пример #4
0
        internal void ClearFullSelection(bool undoable = false)
        {
            var selected = GetSelectedDominoes();

            if (undoable)
            {
                SelectionTool.Select(selected, false);
            }
            else
            {
                foreach (int i in selected.ToArray())
                {
                    RemoveFromSelectedDominoes(i);
                }
                while (undoStack.Count > 0 && undoStack.Peek() is SelectionOperation)
                {
                    undoStack.Pop();
                }
            }
            selectedColors = new int[CurrentProject.colors.Length];
            UpdateUIElements();
            SelectionTool.CurrentSelectionDomain.ResetSelectionArea();
            RefreshColorAmount();
        }
Пример #5
0
 private void SelectAll()
 {
     SelectionTool.Select(Enumerable.Range(0, dominoTransfer.Length).ToList(), true);
     UpdateUIElements();
 }