예제 #1
0
        private void AttachHandlersToRegionVM(CalibratedRegionVM crCM)
        {
            crCM.RemoveCommand = new DelegateCommand((obj) =>
            {
                int idx = (int)obj;

                var mbResult = MessageBox.Show("Удалить отмеченный участок керна?", "Подтверждение удаления участка", MessageBoxButton.YesNo, MessageBoxImage.Question);
                switch (mbResult)
                {
                case MessageBoxResult.Yes:
                    RemoveRegionByIndex(idx);
                    break;

                case MessageBoxResult.No:
                    break;

                default: throw new NotImplementedException();
                }
            });

            crCM.PropertyChanged += CalibratedRegion_PropertyChanged;

            crCM.MoveUp             = delComUp;
            crCM.MoveDown           = delComDown;
            crCM.FocusToNextCommand = focusToNext;
        }
예제 #2
0
        public void MoveRegionOrder(int regionToMove, OrderMoveDirection direction)
        {
            int addition = (direction == OrderMoveDirection.Up) ? (-1) : 1;
            int toSwapWithIdx = regionToMove + addition;
            CalibratedRegionVM toSwapWith = null, target = null;

            foreach (CalibratedRegionVM vm in imageRegions.SelectMany(im => im))
            {
                if (vm.Order == regionToMove)
                {
                    target = vm;
                }
                else if (vm.Order == toSwapWithIdx)
                {
                    toSwapWith = vm;
                }
            }

            target.Order     = toSwapWithIdx;
            toSwapWith.Order = regionToMove;
            System.Diagnostics.Debug.WriteLine("swapped {0} and {1}", toSwapWithIdx, regionToMove);
            RecalculateRegionProperties();
            target.RaiseCanMoveChanged();
            toSwapWith.RaiseCanMoveChanged();
        }
        private void CalibratedRegion_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            CalibratedRegionVM vm = sender as CalibratedRegionVM;

            if (vm != null)
            {
                switch (e.PropertyName)
                {
                case nameof(vm.Length):
                    RaisePropertyChanged(nameof(AnnotatedLength));
                    RaisePropertyChanged(nameof(AnnotatedPercentage));
                    break;

                case nameof(vm.Order):
                    RecalculateRegionProperties();
                    break;
                }
            }
        }