Ejemplo n.º 1
0
        public bool Open(object ownerViewModel)
        {
            if (_isNew && !_isChanged)
            {
                FileDialogResult result = _dialogService.ShowOpenFileDialog(ownerViewModel, CogProjectFileType);
                if (result.IsValid && result.FileName != _settingsService.LastProject)
                {
                    string errorMsg   = null;
                    var    progressVM = new ProgressViewModel(vm =>
                    {
                        if (!OpenProject(vm, result.FileName, out errorMsg))
                        {
                            vm.Canceled = true;
                        }
                    }, true, false);
                    if (_dialogService.ShowModalDialog(ownerViewModel, progressVM) == false)
                    {
                        _dialogService.ShowError(ownerViewModel, errorMsg, "Cog");
                        return(false);
                    }
                    return(true);
                }
            }
            else
            {
                FileDialogResult result = _dialogService.ShowOpenFileDialog(ownerViewModel, CogProjectFileType);
                if (result.IsValid && result.FileName != _settingsService.LastProject)
                {
                    StartNewProcess(result.FileName, 5000);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public bool ExportSegmentFrequencies(object ownerViewModel, SyllablePosition syllablePosition)
        {
            FileDialogResult result = _dialogService.ShowSaveFileDialog(ownerViewModel, "Export Segment Frequencies", SegmentFrequenciesExporters.Keys);

            if (result.IsValid)
            {
                return(Export(ownerViewModel, result.FileName, stream => SegmentFrequenciesExporters[result.SelectedFileType].Export(stream, _projectService.Project, syllablePosition)));
            }
            return(false);
        }
Ejemplo n.º 3
0
        public bool ExportCognateSets(object ownerViewModel)
        {
            FileDialogResult result = _dialogService.ShowSaveFileDialog(ownerViewModel, "Export Cognate Sets", CognateSetsExporters.Keys);

            if (result.IsValid)
            {
                return(Export(ownerViewModel, result.FileName, stream => CognateSetsExporters[result.SelectedFileType].Export(stream, _projectService.Project)));
            }
            return(false);
        }
Ejemplo n.º 4
0
        public bool ExportSimilarityMatrix(object ownerViewModel, SimilarityMetric similarityMetric)
        {
            FileDialogResult result = _dialogService.ShowSaveFileDialog(ownerViewModel, "Export Similarity Matrix", SimilarityMatrixExporters.Keys);

            if (result.IsValid)
            {
                return(Export(ownerViewModel, result.FileName, stream => SimilarityMatrixExporters[result.SelectedFileType].Export(stream, _projectService.Project, similarityMetric)));
            }
            return(false);
        }
Ejemplo n.º 5
0
        public bool ExportVarietyPair(object ownerViewModel, VarietyPair varietyPair)
        {
            FileDialogResult result = _dialogService.ShowSaveFileDialog(ownerViewModel, "Export Variety Pair", VarietyPairExporters.Keys);

            if (result.IsValid)
            {
                return(Export(ownerViewModel, result.FileName, stream => VarietyPairExporters[result.SelectedFileType].Export(stream,
                                                                                                                              _projectService.Project.WordAligners[ComponentIdentifiers.PrimaryWordAligner], varietyPair)));
            }
            return(false);
        }
Ejemplo n.º 6
0
        public bool SaveAs(object ownerViewModel)
        {
            FileDialogResult result = _dialogService.ShowSaveFileDialog(ownerViewModel, CogProjectFileType);

            if (result.IsValid)
            {
                SaveAsProject(result.FileName);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 7
0
        public bool ImportGeographicRegions(object ownerViewModel)
        {
            FileDialogResult result = _dialogService.ShowOpenFileDialog(ownerViewModel, "Import Regions", GeographicRegionsImporters.Keys);

            if (result.IsValid)
            {
                IGeographicRegionsImporter importer = GeographicRegionsImporters[result.SelectedFileType];
                if (Import(importer, ownerViewModel, result.FileName, (importSettingsViewModel, stream) => importer.Import(importSettingsViewModel, stream, _projectService.Project)))
                {
                    Messenger.Default.Send(new DomainModelChangedMessage(false));
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 8
0
        public bool ImportWordLists(object ownerViewModel)
        {
            FileDialogResult result = _dialogService.ShowOpenFileDialog(ownerViewModel, "Import Word Lists", WordListsImporters.Keys);

            if (result.IsValid)
            {
                IWordListsImporter importer = WordListsImporters[result.SelectedFileType];
                if (Import(importer, ownerViewModel, result.FileName, (importSettingsViewModel, stream) => importer.Import(importSettingsViewModel, stream, _projectService.Project)))
                {
                    _analysisService.SegmentAll();
                    Messenger.Default.Send(new DomainModelChangedMessage(true));
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 9
0
        public bool ImportSegmentMappings(object ownerViewModel, out IEnumerable <Tuple <string, string> > mappings)
        {
            FileDialogResult result = _dialogService.ShowOpenFileDialog(ownerViewModel, "Import Correspondences", SegmentMappingsImporters.Keys);

            if (result.IsValid)
            {
                ISegmentMappingsImporter importer = SegmentMappingsImporters[result.SelectedFileType];
                IEnumerable <Tuple <string, string> > importedMappings = null;
                if (Import(importer, ownerViewModel, result.FileName, (importSettingsViewModel, stream) => importedMappings = importer.Import(importSettingsViewModel, stream)))
                {
                    mappings = importedMappings;
                    return(true);
                }
            }
            mappings = null;
            return(false);
        }