Esempio n. 1
0
        private void RepeatLastPoint()
        {
            //Make sure there's a previous frame to repeat action from
            if (CurrentFrame == null || m_Frames == null)
            {
                return;
            }

            if (m_Frames.Count <= 1)
            {
                return;
            }

            if (FrameCounter == 0)
            {
                return;
            }

            MouseFrameViewModel lastFrame = m_Frames[FrameCounter - 1];

            WhiskerViewModel previousWhisker = lastFrame.Whiskers.FirstOrDefault(x => x.WhiskerId == SelectedWhisker.WhiskerId);

            if (previousWhisker == null)
            {
                return;
            }

            WhiskerPointViewModel previousPoint = previousWhisker.WhiskerPoints.FirstOrDefault(x => x.PointId == SelectedWhiskerPoint.PointId);

            if (previousPoint == null)
            {
                return;
            }

            AddUndoAction(SelectedWhiskerPoint.Clone());

            SelectedWhiskerPoint.XRatio = previousPoint.XRatio;
            SelectedWhiskerPoint.YRatio = previousPoint.YRatio;

            SelectedWhiskerPoint.CanvasWidth  = previousPoint.CanvasWidth;
            SelectedWhiskerPoint.CanvasHeight = previousPoint.CanvasHeight;

            NotifyPropertyChanged("Whiskers");

            if (AutoNextPoint)
            {
                IncreaseWhiskerCounter();
            }
        }
Esempio n. 2
0
        private void UndoLastAction()
        {
            if (m_UndoActions.Count == 0)
            {
                return;
            }

            WhiskerPointViewModel whiskerPoint = m_UndoActions.Last();

            if (whiskerPoint != null)
            {
                int whiskerId = whiskerPoint.Model.Parent.WhiskerId;
                int pointId   = whiskerPoint.Model.PointId;

                WhiskerViewModel whisker = Whiskers.Single(x => x.WhiskerId == whiskerId);

                if (whisker != null)
                {
                    WhiskerPointViewModel whiskerPointToReplace = whisker.WhiskerPoints.Single(x => x.PointId == pointId);

                    if (whiskerPointToReplace != null)
                    {
                        int index = whisker.WhiskerPoints.IndexOf(whiskerPointToReplace);

                        whisker.WhiskerPoints[index] = whiskerPoint;
                        RemoveUndoAction(whiskerPoint);

                        CreateWhiskerPointsList();
                        CreatePrevWhiskerPointsList();

                        //Need to re-select the Whisker and/or Whisker Point
                        SelectedWhisker      = whisker;
                        SelectedWhiskerPoint = whiskerPoint;
                    }
                }
            }
        }
Esempio n. 3
0
 public WhiskerPointViewModel(IWhiskerPoint model, WhiskerViewModel parent)
 {
     Model  = model;
     Parent = parent;
     GetColor();
 }