private void LoadProjectWithPersister(IProjectPersister persister)
        {
            vm.ActivePersister = persister;

            vm.CurrentProjectVM = persister.LoadProject();
            menuVM             = new ProjectMenuVM(vm.CurrentProjectVM);
            vm.ActiveSectionVM = menuVM;

            vm.CurrentProjectVM.BoreIntervalsVM.ActivateIntervalImagesCommand =
                new DelegateCommand(arg =>
            {
                Intervals.PhotoCalibratedBoreIntervalVM intervalVM = arg as Intervals.PhotoCalibratedBoreIntervalVM;
                vm.ActiveSectionVM = intervalVM;
            });


            menuVM.ActivateBoreIntervalsCommand = new DelegateCommand(() =>
            {
                vm.ActiveSectionVM = vm.CurrentProjectVM.BoreIntervalsVM;
            });

            menuVM.ExitAppCommand = ExitCommand;

            menuVM.SaveCommand = new DelegateCommand(() =>
            {
                vm.ActivePersister.SaveProject(vm.CurrentProjectVM);
                MessageBox.Show("Проект успешно сохранен", "Успешно", MessageBoxButton.OK, MessageBoxImage.Information);
            });

            menuVM.ActivateAnnotationPlaneCommand = this.ActivateAnnotationPlaneDelegateCommand;

            vm.CurrentProjectVM.PlaneColumnSettingsVM.ActivateAnnotationPlaneCommand = menuVM.ActivateAnnotationPlaneCommand;

            menuVM.ActivateReportGenerationCommand = ActivateReportGenerationDelegateCommand;
        }
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);
                }
            });
        }