Ejemplo n.º 1
0
        public async void ExecuteCopyTemplateCommand()
        {
            try
            {
                var t = (TemplateDialogViewModel)Templates.CurrentItem;
                if ((await DialogService.Ask("Copy Template?", $"Copy template \"{t.Name}?\"", AskButton.OKCancel)) ==
                    AskResult.OK)
                {
                    var vm = Container.Resolve <TemplateDialogViewModel>();
                    vm.CopyFrom(t);
                    vm.IsInternal = false;
                    vm.Add(_templatesSource.Select(t2 => t2.Name));
                    if (DialogService.ShowDialog(vm))
                    {
                        _templatesSource.Add(vm);
                        Templates.MoveCurrentTo(vm);

                        _templateService.SaveTemplates(_localTemplateFolder, _templatesSource.Select(t3 => new Template(t3)));

                        RefreshFrameworksFilter();
                    }
                }
            }
            catch
            {
                // ignored
            }
        }
 private bool SaveChangeIfNeeded()
 {
     if (Root != null && Root.MainItems.IsDirty)
     {
         if (DialogService.Ask("Имеются изменения!\nСохранить?") == InternalDialogResult.OK)
         {
             return(true);
         }
     }
     return(false);
 }
 protected override void ClosingUserControl(CancelEventArgs cansel)
 {
     if (DialogService.Ask("Закрыть программу?") == InternalDialogResult.OK)
     {
         DeActivate();
     }
     else
     {
         cansel.Cancel = true;
     }
 }
        public async void ExecuteDeleteChoiceCommand()
        {
            var vs = (StringViewModel)Choices?.CurrentItem;

            if ((await DialogService.Ask("Delete Choice?", $"Delete choice \"{vs?.Value}?\"", AskButton.OKCancel)) ==
                AskResult.OK)
            {
                Choices?.Remove(Choices.CurrentItem);
                _choicesChanged = true;
                OkCommand.RaiseCanExecuteChanged();
            }
        }
Ejemplo n.º 5
0
 public async void ExecuteDeleteViewSuffixCommand()
 {
     try
     {
         var vs = (StringViewModel)ViewSuffixesView?.CurrentItem;
         if ((await DialogService.Ask("Delete View Suffix?", $"Delete view suffix \"{vs?.Value}?\"", AskButton.OKCancel)) == AskResult.OK)
         {
             ViewSuffixesView?.Remove(ViewSuffixesView.CurrentItem);
         }
     }
     catch (Exception)
     {
         // ignored
     }
 }
Ejemplo n.º 6
0
        public async void ExecuteDeleteFieldCommand()
        {
            var vm = (FieldDialogViewModel)Fields.CurrentItem;

            if ((await DialogService.Ask("Delete Field?", $"Delete field \"{vm.Name}?\"", AskButton.OKCancel)) == AskResult.OK)
            {
                if ((await DialogService.Ask("Are you sure?", $"Are you sure you want to DELETE field \"{vm.Name}?\"", AskButton.OKCancel)) == AskResult.OK)
                {
                    var source = (ObservableCollection <FieldDialogViewModel>)Fields.SourceCollection;
                    source.Remove(vm);
                    Fields.MoveCurrentTo(vm);
                    _fieldsChanged = true;
                    OkCommand.RaiseCanExecuteChanged();
                    ResetFieldValuesForAllBuffers();
                }
            }
        }
        private void ImportPageData()
        {
            if (Root != null && !(Root.CurrentItem is WellboreGridViewModel))
            {
                DialogService.Message("Импорт профиля невозможен! Необходимо выбрать ствол!");
                return;
            }

            WellboreGridViewModel currentwelWellboreGridViewModel = Root.CurrentItem as WellboreGridViewModel;

            if (currentwelWellboreGridViewModel.ChildItems.Count > 0)
            {
                if (DialogService.Ask(String.Format("Данные профиля по стволу \"{0}\"\nбудут удалены.\nПродолжить?", currentwelWellboreGridViewModel.Name)) != InternalDialogResult.OK)
                {
                    return;
                }
            }

            string filePath = DialogService.OpenFileDialog("Excel Files(*.xls;*.xlsx)|*.xls;*.xlsx");

            if (String.IsNullOrEmpty(filePath))
            {
                return;
            }

            try
            {
                List <ProfilePathPoint> profilePaths = ImportService.GetProfilePaths(filePath);
                FixFirstRow(profilePaths);
                currentwelWellboreGridViewModel.ChildItems.Clear();
                List <ProfilePathGridViewModel> profilePathGridViewModels = Mapper.Map(profilePaths, new List <ProfilePathGridViewModel>());
                currentwelWellboreGridViewModel.ChildItems.AddRange(profilePathGridViewModels);
            }
            catch (RangeNotFoundException e)
            {
                DialogService.Message(e.Message);
            }
        }
Ejemplo n.º 8
0
        public async void ExecuteDeleteTemplateCommand()
        {
            try
            {
                var t = (TemplateDialogViewModel)Templates.CurrentItem;
                if ((await DialogService.Ask("Delete Template?", $"Delete template \"{t.Name}?\"", AskButton.OKCancel)) ==
                    AskResult.OK)
                {
                    if ((await DialogService.Ask("Are you sure?", $"Are you sure you want to DELETE template \"{t.Name}?\"",
                                                 AskButton.OKCancel)) == AskResult.OK)
                    {
                        Templates.Remove(Templates.CurrentItem);

                        _templateService.SaveTemplates(_localTemplateFolder, _templatesSource.Select(t2 => new Template(t2)));

                        RefreshFrameworksFilter();
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
Ejemplo n.º 9
0
 protected async Task <bool> ConfirmDiscard()
 {
     return(await DialogService.Ask("Discard Changes?", "Cancel dialog?  You will lose any changes.",
                                    AskButton.OKCancel) == AskResult.OK);
 }