Esempio n. 1
0
        private void Vm_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            BoreIntervalVM vm = sender as BoreIntervalVM;

            switch (e.PropertyName)
            {
            case nameof(vm.LowerDepth):
            case nameof(vm.UpperDepth):
                effectiveActivateIntervalImagesCommand.RaiseCanExecuteChanged();
                break;
            }
        }
Esempio n. 2
0
        private void Initialize()
        {
            effectiveActivateIntervalImagesCommand = new DelegateCommand(obj =>
            {
                //activating the command that are set externally
                ActivateIntervalImagesCommand.Execute(obj);
                ///now performing additional actions
                MessageBox.Show("Геологи!!! Разметка фотографии начинается с верхнего фрагмента керна!", "Направление разметки фото", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                PhotoCalibratedBoreIntervalVM vm = obj as PhotoCalibratedBoreIntervalVM;
                if (vm.ImagesCount == 0)
                {
                    vm.AddNewImageCommand.Execute(null);
                }
            }, obj =>
            {
                //checking extrernally set conditions
                bool externalCanExecute = ActivateIntervalImagesCommand.CanExecute(obj);
                //checking local conditions
                PhotoCalibratedBoreIntervalVM vm = obj as PhotoCalibratedBoreIntervalVM;
                return(externalCanExecute && !double.IsNaN(vm.UpperDepth) && !double.IsNaN(vm.LowerDepth) && (vm.LowerDepth > vm.UpperDepth));
            }
                                                                         );

            intervals.CollectionChanged += Intervals_CollectionChanged;

            Intervals.Add(new PhotoCalibratedBoreIntervalVM(imageStorage));

            AddNewCommand = new DelegateCommand(() =>
            {
                Intervals.Add(new PhotoCalibratedBoreIntervalVM(imageStorage));
            });

            RemoveIntervalCommand = new DelegateCommand((arg) =>
            {
                BoreIntervalVM biVM = arg as BoreIntervalVM;

                if (!(double.IsNaN(biVM.UpperDepth) || double.IsNaN(biVM.LowerDepth)))
                {
                    var result = MessageBox.Show(string.Format("Вы уверены, что хотите идалить интервал отбора {0} - {1}? Ассоциированные с ним фотографии керна будут удалены из проекта.", biVM.UpperDepth, biVM.LowerDepth), "Удаление интервала отбора", MessageBoxButton.OKCancel, MessageBoxImage.Question);
                    if (result == MessageBoxResult.OK)
                    {
                        //System.Diagnostics.Debug.WriteLine("delete "+arg.ToString()+" request");
                        Intervals.Remove(biVM);
                    }
                }
                else
                {
                    Intervals.Remove(biVM);
                }
            });
        }
Esempio n. 3
0
 private void Intervals_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     RaisePropertyChanged(nameof(HasIntervals));
     if (e.NewItems != null)
     {
         foreach (object obj in e.NewItems)
         {
             BoreIntervalVM vm = obj as BoreIntervalVM;
             vm.PropertyChanged += Vm_PropertyChanged;
         }
     }
     if (e.OldItems != null)
     {
         foreach (object obj in e.OldItems)
         {
             BoreIntervalVM vm = obj as BoreIntervalVM;
             vm.PropertyChanged -= Vm_PropertyChanged;
         }
     }
 }