Beispiel #1
0
        private void CreateProject_SelectTestFolderButton_Click(object sender, EventArgs e)
        {
            using (var dialog = DialogEx.SelectFolder())
            {
                var result = dialog.ShowDialog();

                if (result == CommonFileDialogResult.Ok)
                {
                    _projectCreateInfoPlainText.TestDataPath = dialog.FileName;

                    RefreshUI();
                }
            }
        }
Beispiel #2
0
        private void CreateProject_UEFXML_CreateProjectButton_Click(object sender, EventArgs e)
        {
            using (var dialog = DialogEx.SelectFolder())
            {
                var result = dialog.ShowDialog();

                if (result == CommonFileDialogResult.Ok)
                {
                    var projectPath = dialog.FileName;

                    if (Directory.GetFiles(projectPath, "*", SearchOption.AllDirectories).Length > 0)
                    {
                        MessageBox.Show("Directory must be empty.", "Error");

                        return;
                    }

                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            using (var progress = _progressFactory.NewInstance("Creating and saving project..."))
                            {
                                var project = WsdProject.CreateAndSave(
                                    _projectCreateInfoUEFXML, projectPath, progress);

                                this.InvokeIfRequired(() =>
                                {
                                    RefreshUI();
                                    AddProjectTab(project);
                                });
                            }
                        }
                        catch (OperationCanceledException)
                        {
                            this.InvokeIfRequired(RefreshUI);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString(), "Error");
                        }
                    }, TaskCreationOptions.LongRunning);
                }
            }
        }
        private void GenerateData_GenerateDataButton_Click(object sender, EventArgs e)
        {
            var generationInfoValidationResult = _generationInfo.Validate();

            if (generationInfoValidationResult != ValidationResult.Success)
            {
                MessageBox.Show(
                    string.Join(" ", generationInfoValidationResult.Errors.Select(x => x.ErrorMessage)),
                    "Error");

                return;
            }

            if (!_project.HasMeaningEmbeddings &&
                _generationInfo.FeatureGroups
                .Any(x => x.Elements
                     .Any(y => y is MeaningEmbeddingElement)))
            {
                MessageBox.Show(
                    "Current project does not include meaning embeddings. " +
                    "Please remove all MeaningEmbedding elements or load a different project.",
                    "Error");

                return;
            }

            using (var dialog = DialogEx.SelectFolder())
            {
                var result = dialog.ShowDialog();

                if (result == CommonFileDialogResult.Ok)
                {
                    _generationInfo.DestinationFolder = dialog.FileName;

                    if (Directory.GetFiles(dialog.FileName, "*", SearchOption.AllDirectories).Length > 0)
                    {
                        MessageBox.Show("Directory must be empty.", "Error");

                        return;
                    }

                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            using (var progress = _progressFactory.NewInstance("Generating data..."))
                            {
                                new DataGenerator(_pluginComponents)
                                .Generate(_project, _generationInfo, progress);

                                this.InvokeIfRequired(() => RefreshUI());
                            }

                            if (Directory.Exists(dialog.FileName))
                            {
                                Process.Start(dialog.FileName);
                            }
                        }
                        catch (OperationCanceledException)
                        {
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString(), "Error");
                        }
                    }, TaskCreationOptions.LongRunning);
                }
            }
        }