private async Task LoadScriptAsync(string scriptFilename)
        {
            IItemFilterScriptViewModel loadedViewModel;

            Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
            try
            {
                loadedViewModel = await _itemFilterScriptRepository.LoadScriptFromFileAsync(scriptFilename);
            }
            catch (IOException e)
            {
                Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
                if (_logger.IsErrorEnabled)
                {
                    _logger.Error(e);
                }
                _messageBoxService.Show("Script Load Error", "Error loading filter script - " + e.Message,
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                return;
            }

            Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
            _avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
        }
Example #2
0
        private void OnOpenScriptCommand()
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter           = "Filter Files (*.filter)|*.filter|All Files (*.*)|*.*",
                InitialDirectory = _itemFilterScriptRepository.GetItemFilterScriptDirectory()
            };

            if (openFileDialog.ShowDialog() != true)
            {
                return;
            }

            IItemFilterScriptViewModel loadedViewModel;

            try
            {
                loadedViewModel = _itemFilterScriptRepository.LoadScriptFromFile(openFileDialog.FileName);
            }
            catch (IOException e)
            {
                if (_logger.IsErrorEnabled)
                {
                    _logger.Error(e);
                }
                _messageBoxService.Show("Script Load Error", "Error loading filter script - " + e.Message,
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                return;
            }

            _avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
        }