Generate() public method

/// contains invalid path characters. ///
public Generate ( string location ) : GenerationResult
location string
return GenerationResult
Ejemplo n.º 1
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (project != null)
            {
                ValidateSettings();

                // Initialize the dialog that will contain the progress bar
                ProgressDialog progressDialog = new ProgressDialog();

                // Set the dialog to operate in indeterminate mode
                progressDialog.SetIndeterminate(true);

                SolutionType  solutionType  = (SolutionType)cboSolutionType.SelectedIndex;
                DotNetVersion dotNetVersion = (DotNetVersion)cboTargetFrameworkVersion.SelectedIndex;
                string        destination   = txtDestination.Text;

                try
                {
                    Generator        generator = new Generator(project, solutionType, dotNetVersion);
                    GenerationResult result    = new GenerationResult();

                    Thread backgroundThread = new Thread(
                        new ThreadStart(() =>
                    {
                        result = generator.Generate(destination);

                        // Close the dialog if it hasn't been already
                        if (progressDialog.InvokeRequired)
                        {
                            progressDialog.BeginInvoke(new Action(() => progressDialog.Close()));
                        }
                    }));

                    result = CheckDestination(destination);

                    if (result == GenerationResult.Success)
                    {
                        // Start the background process thread
                        backgroundThread.Start();

                        // Open the dialog
                        progressDialog.ShowDialog();
                    }

                    if (result == GenerationResult.Success)
                    {
                        MessageBox.Show(Strings.CodeGenerationCompleted,
                                        Strings.CodeGeneration, MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                    else if (result == GenerationResult.Error)
                    {
                        MessageBox.Show(Strings.CodeGenerationFailed,
                                        Strings.Error, MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else // Cancelled
                    {
                        this.DialogResult = DialogResult.None;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Strings.UnknownError,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 2
0
		private void btnGenerate_Click(object sender, EventArgs e)
		{
			if (project != null)
			{
				ValidateSettings();

				try
				{
					SolutionType solutionType = (SolutionType) cboSolutionType.SelectedIndex;
					Generator generator = new Generator(project, solutionType);
					string destination = txtDestination.Text;

					GenerationResult result = generator.Generate(destination);
					if (result == GenerationResult.Success)
					{
						MessageBox.Show(Strings.CodeGenerationCompleted,
							Strings.CodeGeneration, MessageBoxButtons.OK,
							MessageBoxIcon.Information);
					}
					else if (result == GenerationResult.Error)
					{
						MessageBox.Show(Strings.CodeGenerationFailed,
							Strings.Error, MessageBoxButtons.OK,
							MessageBoxIcon.Error);
					}
					else // Cancelled
					{
						this.DialogResult = DialogResult.None;
					}
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message, Strings.UnknownError,
						MessageBoxButtons.OK, MessageBoxIcon.Error);
				}
			}
		}